diff --git a/.gitignore b/.gitignore index 9bdfbc71632719..3e87dcc4334ee0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,18 @@ venv/ +.clang-format .DS_Store .tags .ipynb_checkpoints .idea +.overlay_init +.overlay_consistent .sconsign.dblite +.vscode* model2.png a.out +.hypothesis +*.dylib *.DSYM *.d *.pyc @@ -14,7 +20,11 @@ a.out .*.swp .*.swo .*.un~ +*.tmp *.o +*.o-* +*.os +*.os-* *.so *.a *.clb @@ -23,21 +33,52 @@ a.out *.vcd config.json clcache +compile_commands.json +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 +selfdrive/ui/_ui +selfdrive/test/longitudinal_maneuvers/out selfdrive/visiond/visiond selfdrive/loggerd/loggerd -selfdrive/sensord/gpsd -selfdrive/sensord/sensord +selfdrive/loggerd/bootlog +selfdrive/sensord/_gpsd +selfdrive/sensord/_sensord +selfdrive/camerad/camerad +selfdrive/camerad/test/ae_gray_test +selfdrive/modeld/_modeld +selfdrive/modeld/_dmonitoringmodeld /src/ one openpilot +notebooks xx +yy +hyperthneed +panda_jungle +provisioning +.coverage* +coverage.xml +htmlcov +pandaextra + +.mypy_cache/ +flycheck_* + +cppcheck_report.txt +comma*.sh + +selfdrive/modeld/thneed/compile +models/*.thneed + +*.bz2 + +build/ + +!**/.gitkeep 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/.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 deleted file mode 100644 index 738679aca5d5e6..00000000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,31 +0,0 @@ -# How to contribute - -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/) - -## Getting Started - - * Join our [Discord](https://discord.comma.ai) - * Make sure you have a [GitHub account](https://github.com/signup/free) - * Fork [our repositories](https://github.com/commaai) on GitHub - -## Testing - -### Local Testing - -You can test your changes on your machine by running `run_docker_tests.sh`. This will run some automated tests in docker against your code. - -### Automated Testing - -All PRs are automatically checked by travis. Check out `.travis.yml` for what travis runs. Any new tests sould be added to travis. - -### Code Style and Linting - -Code is automatically check for style by travis as part of the automated tests. You can also run these yourself by running `check_code_quality.sh`. - -## Car Ports (openpilot) - -We've released a [Model Port guide](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) for porting to Toyota/Lexus models. - -If you port openpilot to a substantially new car brand, see this more generic [Brand Port guide](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84). You might also be eligible for a bounty. See our bounties at [comma.ai/bounties.html](https://comma.ai/bounties.html) diff --git a/Dockerfile.openpilot b/Dockerfile.openpilot deleted file mode 100644 index edf6d478607cd7..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 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 - -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..d12c8e4946b56b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,243 @@ +def phone(String ip, String step_label, String cmd) { + withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) { + def ssh_cmd = """ +ssh -tt -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'END' + +set -e + +export CI=1 +export TEST_DIR=${env.TEST_DIR} +export SOURCE_DIR=${env.SOURCE_DIR} +export GIT_BRANCH=${env.GIT_BRANCH} +export GIT_COMMIT=${env.GIT_COMMIT} + +source ~/.bash_profile +if [ -f /TICI ]; then + source /etc/profile +fi + +ln -snf ${env.TEST_DIR} /data/pythonpath + +if [ -f /EON ]; then + echo \$\$ > /dev/cpuset/app/tasks || true + echo \$PPID > /dev/cpuset/app/tasks || true + mkdir -p /dev/shm + chmod 777 /dev/shm +fi + +cd ${env.TEST_DIR} || true +${cmd} +exit 0 + +END""" + + sh script: ssh_cmd, label: step_label + } +} + +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, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) + steps.each { item -> + phone(device_ip, item[0], item[1]) + } + } + } +} + +pipeline { + agent none + environment { + TEST_DIR = "/data/openpilot" + SOURCE_DIR = "/data/openpilot_source/" + } + options { + timeout(time: 4, unit: 'HOURS') + } + + stages { + stage('build releases') { + when { + branch 'devel-staging' + } + + parallel { + stage('release2') { + agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } } + steps { + phone_steps("eon-build", [ + ["build release2-staging & dashcam-staging", "PUSH=1 $SOURCE_DIR/release/build_release.sh"], + ]) + } + } + + stage('release3') { + agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } } + steps { + phone_steps("tici", [ + ["build release3-staging & dashcam3-staging", "PUSH=1 $SOURCE_DIR/release/build_release.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 'release3'; branch 'release3-staging'; branch 'dashcam3'; branch 'dashcam3-staging'; + branch 'testing-closet*'; branch 'hotfix-*' + } + } + } + + stages { + stage('On-device Tests') { + agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } } + stages { + stage('parallel tests') { + parallel { + stage('C2: build') { + steps { + phone_steps("eon-build", [ + ["build master-ci", "cd $SOURCE_DIR/release && EXTRA_FILES='tools/' ./build_devel.sh"], + ["build openpilot", "cd selfdrive/manager && ./build.py"], + ["test manager", "python selfdrive/manager/test/test_manager.py"], + ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"], + ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"], + ]) + } + } + + stage('C2: replay') { + steps { + phone_steps("eon2", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"], + ]) + } + } + + stage('C2: HW + Unit Tests') { + steps { + phone_steps("eon", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test sounds", "python selfdrive/ui/tests/test_soundd.py"], + ["test boardd loopback", "python selfdrive/boardd/tests/test_boardd_loopback.py"], + ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"], + ["test encoder", "python selfdrive/loggerd/tests/test_encoder.py"], + ["test logcatd", "python selfdrive/logcatd/tests/test_logcatd_android.py"], + ["test updater", "python selfdrive/hardware/eon/test_neos_updater.py"], + ]) + } + } + + /* + stage('Power Consumption Tests') { + steps { + lock(resource: "", label: "c2-zookeeper", inversePrecedence: true, variable: 'device_ip', quantity: 1) { + timeout(time: 90, unit: 'MINUTES') { + sh script: "/home/batman/tools/zookeeper/enable_and_wait.py $device_ip 120", label: "turn on device" + phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) + phone(device_ip, "build", "scons -j4 && sync") + sh script: "/home/batman/tools/zookeeper/disable.py $device_ip", label: "turn off device" + sh script: "/home/batman/tools/zookeeper/enable_and_wait.py $device_ip 120", label: "turn on device" + sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 3", label: "idle power consumption after boot" + sh script: "/home/batman/tools/zookeeper/ignition.py 1", label: "go onroad" + sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 10", label: "onroad power consumption" + sh script: "/home/batman/tools/zookeeper/ignition.py 0", label: "go offroad" + sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 2", label: "idle power consumption offroad" + } + } + } + } + */ + + stage('C3: build') { + environment { + R3_PUSH = "${env.BRANCH_NAME == 'master' ? '1' : ' '}" + } + steps { + phone_steps("tici", [ + ["build master-ci", "cd $SOURCE_DIR/release && EXTRA_FILES='tools/' ./build_devel.sh"], + ["build openpilot", "cd selfdrive/manager && ./build.py"], + ["test manager", "python selfdrive/manager/test/test_manager.py"], + ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"], + ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"], + ]) + } + } + + stage('C3: HW + Unit Tests') { + steps { + phone_steps("tici2", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test boardd loopback", "python selfdrive/boardd/tests/test_boardd_loopback.py"], + ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"], + ["test encoder", "LD_LIBRARY_PATH=/usr/local/lib python selfdrive/loggerd/tests/test_encoder.py"], + ]) + } + } + + stage('C2: camerad') { + steps { + phone_steps("eon-party", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test camerad", "python selfdrive/camerad/test/test_camerad.py"], + ["test exposure", "python selfdrive/camerad/test/test_exposure.py"], + ]) + } + } + + stage('C3: camerad') { + steps { + phone_steps("tici-party", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test camerad", "python selfdrive/camerad/test/test_camerad.py"], + ["test exposure", "python selfdrive/camerad/test/test_exposure.py"], + ]) + } + } + + stage('C3: replay') { + steps { + phone_steps("tici-party", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"], + ]) + } + } + + } + } + + stage('Push master-ci') { + when { + branch 'master' + } + steps { + phone_steps("eon-build", [ + ["push devel", "cd $SOURCE_DIR/release && PUSH='master-ci' ./build_devel.sh"], + ]) + } + } + + } + + 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 614968710c9606..00000000000000 --- a/Pipfile +++ /dev/null @@ -1,140 +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 = "*" - -[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 e4623df10afb4c..00000000000000 --- a/Pipfile.lock +++ /dev/null @@ -1,2810 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "72c6a6eac19abf85ca5f272d04761f8336150d5bec599423c4b16891c99cb0bf" - }, - "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 < '3.2'", - "version": "==1.5" - }, - "certifi": { - "hashes": [ - "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", - "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" - ], - "version": "==2019.3.9" - }, - "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:0afa0b121b89de619e71587e25702e2b7068d7da2164c47e6eee80c17823a62f", - "sha256:1c608ba76f7a20cc9f0c021b7fe5cb04bc1a70327ae93a9298b1bc3e0edddebe", - "sha256:26229570d6787ff3caa932fe9d802960f51a89239b990d275ae845405ce43857", - "sha256:2a9deafa437b6154cac2f25bb88e0bfd075a897c8dc847669d6f478d7e3ee6b1", - "sha256:2f28396fbce6d9d68a40edbf49a6729cf9d92a4d39ff0f501947a89188e9099f", - "sha256:3983dd7b67297db299b403b29b328d9e03e14c4c590ea90aa1ad1d7b35fb178b", - "sha256:4100a3f8e8bbe47d499cdac00e56d5fe750f739701ea52dc049b6c56f5421d97", - "sha256:51abfaa7b6c66f3f18028876713c8804e73d4c2b6ceddbcbcfa8ec62429377f0", - "sha256:61c24f4554efdb8fb1ac6c8e75dab301bcdf2b7b739ed0c2b267493bb43163c5", - "sha256:700ccf921b2fdc9b23910e95b5caae4b35767685e0812343fa7172409f1b5830", - "sha256:7b41eb2e792822a790cb2a171df49d1a9e0baaa8e81f58077b7380a273b93d5f", - "sha256:803987d3b16d55faa997bfc12e8b97f1091f145930dee229b020487aed8a1f44", - "sha256:99af5cfcd208c81998dcf44b3ca466dee7e17453cfb50e98b87947c3a86f8753", - "sha256:9faea1cca34501c7e139bc7ef8e504d532b77865c58592493e2c154a003b450f", - "sha256:a7ba4c9a174db841cfee9a0b92563862a0301d7ca543334666c7266b541f141a", - "sha256:b26071c2313d1880599c69fd831a07b32a8c961ba69d7ccbe5db1cd8d319a4ca", - "sha256:b49dc8e1116abde13a3e6a9eb8da6ab292c5a3325155fb872e39011b110b37e6", - "sha256:bd40def0fd013569887008baa6da9ca428e3d7247adeeaeada153006227bb2e7", - "sha256:bfd0db770e8bd4e044e20298dcae6dfc42561f85d17ee546dcd978c8b23066ae", - "sha256:c2fad1efae5889925c8fd7867fdd61f59480e4e0b510f9db096c912e884704f1", - "sha256:c81aea93d526ccf6bc0b842c91216ee9867cd8792f6725a00f19c8b5837e1715", - "sha256:da786e039b4ad2bce3d53d4799438cf1f5e01a0108f1b8d78ac08e6627281b1a", - "sha256:deab85a069397540987082d251e9c89e0e5b2e3e044014344ff81f60e211fc4b", - "sha256:e3f1e6224c3407beb1849bdc5ae3150929e593e4cffff6ca41c6ec2b10942c80", - "sha256:e74eb224e53aae3943d66e2d29fe42322d5753fd4c0641329bccb7efb3a46552", - "sha256:ee697c7ea65cb14915a64f36874da8ffc2123df43cf8bc952172e04a26656cd6", - "sha256:f37792b16d11606c28e428460bd6a3d14b8917b109e77cdbe4ca78b0b9a52c87", - "sha256:fd2906b54cbf879c09d875ad4e4687c58d87f5ed03496063fec1c9065569fd5d" - ], - "index": "pypi", - "version": "==0.29.10" - }, - "enum34": { - "hashes": [ - "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", - "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", - "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", - "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" - ], - "markers": "python_version < '3'", - "version": "==1.1.6" - }, - "flask": { - "hashes": [ - "sha256:ad7c6d841e64296b962296c2c2dabc6543752985727af86a975072dea984b6f3", - "sha256:e7d32475d1de5facaa55e3958bc4ec66d3762076b074296aa50ef8fdc5b9df61" - ], - "index": "pypi", - "version": "==1.0.3" - }, - "futures": { - "hashes": [ - "sha256:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265", - "sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1" - ], - "markers": "python_version < '3.2'", - "version": "==3.2.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:c40744b6bc5162bbb39c1257fe298b7a393861d50978b565f3ccd9cb9de0182a", - "sha256:f57abacd059dc3bd666258d1efb0377510a89777fda3e3274e3c01f7c03ae22d" - ], - "version": "==4.3.20" - }, - "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:02c2b6d268695a8b64ad61847f92e611e6afcff33fd26c3a2125370c4662905d", - "sha256:ee1e85575587c5b58ddafa25e1c1b01691ef172e139fc25585e5d3f02451da93" - ], - "index": "pypi", - "version": "==1.9.4" - }, - "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:1651e52ed91f0736afd6d94ef9f3259b5534ce8beddb054f3d5ca989c4ef7c4f", - "sha256:5ccb9b3d4cd20c000a9b75689d5add8cd3bce67fcbd0f8ae1b59345247d803af", - "sha256:5e120c4cd3872e332fb35d255ad5998ebcee32ace4387b1b337416b6b90436c7", - "sha256:5e2a3707c69a7281a9957f83718815fd74698cba31f6d69f9ed359921f662221", - "sha256:63d51add9af8d0442dc90f916baf98fdc04e3b0a32afec4bfc83f8d85e72959f", - "sha256:65c5a0bdc49e20f7d6b03a661f71e2fda7a99c51270cafe71598146d09810d0d", - "sha256:66828fabe911aa545d919028441a585edb7c9c77969a5fea6722ef6e6ece38ab", - "sha256:7d79427e82d9dad6e9b47c0b3e7ae5f9d489b1601e3a36ea629bb49501a4daf3", - "sha256:824ee5d3078c4eae737ffc500fbf32f2b14e6ec89b26b435b7834febd70120cf", - "sha256:89dc0a83cccec19ff3c62c091e43e66e0183d1e6b4658c16ee4e659518131494", - "sha256:8b319805f6f7c907b101c864c3ca6cefc9db8ce0791356f180b1b644c7347e4c", - "sha256:90facfb379ab47f94b19519c1ecc8ec8d10813b69d9c163117944948bdec5d15", - "sha256:a0a178c7420021fc0730180a914a4b4b3092ce9696ceb8e72d0f60f8ce1655dd", - "sha256:a7a89591ae315baccb8072f216614b3e59aed7385aef4393a6c741783d6ee9cf", - "sha256:ba2578f0ae582452c02ed9fac2dc477b08e80ce05d2c0885becf5fff6651ccb0", - "sha256:c69b0055c55702f5b0b6b354133e8325b9a56dbc80e1be2d240bead253fb9825", - "sha256:ca434e1858fe222380221ddeb81e86f45522773344c9da63c311d17161df5e06", - "sha256:d4b8ecfc3d92f114f04d5c40f60a65e5196198b827503341521dda12d8b14939", - "sha256:d706025c47b09a54f005953ebe206f6d07a22516776faa4f509aaff681cc5468", - "sha256:d8f27e958f8a2c0c8ffd4d8855c3ce8ac3fa1e105f0491ce31729aa2b3229740", - "sha256:dbd264298f76b9060ce537008eb989317ca787c857e23cbd1b3ddf89f190a9b1", - "sha256:e926d66f0df8fdbf03ba20583af0f215e475c667fb033d45fd031c66c63e34c9", - "sha256:efc3bd48237f973a749f7312f68062f1b4ca5c2032a0673ca3ea8e46aa77187b", - "sha256:f59bc782228777cbfe04555707a9c56d269c787ed25d6d28ed9d0fbb41cb1ad2", - "sha256:f8da5322f4ff5f667a0d5a27e871b560c6637153c81e318b35cb012b2a98835c" - ], - "index": "pypi", - "version": "==18.0.1" - }, - "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:0a860bf2683fdbb4812fe539a6c22ea3f1777843ea985cb8c3807db448a0f7ab", - "sha256:e288416eecd4df19d12407d0c913cbf77aa8009d7fddb18f632aded3bdbdda6b" - ], - "index": "pypi", - "version": "==4.32.1" - }, - "urllib3": { - "hashes": [ - "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", - "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" - ], - "index": "pypi", - "version": "==1.25.3" - }, - "utm": { - "hashes": [ - "sha256:a6608a67df84418fd959a79b228b90ab55b2ae877827f9c210947104c5a75d0e" - ], - "index": "pypi", - "version": "==0.4.2" - }, - "websocket-client": { - "hashes": [ - "sha256:1151d5fb3a62dc129164292e1227655e4bbc5dd5340a5165dfae61128ec50aa9", - "sha256:1fd5520878b68b84b5748bb30e592b10d0a91529d5383f74f4964e72b297fd3a" - ], - "index": "pypi", - "version": "==0.56.0" - }, - "werkzeug": { - "hashes": [ - "sha256:865856ebb55c4dcd0630cdd8f3331a1847a819dda7e8c750d3db6f2aa6c0209c", - "sha256:a0b915f0815982fb2a09161cb8f31708052d0951c3ba433ccc5e1aa276507ca6" - ], - "version": "==0.15.4" - }, - "wrapt": { - "hashes": [ - "sha256:4aea003270831cceb8a90ff27c4031da6ead7ec1886023b80ce0dfe0adf61533" - ], - "version": "==1.11.1" - } - }, - "develop": { - "absl-py": { - "hashes": [ - "sha256:b943d1c567743ed0455878fcd60bc28ac9fae38d129d1ccfad58079da00b8951" - ], - "version": "==0.7.1" - }, - "adal": { - "hashes": [ - "sha256:82e84fa0b442caf8131f1e87a7ebee2546f57ab16a8917a599a02b6e455cb1b0", - "sha256:b6edd095be66561382bdaa59d40b04490e93149fb3b7fa44c1fa5504eed5b8b9" - ], - "version": "==1.2.1" - }, - "aenum": { - "hashes": [ - "sha256:3df9b84cce5dc9ed77c337079f97b66c44c0053eb87d6f4d46b888dc45801e38", - "sha256:7a77c205c4bc9d7fe9bd73b3193002d724aebf5909fa0d297534208953891ec8", - "sha256:a3208e4b28db3a7b232ff69b934aef2ea1bf27286d9978e1e597d46f490e4687" - ], - "index": "pypi", - "version": "==2.1.2" - }, - "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 < '3.2'", - "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:794a9a4b6a9e40c1ac57a377de609872d28d62afe4295c48cdc1b1c92f96ab8e", - "sha256:962b078568cc520869ea2842f307864c9abc30ad5ed160e12b2a89debf220161" - ], - "index": "pypi", - "version": "==1.9.168" - }, - "botocore": { - "hashes": [ - "sha256:675f2b66af486dd02f5825601bb0c8378773999f8705c6f75450849ca41fed80", - "sha256:c3fc314c0e0aa13aa024d272d991e23d37550050abf96b3c7dea889ed1743723" - ], - "version": "==1.12.168" - }, - "celery": { - "hashes": [ - "sha256:4c4532aa683f170f40bd76f928b70bc06ff171a959e06e71bf35f2f9d6031ef9", - "sha256:528e56767ae7e43a16cfef24ee1062491f5754368d38fcfffa861cdb9ef219be" - ], - "index": "pypi", - "version": "==4.3.0" - }, - "certifi": { - "hashes": [ - "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", - "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" - ], - "version": "==2019.3.9" - }, - "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:0afa0b121b89de619e71587e25702e2b7068d7da2164c47e6eee80c17823a62f", - "sha256:1c608ba76f7a20cc9f0c021b7fe5cb04bc1a70327ae93a9298b1bc3e0edddebe", - "sha256:26229570d6787ff3caa932fe9d802960f51a89239b990d275ae845405ce43857", - "sha256:2a9deafa437b6154cac2f25bb88e0bfd075a897c8dc847669d6f478d7e3ee6b1", - "sha256:2f28396fbce6d9d68a40edbf49a6729cf9d92a4d39ff0f501947a89188e9099f", - "sha256:3983dd7b67297db299b403b29b328d9e03e14c4c590ea90aa1ad1d7b35fb178b", - "sha256:4100a3f8e8bbe47d499cdac00e56d5fe750f739701ea52dc049b6c56f5421d97", - "sha256:51abfaa7b6c66f3f18028876713c8804e73d4c2b6ceddbcbcfa8ec62429377f0", - "sha256:61c24f4554efdb8fb1ac6c8e75dab301bcdf2b7b739ed0c2b267493bb43163c5", - "sha256:700ccf921b2fdc9b23910e95b5caae4b35767685e0812343fa7172409f1b5830", - "sha256:7b41eb2e792822a790cb2a171df49d1a9e0baaa8e81f58077b7380a273b93d5f", - "sha256:803987d3b16d55faa997bfc12e8b97f1091f145930dee229b020487aed8a1f44", - "sha256:99af5cfcd208c81998dcf44b3ca466dee7e17453cfb50e98b87947c3a86f8753", - "sha256:9faea1cca34501c7e139bc7ef8e504d532b77865c58592493e2c154a003b450f", - "sha256:a7ba4c9a174db841cfee9a0b92563862a0301d7ca543334666c7266b541f141a", - "sha256:b26071c2313d1880599c69fd831a07b32a8c961ba69d7ccbe5db1cd8d319a4ca", - "sha256:b49dc8e1116abde13a3e6a9eb8da6ab292c5a3325155fb872e39011b110b37e6", - "sha256:bd40def0fd013569887008baa6da9ca428e3d7247adeeaeada153006227bb2e7", - "sha256:bfd0db770e8bd4e044e20298dcae6dfc42561f85d17ee546dcd978c8b23066ae", - "sha256:c2fad1efae5889925c8fd7867fdd61f59480e4e0b510f9db096c912e884704f1", - "sha256:c81aea93d526ccf6bc0b842c91216ee9867cd8792f6725a00f19c8b5837e1715", - "sha256:da786e039b4ad2bce3d53d4799438cf1f5e01a0108f1b8d78ac08e6627281b1a", - "sha256:deab85a069397540987082d251e9c89e0e5b2e3e044014344ff81f60e211fc4b", - "sha256:e3f1e6224c3407beb1849bdc5ae3150929e593e4cffff6ca41c6ec2b10942c80", - "sha256:e74eb224e53aae3943d66e2d29fe42322d5753fd4c0641329bccb7efb3a46552", - "sha256:ee697c7ea65cb14915a64f36874da8ffc2123df43cf8bc952172e04a26656cd6", - "sha256:f37792b16d11606c28e428460bd6a3d14b8917b109e77cdbe4ca78b0b9a52c87", - "sha256:fd2906b54cbf879c09d875ad4e4687c58d87f5ed03496063fec1c9065569fd5d" - ], - "index": "pypi", - "version": "==0.29.10" - }, - "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:ad7c6d841e64296b962296c2c2dabc6543752985727af86a975072dea984b6f3", - "sha256:e7d32475d1de5facaa55e3958bc4ec66d3762076b074296aa50ef8fdc5b9df61" - ], - "index": "pypi", - "version": "==1.0.3" - }, - "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:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265", - "sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1" - ], - "markers": "python_version < '3.2'", - "version": "==3.2.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:0232add03144dd3cf9b660e2718244cb8e175370dca4d3855cb4e489a7811b53", - "sha256:0f20e6dcb1b8662cdca033bb97c0a8116a5343e3ebc7f71c5fe7f89039978350", - "sha256:10b07a623d33d4966f45c85d410bc6a79c5ac6341f06c3beda6c22be12cbfe07", - "sha256:10c0476d5a52d21f402fc073745dc43b87cc8e080a1f49bbff4e1059019310fb", - "sha256:289dae0b35c59d191c524e976dd0a6f8c995d2062e72621eb866ad0f4472a635", - "sha256:2be726f16142d358a0df1e81d583d6820ee561a7856a79cca2fbe49989308be7", - "sha256:4338d2a81f5b4ca022e085040b3cfce19419a5ce44aa7e6810ac1df05365bed7", - "sha256:4c535b46f20e66bee3097583231977e721acdfcb1671d1490c99b7be8902ce18", - "sha256:557154aef70a0e979700cc9528bc8b606b668084a29a0d57dbc4b06b078a2f1c", - "sha256:5bfdd7e6647498f979dc46583723c852d97b25afe995d55aa1c76a5f9816bc1f", - "sha256:87d8943ae7aa6ca5bbad732867d7f17d2550e4966a0c15b52088e8b579422e47", - "sha256:89d8719d8de4d137678f7caa979e1b0a6fd4026f8096ceef8c2d164bbabefaf2", - "sha256:9c3f4af989ce860710ac1864dc2e867dd87e6cee51a2368df1b253596868e52f", - "sha256:9da52c3c728883aee429bb7c315049f50b2139f680cd86bb1165418e4f93a982", - "sha256:9e9736659987beab42d18525ed10d21f80a1ba8389eac03425fbfd5684e6bbf0", - "sha256:9ebcbb1a054cab362d29d3be571d43d6b9b23302d9fc4b43e5327000da1680a9", - "sha256:a93e08636623e24c939851e2e0c0140b14f524b2980c9cdc4ea52b70a871c7e0", - "sha256:ac322d86d1a079e0a118d544443ee16f320af0062c191b4754c0c6ec2fc79310", - "sha256:b1fb101459868f52df6b61e7bb13375e50badf17a160e39fe1d51ae19e53f461", - "sha256:b39aac96cceac624a23d540473835086a3ffa77c91030189988c073488434493", - "sha256:b65507bc273c6dbf539175a786a344cc0ac78d50e5584f72c6599733f8a3301f", - "sha256:be5bb6e47417e537c884a2e2ff2e1a8b2c064a998fcfdfcc67528d4e63e7ebaf", - "sha256:c92de6a28a909c4f460dc1bbbcb50d676cf0b1f40224b222761f73fdd851b522", - "sha256:c9f5962eb7fa7607b20eb0e4f59ed35829bd600fc0eacb626a6db83229a3e445", - "sha256:d00bdf9c546ed6e649f785c55b05288e8b2dbb6bf2eb74b6c579fa0d591d35bd", - "sha256:da804b1dd8293bd9d61b1e6ea989c887ba042a808a4fbdd80001cfa059aafed2", - "sha256:ead6c5aa3e807345913649c3be395aaca2bbb2d225f18b8f31f37eab225508f6", - "sha256:eb4d81550ce6f826af4ec6e8d98be347fe96291d718bf115c3f254621ae8d98d", - "sha256:ef6a18ec8fd32ec81748fe720544ea2fb2d2dc50fd6d06739d5e2eb8f0626a1c", - "sha256:fad42835656e0b6d3b7ffc900598e776722e30f43b7234a48f2576ca30f31a47", - "sha256:fb98dbfee0d963b49ae5754554028cf62e6bd695f22de16d242ba9d2f0b7339b", - "sha256:fb9cd9bb8d26dc17c2dd715a46bca3a879ec8283879b164e85863110dc6e3b2a" - ], - "version": "==1.21.1" - }, - "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:0f2b5cde9f272cb49d52f3f0889fdd1a7ae1e74f37b48dac35a83152780d2b7b", - "sha256:a3e224f430163f767047ab9a042fc55adbcab0c24bbe6cf9f306c4f89fdf0ba3" - ], - "version": "==7.4.2" - }, - "isodate": { - "hashes": [ - "sha256:2e364a3d5759479cdb2d37cce6b9376ea504db2ff90252a2e5b7cc89cc9ff2d8", - "sha256:aa4d33c06640f5352aca96e4b81afd8ab3b47337cc12089822d6f322ac772c81" - ], - "version": "==0.6.0" - }, - "isort": { - "hashes": [ - "sha256:c40744b6bc5162bbb39c1257fe298b7a393861d50978b565f3ccd9cb9de0182a", - "sha256:f57abacd059dc3bd666258d1efb0377510a89777fda3e3274e3c01f7c03ae22d" - ], - "version": "==4.3.20" - }, - "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:b5f9cb06105c1d2d30719db5ffb3ea67da60919fb68deaefa583deccd8813551", - "sha256:c44411eb1463ed77548bc2d5ec0d744c9b81c4a542d9637c7a52824e2121b987" - ], - "version": "==5.2.4" - }, - "jupyter-console": { - "hashes": [ - "sha256:3f928b817fc82cda95e431eb4c2b5eb21be5c483c2b43f424761a966bb808094", - "sha256:545dedd3aaaa355148093c5609f0229aeb121b4852995c2accfa64fe3e0e55cd" - ], - "version": "==5.2.0" - }, - "jupyter-core": { - "hashes": [ - "sha256:927d713ffa616ea11972534411544589976b2493fc7e09ad946e010aa7eb9970", - "sha256:ba70754aa680300306c699790128f6fbd8c306ee5927976cbe48adacf240c0b7" - ], - "version": "==4.4.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:7cbadcf5d8a41e64ebd19157253f0357f2c46f289584c6f58fd38a19f7cc3509" - ], - "index": "pypi", - "version": "==0.2.1" - }, - "keras-preprocessing": { - "hashes": [ - "sha256:44aee5f2c4d80c3b29f208359fcb336df80f293a0bb6b1c738da43ca206656fb", - "sha256:5a8debe01d840de93d49e05ccf1c9b81ae30e210d34dacbcc47aeb3049b528e5" - ], - "version": "==1.1.0" - }, - "keras-resnet": { - "hashes": [ - "sha256:8ce27ba782d1b45b127af51208aefdceb2de8d2c54646bac5fc786506ce558c0" - ], - "version": "==0.2.0" - }, - "keras-retinanet": { - "hashes": [ - "sha256:257b77ca46c6846d8e9260e4eb1c77ab9b564c512bb5ebe23e72fc46b5c41899" - ], - "index": "pypi", - "version": "==0.5.0" - }, - "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:056a31cc95b10ca4eb0d4ebcba714007b1db1c6c45c8e2d139fe91933481b00b", - "sha256:af5b0f892b081f49d95c772a241fb7687f4cc3e42c94328f118dffb1f4e161e5" - ], - "version": "==4.6.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" - }, - "libarchive": { - "hashes": [ - "sha256:37e8cca1eb85d30583cdcffc58116d83abc09be7549d5d6c9ead563c0a8d7b04" - ], - "index": "pypi", - "version": "==0.4.6" - }, - "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.7'", - "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:05538c68251eb0c81bd2010524d8ff36d4266ec0669338fbdcecfd23c733231c", - "sha256:8143093308975f815f968b0d2a1ac8e26ba217eb6d03f3f27aac616aa3a25bd0" - ], - "version": "==0.6.7" - }, - "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:814efbe00988445b2c3f3d1944c9f296a556e2b14a060f7b25372881c2e497d4", - "sha256:8f085e26e60e9d9c0710748510d1c763c8f63905cb16df7658b35a2936e8ca2b" - ], - "index": "pypi", - "version": "==0.3.5" - }, - "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:0ce32c5d989a1827e3f1148f98b9085ed2370fc939bf524c9c851d8714797298", - "sha256:3e1e14f6cde7e5475128d30e97edc3bfb4dc857cb884d8714ec161fdbb3b358e" - ], - "version": "==3.0.1" - }, - "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" - }, - "pandocfilters": { - "hashes": [ - "sha256:b3dd70e169bb5449e6bc6ff96aea89c5eea8c5f6ab5e207fc2f521a2cf4a0da9" - ], - "version": "==1.4.2" - }, - "pathlib2": { - "hashes": [ - "sha256:25199318e8cc3c25dcb45cbe084cc061051336d5a9ea2a12448d3d8cb748f742", - "sha256:5887121d7f7df3603bca2f710e7219f3eca0eb69e0b7cc6e0a022e155ac931a7" - ], - "markers": "python_version in '2.6 2.7 3.2 3.3'", - "version": "==2.3.3" - }, - "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:15c056bfa284c30a7f265a41ac4cbbc93bdbfc0dfe0613b9cb8a8581b51a9e55", - "sha256:1a4e06ba4f74494ea0c58c24de2bb752818e9d504474ec95b0aa94f6b0a7e479", - "sha256:1c3c707c76be43c9e99cb7e3d5f1bee1c8e5be8b8a2a5eeee665efbf8ddde91a", - "sha256:1fd0b290203e3b0882d9605d807b03c0f47e3440f97824586c173eca0aadd99d", - "sha256:24114e4a6e1870c5a24b1da8f60d0ba77a0b4027907860188ea82bd3508c80eb", - "sha256:258d886a49b6b058cd7abb0ab4b2b85ce78669a857398e83e8b8e28b317b5abb", - "sha256:33c79b6dd6bc7f65079ab9ca5bebffb5f5d1141c689c9c6a7855776d1b09b7e8", - "sha256:367385fc797b2c31564c427430c7a8630db1a00bd040555dfc1d5c52e39fcd72", - "sha256:3c1884ff078fb8bf5f63d7d86921838b82ed4a7d0c027add773c2f38b3168754", - "sha256:44e5240e8f4f8861d748f2a58b3f04daadab5e22bfec896bf5434745f788f33f", - "sha256:46aa988e15f3ea72dddd81afe3839437b755fffddb5e173886f11460be909dce", - "sha256:74d90d499c9c736d52dd6d9b7221af5665b9c04f1767e35f5dd8694324bd4601", - "sha256:809c0a2ce9032cbcd7b5313f71af4bdc5c8c771cb86eb7559afd954cab82ebb5", - "sha256:85d1ef2cdafd5507c4221d201aaf62fc9276f8b0f71bd3933363e62a33abc734", - "sha256:8c3889c7681af77ecfa4431cd42a2885d093ecb811e81fbe5e203abc07e0995b", - "sha256:9218d81b9fca98d2c47d35d688a0cea0c42fd473159dfd5612dcb0483c63e40b", - "sha256:9aa4f3827992288edd37c9df345783a69ef58bd20cc02e64b36e44bcd157bbf1", - "sha256:9d80f44137a70b6f84c750d11019a3419f409c944526a95219bea0ac31f4dd91", - "sha256:b7ebd36128a2fe93991293f997e44be9286503c7530ace6a55b938b20be288d8", - "sha256:c4c78e2c71c257c136cdd43869fd3d5e34fc2162dc22e4a5406b0ebe86958239", - "sha256:c6a842537f887be1fe115d8abb5daa9bc8cc124e455ff995830cc785624a97af", - "sha256:cf0a2e040fdf5a6d95f4c286c6ef1df6b36c218b528c8a9158ec2452a804b9b8", - "sha256:cfd28aad6fc61f7a5d4ee556a997dc6e5555d9381d1390c00ecaf984d57e4232", - "sha256:dca5660e25932771460d4688ccbb515677caaf8595f3f3240ec16c117deff89a", - "sha256:de7aedc85918c2f887886442e50f52c1b93545606317956d65f342bd81cb4fc3", - "sha256:e6c0bbf8e277b74196e3140c35f9a1ae3eafd818f7f2d3a15819c49135d6c062" - ], - "version": "==6.0.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:ee0c90350595e4a9f36591f291e6f9933246ea67d7cd7d1d6139a9781b14eaae" - ], - "version": "==0.7.0" - }, - "prompt-toolkit": { - "hashes": [ - "sha256:1e71341526efa4b11bb44d323e687a5d9cef204aabe2907e3f0dc1534cda0ecc", - "sha256:955d81315bb7a049f19cd17d1a73f1a40861483260f7dffd825e98303a8bd6b6", - "sha256:c1cedd626e08b8ee830ee65897de754113ff3f3035880030c08b01674d85c5b4" - ], - "version": "==1.0.16" - }, - "protobuf": { - "hashes": [ - "sha256:03f43eac9d5b651f976e91cf46a25b75e5779d98f0f4114b0abfed83376d75f8", - "sha256:0c94b21e6de01362f91a86b372555d22a60b59708599ca9d5032ae9fdf8e3538", - "sha256:2d2a9f30f61f4063fadd7fb68a2510a6939b43c0d6ceeec5c4704f22225da28e", - "sha256:34a0b05fca061e4abb77dd180209f68d8637115ff319f51e28a6a9382d69853a", - "sha256:358710fd0db25372edcf1150fa691f48376a134a6c69ce29f38f185eea7699e6", - "sha256:41e47198b94c27ba05a08b4a95160656105745c462af574e4bcb0807164065c0", - "sha256:8c61cc8a76e9d381c665aecc5105fa0f1878cf7db8b5cd17202603bcb386d0fc", - "sha256:a6eebc4db759e58fdac02efcd3028b811effac881d8a5bad1996e4e8ee6acb47", - "sha256:a9c12f7c98093da0a46ba76ec40ace725daa1ac4038c41e4b1466afb5c45bb01", - "sha256:cb95068492ba0859b8c9e61fa8ba206a83c64e5d0916fb4543700b2e2b214115", - "sha256:cd98476ce7bb4dcd6a7b101f5eecdc073dafea19f311e36eb8fba1a349346277", - "sha256:ce64cfbea18c535176bdaa10ba740c0fc4c6d998a3f511c17bedb0ae4b3b167c", - "sha256:dcbb59eac73fd454e8f2c5fba9e3d3320fd4707ed6a9d3ea3717924a6f0903ea", - "sha256:dd67f34458ae716029e2a71ede998e9092493b62a519236ca52e3c5202096c87", - "sha256:e3c96056eb5b7284a20e256cb0bf783c8f36ad82a4ae5434a7b7cd02384144a7", - "sha256:f612d584d7a27e2f39e7b17878430a959c1bc09a74ba09db096b468558e5e126", - "sha256:f6de8a7d6122297b81566e5bd4df37fd5d62bec14f8f90ebff8ede1c9726cd0a", - "sha256:fa529d9261682b24c2aaa683667253175c9acebe0a31105394b221090da75832" - ], - "version": "==3.8.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:0f0cdfc7a92d4f2a5c44226162434e34f7d6967d3af416a6f1448649c09a25a4", - "sha256:10510a0016c862af467c6e069e051409f15f5831552bed03f5104b395a5d7dd1", - "sha256:208dd2c89e80d32a69397ba8a5cdb3bc0dc60f961a4f2a9662e5e1624dc799d1", - "sha256:6dc6ee5e7628400083471cba8044010860fe8b22e4dee05e42150a68047d7d9d", - "sha256:794bda39ea6fe434b6e1f58ab3bea9f0e6123fb43702fecd760eed6f1547b20a", - "sha256:dae7277e7c06da00947f3cd32c095b1e65eae09f07478ada4ea9dfa57020b646", - "sha256:eccea049aef47decc380746b3ff242d95636d578c907d0eab3b00918292d6c48" - ], - "index": "pypi", - "version": "==7.43.0.2" - }, - "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:02c2b6d268695a8b64ad61847f92e611e6afcff33fd26c3a2125370c4662905d", - "sha256:ee1e85575587c5b58ddafa25e1c1b01691ef172e139fc25585e5d3f02451da93" - ], - "index": "pypi", - "version": "==1.9.4" - }, - "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" - }, - "pyrsistent": { - "hashes": [ - "sha256:16692ee739d42cf5e39cef8d27649a8c1fdb7aa99887098f1460057c5eb75c3a" - ], - "version": "==0.15.2" - }, - "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:9e4e7109d05d80ce5414f13b16f66725c2b5d574099fd43d37b024e7ea1c4354", - "sha256:d3315d3f972bd9bd32e0738d45801a912f522177ff75094762f31a8c341d1f41" - ], - "version": "==3.8.1" - }, - "python-logstash": { - "hashes": [ - "sha256:10943e5df83f592b4d61b63ad1afff855ccc8c9467f78718f0a59809ba1fe68c" - ], - "index": "pypi", - "version": "==0.4.6" - }, - "python-socketio": { - "hashes": [ - "sha256:89a48591a8850c1f30d735f8e5a0294846da245a9b8940c39e1106e460c7a14e", - "sha256:c7ffeac3d81f2d8d63b3ec7ed1e2d4478cc84aa1da666c1934c19432f4b8c0f8" - ], - "version": "==4.1.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:1651e52ed91f0736afd6d94ef9f3259b5534ce8beddb054f3d5ca989c4ef7c4f", - "sha256:5ccb9b3d4cd20c000a9b75689d5add8cd3bce67fcbd0f8ae1b59345247d803af", - "sha256:5e120c4cd3872e332fb35d255ad5998ebcee32ace4387b1b337416b6b90436c7", - "sha256:5e2a3707c69a7281a9957f83718815fd74698cba31f6d69f9ed359921f662221", - "sha256:63d51add9af8d0442dc90f916baf98fdc04e3b0a32afec4bfc83f8d85e72959f", - "sha256:65c5a0bdc49e20f7d6b03a661f71e2fda7a99c51270cafe71598146d09810d0d", - "sha256:66828fabe911aa545d919028441a585edb7c9c77969a5fea6722ef6e6ece38ab", - "sha256:7d79427e82d9dad6e9b47c0b3e7ae5f9d489b1601e3a36ea629bb49501a4daf3", - "sha256:824ee5d3078c4eae737ffc500fbf32f2b14e6ec89b26b435b7834febd70120cf", - "sha256:89dc0a83cccec19ff3c62c091e43e66e0183d1e6b4658c16ee4e659518131494", - "sha256:8b319805f6f7c907b101c864c3ca6cefc9db8ce0791356f180b1b644c7347e4c", - "sha256:90facfb379ab47f94b19519c1ecc8ec8d10813b69d9c163117944948bdec5d15", - "sha256:a0a178c7420021fc0730180a914a4b4b3092ce9696ceb8e72d0f60f8ce1655dd", - "sha256:a7a89591ae315baccb8072f216614b3e59aed7385aef4393a6c741783d6ee9cf", - "sha256:ba2578f0ae582452c02ed9fac2dc477b08e80ce05d2c0885becf5fff6651ccb0", - "sha256:c69b0055c55702f5b0b6b354133e8325b9a56dbc80e1be2d240bead253fb9825", - "sha256:ca434e1858fe222380221ddeb81e86f45522773344c9da63c311d17161df5e06", - "sha256:d4b8ecfc3d92f114f04d5c40f60a65e5196198b827503341521dda12d8b14939", - "sha256:d706025c47b09a54f005953ebe206f6d07a22516776faa4f509aaff681cc5468", - "sha256:d8f27e958f8a2c0c8ffd4d8855c3ce8ac3fa1e105f0491ce31729aa2b3229740", - "sha256:dbd264298f76b9060ce537008eb989317ca787c857e23cbd1b3ddf89f190a9b1", - "sha256:e926d66f0df8fdbf03ba20583af0f215e475c667fb033d45fd031c66c63e34c9", - "sha256:efc3bd48237f973a749f7312f68062f1b4ca5c2032a0673ca3ea8e46aa77187b", - "sha256:f59bc782228777cbfe04555707a9c56d269c787ed25d6d28ed9d0fbb41cb1ad2", - "sha256:f8da5322f4ff5f667a0d5a27e871b560c6637153c81e318b35cb012b2a98835c" - ], - "index": "pypi", - "version": "==18.0.1" - }, - "qtconsole": { - "hashes": [ - "sha256:4af84facdd6f00a6b9b2927255f717bb23ae4b7a20ba1d9ef0a5a5a8dbe01ae2", - "sha256:60d61d93f7d67ba2b265c6d599d413ffec21202fec999a952f658ff3a73d252b" - ], - "version": "==4.5.1" - }, - "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" - }, - "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:a3289b9124e59aee1621d43b55cd1634468cb3212d09c5b0114a3183cc080cca", - "sha256:f768abc073e8702892718938b8a0ab98ebcb91c2afcb39bf2cb570d3eb51149e" - ], - "index": "pypi", - "version": "==4.0.3" - }, - "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:7cfdaa3e83e3532f31713713feb98be7ea9f3065722be4267e49b6c301271419" - ], - "version": "==1.13.0" - }, - "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:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", - "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", - "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" - ], - "markers": "python_version < '3.5'", - "version": "==3.6.6" - }, - "urllib3": { - "hashes": [ - "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", - "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" - ], - "index": "pypi", - "version": "==1.25.3" - }, - "utm": { - "hashes": [ - "sha256:a6608a67df84418fd959a79b228b90ab55b2ae877827f9c210947104c5a75d0e" - ], - "index": "pypi", - "version": "==0.4.2" - }, - "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:865856ebb55c4dcd0630cdd8f3331a1847a819dda7e8c750d3db6f2aa6c0209c", - "sha256:a0b915f0815982fb2a09161cb8f31708052d0951c3ba433ccc5e1aa276507ca6" - ], - "version": "==0.15.4" - }, - "wheel": { - "hashes": [ - "sha256:5e79117472686ac0c4aef5bad5172ea73a1c2d1646b808c35926bd26bdfb0c08", - "sha256:62fcfa03d45b5b722539ccbc07b190e4bfff4bb9e3a4d470dd9f6a0981002565" - ], - "markers": "python_version < '3'", - "version": "==0.33.4" - }, - "widgetsnbextension": { - "hashes": [ - "sha256:14b2c65f9940c9a7d3b70adbe713dbd38b5ec69724eebaba034d1036cf3d4740", - "sha256:fa618be8435447a017fd1bf2c7ae922d0428056cfc7449f7a8641edf76b48265" - ], - "version": "==3.4.2" - }, - "wrapt": { - "hashes": [ - "sha256:4aea003270831cceb8a90ff27c4031da6ead7ec1886023b80ce0dfe0adf61533" - ], - "version": "==1.11.1" - } - } -} diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 7a4825846f7daa..b012883d78428d --- a/README.md +++ b/README.md @@ -1,221 +1,124 @@ -[![](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/b0ZyIx5.jpg) Table of Contents ======================= -* [Community](#community) -* [Hardware](#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) -* [Testing on PC](#testing-on-pc) -* [Contributing](#contributing) +* [What is openpilot?](#what-is-openpilot) +* [Running in a car](#running-in-a-car) +* [Running on PC](#running-on-pc) +* [Community and Contributing](#community-and-contributing) +* [User Data and comma Account](#user-data-and-comma-account) +* [Safety and Testing](#safety-and-testing) +* [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](docs/CARS.md). In addition, while openpilot is engaged, a camera based Driver Monitoring (DM) feature alerts distracted and asleep drivers. See more about [the vehicle integration](docs/INTEGRATION.md) and [limitations](docs/LIMITATIONS.md). - - - - + + + + - - - - + + + +
-Hardware + +Running in a car ------ -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. +To use openpilot in a car, you need four things +* This software. It's free and available right here. +* One of [the 150+ supported cars](docs/CARS.md). We support Honda, Toyota, Hyundai, Nissan, Kia, Chrysler, Lexus, Acura, Audi, VW, and more. If your car is not supported, but has adaptive cruise control and lane keeping assist, it's likely able to run openpilot. +* A supported device to run this software. This can be a [comma two](https://comma.ai/shop/products/two), [comma three](https://comma.ai/shop/products/three), or if you like to experiment, a [Ubuntu computer with webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam). +* A way to connect to your car. With a comma two or three, you need only a [car harness](https://comma.ai/shop/products/car-harness). With an EON Gold or PC, you also need a [black panda](https://comma.ai/shop/products/panda). -Install openpilot on a neo device by entering ``https://openpilot.comma.ai`` during NEOS setup. +We have detailed instructions for [how to install the device in a car](https://comma.ai/setup). -Supported Cars +Running on PC ------ -| Make | Model | Supported Package | Lateral | Longitudinal | No Accel Below | No Steer Below | Giraffe | -| ---------------------| -------------------------| ---------------------| --------| ---------------| -----------------| ---------------|-------------------| -| Acura | ILX 2016-17 | AcuraWatch Plus | Yes | Yes | 25mph1| 25mph | Nidec | -| Acura | RDX 2018 | 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 2018 | 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 | 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 | SCC + LKAS | Yes | Stock | 19mph | 34mph | Custom6| -| Hyundai | Genesis 2018 | All | Yes | Stock | 19mph | 34mph | Custom6| -| Jeep | Grand Cherokee 2017-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 | Camry 2018 | All | Yes | Stock | 0mph5 | 0mph | Toyota | -| Toyota | C-HR 2017-18 | 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-18 | All | Yes | Yes2| 0mph | 0mph | Toyota | -| Toyota | Highlander Hybrid 2018 | 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 2017-18 | 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 ------- +All of openpilot's services can run as normal on a PC, even without special hardware or a car. To develop or experiment with openpilot you can run openpilot on recorded or simulated data. -| 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| +With openpilot's tools you can plot logs, replay drives and watch the full-res camera streams. See [the tools README](tools/README.md) for more information. -[[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)
+You can also run openpilot in simulation [with the CARLA simulator](tools/sim/README.md). This allows openpilot to drive around a virtual car on your Ubuntu machine. The whole setup should only take a few minutes, but does require a decent GPU. -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. -In Progress Cars +Community and Contributing ------ -- 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 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. Check out [the contributing docs](docs/CONTRIBUTING.md). + +Documentation related to openpilot development can be found on [docs.comma.ai](https://docs.comma.ai). Information about running openpilot (e.g. FAQ, fingerprinting, troubleshooting, custom forks, community hardware) should go on the [wiki](https://github.com/commaai/openpilot/wiki). + +You can add support for your car by following guides we have written for [Brand](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/) and [Model](https://blog.comma.ai/openpilot-port-guide-for-toyota-models/) 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). + +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 through [comma connect](https://connect.comma.ai/). 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. -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. +openpilot logs the road facing cameras, 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. -- 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. +By using openpilot, you agree to [our Privacy Policy](https://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. -Directory structure +Safety and Testing +---- + +* openpilot observes ISO26262 guidelines, see [SAFETY.md](docs/SAFETY.md) for more details. +* openpilot has software in the loop [tests](.github/workflows/selfdrive_tests.yaml) that run on every commit. +* The code enforcing the safety model 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 comma devices continuously replaying routes. + +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 + ├── docs # Documentation ├── 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 + ├── third_party # External libraries + ├── pyextra # Extra python packages └── 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 + ├── controls # Planning and controls ├── debug # Tools to help you debug and do car ports - ├── locationd # Soon to be home of precise location + ├── locationd # Precise localization and vehicle parameter estimation ├── 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 ------- - -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/) + ├── sensord # IMU interface code + ├── test # Unit tests, system tests, and a car simulator + └── ui # The UI Licensing ------ @@ -231,3 +134,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 f73b8daf83ebb8..5d4f114b84040a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,366 @@ +Version 0.8.12 (2021-12-15) +======================== + * New driving model + * Improved behavior around exits + * Better pose accuracy at high speeds, allowing max speed of 90mph + * Fully incorporated comma three data into all parts of training stack + * Improved follow distance + * Better longitudinal policy, especially in low speed traffic + * New alert sounds + * AGNOS 3 + * Display burn in mitigation + * Improved audio amplifier configuration + * System reliability improvements + * Update Python to 3.8.10 + * Raw logs upload moved to connect.comma.ai + * Fixed HUD alerts on newer Honda Bosch thanks to csouers! + * Audi Q3 2020-21 support thanks to jyoung8607! + * Lexus RC 2020 support thanks to ErichMoraga! + +Version 0.8.11 (2021-11-29) +======================== + * Support for CAN FD on the red panda + * Support for an external panda on the comma three + * Navigation: Show more detailed instructions when approaching maneuver + * Fixed occasional steering faults on GM cars thanks to jyoung8607! + * Nissan ECU firmware fingerprinting thanks to robin-reckmann, martinl, and razem-io! + * Cadillac Escalade ESV 2016 support thanks to Gibby! + * Genesis G70 2020 support thanks to tecandrew! + * Hyundai Santa Fe Hybrid 2022 support thanks to sunnyhaibin! + * Mazda CX-9 2021 support thanks to Jacar! + * Volkswagen Polo 2020 support thanks to jyoung8607! + * Volkswagen T-Roc 2021 support thanks to jyoung8607! + +Version 0.8.10 (2021-11-01) +======================== + * New driving model + * Trained on one million minutes!!! + * Fixed lead training making lead predictions significantly more accurate + * Fixed several localizer dataset bugs and loss function bugs, overall improved accuracy + * New driver monitoring model + * Trained on latest data from both comma two and comma three + * Increased model field of view by 40% on comma three + * Improved model stability on masked users + * Improved pose prediction with reworked ground-truth stack + * Lateral and longitudinal planning MPCs now in ACADOS + * Combined longitudinal MPCs + * All longitudinal planning now happens in a single MPC system + * Fixed instability in MPC problem to prevent sporadic CPU usage + * AGNOS 2: minor stability improvements and builder repo open sourced + * tools: new and improved replay thanks to deanlee! + * Moved community-supported cars outside of the Community Features toggle + * Improved FW fingerprinting reliability for Hyundai/Kia/Genesis + * Added prerequisites for longitudinal control on Hyundai/Kia/Genesis and Honda Bosch + * Audi S3 2015 support thanks to jyoung8607! + * Honda Freed 2020 support thanks to belm0! + * Hyundai Ioniq Hybrid 2020-2022 support thanks to sunnyhaibin! + * Hyundai Santa Fe 2022 support thanks to sunnyhaibin! + * Kia K5 2021 support thanks to sunnyhaibin! + * Å koda Kamiq 2021 support thanks to jyoung8607! + * Å koda Karoq 2019 support thanks to jyoung8607! + * Volkswagen Arteon 2021 support thanks to jyoung8607! + * Volkswagen California 2021 support thanks to jyoung8607! + * Volkswagen Taos 2022 support thanks to jyoung8607! + +Version 0.8.9 (2021-09-14) +======================== + * Improved fan control on comma three + * AGNOS 1.5: improved stability + * Honda e 2020 support + +Version 0.8.8 (2021-08-27) +======================== + * New driving model with improved laneless performance + * Trained on 5000+ hours of diverse driving data from 3000+ users in 40+ countries + * Better anti-cheating methods during simulator training ensure the model hugs less when in laneless mode + * All new desire ground-truthing stack makes the model better at lane changes + * New driver monitoring model: improved performance on comma three + * NEOS 18 for comma two: update packages + * AGNOS 1.3 for comma three: fix display init at high temperatures + * Improved auto-exposure on comma three + * Improved longitudinal control on Honda Nidec cars + * Hyundai Kona Hybrid 2020 support thanks to haram-KONA! + * Hyundai Sonata Hybrid 2021 support thanks to Matt-Wash-Burn! + * Kia Niro Hybrid 2021 support thanks to tetious! + +Version 0.8.7 (2021-07-31) +======================== + * comma three support! + * Navigation alpha for the comma three! + * Volkswagen T-Cross 2021 support thanks to jyoung8607! + +Version 0.8.6 (2021-07-21) +======================== + * Revamp lateral and longitudinal planners + * Refactor planner output API to be more readable and verbose + * Planners now output desired trajectories for speed, acceleration, curvature, and curvature rate + * Use MPC for longitudinal planning when no lead car is present, makes accel and decel smoother + * Remove "CHECK DRIVER FACE VISIBILITY" warning + * Fixed cruise fault on some TSS2.5 Camrys and international Toyotas + * Hyundai Elantra Hybrid 2021 support thanks to tecandrew! + * Hyundai Ioniq PHEV 2020 support thanks to YawWashout! + * Kia Niro Hybrid 2019 support thanks to jyoung8607! + * Å koda Octavia RS 2016 support thanks to jyoung8607! + * Toyota Alphard 2020 support thanks to belm0! + * Volkswagen Golf SportWagen 2015 support thanks to jona96! + * Volkswagen Touran 2017 support thanks to jyoung8607! + +Version 0.8.5 (2021-06-11) +======================== + * NEOS update: improved reliability and stability with better voltage regulator configuration + * Smart model-based Forward Collision Warning + * CAN-based fingerprinting moved behind community features toggle + * Improved longitudinal control on Toyotas with a comma pedal + * Improved auto-brightness using road-facing camera + * Added "Software" settings page with updater controls + * Audi Q2 2018 support thanks to jyoung8607! + * Hyundai Elantra 2021 support thanks to CruiseBrantley! + * Lexus UX Hybrid 2019-2020 support thanks to brianhaugen2! + * Toyota Avalon Hybrid 2019 support thanks to jbates9011! + * SEAT Leon 2017 & 2020 support thanks to jyoung8607! + * Å koda Octavia 2015 & 2019 support thanks to jyoung8607! + +Version 0.8.4 (2021-05-17) +======================== + * Delay controls start until system is ready + * Fuzzy car identification, enabled with Community Features toggle + * Localizer optimized for increased precision and less CPU usage + * Retuned lateral control to be more aggressive when model is confident + * Toyota Mirai 2021 support + * Lexus NX 300 2020 support thanks to goesreallyfast! + * Volkswagen Atlas 2018-19 support thanks to jyoung8607! + +Version 0.8.3 (2021-04-01) +======================== + * New model + * Trained on new diverse dataset from 2000+ users from 30+ countries + * Trained with improved segnet from the comma-pencil community project + * 🥬 Dramatically improved end-to-end lateral performance 🥬 + * Toggle added to disable the use of lanelines + * NEOS update: update packages and support for new UI + * New offroad UI based on Qt + * Default SSH key only used for setup + * Kia Ceed 2019 support thanks to ZanZaD13! + * Kia Seltos 2021 support thanks to speedking456! + * Added support for many Volkswagen and Å koda models thanks to jyoung8607! + +Version 0.8.2 (2021-02-26) +======================== + * Use model points directly in MPC (no more polyfits), making lateral planning more accurate + * Use model heading prediction for smoother lateral control + * Smarter actuator delay compensation + * Improve qcamera resolution for improved video in explorer and connect + * Adjust maximum engagement speed to better fit the model's training distribution + * New driver monitoring model trained with 3x more diverse data + * Improved face detection with masks + * More predictable DM alerts when visibility is bad + * Rewritten video streaming between openpilot processes + * Improved longitudinal tuning on TSS2 Corolla and Rav4 thanks to briskspirit! + * Audi A3 2015 and 2017 support thanks to keeleysam! + * Nissan Altima 2020 support thanks to avolmensky! + * Lexus ES Hybrid 2018 support thanks to TheInventorMan! + * Toyota Camry Hybrid 2021 support thanks to alancyau! + +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 + * Improve driver monitoring: eye tracking and improved awareness logic + * Improve path prediction with new driving model + * Improve lane positioning with wide lanes and exits + * Improve lateral control on RAV4 + * Slow down for turns using model + * Open sourced regression test to verify outputs against reference logs + * Open sourced regression test to sanity check all car models + +Version 0.6.2 (2019-07-29) +======================== + * New driving model! + * Improve lane tracking with double lines + * Strongly improve stationary vehicle detection + * Strongly reduce cases of braking due to false leads + * Better lead tracking around turns + * Improve cut-in prediction by using neural network + * Improve lateral control on Toyota Camry and C-HR thanks to zorrobyte! + * Fix unintended openpilot disengagements on Jeep thanks to adhintz! + * Fix delayed transition to offroad when car is turned off + +Version 0.6.1 (2019-07-21) +======================== + * Remote SSH with comma prime and [ssh.comma.ai](https://ssh.comma.ai) + * Panda code Misra-c2012 compliance, tested against cppcheck coverage + * Lockout openpilot after 3 terminal alerts for driver distracted or unresponsive + * Toyota Sienna support thanks to wocsor! + Version 0.6 (2019-07-01) ======================== * New model, with double the pixels and ten times the temporal context! @@ -8,7 +371,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) @@ -314,96 +677,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 deleted file mode 100644 index 3cda811e0cd9f9..00000000000000 --- a/SAFETY.md +++ /dev/null @@ -1,151 +0,0 @@ -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**. - -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. - -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. - -**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..14450cec9f8925 --- /dev/null +++ b/SConstruct @@ -0,0 +1,437 @@ +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('--extras', + action='store_true', + help='build misc extras, like setup and installer files') + +AddOption('--kaitai', + action='store_true', + help='Regenerate kaitai struct parsers') + +AddOption('--asan', + action='store_true', + help='turn on ASAN') + +AddOption('--ubsan', + action='store_true', + help='turn on UBSan') + +AddOption('--clazy', + action='store_true', + help='build with clazy') + +AddOption('--compile_db', + action='store_true', + help='build clang compilation database') + +AddOption('--snpe', + action='store_true', + help='use SNPE on PC') + +AddOption('--external-sconscript', + action='store', + metavar='FILE', + dest='external_sconscript', + help='add an external SConscript to the build') + +AddOption('--no-thneed', + action='store_true', + dest='no_thneed', + help='avoid using thneed') + +real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() +if platform.system() == "Darwin": + arch = "Darwin" + +if arch == "aarch64" and TICI: + arch = "larch64" + +USE_WEBCAM = os.getenv("USE_WEBCAM") is not None + +lenv = { + "PATH": os.environ['PATH'], + "LD_LIBRARY_PATH": [Dir(f"#third_party/acados/{arch}/lib").abspath], + "PYTHONPATH": Dir("#").abspath + ":" + Dir("#pyextra/").abspath, + + "ACADOS_SOURCE_DIR": Dir("#third_party/acados/acados").abspath, + "ACADOS_PYTHON_INTERFACE_PATH": Dir("#pyextra/acados_template").abspath, + "TERA_PATH": Dir("#").abspath + f"/third_party/acados/{arch}/t_renderer", +} + +rpath = lenv["LD_LIBRARY_PATH"].copy() + +if arch == "aarch64" or arch == "larch64": + lenv["LD_LIBRARY_PATH"] += ['/data/data/com.termux/files/usr/lib'] + + if arch == "aarch64": + # android + lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA'] + lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT'] + + cpppath = [ + "#third_party/opencl/include", + ] + + libpath = [ + "/usr/local/lib", + "/usr/lib", + "/system/vendor/lib64", + "/system/comma/usr/lib", + f"#third_party/acados/{arch}/lib", + ] + + if arch == "larch64": + libpath += [ + "#third_party/snpe/larch64", + "#third_party/libyuv/larch64/lib", + "/usr/lib/aarch64-linux-gnu" + ] + cpppath += [ + "#selfdrive/camerad/include", + ] + cflags = ["-DQCOM2", "-mcpu=cortex-a57"] + cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"] + rpath += ["/usr/local/lib"] + else: + rpath = [] + libpath += [ + "#third_party/snpe/aarch64", + "#third_party/libyuv/lib", + "/system/vendor/lib64" + ] + cflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] + cxxflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] +else: + cflags = [] + cxxflags = [] + cpppath = [] + + if arch == "Darwin": + yuv_dir = "mac" if real_arch != "arm64" else "mac_arm64" + libpath = [ + f"#third_party/libyuv/{yuv_dir}/lib", + "/usr/local/lib", + "/opt/homebrew/lib", + "/usr/local/opt/openssl/lib", + "/opt/homebrew/opt/openssl/lib", + "/System/Library/Frameworks/OpenGL.framework/Libraries", + ] + cflags += ["-DGL_SILENCE_DEPRECATION"] + cxxflags += ["-DGL_SILENCE_DEPRECATION"] + cpppath += [ + "/opt/homebrew/include", + "/usr/local/opt/openssl/include", + "/opt/homebrew/opt/openssl/include" + ] + else: + libpath = [ + "#third_party/acados/x86_64/lib", + "#third_party/snpe/x86_64-linux-clang", + "#third_party/libyuv/x64/lib", + "#third_party/mapbox-gl-native-qt/x86_64", + "#cereal", + "#selfdrive/common", + "/usr/lib", + "/usr/local/lib", + ] + + rpath += [ + Dir("#third_party/snpe/x86_64-linux-clang").abspath, + Dir("#cereal").abspath, + Dir("#selfdrive/common").abspath + ] + +if GetOption('asan'): + ccflags = ["-fsanitize=address", "-fno-omit-frame-pointer"] + ldflags = ["-fsanitize=address"] +elif GetOption('ubsan'): + ccflags = ["-fsanitize=undefined"] + ldflags = ["-fsanitize=undefined"] +else: + ccflags = [] + ldflags = [] + +# no --as-needed on mac linker +if arch != "Darwin": + ldflags += ["-Wl,--as-needed", "-Wl,--no-undefined"] + +# Enable swaglog include in submodules +cflags += ["-DSWAGLOG"] +cxxflags += ["-DSWAGLOG"] + +env = Environment( + ENV=lenv, + CCFLAGS=[ + "-g", + "-fPIC", + "-O2", + "-Wunused", + "-Werror", + "-Wshadow", + "-Wno-unknown-warning-option", + "-Wno-deprecated-register", + "-Wno-register", + "-Wno-inconsistent-missing-override", + "-Wno-c99-designator", + "-Wno-reorder-init-list", + "-Wno-error=unused-but-set-variable", + ] + cflags + ccflags, + + CPPPATH=cpppath + [ + "#", + "#third_party/acados/include", + "#third_party/acados/include/blasfeo/include", + "#third_party/acados/include/hpipm/include", + "#third_party/catch2/include", + "#third_party/bzip2", + "#third_party/libyuv/include", + "#third_party/openmax/include", + "#third_party/json11", + "#third_party/curl/include", + "#third_party/libgralloc/include", + "#third_party/android_frameworks_native/include", + "#third_party/android_hardware_libhardware/include", + "#third_party/android_system_core/include", + "#third_party/linux/include", + "#third_party/snpe/include", + "#third_party/mapbox-gl-native-qt/include", + "#third_party/qrcode", + "#third_party", + "#cereal", + "#opendbc/can", + ], + + CC='clang', + CXX='clang++', + LINKFLAGS=ldflags, + + RPATH=rpath, + + CFLAGS=["-std=gnu11"] + cflags, + CXXFLAGS=["-std=c++1z"] + cxxflags, + LIBPATH=libpath + [ + "#cereal", + "#third_party", + "#opendbc/can", + "#selfdrive/boardd", + "#selfdrive/common", + ], + CYTHONCFILESUFFIX=".cpp", + COMPILATIONDB_USE_ABSPATH=True, + tools=["default", "cython", "compilation_db"], +) + +if GetOption('compile_db'): + env.CompilationDatabase('compile_commands.json') + +# Setup cache dir +cache_dir = '/data/scons_cache' if TICI else '/tmp/scons_cache' +CacheDir(cache_dir) +Clean(["."], 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-shadow", "-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') + +# Qt build environment +qt_env = env.Clone() +qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia", "Quick", "Qml", "QuickWidgets", "Location", "Positioning"] +if arch != "aarch64": + qt_modules += ["DBus"] + +qt_libs = [] +if arch == "Darwin": + if real_arch == "arm64": + qt_env['QTDIR'] = "/opt/homebrew/opt/qt@5" + else: + qt_env['QTDIR'] = "/usr/local/opt/qt@5" + qt_dirs = [ + os.path.join(qt_env['QTDIR'], "include"), + ] + qt_dirs += [f"{qt_env['QTDIR']}/include/Qt{m}" for m in qt_modules] + qt_env["LINKFLAGS"] += ["-F" + os.path.join(qt_env['QTDIR'], "lib")] + qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"] +elif arch == "aarch64": + qt_env['QTDIR'] = "/system/comma/usr" + qt_dirs = [ + f"/system/comma/usr/include/qt", + ] + qt_dirs += [f"/system/comma/usr/include/qt/Qt{m}" for m in qt_modules] + + qt_libs = [f"Qt5{m}" for m in qt_modules] + qt_libs += ['EGL', 'GLESv3', 'c++_shared'] +else: + qt_env['QTDIR'] = "/usr" + qt_dirs = [ + f"/usr/include/{real_arch}-linux-gnu/qt5", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.12.8/QtGui", + ] + qt_dirs += [f"/usr/include/{real_arch}-linux-gnu/qt5/Qt{m}" for m in qt_modules] + + qt_libs = [f"Qt5{m}" for m in qt_modules] + if arch == "larch64": + qt_libs += ["GLESv2", "wayland-client"] + elif arch != "Darwin": + qt_libs += ["GL"] + +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_QUICK_LIB", + "-DQT_QUICKWIDGETS_LIB", + "-DQT_QML_LIB", + "-DQT_CORE_LIB", + "-DQT_MESSAGELOGCONTEXT", +] +qt_env['CXXFLAGS'] += qt_flags +qt_env['LIBPATH'] += ['#selfdrive/ui'] +qt_env['LIBS'] = qt_libs + +if GetOption("clazy"): + checks = [ + "level0", + "level1", + "no-range-loop", + "no-non-pod-global-static", + ] + qt_env['CXX'] = 'clazy' + qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0] + qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks) + +Export('env', 'qt_env', 'arch', 'real_arch', 'SHARED', 'USE_WEBCAM') + +SConscript(['selfdrive/common/SConscript']) +Import('_common', '_gpucommon', '_gpu_libs') + +if SHARED: + common, gpucommon = abspath(common), abspath(gpucommon) +else: + common = [_common, 'json11'] + gpucommon = [_gpucommon] + _gpu_libs + +Export('common', 'gpucommon') + +# 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')] + visionipc = [File('#cereal/libvisionipc.a')] + +Export('cereal', 'messaging', 'visionipc') + +# Build rednose library and ekf models + +rednose_config = { + 'generated_folder': '#selfdrive/locationd/models/generated', + 'to_build': { + 'live': ('#selfdrive/locationd/models/live_kf.py', True, ['live_kf_constants.h']), + 'car': ('#selfdrive/locationd/models/car_kf.py', True, []), + }, +} + +if arch not in ["aarch64", "larch64"]: + rednose_config['to_build'].update({ + 'gnss': ('#selfdrive/locationd/models/gnss_kf.py', True, []), + 'loc_4': ('#selfdrive/locationd/models/loc_kf.py', True, []), + 'pos_computer_4': ('#rednose/helpers/lst_sq_computer.py', False, []), + 'pos_computer_5': ('#rednose/helpers/lst_sq_computer.py', False, []), + 'feature_handler_5': ('#rednose/helpers/feature_handler.py', False, []), + 'lane': ('#xx/pipeline/lib/ekf/lane_kf.py', True, []), + }) + +Export('rednose_config') +SConscript(['rednose/SConscript']) + +# Build openpilot + +SConscript(['cereal/SConscript']) +SConscript(['panda/board/SConscript']) +SConscript(['opendbc/can/SConscript']) + +SConscript(['third_party/SConscript']) + +SConscript(['common/SConscript']) +SConscript(['common/kalman/SConscript']) +SConscript(['common/transformations/SConscript']) + +SConscript(['selfdrive/camerad/SConscript']) +SConscript(['selfdrive/modeld/SConscript']) + +SConscript(['selfdrive/controls/lib/cluster/SConscript']) +SConscript(['selfdrive/controls/lib/lateral_mpc_lib/SConscript']) +SConscript(['selfdrive/controls/lib/longitudinal_mpc_lib/SConscript']) + +SConscript(['selfdrive/boardd/SConscript']) +SConscript(['selfdrive/proclogd/SConscript']) +SConscript(['selfdrive/clocksd/SConscript']) + +SConscript(['selfdrive/loggerd/SConscript']) + +SConscript(['selfdrive/locationd/SConscript']) +SConscript(['selfdrive/sensord/SConscript']) +SConscript(['selfdrive/ui/SConscript']) + +if arch != "Darwin": + SConscript(['selfdrive/logcatd/SConscript']) + +if GetOption('test'): + SConscript('panda/tests/safety/SConscript') + +external_sconscript = GetOption('external_sconscript') +if external_sconscript: + SConscript([external_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 deleted file mode 100644 index 41920230b4fa09..00000000000000 Binary files a/apk/ai.comma.plus.offroad.apk and /dev/null differ diff --git a/cereal/.gitignore b/cereal/.gitignore index 3f6de09fb90f69..14cd02efff2110 100644 --- a/cereal/.gitignore +++ b/cereal/.gitignore @@ -1,6 +1,21 @@ gen node_modules package-lock.json +*.tmp *.pyc __pycache__ +.*.swp +.*.swo +*.os +*.o +*.a +test_runner + +libmessaging.* +libmessaging_shared.* +services.h +.sconsign.dblite +libcereal_shared.* +.mypy_cache/ +catch2/ diff --git a/cereal/Makefile b/cereal/Makefile deleted file mode 100644 index 83318bef33d0ad..00000000000000 --- a/cereal/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -PWD := $(shell pwd) - -SRCS := log.capnp car.capnp - -GENS := gen/cpp/car.capnp.c++ gen/cpp/log.capnp.c++ -JS := gen/js/car.capnp.js gen/js/log.capnp.js - -UNAME_M ?= $(shell uname -m) - -GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/include/c++.capnp.h gen/c/include/java.capnp.h - -ifeq ($(UNAME_M),x86_64) - -ifneq (, $(shell which capnpc-java)) -GENS += gen/java/Car.java gen/java/Log.java -else -$(warning capnpc-java not found, skipping java build) -endif - -endif - - -ifeq ($(UNAME_M),aarch64) -CAPNPC=PATH=$(PWD)/../phonelibs/capnp-cpp/aarch64/bin/:$$PATH capnpc -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..df066dc514309f --- /dev/null +++ b/cereal/SConscript @@ -0,0 +1,72 @@ +Import('env', 'envCython', 'arch', 'common') + +import shutil + +cereal_dir = Dir('.') +gen_dir = Dir('gen') +messaging_dir = Dir('messaging') + +# Build cereal + +schema_files = ['log.capnp', 'car.capnp', 'legacy.capnp'] +env.Command(["gen/c/include/c++.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS") +env.Command([f'gen/cpp/{s}.c++' for s in schema_files] + [f'gen/cpp/{s}.h' for s in schema_files], + schema_files, + f"capnpc --src-prefix={cereal_dir.path} $SOURCES -o c++:{gen_dir.path}/cpp/") + +# TODO: remove non shared cereal and messaging +cereal_objects = env.SharedObject([f'gen/cpp/{s}.c++' for s in schema_files]) + +env.Library('cereal', cereal_objects) +env.SharedLibrary('cereal_shared', cereal_objects) + +# Build messaging + +services_h = env.Command(['services.h'], ['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) + +env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq', common]) +Depends('messaging/bridge.cc', services_h) + +envCython.Program('messaging/messaging_pyx.so', 'messaging/messaging_pyx.pyx', LIBS=envCython["LIBS"]+[messaging_lib, "zmq", common]) + + +# Build Vision IPC +vipc_sources = [ + 'visionipc/ipc.cc', + 'visionipc/visionipc_server.cc', + 'visionipc/visionipc_client.cc', + 'visionipc/visionbuf.cc', +] + +if arch in ["aarch64", "larch64"]: + vipc_sources += ['visionipc/visionbuf_ion.cc'] +else: + vipc_sources += ['visionipc/visionbuf_cl.cc'] + +vipc_objects = env.SharedObject(vipc_sources) +vipc = env.Library('visionipc', vipc_objects) + + +libs = envCython["LIBS"]+["OpenCL", "zmq", vipc, messaging_lib, common] +if arch == "aarch64": + libs += ["adreno_utils"] +if arch == "Darwin": + del libs[libs.index('OpenCL')] + envCython['FRAMEWORKS'] += ['OpenCL'] +envCython.Program('visionipc/visionipc_pyx.so', 'visionipc/visionipc_pyx.pyx', LIBS=libs) + + +if GetOption('test'): + env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib, common]) + env.Program('visionipc/test_runner', ['visionipc/test_runner.cc', 'visionipc/visionipc_tests.cc'], LIBS=[vipc, messaging_lib, 'zmq', 'pthread', 'OpenCL', common]) diff --git a/cereal/__init__.py b/cereal/__init__.py index 2d3b48526b2c34..88a181cbc51da4 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 f30b20f9770283..5c8c339b74b3fe 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -1,31 +1,27 @@ using Cxx = import "./include/c++.capnp"; $Cxx.namespace("cereal"); -using Java = import "./include/java.capnp"; -$Java.package("ai.comma.openpilot.cereal"); -$Java.outerClassname("Car"); - @0x8e2af1e708af8b8d; # ******* events causing controls state machine transition ******* struct CarEvent @0x9b1657f34caf3ad3 { name @0 :EventName; + + # event types 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; @@ -37,8 +33,6 @@ struct CarEvent @0x9b1657f34caf3ad3 { buttonEnable @12; pedalPressed @13; cruiseDisabled @14; - radarCanError @15; - dataNeeded @16; speedTooLow @17; outOfSpace @18; overheat @19; @@ -49,33 +43,90 @@ 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; + joystickDebug @34; + steerTempUnavailableSilent @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; + accFaulted @51; sensorDataInvalid @52; commIssue @53; + tooDistracted @54; + posenetInvalid @55; + soundsUnavailable @56; + preLaneChangeLeft @57; + preLaneChangeRight @58; + laneChange @59; + communityFeatureDisallowed @62; + lowMemory @63; + stockAeb @64; + ldw @65; + carUnrecognized @66; + invalidLkasSetting @69; + speedTooHigh @70; + laneChangeBlocked @71; + relayMalfunction @72; + gasPressed @73; + stockFcw @74; + startup @75; + startupNoCar @76; + startupNoControl @77; + startupMaster @78; + startupNoFw @104; + fcw @79; + steerSaturated @80; + belowEngageSpeed @84; + noGps @85; + wrongCruiseMode @87; + modeldLagging @89; + deviceFalling @90; + fanMalfunction @91; + cameraMalfunction @92; + gpsMalfunction @94; + processNotRunning @95; + dashcamMode @96; + controlsInitializing @98; + usbError @99; + roadCameraError @100; + driverCameraError @101; + wideRoadCameraError @102; + localizerMalfunction @103; + highCpuUsage @105; + cruiseMismatch @106; + + driverMonitorLowAccDEPRECATED @68; + radarCanErrorDEPRECATED @15; + radarCommIssueDEPRECATED @67; + gasUnavailableDEPRECATED @3; + dataNeededDEPRECATED @16; + modelCommIssueDEPRECATED @27; + ipasOverrideDEPRECATED @33; + geofenceDEPRECATED @40; + driverMonitorOnDEPRECATED @41; + driverMonitorOffDEPRECATED @42; + calibrationProgressDEPRECATED @47; + invalidGiraffeHondaDEPRECATED @49; + invalidGiraffeToyotaDEPRECATED @60; + internetConnectivityNeededDEPRECATED @61; + whitePandaUnsupportedDEPRECATED @81; + commIssueWarningDEPRECATED @83; + focusRecoverActiveDEPRECATED @86; + neosUpdateRequiredDEPRECATED @88; + modelLagWarningDEPRECATED @93; + startupOneplusDEPRECATED @82; + startupFuzzyFingerprintDEPRECATED @97; } } @@ -83,7 +134,6 @@ struct CarEvent @0x9b1657f34caf3ad3 { # all speeds in m/s struct CarState { - errorsDEPRECATED @0 :List(CarEvent.EventName); events @13 :List(CarEvent); # car speed @@ -95,19 +145,27 @@ struct CarState { wheelSpeeds @2 :WheelSpeeds; # gas pedal, 0.0-1.0 - gas @3 :Float32; # this is user + computer + gas @3 :Float32; # this is user pedal only gasPressed @4 :Bool; # this is user pedal only # brake pedal, 0.0-1.0 brake @5 :Float32; # this is user pedal only brakePressed @6 :Bool; # this is user pedal only - brakeLights @19 :Bool; + brakeHoldActive @38 :Bool; # steering wheel - steeringAngle @7 :Float32; # deg - steeringRate @15 :Float32; # deg/s - steeringTorque @8 :Float32; # TODO: standardize units - steeringPressed @9 :Bool; # if the user is using the steering wheel + steeringAngleDeg @7 :Float32; + steeringAngleOffsetDeg @37 :Float32; # Offset betweens sensors in case there multiple + steeringRateDeg @15 :Float32; + steeringTorque @8 :Float32; # TODO: standardize units + steeringTorqueEps @27 :Float32; # TODO: standardize units + 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; @@ -126,9 +184,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; @@ -143,6 +208,7 @@ struct CarState { available @2 :Bool; speedOffset @3 :Float32; standstill @4 :Bool; + nonAdaptive @5 :Bool; } enum GearShifter { @@ -154,9 +220,10 @@ struct CarState { sport @5; low @6; brake @7; + eco @8; + manumatic @9; } - # send on change struct ButtonEvent { pressed @0 :Bool; @@ -172,8 +239,14 @@ struct CarState { altButton1 @6; altButton2 @7; altButton3 @8; + setCruise @9; + resumeCruise @10; + gapAdjustCruise @11; } } + + errorsDEPRECATED @0 :List(CarEvent.EventName); + brakeLightsDEPRECATED @19 :Bool; } # ******* radar state @ 20hz ******* @@ -217,22 +290,31 @@ struct CarControl { enabled @0 :Bool; active @7 :Bool; - gasDEPRECATED @1 :Float32; - brakeDEPRECATED @2 :Float32; - steeringTorqueDEPRECATED @3 :Float32; - actuators @6 :Actuators; + roll @8 :Float32; + pitch @9 :Float32; cruiseControl @4 :CruiseControl; hudControl @5 :HUDControl; struct Actuators { # range from 0.0 - 1.0 - gas @0: Float32; - brake @1: Float32; + gasDEPRECATED @0: Float32; + brakeDEPRECATED @1: Float32; # range from -1.0 - 1.0 steer @2: Float32; - steerAngle @3: Float32; + steeringAngleDeg @3: Float32; + + accel @4: Float32; # m/s^2 + longControlState @5: LongControlState; + + enum LongControlState @0xe40f3a917d908282{ + off @0; + pid @1; + stopping @2; + starting @3; + } + } struct CruiseControl { @@ -264,21 +346,28 @@ struct CarControl { wrongGear @4; seatbeltUnbuckled @5; speedTooHigh @6; + ldw @7; } enum AudibleAlert { - # these are the choices from the Honda - # map as good as you can for your car none @0; - chimeEngage @1; - chimeDisengage @2; - chimeError @3; - chimeWarning1 @4; - chimeWarning2 @5; - chimeWarningRepeat @6; - chimePrompt @7; + + engage @1; + disengage @2; + refuse @3; + + warningSoft @4; + warningImmediate @5; + + prompt @6; + promptRepeat @7; + promptDistracted @8; } } + + gasDEPRECATED @1 :Float32; + brakeDEPRECATED @2 :Float32; + steeringTorqueDEPRECATED @3 :Float32; } # ****** car param ****** @@ -286,32 +375,33 @@ struct CarControl { struct CarParams { carName @0 :Text; carFingerprint @1 :Text; + fuzzyFingerprint @55 :Bool; enableGasInterceptor @2 :Bool; - enableCruise @3 :Bool; - enableCamera @4 :Bool; - enableDsu @5 :Bool; # driving support unit - enableApgs @6 :Bool; # advanced parking guidance system + pcmCruise @3 :Bool; # is openpilot's state tied to the PCM's cruise state? + enableDsu @5 :Bool; # driving support unit + enableApgs @6 :Bool; # advanced parking guidance system + enableBsm @56 :Bool; # blind spot monitoring + flags @64 :UInt32; # flags for car specific quirks minEnableSpeed @7 :Float32; minSteerSpeed @8 :Float32; - safetyModel @9 :SafetyModel; - safetyParam @10 :Int16; + maxSteeringAngleDeg @54 :Float32; + safetyConfigs @62 :List(SafetyConfig); steerMaxBP @11 :List(Float32); steerMaxV @12 :List(Float32); - gasMaxBP @13 :List(Float32); - gasMaxV @14 :List(Float32); - brakeMaxBP @15 :List(Float32); - brakeMaxV @16 :List(Float32); - + gasMaxBPDEPRECATED @13 :List(Float32); + gasMaxVDEPRECATED @14 :List(Float32); + brakeMaxBPDEPRECATED @15 :List(Float32); + brakeMaxVDEPRECATED @16 :List(Float32); # things about the car in the manual - mass @17 :Float32; # [kg] running weight - wheelbase @18 :Float32; # [m] distance from rear to front axle - centerToFront @19 :Float32; # [m] GC distance to front axle - steerRatio @20 :Float32; # [] ratio between front wheels and steering wheel angles - steerRatioRear @21 :Float32; # [] rear steering ratio wrt front steering (usually 0) + mass @17 :Float32; # [kg] curb weight: all fluids no cargo + wheelbase @18 :Float32; # [m] distance from rear axle to front axle + centerToFront @19 :Float32; # [m] distance from center of mass to front axle + steerRatio @20 :Float32; # [] ratio of steering wheel angle to front wheel angle + steerRatioRear @21 :Float32; # [] ratio of steering wheel angle to rear wheel angle (usually 0) # things we can derive rotationalInertia @22 :Float32; # [kg*m2] body rotational inertia @@ -319,24 +409,54 @@ 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; + lqr @40 :LateralLQRTuning; } steerLimitAlert @28 :Bool; + steerLimitTimer @47 :Float32; # time before steerLimitAlert is issued vEgoStopping @29 :Float32; # Speed at which the car goes into stopping state + vEgoStarting @59 :Float32; # Speed at which the car goes into starting state directAccelControl @30 :Bool; # Does the car have direct accel control or just gas/brake stoppingControl @31 :Bool; # Does the car allows full control even at lows speeds when stopping startAccel @32 :Float32; # Required acceleraton to overcome creep braking + stopAccel @60 :Float32; # Required acceleraton to keep vehicle stationary 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) + stoppingDecelRate @52 :Float32; # m/s^2/s while trying to stop + startingAccelRate @53 :Float32; # m/s^2/s while trying to start steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds + longitudinalActuatorDelayLowerBound @61 :Float32; # Gas/Brake actuator delay in seconds, lower bound + longitudinalActuatorDelayUpperBound @58 :Float32; # Gas/Brake actuator delay in seconds, upper bound openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control? carVin @38 :Text; # VIN number queried during fingerprinting + 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 + + wheelSpeedFactor @63 :Float32; # Multiplier on wheels speeds to computer actual speeds + + struct SafetyConfig { + safetyModel @0 :SafetyModel; + safetyParam @1 :Int16; + } + + struct LateralParams { + torqueBP @0 :List(Int32); + torqueV @1 :List(Int32); + } struct LateralPIDTuning { kpBP @0 :List(Float32); @@ -355,33 +475,124 @@ struct CarParams { deadzoneV @5 :List(Float32); } - struct LateralINDITuning { - outerLoopGain @0 :Float32; - innerLoopGain @1 :Float32; - timeConstant @2 :Float32; - actuatorEffectiveness @3 :Float32; + outerLoopGainBP @4 :List(Float32); + outerLoopGainV @5 :List(Float32); + innerLoopGainBP @6 :List(Float32); + innerLoopGainV @7 :List(Float32); + timeConstantBP @8 :List(Float32); + timeConstantV @9 :List(Float32); + actuatorEffectivenessBP @10 :List(Float32); + actuatorEffectivenessV @11 :List(Float32); + + outerLoopGainDEPRECATED @0 :Float32; + innerLoopGainDEPRECATED @1 :Float32; + timeConstantDEPRECATED @2 :Float32; + actuatorEffectivenessDEPRECATED @3 :Float32; } + struct LateralLQRTuning { + scale @0 :Float32; + ki @1 :Float32; + dcGain @2 :Float32; + + # State space system + a @3 :List(Float32); + b @4 :List(Float32); + c @5 :List(Float32); + + k @6 :List(Float32); # LQR gain + 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 + hondaBosch @20; + volkswagenPq @21; + subaruLegacy @22; # pre-Global platform + hyundaiLegacy @23; + hyundaiCommunity @24; + stellantis @25; } enum SteerControlType { torque @0; angle @1; } + + enum TransmissionType { + unknown @0; + automatic @1; # Traditional auto, including DSG + manual @2; # True "stick shift" only + direct @3; # Electric vehicle or other direct drive + cvt @4; + } + + 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 + } + + enableCameraDEPRECATED @4 :Bool; + isPandaBlackDEPRECATED @39: Bool; + hasStockCameraDEPRECATED @57 :Bool; + safetyParamDEPRECATED @10 :Int16; + safetyModelDEPRECATED @9 :SafetyModel; + safetyModelPassiveDEPRECATED @42 :SafetyModel = silent; } 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/include/java.capnp b/cereal/include/java.capnp deleted file mode 100644 index cddf6eba3d9777..00000000000000 --- a/cereal/include/java.capnp +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors -# Licensed under the MIT License: -# -# 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. - -@0xc5f1af96651f70ea; - -annotation package @0x9ee4c8f803b3b596 (file) : Text; -# Name of the package, such as "org.example.foo", in which the generated code will reside. - -annotation outerClassname @0x9b066bb4881f7cd3 (file) : Text; -# Name of the outer class that will wrap the generated code. 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/legacy.capnp b/cereal/legacy.capnp new file mode 100644 index 00000000000000..9a489168162090 --- /dev/null +++ b/cereal/legacy.capnp @@ -0,0 +1,861 @@ +using Cxx = import "./include/c++.capnp"; +$Cxx.namespace("cereal"); + +@0x80ef1ec4889c2a63; + +# legacy.capnp: a home for deprecated structs + +struct LogRotate @0x9811e1f38f62f2d1 { + segmentNum @0 :Int32; + path @1 :Text; +} + +struct LiveUI @0xc08240f996aefced { + rearViewCam @0 :Bool; + alertText1 @1 :Text; + alertText2 @2 :Text; + awarenessStatus @3 :Float32; +} + +struct UiLayoutState @0x88dcce08ad29dda0 { + activeApp @0 :App; + sidebarCollapsed @1 :Bool; + mapEnabled @2 :Bool; + mockEngaged @3 :Bool; + + enum App @0x9917470acf94d285 { + home @0; + music @1; + nav @2; + settings @3; + none @4; + } +} + +struct OrbslamCorrection @0x8afd33dc9b35e1aa { + correctionMonoTime @0 :UInt64; + prePositionECEF @1 :List(Float64); + postPositionECEF @2 :List(Float64); + prePoseQuatECEF @3 :List(Float32); + postPoseQuatECEF @4 :List(Float32); + numInliers @5 :UInt32; +} + +struct EthernetPacket @0xa99a9d5b33cf5859 { + pkt @0 :Data; + ts @1 :Float32; +} + +struct CellInfo @0xcff7566681c277ce { + timestamp @0 :UInt64; + repr @1 :Text; # android toString() for now +} + +struct WifiScan @0xd4df5a192382ba0b { + bssid @0 :Text; + ssid @1 :Text; + capabilities @2 :Text; + frequency @3 :Int32; + level @4 :Int32; + timestamp @5 :Int64; + + centerFreq0 @6 :Int32; + centerFreq1 @7 :Int32; + channelWidth @8 :ChannelWidth; + operatorFriendlyName @9 :Text; + venueName @10 :Text; + is80211mcResponder @11 :Bool; + passpoint @12 :Bool; + + distanceCm @13 :Int32; + distanceSdCm @14 :Int32; + + enum ChannelWidth @0xcb6a279f015f6b51 { + w20Mhz @0; + w40Mhz @1; + w80Mhz @2; + w160Mhz @3; + w80Plus80Mhz @4; + } +} + +struct LiveEventData @0x94b7baa90c5c321e { + name @0 :Text; + value @1 :Int32; +} + +struct ModelData @0xb8aad62cffef28a9 { + 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; + rightLane @3 :PathData; + lead @4 :LeadData; + freePath @6 :List(Float32); + + settings @5 :ModelSettings; + leadFuture @7 :LeadData; + speed @8 :List(Float32); + meta @10 :MetaData; + longitudinal @11 :LongitudinalData; + + struct PathData @0x8817eeea389e9f08 { + points @0 :List(Float32); + prob @1 :Float32; + std @2 :Float32; + stds @3 :List(Float32); + poly @4 :List(Float32); + validLen @5 :Float32; + } + + struct LeadData @0xd1c9bef96d26fa91 { + dist @0 :Float32; + prob @1 :Float32; + std @2 :Float32; + relVel @3 :Float32; + relVelStd @4 :Float32; + relY @5 :Float32; + relYStd @6 :Float32; + relA @7 :Float32; + relAStd @8 :Float32; + } + + struct ModelSettings @0xa26e3710efd3e914 { + bigBoxX @0 :UInt16; + bigBoxY @1 :UInt16; + bigBoxWidth @2 :UInt16; + bigBoxHeight @3 :UInt16; + boxProjection @4 :List(Float32); + yuvCorrection @5 :List(Float32); + inputTransform @6 :List(Float32); + } + + struct MetaData @0x9744f25fb60f2bf8 { + engagedProb @0 :Float32; + desirePrediction @1 :List(Float32); + brakeDisengageProb @2 :Float32; + gasDisengageProb @3 :Float32; + steerOverrideProb @4 :Float32; + desireState @5 :List(Float32); + } + + struct LongitudinalData @0xf98f999c6a071122 { + distances @2 :List(Float32); + speeds @0 :List(Float32); + accelerations @1 :List(Float32); + } +} + +struct ECEFPoint @0xc25bbbd524983447 { + x @0 :Float64; + y @1 :Float64; + z @2 :Float64; +} + +struct ECEFPointDEPRECATED @0xe10e21168db0c7f7 { + x @0 :Float32; + y @1 :Float32; + z @2 :Float32; +} + +struct GPSPlannerPoints @0xab54c59699f8f9f3 { + curPosDEPRECATED @0 :ECEFPointDEPRECATED; + pointsDEPRECATED @1 :List(ECEFPointDEPRECATED); + curPos @6 :ECEFPoint; + points @7 :List(ECEFPoint); + valid @2 :Bool; + trackName @3 :Text; + speedLimit @4 :Float32; + accelTarget @5 :Float32; +} + +struct GPSPlannerPlan @0xf5ad1d90cdc1dd6b { + valid @0 :Bool; + poly @1 :List(Float32); + trackName @2 :Text; + speed @3 :Float32; + acceleration @4 :Float32; + pointsDEPRECATED @5 :List(ECEFPointDEPRECATED); + points @6 :List(ECEFPoint); + xLookahead @7 :Float32; +} + +struct UiNavigationEvent @0x90c8426c3eaddd3b { + type @0: Type; + status @1: Status; + distanceTo @2: Float32; + endRoadPointDEPRECATED @3: ECEFPointDEPRECATED; + endRoadPoint @4: ECEFPoint; + + enum Type @0xe8db07dcf8fcea05 { + none @0; + laneChangeLeft @1; + laneChangeRight @2; + mergeLeft @3; + mergeRight @4; + turnLeft @5; + turnRight @6; + } + + enum Status @0xb9aa88c75ef99a1f { + none @0; + passive @1; + approaching @2; + active @3; + } +} + +struct LiveLocationData @0xb99b2bc7a57e8128 { + status @0 :UInt8; + + # 3D fix + lat @1 :Float64; + lon @2 :Float64; + alt @3 :Float32; # m + + # speed + speed @4 :Float32; # m/s + + # NED velocity components + vNED @5 :List(Float32); + + # roll, pitch, heading (x,y,z) + roll @6 :Float32; # WRT to center of earth? + pitch @7 :Float32; # WRT to center of earth? + heading @8 :Float32; # WRT to north? + + # what are these? + wanderAngle @9 :Float32; + trackAngle @10 :Float32; + + # car frame -- https://upload.wikimedia.org/wikipedia/commons/f/f5/RPY_angles_of_cars.png + + # gyro, in car frame, deg/s + gyro @11 :List(Float32); + + # accel, in car frame, m/s^2 + accel @12 :List(Float32); + + accuracy @13 :Accuracy; + + source @14 :SensorSource; + # if we are fixing a location in the past + fixMonoTime @15 :UInt64; + + gpsWeek @16 :Int32; + timeOfWeek @17 :Float64; + + positionECEF @18 :List(Float64); + poseQuatECEF @19 :List(Float32); + pitchCalibration @20 :Float32; + yawCalibration @21 :Float32; + imuFrame @22 :List(Float32); + + struct Accuracy @0x943dc4625473b03f { + pNEDError @0 :List(Float32); + vNEDError @1 :List(Float32); + rollError @2 :Float32; + pitchError @3 :Float32; + headingError @4 :Float32; + ellipsoidSemiMajorError @5 :Float32; + ellipsoidSemiMinorError @6 :Float32; + ellipsoidOrientationError @7 :Float32; + } + + enum SensorSource @0xc871d3cc252af657 { + applanix @0; + kalman @1; + orbslam @2; + timing @3; + dummy @4; + } +} + +struct OrbOdometry @0xd7700859ed1f5b76 { + # timing first + startMonoTime @0 :UInt64; + endMonoTime @1 :UInt64; + + # fundamental matrix and error + f @2: List(Float64); + err @3: Float64; + + # number of inlier points + inliers @4: Int32; + + # for debug only + # indexed by endMonoTime features + # value is startMonoTime feature match + # -1 if no match + matches @5: List(Int16); +} + +struct OrbFeatures @0xcd60164a8a0159ef { + timestampEof @0 :UInt64; + # transposed arrays of normalized image coordinates + # len(xs) == len(ys) == len(descriptors) * 32 + xs @1 :List(Float32); + ys @2 :List(Float32); + descriptors @3 :Data; + octaves @4 :List(Int8); + + # match index to last OrbFeatures + # -1 if no match + timestampLastEof @5 :UInt64; + matches @6: List(Int16); +} + +struct OrbFeaturesSummary @0xd500d30c5803fa4f { + timestampEof @0 :UInt64; + timestampLastEof @1 :UInt64; + + featureCount @2 :UInt16; + matchCount @3 :UInt16; + computeNs @4 :UInt64; +} + +struct OrbKeyFrame @0xc8233c0345e27e24 { + # this is a globally unique id for the KeyFrame + id @0: UInt64; + + # this is the location of the KeyFrame + pos @1: ECEFPoint; + + # these are the features in the world + # len(dpos) == len(descriptors) * 32 + dpos @2 :List(ECEFPoint); + descriptors @3 :Data; +} + +struct KalmanOdometry @0x92e21bb7ea38793a { + 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 + rotStd @3 :List(Float32); # std rad/s in device frame +} + +struct OrbObservation @0x9b326d4e436afec7 { + observationMonoTime @0 :UInt64; + normalizedCoordinates @1 :List(Float32); + locationECEF @2 :List(Float64); + matchDistance @3: UInt32; +} + +struct CalibrationFeatures @0x8fdfadb254ea867a { + frameId @0 :UInt32; + + p0 @1 :List(Float32); + p1 @2 :List(Float32); + status @3 :List(Int8); +} + +struct NavStatus @0xbd8822120928120c { + isNavigating @0 :Bool; + currentAddress @1 :Address; + + struct Address @0xce7cd672cacc7814 { + title @0 :Text; + lat @1 :Float64; + lng @2 :Float64; + house @3 :Text; + address @4 :Text; + street @5 :Text; + city @6 :Text; + state @7 :Text; + country @8 :Text; + } +} + +struct NavUpdate @0xdb98be6565516acb { + isNavigating @0 :Bool; + curSegment @1 :Int32; + segments @2 :List(Segment); + + struct LatLng @0x9eaef9187cadbb9b { + lat @0 :Float64; + lng @1 :Float64; + } + + struct Segment @0xa5b39b4fc4d7da3f { + from @0 :LatLng; + to @1 :LatLng; + updateTime @2 :Int32; + distance @3 :Int32; + crossTime @4 :Int32; + exitNo @5 :Int32; + instruction @6 :Instruction; + + parts @7 :List(LatLng); + + enum Instruction @0xc5417a637451246f { + turnLeft @0; + turnRight @1; + keepLeft @2; + keepRight @3; + straight @4; + roundaboutExitNumber @5; + roundaboutExit @6; + roundaboutTurnLeft @7; + unkn8 @8; + roundaboutStraight @9; + unkn10 @10; + roundaboutTurnRight @11; + unkn12 @12; + roundaboutUturn @13; + unkn14 @14; + arrive @15; + exitLeft @16; + exitRight @17; + unkn18 @18; + uturn @19; + # ... + } + } +} + +struct TrafficEvent @0xacfa74a094e62626 { + type @0 :Type; + distance @1 :Float32; + action @2 :Action; + resuming @3 :Bool; + + enum Type @0xd85d75253435bf4b { + stopSign @0; + lightRed @1; + lightYellow @2; + lightGreen @3; + stopLight @4; + } + + enum Action @0xa6f6ce72165ccb49 { + none @0; + yield @1; + stop @2; + resumeReady @3; + } + +} + + +struct AndroidGnss @0xdfdf30d03fc485bd { + union { + measurements @0 :Measurements; + navigationMessage @1 :NavigationMessage; + } + + struct Measurements @0xa20710d4f428d6cd { + clock @0 :Clock; + measurements @1 :List(Measurement); + + struct Clock @0xa0e27b453a38f450 { + timeNanos @0 :Int64; + hardwareClockDiscontinuityCount @1 :Int32; + + hasTimeUncertaintyNanos @2 :Bool; + timeUncertaintyNanos @3 :Float64; + + hasLeapSecond @4 :Bool; + leapSecond @5 :Int32; + + hasFullBiasNanos @6 :Bool; + fullBiasNanos @7 :Int64; + + hasBiasNanos @8 :Bool; + biasNanos @9 :Float64; + + hasBiasUncertaintyNanos @10 :Bool; + biasUncertaintyNanos @11 :Float64; + + hasDriftNanosPerSecond @12 :Bool; + driftNanosPerSecond @13 :Float64; + + hasDriftUncertaintyNanosPerSecond @14 :Bool; + driftUncertaintyNanosPerSecond @15 :Float64; + } + + struct Measurement @0xd949bf717d77614d { + svId @0 :Int32; + constellation @1 :Constellation; + + timeOffsetNanos @2 :Float64; + state @3 :Int32; + receivedSvTimeNanos @4 :Int64; + receivedSvTimeUncertaintyNanos @5 :Int64; + cn0DbHz @6 :Float64; + pseudorangeRateMetersPerSecond @7 :Float64; + pseudorangeRateUncertaintyMetersPerSecond @8 :Float64; + accumulatedDeltaRangeState @9 :Int32; + accumulatedDeltaRangeMeters @10 :Float64; + accumulatedDeltaRangeUncertaintyMeters @11 :Float64; + + hasCarrierFrequencyHz @12 :Bool; + carrierFrequencyHz @13 :Float32; + hasCarrierCycles @14 :Bool; + carrierCycles @15 :Int64; + hasCarrierPhase @16 :Bool; + carrierPhase @17 :Float64; + hasCarrierPhaseUncertainty @18 :Bool; + carrierPhaseUncertainty @19 :Float64; + hasSnrInDb @20 :Bool; + snrInDb @21 :Float64; + + multipathIndicator @22 :MultipathIndicator; + + enum Constellation @0x9ef1f3ff0deb5ffb { + unknown @0; + gps @1; + sbas @2; + glonass @3; + qzss @4; + beidou @5; + galileo @6; + } + + enum State @0xcbb9490adce12d72 { + unknown @0; + codeLock @1; + bitSync @2; + subframeSync @3; + towDecoded @4; + msecAmbiguous @5; + symbolSync @6; + gloStringSync @7; + gloTodDecoded @8; + bdsD2BitSync @9; + bdsD2SubframeSync @10; + galE1bcCodeLock @11; + galE1c2ndCodeLock @12; + galE1bPageSync @13; + sbasSync @14; + } + + enum MultipathIndicator @0xc04e7b6231d4caa8 { + unknown @0; + detected @1; + notDetected @2; + } + } + } + + struct NavigationMessage @0xe2517b083095fd4e { + type @0 :Int32; + svId @1 :Int32; + messageId @2 :Int32; + submessageId @3 :Int32; + data @4 :Data; + status @5 :Status; + + enum Status @0xec1ff7996b35366f { + unknown @0; + parityPassed @1; + parityRebuilt @2; + } + } +} + +struct QcomGnss @0xde94674b07ae51c1 { + logTs @0 :UInt64; + union { + measurementReport @1 :MeasurementReport; + clockReport @2 :ClockReport; + drMeasurementReport @3 :DrMeasurementReport; + drSvPoly @4 :DrSvPolyReport; + rawLog @5 :Data; + } + + enum MeasurementSource @0xd71a12b6faada7ee { + gps @0; + glonass @1; + beidou @2; + } + + enum SVObservationState @0xe81e829a0d6c83e9 { + idle @0; + search @1; + searchVerify @2; + bitEdge @3; + trackVerify @4; + track @5; + restart @6; + dpo @7; + glo10msBe @8; + glo10msAt @9; + } + + struct MeasurementStatus @0xe501010e1bcae83b { + subMillisecondIsValid @0 :Bool; + subBitTimeIsKnown @1 :Bool; + satelliteTimeIsKnown @2 :Bool; + bitEdgeConfirmedFromSignal @3 :Bool; + measuredVelocity @4 :Bool; + fineOrCoarseVelocity @5 :Bool; + lockPointValid @6 :Bool; + lockPointPositive @7 :Bool; + lastUpdateFromDifference @8 :Bool; + lastUpdateFromVelocityDifference @9 :Bool; + strongIndicationOfCrossCorelation @10 :Bool; + tentativeMeasurement @11 :Bool; + measurementNotUsable @12 :Bool; + sirCheckIsNeeded @13 :Bool; + probationMode @14 :Bool; + + glonassMeanderBitEdgeValid @15 :Bool; + glonassTimeMarkValid @16 :Bool; + + gpsRoundRobinRxDiversity @17 :Bool; + gpsRxDiversity @18 :Bool; + gpsLowBandwidthRxDiversityCombined @19 :Bool; + gpsHighBandwidthNu4 @20 :Bool; + gpsHighBandwidthNu8 @21 :Bool; + gpsHighBandwidthUniform @22 :Bool; + multipathIndicator @23 :Bool; + + imdJammingIndicator @24 :Bool; + lteB13TxJammingIndicator @25 :Bool; + freshMeasurementIndicator @26 :Bool; + + multipathEstimateIsValid @27 :Bool; + directionIsValid @28 :Bool; + } + + struct MeasurementReport @0xf580d7d86b7b8692 { + source @0 :MeasurementSource; + + fCount @1 :UInt32; + + gpsWeek @2 :UInt16; + glonassCycleNumber @3 :UInt8; + glonassNumberOfDays @4 :UInt16; + + milliseconds @5 :UInt32; + timeBias @6 :Float32; + clockTimeUncertainty @7 :Float32; + clockFrequencyBias @8 :Float32; + clockFrequencyUncertainty @9 :Float32; + + sv @10 :List(SV); + + struct SV @0xf10c595ae7bb2c27 { + svId @0 :UInt8; + observationState @2 :SVObservationState; + observations @3 :UInt8; + goodObservations @4 :UInt8; + gpsParityErrorCount @5 :UInt16; + glonassFrequencyIndex @1 :Int8; + glonassHemmingErrorCount @6 :UInt8; + filterStages @7 :UInt8; + carrierNoise @8 :UInt16; + latency @9 :Int16; + predetectInterval @10 :UInt8; + postdetections @11 :UInt16; + + unfilteredMeasurementIntegral @12 :UInt32; + unfilteredMeasurementFraction @13 :Float32; + unfilteredTimeUncertainty @14 :Float32; + unfilteredSpeed @15 :Float32; + unfilteredSpeedUncertainty @16 :Float32; + measurementStatus @17 :MeasurementStatus; + multipathEstimate @18 :UInt32; + azimuth @19 :Float32; + elevation @20 :Float32; + carrierPhaseCyclesIntegral @21 :Int32; + carrierPhaseCyclesFraction @22 :UInt16; + fineSpeed @23 :Float32; + fineSpeedUncertainty @24 :Float32; + cycleSlipCount @25 :UInt8; + } + + } + + struct ClockReport @0xca965e4add8f4f0b { + hasFCount @0 :Bool; + fCount @1 :UInt32; + + hasGpsWeek @2 :Bool; + gpsWeek @3 :UInt16; + hasGpsMilliseconds @4 :Bool; + gpsMilliseconds @5 :UInt32; + gpsTimeBias @6 :Float32; + gpsClockTimeUncertainty @7 :Float32; + gpsClockSource @8 :UInt8; + + hasGlonassYear @9 :Bool; + glonassYear @10 :UInt8; + hasGlonassDay @11 :Bool; + glonassDay @12 :UInt16; + hasGlonassMilliseconds @13 :Bool; + glonassMilliseconds @14 :UInt32; + glonassTimeBias @15 :Float32; + glonassClockTimeUncertainty @16 :Float32; + glonassClockSource @17 :UInt8; + + bdsWeek @18 :UInt16; + bdsMilliseconds @19 :UInt32; + bdsTimeBias @20 :Float32; + bdsClockTimeUncertainty @21 :Float32; + bdsClockSource @22 :UInt8; + + galWeek @23 :UInt16; + galMilliseconds @24 :UInt32; + galTimeBias @25 :Float32; + galClockTimeUncertainty @26 :Float32; + galClockSource @27 :UInt8; + + clockFrequencyBias @28 :Float32; + clockFrequencyUncertainty @29 :Float32; + frequencySource @30 :UInt8; + gpsLeapSeconds @31 :UInt8; + gpsLeapSecondsUncertainty @32 :UInt8; + gpsLeapSecondsSource @33 :UInt8; + + gpsToGlonassTimeBiasMilliseconds @34 :Float32; + gpsToGlonassTimeBiasMillisecondsUncertainty @35 :Float32; + gpsToBdsTimeBiasMilliseconds @36 :Float32; + gpsToBdsTimeBiasMillisecondsUncertainty @37 :Float32; + bdsToGloTimeBiasMilliseconds @38 :Float32; + bdsToGloTimeBiasMillisecondsUncertainty @39 :Float32; + gpsToGalTimeBiasMilliseconds @40 :Float32; + gpsToGalTimeBiasMillisecondsUncertainty @41 :Float32; + galToGloTimeBiasMilliseconds @42 :Float32; + galToGloTimeBiasMillisecondsUncertainty @43 :Float32; + galToBdsTimeBiasMilliseconds @44 :Float32; + galToBdsTimeBiasMillisecondsUncertainty @45 :Float32; + + hasRtcTime @46 :Bool; + systemRtcTime @47 :UInt32; + fCountOffset @48 :UInt32; + lpmRtcCount @49 :UInt32; + clockResets @50 :UInt32; + } + + struct DrMeasurementReport @0x8053c39445c6c75c { + + reason @0 :UInt8; + seqNum @1 :UInt8; + seqMax @2 :UInt8; + rfLoss @3 :UInt16; + + systemRtcValid @4 :Bool; + fCount @5 :UInt32; + clockResets @6 :UInt32; + systemRtcTime @7 :UInt64; + + gpsLeapSeconds @8 :UInt8; + gpsLeapSecondsUncertainty @9 :UInt8; + gpsToGlonassTimeBiasMilliseconds @10 :Float32; + gpsToGlonassTimeBiasMillisecondsUncertainty @11 :Float32; + + gpsWeek @12 :UInt16; + gpsMilliseconds @13 :UInt32; + gpsTimeBiasMs @14 :UInt32; + gpsClockTimeUncertaintyMs @15 :UInt32; + gpsClockSource @16 :UInt8; + + glonassClockSource @17 :UInt8; + glonassYear @18 :UInt8; + glonassDay @19 :UInt16; + glonassMilliseconds @20 :UInt32; + glonassTimeBias @21 :Float32; + glonassClockTimeUncertainty @22 :Float32; + + clockFrequencyBias @23 :Float32; + clockFrequencyUncertainty @24 :Float32; + frequencySource @25 :UInt8; + + source @26 :MeasurementSource; + + sv @27 :List(SV); + + struct SV @0xf08b81df8cbf459c { + svId @0 :UInt8; + glonassFrequencyIndex @1 :Int8; + observationState @2 :SVObservationState; + observations @3 :UInt8; + goodObservations @4 :UInt8; + filterStages @5 :UInt8; + predetectInterval @6 :UInt8; + cycleSlipCount @7 :UInt8; + postdetections @8 :UInt16; + + measurementStatus @9 :MeasurementStatus; + + carrierNoise @10 :UInt16; + rfLoss @11 :UInt16; + latency @12 :Int16; + + filteredMeasurementFraction @13 :Float32; + filteredMeasurementIntegral @14 :UInt32; + filteredTimeUncertainty @15 :Float32; + filteredSpeed @16 :Float32; + filteredSpeedUncertainty @17 :Float32; + + unfilteredMeasurementFraction @18 :Float32; + unfilteredMeasurementIntegral @19 :UInt32; + unfilteredTimeUncertainty @20 :Float32; + unfilteredSpeed @21 :Float32; + unfilteredSpeedUncertainty @22 :Float32; + + multipathEstimate @23 :UInt32; + azimuth @24 :Float32; + elevation @25 :Float32; + dopplerAcceleration @26 :Float32; + fineSpeed @27 :Float32; + fineSpeedUncertainty @28 :Float32; + + carrierPhase @29 :Float64; + fCount @30 :UInt32; + + parityErrorCount @31 :UInt16; + goodParity @32 :Bool; + } + } + + struct DrSvPolyReport @0xb1fb80811a673270 { + svId @0 :UInt16; + frequencyIndex @1 :Int8; + + hasPosition @2 :Bool; + hasIono @3 :Bool; + hasTropo @4 :Bool; + hasElevation @5 :Bool; + polyFromXtra @6 :Bool; + hasSbasIono @7 :Bool; + + iode @8 :UInt16; + t0 @9 :Float64; + xyz0 @10 :List(Float64); + xyzN @11 :List(Float64); + other @12 :List(Float32); + + positionUncertainty @13 :Float32; + ionoDelay @14 :Float32; + ionoDot @15 :Float32; + sbasIonoDelay @16 :Float32; + sbasIonoDot @17 :Float32; + tropoDelay @18 :Float32; + elevation @19 :Float32; + elevationDot @20 :Float32; + elevationUncertainty @21 :Float32; + velocityCoeff @22 :List(Float64); + } +} + +struct LidarPts @0xe3d6685d4e9d8f7a { + r @0 :List(UInt16); # uint16 m*500.0 + theta @1 :List(UInt16); # uint16 deg*100.0 + reflect @2 :List(UInt8); # uint8 0-255 + + # For storing out of file. + idx @3 :UInt64; + + # For storing in file + pkt @4 :Data; +} + + diff --git a/cereal/log.capnp b/cereal/log.capnp index adf76c488dacd3..473a9f6b8a54f9 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -1,11 +1,8 @@ using Cxx = import "./include/c++.capnp"; $Cxx.namespace("cereal"); -using Java = import "./include/java.capnp"; -$Java.package("ai.comma.openpilot.cereal"); -$Java.outerClassname("Log"); - using Car = import "car.capnp"; +using Legacy = import "legacy.capnp"; @0xf3b1f17e25a4285b; @@ -22,6 +19,7 @@ struct Map(Key, Value) { struct InitData { kernelArgs @0 :List(Text); kernelVersion @15 :Text; + osVersion @18 :Text; gctx @1 :Text; dongleId @2 :Text; @@ -32,25 +30,36 @@ struct InitData { gitBranch @11 :Text; gitRemote @13 :Text; - androidBuildInfo @5 :AndroidBuildInfo; - androidSensors @6 :List(AndroidSensor); androidProperties @16 :Map(Text, Text); - chffrAndroidExtra @7 :ChffrAndroidExtra; - iosBuildInfo @14 :IosBuildInfo; pandaInfo @8 :PandaInfo; dirty @9 :Bool; passive @12 :Bool; - params @17 :Map(Text, Text); + params @17 :Map(Text, Data); enum DeviceType { unknown @0; neo @1; chffrAndroid @2; chffrIos @3; + tici @4; + pc @5; } + struct PandaInfo { + hasPanda @0 :Bool; + dongleId @1 :Text; + stVersion @2 :Text; + espVersion @3 :Text; + } + + # ***** deprecated stuff ***** + androidBuildInfo @5 :AndroidBuildInfo; + androidSensorsDEPRECATED @6 :List(AndroidSensor); + chffrAndroidExtraDEPRECATED @7 :ChffrAndroidExtra; + iosBuildInfoDEPRECATED @14 :IosBuildInfo; + struct AndroidBuildInfo { board @0 :Text; bootloader @1 :Text; @@ -105,38 +114,48 @@ struct InitData { osVersion @2 :Text; deviceModel @3 :Text; } - - struct PandaInfo { - hasPanda @0 :Bool; - dongleId @1 :Text; - stVersion @2 :Text; - espVersion @3 :Text; - } } struct FrameData { frameId @0 :UInt32; encodeId @1 :UInt32; # DEPRECATED - timestampEof @2 :UInt64; + + frameType @7 :FrameType; frameLength @3 :Int32; + + # Timestamps + timestampEof @2 :UInt64; + timestampSof @8 :UInt64; + + # Exposure integLines @4 :Int32; - globalGain @5 :Int32; + highConversionGain @20 :Bool; + gain @15 :Float32; # This includes highConversionGain if enabled + measuredGreyFraction @21 :Float32; + targetGreyFraction @22 :Float32; + + # Focus lensPos @11 :Int32; lensSag @12 :Float32; lensErr @13 :Float32; lensTruePos @14 :Float32; - image @6 :Data; + focusVal @16 :List(Int16); + focusConf @17 :List(UInt8); + sharpnessScore @18 :List(UInt16); + recoverState @19 :Int32; - frameType @7 :FrameType; - timestampSof @8 :UInt64; transform @10 :List(Float32); androidCaptureResult @9 :AndroidCaptureResult; + image @6 :Data; + globalGainDEPRECATED @5 :Int32; + enum FrameType { unknown @0; neo @1; chffrAndroid @2; + front @3; } struct AndroidCaptureResult { @@ -180,6 +199,7 @@ struct SensorEventData { gyroUncalibrated @12 :SensorVec; proximity @13: Float32; light @14: Float32; + temperature @15: Float32; } source @8 :SensorSource; @@ -197,6 +217,10 @@ struct SensorEventData { lsm6ds3 @5; # accelerometer (c2) bmp280 @6; # barometer (c2) mmc3416x @7; # magnetometer (c2) + bmx055 @8; + rpr0521 @9; + lsm6ds3trc @10; + mmc5603nj @11; } } @@ -218,7 +242,7 @@ struct GpsLocationData { speed @4 :Float32; # Represents heading in degrees. - bearing @5 :Float32; + bearingDeg @5 :Float32; # Represents expected accuracy in meters. (presumably 1 sigma?) accuracy @6 :Float32; @@ -236,7 +260,7 @@ struct GpsLocationData { verticalAccuracy @10 :Float32; # Represents bearing accuracy in degrees. (presumably 1 sigma?) - bearingAccuracy @11 :Float32; + bearingAccuracyDeg @11 :Float32; # Represents velocity accuracy in m/s. (presumably 1 sigma?) speedAccuracy @12 :Float32; @@ -260,71 +284,196 @@ struct CanData { src @3 :UInt8; } -struct ThermalData { - cpu0 @0 :UInt16; - cpu1 @1 :UInt16; - cpu2 @2 :UInt16; - cpu3 @3 :UInt16; - mem @4 :UInt16; - gpu @5 :UInt16; - bat @6 :UInt32; - - # not thermal - freeSpace @7 :Float32; - batteryPercent @8 :Int16; - batteryStatus @9 :Text; - batteryCurrent @15 :Int32; - batteryVoltage @16 :Int32; +struct DeviceState @0xa4d8b5af2aa492eb { usbOnline @12 :Bool; + networkType @22 :NetworkType; + networkInfo @31 :NetworkInfo; + networkStrength @24 :NetworkStrength; + lastAthenaPingTime @32 :UInt64; - fanSpeed @10 :UInt16; started @11 :Bool; - startedTs @13 :UInt64; + startedMonoTime @13 :UInt64; - thermalStatus @14 :ThermalStatus; + # system utilization + freeSpacePercent @7 :Float32; + memoryUsagePercent @19 :Int8; + gpuUsagePercent @33 :Int8; + cpuUsagePercent @34 :List(Int8); # per-core cpu usage + + # power + batteryPercent @8 :Int16; + batteryCurrent @15 :Int32; chargingError @17 :Bool; chargingDisabled @18 :Bool; + offroadPowerUsageUwh @23 :UInt32; + carBatteryCapacityUwh @25 :UInt32; + powerDrawW @40 :Float32; + + # device thermals + cpuTempC @26 :List(Float32); + gpuTempC @27 :List(Float32); + memoryTempC @28 :Float32; + ambientTempC @30 :Float32; + nvmeTempC @35 :List(Float32); + modemTempC @36 :List(Float32); + pmicTempC @39 :List(Float32); + thermalZones @38 :List(ThermalZone); + thermalStatus @14 :ThermalStatus; + + fanSpeedPercentDesired @10 :UInt16; + screenBrightnessPercent @37 :Int8; + + struct ThermalZone { + name @0 :Text; + temp @1 :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 + green @0; + yellow @1; + red @2; + danger @3; + } + + enum NetworkType { + none @0; + wifi @1; + cell2G @2; + cell3G @3; + cell4G @4; + cell5G @5; + ethernet @6; + } + + enum NetworkStrength { + unknown @0; + poor @1; + moderate @2; + good @3; + great @4; + } + + struct NetworkInfo { + technology @0 :Text; + operator @1 :Text; + band @2 :Text; + channel @3 :UInt16; + extra @4 :Text; + state @5 :Text; } + + # 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; + cpuUsagePercentDEPRECATED @20 :Int8; + batteryStatusDEPRECATED @9 :Text; + batteryVoltageDEPRECATED @16 :Int32; + batteryTempCDEPRECATED @29 :Float32; } -struct HealthData { - # from can health - voltage @0 :UInt32; - current @1 :UInt32; - started @2 :Bool; +struct PandaState @0xa7649e2575e4591e { + ignitionLine @2 :Bool; controlsAllowed @3 :Bool; gasInterceptorDetected @4 :Bool; - startedSignalDetected @5 :Bool; - isGreyPanda @6 :Bool; + canSendErrs @7 :UInt32; + canFwdErrs @8 :UInt32; + canRxErrs @19 :UInt32; + gmlanSendErrs @9 :UInt32; + pandaType @10 :PandaType; + ignitionCan @13 :Bool; + safetyModel @14 :Car.CarParams.SafetyModel; + safetyParam @20 :Int16; + faultStatus @15 :FaultStatus; + powerSaveEnabled @16 :Bool; + uptime @17 :UInt32; + faults @18 :List(FaultType); + harnessStatus @21 :HarnessStatus; + heartbeatLost @22 :Bool; + + 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; + interruptRateTick @21; + # Update max fault type in boardd when adding faults + } + + enum PandaType @0x8a58adf93e5b3751 { + unknown @0; + whitePanda @1; + greyPanda @2; + blackPanda @3; + pedal @4; + uno @5; + dos @6; + redPanda @7; + } + + enum HarnessStatus { + notConnected @0; + normal @1; + flipped @2; + } + + startedSignalDetectedDEPRECATED @5 :Bool; + voltageDEPRECATED @0 :UInt32; + currentDEPRECATED @1 :UInt32; + hasGpsDEPRECATED @6 :Bool; + fanSpeedRpmDEPRECATED @11 :UInt16; + usbPowerModeDEPRECATED @12 :PeripheralState.UsbPowerMode; } -struct LiveUI { - rearViewCam @0 :Bool; - alertText1 @1 :Text; - alertText2 @2 :Text; - awarenessStatus @3 :Float32; +struct PeripheralState { + pandaType @0 :PandaState.PandaType; + voltage @1 :UInt32; + current @2 :UInt32; + fanSpeedRpm @3 :UInt16; + usbPowerMode @4 :UsbPowerMode; + + enum UsbPowerMode @0xa8883583b32c9877 { + none @0; + client @1; + cdp @2; + dcp @3; + } } struct RadarState @0x9a185389d6fdd05f { canMonoTimes @10 :List(UInt64); mdMonoTime @6 :UInt64; - ftMonoTimeDEPRECATED @7 :UInt64; - controlsStateMonoTime @11 :UInt64; + carStateMonoTime @11 :UInt64; radarErrors @12 :List(Car.RadarData.Error); - # all deprecated - warpMatrixDEPRECATED @0 :List(Float32); - angleOffsetDEPRECATED @1 :Float32; - calStatusDEPRECATED @2 :Int8; - calCycleDEPRECATED @8 :Int32; - calPercDEPRECATED @9 :Int8; - leadOne @3 :LeadData; leadTwo @4 :LeadData; cumLagMs @5 :Float32; @@ -335,7 +484,6 @@ struct RadarState @0x9a185389d6fdd05f { vRel @2 :Float32; aRel @3 :Float32; vLead @4 :Float32; - aLeadDEPRECATED @5 :Float32; dPath @6 :Float32; vLat @7 :Float32; vLeadK @8 :Float32; @@ -343,22 +491,37 @@ struct RadarState @0x9a185389d6fdd05f { fcw @10 :Bool; status @11 :Bool; aLeadTau @12 :Float32; + modelProb @13 :Float32; + radar @14 :Bool; + + aLeadDEPRECATED @5 :Float32; } + + # deprecated + ftMonoTimeDEPRECATED @7 :UInt64; + warpMatrixDEPRECATED @0 :List(Float32); + angleOffsetDEPRECATED @1 :Float32; + calStatusDEPRECATED @2 :Int8; + calCycleDEPRECATED @8 :Int32; + calPercDEPRECATED @9 :Int8; } 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); + + warpMatrixDEPRECATED @0 :List(Float32); + warpMatrix2DEPRECATED @5 :List(Float32); + warpMatrixBigDEPRECATED @6 :List(Float32); } struct LiveTracks { @@ -375,68 +538,45 @@ struct LiveTracks { } struct ControlsState @0x97ff69c53601abf1 { - canMonoTimeDEPRECATED @16 :UInt64; + startMonoTime @48 :UInt64; canMonoTimes @21 :List(UInt64); - radarStateMonoTimeDEPRECATED @17 :UInt64; - mdMonoTimeDEPRECATED @18 :UInt64; - planMonoTime @28 :UInt64; - pathPlanMonoTime @50 :UInt64; + longitudinalPlanMonoTime @28 :UInt64; + lateralPlanMonoTime @50 :UInt64; state @31 :OpenpilotState; - vEgo @0 :Float32; - vEgoRaw @32 :Float32; - aEgoDEPRECATED @1 :Float32; - longControlState @30 :LongControlState; + enabled @19 :Bool; + active @36 :Bool; + + longControlState @30 :Car.CarControl.Actuators.LongControlState; vPid @2 :Float32; vTargetLead @3 :Float32; + vCruise @22 :Float32; upAccelCmd @4 :Float32; uiAccelCmd @5 :Float32; ufAccelCmd @33 :Float32; - yActualDEPRECATED @6 :Float32; - yDesDEPRECATED @7 :Float32; - upSteerDEPRECATED @8 :Float32; - uiSteerDEPRECATED @9 :Float32; - ufSteerDEPRECATED @34 :Float32; - aTargetMinDEPRECATED @10 :Float32; - aTargetMaxDEPRECATED @11 :Float32; aTarget @35 :Float32; - jerkFactor @12 :Float32; - angleSteers @13 :Float32; # Steering angle in degrees. - angleSteersDes @29 :Float32; - curvature @37 :Float32; # path curvature from vehicle model - hudLeadDEPRECATED @14 :Int32; - cumLagMs @15 :Float32; - startMonoTime @48 :UInt64; - mapValid @49 :Bool; + curvature @37 :Float32; # path curvature from vehicle model forceDecel @51 :Bool; - enabled @19 :Bool; - active @36 :Bool; - steerOverride @20 :Bool; - - vCruise @22 :Float32; - - rearViewCam @23 :Bool; + # UI alerts alertText1 @24 :Text; alertText2 @25 :Text; alertStatus @38 :AlertStatus; alertSize @39 :AlertSize; alertBlinkingRate @42 :Float32; alertType @44 :Text; - alertSound @45 :Text; - awarenessStatus @26 :Float32; - angleModelBias @27 :Float32; - gpsPlannerActive @40 :Bool; + alertSound @56 :Car.CarControl.HUDControl.AudibleAlert; engageable @41 :Bool; # can OP be engaged? - driverMonitoringOn @43 :Bool; - # maps - vCurvature @46 :Float32; - decelForTurn @47 :Bool; + cumLagMs @15 :Float32; + canErrorCounter @57 :UInt32; lateralControlState :union { indiState @52 :LateralINDIState; pidState @53 :LateralPIDState; + lqrState @55 :LateralLQRState; + angleState @58 :LateralAngleState; + debugState @59 :LateralDebugState; } enum OpenpilotState @0xdbe58b96d2d1ac61 { @@ -446,16 +586,9 @@ struct ControlsState @0x97ff69c53601abf1 { softDisabling @3; } - enum LongControlState { - off @0; - pid @1; - stopping @2; - starting @3; - } - 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 } @@ -468,80 +601,181 @@ struct ControlsState @0x97ff69c53601abf1 { struct LateralINDIState { active @0 :Bool; - steerAngle @1 :Float32; - steerRate @2 :Float32; - steerAccel @3 :Float32; + steeringAngleDeg @1 :Float32; + steeringRateDeg @2 :Float32; + steeringAccelDeg @3 :Float32; rateSetPoint @4 :Float32; accelSetPoint @5 :Float32; accelError @6 :Float32; delayedOutput @7 :Float32; delta @8 :Float32; output @9 :Float32; + saturated @10 :Bool; + steeringAngleDesiredDeg @11 :Float32; + steeringRateDesiredDeg @12 :Float32; } struct LateralPIDState { active @0 :Bool; - steerAngle @1 :Float32; - steerRate @2 :Float32; + steeringAngleDeg @1 :Float32; + steeringRateDeg @2 :Float32; angleError @3 :Float32; p @4 :Float32; i @5 :Float32; f @6 :Float32; output @7 :Float32; saturated @8 :Bool; + steeringAngleDesiredDeg @9 :Float32; } -} + struct LateralLQRState { + active @0 :Bool; + steeringAngleDeg @1 :Float32; + i @2 :Float32; + output @3 :Float32; + lqrOutput @4 :Float32; + saturated @5 :Bool; + steeringAngleDesiredDeg @6 :Float32; + } + + struct LateralAngleState { + active @0 :Bool; + steeringAngleDeg @1 :Float32; + output @2 :Float32; + saturated @3 :Bool; + steeringAngleDesiredDeg @4 :Float32; + } + + struct LateralDebugState { + active @0 :Bool; + steeringAngleDeg @1 :Float32; + output @2 :Float32; + saturated @3 :Bool; + } -struct LiveEventData { - name @0 :Text; - value @1 :Int32; + # deprecated + vEgoDEPRECATED @0 :Float32; + vEgoRawDEPRECATED @32 :Float32; + aEgoDEPRECATED @1 :Float32; + canMonoTimeDEPRECATED @16 :UInt64; + radarStateMonoTimeDEPRECATED @17 :UInt64; + mdMonoTimeDEPRECATED @18 :UInt64; + yActualDEPRECATED @6 :Float32; + yDesDEPRECATED @7 :Float32; + upSteerDEPRECATED @8 :Float32; + uiSteerDEPRECATED @9 :Float32; + ufSteerDEPRECATED @34 :Float32; + aTargetMinDEPRECATED @10 :Float32; + aTargetMaxDEPRECATED @11 :Float32; + rearViewCamDEPRECATED @23 :Bool; + driverMonitoringOnDEPRECATED @43 :Bool; + hudLeadDEPRECATED @14 :Int32; + alertSoundDEPRECATED @45 :Text; + angleModelBiasDEPRECATED @27 :Float32; + gpsPlannerActiveDEPRECATED @40 :Bool; + decelForTurnDEPRECATED @47 :Bool; + decelForModelDEPRECATED @54 :Bool; + awarenessStatusDEPRECATED @26 :Float32; + angleSteersDEPRECATED @13 :Float32; + vCurvatureDEPRECATED @46 :Float32; + mapValidDEPRECATED @49 :Bool; + jerkFactorDEPRECATED @12 :Float32; + steerOverrideDEPRECATED @20 :Bool; + steeringAngleDesiredDegDEPRECATED @29 :Float32; } -struct ModelData { +struct ModelDataV2 { frameId @0 :UInt32; + frameAge @1 :UInt32; + frameDropPerc @2 :Float32; + timestampEof @3 :UInt64; + modelExecutionTime @15 :Float32; + gpuExecutionTime @17 :Float32; + rawPredictions @16 :Data; + + # predicted future position, orientation, etc.. + position @4 :XYZTData; + orientation @5 :XYZTData; + velocity @6 :XYZTData; + orientationRate @7 :XYZTData; + acceleration @19 :XYZTData; + + # prediction lanelines and road edges + laneLines @8 :List(XYZTData); + laneLineProbs @9 :List(Float32); + laneLineStds @13 :List(Float32); + roadEdges @10 :List(XYZTData); + roadEdgeStds @14 :List(Float32); + + # predicted lead cars + leads @11 :List(LeadDataV2); + leadsV3 @18 :List(LeadDataV3); + + meta @12 :MetaData; + + # All SI units and in device frame + 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); + } - path @1 :PathData; - leftLane @2 :PathData; - rightLane @3 :PathData; - lead @4 :LeadData; - freePath @6 :List(Float32); - - settings @5 :ModelSettings; + struct LeadDataV2 { + prob @0 :Float32; # probability that car is your lead at time t + t @1 :Float32; - struct PathData { - points @0 :List(Float32); - prob @1 :Float32; - std @2 :Float32; - stds @3 :List(Float32); - poly @4 :List(Float32); + # x and y are relative position in device frame + # v is norm relative speed + # a is norm relative acceleration + xyva @2 :List(Float32); + xyvaStd @3 :List(Float32); } - struct LeadData { - dist @0 :Float32; - prob @1 :Float32; - std @2 :Float32; - relVel @3 :Float32; - relVelStd @4 :Float32; + struct LeadDataV3 { + prob @0 :Float32; # probability that car is your lead at time t + probTime @1 :Float32; + t @2 :List(Float32); + + # x and y are relative position in device frame + # v absolute norm speed + # a is derivative of v + x @3 :List(Float32); + xStd @4 :List(Float32); + y @5 :List(Float32); + yStd @6 :List(Float32); + v @7 :List(Float32); + vStd @8 :List(Float32); + a @9 :List(Float32); + aStd @10 :List(Float32); } - struct ModelSettings { - bigBoxX @0 :UInt16; - bigBoxY @1 :UInt16; - bigBoxWidth @2 :UInt16; - bigBoxHeight @3 :UInt16; - boxProjection @4 :List(Float32); - yuvCorrection @5 :List(Float32); - inputTransform @6 :List(Float32); - } -} -struct CalibrationFeatures { - frameId @0 :UInt32; + struct MetaData { + engagedProb @0 :Float32; + desirePrediction @1 :List(Float32); + desireState @5 :List(Float32); + disengagePredictions @6 :DisengagePredictions; + hardBrakePredicted @7 :Bool; - p0 @1 :List(Float32); - p1 @2 :List(Float32); - status @3 :List(Int8); + # deprecated + brakeDisengageProbDEPRECATED @2 :Float32; + gasDisengageProbDEPRECATED @3 :Float32; + steerOverrideProbDEPRECATED @4 :Float32; + } + + struct DisengagePredictions { + t @0 :List(Float32); + brakeDisengageProbs @1 :List(Float32); + gasDisengageProbs @2 :List(Float32); + steerOverrideProbs @3 :List(Float32); + brake3MetersPerSecondSquaredProbs @4 :List(Float32); + brake4MetersPerSecondSquaredProbs @5 :List(Float32); + brake5MetersPerSecondSquaredProbs @6 :List(Float32); + } } struct EncodeIndex { @@ -556,6 +790,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 @@ -577,678 +813,176 @@ struct AndroidLogEntry { message @6 :Text; } -struct LogRotate { - segmentNum @0 :Int32; - path @1 :Text; -} - -struct Plan { - mdMonoTime @9 :UInt64; - radarStateMonoTime @10 :UInt64; - commIssue @31 :Bool; - - eventsDEPRECATED @13 :List(Car.CarEvent); - - # lateral, 3rd order polynomial - lateralValidDEPRECATED @0 :Bool; - dPolyDEPRECATED @1 :List(Float32); - laneWidthDEPRECATED @11 :Float32; - - # longitudinal - longitudinalValidDEPRECATED @2 :Bool; - vCruise @16 :Float32; - aCruise @17 :Float32; - vTarget @3 :Float32; - vTargetFuture @14 :Float32; - vMax @20 :Float32; - aTargetMinDEPRECATED @4 :Float32; - aTargetMaxDEPRECATED @5 :Float32; - aTarget @18 :Float32; - - vStart @26 :Float32; - aStart @27 :Float32; - - jerkFactor @6 :Float32; +struct LongitudinalPlan @0xe00b5b3eba12876c { + modelMonoTime @9 :UInt64; hasLead @7 :Bool; - hasLeftLaneDEPRECATED @23 :Bool; - hasRightLaneDEPRECATED @24 :Bool; fcw @8 :Bool; longitudinalPlanSource @15 :LongitudinalPlanSource; + processingDelay @29 :Float32; - # gps trajectory in car frame - gpsTrajectory @12 :GpsTrajectory; - - gpsPlannerActive @19 :Bool; - - # maps - vCurvature @21 :Float32; - decelForTurn @22 :Bool; - mapValid @25 :Bool; - radarValid @28 :Bool; - radarCanError @30 :Bool; + # desired speed/accel/jerk over next 2.5s + accels @32 :List(Float32); + speeds @33 :List(Float32); + jerks @34 :List(Float32); - processingDelay @29 :Float32; + enum LongitudinalPlanSource { + cruise @0; + lead0 @1; + lead1 @2; + lead2 @3; + e2e @4; + } + # deprecated + vCruiseDEPRECATED @16 :Float32; + aCruiseDEPRECATED @17 :Float32; + vTargetDEPRECATED @3 :Float32; + vTargetFutureDEPRECATED @14 :Float32; + aTargetDEPRECATED @18 :Float32; + vStartDEPRECATED @26 :Float32; + aStartDEPRECATED @27 :Float32; + vMaxDEPRECATED @20 :Float32; + radarStateMonoTimeDEPRECATED @10 :UInt64; + jerkFactorDEPRECATED @6 :Float32; + hasLeftLaneDEPRECATED @23 :Bool; + hasRightLaneDEPRECATED @24 :Bool; + aTargetMinDEPRECATED @4 :Float32; + aTargetMaxDEPRECATED @5 :Float32; + lateralValidDEPRECATED @0 :Bool; + longitudinalValidDEPRECATED @2 :Bool; + dPolyDEPRECATED @1 :List(Float32); + laneWidthDEPRECATED @11 :Float32; + vCurvatureDEPRECATED @21 :Float32; + decelForTurnDEPRECATED @22 :Bool; + mapValidDEPRECATED @25 :Bool; + radarValidDEPRECATED @28 :Bool; + radarCanErrorDEPRECATED @30 :Bool; + commIssueDEPRECATED @31 :Bool; + eventsDEPRECATED @13 :List(Car.CarEvent); + gpsTrajectoryDEPRECATED @12 :GpsTrajectory; + gpsPlannerActiveDEPRECATED @19 :Bool; struct GpsTrajectory { x @0 :List(Float32); y @1 :List(Float32); } - - enum LongitudinalPlanSource { - cruise @0; - mpc1 @1; - mpc2 @2; - mpc3 @3; - } } -struct PathPlan { +struct LateralPlan @0xe1e9318e2ae8b51e { laneWidth @0 :Float32; - - dPoly @1 :List(Float32); - cPoly @2 :List(Float32); - cProb @3 :Float32; - lPoly @4 :List(Float32); lProb @5 :Float32; - rPoly @6 :List(Float32); rProb @7 :Float32; + dPathPoints @20 :List(Float32); + dProb @21 :Float32; - angleSteers @8 :Float32; # deg - rateSteers @13 :Float32; # deg/s mpcSolutionValid @9 :Bool; - paramsValid @10 :Bool; - modelValidDEPRECATED @12 :Bool; - angleOffset @11 :Float32; - sensorValid @14 :Bool; - commIssue @15 :Bool; -} - -struct LiveLocationData { - status @0 :UInt8; - - # 3D fix - lat @1 :Float64; - lon @2 :Float64; - alt @3 :Float32; # m - - # speed - speed @4 :Float32; # m/s - - # NED velocity components - vNED @5 :List(Float32); - - # roll, pitch, heading (x,y,z) - roll @6 :Float32; # WRT to center of earth? - pitch @7 :Float32; # WRT to center of earth? - heading @8 :Float32; # WRT to north? - - # what are these? - wanderAngle @9 :Float32; - trackAngle @10 :Float32; - - # car frame -- https://upload.wikimedia.org/wikipedia/commons/f/f5/RPY_angles_of_cars.png - - # gyro, in car frame, deg/s - gyro @11 :List(Float32); - - # accel, in car frame, m/s^2 - accel @12 :List(Float32); + desire @17 :Desire; + laneChangeState @18 :LaneChangeState; + laneChangeDirection @19 :LaneChangeDirection; + useLaneLines @29 :Bool; - accuracy @13 :Accuracy; + # desired curvatures over next 2.5s in rad/m + psis @26 :List(Float32); + curvatures @27 :List(Float32); + curvatureRates @28 :List(Float32); - source @14 :SensorSource; - # if we are fixing a location in the past - fixMonoTime @15 :UInt64; - - gpsWeek @16 :Int32; - timeOfWeek @17 :Float64; - - positionECEF @18 :List(Float64); - poseQuatECEF @19 :List(Float32); - pitchCalibration @20 :Float32; - yawCalibration @21 :Float32; - imuFrame @22 :List(Float32); - - struct Accuracy { - pNEDError @0 :List(Float32); - vNEDError @1 :List(Float32); - rollError @2 :Float32; - pitchError @3 :Float32; - headingError @4 :Float32; - ellipsoidSemiMajorError @5 :Float32; - ellipsoidSemiMinorError @6 :Float32; - ellipsoidOrientationError @7 :Float32; - } - - enum SensorSource { - applanix @0; - kalman @1; - orbslam @2; - timing @3; - dummy @4; - } -} - -struct EthernetPacket { - pkt @0 :Data; - ts @1 :Float32; -} - -struct NavUpdate { - isNavigating @0 :Bool; - curSegment @1 :Int32; - segments @2 :List(Segment); - - struct LatLng { - lat @0 :Float64; - lng @1 :Float64; - } - - struct Segment { - from @0 :LatLng; - to @1 :LatLng; - updateTime @2 :Int32; - distance @3 :Int32; - crossTime @4 :Int32; - exitNo @5 :Int32; - instruction @6 :Instruction; - - parts @7 :List(LatLng); - - enum Instruction { - turnLeft @0; - turnRight @1; - keepLeft @2; - keepRight @3; - straight @4; - roundaboutExitNumber @5; - roundaboutExit @6; - roundaboutTurnLeft @7; - unkn8 @8; - roundaboutStraight @9; - unkn10 @10; - roundaboutTurnRight @11; - unkn12 @12; - roundaboutUturn @13; - unkn14 @14; - arrive @15; - exitLeft @16; - exitRight @17; - unkn18 @18; - uturn @19; - # ... - } - } -} - -struct NavStatus { - isNavigating @0 :Bool; - currentAddress @1 :Address; - - struct Address { - title @0 :Text; - lat @1 :Float64; - lng @2 :Float64; - house @3 :Text; - address @4 :Text; - street @5 :Text; - city @6 :Text; - state @7 :Text; - country @8 :Text; - } -} - -struct CellInfo { - timestamp @0 :UInt64; - repr @1 :Text; # android toString() for now -} - -struct WifiScan { - bssid @0 :Text; - ssid @1 :Text; - capabilities @2 :Text; - frequency @3 :Int32; - level @4 :Int32; - timestamp @5 :Int64; - - centerFreq0 @6 :Int32; - centerFreq1 @7 :Int32; - channelWidth @8 :ChannelWidth; - operatorFriendlyName @9 :Text; - venueName @10 :Text; - is80211mcResponder @11 :Bool; - passpoint @12 :Bool; - - distanceCm @13 :Int32; - distanceSdCm @14 :Int32; - - enum ChannelWidth { - w20Mhz @0; - w40Mhz @1; - w80Mhz @2; - w160Mhz @3; - w80Plus80Mhz @4; + enum Desire { + none @0; + turnLeft @1; + turnRight @2; + laneChangeLeft @3; + laneChangeRight @4; + keepLeft @5; + keepRight @6; } -} -struct AndroidGnss { - union { - measurements @0 :Measurements; - navigationMessage @1 :NavigationMessage; + enum LaneChangeState { + off @0; + preLaneChange @1; + laneChangeStarting @2; + laneChangeFinishing @3; } - struct Measurements { - clock @0 :Clock; - measurements @1 :List(Measurement); - - struct Clock { - timeNanos @0 :Int64; - hardwareClockDiscontinuityCount @1 :Int32; - - hasTimeUncertaintyNanos @2 :Bool; - timeUncertaintyNanos @3 :Float64; - - hasLeapSecond @4 :Bool; - leapSecond @5 :Int32; - - hasFullBiasNanos @6 :Bool; - fullBiasNanos @7 :Int64; - - hasBiasNanos @8 :Bool; - biasNanos @9 :Float64; - - hasBiasUncertaintyNanos @10 :Bool; - biasUncertaintyNanos @11 :Float64; - - hasDriftNanosPerSecond @12 :Bool; - driftNanosPerSecond @13 :Float64; - - hasDriftUncertaintyNanosPerSecond @14 :Bool; - driftUncertaintyNanosPerSecond @15 :Float64; - } - - struct Measurement { - svId @0 :Int32; - constellation @1 :Constellation; - - timeOffsetNanos @2 :Float64; - state @3 :Int32; - receivedSvTimeNanos @4 :Int64; - receivedSvTimeUncertaintyNanos @5 :Int64; - cn0DbHz @6 :Float64; - pseudorangeRateMetersPerSecond @7 :Float64; - pseudorangeRateUncertaintyMetersPerSecond @8 :Float64; - accumulatedDeltaRangeState @9 :Int32; - accumulatedDeltaRangeMeters @10 :Float64; - accumulatedDeltaRangeUncertaintyMeters @11 :Float64; - - hasCarrierFrequencyHz @12 :Bool; - carrierFrequencyHz @13 :Float32; - hasCarrierCycles @14 :Bool; - carrierCycles @15 :Int64; - hasCarrierPhase @16 :Bool; - carrierPhase @17 :Float64; - hasCarrierPhaseUncertainty @18 :Bool; - carrierPhaseUncertainty @19 :Float64; - hasSnrInDb @20 :Bool; - snrInDb @21 :Float64; - - multipathIndicator @22 :MultipathIndicator; - - enum Constellation { - unknown @0; - gps @1; - sbas @2; - glonass @3; - qzss @4; - beidou @5; - galileo @6; - } - - enum State { - unknown @0; - codeLock @1; - bitSync @2; - subframeSync @3; - towDecoded @4; - msecAmbiguous @5; - symbolSync @6; - gloStringSync @7; - gloTodDecoded @8; - bdsD2BitSync @9; - bdsD2SubframeSync @10; - galE1bcCodeLock @11; - galE1c2ndCodeLock @12; - galE1bPageSync @13; - sbasSync @14; - } - - enum MultipathIndicator { - unknown @0; - detected @1; - notDetected @2; - } - } + enum LaneChangeDirection { + none @0; + left @1; + right @2; } - struct NavigationMessage { - type @0 :Int32; - svId @1 :Int32; - messageId @2 :Int32; - submessageId @3 :Int32; - data @4 :Data; - status @5 :Status; - - enum Status { - unknown @0; - parityPassed @1; - parityRebuilt @2; - } - } + # deprecated + curvatureDEPRECATED @22 :Float32; + curvatureRateDEPRECATED @23 :Float32; + rawCurvatureDEPRECATED @24 :Float32; + rawCurvatureRateDEPRECATED @25 :Float32; + cProbDEPRECATED @3 :Float32; + dPolyDEPRECATED @1 :List(Float32); + cPolyDEPRECATED @2 :List(Float32); + lPolyDEPRECATED @4 :List(Float32); + rPolyDEPRECATED @6 :List(Float32); + modelValidDEPRECATED @12 :Bool; + commIssueDEPRECATED @15 :Bool; + posenetValidDEPRECATED @16 :Bool; + sensorValidDEPRECATED @14 :Bool; + paramsValidDEPRECATED @10 :Bool; + steeringAngleDegDEPRECATED @8 :Float32; # deg + steeringRateDegDEPRECATED @13 :Float32; # deg/s + angleOffsetDegDEPRECATED @11 :Float32; } -struct QcomGnss { - logTs @0 :UInt64; - union { - measurementReport @1 :MeasurementReport; - clockReport @2 :ClockReport; - drMeasurementReport @3 :DrMeasurementReport; - drSvPoly @4 :DrSvPolyReport; - rawLog @5 :Data; - } - - enum MeasurementSource @0xd71a12b6faada7ee { - gps @0; - glonass @1; - beidou @2; - } - - enum SVObservationState @0xe81e829a0d6c83e9 { - idle @0; - search @1; - searchVerify @2; - bitEdge @3; - trackVerify @4; - track @5; - restart @6; - dpo @7; - glo10msBe @8; - glo10msAt @9; - } - - struct MeasurementStatus @0xe501010e1bcae83b { - subMillisecondIsValid @0 :Bool; - subBitTimeIsKnown @1 :Bool; - satelliteTimeIsKnown @2 :Bool; - bitEdgeConfirmedFromSignal @3 :Bool; - measuredVelocity @4 :Bool; - fineOrCoarseVelocity @5 :Bool; - lockPointValid @6 :Bool; - lockPointPositive @7 :Bool; - lastUpdateFromDifference @8 :Bool; - lastUpdateFromVelocityDifference @9 :Bool; - strongIndicationOfCrossCorelation @10 :Bool; - tentativeMeasurement @11 :Bool; - measurementNotUsable @12 :Bool; - sirCheckIsNeeded @13 :Bool; - probationMode @14 :Bool; - - glonassMeanderBitEdgeValid @15 :Bool; - glonassTimeMarkValid @16 :Bool; - - gpsRoundRobinRxDiversity @17 :Bool; - gpsRxDiversity @18 :Bool; - gpsLowBandwidthRxDiversityCombined @19 :Bool; - gpsHighBandwidthNu4 @20 :Bool; - gpsHighBandwidthNu8 @21 :Bool; - gpsHighBandwidthUniform @22 :Bool; - multipathIndicator @23 :Bool; - - imdJammingIndicator @24 :Bool; - lteB13TxJammingIndicator @25 :Bool; - freshMeasurementIndicator @26 :Bool; - - multipathEstimateIsValid @27 :Bool; - directionIsValid @28 :Bool; - } - - struct MeasurementReport { - source @0 :MeasurementSource; - - fCount @1 :UInt32; - - gpsWeek @2 :UInt16; - glonassCycleNumber @3 :UInt8; - glonassNumberOfDays @4 :UInt16; - - milliseconds @5 :UInt32; - timeBias @6 :Float32; - clockTimeUncertainty @7 :Float32; - clockFrequencyBias @8 :Float32; - clockFrequencyUncertainty @9 :Float32; - - sv @10 :List(SV); - - struct SV { - svId @0 :UInt8; - observationState @2 :SVObservationState; - observations @3 :UInt8; - goodObservations @4 :UInt8; - gpsParityErrorCount @5 :UInt16; - glonassFrequencyIndex @1 :Int8; - glonassHemmingErrorCount @6 :UInt8; - filterStages @7 :UInt8; - carrierNoise @8 :UInt16; - latency @9 :Int16; - predetectInterval @10 :UInt8; - postdetections @11 :UInt16; - - unfilteredMeasurementIntegral @12 :UInt32; - unfilteredMeasurementFraction @13 :Float32; - unfilteredTimeUncertainty @14 :Float32; - unfilteredSpeed @15 :Float32; - unfilteredSpeedUncertainty @16 :Float32; - measurementStatus @17 :MeasurementStatus; - multipathEstimate @18 :UInt32; - azimuth @19 :Float32; - elevation @20 :Float32; - carrierPhaseCyclesIntegral @21 :Int32; - carrierPhaseCyclesFraction @22 :UInt16; - fineSpeed @23 :Float32; - fineSpeedUncertainty @24 :Float32; - cycleSlipCount @25 :UInt8; - } - - } - - struct ClockReport { - hasFCount @0 :Bool; - fCount @1 :UInt32; - - hasGpsWeek @2 :Bool; - gpsWeek @3 :UInt16; - hasGpsMilliseconds @4 :Bool; - gpsMilliseconds @5 :UInt32; - gpsTimeBias @6 :Float32; - gpsClockTimeUncertainty @7 :Float32; - gpsClockSource @8 :UInt8; - - hasGlonassYear @9 :Bool; - glonassYear @10 :UInt8; - hasGlonassDay @11 :Bool; - glonassDay @12 :UInt16; - hasGlonassMilliseconds @13 :Bool; - glonassMilliseconds @14 :UInt32; - glonassTimeBias @15 :Float32; - glonassClockTimeUncertainty @16 :Float32; - glonassClockSource @17 :UInt8; - - bdsWeek @18 :UInt16; - bdsMilliseconds @19 :UInt32; - bdsTimeBias @20 :Float32; - bdsClockTimeUncertainty @21 :Float32; - bdsClockSource @22 :UInt8; - - galWeek @23 :UInt16; - galMilliseconds @24 :UInt32; - galTimeBias @25 :Float32; - galClockTimeUncertainty @26 :Float32; - galClockSource @27 :UInt8; - - clockFrequencyBias @28 :Float32; - clockFrequencyUncertainty @29 :Float32; - frequencySource @30 :UInt8; - gpsLeapSeconds @31 :UInt8; - gpsLeapSecondsUncertainty @32 :UInt8; - gpsLeapSecondsSource @33 :UInt8; - - gpsToGlonassTimeBiasMilliseconds @34 :Float32; - gpsToGlonassTimeBiasMillisecondsUncertainty @35 :Float32; - gpsToBdsTimeBiasMilliseconds @36 :Float32; - gpsToBdsTimeBiasMillisecondsUncertainty @37 :Float32; - bdsToGloTimeBiasMilliseconds @38 :Float32; - bdsToGloTimeBiasMillisecondsUncertainty @39 :Float32; - gpsToGalTimeBiasMilliseconds @40 :Float32; - gpsToGalTimeBiasMillisecondsUncertainty @41 :Float32; - galToGloTimeBiasMilliseconds @42 :Float32; - galToGloTimeBiasMillisecondsUncertainty @43 :Float32; - galToBdsTimeBiasMilliseconds @44 :Float32; - galToBdsTimeBiasMillisecondsUncertainty @45 :Float32; - - hasRtcTime @46 :Bool; - systemRtcTime @47 :UInt32; - fCountOffset @48 :UInt32; - lpmRtcCount @49 :UInt32; - clockResets @50 :UInt32; - } - - struct DrMeasurementReport { - - reason @0 :UInt8; - seqNum @1 :UInt8; - seqMax @2 :UInt8; - rfLoss @3 :UInt16; - - systemRtcValid @4 :Bool; - fCount @5 :UInt32; - clockResets @6 :UInt32; - systemRtcTime @7 :UInt64; +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 + calibratedOrientationNED @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; + timeSinceReset @23 :Float64; + excessiveResets @24 :Bool; - gpsLeapSeconds @8 :UInt8; - gpsLeapSecondsUncertainty @9 :UInt8; - gpsToGlonassTimeBiasMilliseconds @10 :Float32; - gpsToGlonassTimeBiasMillisecondsUncertainty @11 :Float32; - - gpsWeek @12 :UInt16; - gpsMilliseconds @13 :UInt32; - gpsTimeBiasMs @14 :UInt32; - gpsClockTimeUncertaintyMs @15 :UInt32; - gpsClockSource @16 :UInt8; - - glonassClockSource @17 :UInt8; - glonassYear @18 :UInt8; - glonassDay @19 :UInt16; - glonassMilliseconds @20 :UInt32; - glonassTimeBias @21 :Float32; - glonassClockTimeUncertainty @22 :Float32; - - clockFrequencyBias @23 :Float32; - clockFrequencyUncertainty @24 :Float32; - frequencySource @25 :UInt8; - - source @26 :MeasurementSource; - - sv @27 :List(SV); - - struct SV { - svId @0 :UInt8; - glonassFrequencyIndex @1 :Int8; - observationState @2 :SVObservationState; - observations @3 :UInt8; - goodObservations @4 :UInt8; - filterStages @5 :UInt8; - predetectInterval @6 :UInt8; - cycleSlipCount @7 :UInt8; - postdetections @8 :UInt16; - - measurementStatus @9 :MeasurementStatus; - - carrierNoise @10 :UInt16; - rfLoss @11 :UInt16; - latency @12 :Int16; - - filteredMeasurementFraction @13 :Float32; - filteredMeasurementIntegral @14 :UInt32; - filteredTimeUncertainty @15 :Float32; - filteredSpeed @16 :Float32; - filteredSpeedUncertainty @17 :Float32; - - unfilteredMeasurementFraction @18 :Float32; - unfilteredMeasurementIntegral @19 :UInt32; - unfilteredTimeUncertainty @20 :Float32; - unfilteredSpeed @21 :Float32; - unfilteredSpeedUncertainty @22 :Float32; - - multipathEstimate @23 :UInt32; - azimuth @24 :Float32; - elevation @25 :Float32; - dopplerAcceleration @26 :Float32; - fineSpeed @27 :Float32; - fineSpeedUncertainty @28 :Float32; - - carrierPhase @29 :Float64; - fCount @30 :UInt32; - - parityErrorCount @31 :UInt16; - goodParity @32 :Bool; - } + enum Status { + uninitialized @0; + uncalibrated @1; + valid @2; } - struct DrSvPolyReport { - svId @0 :UInt16; - frequencyIndex @1 :Int8; - - hasPosition @2 :Bool; - hasIono @3 :Bool; - hasTropo @4 :Bool; - hasElevation @5 :Bool; - polyFromXtra @6 :Bool; - hasSbasIono @7 :Bool; - - iode @8 :UInt16; - t0 @9 :Float64; - xyz0 @10 :List(Float64); - xyzN @11 :List(Float64); - other @12 :List(Float32); - - positionUncertainty @13 :Float32; - ionoDelay @14 :Float32; - ionoDot @15 :Float32; - sbasIonoDelay @16 :Float32; - sbasIonoDot @17 :Float32; - tropoDelay @18 :Float32; - elevation @19 :Float32; - elevationDot @20 :Float32; - elevationUncertainty @21 :Float32; - - velocityCoeff @22 :List(Float64); - + struct Measurement { + value @0 : List(Float64); + std @1 : List(Float64); + valid @2 : Bool; } } -struct LidarPts { - r @0 :List(UInt16); # uint16 m*500.0 - theta @1 :List(UInt16); # uint16 deg*100.0 - reflect @2 :List(UInt8); # uint8 0-255 - - # For storing out of file. - idx @3 :UInt64; - - # For storing in file - pkt @4 :Data; -} - struct ProcLog { cpuTimes @0 :List(CPUTimes); mem @1 :Mem; @@ -1299,7 +1033,6 @@ struct ProcLog { inactive @6 :UInt64; shared @7 :UInt64; } - } struct UbloxGnss { @@ -1307,6 +1040,8 @@ struct UbloxGnss { measurementReport @0 :MeasurementReport; ephemeris @1 :Ephemeris; ionoData @2 :IonoData; + hwStatus @3 :HwStatus; + hwStatus2 @4 :HwStatus2; } struct MeasurementReport { @@ -1430,8 +1165,48 @@ 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; + flags @5 :UInt8; + + enum AntennaSupervisorState { + init @0; + dontknow @1; + ok @2; + short @3; + open @4; + } + + enum AntennaPowerStatus { + off @0; + on @1; + dontknow @2; + } + } + + struct HwStatus2 { + ofsI @0 :Int8; + magI @1 :UInt8; + ofsQ @2 :Int8; + magQ @3 :UInt8; + cfgSource @4 :ConfigSource; + lowLevCfg @5 :UInt32; + postStatus @6 :UInt32; + + enum ConfigSource { + undefined @0; + rom @1; + otp @2; + configpins @3; + flash @4; + } + } +} struct Clocks { bootTimeNanos @0 :UInt64; @@ -1445,7 +1220,7 @@ struct LiveMpcData { x @0 :List(Float32); y @1 :List(Float32); psi @2 :List(Float32); - delta @3 :List(Float32); + curvature @3 :List(Float32); qpIterations @4 :UInt32; calculationTime @5 :UInt64; cost @6 :Float64; @@ -1465,203 +1240,90 @@ struct LiveLongitudinalMpcData { cost @10 :Float64; } - -struct ECEFPointDEPRECATED @0xe10e21168db0c7f7 { - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; -} - -struct ECEFPoint @0xc25bbbd524983447 { - x @0 :Float64; - y @1 :Float64; - z @2 :Float64; -} - -struct GPSPlannerPoints { - curPosDEPRECATED @0 :ECEFPointDEPRECATED; - pointsDEPRECATED @1 :List(ECEFPointDEPRECATED); - curPos @6 :ECEFPoint; - points @7 :List(ECEFPoint); - valid @2 :Bool; - trackName @3 :Text; - speedLimit @4 :Float32; - accelTarget @5 :Float32; -} - -struct GPSPlannerPlan { - valid @0 :Bool; - poly @1 :List(Float32); - trackName @2 :Text; - speed @3 :Float32; - acceleration @4 :Float32; - pointsDEPRECATED @5 :List(ECEFPointDEPRECATED); - points @6 :List(ECEFPoint); - xLookahead @7 :Float32; -} - -struct TrafficEvent @0xacfa74a094e62626 { - type @0 :Type; - distance @1 :Float32; - action @2 :Action; - resuming @3 :Bool; - - enum Type { - stopSign @0; - lightRed @1; - lightYellow @2; - lightGreen @3; - stopLight @4; - } - - enum Action { - none @0; - yield @1; - stop @2; - resumeReady @3; - } - -} - -struct OrbslamCorrection { - correctionMonoTime @0 :UInt64; - prePositionECEF @1 :List(Float64); - postPositionECEF @2 :List(Float64); - prePoseQuatECEF @3 :List(Float32); - postPoseQuatECEF @4 :List(Float32); - numInliers @5 :UInt32; -} - -struct OrbObservation { - observationMonoTime @0 :UInt64; - normalizedCoordinates @1 :List(Float32); - locationECEF @2 :List(Float64); - matchDistance @3: UInt32; -} - -struct UiNavigationEvent { - type @0: Type; - status @1: Status; - distanceTo @2: Float32; - endRoadPointDEPRECATED @3: ECEFPointDEPRECATED; - endRoadPoint @4: ECEFPoint; - - enum Type { - none @0; - laneChangeLeft @1; - laneChangeRight @2; - mergeLeft @3; - mergeRight @4; - turnLeft @5; - turnRight @6; - } - - enum Status { - none @0; - passive @1; - approaching @2; - active @3; - } -} - -struct UiLayoutState { - activeApp @0 :App; - sidebarCollapsed @1 :Bool; - mapEnabled @2 :Bool; - - enum App { - home @0; - music @1; - nav @2; - } -} - struct Joystick { # convenient for debug and live tuning axes @0: List(Float32); buttons @1: List(Bool); } -struct OrbOdometry { - # timing first - startMonoTime @0 :UInt64; - endMonoTime @1 :UInt64; - - # fundamental matrix and error - f @2: List(Float64); - err @3: Float64; - - # number of inlier points - inliers @4: Int32; - - # for debug only - # indexed by endMonoTime features - # value is startMonoTime feature match - # -1 if no match - matches @5: List(Int16); -} - -struct OrbFeatures { - timestampEof @0 :UInt64; - # transposed arrays of normalized image coordinates - # len(xs) == len(ys) == len(descriptors) * 32 - xs @1 :List(Float32); - ys @2 :List(Float32); - descriptors @3 :Data; - octaves @4 :List(Int8); - - # match index to last OrbFeatures - # -1 if no match - timestampLastEof @5 :UInt64; - matches @6: List(Int16); -} - -struct OrbFeaturesSummary { - timestampEof @0 :UInt64; - timestampLastEof @1 :UInt64; - - featureCount @2 :UInt16; - matchCount @3 :UInt16; - computeNs @4 :UInt64; -} - -struct OrbKeyFrame { - # this is a globally unique id for the KeyFrame - id @0: UInt64; - - # this is the location of the KeyFrame - pos @1: ECEFPoint; - - # these are the features in the world - # len(dpos) == len(descriptors) * 32 - dpos @2 :List(ECEFPoint); - descriptors @3 :Data; +struct DriverState { + frameId @0 :UInt32; + modelExecutionTime @14 :Float32; + dspExecutionTime @16 :Float32; + rawPredictions @15 :Data; + + faceOrientation @3 :List(Float32); + facePosition @4 :List(Float32); + faceProb @5 :Float32; + leftEyeProb @6 :Float32; + rightEyeProb @7 :Float32; + leftBlinkProb @8 :Float32; + rightBlinkProb @9 :Float32; + faceOrientationStd @11 :List(Float32); + facePositionStd @12 :List(Float32); + sunglassesProb @13 :Float32; + poorVision @17 :Float32; + partialFace @18 :Float32; + distractedPose @19 :Float32; + distractedEyes @20 :Float32; + eyesOnRoad @21 :Float32; + phoneUse @22 :Float32; + occludedProb @23 :Float32; + + irPwrDEPRECATED @10 :Float32; + descriptorDEPRECATED @1 :List(Float32); + stdDEPRECATED @2 :Float32; } -struct DriverMonitoring { - frameId @0 :UInt32; - descriptor @1 :List(Float32); - std @2 :Float32; +struct DriverMonitoringState @0xb83cda094a1da284 { + events @0 :List(Car.CarEvent); + faceDetected @1 :Bool; + isDistracted @2 :Bool; + awarenessStatus @3 :Float32; + 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; + isActiveMode @16 :Bool; + + isRHDDEPRECATED @4 :Bool; + isPreviewDEPRECATED @15 :Bool; + rhdCheckedDEPRECATED @5 :Bool; } struct Boot { wallTimeNanos @0 :UInt64; - lastKmsg @1 :Data; - lastPmsg @2 :Data; + pstore @4 :Map(Text, Data); + commands @5 :Map(Text, Data); + launchLog @3 :Text; + + lastKmsgDEPRECATED @1 :Data; + lastPmsgDEPRECATED @2 :Data; } struct LiveParametersData { valid @0 :Bool; gyroBias @1 :Float32; - angleOffset @2 :Float32; - angleOffsetAverage @3 :Float32; + angleOffsetDeg @2 :Float32; + angleOffsetAverageDeg @3 :Float32; stiffnessFactor @4 :Float32; steerRatio @5 :Float32; sensorValid @6 :Bool; yawRate @7 :Float32; + posenetSpeed @8 :Float32; + posenetValid @9 :Bool; + angleOffsetFastStd @10 :Float32; + angleOffsetAverageStd @11 :Float32; + stiffnessFactorStd @12 :Float32; + steerRatioStd @13 :Float32; } -struct LiveMapData { +struct LiveMapDataDEPRECATED { speedLimitValid @0 :Bool; speedLimit @1 :Float32; speedAdvisoryValid @12 :Bool; @@ -1682,92 +1344,189 @@ 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 rotStd @3 :List(Float32); # std rad/s in device frame } -struct KalmanOdometry { - 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 - 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; + signal @1 :Int32; +} + +struct ManagerState { + processes @0 :List(ProcessState); + + struct ProcessState { + name @0 :Text; + pid @1 :Int32; + running @2 :Bool; + shouldBeRunning @4 :Bool; + exitCode @3 :Int32; + } +} + +struct UploaderState { + immediateQueueSize @0 :UInt32; + immediateQueueCount @1 :UInt32; + rawQueueSize @2 :UInt32; + rawQueueCount @3 :UInt32; + + # stats for last successfully uploaded file + lastTime @4 :Float32; # s + lastSpeed @5 :Float32; # MB/s + lastFilename @6 :Text; +} + +struct NavInstruction { + maneuverPrimaryText @0 :Text; + maneuverSecondaryText @1 :Text; + maneuverDistance @2 :Float32; # m + maneuverType @3 :Text; # TODO: Make Enum + maneuverModifier @4 :Text; # TODO: Make Enum + + distanceRemaining @5 :Float32; # m + timeRemaining @6 :Float32; # s + timeRemainingTypical @7 :Float32; # s + + lanes @8 :List(Lane); + showFull @9 :Bool; + + struct Lane { + directions @0 :List(Direction); + active @1 :Bool; + activeDirection @2 :Direction; + } + + enum Direction { + none @0; + left @1; + right @2; + straight @3; + } + +} + +struct NavRoute { + coordinates @0 :List(Coordinate); + + struct Coordinate { + latitude @0 :Float32; + longitude @1 :Float32; + } } struct Event { - # in nanoseconds? - logMonoTime @0 :UInt64; + logMonoTime @0 :UInt64; # nanoseconds valid @67 :Bool = true; union { + # *********** log metadata *********** initData @1 :InitData; - frame @2 :FrameData; + sentinel @73 :Sentinel; + + # *********** bootlog *********** + boot @60 :Boot; + + # ********** openpilot daemon msgs ********** gpsNMEA @3 :GPSNMEAData; - sensorEventDEPRECATED @4 :SensorEventData; can @5 :List(CanData); - thermal @6 :ThermalData; controlsState @7 :ControlsState; - liveEventDEPRECATED @8 :List(LiveEventData); - model @9 :ModelData; - features @10 :CalibrationFeatures; sensorEvents @11 :List(SensorEventData); - health @12 :HealthData; + pandaStates @81 :List(PandaState); + peripheralState @80 :PeripheralState; radarState @13 :RadarState; - liveUIDEPRECATED @14 :LiveUI; - encodeIdx @15 :EncodeIndex; liveTracks @16 :List(LiveTracks); sendcan @17 :List(CanData); - logMessage @18 :Text; liveCalibration @19 :LiveCalibrationData; - androidLogEntry @20 :AndroidLogEntry; - gpsLocation @21 :GpsLocationData; carState @22 :Car.CarState; carControl @23 :Car.CarControl; - plan @24 :Plan; - liveLocation @25 :LiveLocationData; - ethernetData @26 :List(EthernetPacket); - navUpdate @27 :NavUpdate; - cellInfo @28 :List(CellInfo); - wifiScan @29 :List(WifiScan); - androidGnss @30 :AndroidGnss; - qcomGnss @31 :QcomGnss; - lidarPts @32 :LidarPts; - procLog @33 :ProcLog; + longitudinalPlan @24 :LongitudinalPlan; + lateralPlan @64 :LateralPlan; ubloxGnss @34 :UbloxGnss; - clocks @35 :Clocks; - liveMpc @36 :LiveMpcData; - liveLongitudinalMpc @37 :LiveLongitudinalMpcData; - navStatus @38 :NavStatus; ubloxRaw @39 :Data; - gpsPlannerPoints @40 :GPSPlannerPoints; - gpsPlannerPlan @41 :GPSPlannerPlan; - applanixRaw @42 :Data; - trafficEvents @43 :List(TrafficEvent); - liveLocationTiming @44 :LiveLocationData; - orbslamCorrectionDEPRECATED @45 :OrbslamCorrection; - liveLocationCorrected @46 :LiveLocationData; - orbObservation @47 :List(OrbObservation); gpsLocationExternal @48 :GpsLocationData; - location @49 :LiveLocationData; - uiNavigationEvent @50 :UiNavigationEvent; - liveLocationKalman @51 :LiveLocationData; - testJoystick @52 :Joystick; - orbOdometry @53 :OrbOdometry; - orbFeatures @54 :OrbFeatures; - applanixLocation @55 :LiveLocationData; - orbKeyFrame @56 :OrbKeyFrame; - uiLayoutState @57 :UiLayoutState; - orbFeaturesSummary @58 :OrbFeaturesSummary; - driverMonitoring @59 :DriverMonitoring; - boot @60 :Boot; + driverState @59 :DriverState; liveParameters @61 :LiveParametersData; - liveMapData @62 :LiveMapData; cameraOdometry @63 :CameraOdometry; - pathPlan @64 :PathPlan; - kalmanOdometry @65 :KalmanOdometry; thumbnail @66: Thumbnail; carEvents @68: List(Car.CarEvent); carParams @69: Car.CarParams; + driverMonitoringState @71: DriverMonitoringState; + liveLocationKalman @72 :LiveLocationKalman; + modelV2 @75 :ModelDataV2; + + # camera stuff, each camera state has a matching encode idx + roadCameraState @2 :FrameData; + driverCameraState @70: FrameData; + wideRoadCameraState @74: FrameData; + roadEncodeIdx @15 :EncodeIndex; + driverEncodeIdx @76 :EncodeIndex; + wideRoadEncodeIdx @77 :EncodeIndex; + + # systems stuff + androidLog @20 :AndroidLogEntry; + managerState @78 :ManagerState; + uploaderState @79 :UploaderState; + procLog @33 :ProcLog; + clocks @35 :Clocks; + deviceState @6 :DeviceState; + logMessage @18 :Text; + + # navigation + navInstruction @82 :NavInstruction; + navRoute @83 :NavRoute; + navThumbnail @84: Thumbnail; + + # *********** debug *********** + testJoystick @52 :Joystick; + + # *********** legacy + deprecated *********** + model @9 :Legacy.ModelData; # TODO: rename modelV2 and mark this as deprecated + liveMpcDEPRECATED @36 :LiveMpcData; + liveLongitudinalMpcDEPRECATED @37 :LiveLongitudinalMpcData; + liveLocationKalmanDEPRECATED @51 :Legacy.LiveLocationData; + orbslamCorrectionDEPRECATED @45 :Legacy.OrbslamCorrection; + liveUIDEPRECATED @14 :Legacy.LiveUI; + sensorEventDEPRECATED @4 :SensorEventData; + liveEventDEPRECATED @8 :List(Legacy.LiveEventData); + liveLocationDEPRECATED @25 :Legacy.LiveLocationData; + ethernetDataDEPRECATED @26 :List(Legacy.EthernetPacket); + cellInfoDEPRECATED @28 :List(Legacy.CellInfo); + wifiScanDEPRECATED @29 :List(Legacy.WifiScan); + uiNavigationEventDEPRECATED @50 :Legacy.UiNavigationEvent; + liveMapDataDEPRECATED @62 :LiveMapDataDEPRECATED; + gpsPlannerPointsDEPRECATED @40 :Legacy.GPSPlannerPoints; + gpsPlannerPlanDEPRECATED @41 :Legacy.GPSPlannerPlan; + applanixRawDEPRECATED @42 :Data; + androidGnssDEPRECATED @30 :Legacy.AndroidGnss; + qcomGnssDEPRECATD @31 :Legacy.QcomGnss; + lidarPtsDEPRECATED @32 :Legacy.LidarPts; + navStatusDEPRECATED @38 :Legacy.NavStatus; + trafficEventsDEPRECATED @43 :List(Legacy.TrafficEvent); + liveLocationTimingDEPRECATED @44 :Legacy.LiveLocationData; + liveLocationCorrectedDEPRECATED @46 :Legacy.LiveLocationData; + navUpdateDEPRECATED @27 :Legacy.NavUpdate; + orbObservationDEPRECATED @47 :List(Legacy.OrbObservation); + locationDEPRECATED @49 :Legacy.LiveLocationData; + orbOdometryDEPRECATED @53 :Legacy.OrbOdometry; + orbFeaturesDEPRECATED @54 :Legacy.OrbFeatures; + applanixLocationDEPRECATED @55 :Legacy.LiveLocationData; + orbKeyFrameDEPRECATED @56 :Legacy.OrbKeyFrame; + orbFeaturesSummaryDEPRECATED @58 :Legacy.OrbFeaturesSummary; + featuresDEPRECATED @10 :Legacy.CalibrationFeatures; + kalmanOdometryDEPRECATED @65 :Legacy.KalmanOdometry; + gpsLocationDEPRECATED @21 :GpsLocationData; + uiLayoutStateDEPRECATED @57 :Legacy.UiLayoutState; + pandaStateDEPRECATED @12 :PandaState; } } diff --git a/cereal/logger/logger.h b/cereal/logger/logger.h new file mode 100644 index 00000000000000..e21509352f76db --- /dev/null +++ b/cereal/logger/logger.h @@ -0,0 +1,20 @@ +#pragma once + +#ifdef SWAGLOG +#include "selfdrive/common/swaglog.h" +#else + +#define CLOUDLOG_DEBUG 10 +#define CLOUDLOG_INFO 20 +#define CLOUDLOG_WARNING 30 +#define CLOUDLOG_ERROR 40 +#define CLOUDLOG_CRITICAL 50 + +#define cloudlog(lvl, fmt, ...) printf(fmt "\n", ## __VA_ARGS__) + +#define LOGD(fmt, ...) cloudlog(CLOUDLOG_DEBUG, fmt, ## __VA_ARGS__) +#define LOG(fmt, ...) cloudlog(CLOUDLOG_INFO, fmt, ## __VA_ARGS__) +#define LOGW(fmt, ...) cloudlog(CLOUDLOG_WARNING, fmt, ## __VA_ARGS__) +#define LOGE(fmt, ...) cloudlog(CLOUDLOG_ERROR, fmt, ## __VA_ARGS__) + +#endif 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..0440104eb73a22 --- /dev/null +++ b/cereal/messaging/__init__.py @@ -0,0 +1,251 @@ +# 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 os +import capnp + +from typing import Optional, List, Union +from collections import deque + +from cereal import log +from cereal.services import service_list + +assert MultiplePublishersError +assert MessagingError + +NO_TRAVERSAL_LIMIT = 2**64-1 +AVG_FREQ_HISTORY = 100 +SIMULATION = "SIMULATION" in os.environ + +# 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 log_from_bytes(dat: bytes) -> capnp.lib.capnp._DynamicStructReader: + return log.Event.from_bytes(dat, traversal_limit_in_words=NO_TRAVERSAL_LIMIT) + +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_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_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_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_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_from_bytes(dat) + +class SubMaster(): + def __init__(self, services: List[str], poll: Optional[List[str]] = None, + ignore_alive: Optional[List[str]] = None, ignore_avg_freq: 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.recv_dts = {s: deque([0.0] * AVG_FREQ_HISTORY, maxlen=AVG_FREQ_HISTORY) 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] + + self.ignore_average_freq = [] if ignore_avg_freq is None else ignore_avg_freq + self.ignore_alive = [] if ignore_alive is None else 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 + + if self.rcv_time[s] > 1e-5 and self.freq[s] > 1e-5 and (s not in self.non_polled_services) \ + and (s not in self.ignore_average_freq): + self.recv_dts[s].append(cur_time - self.rcv_time[s]) + + 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 + + if SIMULATION: + self.alive[s] = True + + if not SIMULATION: + 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]) + + # alive if average frequency is higher than 90% of expected frequency + avg_dt = sum(self.recv_dts[s]) / AVG_FREQ_HISTORY + expected_dt = 1 / (self.freq[s] * 0.90) + self.alive[s] = self.alive[s] and (avg_dt < expected_dt) + 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) + + def all_readers_updated(self, s: str) -> bool: + return self.sock[s].all_readers_updated() diff --git a/cereal/messaging/bridge.cc b/cereal/messaging/bridge.cc new file mode 100644 index 00000000000000..d4bdfcea714c53 --- /dev/null +++ b/cereal/messaging/bridge.cc @@ -0,0 +1,79 @@ +#include +#include +#include +#include +#include +#include + +typedef void (*sighandler_t)(int sig); + +#include "impl_msgq.h" +#include "impl_zmq.h" +#include "services.h" + +void sigpipe_handler(int sig) { + assert(sig == SIGPIPE); + std::cout << "SIGPIPE received" << std::endl; +} + +static std::vector get_services(std::string whitelist_str, bool zmq_to_msgq) { + std::vector service_list; + for (const auto& it : services) { + std::string name = it.name; + bool in_whitelist = whitelist_str.find(name) != std::string::npos; + if (name == "plusFrame" || name == "uiLayoutState" || (zmq_to_msgq && !in_whitelist)) { + continue; + } + service_list.push_back(name); + } + return service_list; +} + +int main(int argc, char** argv) { + signal(SIGPIPE, (sighandler_t)sigpipe_handler); + + bool zmq_to_msgq = argc > 2; + std::string ip = zmq_to_msgq ? argv[1] : "127.0.0.1"; + std::string whitelist_str = zmq_to_msgq ? std::string(argv[2]) : ""; + + Poller *poller; + Context *pub_context; + Context *sub_context; + if (zmq_to_msgq) { // republishes zmq debugging messages as msgq + poller = new ZMQPoller(); + pub_context = new MSGQContext(); + sub_context = new ZMQContext(); + } else { + poller = new MSGQPoller(); + pub_context = new ZMQContext(); + sub_context = new MSGQContext(); + } + + std::map sub2pub; + for (auto endpoint: get_services(whitelist_str, zmq_to_msgq)) { + PubSocket * pub_sock; + SubSocket * sub_sock; + if (zmq_to_msgq) { + pub_sock = new MSGQPubSocket(); + sub_sock = new ZMQSubSocket(); + } else { + pub_sock = new ZMQPubSocket(); + sub_sock = new MSGQSubSocket(); + } + pub_sock->connect(pub_context, endpoint); + sub_sock->connect(sub_context, endpoint, ip, false); + + poller->registerSocket(sub_sock); + sub2pub[sub_sock] = pub_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..862c94cb3e5140 --- /dev/null +++ b/cereal/messaging/impl_msgq.cc @@ -0,0 +1,230 @@ +#include +#include +#include +#include +#include +#include + +#include "services.h" +#include "impl_msgq.h" + + +volatile sig_atomic_t msgq_do_exit = 0; + +void sig_handler(int signal) { + assert(signal == SIGINT || signal == SIGTERM); + msgq_do_exit = 1; +} + +static bool service_exists(std::string path){ + for (const auto& it : services) { + if (it.name == path) { + return true; + } + } + return false; +} + +static size_t get_size(std::string endpoint){ + size_t sz = DEFAULT_SEGMENT_SIZE; + + if (endpoint == "roadCameraState" || endpoint == "driverCameraState" || endpoint == "wideRoadCameraState"){ + sz *= 10; + } + + 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, bool check_endpoint){ + assert(context); + assert(address == "127.0.0.1"); + + if (check_endpoint && !service_exists(std::string(endpoint))){ + std::cout << "Warning, " << std::string(endpoint) << " is not in service list." << std::endl; + } + + 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, bool check_endpoint){ + assert(context); + + if (check_endpoint && !service_exists(std::string(endpoint))){ + std::cout << "Warning, " << std::string(endpoint) << " is not in service list." << std::endl; + } + + 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); +} + +bool MSGQPubSocket::all_readers_updated() { + return msgq_all_readers_updated(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.h b/cereal/messaging/impl_msgq.h new file mode 100644 index 00000000000000..b67aae6222c2b5 --- /dev/null +++ b/cereal/messaging/impl_msgq.h @@ -0,0 +1,65 @@ +#pragma once +#include "messaging.h" +#include "msgq.h" +#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, bool check_endpoint=true); + 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, bool check_endpoint=true); + int sendMessage(Message *message); + int send(char *data, size_t size); + bool all_readers_updated(); + ~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..aeed176ae814c6 --- /dev/null +++ b/cereal/messaging/impl_zmq.cc @@ -0,0 +1,168 @@ +#include +#include +#include +#include +#include + +#include + +#include "services.h" +#include "impl_zmq.h" + +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, bool check_endpoint){ + 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 + ":"; + if (check_endpoint){ + full_endpoint += std::to_string(get_port(endpoint)); + } else { + full_endpoint += 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, bool check_endpoint){ + sock = zmq_socket(context->getRawContext(), ZMQ_PUB); + if (sock == NULL){ + return -1; + } + + full_endpoint = "tcp://*:"; + if (check_endpoint){ + full_endpoint += std::to_string(get_port(endpoint)); + } else { + full_endpoint += 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); +} + +bool ZMQPubSocket::all_readers_updated() { + assert(false); // TODO not implemented + return false; +} + +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.h b/cereal/messaging/impl_zmq.h new file mode 100644 index 00000000000000..bb232049e034ba --- /dev/null +++ b/cereal/messaging/impl_zmq.h @@ -0,0 +1,64 @@ +#pragma once +#include "messaging.h" +#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, bool check_endpoint=true); + 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, bool check_endpoint=true); + int sendMessage(Message *message); + int send(char *data, size_t size); + bool all_readers_updated(); + ~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..bfa634e612044e --- /dev/null +++ b/cereal/messaging/messaging.cc @@ -0,0 +1,103 @@ +#include "messaging.h" +#include "impl_zmq.h" +#include "impl_msgq.h" + +#ifdef __APPLE__ +const bool MUST_USE_ZMQ = true; +#else +const bool MUST_USE_ZMQ = false; +#endif + +bool messaging_use_zmq(){ + return std::getenv("ZMQ") || MUST_USE_ZMQ; +} + +Context * Context::create(){ + Context * c; + if (messaging_use_zmq()){ + c = new ZMQContext(); + } else { + c = new MSGQContext(); + } + return c; +} + +SubSocket * SubSocket::create(){ + SubSocket * s; + if (messaging_use_zmq()){ + s = new ZMQSubSocket(); + } else { + s = new MSGQSubSocket(); + } + return s; +} + +SubSocket * SubSocket::create(Context * context, std::string endpoint, std::string address, bool conflate, bool check_endpoint){ + SubSocket *s = SubSocket::create(); + int r = s->connect(context, endpoint, address, conflate, check_endpoint); + + if (r == 0) { + return s; + } else { + delete s; + return NULL; + } +} + +PubSocket * PubSocket::create(){ + PubSocket * s; + if (messaging_use_zmq()){ + s = new ZMQPubSocket(); + } else { + s = new MSGQPubSocket(); + } + return s; +} + +PubSocket * PubSocket::create(Context * context, std::string endpoint, bool check_endpoint){ + PubSocket *s = PubSocket::create(); + int r = s->connect(context, endpoint, check_endpoint); + + if (r == 0) { + return s; + } else { + delete s; + return NULL; + } +} + +Poller * Poller::create(){ + Poller * p; + if (messaging_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.h b/cereal/messaging/messaging.h new file mode 100644 index 00000000000000..4a184ff70c6d07 --- /dev/null +++ b/cereal/messaging/messaging.h @@ -0,0 +1,145 @@ +#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 + +bool messaging_use_zmq(); + +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, bool check_endpoint=true) = 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, std::string address="127.0.0.1", bool conflate=false, bool check_endpoint=true); + virtual ~SubSocket(){}; +}; + +class PubSocket { +public: + virtual int connect(Context *context, std::string endpoint, bool check_endpoint=true) = 0; + virtual int sendMessage(Message *message) = 0; + virtual int send(char *data, size_t size) = 0; + virtual bool all_readers_updated() = 0; + static PubSocket * create(); + static PubSocket * create(Context * context, std::string endpoint, bool check_endpoint=true); + static PubSocket * create(Context * context, std::string endpoint, int port, bool check_endpoint=true); + 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::vector &service_list, + const char *address = nullptr, const std::vector &ignore_alive = {}); + void update(int timeout = 1000); + void update_msgs(uint64_t current_time, const std::vector> &messages); + inline bool allAlive(const std::vector &service_list = {}) { return all_(service_list, false, true); } + inline bool allValid(const std::vector &service_list = {}) { return all_(service_list, true, false); } + inline bool allAliveAndValid(const std::vector &service_list = {}) { return all_(service_list, true, true); } + void drain(); + ~SubMaster(); + + uint64_t frame = 0; + bool updated(const char *name) const; + bool alive(const char *name) const; + bool valid(const char *name) const; + uint64_t rcv_frame(const char *name) const; + uint64_t rcv_time(const char *name) const; + cereal::Event::Reader &operator[](const char *name) const; + +private: + bool all_(const std::vector &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::vector &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_; +}; + +class AlignedBuffer { +public: + kj::ArrayPtr align(const char *data, const size_t size) { + words_size = size / sizeof(capnp::word) + 1; + if (aligned_buf.size() < words_size) { + aligned_buf = kj::heapArray(words_size < 512 ? 512 : words_size); + } + memcpy(aligned_buf.begin(), data, size); + return aligned_buf.slice(0, words_size); + } + inline kj::ArrayPtr align(Message *m) { + return align(m->getData(), m->getSize()); + } +private: + kj::Array aligned_buf; + size_t words_size; +}; diff --git a/cereal/messaging/messaging.pxd b/cereal/messaging/messaging.pxd new file mode 100644 index 00000000000000..de232da5f1b8f4 --- /dev/null +++ b/cereal/messaging/messaging.pxd @@ -0,0 +1,40 @@ +# 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.h": + 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) + bool all_readers_updated() + + 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..eed548bb8e9cba --- /dev/null +++ b/cereal/messaging/messaging_pyx.pyx @@ -0,0 +1,154 @@ +# 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 + + def all_readers_updated(self): + return self.socket.all_readers_updated() diff --git a/cereal/messaging/msgq.cc b/cereal/messaging/msgq.cc new file mode 100644 index 00000000000000..cabf8aaba79ffb --- /dev/null +++ b/cereal/messaging/msgq.cc @@ -0,0 +1,464 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "msgq.h" + +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; +} + + +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 + 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, 0664); + 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; +} + +bool msgq_all_readers_updated(msgq_queue_t *q) { + uint64_t num_readers = *q->num_readers; + for (uint64_t i = 0; i < num_readers; i++) { + if (*q->read_valids[i] && *q->write_pointer != *q->read_pointers[i]) { + return false; + } + } + return num_readers > 0; +} diff --git a/cereal/messaging/msgq.h b/cereal/messaging/msgq.h new file mode 100644 index 00000000000000..90a20acdd76be5 --- /dev/null +++ b/cereal/messaging/msgq.h @@ -0,0 +1,68 @@ +#pragma once +#include +#include +#include +#include + +#define DEFAULT_SEGMENT_SIZE (10 * 1024 * 1024) +#define NUM_READERS 10 +#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); + +bool msgq_all_readers_updated(msgq_queue_t *q); diff --git a/cereal/messaging/socketmaster.cc b/cereal/messaging/socketmaster.cc new file mode 100644 index 00000000000000..56698dc2eb7bdb --- /dev/null +++ b/cereal/messaging/socketmaster.cc @@ -0,0 +1,205 @@ +#include +#include +#include +#include +#include + +#include "services.h" +#include "messaging.h" + +const bool SIMULATION = (getenv("SIMULATION") != nullptr) && (std::string(getenv("SIMULATION")) == "1"); + +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::vector &list, const char *value) { + for (auto &v : list) { + if (strcmp(value, v) == 0) return true; + } + return false; +} + +class MessageContext { +public: + MessageContext() : ctx_(nullptr) {}; + ~MessageContext() { delete ctx_; } + inline Context *context() { + std::call_once(init_flag, [=]() { ctx_ = Context::create(); }); + return ctx_; + } +private: + Context *ctx_; + std::once_flag init_flag; +}; + +MessageContext message_context; + +struct SubMaster::SubMessage { + std::string name; + SubSocket *socket = nullptr; + int freq = 0; + bool updated = false, alive = false, valid = true, ignore_alive; + uint64_t rcv_time = 0, rcv_frame = 0; + void *allocated_msg_reader = nullptr; + capnp::FlatArrayMessageReader *msg_reader = nullptr; + AlignedBuffer aligned_buf; + cereal::Event::Reader event; +}; + +SubMaster::SubMaster(const std::vector &service_list, const char *address, + const std::vector &ignore_alive) { + poller_ = Poller::create(); + for (auto name : service_list) { + const service *serv = get_service(name); + assert(serv != nullptr); + SubSocket *socket = SubSocket::create(message_context.context(), name, address ? address : "127.0.0.1", true); + assert(socket != 0); + poller_->registerSocket(socket); + SubMessage *m = new SubMessage{ + .name = name, + .socket = socket, + .freq = serv->frequency, + .ignore_alive = inList(ignore_alive, name), + .allocated_msg_reader = malloc(sizeof(capnp::FlatArrayMessageReader))}; + m->msg_reader = new (m->allocated_msg_reader) capnp::FlatArrayMessageReader({}); + messages_[socket] = m; + services_[name] = m; + } +} + +void SubMaster::update(int timeout) { + for (auto &kv : messages_) kv.second->updated = false; + + auto sockets = poller_->poll(timeout); + uint64_t current_time = nanos_since_boot(); + + std::vector> messages; + + for (auto s : sockets) { + Message *msg = s->receive(true); + if (msg == nullptr) continue; + + SubMessage *m = messages_.at(s); + + m->msg_reader->~FlatArrayMessageReader(); + capnp::ReaderOptions options; + options.traversalLimitInWords = kj::maxValue; // Don't limit + m->msg_reader = new (m->allocated_msg_reader) capnp::FlatArrayMessageReader(m->aligned_buf.align(msg), options); + delete msg; + messages.push_back({m->name, m->msg_reader->getRoot()}); + } + + update_msgs(current_time, messages); +} + +void SubMaster::update_msgs(uint64_t current_time, const std::vector> &messages){ + if (++frame == UINT64_MAX) frame = 1; + + for(auto &kv : messages) { + auto m_find = services_.find(kv.first); + if (m_find == services_.end()){ + continue; + } + SubMessage *m = m_find->second; + m->event = kv.second; + m->updated = true; + m->rcv_time = current_time; + m->rcv_frame = frame; + m->valid = m->event.getValid(); + if (SIMULATION) m->alive = true; + } + + if (!SIMULATION) { + 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)); + } + } +} + +bool SubMaster::all_(const std::vector &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; +} + +bool SubMaster::alive(const char *name) const { + return services_.at(name)->alive; +} + +bool SubMaster::valid(const char *name) const { + return services_.at(name)->valid; +} + +uint64_t SubMaster::rcv_frame(const char *name) const { + return services_.at(name)->rcv_frame; +} + +uint64_t SubMaster::rcv_time(const char *name) const { + return services_.at(name)->rcv_time; +} + +cereal::Event::Reader &SubMaster::operator[](const char *name) const { + return services_.at(name)->event; +}; + +SubMaster::~SubMaster() { + delete poller_; + for (auto &kv : messages_) { + SubMessage *m = kv.second; + m->msg_reader->~FlatArrayMessageReader(); + free(m->allocated_msg_reader); + delete m->socket; + delete m; + } +} + +PubMaster::PubMaster(const std::vector &service_list) { + for (auto name : service_list) { + assert(get_service(name) != nullptr); + PubSocket *socket = PubSocket::create(message_context.context(), 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/cereal/services.py b/cereal/services.py new file mode 100755 index 00000000000000..89f437359a2a54 --- /dev/null +++ b/cereal/services.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +import os +from typing import Optional + +TICI = os.path.isfile('/TICI') +RESERVED_PORT = 8022 # sshd +STARTING_PORT = 8001 + + +def new_port(port: int): + port += STARTING_PORT + return port + 1 if port >= RESERVED_PORT else port + + +class Service: + def __init__(self, port: int, should_log: bool, frequency: float, decimation: Optional[int] = None): + self.port = port + self.should_log = should_log + self.frequency = frequency + self.decimation = decimation + +DCAM_FREQ = 10. if not TICI else 20. + +services = { + # service: (should_log, frequency, qlog decimation (optional)) + "sensorEvents": (True, 100., 100), + "gpsNMEA": (True, 9.), + "deviceState": (True, 2., 1), + "can": (True, 100.), + "controlsState": (True, 100., 10), + "pandaStates": (True, 2., 1), + "peripheralState": (True, 2., 1), + "radarState": (True, 20., 5), + "roadEncodeIdx": (True, 20., 1), + "liveTracks": (True, 20.), + "sendcan": (True, 100., 139), + "logMessage": (True, 0.), + "liveCalibration": (True, 4., 4), + "androidLog": (True, 0.), + "carState": (True, 100., 10), + "carControl": (True, 100., 10), + "longitudinalPlan": (True, 20., 5), + "procLog": (True, 0.5), + "gpsLocationExternal": (True, 10., 1), + "ubloxGnss": (True, 10.), + "clocks": (True, 1., 1), + "ubloxRaw": (True, 20.), + "liveLocationKalman": (True, 20., 2), + "liveParameters": (True, 20., 2), + "cameraOdometry": (True, 20., 5), + "lateralPlan": (True, 20., 5), + "thumbnail": (True, 0.2, 1), + "carEvents": (True, 1., 1), + "carParams": (True, 0.02, 1), + "roadCameraState": (True, 20., 20), + "driverCameraState": (True, DCAM_FREQ, DCAM_FREQ), + "driverEncodeIdx": (True, DCAM_FREQ, 1), + "driverState": (True, DCAM_FREQ, DCAM_FREQ / 2), + "driverMonitoringState": (True, DCAM_FREQ, DCAM_FREQ / 2), + "wideRoadEncodeIdx": (True, 20., 1), + "wideRoadCameraState": (True, 20., 20), + "modelV2": (True, 20., 40), + "managerState": (True, 2., 1), + "uploaderState": (True, 0., 1), + "navInstruction": (True, 0.), + "navRoute": (True, 0.), + "navThumbnail": (True, 0.), + + # debug + "testJoystick": (False, 0.), +} +service_list = {name: Service(new_port(idx), *vals) for # type: ignore + idx, (name, vals) in enumerate(services.items())} + + +def build_header(): + h = "" + h += "/* THIS IS AN AUTOGENERATED FILE, PLEASE EDIT services.py */\n" + h += "#ifndef __SERVICES_H\n" + h += "#define __SERVICES_H\n" + h += "struct service { char name[0x100]; int port; bool should_log; int frequency; int decimation; };\n" + h += "static struct service services[] = {\n" + for k, v in service_list.items(): + should_log = "true" if v.should_log else "false" + decimation = -1 if v.decimation is None else v.decimation + h += ' { "%s", %d, %s, %d, %d },\n' % \ + (k, v.port, should_log, v.frequency, decimation) + h += "};\n" + h += "#endif\n" + return h + + +if __name__ == "__main__": + print(build_header()) diff --git a/cereal/visionipc/.gitignore b/cereal/visionipc/.gitignore new file mode 100644 index 00000000000000..fa5a2b9f388686 --- /dev/null +++ b/cereal/visionipc/.gitignore @@ -0,0 +1,2 @@ +visionipc_pyx.cpp +*.so diff --git a/panda/examples/__init__.py b/cereal/visionipc/__init__.py similarity index 100% rename from panda/examples/__init__.py rename to cereal/visionipc/__init__.py diff --git a/cereal/visionipc/ipc.cc b/cereal/visionipc/ipc.cc new file mode 100644 index 00000000000000..29c4c9c37491d1 --- /dev/null +++ b/cereal/visionipc/ipc.cc @@ -0,0 +1,121 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef __APPLE__ +#define getsocket() socket(AF_UNIX, SOCK_STREAM, 0) +#else +#define getsocket() socket(AF_UNIX, SOCK_SEQPACKET, 0) +#endif + +#include "ipc.h" + +int ipc_connect(const char* socket_path) { + int err; + + int sock = getsocket(); + + if (sock < 0) return -1; + struct sockaddr_un addr = { + .sun_family = AF_UNIX, + }; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + err = connect(sock, (struct sockaddr*)&addr, sizeof(addr)); + if (err != 0) { + close(sock); + return -1; + } + + return sock; +} + +int ipc_bind(const char* socket_path) { + int err; + + unlink(socket_path); + + int sock = getsocket(); + + struct sockaddr_un addr = { + .sun_family = AF_UNIX, + }; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + err = bind(sock, (struct sockaddr *)&addr, sizeof(addr)); + assert(err == 0); + + err = listen(sock, 3); + assert(err == 0); + + return sock; +} + + +int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fds, int num_fds, + int *out_num_fds) { + char control_buf[CMSG_SPACE(sizeof(int) * num_fds)]; + memset(control_buf, 0, CMSG_SPACE(sizeof(int) * num_fds)); + + struct iovec iov = { + .iov_base = buf, + .iov_len = buf_size, + }; + struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen = 1, + }; + + if (num_fds > 0) { + assert(fds); + + msg.msg_control = control_buf; + msg.msg_controllen = CMSG_SPACE(sizeof(int) * num_fds); + } + + if (send) { + if (num_fds) { + struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); + assert(cmsg); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds); + memcpy(CMSG_DATA(cmsg), fds, sizeof(int) * num_fds); + } + return sendmsg(fd, &msg, 0); + } else { + int r = recvmsg(fd, &msg, 0); + if (r < 0) return r; + + int recv_fds = 0; + if (msg.msg_controllen > 0) { + struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); + assert(cmsg); + assert(cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS); + recv_fds = (cmsg->cmsg_len - CMSG_LEN(0)); + assert(recv_fds > 0 && (recv_fds % sizeof(int)) == 0); + recv_fds /= sizeof(int); + + assert(fds && recv_fds <= num_fds); + memcpy(fds, CMSG_DATA(cmsg), sizeof(int) * recv_fds); + } + + if (msg.msg_flags) { + for (int i=0; i + +int ipc_connect(const char* socket_path); +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); diff --git a/cereal/visionipc/test_runner.cc b/cereal/visionipc/test_runner.cc new file mode 100644 index 00000000000000..62bf7476a18996 --- /dev/null +++ b/cereal/visionipc/test_runner.cc @@ -0,0 +1,2 @@ +#define CATCH_CONFIG_MAIN +#include "catch2/catch.hpp" diff --git a/cereal/visionipc/visionbuf.cc b/cereal/visionipc/visionbuf.cc new file mode 100644 index 00000000000000..e94a8bbc014760 --- /dev/null +++ b/cereal/visionipc/visionbuf.cc @@ -0,0 +1,49 @@ +#include "visionbuf.h" + +#define ALIGN(x, align) (((x) + (align)-1) & ~((align)-1)) + +#ifdef QCOM +// from libadreno_utils.so +extern "C" void compute_aligned_width_and_height(int width, + int height, + int bpp, + int tile_mode, + int raster_mode, + int padding_threshold, + int *aligned_w, + int *aligned_h); +#endif + +void visionbuf_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h) { +#ifdef QCOM + 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 +} + +void VisionBuf::init_rgb(size_t init_width, size_t init_height, size_t init_stride) { + this->rgb = true; + this->width = init_width; + this->height = init_height; + this->stride = init_stride; +} + +void VisionBuf::init_yuv(size_t init_width, size_t init_height){ + this->rgb = false; + this->width = init_width; + this->height = init_height; + + this->y = (uint8_t *)this->addr; + this->u = this->y + (this->width * this->height); + this->v = this->u + (this->width / 2 * this->height / 2); +} + + +uint64_t VisionBuf::get_frame_id() { + return *frame_id; +} + +void VisionBuf::set_frame_id(uint64_t id) { + *frame_id = id; +} diff --git a/cereal/visionipc/visionbuf.h b/cereal/visionipc/visionbuf.h new file mode 100644 index 00000000000000..b27a08b26b5271 --- /dev/null +++ b/cereal/visionipc/visionbuf.h @@ -0,0 +1,67 @@ +#pragma once +#include "visionipc.h" + +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#ifdef __APPLE__ +#include +#else +#include +#endif + +#define VISIONBUF_SYNC_FROM_DEVICE 0 +#define VISIONBUF_SYNC_TO_DEVICE 1 + +enum VisionStreamType { + VISION_STREAM_RGB_BACK, + VISION_STREAM_RGB_FRONT, + VISION_STREAM_RGB_WIDE, + VISION_STREAM_ROAD, + VISION_STREAM_DRIVER, + VISION_STREAM_WIDE_ROAD, + VISION_STREAM_RGB_MAP, + VISION_STREAM_MAX, +}; + +class VisionBuf { + public: + size_t len = 0; + size_t mmap_len = 0; + void * addr = nullptr; + uint64_t *frame_id; + int fd = 0; + + bool rgb = false; + size_t width = 0; + size_t height = 0; + size_t stride = 0; + + // YUV + uint8_t * y = nullptr; + uint8_t * u = nullptr; + uint8_t * v = nullptr; + + // Visionipc + uint64_t server_id = 0; + size_t idx = 0; + VisionStreamType type; + + // OpenCL + cl_mem buf_cl = nullptr; + cl_command_queue copy_q = nullptr; + + // ion + int handle = 0; + + void allocate(size_t len); + void import(); + void init_cl(cl_device_id device_id, cl_context ctx); + void init_rgb(size_t width, size_t height, size_t stride); + void init_yuv(size_t width, size_t height); + int sync(int dir); + int free(); + + void set_frame_id(uint64_t id); + uint64_t get_frame_id(); +}; + +void visionbuf_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h); diff --git a/cereal/visionipc/visionbuf_cl.cc b/cereal/visionipc/visionbuf_cl.cc new file mode 100644 index 00000000000000..0286d28fddbf17 --- /dev/null +++ b/cereal/visionipc/visionbuf_cl.cc @@ -0,0 +1,94 @@ +#include "visionbuf.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +std::atomic offset = 0; + +static 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, 0664); + 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; +} + +void VisionBuf::allocate(size_t length) { + this->len = length; + this->mmap_len = this->len; + this->addr = malloc_with_fd(this->len, &this->fd); + this->frame_id = (uint64_t*)((uint8_t*)this->addr + this->len); +} + +void VisionBuf::init_cl(cl_device_id device_id, cl_context ctx){ + int err; + + this->copy_q = clCreateCommandQueue(ctx, device_id, 0, &err); + assert(err == 0); + + this->buf_cl = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, this->len, this->addr, &err); + assert(err == 0); +} + + +void VisionBuf::import(){ + assert(this->fd >= 0); + this->addr = mmap(NULL, this->mmap_len, PROT_READ | PROT_WRITE, MAP_SHARED, this->fd, 0); + assert(this->addr != MAP_FAILED); + + this->frame_id = (uint64_t*)((uint8_t*)this->addr + this->len); +} + + +int VisionBuf::sync(int dir) { + int err = 0; + if (!this->buf_cl) return 0; + + if (dir == VISIONBUF_SYNC_FROM_DEVICE) { + err = clEnqueueReadBuffer(this->copy_q, this->buf_cl, CL_FALSE, 0, this->len, this->addr, 0, NULL, NULL); + } else { + err = clEnqueueWriteBuffer(this->copy_q, this->buf_cl, CL_FALSE, 0, this->len, this->addr, 0, NULL, NULL); + } + + if (err == 0){ + err = clFinish(this->copy_q); + } + + return err; +} + +int VisionBuf::free() { + int err = 0; + if (this->buf_cl){ + err = clReleaseMemObject(this->buf_cl); + if (err != 0) return err; + + err = clReleaseCommandQueue(this->copy_q); + if (err != 0) return err; + } + + err = munmap(this->addr, this->len); + if (err != 0) return err; + + err = close(this->fd); + return err; +} diff --git a/cereal/visionipc/visionbuf_ion.cc b/cereal/visionipc/visionbuf_ion.cc new file mode 100644 index 00000000000000..c66b668c65839c --- /dev/null +++ b/cereal/visionipc/visionbuf_ion.cc @@ -0,0 +1,158 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "visionbuf.h" + +// keep trying if x gets interrupted by a signal +#define HANDLE_EINTR(x) \ + ({ \ + decltype(x) ret; \ + int try_cnt = 0; \ + do { \ + ret = (x); \ + } while (ret == -1 && errno == EINTR && try_cnt++ < 100); \ + ret; \ + }) + +// just hard-code these for convenience +// size_t device_page_size = 0; +// clGetDeviceInfo(device_id, CL_DEVICE_PAGE_SIZE_QCOM, +// sizeof(device_page_size), &device_page_size, +// NULL); + +// size_t padding_cl = 0; +// clGetDeviceInfo(device_id, CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM, +// sizeof(padding_cl), &padding_cl, +// NULL); +#define DEVICE_PAGE_SIZE_CL 4096 +#define PADDING_CL 0 + +static int ion_fd = -1; +static void ion_init() { + if (ion_fd == -1) { + ion_fd = open("/dev/ion", O_RDWR | O_NONBLOCK); + } +} + +void VisionBuf::allocate(size_t length) { + int err; + + ion_init(); + + struct ion_allocation_data ion_alloc = {0}; + ion_alloc.len = length + PADDING_CL + sizeof(uint64_t); + ion_alloc.align = 4096; + ion_alloc.heap_id_mask = 1 << ION_IOMMU_HEAP_ID; + ion_alloc.flags = ION_FLAG_CACHED; + + err = HANDLE_EINTR(ioctl(ion_fd, ION_IOC_ALLOC, &ion_alloc)); + assert(err == 0); + + struct ion_fd_data ion_fd_data = {0}; + ion_fd_data.handle = ion_alloc.handle; + err = HANDLE_EINTR(ioctl(ion_fd, ION_IOC_SHARE, &ion_fd_data)); + assert(err == 0); + + void *mmap_addr = mmap(NULL, ion_alloc.len, + PROT_READ | PROT_WRITE, + MAP_SHARED, ion_fd_data.fd, 0); + assert(mmap_addr != MAP_FAILED); + + memset(mmap_addr, 0, ion_alloc.len); + + this->len = length; + this->mmap_len = ion_alloc.len; + this->addr = mmap_addr; + this->handle = ion_alloc.handle; + this->fd = ion_fd_data.fd; + this->frame_id = (uint64_t*)((uint8_t*)this->addr + this->len + PADDING_CL); +} + +void VisionBuf::import(){ + int err; + assert(this->fd >= 0); + + ion_init(); + + // Get handle + struct ion_fd_data fd_data = {0}; + fd_data.fd = this->fd; + err = HANDLE_EINTR(ioctl(ion_fd, ION_IOC_IMPORT, &fd_data)); + assert(err == 0); + + this->handle = fd_data.handle; + this->addr = mmap(NULL, this->mmap_len, PROT_READ | PROT_WRITE, MAP_SHARED, this->fd, 0); + assert(this->addr != MAP_FAILED); + + this->frame_id = (uint64_t*)((uint8_t*)this->addr + this->len + PADDING_CL); +} + +void VisionBuf::init_cl(cl_device_id device_id, cl_context ctx) { + int err; + + assert(((uintptr_t)this->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 = this->fd; + ion_cl.ion_hostptr = this->addr; + + this->buf_cl = clCreateBuffer(ctx, + CL_MEM_USE_HOST_PTR | CL_MEM_EXT_HOST_PTR_QCOM, + this->len, &ion_cl, &err); + assert(err == 0); +} + + +int VisionBuf::sync(int dir) { + struct ion_flush_data flush_data = {0}; + flush_data.handle = this->handle; + flush_data.vaddr = this->addr; + flush_data.offset = 0; + flush_data.length = this->len; + + // ION_IOC_INV_CACHES ~= DMA_FROM_DEVICE + // ION_IOC_CLEAN_CACHES ~= DMA_TO_DEVICE + // ION_IOC_CLEAN_INV_CACHES ~= DMA_BIDIRECTIONAL + + struct ion_custom_data custom_data = {0}; + + assert(dir == VISIONBUF_SYNC_FROM_DEVICE || dir == VISIONBUF_SYNC_TO_DEVICE); + custom_data.cmd = (dir == VISIONBUF_SYNC_FROM_DEVICE) ? + ION_IOC_INV_CACHES : ION_IOC_CLEAN_CACHES; + + custom_data.arg = (unsigned long)&flush_data; + return HANDLE_EINTR(ioctl(ion_fd, ION_IOC_CUSTOM, &custom_data)); +} + +int VisionBuf::free() { + int err = 0; + + if (this->buf_cl){ + err = clReleaseMemObject(this->buf_cl); + if (err != 0) return err; + } + + err = munmap(this->addr, this->mmap_len); + if (err != 0) return err; + + err = close(this->fd); + if (err != 0) return err; + + struct ion_handle_data handle_data = {.handle = this->handle}; + return HANDLE_EINTR(ioctl(ion_fd, ION_IOC_FREE, &handle_data)); +} diff --git a/cereal/visionipc/visionipc.h b/cereal/visionipc/visionipc.h new file mode 100644 index 00000000000000..fb640692c302fe --- /dev/null +++ b/cereal/visionipc/visionipc.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +constexpr int VISIONIPC_MAX_FDS = 128; + +struct VisionIpcBufExtra { + uint32_t frame_id; + uint64_t timestamp_sof; + uint64_t timestamp_eof; +}; + +struct VisionIpcPacket { + uint64_t server_id; + size_t idx; + struct VisionIpcBufExtra extra; +}; diff --git a/cereal/visionipc/visionipc.pxd b/cereal/visionipc/visionipc.pxd new file mode 100644 index 00000000000000..5cb729f7e1fda4 --- /dev/null +++ b/cereal/visionipc/visionipc.pxd @@ -0,0 +1,39 @@ +# distutils: language = c++ +#cython: language_level=3 + +from libcpp.string cimport string +from libcpp.vector cimport vector +from libc.stdint cimport uint32_t, uint64_t +from libcpp cimport bool + +cdef extern from "visionbuf.h": + cdef enum VisionStreamType: + pass + + cdef cppclass VisionBuf: + void * addr + size_t len + size_t width + size_t height + size_t stride + +cdef extern from "visionipc.h": + struct VisionIpcBufExtra: + uint32_t frame_id + uint64_t timestamp_sof + uint64_t timestamp_eof + +cdef extern from "visionipc_server.h": + cdef cppclass VisionIpcServer: + VisionIpcServer(string, void*, void*) + void create_buffers(VisionStreamType, size_t, bool, size_t, size_t) + VisionBuf * get_buffer(VisionStreamType) + void send(VisionBuf *, VisionIpcBufExtra *, bool) + void start_listener() + +cdef extern from "visionipc_client.h": + cdef cppclass VisionIpcClient: + VisionIpcClient(string, VisionStreamType, bool, void*, void*) + VisionBuf * recv(VisionIpcBufExtra *, int) + bool connect(bool) + bool is_connected() diff --git a/cereal/visionipc/visionipc_client.cc b/cereal/visionipc/visionipc_client.cc new file mode 100644 index 00000000000000..ece2393562bbee --- /dev/null +++ b/cereal/visionipc/visionipc_client.cc @@ -0,0 +1,129 @@ +#include +#include +#include +#include + +#include "visionipc/ipc.h" +#include "visionipc/visionipc_client.h" +#include "visionipc/visionipc_server.h" +#include "logger/logger.h" + +VisionIpcClient::VisionIpcClient(std::string name, VisionStreamType type, bool conflate, cl_device_id device_id, cl_context ctx) : name(name), type(type), device_id(device_id), ctx(ctx) { + msg_ctx = Context::create(); + sock = SubSocket::create(msg_ctx, get_endpoint_name(name, type), "127.0.0.1", conflate, false); + + poller = Poller::create(); + poller->registerSocket(sock); +} + +// Connect is not thread safe. Do not use the buffers while calling connect +bool VisionIpcClient::connect(bool blocking){ + connected = false; + + // Cleanup old buffers on reconnect + for (size_t i = 0; i < num_buffers; i++){ + if (buffers[i].free() != 0) { + LOGE("Failed to free buffer %zu", i); + } + } + + num_buffers = 0; + + // Connect to server socket and ask for all FDs of type + std::string path = "/tmp/visionipc_" + name; + + int socket_fd = -1; + while (socket_fd < 0) { + socket_fd = ipc_connect(path.c_str()); + + if (socket_fd < 0) { + if (blocking){ + std::cout << "VisionIpcClient connecting" << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } else { + return false; + } + } + } + + // Send stream type to server to request FDs + int r = ipc_sendrecv_with_fds(true, socket_fd, &type, sizeof(type), nullptr, 0, nullptr); + assert(r == sizeof(type)); + + // Get FDs + int fds[VISIONIPC_MAX_FDS]; + VisionBuf bufs[VISIONIPC_MAX_FDS]; + r = ipc_sendrecv_with_fds(false, socket_fd, &bufs, sizeof(bufs), fds, VISIONIPC_MAX_FDS, &num_buffers); + + assert(num_buffers >= 0); + assert(r == sizeof(VisionBuf) * num_buffers); + + // Import buffers + for (size_t i = 0; i < num_buffers; i++){ + buffers[i] = bufs[i]; + buffers[i].fd = fds[i]; + buffers[i].import(); + if (buffers[i].rgb) { + buffers[i].init_rgb(buffers[i].width, buffers[i].height, buffers[i].stride); + } else { + buffers[i].init_yuv(buffers[i].width, buffers[i].height); + } + + if (device_id) buffers[i].init_cl(device_id, ctx); + } + + close(socket_fd); + connected = true; + return true; +} + +VisionBuf * VisionIpcClient::recv(VisionIpcBufExtra * extra, const int timeout_ms){ + auto p = poller->poll(timeout_ms); + + if (!p.size()){ + return nullptr; + } + + Message * r = sock->receive(true); + if (r == nullptr){ + return nullptr; + } + + // Get buffer + assert(r->getSize() == sizeof(VisionIpcPacket)); + VisionIpcPacket *packet = (VisionIpcPacket*)r->getData(); + + assert(packet->idx < num_buffers); + VisionBuf * buf = &buffers[packet->idx]; + + if (buf->server_id != packet->server_id){ + connected = false; + delete r; + return nullptr; + } + + if (extra) { + *extra = packet->extra; + } + + if (buf->sync(VISIONBUF_SYNC_TO_DEVICE) != 0) { + LOGE("Failed to sync buffer"); + } + + delete r; + return buf; +} + + + +VisionIpcClient::~VisionIpcClient(){ + for (size_t i = 0; i < num_buffers; i++){ + if (buffers[i].free() != 0) { + LOGE("Failed to free buffer %zu", i); + } + } + + delete sock; + delete poller; + delete msg_ctx; +} diff --git a/cereal/visionipc/visionipc_client.h b/cereal/visionipc/visionipc_client.h new file mode 100644 index 00000000000000..a6426ce921efb1 --- /dev/null +++ b/cereal/visionipc/visionipc_client.h @@ -0,0 +1,33 @@ +#pragma once +#include +#include +#include + +#include "messaging/messaging.h" +#include "visionipc/visionipc.h" +#include "visionipc/visionbuf.h" + +class VisionIpcClient { +private: + std::string name; + Context * msg_ctx; + SubSocket * sock; + Poller * poller; + + VisionStreamType type; + + cl_device_id device_id = nullptr; + cl_context ctx = nullptr; + + void init_msgq(bool conflate); + +public: + bool connected = false; + int num_buffers = 0; + VisionBuf buffers[VISIONIPC_MAX_FDS]; + VisionIpcClient(std::string name, VisionStreamType type, bool conflate, cl_device_id device_id=nullptr, cl_context ctx=nullptr); + ~VisionIpcClient(); + VisionBuf * recv(VisionIpcBufExtra * extra=nullptr, const int timeout_ms=100); + bool connect(bool blocking=true); + bool is_connected() { return connected; } +}; diff --git a/cereal/visionipc/visionipc_pyx.pyx b/cereal/visionipc/visionipc_pyx.pyx new file mode 100644 index 00000000000000..3168f1e66c647b --- /dev/null +++ b/cereal/visionipc/visionipc_pyx.pyx @@ -0,0 +1,93 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii, language_level=3 + +import sys +import numpy as np +cimport numpy as cnp +from cython.view cimport array +from libc.string cimport memcpy +from libc.stdint cimport uint32_t, uint64_t +from libcpp cimport bool +from libcpp.string cimport string + +from .visionipc cimport VisionIpcServer as cppVisionIpcServer +from .visionipc cimport VisionIpcClient as cppVisionIpcClient +from .visionipc cimport VisionBuf as cppVisionBuf +from .visionipc cimport VisionIpcBufExtra + +cpdef enum VisionStreamType: + VISION_STREAM_RGB_BACK + VISION_STREAM_RGB_FRONT + VISION_STREAM_RGB_WIDE + VISION_STREAM_ROAD + VISION_STREAM_DRIVER + VISION_STREAM_WIDE_ROAD + + +cdef class VisionIpcServer: + cdef cppVisionIpcServer * server + + def __init__(self, string name): + self.server = new cppVisionIpcServer(name, NULL, NULL) + + def create_buffers(self, VisionStreamType tp, size_t num_buffers, bool rgb, size_t width, size_t height): + self.server.create_buffers(tp, num_buffers, rgb, width, height) + + def send(self, VisionStreamType tp, bytes data, uint32_t frame_id=0, uint64_t timestamp_sof=0, uint64_t timestamp_eof=0): + cdef cppVisionBuf * buf = self.server.get_buffer(tp) + + # Populate buffer + assert buf.len == len(data) + memcpy(buf.addr, data, len(data)) + + cdef VisionIpcBufExtra extra + extra.frame_id = frame_id + extra.timestamp_sof = timestamp_sof + extra.timestamp_eof = timestamp_eof + + self.server.send(buf, &extra, False) + + def start_listener(self): + self.server.start_listener() + + def __dealloc__(self): + del self.server + + +cdef class VisionIpcClient: + cdef cppVisionBuf * buf + cdef cppVisionIpcClient * client + + def __cinit__(self, string name, VisionStreamType stream, bool conflate): + self.client = new cppVisionIpcClient(name, stream, conflate, NULL, NULL) + self.buf = NULL + + def __dealloc__(self): + del self.client + + @property + def width(self): + return None if not self.buf else self.buf.width + + @property + def height(self): + return None if not self.buf else self.buf.height + + @property + def stride(self): + return None if not self.buf else self.buf.stride + + def recv(self, int timeout_ms=100): + self.buf = self.client.recv(NULL, timeout_ms) + if not self.buf: + return None + cdef cnp.ndarray dat = np.empty(self.buf.len, dtype=np.uint8) + cdef char[:] dat_view = dat + memcpy(&dat_view[0], self.buf.addr, self.buf.len) + return dat + + def connect(self, bool blocking): + return self.client.connect(blocking) + + def is_connected(self): + return self.client.is_connected() diff --git a/cereal/visionipc/visionipc_server.cc b/cereal/visionipc/visionipc_server.cc new file mode 100644 index 00000000000000..e15c1aee4a94a1 --- /dev/null +++ b/cereal/visionipc/visionipc_server.cc @@ -0,0 +1,184 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "messaging/messaging.h" +#include "visionipc/ipc.h" +#include "visionipc/visionipc_server.h" +#include "logger/logger.h" + +std::string get_endpoint_name(std::string name, VisionStreamType type){ + if (messaging_use_zmq()){ + assert(name == "camerad"); + return std::to_string(9000 + static_cast(type)); + } else { + return "visionipc_" + name + "_" + std::to_string(type); + } +} + +VisionIpcServer::VisionIpcServer(std::string name, cl_device_id device_id, cl_context ctx) : name(name), device_id(device_id), ctx(ctx) { + msg_ctx = Context::create(); + + std::random_device rd("/dev/urandom"); + std::uniform_int_distribution distribution(0,std::numeric_limits::max()); + server_id = distribution(rd); +} + +void VisionIpcServer::create_buffers(VisionStreamType type, size_t num_buffers, bool rgb, size_t width, size_t height){ + // TODO: assert that this type is not created yet + assert(num_buffers < VISIONIPC_MAX_FDS); + int aligned_w = 0, aligned_h = 0; + + size_t size = 0; + size_t stride = 0; // Only used for RGB + + if (rgb) { + visionbuf_compute_aligned_width_and_height(width, height, &aligned_w, &aligned_h); + size = (size_t)aligned_w * (size_t)aligned_h * 3; + stride = aligned_w * 3; + } else { + size = width * height * 3 / 2; + } + + // Create map + alloc requested buffers + for (size_t i = 0; i < num_buffers; i++){ + VisionBuf* buf = new VisionBuf(); + buf->allocate(size); + buf->idx = i; + buf->type = type; + + if (device_id) buf->init_cl(device_id, ctx); + + rgb ? buf->init_rgb(width, height, stride) : buf->init_yuv(width, height); + + buffers[type].push_back(buf); + } + + cur_idx[type] = 0; + + // Create msgq publisher for each of the `name` + type combos + // TODO: compute port number directly if using zmq + sockets[type] = PubSocket::create(msg_ctx, get_endpoint_name(name, type), false); +} + + +void VisionIpcServer::start_listener(){ + listener_thread = std::thread(&VisionIpcServer::listener, this); +} + + +void VisionIpcServer::listener(){ + std::cout << "Starting listener for: " << name << std::endl; + + std::string path = "/tmp/visionipc_" + name; + int sock = ipc_bind(path.c_str()); + assert(sock >= 0); + + while (!should_exit){ + // Wait for incoming connection + struct pollfd polls[1] = {{0}}; + polls[0].fd = sock; + polls[0].events = POLLIN; + + int ret = poll(polls, 1, 100); + if (ret < 0) { + if (errno == EINTR || errno == EAGAIN) continue; + std::cout << "poll failed, stopping listener" << std::endl; + break; + } + + if (should_exit) break; + if (!polls[0].revents) { + continue; + } + + // Handle incoming request + int fd = accept(sock, NULL, NULL); + assert(fd >= 0); + + VisionStreamType type = VisionStreamType::VISION_STREAM_MAX; + int r = ipc_sendrecv_with_fds(false, fd, &type, sizeof(type), nullptr, 0, nullptr); + assert(r == sizeof(type)); + if (buffers.count(type) <= 0) { + std::cout << "got request for invalid buffer type: " << type << std::endl; + close(fd); + continue; + } + + int fds[VISIONIPC_MAX_FDS]; + int num_fds = buffers[type].size(); + VisionBuf bufs[VISIONIPC_MAX_FDS]; + + for (int i = 0; i < num_fds; i++){ + fds[i] = buffers[type][i]->fd; + bufs[i] = *buffers[type][i]; + + // Remove some private openCL/ion metadata + bufs[i].buf_cl = 0; + bufs[i].copy_q = 0; + bufs[i].handle = 0; + + bufs[i].server_id = server_id; + } + + r = ipc_sendrecv_with_fds(true, fd, &bufs, sizeof(VisionBuf) * num_fds, fds, num_fds, nullptr); + + close(fd); + } + + std::cout << "Stopping listener for: " << name << std::endl; + close(sock); +} + + + +VisionBuf * VisionIpcServer::get_buffer(VisionStreamType type){ + // Do we want to keep track if the buffer has been sent out yet and warn user? + assert(buffers.count(type)); + auto b = buffers[type]; + return b[cur_idx[type]++ % b.size()]; +} + +void VisionIpcServer::send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync){ + if (sync) { + if (buf->sync(VISIONBUF_SYNC_FROM_DEVICE) != 0) { + LOGE("Failed to sync buffer"); + } + } + assert(buffers.count(buf->type)); + assert(buf->idx < buffers[buf->type].size()); + + // Send over correct msgq socket + VisionIpcPacket packet = {0}; + packet.server_id = server_id; + packet.idx = buf->idx; + packet.extra = *extra; + + sockets[buf->type]->send((char*)&packet, sizeof(packet)); +} + +VisionIpcServer::~VisionIpcServer(){ + should_exit = true; + listener_thread.join(); + + // VisionBuf cleanup + for( auto const& [type, buf] : buffers ) { + for (VisionBuf* b : buf){ + if (b->free() != 0) { + LOGE("Failed to free buffer"); + } + delete b; + } + } + + // Messaging cleanup + for( auto const& [type, sock] : sockets ) { + delete sock; + } + delete msg_ctx; +} diff --git a/cereal/visionipc/visionipc_server.h b/cereal/visionipc/visionipc_server.h new file mode 100644 index 00000000000000..01409f78d8dd85 --- /dev/null +++ b/cereal/visionipc/visionipc_server.h @@ -0,0 +1,42 @@ +#pragma once +#include +#include +#include +#include +#include + +#include "messaging/messaging.h" +#include "visionipc/visionipc.h" +#include "visionipc/visionbuf.h" + +std::string get_endpoint_name(std::string name, VisionStreamType type); + +class VisionIpcServer { + private: + cl_device_id device_id = nullptr; + cl_context ctx = nullptr; + uint64_t server_id; + + std::atomic should_exit = false; + std::string name; + std::thread listener_thread; + + std::map > cur_idx; + std::map > buffers; + std::map > idxs; + + Context * msg_ctx; + std::map sockets; + + void listener(void); + + public: + VisionIpcServer(std::string name, cl_device_id device_id=nullptr, cl_context ctx=nullptr); + ~VisionIpcServer(); + + VisionBuf * get_buffer(VisionStreamType type); + + void create_buffers(VisionStreamType type, size_t num_buffers, bool rgb, size_t width, size_t height); + void send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync=true); + void start_listener(); +}; diff --git a/cereal/visionipc/visionipc_tests.cc b/cereal/visionipc/visionipc_tests.cc new file mode 100644 index 00000000000000..4d1df05f51db0a --- /dev/null +++ b/cereal/visionipc/visionipc_tests.cc @@ -0,0 +1,137 @@ +#include +#include + +#include "catch2/catch.hpp" +#include "visionipc_server.h" +#include "visionipc_client.h" + +static void zmq_sleep(int milliseconds=1000){ + if (messaging_use_zmq()){ + std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); + } +} + +TEST_CASE("Connecting"){ + VisionIpcServer server("camerad"); + server.create_buffers(VISION_STREAM_ROAD, 1, false, 100, 100); + server.start_listener(); + + VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_ROAD, false); + REQUIRE(client.connect()); + + REQUIRE(client.connected); +} + +TEST_CASE("Check buffers"){ + size_t width = 100, height = 200, num_buffers = 5; + VisionIpcServer server("camerad"); + server.create_buffers(VISION_STREAM_ROAD, num_buffers, false, width, height); + server.start_listener(); + + VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_ROAD, false); + REQUIRE(client.connect()); + + REQUIRE(client.buffers[0].width == width); + REQUIRE(client.buffers[0].height == height); + REQUIRE(client.buffers[0].len); + REQUIRE(client.num_buffers == num_buffers); +} + +TEST_CASE("Check yuv/rgb"){ + VisionIpcServer server("camerad"); + server.create_buffers(VISION_STREAM_ROAD, 1, false, 100, 100); + server.create_buffers(VISION_STREAM_RGB_BACK, 1, true, 100, 100); + server.start_listener(); + + VisionIpcClient client_yuv = VisionIpcClient("camerad", VISION_STREAM_ROAD, false); + VisionIpcClient client_rgb = VisionIpcClient("camerad", VISION_STREAM_RGB_BACK, false); + client_yuv.connect(); + client_rgb.connect(); + + REQUIRE(client_rgb.buffers[0].rgb == true); + REQUIRE(client_yuv.buffers[0].rgb == false); +} + +TEST_CASE("Send single buffer"){ + VisionIpcServer server("camerad"); + server.create_buffers(VISION_STREAM_ROAD, 1, true, 100, 100); + server.start_listener(); + + VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_ROAD, false); + REQUIRE(client.connect()); + zmq_sleep(); + + VisionBuf * buf = server.get_buffer(VISION_STREAM_ROAD); + REQUIRE(buf != nullptr); + + *((uint64_t*)buf->addr) = 1234; + + VisionIpcBufExtra extra = {0}; + extra.frame_id = 1337; + buf->set_frame_id(extra.frame_id); + + server.send(buf, &extra); + + VisionIpcBufExtra extra_recv = {0}; + VisionBuf * recv_buf = client.recv(&extra_recv); + REQUIRE(recv_buf != nullptr); + REQUIRE(*(uint64_t*)recv_buf->addr == 1234); + REQUIRE(extra_recv.frame_id == extra.frame_id); + REQUIRE(recv_buf->get_frame_id() == extra.frame_id); +} + + +TEST_CASE("Test no conflate"){ + VisionIpcServer server("camerad"); + server.create_buffers(VISION_STREAM_ROAD, 1, true, 100, 100); + server.start_listener(); + + VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_ROAD, false); + REQUIRE(client.connect()); + zmq_sleep(); + + VisionBuf * buf = server.get_buffer(VISION_STREAM_ROAD); + REQUIRE(buf != nullptr); + + VisionIpcBufExtra extra = {0}; + extra.frame_id = 1; + server.send(buf, &extra); + extra.frame_id = 2; + server.send(buf, &extra); + + VisionIpcBufExtra extra_recv = {0}; + VisionBuf * recv_buf = client.recv(&extra_recv); + REQUIRE(recv_buf != nullptr); + REQUIRE(extra_recv.frame_id == 1); + + recv_buf = client.recv(&extra_recv); + REQUIRE(recv_buf != nullptr); + REQUIRE(extra_recv.frame_id == 2); +} + +TEST_CASE("Test conflate"){ + VisionIpcServer server("camerad"); + server.create_buffers(VISION_STREAM_ROAD, 1, true, 100, 100); + server.start_listener(); + + VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_ROAD, true); + REQUIRE(client.connect()); + zmq_sleep(); + + VisionBuf * buf = server.get_buffer(VISION_STREAM_ROAD); + REQUIRE(buf != nullptr); + + VisionIpcBufExtra extra = {0}; + extra.frame_id = 1; + server.send(buf, &extra); + extra.frame_id = 2; + server.send(buf, &extra); + + VisionIpcBufExtra extra_recv = {0}; + VisionBuf * recv_buf = client.recv(&extra_recv); + REQUIRE(recv_buf != nullptr); + REQUIRE(extra_recv.frame_id == 2); + + recv_buf = client.recv(&extra_recv); + REQUIRE(recv_buf == nullptr); +} 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..a41fc8b7eb241a --- /dev/null +++ b/common/SConscript @@ -0,0 +1,4 @@ +Import('envCython', 'common') + +envCython.Program('clock.so', 'clock.pyx') +envCython.Program('params_pyx.so', 'params_pyx.pyx', LIBS=envCython['LIBS'] + [common, 'zmq']) diff --git a/common/api/__init__.py b/common/api/__init__.py index 2dc2ffa990533b..8b83dfc641699a 100644 --- a/common/api/__init__.py +++ b/common/api/__init__.py @@ -1,15 +1,46 @@ +import jwt +import os import requests +from datetime import datetime, timedelta +from common.basedir import PERSIST +from selfdrive.version import get_version -from selfdrive.version import version +API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com') -def api_get(endpoint, method='GET', timeout=None, access_token=None, **params): - backend = "https://api.commadotai.com/" +class Api(): + def __init__(self, dongle_id): + self.dongle_id = dongle_id + with open(PERSIST+'/comma/id_rsa') as f: + self.private_key = f.read() + + def get(self, *args, **kwargs): + return self.request('GET', *args, **kwargs) + + def post(self, *args, **kwargs): + return self.request('POST', *args, **kwargs) + + 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): + now = datetime.utcnow() + payload = { + 'identity': self.dongle_id, + 'nbf': now, + 'iat': now, + 'exp': now + timedelta(hours=1) + } + token = jwt.encode(payload, self.private_key, algorithm='RS256') + if isinstance(token, bytes): + token = token.decode('utf8') + return token + + +def api_get(endpoint, method='GET', timeout=None, access_token=None, **params): headers = {} if access_token is not None: - headers['Authorization'] = "JWT "+access_token - - headers['User-Agent'] = "openpilot-" + version + headers['Authorization'] = "JWT " + access_token - return requests.request(method, backend+endpoint, timeout=timeout, headers = headers, params=params) + headers['User-Agent'] = "openpilot-" + get_version() + return requests.request(method, API_HOST + "/" + endpoint, timeout=timeout, headers=headers, params=params) diff --git a/common/basedir.py b/common/basedir.py index 99760fa3343653..8be1cf6afa729d 100644 --- a/common/basedir.py +++ b/common/basedir.py @@ -1,4 +1,11 @@ import os -BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) +from pathlib import Path + +from selfdrive.hardware import PC +BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) +if PC: + PERSIST = os.path.join(str(Path.home()), ".comma", "persist") +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/dbc.py b/common/dbc.py deleted file mode 100755 index 693b2985a4cf62..00000000000000 --- a/common/dbc.py +++ /dev/null @@ -1,289 +0,0 @@ -import re -import os -import struct -import sys -import numbers -from collections import namedtuple, defaultdict - -def int_or_float(s): - # return number, trying to maintain int format - if s.isdigit(): - return int(s, 10) - else: - return float(s) - -DBCSignal = namedtuple( - "DBCSignal", ["name", "start_bit", "size", "is_little_endian", "is_signed", - "factor", "offset", "tmin", "tmax", "units"]) - - -class dbc(object): - def __init__(self, fn): - self.name, _ = os.path.splitext(os.path.basename(fn)) - with open(fn) as f: - self.txt = f.readlines() - self._warned_addresses = set() - - # regexps from https://github.com/ebroecker/canmatrix/blob/master/canmatrix/importdbc.py - bo_regexp = re.compile(r"^BO\_ (\w+) (\w+) *: (\w+) (\w+)") - sg_regexp = re.compile(r"^SG\_ (\w+) : (\d+)\|(\d+)@(\d+)([\+|\-]) \(([0-9.+\-eE]+),([0-9.+\-eE]+)\) \[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] \"(.*)\" (.*)") - sgm_regexp = re.compile(r"^SG\_ (\w+) (\w+) *: (\d+)\|(\d+)@(\d+)([\+|\-]) \(([0-9.+\-eE]+),([0-9.+\-eE]+)\) \[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] \"(.*)\" (.*)") - val_regexp = re.compile(r"VAL\_ (\w+) (\w+) (\s*[-+]?[0-9]+\s+\".+?\"[^;]*)") - - # A dictionary which maps message ids to tuples ((name, size), signals). - # name is the ASCII name of the message. - # size is the size of the message in bytes. - # signals is a list signals contained in the message. - # signals is a list of DBCSignal in order of increasing start_bit. - self.msgs = {} - - # A dictionary which maps message ids to a list of tuples (signal name, definition value pairs) - self.def_vals = defaultdict(list) - - # lookup to bit reverse each byte - self.bits_index = [(i & ~0b111) + ((-i-1) & 0b111) for i in xrange(64)] - - for l in self.txt: - l = l.strip() - - if l.startswith("BO_ "): - # new group - dat = bo_regexp.match(l) - - if dat is None: - print("bad BO {0}".format(l)) - - name = dat.group(2) - size = int(dat.group(3)) - ids = int(dat.group(1), 0) # could be hex - if ids in self.msgs: - sys.exit("Duplicate address detected %d %s" % (ids, self.name)) - - self.msgs[ids] = ((name, size), []) - - if l.startswith("SG_ "): - # new signal - dat = sg_regexp.match(l) - go = 0 - if dat is None: - dat = sgm_regexp.match(l) - go = 1 - - if dat is None: - 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) - - self.msgs[ids][1].append( - DBCSignal(sgname, start_bit, signal_size, is_little_endian, - is_signed, factor, offset, tmin, tmax, units)) - - if l.startswith("VAL_ "): - # new signal value/definition - dat = val_regexp.match(l) - - if dat is None: - print("bad VAL {0}".format(l)) - - 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.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)+'"' - - self.def_vals[ids].append((sgname, defvals)) - - for msg in self.msgs.values(): - msg[1].sort(key=lambda x: x.start_bit) - - self.msg_name_to_address = {} - for address, m in self.msgs.items(): - name = m[0][0] - self.msg_name_to_address[name] = address - - def lookup_msg_id(self, msg_id): - if not isinstance(msg_id, numbers.Number): - msg_id = self.msg_name_to_address[msg_id] - return msg_id - - def reverse_bytes(self, x): - return ((x & 0xff00000000000000) >> 56) | \ - ((x & 0x00ff000000000000) >> 40) | \ - ((x & 0x0000ff0000000000) >> 24) | \ - ((x & 0x000000ff00000000) >> 8) | \ - ((x & 0x00000000ff000000) << 8) | \ - ((x & 0x0000000000ff0000) << 24) | \ - ((x & 0x000000000000ff00) << 40) | \ - ((x & 0x00000000000000ff) << 56) - - def encode(self, msg_id, dd): - """Encode a CAN message using the dbc. - - Inputs: - msg_id: The message ID. - dd: A dictionary mapping signal name to signal data. - """ - msg_id = self.lookup_msg_id(msg_id) - - msg_def = self.msgs[msg_id] - size = msg_def[0][1] - - result = 0 - for s in msg_def[1]: - 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 - - 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: - mask = self.reverse_bytes(mask) - dat = self.reverse_bytes(dat) - - result &= ~mask - result |= dat - - result = struct.pack('>Q', result) - return result[:size] - - def decode(self, x, arr=None, debug=False): - """Decode a CAN message using the dbc. - - Inputs: - x: A collection with elements (address, time, data), where address is - the CAN address, time is the bus time, and data is the CAN data as a - hex string. - arr: Optional list of signals which should be decoded and returned. - debug: True to print debugging statements. - - Returns: - A tuple (name, data), where name is the name of the CAN message and data - is the decoded result. If arr is None, data is a dict of properties. - Otherwise data is a list of the same length as arr. - - Returns (None, None) if the message could not be decoded. - """ - - if arr is None: - out = {} - else: - 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])) - self._warned_addresses.add(x[0]) - return None, None - - name = msg[0][0] - if debug: - print(name) - - st = x[2].ljust(8, '\x00') - le, be = None, None - - for s in msg[1]: - if arr is not None and s[0] not in arr: - continue - - start_bit = s[1] - signal_size = s[2] - little_endian = s[3] - signed = s[4] - 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 - - if shift_amount < 0: - continue - - tmp = (tmp >> shift_amount) & ((1 << b2) - 1) - if signed and (tmp >> (b2 - 1)): - tmp -= (1 << b2) - - tmp = tmp * factor + offset - - # if debug: - # print("%40s %2d %2d %7.2f %s" % (s[0], s[1], s[2], tmp, s[-1])) - - if arr is None: - out[s[0]] = tmp - else: - out[arr.index(s[0])] = tmp - return name, out - - def get_signals(self, msg): - msg = self.lookup_msg_id(msg) - return [sgs.name for sgs in self.msgs[msg][1]] - - -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}) - encoded = dbc_test.encode(*msg) - decoded = dbc_test.decode((0x25, 0, encoded)) - assert decoded == 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) - - 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) - decoded = dbc_test.decode((0x2b0, 0, encoded)) - - assert decoded == msg diff --git a/common/dict_helpers.py b/common/dict_helpers.py new file mode 100644 index 00000000000000..62cff63b58ebb7 --- /dev/null +++ b/common/dict_helpers.py @@ -0,0 +1,9 @@ +# remove all keys that end in DEPRECATED +def strip_deprecated_keys(d): + for k in list(d.keys()): + if isinstance(k, str): + if k.endswith('DEPRECATED'): + d.pop(k) + elif isinstance(d[k], dict): + strip_deprecated_keys(d[k]) + return d 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 bdfe9d0ecf84b5..2037a665b060dc 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,33 +21,26 @@ 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"): - 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): - def __init__(self, target_path, temp_dir=None): - self._target_path = target_path + +class NamedTemporaryDir(): + def __init__(self, temp_dir=None): self._path = tempfile.mkdtemp(dir=temp_dir) @property @@ -51,39 +48,40 @@ def name(self): return self._path def close(self): - os.rename(self._path, self._target_path) + shutil.rmtree(self._path) - def __enter__(self): return self + def __enter__(self): + return self - def __exit__(self, type, value, traceback): - if type is None: - self.close() - else: - shutil.rmtree(self._path) + def __exit__(self, exc_type, exc_value, traceback): + self.close() -class NamedTemporaryDir(object): - def __init__(self, temp_dir=None): - self._path = tempfile.mkdtemp(dir=temp_dir) - @property - def name(self): - return self._path +class CallbackReader: + """Wraps a file, but overrides the read method to also + call a callback function with the number of bytes read so far.""" + def __init__(self, f, callback, *args): + self.f = f + self.callback = callback + self.cb_args = args + self.total_read = 0 - def close(self): - shutil.rmtree(self._path) + def __getattr__(self, attr): + return getattr(self.f, attr) - def __enter__(self): return self + def read(self, *args, **kwargs): + chunk = self.f.read(*args, **kwargs) + self.total_read += len(chunk) + self.callback(*self.cb_args, self.total_read) + return chunk - def __exit__(self, type, value, traceback): - self.close() def _get_fileobject_func(writer, temp_dir): def _get_fileobject(): - file_obj = writer.get_fileobject(dir=temp_dir) - os.chmod(file_obj.name, 0o644) - return file_obj + return writer.get_fileobject(dir=temp_dir) 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. @@ -100,4 +98,3 @@ def atomic_write_in_dir(path, **kwargs): """ writer = AtomicWriter(path, **kwargs) return writer._open(_get_fileobject_func(writer, os.path.dirname(path))) - diff --git a/common/filter_simple.py b/common/filter_simple.py index a3206db1cc5684..0ec7a515621afb 100644 --- a/common/filter_simple.py +++ b/common/filter_simple.py @@ -1,10 +1,18 @@ -class FirstOrderFilter(): +class FirstOrderFilter: # first order filter - def __init__(self, x0, ts, dt): - self.k = (dt / ts) / (1. + dt / ts) + def __init__(self, x0, rc, dt, initialized=True): self.x = x0 + self.dt = dt + self.update_alpha(rc) + self.initialized = initialized - def update(self, x): - self.x = (1. - self.k) * self.x + self.k * x - + def update_alpha(self, rc): + self.alpha = self.dt / (rc + self.dt) + def update(self, x): + if self.initialized: + self.x = (1. - self.alpha) * self.x + self.alpha * x + else: + self.initialized = True + self.x = x + return self.x diff --git a/common/fingerprints.py b/common/fingerprints.py deleted file mode 100644 index ddc3bceb66ae8d..00000000000000 --- a/common/fingerprints.py +++ /dev/null @@ -1,64 +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 - bus = msg.src - # ignore addresses that are more than 11 bits - return (adr in car_fingerprint and car_fingerprint[adr] == len(msg.dat)) or \ - bus != 0 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/ekf.py b/common/kalman/ekf.py deleted file mode 100644 index fbed218f7a7b38..00000000000000 --- a/common/kalman/ekf.py +++ /dev/null @@ -1,253 +0,0 @@ -# pylint: skip-file -from __future__ import print_function -import abc -import numpy as np -# The EKF class contains the framework for an Extended Kalman Filter, but must be subclassed to use. -# A subclass must implement: -# 1) calc_transfer_fun(); see bottom of file for more info. -# 2) __init__() to initialize self.state, self.covar, and self.process_noise appropriately - -# Alternatively, the existing implementations of EKF can be used (e.g. EKF2D) - -# Sensor classes are optionally used to pass measurement information into the EKF, to keep -# sensor parameters and processing methods for a each sensor together. -# Sensor classes have a read() method which takes raw sensor data and returns -# a SensorReading object, which can be passed to the EKF update() method. - -# For usage, see run_ekf1d.py in selfdrive/new for a simple example. -# ekf.predict(dt) should be called between update cycles with the time since it was last called. -# Ideally, predict(dt) should be called at a relatively constant rate. -# update() should be called once per sensor, and can be called multiple times between predict steps. -# Access and set the state of the filter directly with ekf.state and ekf.covar. - - -class SensorReading: - # Given a perfect model and no noise, data = obs_model * state - def __init__(self, data, covar, obs_model): - self.data = data - self.obs_model = obs_model - self.covar = covar - - def __repr__(self): - return "SensorReading(data={}, covar={}, obs_model={})".format( - repr(self.data), repr(self.covar), repr(self.obs_model)) - - -# A generic sensor class that does no pre-processing of data -class SimpleSensor: - # obs_model can be - # a full observation model matrix, or - # an integer or tuple of indices into ekf.state, indicating which variables are being directly observed - # covar can be - # a full covariance matrix - # a float or tuple of individual covars for each component of the sensor reading - # dims is the number of states in the EKF - def __init__(self, obs_model, covar, dims): - # Allow for integer covar/obs_model - if not hasattr(obs_model, "__len__"): - obs_model = (obs_model, ) - if not hasattr(covar, "__len__"): - covar = (covar, ) - - # Full observation model passed - if dims in np.array(obs_model).shape: - self.obs_model = np.asmatrix(obs_model) - self.covar = np.asmatrix(covar) - # Indices of unit observations passed - else: - self.obs_model = np.matlib.zeros((len(obs_model), dims)) - self.obs_model[:, list(obs_model)] = np.identity(len(obs_model)) - if np.asarray(covar).ndim == 2: - self.covar = np.asmatrix(covar) - elif len(covar) == len(obs_model): - self.covar = np.matlib.diag(covar) - else: - self.covar = np.matlib.identity(len(obs_model)) * covar - - def read(self, data, covar=None): - if covar: - self.covar = covar - return SensorReading(data, self.covar, self.obs_model) - - -class EKF: - __metaclass__ = abc.ABCMeta - - def __init__(self, debug=False): - self.DEBUG = debug - - - def __str__(self): - return "EKF(state={}, covar={})".format(self.state, self.covar) - - # Measurement update - # Reading should be a SensorReading object with data, covar, and obs_model attributes - def update(self, reading): - # Potential improvements: - # deal with negative covars - # add noise to really low covars to ensure stability - # use mahalanobis distance to reject outliers - # wrap angles after state updates and innovation - - # y = z - H*x - innovation = reading.data - reading.obs_model * self.state - - if self.DEBUG: - print("reading:\n",reading.data) - print("innovation:\n",innovation) - - # S = H*P*H' + R - innovation_covar = reading.obs_model * self.covar * reading.obs_model.T + reading.covar - - # K = P*H'*S^-1 - kalman_gain = self.covar * reading.obs_model.T * np.linalg.inv( - innovation_covar) - - if self.DEBUG: - print("gain:\n", kalman_gain) - print("innovation_covar:\n", innovation_covar) - print("innovation: ", innovation) - print("test: ", self.covar * reading.obs_model.T * ( - reading.obs_model * self.covar * reading.obs_model.T + reading.covar * - 0).I) - - # x = x + K*y - self.state += kalman_gain*innovation - - # print "covar", np.diag(self.covar) - #self.state[(roll_vel, yaw_vel, pitch_vel),:] = reading.data - - # Standard form: P = (I - K*H)*P - # self.covar = (self.identity - kalman_gain*reading.obs_model) * self.covar - - # Use the Joseph form for numerical stability: P = (I-K*H)*P*(I - K*H)' + K*R*K' - aux_mtrx = (self.identity - kalman_gain * reading.obs_model) - self.covar = aux_mtrx * self.covar * aux_mtrx.T + kalman_gain * reading.covar * kalman_gain.T - - if self.DEBUG: - print("After update") - print("state\n", self.state) - print("covar:\n",self.covar) - - def update_scalar(self, reading): - # like update but knowing that measurement is a scalar - # this avoids matrix inversions and speeds up (surprisingly) drived.py a lot - - # innovation = reading.data - np.matmul(reading.obs_model, self.state) - # innovation_covar = np.matmul(np.matmul(reading.obs_model, self.covar), reading.obs_model.T) + reading.covar - # kalman_gain = np.matmul(self.covar, reading.obs_model.T)/innovation_covar - # self.state += np.matmul(kalman_gain, innovation) - # aux_mtrx = self.identity - np.matmul(kalman_gain, reading.obs_model) - # self.covar = np.matmul(aux_mtrx, np.matmul(self.covar, aux_mtrx.T)) + np.matmul(kalman_gain, np.matmul(reading.covar, kalman_gain.T)) - - # written without np.matmul - es = np.einsum - ABC_T = "ij,jk,lk->il" - AB_T = "ij,kj->ik" - AB = "ij,jk->ik" - innovation = reading.data - es(AB, reading.obs_model, self.state) - innovation_covar = es(ABC_T, reading.obs_model, self.covar, - reading.obs_model) + reading.covar - kalman_gain = es(AB_T, self.covar, reading.obs_model) / innovation_covar - - self.state += es(AB, kalman_gain, innovation) - aux_mtrx = self.identity - es(AB, kalman_gain, reading.obs_model) - self.covar = es(ABC_T, aux_mtrx, self.covar, aux_mtrx) + \ - es(ABC_T, kalman_gain, reading.covar, kalman_gain) - - # Prediction update - def predict(self, dt): - es = np.einsum - ABC_T = "ij,jk,lk->il" - AB = "ij,jk->ik" - - # State update - transfer_fun, transfer_fun_jacobian = self.calc_transfer_fun(dt) - - # self.state = np.matmul(transfer_fun, self.state) - # self.covar = np.matmul(np.matmul(transfer_fun_jacobian, self.covar), transfer_fun_jacobian.T) + self.process_noise * dt - - # x = f(x, u), written in the form x = A(x, u)*x - self.state = es(AB, transfer_fun, self.state) - - # P = J*P*J' + Q - self.covar = es(ABC_T, transfer_fun_jacobian, self.covar, - transfer_fun_jacobian) + self.process_noise * dt #!dt - - #! Clip covariance to avoid explosions - self.covar = np.clip(self.covar,-1e10,1e10) - - @abc.abstractmethod - def calc_transfer_fun(self, dt): - """Return a tuple with the transfer function and transfer function jacobian - The transfer function and jacobian should both be a numpy matrix of size DIMSxDIMS - - The transfer function matrix A should satisfy the state-update equation - x_(k+1) = A * x_k - - The jacobian J is the direct jacobian A*x_k. For linear systems J=A. - - Current implementations calculate A and J as functions of state. Control input - can be added trivially by adding a control parameter to predict() and calc_tranfer_update(), - and using it during calculation of A and J - """ - - -class FastEKF1D(EKF): - """Fast version of EKF for 1D problems with scalar readings.""" - - def __init__(self, dt, var_init, Q): - super(FastEKF1D, self).__init__(False) - self.state = [0, 0] - self.covar = [var_init, var_init, 0] - - # Process Noise - self.dtQ0 = dt * Q[0] - self.dtQ1 = dt * Q[1] - - def update(self, reading): - raise NotImplementedError - - def update_scalar(self, reading): - # TODO(mgraczyk): Delete this for speed. - # assert np.all(reading.obs_model == [1, 0]) - - rcov = reading.covar[0, 0] - - x = self.state - S = self.covar - - innovation = reading.data - x[0] - innovation_covar = S[0] + rcov - - k0 = S[0] / innovation_covar - k1 = S[2] / innovation_covar - - x[0] += k0 * innovation - x[1] += k1 * innovation - - mk = 1 - k0 - S[1] += k1 * (k1 * (S[0] + rcov) - 2 * S[2]) - S[2] = mk * (S[2] - k1 * S[0]) + rcov * k0 * k1 - S[0] = mk * mk * S[0] + rcov * k0 * k0 - - def predict(self, dt): - # State update - x = self.state - - x[0] += dt * x[1] - - # P = J*P*J' + Q - S = self.covar - S[0] += dt * (2 * S[2] + dt * S[1]) + self.dtQ0 - S[2] += dt * S[1] - S[1] += self.dtQ1 - - # Clip covariance to avoid explosions - S = max(-1e10, min(S, 1e10)) - - def calc_transfer_fun(self, dt): - tf = np.identity(2) - tf[0, 1] = dt - tfj = tf - return tf, tfj 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_ekf.py b/common/kalman/tests/test_ekf.py deleted file mode 100644 index 3d6da323d47abd..00000000000000 --- a/common/kalman/tests/test_ekf.py +++ /dev/null @@ -1,116 +0,0 @@ -import numpy as np -import numpy.matlib -import unittest -import timeit - -from common.kalman.ekf import EKF, SimpleSensor, FastEKF1D - -class TestEKF(EKF): - def __init__(self, var_init, Q): - super(TestEKF, self).__init__(False) - self.identity = numpy.matlib.identity(2) - self.state = numpy.matlib.zeros((2, 1)) - self.covar = self.identity * var_init - - self.process_noise = numpy.matlib.diag(Q) - - def calc_transfer_fun(self, dt): - tf = numpy.matlib.identity(2) - tf[0, 1] = dt - return tf, tf - - -class EKFTest(unittest.TestCase): - def test_update_scalar(self): - ekf = TestEKF(1e3, [0.1, 1]) - dt = 1. / 100 - - sensor = SimpleSensor(0, 1, 2) - readings = map(sensor.read, np.arange(100, 300)) - - for reading in readings: - ekf.update_scalar(reading) - ekf.predict(dt) - - np.testing.assert_allclose(ekf.state, [[300], [100]], 1e-4) - np.testing.assert_allclose( - ekf.covar, - np.asarray([[0.0563, 0.10278], [0.10278, 0.55779]]), - atol=1e-4) - - def test_unbiased(self): - ekf = TestEKF(1e3, [0., 0.]) - dt = np.float64(1. / 100) - - sensor = SimpleSensor(0, 1, 2) - readings = map(sensor.read, np.arange(1000)) - - for reading in readings: - ekf.update_scalar(reading) - ekf.predict(dt) - - np.testing.assert_allclose(ekf.state, [[1000.], [100.]], 1e-4) - - -class FastEKF1DTest(unittest.TestCase): - def test_correctness(self): - dt = 1. / 100 - reading = SimpleSensor(0, 1, 2).read(100) - - ekf = TestEKF(1e3, [0.1, 1]) - fast_ekf = FastEKF1D(dt, 1e3, [0.1, 1]) - - ekf.update_scalar(reading) - fast_ekf.update_scalar(reading) - self.assertAlmostEqual(ekf.state[0] , fast_ekf.state[0]) - self.assertAlmostEqual(ekf.state[1] , fast_ekf.state[1]) - self.assertAlmostEqual(ekf.covar[0, 0], fast_ekf.covar[0]) - self.assertAlmostEqual(ekf.covar[0, 1], fast_ekf.covar[2]) - self.assertAlmostEqual(ekf.covar[1, 1], fast_ekf.covar[1]) - - ekf.predict(dt) - fast_ekf.predict(dt) - self.assertAlmostEqual(ekf.state[0] , fast_ekf.state[0]) - self.assertAlmostEqual(ekf.state[1] , fast_ekf.state[1]) - self.assertAlmostEqual(ekf.covar[0, 0], fast_ekf.covar[0]) - self.assertAlmostEqual(ekf.covar[0, 1], fast_ekf.covar[2]) - self.assertAlmostEqual(ekf.covar[1, 1], fast_ekf.covar[1]) - - def test_speed(self): - setup = """ -import numpy as np -from common.kalman.tests.test_ekf import TestEKF -from common.kalman.ekf import SimpleSensor, FastEKF1D - -dt = 1. / 100 -reading = SimpleSensor(0, 1, 2).read(100) - -var_init, Q = 1e3, [0.1, 1] -ekf = TestEKF(var_init, Q) -fast_ekf = FastEKF1D(dt, var_init, Q) - """ - - timeit.timeit(""" -ekf.update_scalar(reading) -ekf.predict(dt) - """, setup=setup, number=1000) - - ekf_speed = timeit.timeit(""" -ekf.update_scalar(reading) -ekf.predict(dt) - """, setup=setup, number=20000) - - timeit.timeit(""" -fast_ekf.update_scalar(reading) -fast_ekf.predict(dt) - """, setup=setup, number=1000) - - fast_ekf_speed = timeit.timeit(""" -fast_ekf.update_scalar(reading) -fast_ekf.predict(dt) - """, setup=setup, number=20000) - - assert fast_ekf_speed < ekf_speed / 4 - -if __name__ == "__main__": - unittest.main() 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..d3a75d0f485fa3 100644 --- a/common/logging_extra.py +++ b/common/logging_extra.py @@ -1,9 +1,12 @@ +import io import os import sys import copy import json +import uuid import socket import logging +import traceback from threading import local from collections import OrderedDict from contextlib import contextmanager @@ -60,14 +63,57 @@ def format_dict(self, record): return record_dict def format(self, record): + if self.swaglogger is None: + raise Exception("must set swaglogger before calling format()") return json_robust_dumps(self.format_dict(record)) +class SwagLogFileFormatter(SwagFormatter): + def fix_kv(self, k, v): + # append type to names to preserve legacy naming in logs + # avoids overlapping key namespaces with different types + # e.g. log.info() creates 'msg' -> 'msg$s' + # log.event() creates 'msg.health.logMonoTime' -> 'msg.health.logMonoTime$i' + # because overlapping namespace 'msg' caused problems + if isinstance(v, (str, bytes)): + k += "$s" + elif isinstance(v, float): + k += "$f" + elif isinstance(v, bool): + k += "$b" + elif isinstance(v, int): + k += "$i" + elif isinstance(v, dict): + nv = {} + for ik, iv in v.items(): + ik, iv = self.fix_kv(ik, iv) + nv[ik] = iv + v = nv + elif isinstance(v, list): + k += "$a" + return k, v + + def format(self, record): + if isinstance(record, str): + v = json.loads(record) + else: + v = self.format_dict(record) + + mk, mv = self.fix_kv('msg', v['msg']) + del v['msg'] + v[mk] = mv + v['id'] = uuid.uuid4().hex + + return json_robust_dumps(v) + 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 +124,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 +156,51 @@ 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) + elif 'debug' in kwargs: + self.debug(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/markdown.py b/common/markdown.py new file mode 100755 index 00000000000000..30c5bc2c09c8c2 --- /dev/null +++ b/common/markdown.py @@ -0,0 +1,48 @@ +from typing import List + +HTML_REPLACEMENTS = [ + (r'&', r'&'), + (r'"', r'"'), +] + + +def parse_markdown(text: str, tab_length: int = 2) -> str: + lines = text.split("\n") + output: List[str] = [] + list_level = 0 + + def end_outstanding_lists(level: int, end_level: int) -> int: + while level > end_level: + level -= 1 + output.append("") + if level > 0: + output.append("") + return end_level + + for i, line in enumerate(lines): + if i + 1 < len(lines) and lines[i + 1].startswith("==="): # heading + output.append(f"

{line}

") + elif line.startswith("==="): + pass + elif line.lstrip().startswith("* "): # list + line_level = 1 + line.count(" " * tab_length, 0, line.index("*")) + if list_level >= line_level: + list_level = end_outstanding_lists(list_level, line_level) + else: + list_level += 1 + if list_level > 1: + output[-1] = output[-1].replace("", "") + output.append("
    ") + output.append(f"
  • {line.replace('*', '', 1).lstrip()}
  • ") + else: + list_level = end_outstanding_lists(list_level, 0) + if len(line) > 0: + output.append(line) + + end_outstanding_lists(list_level, 0) + output_str = "\n".join(output) + "\n" + + for (fr, to) in HTML_REPLACEMENTS: + output_str = output_str.replace(fr, to) + + return output_str 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 c374d5233e2b67..2cfca37129afd6 --- a/common/params.py +++ b/common/params.py @@ -1,360 +1,19 @@ -#!/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 - - -class UnknownKeyName(Exception): - pass - - -keys = { - "AccessToken": [TxType.PERSISTENT], - "CalibrationParams": [TxType.PERSISTENT], - "CarParams": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], - "CompletedTrainingVersion": [TxType.PERSISTENT], - "ControlsParams": [TxType.PERSISTENT], - "DoUninstall": [TxType.CLEAR_ON_MANAGER_START], - "DongleId": [TxType.PERSISTENT], - "GitBranch": [TxType.PERSISTENT], - "GitCommit": [TxType.PERSISTENT], - "GitRemote": [TxType.PERSISTENT], - "HasAcceptedTerms": [TxType.PERSISTENT], - "IsDriverMonitoringEnabled": [TxType.PERSISTENT], - "IsFcwEnabled": [TxType.PERSISTENT], - "IsGeofenceEnabled": [TxType.PERSISTENT], - "IsMetric": [TxType.PERSISTENT], - "IsUpdateAvailable": [TxType.PERSISTENT], - "IsUploadRawEnabled": [TxType.PERSISTENT], - "IsUploadVideoOverCellularEnabled": [TxType.PERSISTENT], - "LimitSetSpeed": [TxType.PERSISTENT], - "LiveParameters": [TxType.PERSISTENT], - "LongitudinalControl": [TxType.PERSISTENT], - "Passive": [TxType.PERSISTENT], - "RecordFront": [TxType.PERSISTENT], - "ShouldDoUpdate": [TxType.CLEAR_ON_MANAGER_START], - "SpeedLimitOffset": [TxType.PERSISTENT], - "SubscriberInfo": [TxType.PERSISTENT], - "TrainingVersion": [TxType.PERSISTENT], - "Version": [TxType.PERSISTENT], -} - - -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 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) +from common.params_pyx import Params, ParamKeyType, UnknownKeyName, put_nonblocking # pylint: disable=no-name-in-module, import-error +assert Params +assert ParamKeyType +assert UnknownKeyName +assert put_nonblocking 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"))) + import sys - # 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 + params = Params() + key = sys.argv[1] + assert params.check_key(key), f"unknown param: {key}" + + if len(sys.argv) == 3: + val = sys.argv[2] + print(f"SET: {key} = {val}") + params.put(key, val) + elif len(sys.argv) == 2: + print(f"GET: {key} = {params.get(key)}") diff --git a/common/params_pyx.pyx b/common/params_pyx.pyx new file mode 100755 index 00000000000000..7b35e815dfd973 --- /dev/null +++ b/common/params_pyx.pyx @@ -0,0 +1,106 @@ +# distutils: language = c++ +# cython: language_level = 3 +from libcpp cimport bool +from libcpp.string cimport string +import threading + +cdef extern from "selfdrive/common/params.h": + cpdef enum ParamKeyType: + PERSISTENT + CLEAR_ON_MANAGER_START + CLEAR_ON_PANDA_DISCONNECT + CLEAR_ON_IGNITION_ON + CLEAR_ON_IGNITION_OFF + ALL + + cdef cppclass c_Params "Params": + c_Params(string) nogil + string get(string, bool) nogil + bool getBool(string) nogil + int remove(string) nogil + int put(string, string) nogil + int putBool(string, bool) nogil + bool checkKey(string) nogil + void clearAll(ParamKeyType) + + +def ensure_bytes(v): + return v.encode() if isinstance(v, str) else v; + +class UnknownKeyName(Exception): + pass + +cdef class Params: + cdef c_Params* p + + def __cinit__(self, d=""): + cdef string path = d.encode() + with nogil: + self.p = new c_Params(path) + + def __dealloc__(self): + del self.p + + def clear_all(self, tx_type=ParamKeyType.ALL): + self.p.clearAll(tx_type) + + def check_key(self, key): + key = ensure_bytes(key) + if not self.p.checkKey(key): + raise UnknownKeyName(key) + return key + + def get(self, key, bool block=False, encoding=None): + cdef string k = self.check_key(key) + cdef string val + with nogil: + val = self.p.get(k, block) + + 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 + + return val if encoding is None else val.decode(encoding) + + def get_bool(self, key): + cdef string k = self.check_key(key) + cdef bool r + with nogil: + r = self.p.getBool(k) + return r + + 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. + """ + cdef string k = self.check_key(key) + cdef string dat_bytes = ensure_bytes(dat) + with nogil: + self.p.put(k, dat_bytes) + + def put_bool(self, key, bool val): + cdef string k = self.check_key(key) + with nogil: + self.p.putBool(k, val) + + def delete(self, key): + cdef string k = self.check_key(key) + with nogil: + self.p.remove(k) + +def put_nonblocking(key, val, d=""): + def f(key, val): + params = Params(d) + cdef string k = ensure_bytes(key) + params.put(k, 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 8bcd06966ff444..762410f09e41e8 100644 --- a/common/realtime.py +++ b/common/realtime.py @@ -1,74 +1,80 @@ """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 +from typing import Optional -# 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 -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 + # CORE 3 + # - boardd = 55 + CTRL_HIGH = 53 - tid = libc.syscall(NR_gettid) - return subprocess.call(['chrt', '-f', '-p', str(level), str(tid)]) +def set_realtime_priority(level: int) -> None: + if not PC: + os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(level)) # type: ignore[attr-defined] -class Ratekeeper(object): - def __init__(self, rate, print_delay_threshold=0.): + +def set_core_affinity(core: int) -> None: + if not PC: + os.sched_setaffinity(0, [core,]) + + +def config_realtime_process(core: int, priority: int) -> None: + gc.disable() + set_realtime_priority(priority) + set_core_affinity(core) + + +class Ratekeeper: + def __init__(self, rate: int, print_delay_threshold: Optional[float] = 0.0) -> None: """Rate in Hz for ratekeeping. print_delay_threshold must be nonnegative.""" self._interval = 1. / rate self._next_frame_time = sec_since_boot() + self._interval self._print_delay_threshold = print_delay_threshold self._frame = 0 - self._remaining = 0 + self._remaining = 0.0 self._process_name = multiprocessing.current_process().name @property - def frame(self): + def frame(self) -> int: return self._frame @property - def remaining(self): + def remaining(self) -> float: return self._remaining # Maintain loop rate by calling this at the end of each loop - def keep_time(self): + def keep_time(self) -> bool: lagged = self.monitor_time() if self._remaining > 0: time.sleep(self._remaining) return lagged # this only monitor the cumulative lag, but does not enforce a rate - def monitor_time(self): + def monitor_time(self) -> bool: lagged = False remaining = self._next_frame_time - sec_since_boot() self._next_frame_time += self._interval diff --git a/common/spinner.py b/common/spinner.py new file mode 100644 index 00000000000000..27b765196fe699 --- /dev/null +++ b/common/spinner.py @@ -0,0 +1,52 @@ +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: str): + 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 update_progress(self, cur: int, total: int): + self.update(str(round(100 * cur / total))) + + 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..ee9b9a2b732fef --- /dev/null +++ b/common/transformations/SConscript @@ -0,0 +1,6 @@ +Import('env', 'envCython') + +transformations = env.Library('transformations', ['orientation.cc', 'coordinates.cc']) +Export('transformations') + +envCython.Program('transformations.so', 'transformations.pyx') diff --git a/common/transformations/camera.py b/common/transformations/camera.py index 2e04c5ac220747..d71f865ca94426 100644 --- a/common/transformations/camera.py +++ b/common/transformations/camera.py @@ -1,30 +1,60 @@ 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 = 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 + +eon_f_frame_size = (1164, 874) +eon_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_intrinsics = np.array([ - [FOCAL, 0., W/2.], - [ 0., FOCAL, H/2.], - [ 0., 0., 1.]]) +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 +eon_dcam_intrinsics = np.array([ + [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]]) -leon_dcam_intrinsics = np.array([ - [650, 0, 816//2], - [ 0, 650, 612//2], - [ 0, 0, 1]]) +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]]) -eon_dcam_intrinsics = np.array([ - [860, 0, 1152//2], - [ 0, 860, 864//2], - [ 0, 0, 1]]) +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 +74,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 +83,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 +97,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 +112,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), dtype=img_pts.dtype))) 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 +162,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..b729ac3d872bd2 --- /dev/null +++ b/common/transformations/coordinates.cc @@ -0,0 +1,102 @@ +#define _USE_MATH_DEFINES + +#include +#include +#include + +#include "coordinates.hpp" + + + +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..f5ba0d3fe7ab83 --- /dev/null +++ b/common/transformations/coordinates.hpp @@ -0,0 +1,41 @@ +#pragma once + +#define DEG2RAD(x) ((x) * M_PI / 180.0) +#define RAD2DEG(x) ((x) * 180.0 / M_PI) + +struct ECEF { + double x, y, z; + Eigen::Vector3d to_vector(){ + return Eigen::Vector3d(x, y, z); + } +}; + +struct NED { + double n, e, d; + Eigen::Vector3d to_vector(){ + return Eigen::Vector3d(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..5d6458fad3c139 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 -BIGMODEL_INPUT_SIZE = (864, 288) +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]]) + + +# 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)) @@ -68,25 +81,39 @@ bigmodel_frame_from_road_frame = np.dot(bigmodel_intrinsics, get_view_frame_from_road_frame(0, 0, 0, model_height)) +bigmodel_frame_from_calib_frame = np.dot(bigmodel_intrinsics, + get_view_frame_from_calib_frame(0, 0, 0, 0)) + +sbigmodel_frame_from_road_frame = np.dot(sbigmodel_intrinsics, + get_view_frame_from_road_frame(0, 0, 0, model_height)) + +sbigmodel_frame_from_calib_frame = np.dot(sbigmodel_intrinsics, + get_view_frame_from_calib_frame(0, 0, 0, 0)) + 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 +124,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 +166,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..7909c0affba553 --- /dev/null +++ b/common/transformations/orientation.cc @@ -0,0 +1,144 @@ +#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 asin_arg_clipped = std::clamp(2 * (quat.w() * quat.y() - quat.z() * quat.x()), -1.0, 1.0); + double theta = asin(asin_arg_clipped); + 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(const Eigen::Matrix3d &rot){ + return ensure_unique(Eigen::Quaterniond(rot)); +} + +Eigen::Matrix3d euler2rot(Eigen::Vector3d euler){ + return quat2rot(euler2quat(euler)); +} + +Eigen::Vector3d rot2euler(const 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}; +} + diff --git a/common/transformations/orientation.hpp b/common/transformations/orientation.hpp new file mode 100644 index 00000000000000..ebd7da0aeed2fc --- /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(const Eigen::Matrix3d &rot); +Eigen::Matrix3d euler2rot(Eigen::Vector3d euler); +Eigen::Vector3d rot2euler(const 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 29357e34bd9136..00000000000000 --- a/common/vin.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python -import time -from common.realtime import sec_since_boot -import selfdrive.messaging as messaging -from selfdrive.boardd.boardd import can_list_to_can_capnp - -def get_vin(logcan, sendcan): - - # works on standard 11-bit addresses for diagnostic. Tested on Toyota and Subaru; - # Honda uses the extended 29-bit addresses, and unfortunately only works from OBDII - query_msg = [[0x7df, 0, '\x02\x09\x02'.ljust(8, "\x00"), 0], - [0x7e0, 0, '\x30'.ljust(8, "\x00"), 0]] - - cnts = [1, 2] # Number of messages to wait for at each iteration - vin_valid = True - - dat = [] - for i in range(len(query_msg)): - cnt = 0 - sendcan.send(can_list_to_can_capnp([query_msg[i]], msgtype='sendcan')) - got_response = False - t_start = sec_since_boot() - while sec_since_boot() - t_start < 0.05 and not got_response: - for a in messaging.drain_sock(logcan): - for can in a.can: - if can.src == 0 and can.address == 0x7e8: - vin_valid = vin_valid and is_vin_response_valid(can.dat, i, cnt) - dat += can.dat[2:] if i == 0 else can.dat[1:] - cnt += 1 - if cnt == cnts[i]: - got_response = True - time.sleep(0.01) - - return "".join(dat[3:]) if vin_valid else "" - -""" -if 'vin' not in gctx: - print "getting vin" - gctx['vin'] = query_vin()[3:] - print "got VIN %s" % (gctx['vin'],) - cloudlog.info("got VIN %s" % (gctx['vin'],)) - -# *** determine platform based on VIN **** -if vin.startswith("19UDE2F36G"): - print "ACURA ILX 2016" - self.civic = False -else: - # TODO: add Honda check explicitly - print "HONDA CIVIC 2016" - self.civic = True - -# *** special case VIN of Acura test platform -if vin == "19UDE2F36GA001322": - print "comma.ai test platform detected" - # it has a gas interceptor and a torque mod - self.torque_mod = True -""" - - -# sanity checks on response messages from vin query -def is_vin_response_valid(can_dat, step, cnt): - - can_dat = [ord(i) for i in can_dat] - - if len(can_dat) != 8: - # ISO-TP meesages are all 8 bytes - return False - - if step == 0: - # VIN does not fit in a single message and it's 20 bytes of data - if can_dat[0] != 0x10 or can_dat[1] != 0x14: - return False - - if step == 1 and cnt == 0: - # first response after a CONTINUE query is sent - if can_dat[0] != 0x21: - return False - - if step == 1 and cnt == 1: - # second response after a CONTINUE query is sent - if can_dat[0] != 0x22: - return False - - return True - - -if __name__ == "__main__": - import zmq - from selfdrive.services import service_list - context = zmq.Context() - logcan = messaging.sub_sock(context, service_list['can'].port) - sendcan = messaging.pub_sock(context, service_list['sendcan'].port) - time.sleep(1.) # give time to sendcan socket to start - - print get_vin(logcan, sendcan) 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/docs/CARS.md b/docs/CARS.md new file mode 100644 index 00000000000000..9c762ee7bf5446 --- /dev/null +++ b/docs/CARS.md @@ -0,0 +1,184 @@ +# Supported Cars + +## comma.ai supported 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 2019-21 | All | Stock | 0mph | 3mph | +| Honda | Accord 2018-21 | All | Stock | 0mph | 3mph | +| Honda | Accord Hybrid 2018-21 | All | Stock | 0mph | 3mph | +| Honda | Civic Hatchback 2017-21 | Honda Sensing | Stock | 0mph | 12mph | +| Honda | Civic Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | +| Honda | Civic Coupe 2019-20 | All | Stock | 0mph | 2mph2 | +| Honda | Civic Sedan 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | +| Honda | Civic Sedan 2019-20 | All | Stock | 0mph | 2mph2 | +| Honda | CR-V 2015-16 | Touring | openpilot | 25mph1 | 12mph | +| Honda | CR-V 2017-21 | Honda Sensing | Stock | 0mph | 12mph | +| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph | +| Honda | e 2020 | All | Stock | 0mph | 3mph | +| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | Freed 2020 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | HR-V 2019-20 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | Insight 2019-21 | All | Stock | 0mph | 3mph | +| Honda | Inspire 2018 | All | Stock | 0mph | 3mph | +| Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph1 | 0mph | +| Honda | Passport 2019-21 | All | openpilot | 25mph1 | 12mph | +| Honda | Pilot 2016-21 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | Ridgeline 2017-21 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Hyundai | Palisade 2020-21 | All | Stock | 0mph | 0mph | +| Hyundai | Sonata 2020-22 | All | Stock | 0mph | 0mph | +| Lexus | CT Hybrid 2017-18 | LSS | Stock3| 0mph | 0mph | +| Lexus | ES 2019-21 | All | openpilot | 0mph | 0mph | +| Lexus | ES Hybrid 2017-18 | LSS | Stock3| 0mph | 0mph | +| Lexus | ES Hybrid 2019-21 | All | openpilot | 0mph | 0mph | +| Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph | +| Lexus | NX 2018-2019 | All | Stock3| 0mph | 0mph | +| Lexus | NX 2020 | All | openpilot | 0mph | 0mph | +| Lexus | NX Hybrid 2018-19 | All | Stock3| 0mph | 0mph | +| Lexus | RC 2020 | All | Stock | 22mph | 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-21 | All | openpilot | 0mph | 0mph | +| Lexus | UX Hybrid 2019-21 | All | openpilot | 0mph | 0mph | +| Toyota | Alphard 2020 | All | openpilot | 0mph | 0mph | +| Toyota | Avalon 2016-21 | TSS-P | Stock3| 20mph1 | 0mph | +| Toyota | Avalon Hybrid 2019-21 | TSS-P | Stock3| 20mph1 | 0mph | +| Toyota | Camry 2018-20 | All | Stock | 0mph4 | 0mph | +| Toyota | Camry 2021-22 | All | openpilot | 0mph4 | 0mph | +| Toyota | Camry Hybrid 2018-20 | All | Stock | 0mph4 | 0mph | +| Toyota | Camry Hybrid 2021-22 | All | openpilot | 0mph | 0mph | +| Toyota | C-HR 2017-21 | 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-22 | All | openpilot | 0mph | 0mph | +| Toyota | Corolla Hatchback 2019-22 | All | openpilot | 0mph | 0mph | +| Toyota | Corolla Hybrid 2020-22 | All | openpilot | 0mph | 0mph | +| Toyota | Highlander 2017-19 | All | Stock3| 0mph | 0mph | +| Toyota | Highlander 2020-22 | All | openpilot | 0mph | 0mph | +| Toyota | Highlander Hybrid 2017-19 | All | Stock3| 0mph | 0mph | +| Toyota | Highlander Hybrid 2020-22 | All | openpilot | 0mph | 0mph | +| Toyota | Mirai 2021 | 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 | Prius Prime 2021-22 | All | openpilot | 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 | +| ----------| ------------------------------| ------------------| -----------------| -------------------| -------------| +| Audi | A3 2014-19 | ACC + Lane Assist | Stock | 0mph | 0mph | +| Audi | A3 Sportback e-tron 2017-18 | ACC + Lane Assist | Stock | 0mph | 0mph | +| Audi | Q2 2018 | ACC + Lane Assist | Stock | 0mph | 0mph | +| Audi | Q3 2020-21 | ACC + Lane Assist | Stock | 0mph | 0mph | +| Audi | S3 2015 | ACC + Lane Assist | Stock | 0mph | 0mph | +| Buick | Regal 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Cadillac | ATS 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | +| Cadillac | Escalade ESV 20161 | ACC + LKAS | 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-21 | Adaptive Cruise | Stock | 0mph | 39mph | +| Genesis | G70 2018 | All | Stock | 0mph | 0mph | +| Genesis | G70 2020 | 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 | Elantra 2021 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Elantra Hybrid 2021 | SCC + LKAS | Stock | 0mph | 0mph | +| 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 | Ioniq Hybrid 2017-19 | SCC + LKAS | Stock | 0mph | 32mph | +| Hyundai | Ioniq Hybrid 2020-22 | SCC + LFA | Stock | 0mph | 0mph | +| Hyundai | Ioniq PHEV 2020-21 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Kona 2020 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Kona EV 2018-19 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Kona Hybrid 2020 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Santa Fe 2019-20 | All | Stock | 0mph | 0mph | +| Hyundai | Santa Fe 2021-22 | All | Stock | 0mph | 0mph | +| Hyundai | Santa Fe Hybrid 2022 | All | Stock | 0mph | 0mph | +| Hyundai | Sonata 2018-2019 | SCC + LKAS | Stock | 0mph | 0mph | +| Hyundai | Sonata Hybrid 2021-22 | All | Stock | 0mph | 0mph | +| Hyundai | Veloster 2019-20 | 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 | Ceed 2019 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Forte 2018-21 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | K5 2021-22 | SCC + LFA | Stock | 0mph | 0mph | +| Kia | Niro EV 2019-21 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Niro Hybrid 2021 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Niro PHEV 2019 | SCC + LKAS | Stock | 10mph | 32mph | +| Kia | Optima 2017 | SCC + LKAS | Stock | 0mph | 32mph | +| Kia | Optima 2019 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Seltos 2021 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Sorento 2018-19 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Stinger 2018 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Telluride 2020 | SCC + LKAS | Stock | 0mph | 0mph | +| Mazda | CX-9 2021 | All | Stock | 0mph | 28mph | +| Nissan | Altima 2019-20 | ProPILOT | Stock | 0mph | 0mph | +| Nissan | Leaf 2018-22 | ProPILOT | Stock | 0mph | 0mph | +| Nissan | Rogue 2018-20 | ProPILOT | Stock | 0mph | 0mph | +| Nissan | X-Trail 2017 | ProPILOT | Stock | 0mph | 0mph | +| SEAT | Ateca 2018 | Driver Assistance | Stock | 0mph | 0mph | +| SEAT | Leon 2014-2020 | Driver Assistance | Stock | 0mph | 0mph | +| Å koda | Kamiq 20212 | Driver Assistance | Stock | 0mph | 0mph | +| Å koda | Karoq 2019 | Driver Assistance | Stock | 0mph | 0mph | +| Å koda | Kodiaq 2018-19 | Driver Assistance | Stock | 0mph | 0mph | +| Å koda | Octavia 2015, 2018-19 | Driver Assistance | Stock | 0mph | 0mph | +| Å koda | Octavia RS 2016 | Driver Assistance | Stock | 0mph | 0mph | +| Å koda | Scala 2020 | Driver Assistance | Stock | 0mph | 0mph | +| Å koda | Superb 2015-18 | Driver Assistance | Stock | 0mph | 0mph | +| Subaru | Ascent 2019 | EyeSight | Stock | 0mph | 0mph | +| Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph | +| Subaru | Forester 2019-21 | EyeSight | Stock | 0mph | 0mph | +| Subaru | Impreza 2017-19 | EyeSight | Stock | 0mph | 0mph | +| Volkswagen| Arteon 20214 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Atlas 2018-19 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| California 20214 | Driver Assistance | Stock | 0mph | 32mph | +| Volkswagen| e-Golf 2014, 2019-20 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Golf 2015-20 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Golf Alltrack 2017-18 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Golf GTE 2016 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Golf GTI 2018-20 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Golf R 2016-19 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Golf SportsVan 2016 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Golf SportWagen 2015 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Jetta 2018-20 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Jetta GLI 2021 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Passat 2016-183 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Polo 2020 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| T-Cross 20214 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| T-Roc 20214 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Taos 20224 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Tiguan 2020 | Driver Assistance | Stock | 0mph | 0mph | +| Volkswagen| Touran 2017 | 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).***
    +2Not including the China market Kamiq, which is based on the (currently) unsupported PQ34 platform.
    +3Not including the USA/China market Passat, which is based on the (currently) unsupported PQ35/NMS platform.
    +4Model-years 2021 and beyond may have a new camera harness design, which isn't yet available from the comma store. Before ordering, +remove the Lane Assist camera cover and check to see if the connector is black (older design) or light brown (newer design). For the newer design, +in the interim, choose "VW J533 Development" from the vehicle drop-down for a harness that integrates at the CAN gateway inside the dashboard.
    +Community Maintained Cars and Features are not verified by comma to meet our [safety model](SAFETY.md). Be extra cautious using them. + +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 + +Although they're not upstream, the community has openpilot running on other makes and models. See the 'Community Supported Models' section of each make [on our wiki](https://wiki.comma.ai/). diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 00000000000000..b9da6c576c2639 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,41 @@ +# How to contribute + +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. Check out our [post about externalization](https://blog.comma.ai/a-2020-theme-externalization/). + +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 at https://docs.comma.ai and on our [blog](https://blog.comma.ai/). + +### Getting Started + + * Setup your [development environment](../tools/) + * Join our [Discord](https://discord.comma.ai) + * Make sure you have a [GitHub account](https://github.com/signup/free) + * Fork [our repositories](https://github.com/commaai) on GitHub + +## Pull Requests + +Pull requests should be against the master branch. Welcomed contributions include bug reports, car ports, and any [open issue](https://github.com/commaai/openpilot/issues). If you're unsure about a contribution, feel free to open a discussion, issue, or draft PR to discuss the problem you're trying to solve. + +A good pull request has all of the following: +* a clearly stated purpose +* every line changed directly contributes to the stated purpose +* verification, i.e. how did you test your PR? +* justification + * if you've optimized something, post benchmarks to prove it's better + * if you've improved your car's tuning, post before and after plots +* passes the CI tests + +### Car Ports + +We've released a [Model Port guide](https://blog.comma.ai/openpilot-port-guide-for-toyota-models/) for porting to Toyota/Lexus models. + +If you port openpilot to a substantially new car brand, see this more generic [Brand Port guide](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/). + +## Testing + +### Automated Testing + +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 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`. diff --git a/docs/INTEGRATION.md b/docs/INTEGRATION.md new file mode 100644 index 00000000000000..97b72e39d3cdc0 --- /dev/null +++ b/docs/INTEGRATION.md @@ -0,0 +1,11 @@ +# Integration with Stock Features + +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](CARS.md)): +* Stock ACC is replaced by openpilot ACC. +* openpilot FCW operates in addition to stock FCW. + +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. diff --git a/docs/LIMITATIONS.md b/docs/LIMITATIONS.md new file mode 100644 index 00000000000000..8c112659c24a2b --- /dev/null +++ b/docs/LIMITATIONS.md @@ -0,0 +1,58 @@ +# Limitations +## Limitations of openpilot ALC and LDW + +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. diff --git a/installer/updater/Makefile b/installer/updater/Makefile deleted file mode 100644 index d9444e6c592a70..00000000000000 --- a/installer/updater/Makefile +++ /dev/null @@ -1,88 +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 -g -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) - -CURL_FLAGS = -I$(PHONELIBS)/curl/include -CURL_LIBS = $(PHONELIBS)/curl/lib/libcurl.a \ - $(PHONELIBS)/zlib/lib/libz.a - -BORINGSSL_FLAGS = -I$(PHONELIBS)/boringssl/include -BORINGSSL_LIBS = $(PHONELIBS)/boringssl/lib/libssl_static.a \ - $(PHONELIBS)/boringssl/lib/libcrypto_static.a \ - -NANOVG_FLAGS = -I$(PHONELIBS)/nanovg - -JSON11_FLAGS = -I$(PHONELIBS)/json11 - -OPENGL_LIBS = -lGLESv3 - -FRAMEBUFFER_LIBS = -lutils -lgui -lEGL - -.PHONY: all -all: updater - -OBJS = courbd.ttf.o \ - ../../selfdrive/common/touch.o \ - ../../selfdrive/common/framebuffer.o \ - $(PHONELIBS)/json11/json11.o \ - $(PHONELIBS)/nanovg/nanovg.o - -DEPS := $(OBJS:.o=.d) - -updater: updater.o $(OBJS) - @echo "[ LINK ] $@" - $(CXX) $(CPPFLAGS) -fPIC -o 'updater' $^ \ - $(FRAMEBUFFER_LIBS) \ - $(CURL_LIBS) \ - $(BORINGSSL_LIBS) \ - -L/system/vendor/lib64 \ - $(OPENGL_LIBS) \ - -lcutils -lm -llog - strip updater - -courbd.ttf.o: ../../selfdrive/assets/courbd.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) \ - $(JSON11_FLAGS) \ - $(CURL_FLAGS) \ - $(BORINGSSL_FLAGS) \ - -c -o '$@' '$<' - - -.PHONY: clean -clean: - rm -f $(OBJS) $(DEPS) - --include $(DEPS) diff --git a/installer/updater/update.json b/installer/updater/update.json deleted file mode 100644 index 827a44b10db74d..00000000000000 --- a/installer/updater/update.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ota_url": "https://commadist.azureedge.net/neosupdate/ota-signed-c992abb59cbaf6588f51055db52db619061107851773fc8480acb8bb5d77a28f.zip", - "ota_hash": "c992abb59cbaf6588f51055db52db619061107851773fc8480acb8bb5d77a28f", - "recovery_url": "https://commadist.azureedge.net/neosupdate/recovery-af099a84cfd7b91266090779238ac358278948dcde2dcfa0fbca6e8397366f0a.img", - "recovery_len": 15136044, - "recovery_hash": "af099a84cfd7b91266090779238ac358278948dcde2dcfa0fbca6e8397366f0a" -} diff --git a/installer/updater/updater b/installer/updater/updater index 857a78e6f52703..8bf40708a64510 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 deleted file mode 100644 index 58fab324139f46..00000000000000 --- a/installer/updater/updater.cc +++ /dev/null @@ -1,675 +0,0 @@ -#include -#include -#include -#include - -#include -#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 "json11.hpp" - -#include "common/framebuffer.h" -#include "common/touch.h" -#include "common/utilpp.h" - -#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 RECOVERY_DEV "/dev/block/bootdevice/by-name/recovery" -#define RECOVERY_COMMAND "/cache/recovery/command" - -#define UPDATE_DIR "/data/neoupdate" - -extern const uint8_t bin_courbd[] asm("_binary_courbd_ttf_start"); -extern const uint8_t bin_courbd_end[] asm("_binary_courbd_ttf_end"); - -namespace { - -std::string sha256_file(std::string fn, size_t limit=0) { - SHA256_CTX ctx; - SHA256_Init(&ctx); - - FILE *file = fopen(fn.c_str(), "rb"); - if (!file) return ""; - - const size_t buf_size = 8192; - std::unique_ptr buffer( new char[ buf_size ] ); - - bool read_limit = (limit != 0); - while (true) { - size_t read_size = buf_size; - if (read_limit) read_size = std::min(read_size, limit); - size_t bytes_read = fread(buffer.get(), 1, read_size, file); - if (!bytes_read) break; - - SHA256_Update(&ctx, buffer.get(), bytes_read); - - if (read_limit) { - limit -= bytes_read; - if (limit == 0) break; - } - } - - uint8_t hash[SHA256_DIGEST_LENGTH]; - SHA256_Final(hash, &ctx); - - fclose(file); - - return util::tohex(hash, sizeof(hash)); -} - -size_t download_string_write(void *ptr, size_t size, size_t nmeb, void *up) { - size_t sz = size * nmeb; - ((std::string*)up)->append((char*)ptr, sz); - return sz; -} - -std::string download_string(CURL *curl, std::string url) { - std::string os; - - 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_USERAGENT, USER_AGENT); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 0); - - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); - - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, download_string_write); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &os); - CURLcode res = curl_easy_perform(curl); - if (res != CURLE_OK) { - return ""; - } - - return os; -} - -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() { - std::string bat_cap_s = util::read_file("/sys/class/power_supply/battery/capacity"); - int bat_cap = atoi(bat_cap_s.c_str()); - 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 bat_cap > 35 || (current_now < 0 && bat_cap > 10); -} - -bool check_space() { - struct statvfs stat; - if (statvfs("/data/", &stat) != 0) { - return false; - } - size_t space = stat.f_bsize * stat.f_bavail; - return space > 2000000000ULL; // 2GB -} - -static void start_settings_activity(const char* name) { - char launch_cmd[1024]; - snprintf(launch_cmd, sizeof(launch_cmd), - "am start -W --ez :settings:show_fragment_as_subsetting true -n 'com.android.settings/.%s'", name); - system(launch_cmd); -} - -struct Updater { - bool do_exit = false; - - TouchState touch; - - int fb_w, fb_h; - EGLDisplay display; - EGLSurface surface; - - FramebufferState *fb = NULL; - NVGcontext *vg = NULL; - int font; - - std::thread update_thread_handle; - - std::mutex lock; - - // i hate state machines give me coroutines already - enum UpdateState { - CONFIRMATION, - RUNNING, - ERROR, - }; - UpdateState state; - - std::string progress_text; - float progress_frac; - - std::string error_text; - - // button - int b_x, b_w, b_y, b_h; - int balt_x; - - CURL *curl = NULL; - - Updater() { - touch_init(&touch); - - fb = framebuffer_init("updater", 0x00001000, false, - &display, &surface, &fb_w, &fb_h); - assert(fb); - - vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG); - assert(vg); - font = nvgCreateFontMem(vg, "courbd", (unsigned char*)bin_courbd, (bin_courbd_end - bin_courbd), 0); - assert(font >= 0); - - b_w = 600; - balt_x = 200; - b_x = fb_w-b_w-200; - b_y = 700; - b_h = 250; - - state = CONFIRMATION; - - } - - int download_file_xferinfo(curl_off_t dltotal, curl_off_t dlno, - curl_off_t ultotal, curl_off_t ulnow) { - { - std::lock_guard guard(lock); - if (dltotal != 0) { - progress_frac = (float) dlno / dltotal; - } - } - // printf("info: %ld %ld %f\n", dltotal, dlno, progress_frac); - return 0; - } - - bool download_file(std::string url, std::string out_fn) { - FILE *of = fopen(out_fn.c_str(), "ab"); - assert(of); - - CURLcode res; - long last_resume_from = 0; - - fseek(of, 0, SEEK_END); - - int tries = 4; - - bool ret = false; - - while (true) { - long resume_from = ftell(of); - - 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_USERAGENT, USER_AGENT); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(curl, CURLOPT_RESUME_FROM, resume_from); - - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, download_file_write); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, of); - - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - - curl_easy_setopt(curl, CURLOPT_XFERINFODATA, this); - curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, &Updater::download_file_xferinfo); - - CURLcode res = curl_easy_perform(curl); - - long response_code = 0; - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); - - // double content_length = 0.0; - // curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &content_length); - - printf("download %s res %d, code %ld, resume from %ld\n", url.c_str(), res, response_code, resume_from); - if (res == CURLE_OK) { - ret = true; - break; - } else if (res == CURLE_HTTP_RETURNED_ERROR && response_code == 416) { - // failed because the file is already complete? - ret = true; - break; - } else if (resume_from == last_resume_from) { - // failed and dind't make make forward progress. only retry a couple times - tries--; - if (tries <= 0) { - break; - } - } - last_resume_from = resume_from; - } - // printf("res %d\n", res); - - // printf("- %ld %f\n", response_code, content_length); - - fclose(of); - - return ret; - } - - void set_progress(std::string text) { - std::lock_guard guard(lock); - progress_text = text; - } - - void set_error(std::string text) { - std::lock_guard guard(lock); - error_text = text; - state = ERROR; - } - - std::string stage_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 ""; - } - - 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() { - curl = curl_easy_init(); - assert(curl); - - if (!check_battery()) { - set_error("Please plug power in to your EON and wait for charge"); - return; - } - - if (!check_space()) { - set_error("2GB of free space required to update"); - return; - } - - 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); - } - - 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; - } - - 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(); - - // 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; - } - - // std::string installer_fn = stage_download(installer_url, installer_hash, "installer"); - // if (installer_fn.empty()) { - // //error'd - // return; - // } - - std::string recovery_fn; - if (recovery_url.empty() || recovery_hash.empty() || recovery_len == 0) { - set_progress("skipping recovery flash..."); - } else { - // only download the recovery if it differs from what's flashed - set_progress("checking recovery..."); - std::string existing_recovery_hash = sha256_file(RECOVERY_DEV, recovery_len); - 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"); - if (recovery_fn.empty()) { - // error'd - return; - } - } - } - - std::string ota_fn = stage_download(ota_url, ota_hash, "update"); - if (ota_fn.empty()) { - //error'd - return; - } - - if (!check_battery()) { - set_error("must have at least 35% battery to update"); - return; - } - - if (!recovery_fn.empty()) { - // flash recovery - set_progress("flashing recovery..."); - - FILE *flash_file = fopen(recovery_fn.c_str(), "rb"); - if (!flash_file) { - set_error("failed to flash recovery"); - return; - } - - FILE *recovery_dev = fopen(RECOVERY_DEV, "w+b"); - if (!recovery_dev) { - fclose(flash_file); - set_error("failed to flash recovery"); - return; - } - - const size_t buf_size = 4096; - std::unique_ptr buffer( new char[ buf_size ] ); - - while (true) { - size_t bytes_read = fread(buffer.get(), 1, buf_size, flash_file); - if (!bytes_read) break; - - size_t bytes_written = fwrite(buffer.get(), 1, bytes_read, recovery_dev); - if (bytes_read != bytes_written) { - fclose(recovery_dev); - fclose(flash_file); - set_error("failed to flash recovery: write failed"); - return; - } - } - - fclose(recovery_dev); - fclose(flash_file); - - set_progress("verifying flash..."); - std::string new_recovery_hash = sha256_file(RECOVERY_DEV, recovery_len); - printf("new recovery hash: %s\n", new_recovery_hash.c_str()); - - if (new_recovery_hash != recovery_hash) { - set_error("recovery flash corrupted"); - return; - } - - } - - // write arguments to recovery - FILE *cmd_file = fopen(RECOVERY_COMMAND, "wb"); - if (!cmd_file) { - set_error("failed to reboot into recovery"); - return; - } - fprintf(cmd_file, "--update_package=%s\n", ota_fn.c_str()); - fclose(cmd_file); - - set_progress("rebooting"); - - // remove the continue.sh so we come back into the setup. - // maybe we should go directly into the installer, but what if we don't come back with internet? :/ - //unlink("/data/data/com.termux/files/continue.sh"); - - // TODO: this should be generic between android versions - // IPowerManager.reboot(confirm=false, reason="recovery", wait=true) - system("service call power 16 i32 0 s16 recovery i32 1"); - while(1) pause(); - - // execl("/system/bin/reboot", "recovery"); - // set_error("failed to reboot into recovery"); - } - - void draw_ack_screen(const char *message, const char *button, const char *altbutton) { - nvgFontSize(vg, 96.0f); - nvgFillColor(vg, nvgRGBA(255,255,255,255)); - nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); - nvgTextBox(vg, 50, 100, fb_w-100, message, NULL); - - // draw button - if (button) { - nvgBeginPath(vg); - nvgFillColor(vg, nvgRGBA(0, 0, 0, 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, button, NULL); - - nvgBeginPath(vg); - nvgStrokeColor(vg, nvgRGBA(255, 255, 255, 255)); - nvgStrokeWidth(vg, 5); - nvgRoundedRect(vg, b_x, b_y, b_w, b_h, 20); - nvgStroke(vg); - } - - // draw button - if (altbutton) { - nvgBeginPath(vg); - nvgFillColor(vg, nvgRGBA(0, 0, 0, 255)); - nvgRoundedRect(vg, balt_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, balt_x+b_w/2, b_y+b_h/2, altbutton, NULL); - - nvgBeginPath(vg); - nvgStrokeColor(vg, nvgRGBA(255, 255, 255, 255)); - nvgStrokeWidth(vg, 5); - nvgRoundedRect(vg, balt_x, b_y, b_w, b_h, 20); - nvgStroke(vg); - } - } - - void draw_progress_screen() { - // draw progress message - nvgFontSize(vg, 64.0f); - nvgFillColor(vg, nvgRGBA(255,255,255,255)); - nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE); - nvgTextBox(vg, 0, 700, fb_w, progress_text.c_str(), NULL); - - // draw progress bar - { - int progress_width = 800; - int progress_x = fb_w/2-progress_width/2; - int progress_y = 768; - int progress_height = 15; - - int powerprompt_y = 512; - nvgText(vg, fb_w/2, powerprompt_y, "Ensure EON is connected to power", NULL); - - NVGpaint paint = nvgBoxGradient( - vg, progress_x + 1, progress_y + 1, - progress_width - 2, progress_height, 3, 4, nvgRGB(0, 32, 0), nvgRGB(0, 92, 0)); - nvgBeginPath(vg); - nvgRoundedRect(vg, progress_x, progress_y, progress_width, progress_height, 3); - nvgFillPaint(vg, paint); - nvgFill(vg); - - float value = std::min(std::max(0.0f, progress_frac), 1.0f); - int bar_pos = ((progress_width - 2) * value); - - paint = nvgBoxGradient( - vg, progress_x, progress_y, - bar_pos+1.5f, progress_height-1, 3, 4, - nvgRGB(220, 100, 0), nvgRGB(128, 100, 0)); - - nvgBeginPath(vg); - nvgRoundedRect( - vg, progress_x+1, progress_y+1, - bar_pos, progress_height-2, 3); - nvgFillPaint(vg, paint); - nvgFill(vg); - } - } - - void ui_draw() { - std::lock_guard guard(lock); - - nvgBeginFrame(vg, fb_w, fb_h, 1.0f); - - switch (state) { - case CONFIRMATION: - draw_ack_screen("An upgrade to NEOS is required.\n\n" - "Your device will now be reset and upgraded. You may want to connect to wifi as download is around 1 GB\nData on device shouldn't be lost.", - "continue", - "wifi"); - break; - case RUNNING: - draw_progress_screen(); - break; - case ERROR: - draw_ack_screen(("ERROR: " + error_text + "\n\nYou will need to retry").c_str(), NULL, "exit"); - break; - } - - nvgEndFrame(vg); - } - - void ui_update() { - std::lock_guard guard(lock); - - switch (state) { - case ERROR: - case CONFIRMATION: { - int touch_x = -1, touch_y = -1; - int res = touch_poll(&touch, &touch_x, &touch_y, 0); - if (res == 1 && !is_settings_active()) { - if (touch_x >= b_x && touch_x < b_x+b_w && touch_y >= b_y && touch_y < b_y+b_h) { - if (state == CONFIRMATION) { - state = RUNNING; - update_thread_handle = std::thread(&Updater::run_stages, this); - } - } - if (touch_x >= balt_x && touch_x < balt_x+b_w && touch_y >= b_y && touch_y < b_y+b_h) { - if (state == CONFIRMATION) { - start_settings_activity("Settings$WifiSettingsActivity"); - } else if (state == ERROR) { - do_exit = 1; - } - } - } - } - default: - break; - } - } - - - void go() { - while (!do_exit) { - ui_update(); - - glClearColor(0.19, 0.09, 0.2, 1.0); - glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - ui_draw(); - - glDisable(GL_BLEND); - - eglSwapBuffers(display, surface); - assert(glGetError() == GL_NO_ERROR); - - // no simple way to do 30fps vsync with surfaceflinger... - usleep(30000); - } - - if (update_thread_handle.joinable()) { - update_thread_handle.join(); - } - - 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[]) { - if (argc > 1) { - if (strcmp(argv[1], "local") == 0) { - manifest_url = MANIFEST_URL_EON_LOCAL; - } else if (strcmp(argv[1], "staging") == 0) { - manifest_url = MANIFEST_URL_EON_STAGING; - } else { - manifest_url = argv[1]; - } - } - printf("updating from %s\n", manifest_url); - Updater updater; - updater.go(); - - return 0; -} diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index 287c72a78e7f14..7ef671c2652e2e 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -1,44 +1,192 @@ #!/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 -function launch { - # apply update - 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 +source "$BASEDIR/launch_env.sh" + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +function two_init { + + # set IO scheduler + setprop sys.io.scheduler noop + for f in /sys/block/*/queue/scheduler; do + echo noop > $f + done + + # *** shield cores 2-3 *** + + # TODO: should we enable this? + # offline cores 2-3 to force recurring timers onto the other cores + #echo 0 > /sys/devices/system/cpu/cpu2/online + #echo 0 > /sys/devices/system/cpu/cpu3/online + #echo 1 > /sys/devices/system/cpu/cpu2/online + #echo 1 > /sys/devices/system/cpu/cpu3/online + + # 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 + + # 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 - exec "${BASH_SOURCE[0]}" + # wifi scan + wpa_cli IFNAME=wlan0 SCAN + + # Check for NEOS update + if [ $(< /VERSION) != "$REQUIRED_NEOS_VERSION" ]; then + echo "Installing NEOS update" + NEOS_PY="$DIR/selfdrive/hardware/eon/neos.py" + MANIFEST="$DIR/selfdrive/hardware/eon/neos.json" + $NEOS_PY --swap-if-ready $MANIFEST + $DIR/selfdrive/hardware/eon/updater $NEOS_PY $MANIFEST + fi +} + +function tici_init { + # wait longer for weston to come up + if [ -f "$BASEDIR/prebuilt" ]; then + sleep 3 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 + # setup governors + 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' + + # TODO: move this to agnos + # network manager config + nmcli connection modify --temporary lte gsm.auto-config yes + nmcli connection modify --temporary lte gsm.home-only yes + sudo rm -f /data/etc/NetworkManager/system-connections/*.nmmeta + + # set success flag for current boot slot + sudo abctl --set_success + + # Check if AGNOS update is required + if [ $(< /VERSION) != "$AGNOS_VERSION" ]; then + AGNOS_PY="$DIR/selfdrive/hardware/tici/agnos.py" + MANIFEST="$DIR/selfdrive/hardware/tici/agnos.json" + if $AGNOS_PY --verify $MANIFEST; then + sudo reboot + fi + $DIR/selfdrive/hardware/tici/updater $AGNOS_PY $MANIFEST + fi +} + +function launch { + # Remove orphaned git lock if it exists on boot + [ -f "$DIR/.git/index.lock" ] && rm -f $DIR/.git/index.lock + + # Pull time from panda + $DIR/selfdrive/boardd/set_time.py + + # 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 [ -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 + + echo "Restarting launch script ${LAUNCHER_LOCATION}" + unset REQUIRED_NEOS_VERSION + unset AGNOS_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 # handle pythonpath - ln -s /data/openpilot /data/pythonpath - export PYTHONPATH="$PWD" + ln -sfn $(pwd) /data/pythonpath + export PYTHONPATH="$PWD:$PWD/pyextra" + + # hardware specific init + if [ -f /EON ]; then + two_init + elif [ -f /TICI ]; then + tici_init + fi + + # write tmux scrollback to a file + tmux capture-pane -pq -S-1000 > /tmp/launch_log # start manager - cd selfdrive - ./manager.py + cd selfdrive/manager + ./build.py && ./manager.py # if broken, keep on screen error while true; do sleep 1; done diff --git a/launch_env.sh b/launch_env.sh new file mode 100755 index 00000000000000..cb0a0572d06089 --- /dev/null +++ b/launch_env.sh @@ -0,0 +1,21 @@ +#!/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="18" +fi + +if [ -z "$AGNOS_VERSION" ]; then + export AGNOS_VERSION="3" +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..be61a6c30e2ed9 Binary files /dev/null and b/models/dmonitoring_model_q.dlc differ diff --git a/models/driving_model.dlc b/models/driving_model.dlc deleted file mode 100644 index 3cceccf1160b1a..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 b860a1185af126..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..02d0a56f8162c8 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 e2e853ea159ad4..065fe7d5a32bb5 100644 --- a/opendbc/acura_ilx_2016_can_generated.dbc +++ b/opendbc/acura_ilx_2016_can_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,11 +228,30 @@ 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_ "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_ "acura_ilx_2016_can.dbc starts here"; @@ -260,15 +275,16 @@ BO_ 316 GAS_PEDAL: 8 PCM 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_ 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_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 @@ -307,4 +323,3 @@ 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/acura_rdx_2018_can_generated.dbc b/opendbc/acura_rdx_2018_can_generated.dbc index e40672eac41447..2acbe3fd7a762d 100644 --- a/opendbc/acura_rdx_2018_can_generated.dbc +++ b/opendbc/acura_rdx_2018_can_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,17 +228,36 @@ 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_ "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_ "acura_rdx_2018_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_ 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 @@ -253,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 @@ -295,4 +310,3 @@ 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/acura_rdx_2020_can_generated.dbc b/opendbc/acura_rdx_2020_can_generated.dbc new file mode 100644 index 00000000000000..3fadba45570815 --- /dev/null +++ b/opendbc/acura_rdx_2020_can_generated.dbc @@ -0,0 +1,434 @@ +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_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" 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 + SG_ IMPERIAL_UNIT : 63|1@0+ (1,0) [0|1] "" 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" ; + 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..30940473441db5 --- /dev/null +++ b/opendbc/can/SConscript @@ -0,0 +1,25 @@ +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()] +parser = lenv.Program('parser_pyx.so', 'parser_pyx.pyx') +packer = lenv.Program('packer_pyx.so', 'packer_pyx.pyx') + +lenv.Depends(parser, libdbc) +lenv.Depends(packer, libdbc) diff --git a/panda/tests/__init__.py b/opendbc/can/__init__.py similarity index 100% rename from panda/tests/__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..2a089980c9ddd6 --- /dev/null +++ b/opendbc/can/common.cc @@ -0,0 +1,221 @@ +#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; + bool extended = address > 0x7FF; // extended can + while (address) { s += (address & 0xF); address >>= 4; } + while (d) { s += (d & 0xF); d >>= 4; } + s = 8-s; + if (extended) s += 3; + 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: // LH_EPS_03 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[]){0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16}[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 0x12E: // ACC_07 Automatic Cruise Control + crc ^= (uint8_t[]){0xF8,0xE5,0x97,0xC9,0xD6,0x07,0x47,0x21,0x66,0xDD,0xCF,0x6F,0xA1,0x94,0x74,0x63}[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 0x324: // ACC_04 Automatic Cruise Control + crc ^= (uint8_t[]){0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27}[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..95833402e214fc --- /dev/null +++ b/opendbc/can/common.h @@ -0,0 +1,85 @@ +#pragma once + +#include +#include +#include + +#include "common_dbc.h" +#include +#include + +#ifndef DYNAMIC_CAPNP +#include "cereal/gen/cpp/log.capnp.h" +#endif + +#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 ignore_checksum = false; + bool ignore_counter = false; + + 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; + kj::Array aligned_buf; + + 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); + CANParser(int abus, const std::string& dbc_name, bool ignore_checksum, bool ignore_counter); + #ifndef DYNAMIC_CAPNP + void update_string(const std::string &data, bool sendcan); + void UpdateCans(uint64_t sec, const capnp::List::Reader& cans); + #endif + void UpdateCans(uint64_t sec, const capnp::DynamicStruct::Reader& cans); + void UpdateValid(uint64_t sec); + 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 &values, int counter); + Msg* lookup_message(uint32_t address); +}; diff --git a/opendbc/can/common.pxd b/opendbc/can/common.pxd new file mode 100644 index 00000000000000..273529bf58b219 --- /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: + string 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..f40b4ac427ba12 --- /dev/null +++ b/opendbc/can/common_dbc.h @@ -0,0 +1,86 @@ +#pragma once + +#include +#include +#include +#include + +#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) + +struct SignalPackValue { + std::string 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; +}; + +std::vector& get_dbcs(); +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 89% rename from selfdrive/can/dbc.cc rename to opendbc/can/dbc.cc index 95d5e4d791394a..5747c7c6bc0b52 100644 --- a/selfdrive/can/dbc.cc +++ b/opendbc/can/dbc.cc @@ -1,17 +1,12 @@ -#include #include -#include "common.h" - -namespace { +#include "common_dbc.h" std::vector& get_dbcs() { static std::vector vec; return vec; } -} - const DBC* dbc_lookup(const std::string& dbc_name) { for (const auto& dbci : get_dbcs()) { if (dbc_name == dbci->name) { diff --git a/opendbc/can/dbc.py b/opendbc/can/dbc.py new file mode 100755 index 00000000000000..043a674a309105 --- /dev/null +++ b/opendbc/can/dbc.py @@ -0,0 +1,257 @@ +#!/usr/bin/env python3 +import re +import os +import struct +import sys +import numbers +from collections import namedtuple, defaultdict + +def int_or_float(s): + # return number, trying to maintain int format + if s.isdigit(): + return int(s, 10) + else: + return float(s) + + +DBCSignal = namedtuple( + "DBCSignal", ["name", "start_bit", "size", "is_little_endian", "is_signed", + "factor", "offset", "tmin", "tmax", "units"]) + + +class dbc(): + def __init__(self, fn): + self.name, _ = os.path.splitext(os.path.basename(fn)) + with open(fn, encoding="ascii") as f: + self.txt = f.readlines() + self._warned_addresses = set() + + # regexps from https://github.com/ebroecker/canmatrix/blob/master/canmatrix/importdbc.py + bo_regexp = re.compile(r"^BO\_ (\w+) (\w+) *: (\w+) (\w+)") + sg_regexp = re.compile(r"^SG\_ (\w+) : (\d+)\|(\d+)@(\d+)([\+|\-]) \(([0-9.+\-eE]+),([0-9.+\-eE]+)\) \[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] \"(.*)\" (.*)") + sgm_regexp = re.compile(r"^SG\_ (\w+) (\w+) *: (\d+)\|(\d+)@(\d+)([\+|\-]) \(([0-9.+\-eE]+),([0-9.+\-eE]+)\) \[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] \"(.*)\" (.*)") + val_regexp = re.compile(r"VAL\_ (\w+) (\w+) (\s*[-+]?[0-9]+\s+\".+?\"[^;]*)") + + # A dictionary which maps message ids to tuples ((name, size), signals). + # name is the ASCII name of the message. + # size is the size of the message in bytes. + # signals is a list signals contained in the message. + # signals is a list of DBCSignal in order of increasing start_bit. + self.msgs = {} + + # A dictionary which maps message ids to a list of tuples (signal name, definition value pairs) + self.def_vals = defaultdict(list) + + # lookup to bit reverse each byte + self.bits_index = [(i & ~0b111) + ((-i - 1) & 0b111) for i in range(64)] + + for l in self.txt: + l = l.strip() + + if l.startswith("BO_ "): + # new group + dat = bo_regexp.match(l) + + if dat is None: + print("bad BO {0}".format(l)) + + name = dat.group(2) + size = int(dat.group(3)) + ids = int(dat.group(1), 0) # could be hex + if ids in self.msgs: + sys.exit("Duplicate address detected %d %s" % (ids, self.name)) + + self.msgs[ids] = ((name, size), []) + + if l.startswith("SG_ "): + # new signal + dat = sg_regexp.match(l) + go = 0 + if dat is None: + dat = sgm_regexp.match(l) + go = 1 + + if dat is None: + 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) + + self.msgs[ids][1].append( + DBCSignal(sgname, start_bit, signal_size, is_little_endian, + is_signed, factor, offset, tmin, tmax, units)) + + if l.startswith("VAL_ "): + # new signal value/definition + dat = val_regexp.match(l) + + if dat is None: + print("bad VAL {0}".format(l)) + + 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.split('"')[:-1] + + # 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)) + + for msg in self.msgs.values(): + msg[1].sort(key=lambda x: x.start_bit) + + self.msg_name_to_address = {} + for address, m in self.msgs.items(): + name = m[0][0] + self.msg_name_to_address[name] = address + + def lookup_msg_id(self, msg_id): + if not isinstance(msg_id, numbers.Number): + msg_id = self.msg_name_to_address[msg_id] + return msg_id + + def reverse_bytes(self, x): + return ((x & 0xff00000000000000) >> 56) | \ + ((x & 0x00ff000000000000) >> 40) | \ + ((x & 0x0000ff0000000000) >> 24) | \ + ((x & 0x000000ff00000000) >> 8) | \ + ((x & 0x00000000ff000000) << 8) | \ + ((x & 0x0000000000ff0000) << 24) | \ + ((x & 0x000000000000ff00) << 40) | \ + ((x & 0x00000000000000ff) << 56) + + def encode(self, msg_id, dd): + """Encode a CAN message using the dbc. + + Inputs: + msg_id: The message ID. + dd: A dictionary mapping signal name to signal data. + """ + msg_id = self.lookup_msg_id(msg_id) + + msg_def = self.msgs[msg_id] + size = msg_def[0][1] + + result = 0 + for s in msg_def[1]: + ival = dd.get(s.name) + if ival is not None: + + ival = (ival - s.offset) / s.factor + ival = int(round(ival)) + + if s.is_signed and ival < 0: + ival = (1 << s.size) + ival + + 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) + dat = self.reverse_bytes(dat) + + result &= ~mask + result |= dat + + result = struct.pack('>Q', result) + return result[:size] + + def decode(self, x, arr=None, debug=False): + """Decode a CAN message using the dbc. + + Inputs: + x: A collection with elements (address, time, data), where address is + the CAN address, time is the bus time, and data is the CAN data as a + hex string. + arr: Optional list of signals which should be decoded and returned. + debug: True to print debugging statements. + + Returns: + A tuple (name, data), where name is the name of the CAN message and data + is the decoded result. If arr is None, data is a dict of properties. + Otherwise data is a list of the same length as arr. + + Returns (None, None) if the message could not be decoded. + """ + + if arr is None: + out = {} + else: + 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])) + self._warned_addresses.add(x[0]) + return None, None + + name = msg[0][0] + if debug: + print(name) + + st = x[2].ljust(8, b'\x00') + le, be = None, None + + for s in msg[1]: + if arr is not None and s[0] not in arr: + continue + + start_bit = s[1] + signal_size = s[2] + little_endian = s[3] + signed = s[4] + factor = s[5] + offset = s[6] + + if little_endian: + if le is None: + le = struct.unpack("Q", st)[0] + 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 << signal_size) - 1) + if signed and (tmp >> (signal_size - 1)): + tmp -= (1 << signal_size) + + tmp = tmp * factor + offset + + # if debug: + # print("%40s %2d %2d %7.2f %s" % (s[0], s[1], s[2], tmp, s[-1])) + + if arr is None: + out[s[0]] = tmp + else: + out[arr.index(s[0])] = tmp + return name, out + + def get_signals(self, msg): + msg = self.lookup_msg_id(msg) + return [sgs.name for sgs in self.msgs[msg][1]] 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/panda/board/pedal/obj/.gitkeep b/opendbc/can/dbc_out/.gitkeep similarity index 100% rename from panda/board/pedal/obj/.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..5a7312c600b997 --- /dev/null +++ b/opendbc/can/packer.cc @@ -0,0 +1,117 @@ +#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); +} + +static uint64_t set_value(uint64_t ret, const 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) { + double value = sigval.value; + + auto sig_it = signal_lookup.find(std::make_pair(address, sigval.name)); + if (sig_it == signal_lookup.end()) { + WARN("undefined signal %s - %d\n", sigval.name.c_str(), address); + continue; + } + const 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; + } + const 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()) { + const 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; +} + +Msg* CANPacker::lookup_message(uint32_t address) { + return &message_lookup[address]; +} 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..4b8f3e36f0e71b --- /dev/null +++ b/opendbc/can/packer_pyx.pyx @@ -0,0 +1,65 @@ +# 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 + values_thing.reserve(len(values)) + cdef SignalPackValue spv + + for name, value in values.iteritems(): + spv.name = name.encode('utf8') + 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..7e64199a1fcf9b --- /dev/null +++ b/opendbc/can/parser.cc @@ -0,0 +1,302 @@ +#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 (!ignore_checksum) { + 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::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::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; + } + } + } + if (!ignore_counter) { + if (sig.type == SignalType::HONDA_COUNTER) { + if (!update_counter_generic(tmp, sig.b2)) { + return false; + } + } else if (sig.type == SignalType::VOLKSWAGEN_COUNTER) { + if (!update_counter_generic(tmp, sig.b2)) { + 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), aligned_buf(kj::heapArray(1024)) { + + dbc = dbc_lookup(dbc_name); + assert(dbc); + init_crc_lookup_tables(); + + for (const auto& op : options) { + MessageState &state = message_states[op.address]; + state.address = op.address; + // state.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; i < dbc->num_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; i < msg->num_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; i < msg->num_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; + } + } + } + } +} + +CANParser::CANParser(int abus, const std::string& dbc_name, bool ignore_checksum, bool ignore_counter) + : bus(abus) { + // Add all messages and signals + + dbc = dbc_lookup(dbc_name); + assert(dbc); + init_crc_lookup_tables(); + + for (int i = 0; i < dbc->num_msgs; i++) { + const Msg* msg = &dbc->msgs[i]; + MessageState state = { + .address = msg->address, + .size = msg->size, + .ignore_checksum = ignore_checksum, + .ignore_counter = ignore_counter, + }; + + for (int j = 0; j < msg->num_sigs; j++) { + const Signal *sig = &msg->sigs[j]; + state.parse_sigs.push_back(*sig); + state.vals.push_back(0); + } + + message_states[state.address] = state; + } +} + +#ifndef DYNAMIC_CAPNP +void CANParser::update_string(const std::string &data, bool sendcan) { + // format for board, make copy due to alignment issues. + const size_t buf_size = (data.length() / sizeof(capnp::word)) + 1; + if (aligned_buf.size() < buf_size) { + aligned_buf = kj::heapArray(buf_size); + } + memcpy(aligned_buf.begin(), data.data(), data.length()); + + // extract the messages + capnp::FlatArrayMessageReader cmsg(aligned_buf.slice(0, buf_size)); + cereal::Event::Reader event = cmsg.getRoot(); + + last_sec = event.getLogMonoTime(); + + auto cans = sendcan? event.getSendcan() : event.getCan(); + UpdateCans(last_sec, cans); + + UpdateValid(last_sec); +} + +void CANParser::UpdateCans(uint64_t sec, const capnp::List::Reader& cans) { + int msg_count = cans.size(); + + DEBUG("got %d messages\n", msg_count); + + for (int i = 0; i < msg_count; i++) { + auto cmsg = cans[i]; + // parse the messages + 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); + } +} +#endif + +void CANParser::UpdateCans(uint64_t sec, const capnp::DynamicStruct::Reader& cmsg) { + // assume message struct is `cereal::CanData` and parse + assert(cmsg.has("address") && cmsg.has("src") && cmsg.has("dat") && cmsg.has("busTime")); + + if (cmsg.get("src").as() != bus) { + DEBUG("skip %d: wrong bus\n", cmsg.get("address").as()); + return; + } + + auto state_it = message_states.find(cmsg.get("address").as()); + if (state_it == message_states.end()) { + DEBUG("skip %d: not specified\n", cmsg.get("address").as()); + return; + } + + auto dat = cmsg.get("dat").as(); + if (dat.size() > 8) return; //shouldn't ever happen + uint8_t data[8] = {0}; + memcpy(data, dat.begin(), dat.size()); + state_it->second.parse(sec, cmsg.get("busTime").as(), data); +} + +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); + } else { + DEBUG("0x%X MISSING\n", state.address); + } + can_valid = false; + } + } +} + +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(f"Can't find DBC: '{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') + def_val = val.def_val.decode('utf8') + address = val.address + msgname = address_to_msg_name[address] + + # separate definition/value pairs + def_val = def_val.split() + values = [int(v) for v in def_val[::2]] + defs = def_val[1::2] + + + # 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..04a67db95e844d --- /dev/null +++ b/opendbc/can/process_dbc.py @@ -0,0 +1,131 @@ +#!/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_", "stellantis_")): + 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, "a+") as out_f: + out_f.seek(0) + if out_f.read() != parser_code: + out_f.seek(0) + out_f.truncate() + 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 db2892d33b8c39..245eefb8b0a335 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 @@ -262,7 +261,7 @@ BO_ 300 NEW_MSG_12C: 8 XXX BO_ 308 ACCEL_GAS_134: 8 XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX - SG_ ACCEL_134 : 43|4@0+ (1,0) [0|15] "" XXX + SG_ ACCEL_134 : 46|7@0+ (1,0) [0|127] "" XXX BO_ 532 ENERGY_RELATED_214: 8 XXX SG_ NOISY_SLOWLY_DECREASING : 16|9@0+ (1,0) [0|255] "" XXX @@ -301,6 +300,7 @@ BO_ 501 DASHBOARD: 8 XXX SG_ ACC_DISTANCE_CONFIG_1 : 1|2@0+ (1,0) [0|3] "" XXX SG_ ACC_DISTANCE_CONFIG_2 : 41|2@0+ (1,0) [0|3] "" XXX SG_ SPEED_DIGITAL : 63|8@0+ (1,0) [0|255] "mph" XXX + SG_ CRUISE_STATE : 38|3@0+ (1,0) [0|7] "" XXX BO_ 639 NEW_MSG_27f: 8 XXX SG_ INCREASING : 47|8@0+ (1,0) [0|255] "" XXX @@ -393,10 +393,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 +410,8 @@ 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"; CM_ SG_ 816 TOGGLE_PARKSENSE "sending 3000071ec0ff9000 enables or disables parksense"; @@ -427,9 +426,11 @@ CM_ SG_ 500 ACC_STATUS_1 "2 briefly (9 packets) when ACC goes to green, 1 help w CM_ SG_ 500 BRAKE_MAYBE "2046 in non-ACC and non-decel. Signal on deceleration. 818 for already stopped break."; CM_ SG_ 500 ACC_STATUS_2 "set to 1 in non-ACC, 3 when ACC enabled (white icon), and 7 when ACC in use (green icon)"; CM_ SG_ 500 BRAKE_BOOL_1 "set to 1 when ACC decel. 0 on non-ACC and accel."; +CM_ SG_ 501 CRUISE_STATE "may just be an icon, but seems to indicate different cruise modes: ACC and Non-ACC and engaged state for both."; 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_ 501 CRUISE_STATE 0 "Off" 1 "CC On" 2 "CC Engaged" 3 "ACC On" 4 "ACC Engaged"; +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 77d29d4298bdfa..00000000000000 --- a/opendbc/generator/honda/_honda_2017.dbc +++ /dev/null @@ -1,215 +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_ 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_ 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 58cc3300179f20..00000000000000 --- a/opendbc/generator/toyota/_toyota_2017.dbc +++ /dev/null @@ -1,262 +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_ YAW_RATE : 1|10@0+ (1,-512) [0|65535] "" XXX - SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX - -BO_ 37 STEER_ANGLE_SENSOR: 8 XXX - SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX - SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX - SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX - -BO_ 166 BRAKE: 8 XXX - SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX - SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX - -BO_ 170 WHEEL_SPEEDS: 8 XXX - SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX - -BO_ 180 SPEED: 8 XXX - SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX - -BO_ 353 DSU_SPEED: 8 XXX - SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX - -BO_ 466 PCM_CRUISE: 8 XXX - SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX - SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX - SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 467 PCM_CRUISE_2: 8 XXX - SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX - SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 552 ACCELEROMETER: 8 XXX - SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX - SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX - -BO_ 560 BRAKE_MODULE2: 7 XXX - SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX - -BO_ 614 STEERING_IPAS: 8 IPAS - SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX - SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX - SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 643 PRE_COLLISION: 8 XXX - -BO_ 740 STEERING_LKA: 5 XXX - SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX - SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX - SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX - SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX - SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 742 LEAD_INFO: 8 DSU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU - SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU - SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU - -BO_ 835 ACC_CONTROL: 8 DSU - SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU - SG_ SET_ME_X01 : 23|2@0+ (1,0) [0|3] "" HCU - SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX - SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX - SG_ SET_ME_1 : 30|1@0+ (1,0) [0|1] "" HCU - SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU - SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 921 PCM_CRUISE_SM: 8 XXX - SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX - SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX - SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 951 ESP_CONTROL: 8 ESP - SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX - -BO_ 1041 ACC_HUD: 8 DSU - SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX - -BO_ 1042 LKAS_HUD: 8 XXX - SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX - SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX - SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX - SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX - SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX - SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX - SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX - -BO_ 1553 UI_SEETING: 8 XXX - SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX - -BO_ 1556 STEERING_LEVERS: 8 XXX - SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX - -BO_ 1568 SEATS_DOORS: 8 XXX - SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX - -BO_ 1570 LIGHT_STALK: 8 SCM - SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX - -BO_ 1161 RSA1: 8 FCM - SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX - SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX - SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX - SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX - SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX - SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX - SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX - -BO_ 1162 RSA2: 8 FCM - SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX - SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX - SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX - SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX - SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX - SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX - SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX - SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX - -BO_ 1163 RSA3: 8 FCM - SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX - SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX - SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX - SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX - SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX - SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX - SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX - SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX - SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX - -CM_ SG_ 36 ACCEL_Y "unit is tbd"; -CM_ SG_ 36 YAW_RATE "verify"; -CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; -CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; -CM_ SG_ 37 STEER_RATE "factor is tbd"; -CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; -CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isnt perfect"; -CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; -CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; -CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; -CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; -CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; -CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; -CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; -CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; -CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; -CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; -CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; -CM_ SG_ 1161 SPDVAL2 "conditional speed value 70" -CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; -CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; -CM_ SG_ 1163 TSREQPD "always 1"; -CM_ SG_ 1163 TSRMSW "always 1"; -CM_ SG_ 1163 OTSGNNTM "always 3"; -CM_ SG_ 1163 NTLVLSPD "always 3"; -CM_ SG_ 1163 OVSPNTM "always 3"; -CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; -CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; -CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; -CM_ SG_ 1163 TSRSPU "always 1"; - -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; -VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; -VAL_ 614 STATE 3 "enabled" 1 "disabled"; -VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; -VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; -VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; -VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; -VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; -VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; -VAL_ 1553 UNITS 1 "km" 2 "miles"; -VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; -VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; -VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; -VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; -VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 129 "no entry"; -VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; - - -CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; 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 6548822fddca9c..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.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_ 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_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..cf34478d00a99d 100644 --- a/opendbc/gm_global_a_powertrain.dbc +++ b/opendbc/gm_global_a_powertrain.dbc @@ -72,8 +72,13 @@ BO_ 201 ECMEngineStatus: 8 K20_ECM SG_ Brake_Pressed : 40|1@0+ (1,0) [0|1] "" NEO SG_ Standstill : 2|1@0+ (1,0) [0|1] "" NEO -BO_ 209 EBCMBrakePedalTorque: 7 K17_EBCM - SG_ BrakePedalTorque : 3|12@0+ (1,0) [0|0] "" NEO +BO_ 209 EBCMBrakePedalSensors: 7 K17_EBCM + SG_ Counter1 : 7|2@0+ (1,0) [0|3] "" XXX + SG_ Counter2 : 23|2@0+ (1,0) [0|3] "" XXX + SG_ BrakePedalPosition1 : 5|14@0+ (1,0) [0|16383] "" XXX + SG_ BrakePedalPosition2 : 21|14@0- (-1,0) [0|16383] "" XXX + SG_ BrakeNormalized1 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ BrakeNormalized2 : 47|8@0- (-1,0) [0|255] "" XXX BO_ 241 EBCMBrakePedalPosition: 6 K17_EBCM SG_ BrakePedalPosition : 15|8@0+ (1,0) [0|255] "" NEO @@ -116,7 +121,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 @@ -133,8 +138,8 @@ BO_ 481 ASCMSteeringButton: 7 K124_ASCM SG_ DriveModeButton : 39|1@0+ (1,0) [0|1] "" XXX 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 + SG_ SteeringWheelAngle : 15|16@0- (0.0625,0) [-2047|2047] "deg" NEO + SG_ SteeringWheelRate : 27|12@0- (1,0) [-2047|2047] "deg/s" NEO BO_ 489 EBCMVehicleDynamic: 8 K17_EBCM SG_ BrakePedalPressed : 6|1@0+ (1,0) [0|0] "" NEO @@ -163,14 +168,14 @@ BO_ 715 ASCMGasRegenCmd: 8 K124_ASCM BO_ 717 ASCM_2CD: 5 K124_ASCM BO_ 810 TCICOnStarGPSPosition: 8 K73_TCIC - SG_ GPSLongitude : 39|32@0+ (1,0) [0|0] "milliarcsecond" NEO + SG_ GPSLongitude : 39|32@0+ (1,-2147483648) [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 +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 +200,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 +246,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_2018_can_generated.dbc b/opendbc/honda_accord_2018_can_generated.dbc new file mode 100644 index 00000000000000..0b79ceef4328a9 --- /dev/null +++ b/opendbc/honda_accord_2018_can_generated.dbc @@ -0,0 +1,491 @@ +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_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" 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 + SG_ IMPERIAL_UNIT : 63|1@0+ (1,0) [0|1] "" 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 + +BO_ 13274 LKAS_HUD_A: 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_ SET_ME_X01 : 20|1@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_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 13275 LKAS_HUD_B: 8 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_ SET_ME_X01 : 20|1@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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +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_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 + SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON + SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON + +BO_ 401 GEARBOX_15T: 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_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; +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" ; + diff --git a/opendbc/honda_accord_lx15t_2018_can_generated.dbc b/opendbc/honda_accord_lx15t_2018_can_generated.dbc deleted file mode 100644 index 6159efb0e8144f..00000000000000 --- a/opendbc/honda_accord_lx15t_2018_can_generated.dbc +++ /dev/null @@ -1,322 +0,0 @@ -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_ 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" ; - -CM_ "honda_accord_lx15t_2018_can.dbc starts here" - - -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/honda_accord_s2t_2018_can_generated.dbc b/opendbc/honda_accord_s2t_2018_can_generated.dbc deleted file mode 100644 index 7b3e99bc846542..00000000000000 --- a/opendbc/honda_accord_s2t_2018_can_generated.dbc +++ /dev/null @@ -1,318 +0,0 @@ -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_ 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" ; - -CM_ "honda_accord_s2t_2018_can.dbc starts here" - - -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/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..cb2a3592aac288 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,14 +37,29 @@ 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 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_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" 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 @@ -52,17 +67,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 +99,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 +115,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 +136,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 +173,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 +278,17 @@ 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 + SG_ IMPERIAL_UNIT : 63|1@0+ (1,0) [0|1] "" 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 +306,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 +371,68 @@ 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 +BO_ 13274 LKAS_HUD_A: 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_ SET_ME_X01 : 20|1@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_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 13275 LKAS_HUD_B: 8 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_ SET_ME_X01 : 20|1@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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +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 +449,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 @@ -322,4 +490,3 @@ 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_sedan_16_diesel_2019_can_generated.dbc b/opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc new file mode 100644 index 00000000000000..0ddb0bd401959f --- /dev/null +++ b/opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc @@ -0,0 +1,487 @@ +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_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" 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 + SG_ IMPERIAL_UNIT : 63|1@0+ (1,0) [0|1] "" 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 + +BO_ 13274 LKAS_HUD_A: 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_ SET_ME_X01 : 20|1@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_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 13275 LKAS_HUD_B: 8 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_ SET_ME_X01 : 20|1@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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +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" ; + diff --git a/opendbc/honda_civic_touring_2016_can_generated.dbc b/opendbc/honda_civic_touring_2016_can_generated.dbc index 7e95e638bf1b6d..9315c822aaa575 100644 --- a/opendbc/honda_civic_touring_2016_can_generated.dbc +++ b/opendbc/honda_civic_touring_2016_can_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,11 +228,30 @@ 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_ "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_ "honda_civic_touring_2016_can.dbc starts here"; @@ -264,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 @@ -328,6 +346,7 @@ BO_ 862 HIGHBEAM_CONTROL: 8 ADAS SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX + SG_ DASHBOARD_ALERT : 39|8@0+ (1,0) [0|255] "" EON 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 @@ -371,7 +390,7 @@ 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_ 884 DASHBOARD_ALERT 0 "none" 51 "acc_problem" 55 "cmbs_problem" 75 "key_not_detected" 79 "fasten_seatbelt" 111 "lkas_problem" 131 "brake_system_problem" 132 "brake_hold_problem" 139 "tbd" 161 "door_open" 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/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..3be8848bd1dc9b 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,14 +37,29 @@ 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 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_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" 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 @@ -52,17 +67,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 +99,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 +115,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 +136,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 +173,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 +278,17 @@ 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 + SG_ IMPERIAL_UNIT : 63|1@0+ (1,0) [0|1] "" 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 +306,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 +371,68 @@ 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 +BO_ 13274 LKAS_HUD_A: 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_ SET_ME_X01 : 20|1@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_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 13275 LKAS_HUD_B: 8 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_ SET_ME_X01 : 20|1@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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +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 @@ -333,4 +496,3 @@ 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_crv_executive_2016_can_generated.dbc b/opendbc/honda_crv_executive_2016_can_generated.dbc new file mode 100644 index 00000000000000..55611dd9ee10e4 --- /dev/null +++ b/opendbc/honda_crv_executive_2016_can_generated.dbc @@ -0,0 +1,318 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +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_ "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_ "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" ; + diff --git a/opendbc/honda_crv_hybrid_2019_can_generated.dbc b/opendbc/honda_crv_hybrid_2019_can_generated.dbc index 4fd8ae924a43ef..01a24c96c259fc 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,14 +37,29 @@ 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 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_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" 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 @@ -52,17 +67,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 +99,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 +115,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 +136,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 +173,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 +278,17 @@ 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 + SG_ IMPERIAL_UNIT : 63|1@0+ (1,0) [0|1] "" 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 +306,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 +371,68 @@ 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 +BO_ 13274 LKAS_HUD_A: 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_ SET_ME_X01 : 20|1@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_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 13275 LKAS_HUD_B: 8 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_ SET_ME_X01 : 20|1@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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +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 @@ -315,4 +478,3 @@ 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_crv_touring_2016_can_generated.dbc b/opendbc/honda_crv_touring_2016_can_generated.dbc index 1e25cbf79c1a2c..45d85cad788b5f 100644 --- a/opendbc/honda_crv_touring_2016_can_generated.dbc +++ b/opendbc/honda_crv_touring_2016_can_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,23 +228,42 @@ 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_ "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_ "honda_crv_touring_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_ 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_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 @@ -305,4 +320,3 @@ 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_fit_ex_2018_can_generated.dbc b/opendbc/honda_fit_ex_2018_can_generated.dbc index fe3a4735c7de56..df47a001d58a78 100644 --- a/opendbc/honda_fit_ex_2018_can_generated.dbc +++ b/opendbc/honda_fit_ex_2018_can_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,11 +228,30 @@ 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_ "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_ "honda_fit_ex_2018_can.dbc starts here"; @@ -258,17 +273,21 @@ BO_ 304 GAS_PEDAL_2: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@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 : 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_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_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 @@ -283,6 +302,7 @@ BO_ 422 SCM_BUTTONS: 8 SCM 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] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON @@ -325,4 +345,3 @@ VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "c 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..5bb0ab01c652b6 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,14 +37,29 @@ 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 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_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" 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 @@ -52,17 +67,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 +99,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 +115,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 +136,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 +173,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 +278,17 @@ 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 + SG_ IMPERIAL_UNIT : 63|1@0+ (1,0) [0|1] "" 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 +306,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 +371,68 @@ 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 +BO_ 13274 LKAS_HUD_A: 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_ SET_ME_X01 : 20|1@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_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY + +BO_ 13275 LKAS_HUD_B: 8 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_ SET_ME_X01 : 20|1@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_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY + SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY + +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 @@ -311,4 +474,3 @@ BO_ 1029 DOORS_STATUS: 8 BDY 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/honda_odyssey_exl_2018_generated.dbc b/opendbc/honda_odyssey_exl_2018_generated.dbc index 3a95af4b262e0f..586d2f8ab91010 100644 --- a/opendbc/honda_odyssey_exl_2018_generated.dbc +++ b/opendbc/honda_odyssey_exl_2018_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,11 +228,30 @@ 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_ "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_ "honda_odyssey_exl_2018.dbc starts here"; @@ -252,15 +267,16 @@ BO_ 316 GAS_PEDAL: 8 PCM 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_ 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_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 @@ -341,4 +357,3 @@ 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/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..db99d2184a6c1a --- /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 _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_ "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_ "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 50f2911a8bb8db..2cc61de8b60ad5 100644 --- a/opendbc/honda_pilot_touring_2017_can_generated.dbc +++ b/opendbc/honda_pilot_touring_2017_can_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,11 +228,30 @@ 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_ "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_ "honda_pilot_touring_2017_can.dbc starts here"; @@ -260,15 +275,16 @@ BO_ 316 GAS_PEDAL: 8 PCM 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_ 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_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 @@ -297,4 +313,3 @@ VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "c 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_ridgeline_black_edition_2017_can_generated.dbc b/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc index 725acb553f76a1..19ded5414d9486 100644 --- a/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc +++ b/opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc @@ -1,25 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" @@ -78,6 +60,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 +68,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 @@ -107,21 +97,24 @@ BO_ 490 VEHICLE_DYNAMICS: 8 VSA 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_ SET_ME_X00 : 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_ SET_ME_X00_2 : 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_ 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_0X80 : 31|8@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_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" 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_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" 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 @@ -160,7 +153,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 @@ -170,10 +163,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 @@ -223,6 +218,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"; @@ -232,11 +228,30 @@ 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_ "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_ "honda_ridgeline_black_edition_2017_can.dbc starts here"; @@ -255,15 +270,16 @@ BO_ 316 GAS_PEDAL: 8 PCM 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_ 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_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 @@ -292,4 +308,3 @@ VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "c 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/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 e3e6a1eb6118cb..3ae17aab68c60b 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_Icon : 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 : 37|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 @@ -1021,10 +1028,7 @@ BO_ 48 EMS18: 6 EMS 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_Gear : 9|4@1+ (1,0) [0|15] "" 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 @@ -1035,6 +1039,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 +1164,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 @@ -1190,21 +1195,21 @@ BO_ 1313 GW_DDM_PE: 8 BCM 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 +1230,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 +1372,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 +1427,231 @@ 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.02,0) [0|1.26] "m/s^2" ESC + SG_ ComfortBandLower : 6|6@1+ (0.02,0) [0|1.26] "m/s^2" ESC + SG_ JerkUpperLimit : 12|7@1+ (0.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_ HDA_Active : 2|1@1+ (1,0) [0|1] "" XXX + SG_ HDA_Icon_State : 3|2@1+ (1,0) [0|3] "" XXX + SG_ HDA_Chime : 7|1@1+ (1,0) [0|1] "" XXX + SG_ HDA_VSetReq : 8|8@1+ (1,0) [0|255] "km/h" XXX + SG_ LFA_SysWarning : 16|3@1+ (1,0) [0|7] "" XXX + SG_ NEW_SIGNAL_1 : 20|3@1+ (1,0) [0|7] "" XXX + SG_ LFA_Icon_State : 24|2@1+ (1,0) [0|3] "" XXX + SG_ LFA_USM : 27|2@1+ (1,0) [0|3] "" XXX + SG_ HDA_SysWarning : 29|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 + SG_ LFA_Pressed : 4|1@0+ (1,0) [0|1] "" XXX + +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|254] "" XXX + SG_ CR_Vcu_AccPedDep_Pos : 56|8@1+ (1,0) [0|254] "" 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 MFC_4a7: 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: 8 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 + SG_ Counter : 58|4@1+ (1,0) [0|15] "" MDPS + SG_ Checksum : 62|2@1+ (1,0) [0|3] "" MDPS + +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 EMS_366: 8 EMS + SG_ TQI_1 : 0|8@1+ (0.390625,0) [0|99.6094] "%" MDPS + SG_ N : 8|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" MDPS + SG_ TQI_2 : 24|8@1+ (0.390625,0) [0|99.6094] "%" MDPS + 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 M_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 + +BO_ 1348 Navi_HU: 8 XXX + SG_ SpeedLim_Nav_Clu : 7|8@0+ (1,0) [0|255] "" XXX + + + + +VAL_ 871 CF_Lvr_Gear 5 "D" 8 "S" 6 "N" 7 "R" 0 "P" ; +VAL_ 1322 CF_Clu_Gear 1 "P" 2 "R" 4 "N" 8 "D" ; +VAL_ 274 CUR_GR 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 7 "D" 8 "D" 14 "R" 0 "P" ; +VAL_ 909 CF_VSM_Warn 2 "FCW" 3 "AEB" ; +VAL_ 1157 HDA_Icon_State 0 "no_hda" 1 "white_hda" 2 "green_hda" ; +VAL_ 1157 LFA_SysWarning 0 "no_message" 1 "switching_to_hda" 2 "switching_to_scc" 3 "lfa_error" 4 "check_hda" 5 "keep_hands_on_wheel_orange" 6 "keep_hands_on_wheel_red" ; +VAL_ 1157 LFA_Icon_State 0 "no_wheel" 1 "white_wheel" 2 "green_wheel" 3 "green_wheel_blink" ; +VAL_ 1157 HDA_SysWarning 0 "no_message" 1 "driving_convenience_systems_cancelled" 2 "highway_drive_assist_system_cancelled" ; +VAL_ 882 Elect_Gear_Shifter 5 "D" 8 "S" 6 "N" 7 "R" 0 "P" ; +CM_ "BO_ E_EMS11: All (plug-in) hybrids use this gas signal: CR_Vcu_AccPedDep_Pos, and all EVs use the Accel_Pedal_Pos signal. See hyundai/values.py for a specific car list"; +CM_ SG_ 1348 SpeedLim_Nav_Clu "Speed limit displayed on Nav, Cluster and HUD"; \ No newline at end of file diff --git a/opendbc/hyundai_kia_mando_front_radar.dbc b/opendbc/hyundai_kia_mando_front_radar.dbc new file mode 100644 index 00000000000000..552cdddeaf55ba --- /dev/null +++ b/opendbc/hyundai_kia_mando_front_radar.dbc @@ -0,0 +1,454 @@ + +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_ 1280 RADAR_TRACK_500: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1281 RADAR_TRACK_501: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1282 RADAR_TRACK_502: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1283 RADAR_TRACK_503: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1284 RADAR_TRACK_504: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1285 RADAR_TRACK_505: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1286 RADAR_TRACK_506: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1287 RADAR_TRACK_507: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1288 RADAR_TRACK_508: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1289 RADAR_TRACK_509: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1290 RADAR_TRACK_50a: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1291 RADAR_TRACK_50b: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1292 RADAR_TRACK_50c: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1293 RADAR_TRACK_50d: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1294 RADAR_TRACK_50e: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1295 RADAR_TRACK_50f: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1296 RADAR_TRACK_510: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1297 RADAR_TRACK_511: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1298 RADAR_TRACK_512: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1299 RADAR_TRACK_513: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1300 RADAR_TRACK_514: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1301 RADAR_TRACK_515: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1302 RADAR_TRACK_516: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1303 RADAR_TRACK_517: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1304 RADAR_TRACK_518: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1305 RADAR_TRACK_519: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1306 RADAR_TRACK_51a: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1307 RADAR_TRACK_51b: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1308 RADAR_TRACK_51c: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1309 RADAR_TRACK_51d: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1310 RADAR_TRACK_51e: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + + +BO_ 1311 RADAR_TRACK_51f: 8 RADAR + SG_ UNKNOWN_1 : 7|8@0- (1,0) [-128|127] "" XXX + SG_ AZIMUTH : 12|10@0- (0.2,0) [-102.4|102.2] "" XXX + SG_ STATE : 15|3@0+ (1,0) [0|7] "" XXX + SG_ LONG_DIST : 18|11@0+ (0.1,0) [0|204.7] "" XXX + SG_ REL_ACCEL : 33|10@0- (0.02,0) [-10.24|10.22] "" XXX + SG_ ZEROS : 37|4@0+ (1,0) [0|255] "" XXX + SG_ COUNTER : 38|1@0+ (1,0) [0|1] "" XXX + SG_ STATE_3 : 39|1@0+ (1,0) [0|1] "" XXX + SG_ REL_SPEED : 53|14@0- (0.01,0) [-81.92|81.92] "" XXX + SG_ STATE_2 : 55|2@0+ (1,0) [0|3] "" XXX + diff --git a/opendbc/lexus_ct200h_2018_pt_generated.dbc b/opendbc/lexus_ct200h_2018_pt_generated.dbc new file mode 100644 index 00000000000000..06fcd3dc1b9789 --- /dev/null +++ b/opendbc/lexus_ct200h_2018_pt_generated.dbc @@ -0,0 +1,453 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX + +BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX + 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_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX + +BO_ 1556 STEERING_LEVERS: 8 XXX + SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX + +BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|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 + +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; +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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; + +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; +VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; +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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; +VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; + + + + +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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "lexus_ct200h_2018_pt.dbc starts here"; + + + +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_ 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- (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 + 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"; diff --git a/opendbc/lexus_gs300h_2017_pt_generated.dbc b/opendbc/lexus_gs300h_2017_pt_generated.dbc deleted file mode 100644 index 201098af8ca64b..00000000000000 --- a/opendbc/lexus_gs300h_2017_pt_generated.dbc +++ /dev/null @@ -1,336 +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 - -BO_ 36 KINEMATICS: 8 XXX - SG_ ACCEL_Y : 33|10@0+ (1,-512) [0|65535] "" XXX - SG_ YAW_RATE : 1|10@0+ (1,-512) [0|65535] "" XXX - SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX - -BO_ 37 STEER_ANGLE_SENSOR: 8 XXX - SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX - SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX - SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX - -BO_ 166 BRAKE: 8 XXX - SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX - SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX - -BO_ 170 WHEEL_SPEEDS: 8 XXX - SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX - -BO_ 180 SPEED: 8 XXX - SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX - -BO_ 353 DSU_SPEED: 8 XXX - SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX - -BO_ 466 PCM_CRUISE: 8 XXX - SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX - SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX - SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 467 PCM_CRUISE_2: 8 XXX - SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX - SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 552 ACCELEROMETER: 8 XXX - SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX - SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX - -BO_ 560 BRAKE_MODULE2: 7 XXX - SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX - -BO_ 614 STEERING_IPAS: 8 IPAS - SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX - SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX - SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 643 PRE_COLLISION: 8 XXX - -BO_ 740 STEERING_LKA: 5 XXX - SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX - SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX - SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX - SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX - SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 742 LEAD_INFO: 8 DSU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU - SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU - SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU - -BO_ 835 ACC_CONTROL: 8 DSU - SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU - SG_ SET_ME_X01 : 23|2@0+ (1,0) [0|3] "" HCU - SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX - SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX - SG_ SET_ME_1 : 30|1@0+ (1,0) [0|1] "" HCU - SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU - SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 921 PCM_CRUISE_SM: 8 XXX - SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX - SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX - SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 951 ESP_CONTROL: 8 ESP - SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX - -BO_ 1041 ACC_HUD: 8 DSU - SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX - -BO_ 1042 LKAS_HUD: 8 XXX - SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX - SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX - SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX - SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX - SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX - SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX - SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX - -BO_ 1553 UI_SEETING: 8 XXX - SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX - -BO_ 1556 STEERING_LEVERS: 8 XXX - SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX - -BO_ 1568 SEATS_DOORS: 8 XXX - SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX - -BO_ 1570 LIGHT_STALK: 8 SCM - SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX - -BO_ 1161 RSA1: 8 FCM - SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX - SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX - SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX - SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX - SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX - SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX - SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX - -BO_ 1162 RSA2: 8 FCM - SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX - SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX - SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX - SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX - SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX - SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX - SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX - SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX - -BO_ 1163 RSA3: 8 FCM - SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX - SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX - SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX - SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX - SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX - SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX - SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX - SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX - SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX - -CM_ SG_ 36 ACCEL_Y "unit is tbd"; -CM_ SG_ 36 YAW_RATE "verify"; -CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; -CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; -CM_ SG_ 37 STEER_RATE "factor is tbd"; -CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; -CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isnt perfect"; -CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; -CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; -CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; -CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; -CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; -CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; -CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; -CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; -CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; -CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; -CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; -CM_ SG_ 1161 SPDVAL2 "conditional speed value 70" -CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; -CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; -CM_ SG_ 1163 TSREQPD "always 1"; -CM_ SG_ 1163 TSRMSW "always 1"; -CM_ SG_ 1163 OTSGNNTM "always 3"; -CM_ SG_ 1163 NTLVLSPD "always 3"; -CM_ SG_ 1163 OVSPNTM "always 3"; -CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; -CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; -CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; -CM_ SG_ 1163 TSRSPU "always 1"; - -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; -VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; -VAL_ 614 STATE 3 "enabled" 1 "disabled"; -VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; -VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; -VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; -VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; -VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; -VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; -VAL_ 1553 UNITS 1 "km" 2 "miles"; -VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; -VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; -VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; -VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; -VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 129 "no entry"; -VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; - - -CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; - -CM_ "lexus_gs300h_2017_pt.dbc starts here" - - - -BO_ 550 BRAKE_MODULE: 8 XXX - SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX - SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX - SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX - -BO_ 581 GAS_PEDAL: 5 XXX - SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX - -BO_ 608 STEER_TORQUE_SENSOR: 8 XXX - SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX - SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX - SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 610 EPS_STATUS: 5 EPS - SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX - SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX - SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX - SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 956 GEAR_PACKET: 8 XXX - SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX - -BO_ 1009 PCM_CRUISE_3: 8 XXX - SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX - SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|15] "" XXX - -CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; -CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; -CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; -CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; -VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; -VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; -VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; diff --git a/opendbc/lexus_is_2018_pt_generated.dbc b/opendbc/lexus_is_2018_pt_generated.dbc index a7acb08db16ebf..571dfee5d76146 100644 --- a/opendbc/lexus_is_2018_pt_generated.dbc +++ b/opendbc/lexus_is_2018_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "lexus_is_2018_pt.dbc starts here"; @@ -304,15 +422,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.73,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 @@ -323,11 +445,14 @@ BO_ 610 EPS_STATUS: 5 EPS BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX -BO_ 1009 PCM_CRUISE_3: 8 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 +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 cbc770aa16f2b9..00000000000000 --- a/opendbc/lexus_is_hybrid_2017_pt_generated.dbc +++ /dev/null @@ -1,339 +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 - -BO_ 36 KINEMATICS: 8 XXX - SG_ ACCEL_Y : 33|10@0+ (1,-512) [0|65535] "" XXX - SG_ YAW_RATE : 1|10@0+ (1,-512) [0|65535] "" XXX - SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX - -BO_ 37 STEER_ANGLE_SENSOR: 8 XXX - SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX - SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX - SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX - -BO_ 166 BRAKE: 8 XXX - SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX - SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX - -BO_ 170 WHEEL_SPEEDS: 8 XXX - SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX - SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX - -BO_ 180 SPEED: 8 XXX - SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX - -BO_ 353 DSU_SPEED: 8 XXX - SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX - -BO_ 466 PCM_CRUISE: 8 XXX - SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX - SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX - SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 467 PCM_CRUISE_2: 8 XXX - SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX - SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX - SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 552 ACCELEROMETER: 8 XXX - SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX - SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX - -BO_ 560 BRAKE_MODULE2: 7 XXX - SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX - -BO_ 614 STEERING_IPAS: 8 IPAS - SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX - SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX - SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX - SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX - SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 643 PRE_COLLISION: 8 XXX - -BO_ 740 STEERING_LKA: 5 XXX - SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX - SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX - SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX - SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX - SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX - SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX - -BO_ 742 LEAD_INFO: 8 DSU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU - SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU - SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU - -BO_ 835 ACC_CONTROL: 8 DSU - SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU - SG_ SET_ME_X01 : 23|2@0+ (1,0) [0|3] "" HCU - SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX - SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX - SG_ SET_ME_1 : 30|1@0+ (1,0) [0|1] "" HCU - SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU - SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU - SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX - -BO_ 921 PCM_CRUISE_SM: 8 XXX - SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX - SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX - SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX - -BO_ 951 ESP_CONTROL: 8 ESP - SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX - SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX - -BO_ 1041 ACC_HUD: 8 DSU - SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX - -BO_ 1042 LKAS_HUD: 8 XXX - SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX - SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX - SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX - SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX - SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX - SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX - SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX - SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX - SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX - SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX - -BO_ 1553 UI_SEETING: 8 XXX - SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX - -BO_ 1556 STEERING_LEVERS: 8 XXX - SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX - -BO_ 1568 SEATS_DOORS: 8 XXX - SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX - SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX - -BO_ 1570 LIGHT_STALK: 8 SCM - SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX - -BO_ 1161 RSA1: 8 FCM - SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX - SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX - SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX - SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX - SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX - SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX - SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX - SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX - -BO_ 1162 RSA2: 8 FCM - SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX - SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX - SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX - SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX - SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX - SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX - SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX - SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX - SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX - SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX - SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX - -BO_ 1163 RSA3: 8 FCM - SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX - SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX - SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX - SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX - SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX - SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX - SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX - SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX - SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX - -CM_ SG_ 36 ACCEL_Y "unit is tbd"; -CM_ SG_ 36 YAW_RATE "verify"; -CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; -CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; -CM_ SG_ 37 STEER_RATE "factor is tbd"; -CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; -CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isnt perfect"; -CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; -CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; -CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; -CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; -CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; -CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; -CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; -CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; -CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; -CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; -CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; -CM_ SG_ 1161 SPDVAL2 "conditional speed value 70" -CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; -CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; -CM_ SG_ 1163 TSREQPD "always 1"; -CM_ SG_ 1163 TSRMSW "always 1"; -CM_ SG_ 1163 OTSGNNTM "always 3"; -CM_ SG_ 1163 NTLVLSPD "always 3"; -CM_ SG_ 1163 OVSPNTM "always 3"; -CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; -CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; -CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; -CM_ SG_ 1163 TSRSPU "always 1"; - -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; -VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; -VAL_ 614 STATE 3 "enabled" 1 "disabled"; -VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; -VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; -VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; -VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; -VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; -VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; -VAL_ 1553 UNITS 1 "km" 2 "miles"; -VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; -VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; -VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; -VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; -VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 129 "no entry"; -VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; - - -CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; - -CM_ "lexus_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..5351a4f491759b --- /dev/null +++ b/opendbc/lexus_nx300_2018_pt_generated.dbc @@ -0,0 +1,455 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX + +BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX + 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_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX + +BO_ 1556 STEERING_LEVERS: 8 XXX + SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX + +BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|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 + +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; +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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; + +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; +VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; +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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; +VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; + + + + +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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +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..0ec03a45c8ed58 --- /dev/null +++ b/opendbc/lexus_nx300h_2018_pt_generated.dbc @@ -0,0 +1,454 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX + +BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX + 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_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX + +BO_ 1556 STEERING_LEVERS: 8 XXX + SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX + +BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|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 + +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; +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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; + +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; +VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; +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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; +VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; + + + + +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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +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 new file mode 100644 index 00000000000000..e4ea2289bc989b --- /dev/null +++ b/opendbc/lexus_rx_350_2016_pt_generated.dbc @@ -0,0 +1,454 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX + +BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX + 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_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX + +BO_ 1556 STEERING_LEVERS: 8 XXX + SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX + +BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|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 + +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; +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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; + +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; +VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; +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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; +VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; + + + + +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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "lexus_rx_350_2016_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_ 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 + +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/lexus_rx_hybrid_2017_pt_generated.dbc b/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc index 6f01126fa5aaf1..fd9f217f29a14c 100644 --- a/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc +++ b/opendbc/lexus_rx_hybrid_2017_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "lexus_rx_hybrid_2017_pt.dbc starts here"; @@ -312,6 +430,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..fdd6d28248e865 --- /dev/null +++ b/opendbc/mazda_2017.dbc @@ -0,0 +1,764 @@ +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_ 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_ SPEED_SIGN_CAM : 32|1@0+ (1,0) [0|32767] "" XXX + SG_ SPEED_SIGN_ON : 12|1@0+ (1,0) [0|3] "" XXX + SG_ STOP_SIGN : 31|4@0+ (1,0) [0|1] "" XXX + SG_ NEW_SIGNAL_4 : 33|1@0+ (1,0) [0|1] "" XXX + +BO_ 1157 CAM_SETTINGS: 8 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_ WARNING : 11|1@0+ (1,0) [0|1] "" XXX + SG_ BIT1 : 12|1@0+ (1,0) [0|7] "" XXX + SG_ BIT2 : 14|1@0+ (1,0) [0|1] "" XXX + SG_ BIT3 : 18|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_ CTR : 51|4@0+ (1,0) [0|15] "" XXX + SG_ NEW_SIGNAL_21 : 23|1@0+ (1,0) [0|15] "" XXX + SG_ GAS_MAYBE : 22|1@0+ (1,0) [0|1] "" XXX + SG_ ACCEL_CMD : 46|8@0- (1,0) [0|15] "" XXX + SG_ CRUISE_ACTIVE_CAR_MOVING : 16|1@0+ (1,0) [0|1] "" XXX + SG_ PLUS_ONE_CRZ : 17|1@0+ (1,0) [0|255] "" XXX + SG_ CRZ_STARTED : 18|1@0+ (1,0) [0|1] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX + SG_ PLUS_ONE_CRZ_2 : 19|1@0+ (1,0) [0|1] "" XXX + SG_ ACCEL_CMD_LOW_RES : 29|8@0- (1,0) [0|255] "" XXX + SG_ CRZ_SPEED : 7|16@0+ (0.005,-0.5) [0|328] "kph" 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_6 : 10|1@0+ (1,0) [0|1] "" 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_ 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 + SG_ NEW_SIGNAL_3 : 1|1@0+ (1,0) [0|1] "" XXX + SG_ CRZ_ACTIVE : 3|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_ CRZ_AVAILABLE : 17|1@0+ (1,0) [0|255] "" XXX + SG_ DISTANCE_SETTING : 20|3@0+ (1,0) [0|7] "" XXX + +BO_ 539 CRZ_INFO: 8 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|8@0- (1,0) [0|1] "" XXX + SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX + SG_ NEW_SIGNAL_1 : 7|16@0+ (1,0) [0|65535] "" 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_ 863 STOP_SIGN "value 9 when stop sign is active"; +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_ 540 DISTANCE_SETTING "Radar distance 0: disabled, 1: 4 bars, 2: 3 bars, 3: 2 bars, 4: 1 bar"; +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_leaf_2018.dbc b/opendbc/nissan_leaf_2018.dbc new file mode 100644 index 00000000000000..6483d9cbf9ec1c --- /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_ USER_BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" 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..6e5b3ff27bcfd6 --- /dev/null +++ b/opendbc/subaru_forester_2017_generated.dbc @@ -0,0 +1,265 @@ +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_ Signal1 : 12|2@1+ (1,0) [0|7] "" XXX + SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 15|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_ Signal3 : 31|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 + SG_ Signal4 : 57|7@1+ (1,0) [0|127] "" 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_ Cruise_Fault : 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_ Distance_Swap : 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_ Close_Distance : 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_ Cruise_Fault : 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_ Cruise_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_ 977 Dash_State2: 8 XXX + SG_ UNITS : 15|1@1+ (1,0) [0|1] "" 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 Cruise_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"; +CM_ SG_ 977 UNITS "0 = Metric, 1 = Imperial"; + +VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; + +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_ Steer_Error_1 : 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..7964225b978eca --- /dev/null +++ b/opendbc/subaru_global_2017_generated.dbc @@ -0,0 +1,317 @@ +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_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX + SG_ Engine_RPM : 16|12@1+ (1,0) [0|4095] "" XXX + SG_ Signal2 : 28|4@1+ (1,0) [0|15] "" 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_ Signal3 : 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_ UNITS : 24|1@1+ (1,0) [0|1] "" 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_ BRAKE : 54|1@1+ (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_LIGHTS : 60|1@1+ (1,0) [0|1] "" XXX + SG_ WIPERS : 62|1@0+ (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|2@1+ (1,0) [0|3] "" XXX + SG_ Cruise_State_Msg : 16|4@1+ (1,0) [0|15] "" XXX + SG_ LKAS_State_Msg : 20|3@1+ (1,0) [0|7] "" XXX + SG_ Signal2 : 23|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Soft_Disable : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Status_Msg : 25|2@1+ (1,0) [0|3] "" XXX + SG_ Signal3 : 27|1@1+ (1,0) [0|1] "" XXX + SG_ Cruise_Distance : 28|3@1+ (1,0) [0|7] "" XXX + SG_ Signal4 : 31|1@1+ (1,0) [0|1] "" XXX + SG_ Conventional_Cruise : 32|1@1+ (1,0) [0|1] "" XXX + SG_ Signal5 : 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_ Signal6 : 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_ Display_Own_Car : 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_ LKAS_Alert_Msg : 12|3@1+ (1,0) [0|7] "" XXX + SG_ Signal1 : 15|2@1+ (1,0) [0|3] "" XXX + SG_ LKAS_ACTIVE : 17|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Dash_State : 18|2@1+ (1,0) [0|2] "" XXX + SG_ Signal2 : 20|3@1+ (1,0) [0|7] "" XXX + SG_ Backward_Speed_Limit_Menu : 23|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Left_Line_Enable : 24|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Left_Line_Light_Blink : 25|1@1+ (1,0) [0|1] "" XXX + SG_ LKAS_Right_Line_Enable : 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|2@1+ (1,0) [0|3] "" XXX + SG_ LKAS_Right_Line_Visible : 30|2@1+ (1,0) [0|3] "" XXX + SG_ LKAS_Alert : 32|5@1+ (1,0) [0|31] "" XXX + SG_ Signal3 : 37|27@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 LKAS_State_Msg "1 = LKAS_Off_Sharp_Curve, 2 = Keep_Hands_On_Steering_wheel_disabled, 3 = LKAS_Off, 4 = LKAS_Off_Too_Slow, 5 = LKAS_Off_Too_Fast"; +CM_ SG_ 801 Cruise_State_Msg "1 = Cruise_Off_Steep_Slope, 2 = Cruise_lvl1_eco, 3 = Cruise_lvl2_comfort, 4 = Cruise_off_empty_reason, 5 = Cruise_off, 6 = Cruise_Unable_to_set, 7 = Cruise_Unable_to_set_brakes_applied, 8 = Eyesight_not_ready, 9 = Cruise_lvl3_standard, 10 = Cruise_lvl4_dynamic, 11 = Cruise_Unable_to_set_steep_slope"; +CM_ SG_ 801 Cruise_Soft_Disable "Eyesight soft disable (eg direct sunlight)"; +CM_ SG_ 801 Cruise_Status_Msg "1 = Disabled_Bad_Visibility, 2 = Disabled_Check_Manual"; +CM_ SG_ 802 LKAS_ACTIVE "Turns on the full LKAS dash display"; +CM_ SG_ 802 LKAS_Alert_Msg "1 = Keep_Hands_On_Wheel, 6 = Pre_Collision_Braking, 7 = Keep_Hands_On_Wheel_Off"; +CM_ SG_ 802 LKAS_Alert "1 = FCW_Cont_Beep, 2 = FCW_Repeated_Beep, 3 = Throttle_Management_Activated_Warning, 4 = Throttle_Management_Activated_Alert, 5 = Pre_Collision_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, 18 = Keep_Hands_On_Steering_Alert, 24 = Audio_Beep, 25 = Audio_Lead_Car_Change, 26 = Audio_ACC_Disengaged, 27 = Audio_LKAS_disabled, 28 = Audio_Ding_Ding, 30 = Audio_Repeated_Beep"; +CM_ SG_ 802 LKAS_Left_Line_Visible "0 = Off, 1 = White, 2 = Green, 3 = Orange"; +CM_ SG_ 802 LKAS_Dash_State "0 = Off, 1 = Ready, 2 = Active"; +CM_ SG_ 802 LKAS_Right_Line_Visible "0 = Off, 1 = White, 2 = Green, 3 = Orange"; +CM_ SG_ 912 UNITS "0 = Metric, 1 = Imperial"; +CM_ SG_ 912 ICY_ROAD "1 = DASHLIGHT ON, 2 = WARNING, 3 = OFF"; + +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..bea56d5323338b --- /dev/null +++ b/opendbc/subaru_outback_2015_generated.dbc @@ -0,0 +1,280 @@ +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_ Signal1 : 12|2@1+ (1,0) [0|7] "" XXX + SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 15|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_ Signal3 : 31|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 + SG_ Signal4 : 57|7@1+ (1,0) [0|127] "" 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_ Cruise_Fault : 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_ Distance_Swap : 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_ Close_Distance : 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_ Cruise_Fault : 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_ Cruise_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_ 977 Dash_State2: 8 XXX + SG_ UNITS : 15|1@1+ (1,0) [0|1] "" 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 Cruise_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"; +CM_ SG_ 977 UNITS "0 = Metric, 1 = Imperial"; + +VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; + +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_ Cruise_Distance : 21|3@1+ (1,0) [0|7] "" XXX + SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX + SG_ Cruise_Fault : 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_ Car_Follow : 46|1@1+ (1,0) [0|1] "" XXX + SG_ Far_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_ Steer_Error_1 : 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 Cruise_Fault "No engagement until restart"; +CM_ SG_ 358 Car_Follow "lead 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..ba6a9fc310c966 --- /dev/null +++ b/opendbc/subaru_outback_2019_generated.dbc @@ -0,0 +1,280 @@ +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_ Signal1 : 12|2@1+ (1,0) [0|7] "" XXX + SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX + SG_ Signal2 : 15|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_ Signal3 : 31|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 + SG_ Signal4 : 57|7@1+ (1,0) [0|127] "" 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_ Cruise_Fault : 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_ Distance_Swap : 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_ Close_Distance : 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_ Cruise_Fault : 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_ Cruise_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_ 977 Dash_State2: 8 XXX + SG_ UNITS : 15|1@1+ (1,0) [0|1] "" 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 Cruise_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"; +CM_ SG_ 977 UNITS "0 = Metric, 1 = Imperial"; + +VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; + +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_ Cruise_Distance : 21|3@1+ (1,0) [0|7] "" XXX + SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX + SG_ Cruise_Fault : 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_ Car_Follow : 46|1@1+ (1,0) [0|1] "" XXX + SG_ Far_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_ Steer_Error_1 : 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 Cruise_Fault "No engagement until restart"; +CM_ SG_ 358 Car_Follow "lead car detected"; diff --git a/opendbc/tesla_can.dbc b/opendbc/tesla_can.dbc index c257fe2e032f77..cfa86aac1595a5 100644 --- a/opendbc/tesla_can.dbc +++ b/opendbc/tesla_can.dbc @@ -34,14 +34,17 @@ NS_ : BS_: BU_: - NEO - MCU - GTW - EPAS - DI - ESP - SBW - STW + NEO + MCU + GTW + EPAS + DI + ESP + SBW + STW + APP + DAS + XXX VAL_TABLE_ StW_AnglHP_Spd 16383 "SNA" ; VAL_TABLE_ DI_aebFaultReason 15 "DI_AEB_FAULT_DAS_REQ_DI_UNAVAIL" 14 "DI_AEB_FAULT_ACCEL_REQ_INVALID" 13 "DI_AEB_FAULT_MIN_TIME_BTWN_EVENTS" 12 "DI_AEB_FAULT_ESP_MIA" 11 "DI_AEB_FAULT_ESP_FAULT" 10 "DI_AEB_FAULT_EPB_NOT_PARKED" 9 "DI_AEB_FAULT_ACCEL_OUT_OF_BOUNDS" 8 "DI_AEB_FAULT_PM_REQUEST" 7 "DI_AEB_FAULT_VEL_EST_ABNORMAL" 6 "DI_AEB_FAULT_DAS_SNA" 5 "DI_AEB_FAULT_DAS_CONTROL_MIA" 4 "DI_AEB_FAULT_SPEED_DELTA" 3 "DI_AEB_FAULT_EBR_FAULT" 2 "DI_AEB_FAULT_PM_MIA" 1 "DI_AEB_FAULT_EPB_MIA" 0 "DI_AEB_FAULT_NONE" ; @@ -68,6 +71,17 @@ BO_ 1160 DAS_steeringControl: 4 NEO SG_ DAS_steeringAngleRequest : 6|15@0+ (0.1,-1638.35) [-1638.35|1638.35] "deg" EPAS SG_ DAS_steeringHapticRequest : 7|1@0+ (1,0) [0|0] "" EPAS +BO_ 697 DAS_control: 8 NEO + SG_ DAS_setSpeed : 0|12@1+ (0.1,0) [0|409.4] "kph" NEO + SG_ DAS_accState : 12|4@1+ (1,0) [0|0] "" NEO + SG_ DAS_aebEvent : 16|2@1+ (1,0) [0|3] "" NEO + SG_ DAS_jerkMin : 18|9@1+ (0.03,-15.232) [-15.232|0.098] "m/s^3" NEO + SG_ DAS_jerkMax : 27|8@1+ (0.059,0) [0|15.045] "m/s^3" NEO + SG_ DAS_accelMin : 35|9@1+ (0.04,-15) [-15|5.44] "m/s^2" NEO + SG_ DAS_accelMax : 44|9@1+ (0.04,-15) [-15|5.44] "m/s^2" NEO + SG_ DAS_controlCounter : 53|3@1+ (1,0) [0|0] "" NEO + SG_ DAS_controlChecksum : 56|8@1+ (1,0) [0|0] "" NEO + BO_ 257 GTW_epasControl: 3 NEO SG_ GTW_epasControlChecksum : 23|8@0+ (1,0) [0|255] "" NEO SG_ GTW_epasControlCounter : 11|4@0+ (1,0) [0|15] "" NEO @@ -98,7 +112,7 @@ BO_ 3 STW_ANGL_STAT: 8 STW SG_ MC_STW_ANGL_STAT : 55|4@0+ (1,0) [0|15] "" NEO SG_ CRC_STW_ANGL_STAT : 63|8@0+ (1,0) [0|255] "" NEO -BO_ 14 STW_ANGLHP_STAT: 8 STW +BO_ 14 STW_ANGLHP_STAT: 8 STW SG_ StW_AnglHP : 5|14@0+ (0.1,-819.2) [-819.2|819] "deg" NEO SG_ StW_AnglHP_Spd : 21|14@0+ (0.5,-4096) [-4096|4095.5] "deg/s" NEO SG_ StW_AnglHP_Sens_Stat : 33|2@0+ (1,0) [0|0] "" NEO @@ -147,38 +161,48 @@ BO_ 309 ESP_135h: 5 ESP SG_ ESP_espOffLamp : 31|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_stabilityControlSts : 14|3@0+ (1,0) [6|7] "" NEO SG_ ESP_tcLampFlash : 5|1@0+ (1,0) [-1|2] "" NEO - SG_ ESP_tcOffLamp : 15|1@0+ (1,0) [0|1] "" NEO BO_ 341 ESP_B: 8 ESP - SG_ ESP_BChecksum : 39|8@0+ (1,0) [0|255] "" NEO,EPAS - SG_ ESP_BCounter : 62|4@0+ (1,0) [1|15] "" NEO,EPAS - SG_ ESP_vehicleSpeed : 47|16@0+ (0.00999999978,0) [0|0] "kph" NEO,EPAS - SG_ ESP_vehicleSpeedQF : 57|2@0+ (1,0) [1|2] "" NEO,EPAS - SG_ ESP_wheelPulseCountFrL : 7|8@0+ (1,0) [0|254] "" NEO,EPAS - SG_ ESP_wheelPulseCountFrR : 15|8@0+ (1,0) [0|254] "" NEO,EPAS - SG_ ESP_wheelPulseCountReL : 23|8@0+ (1,0) [0|254] "" NEO,EPAS + SG_ ESP_tcOffLamp : 15|1@0+ (1,0) [0|1] "" NEO + +BO_ 341 ESP_B: 8 ESP + SG_ ESP_BChecksum : 39|8@0+ (1,0) [0|255] "" NEO,EPAS + SG_ ESP_BCounter : 62|4@0+ (1,0) [1|15] "" NEO,EPAS + SG_ ESP_vehicleSpeed : 47|16@0+ (0.00999999978,0) [0|0] "kph" NEO,EPAS + SG_ ESP_vehicleSpeedQF : 57|2@0+ (1,0) [1|2] "" NEO,EPAS + SG_ ESP_wheelPulseCountFrL : 7|8@0+ (1,0) [0|254] "" NEO,EPAS + SG_ ESP_wheelPulseCountFrR : 15|8@0+ (1,0) [0|254] "" NEO,EPAS + SG_ ESP_wheelPulseCountReL : 23|8@0+ (1,0) [0|254] "" NEO,EPAS SG_ ESP_wheelPulseCountReR : 31|8@0+ (1,0) [0|254] "" NEO,EPAS -BO_ 532 EPB_epasControl: 3 EPB - SG_ EPB_epasControlChecksum : 23|8@0+ (1,0) [0|255] "" NEO,EPAS - SG_ EPB_epasControlCounter : 11|4@0+ (1,0) [0|15] "" NEO,EPAS +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_ 532 EPB_epasControl: 3 EPB + SG_ EPB_epasControlChecksum : 23|8@0+ (1,0) [0|255] "" NEO,EPAS + SG_ EPB_epasControlCounter : 11|4@0+ (1,0) [0|15] "" NEO,EPAS 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 @@ -271,14 +295,45 @@ 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 MCU - SG_ MCU_gpsHDOP : 0|8@1+ (0.1,0) [0|25.5] "1" NEO - SG_ MCU_gpsVehicleHeading : 8|16@1+ (0.00781,0) [0|511.82835] "deg" NEO - SG_ MCU_gpsVehicleSpeed : 24|16@1+ (0.00391,0) [0|256.24185] "km/hr" NEO - SG_ MCU_mppSpeedLimit : 51|5@1+ (5,0) [0|155] "kph/mph" NEO - SG_ MCU_speedLimitUnits : 41|1@1+ (1,0) [-1|2] "" NEO - SG_ MCU_userSpeedOffset : 42|6@1+ (1,-30) [-30|33] "kph/mph" NEO - SG_ MCU_userSpeedOffsetUnits : 40|1@1+ (1,0) [-1|2] "" NEO +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 + SG_ MCU_parkBrakeRequest : 1|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_trailerModeCH : 3|1@1+ (1,0) [0|0] "" NEO + SG_ MCU_fcwSensitivity : 4|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_fcwEnable : 6|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_latControlEnable : 8|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_accOvertakeEnable : 10|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_ldwEnable : 12|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_aebEnable : 14|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_bsdEnable : 16|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_ahlbEnable : 18|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_parkSetting : 20|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_pedalSafetyEnable : 22|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_frontDefrostReq_das : 24|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_autoParkRequest : 26|4@1+ (1,0) [0|0] "" NEO + SG_ MCU_redLightStopSignEnable : 30|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_enableCreepTorqueCH : 32|1@1+ (1,0) [0|0] "" NEO + SG_ MCU_narrowGarages : 33|1@1+ (1,0) [0|0] "" NEO + SG_ MCU_rebootAutopilot : 34|1@1+ (1,0) [0|0] "" NEO + SG_ MCU_enableAutowipers : 35|1@1+ (1,0) [0|0] "" NEO + SG_ MCU_overPaintedUSS : 38|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_selfParkTune : 40|4@1+ (1,0) [0|15] "" NEO + SG_ MCU_towModeEnable : 44|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_zeroSpeedConfirmed : 46|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_aesEnable : 48|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_autoLaneChangeEnable : 50|2@1+ (1,0) [0|0] "" NEO + SG_ MCU_chassisControlCounter : 52|4@1+ (1,0) [0|0] "" NEO + SG_ MCU_chassisControlChecksum : 56|8@1+ (1,0) [0|0] "" NEO BO_ 904 MCU_clusterBacklightRequest: 3 NEO SG_ MCU_clusterBacklightOn : 7|1@1+ (1,0) [0|1] "" NEO @@ -287,9 +342,13 @@ BO_ 904 MCU_clusterBacklightRequest: 3 NEO SG_ MCU_clusterReadyForPowerOff : 5|1@1+ (1,0) [0|1] "" NEO BO_ 984 MCU_locationStatus: 8 MCU - SG_ MCU_gpsAccuracy : 56|7@1+ (0.200000003,0) [0|25.200000378] "m" NEO - SG_ MCU_latitude : 0|28@1- (1E-006,0) [-134.217727597347|134.217726597347] "deg" NEO - SG_ MCU_longitude : 28|28@1- (1E-006,0) [-268.435455194694|268.435454194694] "deg" NEO + SG_ MCU_gpsAccuracy : 57|7@1+ (0.2,0) [0|0] "m" NEO + SG_ MCU_latitude : 0|28@1- (1E-06,0) [0|0] "deg" NEO + SG_ MCU_longitude : 28|29@1- (1E-06,0) [0|0] "deg" NEO + +BO_ 104 MCU_locationStatus2: 8 MCU + SG_ MCU_elevation : 0|32@1- (0.1,0) [0|0] "m" GTW + SG_ MCU_navigonExpectedSpeed : 32|7@1+ (1,0) [0|126] "mph" GTW BO_ 840 GTW_status: 8 GTW SG_ GTW_accGoingDown : 6|1@0+ (1,0) [0|1] "" NEO @@ -307,7 +366,265 @@ 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 -CM_ "CHFFR_METRIC 1160 DAS_steeringAngleRequest STEER_ANGLE 0.1098666 180; CHFFR_METRIC 264 DI_motorRPM ENGINE_RPM 1 0"; +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 + SG_ GTW_unknown1 : 5|1@0+ (1,0) [0|0] "" NEO + SG_ GTW_dasHw : 7|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_parkAssistInstalled : 9|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_forwardRadarHw : 11|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_airSuspensionInstalled : 14|3@0+ (1,0) [0|0] "" NEO + SG_ GTW_unknown2 : 15|1@0+ (1,0) [0|0] "" NEO + SG_ GTW_country : 23|16@0+ (1,0) [0|0] "" NEO + SG_ GTW_parkSensorGeometryType : 33|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_rhd : 34|1@0+ (1,0) [0|0] "" NEO + SG_ GTW_bodyControlsType : 35|1@0+ (1,0) [0|0] "" NEO + SG_ GTW_radarPosition : 39|4@0+ (1,0) [0|0] "" NEO + SG_ GTW_rearCornerRadarHw : 41|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_frontCornerRadarHw : 43|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_epasType : 45|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_chassisType : 47|2@0+ (1,0) [0|2] "" NEO + SG_ GTW_wheelType : 52|5@0+ (1,0) [0|0] "" NEO + SG_ GTW_rearSeatControllerMask : 55|3@0+ (1,0) [0|7] "" NEO + SG_ GTW_euVehicle : 56|1@0+ (1,0) [0|0] "" NEO + SG_ GTW_foldingMirrorsInstalled : 57|1@0+ (1,0) [0|0] "" NEO + SG_ GTW_brakeHwType : 59|2@0+ (1,0) [0|2] "" NEO + SG_ GTW_autopilot : 61|2@0+ (1,0) [0|0] "" NEO + SG_ GTW_unknown3 : 63|2@0+ (1,0) [0|0] "" NEO + +BO_ 1006 UI_autopilotControl: 8 GTW + SG_ UI_autopilotControlIndex M : 0|3@1+ (1,0) [0|7] "" APP,APS + SG_ UI_hovEnabled m0 : 3|1@1+ (1,0) [0|0] "" APP,APS + SG_ UI_donDisableAutoWiperDuration m0 : 4|3@1+ (1,0) [0|0] "" APP,APS + SG_ UI_donDisableOnAutoWiperSpeed m0 : 7|4@1+ (1,0) [0|0] "" APP,APS + SG_ UI_blindspotMinSpeed m0 : 11|4@1+ (1,0) [0|0] "" APP,APS + SG_ UI_blindspotDistance m0 : 15|3@1+ (1,0) [0|0] "" APP,APS + SG_ UI_blindspotTTC m0 : 18|3@1+ (1,0) [0|0] "" APP,APS + SG_ UI_donStopEndOfRampBuffer m0 : 21|3@1+ (1,0) [0|0] "" APP,APS + SG_ UI_donDisableCutin m0 : 24|1@1+ (1,0) [0|0] "" APP,APS + SG_ UI_donMinGoreWidthForAbortMap m0 : 25|4@1+ (1,0) [0|0] "" APP,APS + SG_ UI_donAlcProgGoreAbortThres m0 : 29|4@1+ (1,0) [0|0] "" APP,APS + SG_ UI_donMinGoreWidthForAbortNotMap m0 : 33|4@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcDisableUltrasonicCheck m0 : 37|1@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcUltrasonicDistance m0 : 38|4@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcUltrasonicWaitTime m0 : 42|3@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcEgoLeadingReactionAccel m0 : 48|2@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcMergIntervalRearDHyst m0 : 50|2@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcMergingIntervalHeadwayHyst m0 : 52|2@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcAssertivenessRate m0 : 54|2@1+ (1,0) [0|0] "" APP,APS + SG_ UI_alcViewRangeSensitivity m0 : 56|2@1+ (1,0) [0|0] "" APP,APS + SG_ UI_camBlockLaneCheckDisable m1 : 3|1@1+ (1,0) [0|0] "" APP,APS + SG_ UI_camBlockLaneCheckThreshold m1 : 4|6@1+ (0.01587,0) [0|1] "%" APP,APS + SG_ UI_camBlockBlurDisable m1 : 10|1@1+ (1,0) [0|0] "" APP,APS + SG_ UI_camBlockBlurThreshold m1 : 11|6@1+ (0.01587,0) [0|1] "%" APP,APS + +BO_ 728 UI_csaOfframpCurvature: 8 GTW + SG_ UI_csaOfframpCurvC2 : 0|16@1- (1E-06,0) [-0.032768|0.032767] "1/m" DAS + SG_ UI_csaOfframpCurvC3 : 16|16@1- (4E-09,0) [-0.000131072|0.000131068] "1/m2" DAS + SG_ UI_csaOfframpCurvRange : 32|8@1+ (2,0) [0|510] "m" DAS + SG_ UI_csaOfframpCurvCounter : 40|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ UI_csaOfframpCurvUsingTspline : 48|1@1+ (1,0) [0|1] "" DAS + SG_ UI_csaOfframpCurvReserved : 49|7@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_csaOfframpCurvChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX + +BO_ 744 UI_csaRoadCurvature: 8 GTW + SG_ UI_csaRoadCurvC2 : 0|16@1- (1E-06,0) [-0.032768|0.032767] "1/m" DAS + SG_ UI_csaRoadCurvC3 : 16|16@1- (4E-09,0) [-0.000131072|0.000131068] "1/m2" DAS + SG_ UI_csaRoadCurvRange : 32|8@1+ (2,0) [0|510] "m" DAS + SG_ UI_csaRoadCurvCounter : 40|8@1+ (1,0) [0|255] "" Vector__XXX + SG_ UI_csaRoadCurvUsingTspline : 48|1@1+ (1,0) [0|1] "" DAS + SG_ UI_csaRoadCurvReserved : 49|7@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_csaRoadCurvChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX + +BO_ 1080 UI_driverAssistAnonDebugParams: 8 GTW + SG_ UI_anonDebugParam1 : 0|7@1+ (1,0) [0|100] "" DAS + SG_ UI_anonDebugFlag1 : 7|1@1+ (1,0) [0|0] "" DAS + SG_ UI_anonDebugParam2 : 8|7@1+ (1,0) [0|100] "" DAS + SG_ UI_anonDebugFlag2 : 15|1@1+ (1,0) [0|0] "" DAS + SG_ UI_anonDebugParam3 : 16|7@1+ (1,0) [0|100] "" DAS + SG_ UI_anonDebugFlag3 : 23|1@1+ (1,0) [0|0] "" DAS + SG_ UI_anonDebugParam4 : 24|7@1+ (1,0) [0|100] "" DAS + SG_ UI_anonDebugFlag4 : 31|1@1+ (1,0) [0|0] "" DAS + SG_ UI_anonDebugParam5 : 32|7@1+ (1,0) [0|100] "" DAS + SG_ UI_anonDebugParam6 : 40|7@1+ (1,0) [0|100] "" DAS + SG_ UI_anonDebugParam7 : 48|7@1+ (1,0) [0|100] "" DAS + SG_ UI_visionSpeedSlider : 56|7@1+ (1,0) [0|100] "" DAS + +BO_ 1000 UI_driverAssistControl: 8 GTW + SG_ UI_autopilotControlRequest : 0|1@1+ (1,0) [1|0] "" DAS + SG_ UI_ulcStalkConfirm : 1|1@1+ (1,0) [1|0] "" DAS + SG_ UI_summonHeartbeat : 2|2@1+ (1,0) [0|0] "" DAS + SG_ UI_curvSpeedAdaptDisable : 4|1@1+ (1,0) [0|0] "" DAS + SG_ UI_dasDeveloper : 5|1@1+ (1,0) [0|0] "" DAS + SG_ UI_enableVinAssociation : 6|1@1+ (1,0) [0|0] "" DAS + SG_ UI_lssLkaEnabled : 7|1@1+ (1,0) [0|0] "" DAS + SG_ UI_lssLdwEnabled : 8|1@1+ (1,0) [0|0] "" DAS + SG_ UI_autoSummonEnable : 10|1@1+ (1,0) [0|1] "" DAS + SG_ UI_exceptionListEnable : 11|1@1+ (1,0) [0|1] "" APP + SG_ UI_roadCheckDisable : 12|1@1+ (1,0) [0|0] "" DAS + SG_ UI_driveOnMapsEnable : 13|1@1+ (1,0) [0|0] "" DAS + SG_ UI_handsOnRequirementDisable : 14|1@1+ (1,0) [0|0] "" DAS + SG_ UI_forksEnable : 15|1@1+ (1,0) [0|0] "" DAS + SG_ UI_fuseLanesDisable : 16|1@1+ (1,0) [0|0] "" DAS + SG_ UI_fuseHPPDisable : 17|1@1+ (1,0) [0|0] "" DAS + SG_ UI_fuseVehiclesDisable : 18|1@1+ (1,0) [0|0] "" DAS + SG_ UI_enableNextGenACC : 19|1@1+ (1,0) [0|1] "" APP + SG_ UI_visionSpeedType : 20|2@1+ (1,0) [0|0] "" APP + SG_ UI_curvatureDatabaseOnly : 22|1@1+ (1,0) [0|0] "" DAS + SG_ UI_lssElkEnabled : 23|1@1+ (1,0) [0|0] "" DAS + SG_ UI_summonExitType : 24|2@1+ (1,0) [0|3] "" DAS + SG_ UI_summonEntryType : 26|2@1+ (1,0) [0|3] "" DAS + SG_ UI_selfParkRequest : 28|4@1+ (1,0) [0|15] "" DAS,PARK + SG_ UI_summonReverseDist : 32|6@1+ (1,0) [0|63] "" DAS + SG_ UI_undertakeAssistEnable : 38|1@1+ (1,0) [0|0] "" DAS + SG_ UI_adaptiveSetSpeedEnable : 39|1@1+ (1,0) [0|0] "" DAS + SG_ UI_drivingSide : 40|2@1+ (1,0) [0|3] "" DAS + SG_ UI_enableClipTelemetry : 42|1@1+ (1,0) [0|0] "" APP + SG_ UI_enableTripTelemetry : 43|1@1+ (1,0) [0|0] "" APP + SG_ UI_enableRoadSegmentTelemetry : 44|1@1+ (1,0) [0|0] "" APP + SG_ UI_followNavRouteEnable : 46|1@1+ (1,0) [0|0] "" APP + SG_ UI_ulcSpeedConfig : 48|2@1+ (1,0) [0|3] "" APP + SG_ UI_ulcBlindSpotConfig : 50|2@1+ (1,0) [0|3] "" APP + SG_ UI_autopilotAlwaysOn : 52|1@1+ (1,0) [0|1] "" APP + SG_ UI_accFromZero : 53|1@1+ (1,0) [0|1] "" APP + SG_ UI_alcOffHighwayEnable : 54|1@1+ (1,0) [0|1] "" APP + SG_ UI_validationLoop : 55|1@1+ (1,0) [0|1] "" APP + SG_ UI_ulcOffHighway : 56|1@1+ (1,0) [0|1] "" APP + SG_ UI_enableNavRouteCSA : 57|1@1+ (1,0) [0|1] "" APP + SG_ UI_enableCutinExperiments : 58|1@1+ (1,0) [0|1] "" APP + SG_ UI_source3D : 60|3@1+ (1,0) [0|7] "" APP + SG_ UI_enableVisionOnlyStops : 63|1@1+ (1,0) [0|1] "" APP + +BO_ 968 UI_driverAssistMapData: 8 GTW + SG_ UI_mapSpeedLimitDependency : 0|3@1+ (1,0) [0|0] "" DAS + SG_ UI_roadClass : 3|3@1+ (1,0) [0|0] "" DAS + SG_ UI_inSuperchargerGeofence : 6|1@1+ (1,0) [0|0] "" DAS + SG_ UI_mapSpeedUnits : 7|1@1+ (1,0) [0|0] "" DAS + SG_ UI_mapSpeedLimit : 8|5@1+ (1,0) [0|0] "" DAS + SG_ UI_mapSpeedLimitType : 13|3@1+ (1,0) [0|0] "" DAS + SG_ UI_countryCode : 16|10@1+ (1,0) [0|0] "" DAS + SG_ UI_streetCount : 26|2@1+ (1,0) [0|0] "" DAS + SG_ UI_gpsRoadMatch : 28|1@1+ (1,0) [0|0] "" DAS + SG_ UI_navRouteActive : 29|1@1+ (1,0) [0|0] "" DAS + SG_ UI_parallelAutoparkEnabled : 30|1@1+ (1,0) [0|1] "" DAS + SG_ UI_perpendicularAutoparkEnabled : 31|1@1+ (1,0) [0|1] "" DAS + SG_ UI_nextBranchDist : 32|5@1+ (10,0) [0|300] "m" DAS + SG_ UI_controlledAccess : 37|1@1+ (1,0) [0|0] "" DAS + SG_ UI_nextBranchLeftOffRamp : 38|1@1+ (1,0) [0|0] "" DAS + SG_ UI_nextBranchRightOffRamp : 39|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectLeftLane : 40|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectRightLane : 41|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectHPP : 42|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectNav : 43|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectLeftFreeSpace : 44|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectRightFreeSpace : 45|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectAutosteer : 46|1@1+ (1,0) [0|0] "" DAS + SG_ UI_rejectHandsOn : 47|1@1+ (1,0) [0|0] "" DAS + SG_ UI_acceptBottsDots : 48|1@1+ (1,0) [0|0] "" DAS + SG_ UI_autosteerRestricted : 49|1@1+ (1,0) [0|0] "" DAS + SG_ UI_pmmEnabled : 50|1@1+ (1,0) [0|0] "" DAS + SG_ UI_scaEnabled : 51|1@1+ (1,0) [0|0] "" DAS + SG_ UI_mapDataCounter : 52|4@1+ (1,0) [0|0] "" DAS + SG_ UI_mapDataChecksum : 56|8@1+ (1,0) [0|0] "" DAS + +BO_ 568 UI_driverAssistRoadSign: 8 GTW + SG_ UI_roadSign M : 0|8@1+ (1,0) [0|0] "" DAS + SG_ UI_splineLocConfidence : 40|7@1+ (1,0) [0|100] "" DAS + SG_ UI_splineID : 48|4@1+ (1,0) [0|15] "" Vector__XXX + SG_ UI_roadSignCounter : 52|4@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_roadSignChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_dummyData m0 : 8|1@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_stopSignStopLineDist m1 : 8|10@1+ (0.25,-8) [-8|247.5] "m" Vector__XXX + SG_ UI_stopSignStopLineConf m1 : 18|7@1+ (1,0) [0|100] "" Vector__XXX + SG_ UI_trafficLightStopLineDist m2 : 8|10@1+ (0.25,-8) [-8|247.5] "m" Vector__XXX + SG_ UI_trafficLightStopLineConf m2 : 18|7@1+ (1,0) [0|100] "" Vector__XXX + SG_ UI_baseMapSpeedLimitMPS m3 : 8|8@1+ (0.25,0) [0|63.75] "m/s" DAS + SG_ UI_bottomQrtlFleetSpeedMPS m3 : 16|8@1+ (0.25,0) [0|63.75] "m/s" DAS + SG_ UI_topQrtlFleetSpeedMPS m3 : 24|8@1+ (0.25,0) [0|63.75] "m/s" DAS + SG_ UI_meanFleetSplineSpeedMPS m4 : 8|8@1+ (0.25,0) [0|63.75] "m/s" DAS + SG_ UI_medianFleetSpeedMPS m4 : 16|8@1+ (0.25,0) [0|63.75] "m/s" DAS + SG_ UI_meanFleetSplineAccelMPS2 m4 : 24|8@1+ (0.05,-6.35) [-6.35|6.4] "m/s^2" DAS + SG_ UI_rampType m4 : 32|3@1+ (1,0) [0|7] "" DAS + SG_ UI_currSplineIdFull m5 : 8|32@1+ (1,0) [0|1] "" APP + + +BO_ 696 UI_radarMapData: 8 GTW + SG_ UI_radarTargetDx : 0|8@1+ (1,-95) [-95|160] "m" DAS + SG_ UI_radarTargetDxEnd : 8|8@1+ (1,0) [0|255] "m" DAS + SG_ UI_radarTargetTrustMap : 16|1@1+ (1,0) [0|1] "" DAS + SG_ UI_radarEnableBraking : 17|1@1+ (1,0) [0|1] "" DAS + SG_ UI_radarMapDataCounter : 52|4@1+ (1,0) [0|0] "" DAS + SG_ UI_radarMapDataChecksum : 56|8@1+ (1,0) [0|0] "" DAS + +BO_ 712 UI_roadCurvature: 8 GTW + SG_ UI_roadCurvC0 : 0|11@1- (0.02,0) [-20.48|20.46] "m" DAS + SG_ UI_roadCurvC1 : 11|10@1- (0.00075,0) [-0.384|0.38325] "1" DAS + SG_ UI_roadCurvC2 : 21|14@1- (7.5E-06,0) [-0.03072|0.03071625] "1/m" DAS + SG_ UI_roadCurvC3 : 35|13@1- (3E-08,0) [-0.00012288|0.00012285] "1/m2" DAS + SG_ UI_roadCurvRange : 48|6@1+ (4,0) [0|252] "m" DAS + SG_ UI_roadCurvHealth : 54|2@1+ (1,0) [0|0] "" DAS + SG_ UI_roadCurvChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX + +BO_ 582 UI_solarData: 5 GTW + SG_ UI_solarAzimuthAngle : 0|16@1- (1,0) [0|360] "deg" APP + SG_ UI_solarAzimuthAngleCarRef : 16|9@1- (1,0) [-180|180] "deg" APP + SG_ UI_isSunUp : 25|1@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_solarElevationAngle : 32|8@1- (1,0) [-90|90] "deg" APP + +BO_ 824 UI_status: 8 GTW + SG_ UI_touchActive : 0|1@1+ (1,0) [0|0] "" IC + SG_ UI_audioActive : 1|1@1+ (1,0) [0|0] "" IC + SG_ UI_bluetoothActive : 2|1@1+ (1,0) [0|0] "" IC + SG_ UI_cellActive : 3|1@1+ (1,0) [0|0] "" IC + SG_ UI_displayReady : 4|1@1+ (1,0) [0|0] "" IC + SG_ UI_gpsActive : 5|1@1+ (1,0) [0|0] "" IC + SG_ UI_wifiConnected : 6|1@1+ (1,0) [0|0] "" IC,APP + SG_ UI_systemActive : 7|1@1+ (1,0) [0|0] "" IC + SG_ UI_xmActive : 8|1@1+ (1,0) [0|0] "" IC + SG_ UI_displayOn : 9|1@1+ (1,0) [0|0] "" IC,APP + SG_ UI_readyForDrive : 10|1@1+ (1,0) [0|0] "" IC + SG_ UI_cellConnected : 11|1@1+ (1,0) [0|0] "" IC,APP + SG_ UI_vpnActive : 12|1@1+ (1,0) [0|0] "" IC,APP + SG_ UI_wifiActive : 13|1@1+ (1,0) [0|0] "" IC + SG_ UI_cameraActive : 14|1@1+ (1,0) [0|0] "" IC,APP + SG_ UI_usbActive : 15|1@1+ (1,0) [0|0] "" IC + SG_ UI_screenshotActive : 16|1@1+ (1,0) [0|0] "" IC,APP + SG_ UI_monitorModemPower : 17|1@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_factoryReset : 18|2@1+ (1,0) [0|3] "" Vector__XXX + SG_ UI_cellNetworkTechnology : 20|4@1+ (1,0) [0|15] "" APP + SG_ UI_tegraCoreTemperature : 24|8@1+ (1,-64) [0|0] "deg C" IC + SG_ UI_tegraAmbientTemperature : 32|8@1+ (1,-64) [0|0] "deg C" IC + SG_ UI_googleWifiUsages : 40|8@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_autopilotTrial : 48|2@1+ (1,0) [0|0] "" APP + SG_ UI_cellSignalBars : 50|3@1+ (1,0) [0|7] "" APP + SG_ UI_hardwareType : 53|2@1+ (1,0) [0|3] "" APP + SG_ UI_developmentCar : 55|1@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_cellReceiverPower : 56|8@1+ (1,-128) [-128|127] "dB" APP + +BO_ 1064 UI_telemetryControl: 8 GTW + SG_ UI_TCR_enable : 0|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_moveStateStanding : 1|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_moveStateStopped : 2|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_moveStateMoving : 3|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_moveStateIndeterm : 4|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_classConstElem : 5|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_classMovingPed : 6|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_classMovingTwoWheel : 7|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_classMovingFourWheel : 8|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_classUnknown : 9|1@1+ (1,0) [0|0] "" DAS + SG_ UI_TCR_downSampleFactor : 16|4@1+ (1,0) [0|15] "" Vector__XXX + SG_ UI_TCR_wExist : 24|5@1+ (1,0) [0|31] "" Vector__XXX + SG_ UI_TCR_vehSpeed : 32|8@1+ (1,0) [0|0] "" Vector__XXX + SG_ UI_TCR_minRCS : 40|8@1+ (0.25,-14) [-14|49.75] "dB" Vector__XXX + SG_ UI_TCR_maxDy : 48|5@1+ (0.5,0) [0|15.5] "m" Vector__XXX + SG_ UI_TCR_maxObjects : 56|5@1+ (1,0) [0|31] "" Vector__XXX + SG_ UI_TCR_maxRoadClass : 61|3@1+ (1,0) [0|7] "" Vector__XXX + +BO_ 522 BrakeMessage: 8 XXX + SG_ driverBrakeStatus : 2|2@1+ (1,0) [0|3] "" XXX + +BO_ 921 AutopilotStatus: 8 XXX + SG_ autopilotStatus : 0|4@1+ (1,0) [0|0] "" XXX VAL_ 3 StW_Angl 16383 "SNA" ; VAL_ 3 StW_AnglSens_Id 2 "MUST" 0 "PSBL" 1 "SELF" ; @@ -364,8 +681,10 @@ 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_ 522 driverBrakeStatus 2 "APPLIED" 1 "NOT_APPLIED" ; +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" ; @@ -382,6 +701,13 @@ 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_ 697 DAS_setSpeed 4095 "SNA" ; +VAL_ 697 DAS_accState 15 "FAULT_SNA" 13 "ACC_CANCEL_GENERIC_SILENT" 11 "APC_SELFPARK_START" 10 "APC_UNPARK_COMPLETE" 9 "APC_PAUSE" 8 "APC_ABORT" 7 "APC_COMPLETE" 6 "APC_FORWARD" 5 "APC_BACKWARD" 4 "ACC_ON" 3 "ACC_HOLD" 0 "ACC_CANCEL_GENERIC" ; +VAL_ 697 DAS_aebEvent 3 "AEB_SNA" 2 "AEB_FAULT" 1 "AEB_ACTIVE" 0 "AEB_NOT_ACTIVE" ; +VAL_ 697 DAS_jerkMin 511 "SNA" ; +VAL_ 697 DAS_jerkMax 255 "SNA" ; +VAL_ 697 DAS_accelMin 511 "SNA" ; +VAL_ 697 DAS_accelMax 511 "SNA" ; VAL_ 792 BOOT_STATE 2 "Init" 3 "SNA" 0 "closed" 1 "open" ; VAL_ 792 CERRD 1 "CAN error detect" 0 "no Can error detected" ; VAL_ 792 DAY 1 "Init" 0 "SNA" ; @@ -416,6 +742,9 @@ VAL_ 880 EPAS_steeringRackForce 1022 "NOT_IN_SPEC" 1023 "SNA" ; VAL_ 880 EPAS_steeringReduced 0 "NORMAL_ASSIST" 1 "REDUCED_ASSIST" ; VAL_ 880 EPAS_torsionBarTorque 0 "SEE_SPECIFICATION" 4095 "SNA" 4094 "UNDEFINABLE_DATA" ; VAL_ 904 MCU_clusterReadyForDrive 0 "NO_SNA" 1 "YES" ; +VAL_ 921 autopilotStatus 5 "ACTIVE_NAVIGATE_ON_AUTOPILOT" 4 "ACTIVE_2" 3 "ACTIVE_1" 2 "AVAILABLE" 1 "UNAVAILABLE" 0 "DISABLED" ; 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" ; + + diff --git a/opendbc/tesla_powertrain.dbc b/opendbc/tesla_powertrain.dbc new file mode 100644 index 00000000000000..8572ee20f4fd3d --- /dev/null +++ b/opendbc/tesla_powertrain.dbc @@ -0,0 +1,179 @@ +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_: + NEO + MCU + GTW + EPAS + DI + ESP + SBW + STW + APP + DAS + XXX + +BO_ 262 DI_torque1: 8 DI + SG_ DI_torqueDriver : 0|13@1- (0.25,0) [-750|750] "Nm" NEO + SG_ DI_torque1Counter : 13|3@1+ (1,0) [0|0] "" NEO + SG_ DI_torqueMotor : 16|13@1- (0.25,0) [-750|750] "Nm" NEO + SG_ DI_soptState : 29|3@1+ (1,0) [0|0] "" NEO + SG_ DI_motorRPM : 32|16@1- (1,0) [-17000|17000] "RPM" NEO + SG_ DI_pedalPos : 48|8@1+ (0.4,0) [0|100] "%" NEO + SG_ DI_torque1Checksum : 56|8@1+ (1,0) [0|0] "" NEO + +BO_ 278 DI_torque2: 6 DI + SG_ DI_torqueEstimate : 0|12@1- (0.5,0) [-750|750] "Nm" NEO + SG_ DI_gear : 12|3@1+ (1,0) [0|0] "" NEO + SG_ DI_brakePedal : 15|1@1+ (1,0) [0|0] "" NEO + SG_ DI_vehicleSpeed : 16|12@1+ (0.05,-25) [-25|179.75] "MPH" NEO + SG_ DI_gearRequest : 28|3@1+ (1,0) [0|0] "" NEO + SG_ DI_torqueInterfaceFailure : 31|1@1+ (1,0) [0|0] "" NEO + SG_ DI_torque2Counter : 32|4@1+ (1,0) [0|0] "" NEO + SG_ DI_brakePedalState : 36|2@1+ (1,0) [0|0] "" NEO + SG_ DI_epbParkRequest : 38|1@1+ (1,0) [0|0] "" NEO + SG_ DI_epbInterfaceReady : 39|1@1+ (1,0) [0|0] "" NEO + SG_ DI_torque2Checksum : 40|8@1+ (1,0) [0|0] "" NEO + +BO_ 504 BrakeMessage: 8 XXX + SG_ driverBrakeStatus : 2|2@1+ (1,0) [0|3] "" XXX + +BO_ 568 STW_ACTN_RQ: 8 STW + SG_ SpdCtrlLvr_Stat : 0|6@1+ (1,0) [0|0] "" NEO + SG_ VSL_Enbl_Rq : 6|1@1+ (1,0) [0|0] "" NEO + SG_ SpdCtrlLvrStat_Inv : 7|1@1+ (1,0) [0|0] "" NEO + SG_ DTR_Dist_Rq : 8|8@1+ (1,0) [0|200] "" NEO + SG_ TurnIndLvr_Stat : 16|2@1+ (1,0) [0|0] "" NEO + SG_ HiBmLvr_Stat : 18|2@1+ (1,0) [0|0] "" NEO + SG_ WprWashSw_Psd : 20|2@1+ (1,0) [0|0] "" NEO + SG_ WprWash_R_Sw_Posn_V2 : 22|2@1+ (1,0) [0|0] "" NEO + SG_ StW_Lvr_Stat : 24|3@1+ (1,0) [0|0] "" NEO + SG_ StW_Cond_Flt : 27|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Cond_Psd : 28|2@1+ (1,0) [0|0] "" NEO + SG_ HrnSw_Psd : 30|2@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw00_Psd : 32|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw01_Psd : 33|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw02_Psd : 34|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw03_Psd : 35|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw04_Psd : 36|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw05_Psd : 37|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw06_Psd : 38|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw07_Psd : 39|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw08_Psd : 40|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw09_Psd : 41|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw10_Psd : 42|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw11_Psd : 43|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw12_Psd : 44|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw13_Psd : 45|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw14_Psd : 46|1@1+ (1,0) [0|0] "" NEO + SG_ StW_Sw15_Psd : 47|1@1+ (1,0) [0|0] "" NEO + SG_ WprSw6Posn : 48|3@1+ (1,0) [0|0] "" NEO + SG_ MC_STW_ACTN_RQ : 52|4@1+ (1,0) [0|15] "" NEO + SG_ CRC_STW_ACTN_RQ : 56|8@1+ (1,0) [0|0] "" NEO + +BO_ 598 DI_state: 8 DI + SG_ DI_systemState : 0|3@1+ (1,0) [0|0] "" NEO + SG_ DI_vehicleHoldState : 3|3@1+ (1,0) [0|0] "" NEO + SG_ DI_proximity : 6|1@1+ (1,0) [0|0] "" NEO + SG_ DI_driveReady : 7|1@1+ (1,0) [0|0] "" NEO + SG_ DI_regenLight : 8|1@1+ (1,0) [0|0] "" NEO + SG_ DI_state : 9|3@1+ (1,0) [0|0] "" NEO + SG_ DI_cruiseState : 12|4@1+ (1,0) [0|0] "" NEO + SG_ DI_analogSpeed : 16|12@1+ (0.1,0) [0|150] "speed" NEO + SG_ DI_immobilizerState : 28|3@1+ (1,0) [0|0] "" NEO + SG_ DI_speedUnits : 31|1@1+ (1,0) [0|1] "" NEO + SG_ DI_cruiseSet : 32|9@1+ (0.5,0) [0|255.5] "speed" NEO + SG_ DI_aebState : 41|3@1+ (1,0) [0|0] "" NEO + SG_ DI_stateCounter : 44|4@1+ (1,0) [0|0] "" NEO + SG_ DI_digitalSpeed : 48|8@1+ (1,0) [0|250] "" NEO + SG_ DI_stateChecksum : 56|8@1+ (1,0) [0|0] "" NEO + +BO_ 703 DAS_control: 8 GTW + SG_ DAS_setSpeed : 0|12@1+ (0.1,0) [0|409.4] "kph" DI,PM,APS + SG_ DAS_accState : 12|4@1+ (1,0) [0|0] "" DI,PM,APS + SG_ DAS_aebEvent : 16|2@1+ (1,0) [0|3] "" DI,PM,APS + SG_ DAS_jerkMin : 18|9@1+ (0.03,-15.232) [-15.232|0.098] "m/s^3" DI,PM,APS + SG_ DAS_jerkMax : 27|8@1+ (0.059,0) [0|15.045] "m/s^3" DI,PM,APS + SG_ DAS_accelMin : 35|9@1+ (0.04,-15) [-15|5.44] "m/s^2" DI,PM,APS + SG_ DAS_accelMax : 44|9@1+ (0.04,-15) [-15|5.44] "m/s^2" DI,PM,APS + SG_ DAS_controlCounter : 53|3@1+ (1,0) [0|0] "" DI,PM,APS + SG_ DAS_controlChecksum : 56|8@1+ (1,0) [0|0] "" DI,PM,APS + +VAL_ 262 DI_torqueDriver -4096 "SNA" ; +VAL_ 262 DI_torqueMotor -4096 "SNA" ; +VAL_ 262 DI_soptState 7 "SOPT_TEST_SNA" 4 "SOPT_TEST_NOT_RUN" 3 "SOPT_TEST_PASSED" 2 "SOPT_TEST_FAILED" 1 "SOPT_TEST_IN_PROGRESS" 0 "SOPT_PRE_TEST" ; +VAL_ 262 DI_motorRPM -32768 "SNA" ; +VAL_ 262 DI_pedalPos 255 "SNA" ; +VAL_ 278 DI_torqueEstimate -2048 "SNA" ; +VAL_ 278 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" ; +VAL_ 278 DI_brakePedal 1 "Applied" 0 "Not_applied" ; +VAL_ 278 DI_vehicleSpeed 4095 "SNA" ; +VAL_ 278 DI_gearRequest 7 "DI_GEAR_SNA" 4 "DI_GEAR_D" 3 "DI_GEAR_N" 2 "DI_GEAR_R" 1 "DI_GEAR_P" 0 "DI_GEAR_INVALID" ; +VAL_ 278 DI_torqueInterfaceFailure 1 "TORQUE_INTERFACE_FAILED" 0 "TORQUE_INTERFACE_NORMAL" ; +VAL_ 278 DI_brakePedalState 3 "SNA" 2 "INVALID" 1 "ON" 0 "OFF" ; +VAL_ 278 DI_epbParkRequest 1 "Park_requested" 0 "No_request" ; +VAL_ 278 DI_epbInterfaceReady 1 "EPB_INTERFACE_READY" 0 "EPB_INTERFACE_NOT_READY" ; +VAL_ 504 driverBrakeStatus 2 "APPLIED" 1 "NOT_APPLIED" ; +VAL_ 568 SpdCtrlLvr_Stat 32 "DN_1ST" 16 "UP_1ST" 8 "DN_2ND" 4 "UP_2ND" 2 "RWD" 1 "FWD" 0 "IDLE" ; +VAL_ 568 DTR_Dist_Rq 255 "SNA" 200 "ACC_DIST_7" 166 "ACC_DIST_6" 133 "ACC_DIST_5" 100 "ACC_DIST_4" 66 "ACC_DIST_3" 33 "ACC_DIST_2" 0 "ACC_DIST_1" ; +VAL_ 568 TurnIndLvr_Stat 3 "SNA" 2 "RIGHT" 1 "LEFT" 0 "IDLE" ; +VAL_ 568 HiBmLvr_Stat 3 "SNA" 2 "HIBM_FLSH_ON_PSD" 1 "HIBM_ON_PSD" 0 "IDLE" ; +VAL_ 568 WprWashSw_Psd 3 "SNA" 2 "WASH" 1 "TIPWIPE" 0 "NPSD" ; +VAL_ 568 WprWash_R_Sw_Posn_V2 3 "SNA" 2 "WASH" 1 "INTERVAL" 0 "OFF" ; +VAL_ 568 StW_Lvr_Stat 4 "STW_BACK" 3 "STW_FWD" 2 "STW_DOWN" 1 "STW_UP" 0 "NPSD" ; +VAL_ 568 StW_Cond_Psd 3 "SNA" 2 "DOWN" 1 "UP" 0 "NPSD" ; +VAL_ 568 HrnSw_Psd 3 "SNA" 2 "NDEF2" 1 "PSD" 0 "NPSD" ; +VAL_ 568 StW_Sw00_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; +VAL_ 568 StW_Sw01_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; +VAL_ 568 StW_Sw03_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; +VAL_ 568 StW_Sw04_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; +VAL_ 568 WprSw6Posn 7 "SNA" 6 "STAGE2" 5 "STAGE1" 4 "INTERVAL4" 3 "INTERVAL3" 2 "INTERVAL2" 1 "INTERVAL1" 0 "OFF" ; +VAL_ 598 DI_aebState 2 "ENABLED" 4 "FAULT" 7 "SNA" 1 "STANDBY" 3 "STANDSTILL" 0 "UNAVAILABLE" ; +VAL_ 598 DI_analogSpeed 4095 "SNA" ; +VAL_ 598 DI_cruiseState 2 "ENABLED" 5 "FAULT" 0 "OFF" 4 "OVERRIDE" 7 "PRE_CANCEL" 6 "PRE_FAULT" 1 "STANDBY" 3 "STANDSTILL" ; +VAL_ 598 DI_digitalSpeed 255 "SNA" ; +VAL_ 598 DI_immobilizerState 2 "AUTHENTICATING" 3 "DISARMED" 6 "FAULT" 4 "IDLE" 0 "INIT_SNA" 1 "REQUEST" 5 "RESET" ; +VAL_ 598 DI_speedUnits 1 "KPH" 0 "MPH" ; +VAL_ 598 DI_state 3 "ABORT" 4 "ENABLE" 2 "FAULT" 1 "STANDBY" 0 "UNAVAILABLE" ; +VAL_ 598 DI_systemState 3 "ABORT" 4 "ENABLE" 2 "FAULT" 1 "STANDBY" 0 "UNAVAILABLE" ; +VAL_ 598 DI_vehicleHoldState 2 "BLEND_IN" 4 "BLEND_OUT" 6 "FAULT" 7 "INIT" 5 "PARK" 1 "STANDBY" 3 "STANDSTILL" 0 "UNAVAILABLE" ; +VAL_ 703 DAS_setSpeed 4095 "SNA" ; +VAL_ 703 DAS_accState 15 "FAULT_SNA" 13 "ACC_CANCEL_GENERIC_SILENT" 11 "APC_SELFPARK_START" 10 "APC_UNPARK_COMPLETE" 9 "APC_PAUSE" 8 "APC_ABORT" 7 "APC_COMPLETE" 6 "APC_FORWARD" 5 "APC_BACKWARD" 4 "ACC_ON" 3 "ACC_HOLD" 0 "ACC_CANCEL_GENERIC" ; +VAL_ 703 DAS_aebEvent 3 "AEB_SNA" 2 "AEB_FAULT" 1 "AEB_ACTIVE" 0 "AEB_NOT_ACTIVE" ; +VAL_ 703 DAS_jerkMin 511 "SNA" ; +VAL_ 703 DAS_jerkMax 255 "SNA" ; +VAL_ 703 DAS_accelMin 511 "SNA" ; +VAL_ 703 DAS_accelMax 511 "SNA" ; \ No newline at end of file diff --git a/opendbc/toyota_avalon_2017_pt_generated.dbc b/opendbc/toyota_avalon_2017_pt_generated.dbc index c93250fab2e64b..901616d585e6a5 100644 --- a/opendbc/toyota_avalon_2017_pt_generated.dbc +++ b/opendbc/toyota_avalon_2017_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_avalon_2017_pt.dbc starts here"; @@ -313,6 +431,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 5578b706378ae1..55ebbb6a4ec6ad 100644 --- a/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc +++ b/opendbc/toyota_camry_hybrid_2018_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_camry_hybrid_2018_pt.dbc starts here"; @@ -318,7 +436,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 c24428f342b855..5fa0e83994873d 100644 --- a/opendbc/toyota_corolla_2017_pt_generated.dbc +++ b/opendbc/toyota_corolla_2017_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_corolla_2017_pt.dbc starts here"; @@ -308,10 +426,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 d9962c09beed4d..6745ef9a064c0f 100644 --- a/opendbc/toyota_highlander_2017_pt_generated.dbc +++ b/opendbc/toyota_highlander_2017_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_highlander_2017_pt.dbc starts here"; @@ -313,6 +431,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 d7c53cde7a4003..c8870edfdd65bc 100644 --- a/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc +++ b/opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_highlander_hybrid_2018_pt.dbc starts here"; @@ -312,6 +430,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 0e2bbb3141c932..8102d48cc2c311 100644 --- a/opendbc/toyota_nodsu_hybrid_pt_generated.dbc +++ b/opendbc/toyota_nodsu_hybrid_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,85 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + + +CM_ "Imported file _toyota_nodsu_common.dbc starts here"; +BO_ 401 STEERING_LTA: 8 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.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_ 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_ "toyota_nodsu_hybrid_pt.dbc starts here"; + @@ -318,7 +467,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 d9e343f6a0f5a8..58ca9c51aa9888 100644 --- a/opendbc/toyota_nodsu_pt_generated.dbc +++ b/opendbc/toyota_nodsu_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,26 +366,87 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + + +CM_ "Imported file _toyota_nodsu_common.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_ 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_ "toyota_nodsu_pt.dbc starts here"; + + + BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX @@ -324,7 +462,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 56c1e5f856001d..c3857583c4e721 100644 --- a/opendbc/toyota_prius_2017_pt_generated.dbc +++ b/opendbc/toyota_prius_2017_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_prius_2017_pt.dbc starts here"; @@ -318,6 +436,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 e507f13cdf10bd..f70b869824b456 100644 --- a/opendbc/toyota_rav4_2017_pt_generated.dbc +++ b/opendbc/toyota_rav4_2017_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_rav4_2017_pt.dbc starts here"; @@ -312,6 +430,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 228d8f1b270bad..e6345fa8c46afd 100644 --- a/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc +++ b/opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_rav4_hybrid_2017_pt.dbc starts here"; @@ -312,6 +430,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 1d4786f869e4f8..9141a34b0a95da 100644 --- a/opendbc/toyota_sienna_xle_2018_pt_generated.dbc +++ b/opendbc/toyota_sienna_xle_2018_pt_generated.dbc @@ -1,37 +1,7 @@ -CM_ "AUTOGENERATED FILE, DO NOT EDIT" +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" +CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" @@ -67,11 +37,11 @@ NS_ : BS_: -BU_: XXX DSU HCU EPS IPAS +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,18 +61,22 @@ 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 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 @@ -128,7 +102,16 @@ BO_ 614 STEERING_IPAS: 8 IPAS SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX -BO_ 643 PRE_COLLISION: 8 XXX +BO_ 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 @@ -145,14 +128,30 @@ BO_ 742 LEAD_INFO: 8 DSU 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_ ACC_MALFUNCTION : 18|1@0+ (1,0) [0|0] "" XXX + SG_ ACC_CUT_IN : 25|1@0+ (1,0) [0|1] "" XXX + SG_ ALLOW_LONG_PRESS : 17|2@0+ (1,0) [0|2] "" XXX + SG_ ACC_TYPE : 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_ 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 + SG_ RADAR_DIRTY : 19|1@0+ (1,0) [0|1] "" 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 @@ -162,13 +161,21 @@ 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 + SG_ BRAKE_HOLD_ENABLED : 33|1@1+ (1,0) [0|1] "" XXX + SG_ BRAKE_HOLD_ACTIVE : 36|1@0+ (1,0) [0|1] "" XXX + +BO_ 1020 SOLAR_SENSOR: 8 XXX + SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU + SG_ PCS_INDICATOR : 7|2@0+ (1,0) [0|3] "" XXX 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 + SG_ PCS_OFF : 40|1@0+ (1,0) [0|0] "" XXX + SG_ PCS_SENSITIVITY : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX @@ -186,13 +193,51 @@ 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_ 1553 UI_SEETING: 8 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 + SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX + SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX + SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" 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 @@ -201,6 +246,11 @@ BO_ 1568 SEATS_DOORS: 8 XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX + SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX + SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX + SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX + SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX + SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX @@ -244,25 +294,44 @@ BO_ 1163 RSA3: 8 FCM SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX +BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW + SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX + SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@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_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; +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 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; +CM_ SG_ 835 RADAR_DIRTY "Display Clean Radar Sensor message on HUD"; +CM_ SG_ 835 ACC_MALFUNCTION "display ACC fault on dash if set to 1"; +CM_ SG_ 835 ACC_CUT_IN "Display blinking yellow lead if set to 1"; +CM_ SG_ 835 DISTANCE "Display Distance Bars on HUD Permanently"; +CM_ SG_ 835 ALLOW_LONG_PRESS "Enable Toyota's factory set speed increment behaviour, available on both metrics cars and imperial unit cars"; +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_ 1041 PCS_INDICATOR "Pre-Collision System Indicator"; +CM_ SG_ 1041 PCS_SENSITIVITY "Pre-Collision System Sensitivity"; 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"; @@ -274,12 +343,20 @@ 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"; +CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; -VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off"; +VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "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_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; +VAL_ 835 ACC_MALFUNCTION 1 "faulted" 0 "ok"; +VAL_ 835 ACC_CUT_IN 1 "CUT-IN Detected" 0 "clear"; +VAL_ 835 ALLOW_LONG_PRESS 2 "set speed increase by 5 speed units regardless" 1 "set speed increase by 1 speed unit on short press, 5 speed units on long press"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; +VAL_ 1041 PCS_INDICATOR 2 "PCS Faulted" 1 "PCS Turned Off By User" 0 "PCS Enabled"; +VAL_ 1041 PCS_SENSITIVITY 64 "high sensitivity" 128 "mid sensitivity" 192 "low sensitivity" 0 "off"; 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"; @@ -289,13 +366,54 @@ 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 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" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; 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_ "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"; + +BO_ 767 SDSU: 8 XXX + SG_ FD_BUTTON : 7|1@0+ (1,0) [0|1] "" XXX + +CM_ "BO_ SDSU: The sDSU is a modified DSU for use in TSS1 Toyotas. Learn more: https://github.com/wocsor/panda/tree/smart_dsu"; + +CM_ SG_ 767 FD_BUTTON "The follow distance button signal as forwarded by the sdsu"; + +CM_ "toyota_sienna_xle_2018_pt.dbc starts here"; @@ -313,6 +431,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..2302035d8d04e8 100644 --- a/opendbc/vw_mqb_2010.dbc +++ b/opendbc/vw_mqb_2010.dbc @@ -33,12 +33,12 @@ NS_ : BS_: -BU_: Airbag_MQB BAP_Tester_MQB BMS_MQB Datenlogger_MQB Gateway_MQB Getriebe_DQ_Hybrid_MQB Getriebe_DQ_MQB LEH_MQB Motor_Diesel_MQB Motor_Hybrid_MQB Motor_Otto_MQB SAK_MQB Waehlhebel_MQB Vector__XXX 9 l c i XXX +BU_: Airbag_MQB BAP_Tester_MQB BMS_MQB Datenlogger_MQB Gateway_MQB Getriebe_DQ_Hybrid_MQB Getriebe_DQ_MQB LEH_MQB Motor_Diesel_MQB Motor_Hybrid_MQB Motor_Otto_MQB SAK_MQB Waehlhebel_MQB Vector__XXX l c i XXX 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 - -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_ 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_ 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 LH_EPS_03: 8 XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX + SG_ EPS_DSR_Status : 12|4@1+ (1,0) [0|15] "" XXX + SG_ EPS_Berechneter_LW : 16|12@1+ (0.15,0) [0|613.95] "Unit_DegreOfArc" XXX + SG_ EPS_BLW_QBit : 30|1@1+ (1,0) [0|1] "" XXX + SG_ EPS_VZ_BLW : 31|1@1+ (1,0) [0|1] "" XXX + SG_ EPS_HCA_Status : 32|4@1+ (1,0) [0|15] "" XXX + SG_ EPS_Lenkmoment : 40|10@1+ (1,0) [0|8] "Unit_centiNewtoMeter" XXX + SG_ EPS_Lenkmoment_QBit : 54|1@1+ (1,0) [0|1] "" XXX + SG_ EPS_VZ_Lenkmoment : 55|1@1+ (1,0) [0|1] "" XXX + SG_ EPS_Lenkungstyp : 60|4@1+ (1,0) [0|15] "" XXX BO_ 286 VehicleSpeed: 8 XXX SG_ VehicleSpeed_CRC : 0|8@1+ (1,0) [0|255] "" XXX @@ -1188,38 +1213,57 @@ BO_ 286 VehicleSpeed: 8 XXX SG_ Speed : 52|12@1+ (0.125,0) [0|1] "" 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_ Alert_Message : 16|4@1+ (1,0) [0|15] "" XXX - SG_ LDW_Direction : 20|1@0+ (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_ LDW_Gong : 12|2@1+ (1,0) [0|3] "" XXX + SG_ LDW_SW_Warnung_links : 14|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_SW_Warnung_rechts : 15|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_Texte : 16|4@1+ (1,0) [0|15] "" XXX + SG_ LDW_Seite_DLCTLC : 20|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_Lernmodus : 21|3@1+ (1,0) [0|7] "" XXX + SG_ LDW_Anlaufsp_VLR : 24|4@1+ (1,0) [0|15] "" XXX + SG_ LDW_Vib_Amp_VLR : 28|4@1+ (1,0) [0|15] "" XXX + SG_ LDW_Anlaufzeit_VLR : 32|4@1+ (1,0) [0|15] "" XXX + SG_ LDW_Lernmodus_rechts : 36|2@1+ (1,0) [0|3] "" XXX + SG_ LDW_Lernmodus_links : 38|2@1+ (1,0) [0|3] "" XXX + SG_ LDW_DLC : 40|8@1+ (0.01,-1.25) [-1.25|1.25] "Unit_Meter" XXX + SG_ LDW_TLC : 48|5@1+ (0.1,0) [0|3] "Unit_Secon" XXX + SG_ LDW_Warnung_links : 56|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_Warnung_rechts : 57|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_Codierinfo_fuer_VLR : 58|2@1+ (1,0) [0|3] "" XXX + SG_ LDW_Frontscheibenheizung_aktiv : 60|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_Status_LED_gelb : 61|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_Status_LED_gruen : 62|1@1+ (1,0) [0|1] "" XXX + SG_ LDW_KD_Fehler : 63|1@1+ (1,0) [0|1] "" XXX BO_ 780 ACC_02: 8 XXX - SG_ Kollision1 : 23|1@1+ (1,0) [0|1] "" 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 - SG_ MotorbitB5_1 : 41|1@1+ (1,0) [0|1] "" XXX - SG_ 1_aktivieren : 42|1@1+ (1,0) [0|1] "" XXX - SG_ Tacho_LED : 43|1@1+ (1,0) [0|1] "" XXX - SG_ Hebelquit : 44|1@1+ (1,0) [0|1] "" XXX - SG_ 1_aktivieren_inv : 45|1@1+ (1,0) [0|1] "" XXX - SG_ Folgefahrt : 46|1@1+ (1,0) [0|1] "" 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 + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX + SG_ ACC_Wunschgeschw : 12|10@1+ (0.32,0) [0.00|326.72] "Unit_KiloMeterPerHour" XXX + SG_ ACC_Status_Prim_Anz : 22|2@1+ (1.0,0.0) [0.0|3] "" XXX + SG_ ACC_Abstandsindex : 24|10@1+ (1,0) [1|1021] "" XXX + SG_ ACC_Akustik : 34|3@1+ (1.0,0.0) [0.0|7] "" XXX + SG_ ACC_Gesetzte_Zeitluecke : 37|3@1+ (1.0,0.0) [0.0|7] "" XXX + SG_ ACC_Optischer_Fahrerhinweis : 40|1@1+ (1.0,0.0) [0.0|1] "" XXX + SG_ ACC_Typ_Tachokranz : 41|1@1+ (1.0,0.0) [0.0|1] "" XXX + SG_ ACC_Anzeige_Zeitluecke : 42|1@1+ (1.0,0.0) [0.0|1] "" XXX + SG_ ACC_Tachokranz : 43|1@1+ (1.0,0.0) [0.0|1] "" XXX + SG_ ACC_Display_Prio : 44|2@1+ (1.0,0.0) [0.0|3] "" XXX + SG_ ACC_Relevantes_Objekt : 46|2@1+ (1.0,0.0) [0.0|3] "" XXX + SG_ ACC_Texte_Primaeranz : 48|7@1+ (1.0,0.0) [0.0|127] "" XXX + SG_ ACC_Wunschgeschw_erreicht : 55|1@1+ (1.0,0.0) [0.0|1] "" XXX + SG_ ACC_Status_Anzeige : 61|3@1+ (1.0,0.0) [0.0|7] "" XXX BO_ 302 ACC_07: 8 XXX - SG_ ACC_07_BZ : 8|4@1+ (1,0) [0|15] "" XXX - SG_ ACC_07_CRC : 0|8@1+ (1,0) [0|255] "" XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX + SG_ ACC_Distance_to_Stop : 12|11@1+ (0.01,0) [0|1] "m" XXX + SG_ ACC_Hold_Request : 23|1@1+ (1,0) [0|1] "x" XXX + SG_ ACC_Boost_Request : 24|1@1+ (1,0) [0|1] "" XXX + SG_ ACC_Freewheel_Request : 25|1@1+ (1,0) [0|1] "" XXX + SG_ ACC_Freewheel_Type : 26|2@1+ (1,0) [0|3] "enum" XXX + SG_ ACC_Hold_Type : 28|3@1+ (1,0) [0|15] "enum" XXX + SG_ ACC_Hold_Release : 31|1@1+ (1,0) [0|1] "" XXX + SG_ ACC_Accel_Secondary : 32|8@1+ (0.03,-4.6) [-4.6|2.99] "m/s2" XXX + SG_ ACC_Accel_TSK : 53|11@1+ (0.005,-7.22) [-7.22|3.005] "m/s2" XXX BO_ 264 Fahrwerk_01: 8 XXX SG_ Fahrwerk_01_BZ : 8|4@1+ (1,0) [0|15] "" XXX @@ -1229,13 +1273,39 @@ 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 - SG_ ACC_04_BZ : 8|4@1+ (1,0) [0|15] "" XXX + SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX + SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX + SG_ ACC_Texte_Zusatzanz : 16|6@1+ (1.0,0.0) [0.0|63] "" XXX + SG_ ACC_Status_Zusatzanz : 22|5@1+ (1.0,0.0) [0.0|31] "" XXX + SG_ ACC_Texte : 27|5@1+ (1.0,0.0) [0.0|31] "" XXX + SG_ ACC_Texte_braking_guard : 32|3@1+ (1.0,0.0) [0.0|7] "" XXX + SG_ ACC_Warnhinweis : 35|1@1+ (1.0,0.0) [0.0|1] "" XXX + SG_ ACC_Geschw_Zielfahrzeug : 40|10@1+ (0.32,0) [0.00|326.72] "Unit_KiloMeterPerHour" XXX + SG_ ACC_Charisma_FahrPr : 56|3@1+ (1.0,0.0) [0.0|7] "" XXX + SG_ ACC_Charisma_Status : 59|2@1+ (1.0,0.0) [0.0|3] "" XXX + SG_ ACC_Charisma_Umschaltung : 61|2@1+ (1.0,0.0) [0.0|3] "" XXX BO_ 917 LWR_AFS_01: 8 XXX @@ -1251,18 +1321,80 @@ 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 -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"; +BO_ 1440 RLS_01: 8 XXX + +BO_ 870 Blinkmodi_02: 8 XXX + SG_ Hazard_Switch : 20|1@1+ (1,0) [0|1] "" XXX + SG_ Comfort_Signal_Left : 23|1@1+ (1,0) [0|1] "" XXX + SG_ Comfort_Signal_Right : 24|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Turn_Exterior_Bulb_1 : 25|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Turn_Exterior_Bulb_1 : 26|1@1+ (1,0) [0|1] "" XXX + SG_ Left_Turn_Exterior_Bulb_2 : 27|1@1+ (1,0) [0|1] "" XXX + SG_ Right_Turn_Exterior_Bulb_2 : 28|1@1+ (1,0) [0|1] "" XXX + SG_ Fast_Send_Rate_Active : 37|1@1+ (1,0) [0|1] "" 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_ 134 LWI_Lenkradwinkel "Steering angle WITH variable ratio effect included"; +CM_ SG_ 159 EPS_HCA_Status "Status of Heading Control Assist feature"; +CM_ SG_ 159 EPS_Lenkmoment "Steering input by driver, torque"; +CM_ SG_ 159 EPS_VZ_Lenkmoment "Steering input by driver, direction"; +CM_ SG_ 159 EPS_Berechneter_LW "Raw steering angle, degrees"; +CM_ SG_ 159 EPS_VZ_BLW "Raw steering angle, direction"; +CM_ SG_ 173 COUNTERXX "Message not renamed to COUNTER because J533 rate-limiting makes it look like messages are being lost"; +CM_ SG_ 294 SET_ME_0X3 "May be zero when sent by older cameras"; +CM_ SG_ 294 SET_ME_0X07 "May be zero when sent by older cameras"; +CM_ SG_ 294 SET_ME_0XFE "May be zero when sent by older cameras"; CM_ SG_ 294 Assist_Torque "Heading control input, torque"; CM_ SG_ 294 Assist_VZ "Heading control input, direction (sign)"; 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_ 302 ACC_Hold_Request "Active request for ABS brake hold in ACC_Hold_Type"; +CM_ SG_ 302 ACC_Boost_Request "Hybrid engine start related"; +CM_ SG_ 302 ACC_Freewheel_Request "Active request for DSG sailing/coasting in ACC_Freewheel_Type"; +CM_ SG_ 302 ACC_Hold_Release "Request to ABS to release brake hold"; +CM_ SG_ 302 ACC_Accel_Secondary "Target acceleration of the secondary controller"; +CM_ SG_ 302 ACC_Accel_TSK "Mirror of request to TSK to implement a target acceleration"; +CM_ SG_ 870 Hazard_Switch "Four-way flashers active"; +CM_ SG_ 870 Comfort_Signal_Left "Comfort turn signal active, left"; +CM_ SG_ 870 Comfort_Signal_Right "Comfort turn signal active, right"; +CM_ SG_ 870 Left_Turn_Exterior_Bulb_1 "Probably front"; +CM_ SG_ 870 Right_Turn_Exterior_Bulb_1 "Probably front"; +CM_ SG_ 870 Left_Turn_Exterior_Bulb_2 "Probably rear"; +CM_ SG_ 870 Right_Turn_Exterior_Bulb_2 "Probably rear"; +CM_ SG_ 870 Fast_Send_Rate_Active "CAN message send rate"; 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 +1406,15 @@ 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_ 159 EPS_HCA_Status 0 "disabled" 1 "initializing" 2 "fault" 3 "ready" 4 "rejected" 5 "active"; +VAL_ 173 GE_Fahrstufe 5 "P" 6 "R" 7 "N" 8 "D" 9 "S" 10 "E" 14 "T"; +VAL_ 288 TSK_Status 0 "init" 1 "disabled" 2 "enabled" 3 "regulating" 4 "accel_pedal_override" 5 "brake_only" 6 "temp_fault" 7 "perm_fault"; +VAL_ 302 ACC_Freewheel_Type 0 "freewheel_released" 1 "freewheel_not_permitted" 2 "freewheel_not_released" 3 "freewheel_requested" ; +VAL_ 302 ACC_Hold_Type 0 "no_request" 1 "hold" 2 "park" 3 "hold_standby" 4 "startup" 5 "loosen_over_ramp" ; +VAL_ 391 GearPosition 2 "P" 3 "R" 4 "N" 5 "D" 6 "D"; +VAL_ 391 RegenBrakingMode 0 "default" 1 "B1" 2 "B2" 3 "B3"; +VAL_ 870 Fast_Send_Rate_Active 0 "1 Hz" 1 "50 Hz"; diff --git a/panda/.circleci/config.yml b/panda/.circleci/config.yml deleted file mode 100644 index e36aaa142a5a18..00000000000000 --- a/panda/.circleci/config.yml +++ /dev/null @@ -1,110 +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 - - store_artifacts: - name: Store cppcheck safety test output - path: /tmp/misra/cppcheck_safety_output.txt - - store_artifacts: - name: Store misra safety test output - path: /tmp/misra/misra_safety_output.txt - - - strict-compiler: - machine: - docker_layer_caching: true - steps: - - checkout - - run: - name: Build image - command: "docker build -t panda_strict_compiler -f tests/build_strict/Dockerfile ." - - run: - name: Build Panda with strict compiler rules - command: | - docker run panda_strict_compiler /bin/bash -c "cd /panda/tests/build_strict; ./test_build_strict.sh" - - 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" - -workflows: - version: 2 - main: - jobs: - - safety - - misra-c2012 - - strict-compiler - - build - - safety_replay 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..3a8ead1e0fbf1f 100644 --- a/panda/.gitignore +++ b/panda/.gitignore @@ -3,7 +3,9 @@ .*.swo *.o *.so +*.os *.d +*.dump a.out *~ .#* @@ -12,4 +14,7 @@ pandacan.egg-info/ board/obj/ examples/output.csv .DS_Store +.vscode* nosetests.xml +.mypy_cache/ +.sconsign.dblite 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 0a861a5fa1ae2c..00000000000000 --- a/panda/Jenkinsfile +++ /dev/null @@ -1,53 +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') { - steps { - lock(resource: "Pandas", inversePrecedence: true, quantity:1){ - timeout(time: 60, unit: 'MINUTES') { - 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 '" - } - } - } - } - stage('Test EON Build') { - steps { - lock(resource: "Pandas", inversePrecedence: true, quantity:1){ - timeout(time: 60, unit: 'MINUTES') { - sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_dev.xml" - sh "touch EON && docker cp EON ${env.DOCKER_NAME}:/EON" - sh "docker start -a ${env.DOCKER_NAME}" - } - } - } - } - } - post { - always { - script { - sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_EON.xml" - sh "docker rm ${env.DOCKER_NAME}" - } - junit "test_results*.xml" - } - } -} \ No newline at end of file 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 deleted file mode 100644 index ec7b9678297f1e..00000000000000 --- a/panda/VERSION +++ /dev/null @@ -1 +0,0 @@ -v1.4.0 \ No newline at end of file diff --git a/panda/__init__.py b/panda/__init__.py index b802cf5a59582a..a9bf38f4812bae 100644 --- a/panda/__init__.py +++ b/panda/__init__.py @@ -1 +1,9 @@ -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, PandaSerial, pack_can_buffer, unpack_can_buffer, \ + DEFAULT_FW_FN, DEFAULT_H7_FW_FN, MCU_TYPE_H7, MCU_TYPE_F4, DLC_TO_LEN, LEN_TO_DLC + +from .python.config import BOOTSTUB_ADDRESS, BLOCK_SIZE_FX, APP_ADDRESS_FX, \ + BLOCK_SIZE_H7, APP_ADDRESS_H7, DEVICE_SERIAL_NUMBER_ADDR_H7, \ + DEVICE_SERIAL_NUMBER_ADDR_FX diff --git a/panda/board/Makefile b/panda/board/Makefile deleted file mode 100644 index ed6dcaa0309fc8..00000000000000 --- a/panda/board/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PROJ_NAME = panda -CFLAGS = -g -Wall - -CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -CFLAGS += -mhard-float -DSTM32F4 -DSTM32F413xx -mfpu=fpv4-sp-d16 -fsingle-precision-constant -STARTUP_FILE = startup_stm32f413xx - -include build.mk diff --git a/panda/board/Makefile.strict b/panda/board/Makefile.strict deleted file mode 100644 index b6c72b58b1485a..00000000000000 --- a/panda/board/Makefile.strict +++ /dev/null @@ -1,8 +0,0 @@ -PROJ_NAME = panda -CFLAGS = -g -Wall -Wextra -Wstrict-prototypes - -CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -CFLAGS += -mhard-float -DSTM32F4 -DSTM32F413xx -mfpu=fpv4-sp-d16 -fsingle-precision-constant -STARTUP_FILE = startup_stm32f413xx - -include build.mk diff --git a/panda/board/README.md b/panda/board/README.md index 5fe2e4b238c2dd..add2e92350c83a 100644 --- a/panda/board/README.md +++ b/panda/board/README.md @@ -4,6 +4,7 @@ Dependencies **Mac** ``` +xcode-select --install ./get_sdk_mac.sh ``` @@ -20,7 +21,8 @@ Programming **Panda** ``` -make +scons -u # Compile +./flash.sh # Compile & Flash ``` Troubleshooting @@ -28,7 +30,7 @@ Troubleshooting If your panda will not flash and is quickly blinking a single Green LED, use: ``` -make recover +./recover.sh ``` diff --git a/panda/board/SConscript b/panda/board/SConscript new file mode 100644 index 00000000000000..4570bf1a5ba386 --- /dev/null +++ b/panda/board/SConscript @@ -0,0 +1,188 @@ +import os +import subprocess + +PREFIX = "arm-none-eabi-" +BUILDER = "DEV" + +common_flags = [] +build_projects = {} + +if os.getenv("PEDAL"): + build_projects["pedal"] = { + "MAIN": "pedal/main.c", + "STARTUP_FILE": "stm32fx/startup_stm32f205xx.s", + "LINKER_SCRIPT": "stm32fx/stm32fx_flash.ld", + "APP_START_ADDRESS": "0x8004000", + "PROJECT_FLAGS": [ + "-mcpu=cortex-m3", + "-msoft-float", + "-DSTM32F2", + "-DSTM32F205xx", + "-O2", + "-DPEDAL", + ], + } + + if os.getenv("PEDAL_USB"): + build_projects["pedal_usb"] = build_projects.pop("pedal") + build_projects["pedal_usb"]["PROJECT_FLAGS"].append("-DPEDAL_USB") + +build_projects["panda"] = { + "MAIN": "main.c", + "STARTUP_FILE": "stm32fx/startup_stm32f413xx.s", + "LINKER_SCRIPT": "stm32fx/stm32fx_flash.ld", + "APP_START_ADDRESS": "0x8004000", + "PROJECT_FLAGS": [ + "-mcpu=cortex-m4", + "-mhard-float", + "-DSTM32F4", + "-DSTM32F413xx", + "-mfpu=fpv4-sp-d16", + "-fsingle-precision-constant", + "-Os", + "-g", + "-DPANDA", + ], +} + +# arm-none-eabi-gcc on comma two has no cortex-m7 support +if not os.path.exists("/EON"): + build_projects["panda_h7"] = { + "MAIN": "main.c", + "STARTUP_FILE": "stm32h7/startup_stm32h7x5xx.s", + "LINKER_SCRIPT": "stm32h7/stm32h7x5_flash.ld", + "APP_START_ADDRESS": "0x8020000", + "PROJECT_FLAGS": [ + "-mcpu=cortex-m7", + "-mhard-float", + "-DSTM32H7", + "-DSTM32H725xx", + "-mfpu=fpv5-d16", + "-fsingle-precision-constant", + "-Os", + "-g", + "-DPANDA", + ], + } + +if os.getenv("RELEASE"): + BUILD_TYPE = "RELEASE" + cert_fn = os.getenv("CERT") + assert cert_fn is not None, 'No certificate file specified. Please set CERT env variable' + assert os.path.exists(cert_fn), 'Certificate file not found. Please specify absolute path' +else: + BUILD_TYPE = "DEBUG" + cert_fn = File("../certs/debug").srcnode().abspath + common_flags += ["-DALLOW_DEBUG"] + +if os.getenv("DEBUG"): + common_flags += ["-DDEBUG"] + +includes = [ + "stm32fx/inc", + "stm32h7/inc", + "..", + ".", +] + +def get_version(builder, build_type): + try: + git = subprocess.check_output(["git", "rev-parse", "--short=8", "HEAD"], encoding='utf8').strip() + except subprocess.CalledProcessError: + git = "unknown" + return f"{builder}-{git}-{build_type}" + + +def to_c_uint32(x): + nums = [] + for _ in range(0x20): + nums.append(x % (2**32)) + x //= (2**32) + return "{" + 'U,'.join(map(str, nums)) + "U}" + + +def get_key_header(name): + from Crypto.PublicKey import RSA + + public_fn = File(f'../certs/{name}.pub').srcnode().abspath + rsa = RSA.importKey(open(public_fn).read()) + assert(rsa.size_in_bits() == 1024) + + rr = pow(2**1024, 2, rsa.n) + n0inv = 2**32 - pow(rsa.n, -1, 2**32) + + r = [ + f"RSAPublicKey {name}_rsa_key = {{", + f" .len = 0x20,", + f" .n0inv = {n0inv}U,", + f" .n = {to_c_uint32(rsa.n)},", + f" .rr = {to_c_uint32(rr)},", + f" .exponent = {rsa.e},", + f"}};", + ] + return r + +def objcopy(source, target, env, for_signature): + return '$OBJCOPY -O binary %s %s' % (source[0], target[0]) + +# Common autogenerated includes +with open("obj/gitversion.h", "w") as f: + f.write(f'const uint8_t gitversion[] = "{get_version(BUILDER, BUILD_TYPE)}";\n') + +certs = [get_key_header(n) for n in ["debug", "release"]] +with open("obj/cert.h", "w") as f: + for cert in certs: + f.write("\n".join(cert) + "\n") + +for project_name in build_projects: + project = build_projects[project_name] + linkerscript_fn = File(project["LINKER_SCRIPT"]).srcnode().abspath + + flags = [ + "-Wall", + "-Wextra", + "-Wstrict-prototypes", + "-Werror", + "-mlittle-endian", + "-mthumb", + "-nostdlib", + "-fno-builtin", + f"-T{linkerscript_fn}", + "-std=gnu11", + ] + project["PROJECT_FLAGS"] + common_flags + + project_env = Environment( + ENV=os.environ, + CC=PREFIX + 'gcc', + AS=PREFIX + 'gcc', + OBJCOPY=PREFIX + 'objcopy', + OBJDUMP=PREFIX + 'objdump', + ASCOM="$AS $ASFLAGS -o $TARGET -c $SOURCES", + CFLAGS=flags, + ASFLAGS=flags, + LINKFLAGS=flags, + CPPPATH=includes, + BUILDERS={ + 'Objcopy': Builder(generator=objcopy, suffix='.bin', src_suffix='.elf') + } + ) + startup = project_env.Object(project["STARTUP_FILE"]) + + # Bootstub + crypto_obj = [ + project_env.Object(f"rsa-{project_name}", "../crypto/rsa.c"), + project_env.Object(f"sha-{project_name}", "../crypto/sha.c") + ] + bootstub_obj = project_env.Object(f"bootstub-{project_name}", "bootstub.c") + bootstub_elf = project_env.Program(f"obj/bootstub.{project_name}.elf", [startup] + crypto_obj + [bootstub_obj]) + bootstub_bin = project_env.Objcopy(f"obj/bootstub.{project_name}.bin", bootstub_elf) + + # Build main + main_obj = project_env.Object(f"main-{project_name}", project["MAIN"]) + main_elf = project_env.Program(f"obj/{project_name}.elf", [startup, main_obj], + LINKFLAGS=[f"-Wl,--section-start,.isr_vector={project['APP_START_ADDRESS']}"] + flags) + main_bin = project_env.Objcopy(f"obj/{project_name}.bin", main_elf) + + # Sign main + sign_py = File("../crypto/sign.py").srcnode().abspath + panda_bin_signed = project_env.Command(f"obj/{project_name}.bin.signed", main_bin, f"SETLEN=1 {sign_py} $SOURCE $TARGET {cert_fn}") diff --git a/panda/board/boards/black.h b/panda/board/boards/black.h new file mode 100644 index 00000000000000..5e86deecd85ca6 --- /dev/null +++ b/panda/board/boards/black.h @@ -0,0 +1,225 @@ +// ///////////////////// // +// Black Panda + Harness // +// ///////////////////// // + +void black_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 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) { + 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 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_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 GPS mode\n"); + break; + } +} + +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_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; + } +} + +bool black_check_ignition(void){ + // ignition is checked through harness + return harness_check_ignition(); +} + +void black_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); + + // Turn on GPS load switch. + black_set_gps_load_switch(true); + + // Turn on USB load switch. + black_set_usb_load_switch(true); + + // Set right power mode + black_set_usb_power_mode(USB_POWER_CDP); + + // Initialize harness + harness_init(); + + // Enable CAN transceivers + black_enable_can_transceivers(true); + + // Disable LEDs + black_set_led(LED_RED, false); + black_set_led(LED_GREEN, false); + black_set_led(LED_BLUE, false); + + // Set normal CAN mode + black_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); + } +} + +const harness_configuration black_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_black = { + .board_type = "Black", + .harness_config = &black_harness_config, + .has_gps = true, + .has_hw_gmlan = false, + .has_obd = true, + .has_lin = false, + .has_rtc = false, + .init = black_init, + .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_gps_mode = black_set_gps_mode, + .set_can_mode = black_set_can_mode, + .usb_power_mode_tick = unused_usb_power_mode_tick, + .check_ignition = black_check_ignition, + .read_current = unused_read_current, + .set_fan_power = unused_set_fan_power, + .set_ir_power = unused_set_ir_power, + .set_phone_power = unused_set_phone_power, + .set_clock_source_mode = unused_set_clock_source_mode, + .set_siren = unused_set_siren +}; diff --git a/panda/board/boards/board_declarations.h b/panda/board/boards/board_declarations.h new file mode 100644 index 00000000000000..0ec1a5f2a2dac7 --- /dev/null +++ b/panda/board/boards/board_declarations.h @@ -0,0 +1,77 @@ +// ******************** Prototypes ******************** +typedef void (*board_init)(void); +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_gps_mode)(uint8_t mode); +typedef void (*board_set_can_mode)(uint8_t mode); +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; + const bool has_gps; + const bool has_hw_gmlan; + const bool has_obd; + const bool has_lin; + const bool has_rtc; + board_init init; + 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_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 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 +#define HW_TYPE_RED_PANDA 7U + +// LED colors +#define LED_RED 0U +#define LED_GREEN 1U +#define LED_BLUE 2U + +// 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 + +// GPS modes +#define GPS_DISABLED 0U +#define GPS_ENABLED 1U +#define GPS_BOOTMODE 2U + +// CAN modes +#define CAN_MODE_NORMAL 0U +#define CAN_MODE_GMLAN_CAN2 1U +#define CAN_MODE_GMLAN_CAN3 2U +#define CAN_MODE_OBD_CAN2 3U + +// ********************* Globals ********************** +uint8_t usb_power_mode = USB_POWER_NONE; diff --git a/panda/board/boards/dos.h b/panda/board/boards/dos.h new file mode 100644 index 00000000000000..90f075e49b1752 --- /dev/null +++ b/panda/board/boards/dos.h @@ -0,0 +1,227 @@ +// ///////////// // +// 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)){ + dos_enable_can_transceiver(i, true); + } else { + dos_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_bootkick(bool enabled){ + set_gpio_output(GPIOC, 4, !enabled); +} + +void dos_set_usb_power_mode(uint8_t mode) { + bool valid = false; + switch (mode) { + case USB_POWER_CLIENT: + dos_set_bootkick(false); + valid = true; + break; + case USB_POWER_CDP: + dos_set_bootkick(true); + valid = true; + break; + default: + puts("Invalid USB power mode\n"); + break; + } + if (valid) { + usb_power_mode = 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; + } +} + +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); +} + +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 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, + .has_gps = false, + .has_hw_gmlan = false, + .has_obd = true, + .has_lin = false, + .has_rtc = true, + .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 = unused_set_gps_mode, + .set_can_mode = dos_set_can_mode, + .usb_power_mode_tick = unused_usb_power_mode_tick, + .check_ignition = dos_check_ignition, + .read_current = unused_read_current, + .set_fan_power = dos_set_fan_power, + .set_ir_power = dos_set_ir_power, + .set_phone_power = unused_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 new file mode 100644 index 00000000000000..ad68787fac61bd --- /dev/null +++ b/panda/board/boards/grey.h @@ -0,0 +1,59 @@ +// ////////// // +// Grey Panda // +// ////////// // + +// 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, + .has_gps = true, + .has_hw_gmlan = true, + .has_obd = false, + .has_lin = true, + .has_rtc = false, + .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_gps_mode = grey_set_gps_mode, + .set_can_mode = white_set_can_mode, + .usb_power_mode_tick = unused_usb_power_mode_tick, + .check_ignition = white_check_ignition, + .read_current = white_read_current, + .set_fan_power = unused_set_fan_power, + .set_ir_power = unused_set_ir_power, + .set_phone_power = unused_set_phone_power, + .set_clock_source_mode = unused_set_clock_source_mode, + .set_siren = unused_set_siren +}; diff --git a/panda/board/boards/pedal.h b/panda/board/boards/pedal.h new file mode 100644 index 00000000000000..f3922b164d9317 --- /dev/null +++ b/panda/board/boards/pedal.h @@ -0,0 +1,102 @@ +// ///// // +// Pedal // +// ///// // + +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 transceiver ("); puth(transceiver); puts("): enabling failed\n"); + break; + } +} + +void pedal_enable_can_transceivers(bool enabled) { + pedal_enable_can_transceiver(1U, enabled); +} + +void pedal_set_led(uint8_t color, bool enabled) { + switch (color){ + case LED_RED: + set_gpio_output(GPIOB, 10, !enabled); + break; + case LED_GREEN: + set_gpio_output(GPIOB, 11, !enabled); + break; + default: + break; + } +} + +void pedal_set_usb_power_mode(uint8_t mode){ + usb_power_mode = mode; + puts("Trying to set USB power mode on pedal. This is not supported.\n"); +} + +void pedal_set_gps_mode(uint8_t mode) { + UNUSED(mode); + puts("Trying to set ESP/GPS mode on pedal. This is not supported.\n"); +} + +void pedal_set_can_mode(uint8_t mode){ + switch (mode) { + case CAN_MODE_NORMAL: + break; + default: + puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); + break; + } +} + +bool pedal_check_ignition(void){ + // not supported on pedal + return false; +} + +void pedal_init(void) { + common_init_gpio(); + + // C0, C1: Throttle inputs + set_gpio_mode(GPIOC, 0, MODE_ANALOG); + set_gpio_mode(GPIOC, 1, MODE_ANALOG); + // DAC outputs on A4 and A5 + // apparently they don't need GPIO setup + + // Enable transceiver + pedal_enable_can_transceivers(true); + + // Disable LEDs + pedal_set_led(LED_RED, false); + pedal_set_led(LED_GREEN, false); +} + +const harness_configuration pedal_harness_config = { + .has_harness = false +}; + +const board board_pedal = { + .board_type = "Pedal", + .harness_config = &pedal_harness_config, + .has_gps = false, + .has_hw_gmlan = false, + .has_obd = false, + .has_lin = false, + .has_rtc = false, + .init = pedal_init, + .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_gps_mode = pedal_set_gps_mode, + .set_can_mode = pedal_set_can_mode, + .usb_power_mode_tick = unused_usb_power_mode_tick, + .check_ignition = pedal_check_ignition, + .read_current = unused_read_current, + .set_fan_power = unused_set_fan_power, + .set_ir_power = unused_set_ir_power, + .set_phone_power = unused_set_phone_power, + .set_clock_source_mode = unused_set_clock_source_mode, + .set_siren = unused_set_siren +}; diff --git a/panda/board/boards/red.h b/panda/board/boards/red.h new file mode 100644 index 00000000000000..17d4f039253c1a --- /dev/null +++ b/panda/board/boards/red.h @@ -0,0 +1,202 @@ +// ///////////////////// // +// Red Panda + Harness // +// ///////////////////// // + +void red_enable_can_transceiver(uint8_t transceiver, bool enabled) { + switch (transceiver) { + case 1U: + set_gpio_output(GPIOG, 11, !enabled); + break; + case 2U: + set_gpio_output(GPIOB, 3, !enabled); + break; + case 3U: + set_gpio_output(GPIOD, 7, !enabled); + break; + case 4U: + set_gpio_output(GPIOB, 4, !enabled); + break; + default: + break; + } +} + +void red_enable_can_transceivers(bool enabled) { + uint8_t main_bus = (car_harness_status == HARNESS_STATUS_FLIPPED) ? 3U : 1U; + for (uint8_t i=1U; i<=4U; i++) { + // Leave main CAN always on for CAN-based ignition detection + if (i == main_bus) { + red_enable_can_transceiver(i, true); + } else { + red_enable_can_transceiver(i, enabled); + } + } +} + +void red_set_led(uint8_t color, bool enabled) { + switch (color) { + case LED_RED: + set_gpio_output(GPIOE, 4, !enabled); + break; + case LED_GREEN: + set_gpio_output(GPIOE, 3, !enabled); + break; + case LED_BLUE: + set_gpio_output(GPIOE, 2, !enabled); + break; + default: + break; + } +} + +void red_set_usb_load_switch(bool enabled) { + set_gpio_output(GPIOB, 14, !enabled); +} + +void red_set_usb_power_mode(uint8_t mode) { + bool valid = false; + switch (mode) { + case USB_POWER_CLIENT: + red_set_usb_load_switch(false); + valid = true; + break; + case USB_POWER_CDP: + red_set_usb_load_switch(true); + valid = true; + break; + default: + break; + } + if (valid) { + usb_power_mode = mode; + } +} + +void red_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 normal mode + set_gpio_pullup(GPIOB, 12, PULL_NONE); + set_gpio_mode(GPIOB, 12, MODE_ANALOG); + + set_gpio_pullup(GPIOB, 13, PULL_NONE); + set_gpio_mode(GPIOB, 13, MODE_ANALOG); + + // B5,B6: FDCAN2 mode + set_gpio_pullup(GPIOB, 5, PULL_NONE); + set_gpio_alternate(GPIOB, 5, GPIO_AF9_FDCAN2); + + set_gpio_pullup(GPIOB, 6, PULL_NONE); + set_gpio_alternate(GPIOB, 6, GPIO_AF9_FDCAN2); + } else { + // B5,B6: disable normal mode + set_gpio_pullup(GPIOB, 5, PULL_NONE); + set_gpio_mode(GPIOB, 5, MODE_ANALOG); + + set_gpio_pullup(GPIOB, 6, PULL_NONE); + set_gpio_mode(GPIOB, 6, MODE_ANALOG); + // B12,B13: FDCAN2 mode + set_gpio_pullup(GPIOB, 12, PULL_NONE); + set_gpio_alternate(GPIOB, 12, GPIO_AF9_FDCAN2); + + set_gpio_pullup(GPIOB, 13, PULL_NONE); + set_gpio_alternate(GPIOB, 13, GPIO_AF9_FDCAN2); + } + break; + default: + break; + } +} + +bool red_check_ignition(void) { + // ignition is checked through harness + return harness_check_ignition(); +} + +void red_init(void) { + common_init_gpio(); + + //C4,A1: OBD_SBU1, OBD_SBU2 + set_gpio_pullup(GPIOC, 4, PULL_NONE); + set_gpio_mode(GPIOC, 4, MODE_ANALOG); + + set_gpio_pullup(GPIOA, 1, PULL_NONE); + set_gpio_mode(GPIOA, 1, MODE_ANALOG); + + //C10,C11 : OBD_SBU1_RELAY, OBD_SBU2_RELAY + set_gpio_output_type(GPIOC, 10, OUTPUT_TYPE_OPEN_DRAIN); + set_gpio_pullup(GPIOC, 10, PULL_NONE); + set_gpio_mode(GPIOC, 10, MODE_OUTPUT); + set_gpio_output(GPIOC, 10, 1); + + set_gpio_output_type(GPIOC, 11, OUTPUT_TYPE_OPEN_DRAIN); + set_gpio_pullup(GPIOC, 11, PULL_NONE); + set_gpio_mode(GPIOC, 11, MODE_OUTPUT); + set_gpio_output(GPIOC, 11, 1); + + // Turn on USB load switch. + red_set_usb_load_switch(true); + + // Set right power mode + red_set_usb_power_mode(USB_POWER_CDP); + + // Initialize harness + harness_init(); + + // Enable CAN transceivers + red_enable_can_transceivers(true); + + // Disable LEDs + red_set_led(LED_RED, false); + red_set_led(LED_GREEN, false); + red_set_led(LED_BLUE, false); + + // Set normal CAN mode + red_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); + } +} + +const harness_configuration red_harness_config = { + .has_harness = true, + .GPIO_SBU1 = GPIOC, + .GPIO_SBU2 = GPIOA, + .GPIO_relay_SBU1 = GPIOC, + .GPIO_relay_SBU2 = GPIOC, + .pin_SBU1 = 4, + .pin_SBU2 = 1, + .pin_relay_SBU1 = 10, + .pin_relay_SBU2 = 11, + .adc_channel_SBU1 = 4, //ADC12_INP4 + .adc_channel_SBU2 = 17 //ADC1_INP17 +}; + +const board board_red = { + .board_type = "Red", + .harness_config = &red_harness_config, + .has_gps = false, + .has_hw_gmlan = false, + .has_obd = true, + .has_lin = false, + .has_rtc = false, + .init = red_init, + .enable_can_transceiver = red_enable_can_transceiver, + .enable_can_transceivers = red_enable_can_transceivers, + .set_led = red_set_led, + .set_usb_power_mode = red_set_usb_power_mode, + .set_gps_mode = unused_set_gps_mode, + .set_can_mode = red_set_can_mode, + .usb_power_mode_tick = unused_usb_power_mode_tick, + .check_ignition = red_check_ignition, + .read_current = unused_read_current, + .set_fan_power = unused_set_fan_power, + .set_ir_power = unused_set_ir_power, + .set_phone_power = unused_set_phone_power, + .set_clock_source_mode = unused_set_clock_source_mode, + .set_siren = unused_set_siren +}; diff --git a/panda/board/boards/uno.h b/panda/board/boards/uno.h new file mode 100644 index 00000000000000..d8f0e0c849d25e --- /dev/null +++ b/panda/board/boards/uno.h @@ -0,0 +1,288 @@ +// ///////////// // +// 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); +} + +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); + } + + // 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, + .has_gps = true, + .has_hw_gmlan = false, + .has_obd = true, + .has_lin = false, + .has_rtc = true, + .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 = unused_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 = unused_set_clock_source_mode, + .set_siren = unused_set_siren +}; diff --git a/panda/board/boards/unused_funcs.h b/panda/board/boards/unused_funcs.h new file mode 100644 index 00000000000000..e9d59c69a2f29d --- /dev/null +++ b/panda/board/boards/unused_funcs.h @@ -0,0 +1,31 @@ +void unused_set_gps_mode(uint8_t mode) { + UNUSED(mode); +} + +void unused_usb_power_mode_tick(uint32_t uptime) { + UNUSED(uptime); +} + +void unused_set_ir_power(uint8_t percentage) { + UNUSED(percentage); +} + +void unused_set_fan_power(uint8_t percentage) { + UNUSED(percentage); +} + +void unused_set_phone_power(bool enabled) { + UNUSED(enabled); +} + +void unused_set_clock_source_mode(uint8_t mode) { + UNUSED(mode); +} + +void unused_set_siren(bool enabled) { + UNUSED(enabled); +} + +uint32_t unused_read_current(void) { + return 0U; +} diff --git a/panda/board/boards/white.h b/panda/board/boards/white.h new file mode 100644 index 00000000000000..560a3d4a590603 --- /dev/null +++ b/panda/board/boards/white.h @@ -0,0 +1,264 @@ +// /////////// // +// White Panda // +// /////////// // + +void white_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; + default: + puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); + break; + } +} + +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) { + 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 white_set_usb_power_mode(uint8_t mode){ + bool valid_mode = true; + switch (mode) { + case USB_POWER_CLIENT: + // B2,A13: set client mode + set_gpio_output(GPIOB, 2, 0); + set_gpio_output(GPIOA, 13, 1); + break; + case USB_POWER_CDP: + // B2,A13: set CDP mode + set_gpio_output(GPIOB, 2, 1); + set_gpio_output(GPIOA, 13, 1); + break; + case USB_POWER_DCP: + // B2,A13: set DCP mode on the charger (breaks USB!) + set_gpio_output(GPIOB, 2, 0); + set_gpio_output(GPIOA, 13, 0); + break; + default: + valid_mode = false; + puts("Invalid usb power mode\n"); + break; + } + + if (valid_mode) { + usb_power_mode = mode; + } +} + +void white_set_gps_mode(uint8_t mode) { + switch (mode) { + case GPS_DISABLED: + // ESP OFF + set_gpio_output(GPIOC, 14, 0); + set_gpio_output(GPIOC, 5, 0); + 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; + } +} + +void white_set_can_mode(uint8_t mode){ + switch (mode) { + case CAN_MODE_NORMAL: + // B12,B13: disable GMLAN mode + set_gpio_mode(GPIOB, 12, MODE_INPUT); + set_gpio_mode(GPIOB, 13, MODE_INPUT); + + // B3,B4: disable GMLAN mode + set_gpio_mode(GPIOB, 3, MODE_INPUT); + set_gpio_mode(GPIOB, 4, MODE_INPUT); + + // B5,B6: normal CAN2 mode + set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); + set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); + + // A8,A15: normal CAN3 mode + set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); + set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); + break; + case CAN_MODE_GMLAN_CAN2: + // B5,B6: disable CAN2 mode + set_gpio_mode(GPIOB, 5, MODE_INPUT); + set_gpio_mode(GPIOB, 6, MODE_INPUT); + + // B3,B4: disable GMLAN mode + set_gpio_mode(GPIOB, 3, MODE_INPUT); + set_gpio_mode(GPIOB, 4, MODE_INPUT); + + // B12,B13: GMLAN mode + set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); + set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); + + // A8,A15: normal CAN3 mode + set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); + set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); + break; + case CAN_MODE_GMLAN_CAN3: + // A8,A15: disable CAN3 mode + set_gpio_mode(GPIOA, 8, MODE_INPUT); + set_gpio_mode(GPIOA, 15, MODE_INPUT); + + // B12,B13: disable GMLAN mode + set_gpio_mode(GPIOB, 12, MODE_INPUT); + set_gpio_mode(GPIOB, 13, MODE_INPUT); + + // B3,B4: GMLAN mode + set_gpio_alternate(GPIOB, 3, GPIO_AF11_CAN3); + set_gpio_alternate(GPIOB, 4, GPIO_AF11_CAN3); + + // B5,B6: normal CAN2 mode + set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); + set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); + break; + default: + puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); + break; + } +} + +uint32_t white_read_current(void){ + return adc_get(ADCCHAN_CURRENT); +} + +bool white_check_ignition(void){ + // ignition is on PA1 + return !get_gpio_input(GPIOA, 1); +} + +void white_grey_common_init(void) { + common_init_gpio(); + + // C3: current sense + set_gpio_mode(GPIOC, 3, MODE_ANALOG); + + // A1: started_alt + set_gpio_pullup(GPIOA, 1, PULL_UP); + + // A2, A3: USART 2 for debugging + set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); + set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); + + // A4, A5, A6, A7: SPI + set_gpio_alternate(GPIOA, 4, GPIO_AF5_SPI1); + set_gpio_alternate(GPIOA, 5, GPIO_AF5_SPI1); + set_gpio_alternate(GPIOA, 6, GPIO_AF5_SPI1); + set_gpio_alternate(GPIOA, 7, GPIO_AF5_SPI1); + + // B12: GMLAN, ignition sense, pull up + set_gpio_pullup(GPIOB, 12, PULL_UP); + + /* GMLAN mode pins: + M0(B15) M1(B14) mode + ======================= + 0 0 sleep + 1 0 100kbit + 0 1 high voltage wakeup + 1 1 33kbit (normal) + */ + set_gpio_output(GPIOB, 14, 1); + set_gpio_output(GPIOB, 15, 1); + + // B7: K-line enable + set_gpio_output(GPIOB, 7, 1); + + // C12, D2: Setup K-line (UART5) + set_gpio_alternate(GPIOC, 12, GPIO_AF8_UART5); + set_gpio_alternate(GPIOD, 2, GPIO_AF8_UART5); + set_gpio_pullup(GPIOD, 2, PULL_UP); + + // L-line enable + set_gpio_output(GPIOA, 14, 1); + + // C10, C11: L-Line setup (USART3) + set_gpio_alternate(GPIOC, 10, GPIO_AF7_USART3); + set_gpio_alternate(GPIOC, 11, GPIO_AF7_USART3); + set_gpio_pullup(GPIOC, 11, PULL_UP); + + // Enable CAN transceivers + white_enable_can_transceivers(true); + + // Disable LEDs + white_set_led(LED_RED, false); + white_set_led(LED_GREEN, false); + white_set_led(LED_BLUE, false); + + // 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 + 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 = { + .has_harness = false +}; + +const board board_white = { + .board_type = "White", + .harness_config = &white_harness_config, + .has_gps = false, + .has_hw_gmlan = true, + .has_obd = false, + .has_lin = true, + .has_rtc = false, + .init = white_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_gps_mode = white_set_gps_mode, + .set_can_mode = white_set_can_mode, + .usb_power_mode_tick = unused_usb_power_mode_tick, + .check_ignition = white_check_ignition, + .read_current = white_read_current, + .set_fan_power = unused_set_fan_power, + .set_ir_power = unused_set_ir_power, + .set_phone_power = unused_set_phone_power, + .set_clock_source_mode = unused_set_clock_source_mode, + .set_siren = unused_set_siren +}; diff --git a/panda/board/bootstub.c b/panda/board/bootstub.c index 691d0d02e33cda..a31721232ece02 100644 --- a/panda/board/bootstub.c +++ b/panda/board/bootstub.c @@ -1,44 +1,29 @@ #define BOOTSTUB -#include "config.h" -#include "obj/gitversion.h" +#define VERS_TAG 0x53524556 +#define MIN_VERSION 2 -#ifdef STM32F4 - #define PANDA - #include "stm32f4xx.h" - #include "stm32f4xx_hal_gpio_ex.h" -#else - #include "stm32f2xx.h" - #include "stm32f2xx_hal_gpio_ex.h" -#endif +// ********************* Includes ********************* +#include "config.h" -// default since there's no serial -void puts(const char *a) {} -void puth(unsigned int i) {} +#include "drivers/pwm.h" +#include "drivers/usb.h" -#include "libc.h" +#include "early_init.h" #include "provision.h" -#include "drivers/clock.h" -#include "drivers/llgpio.h" -#include "gpio.h" - -#include "drivers/spi.h" -#include "drivers/usb.h" -//#include "drivers/uart.h" - #include "crypto/rsa.h" #include "crypto/sha.h" #include "obj/cert.h" +#include "obj/gitversion.h" +#include "flasher.h" -#include "spi_flasher.h" - -void __initialize_hardware_early() { - early(); +void __initialize_hardware_early(void) { + early_initialization(); } -void fail() { +void fail(void) { soft_flasher_start(); } @@ -48,14 +33,14 @@ extern void *_app_start[]; // FIXME: sometimes your panda will fail flashing and will quickly blink a single Green LED // BOUNTY: $200 coupon on shop.comma.ai or $100 check. -int main() { - __disable_irq(); - clock_init(); - detect(); +int main(void) { + // Init interrupt table + init_interrupts(true); - if (revision == PANDA_REV_C) { - set_usb_power_mode(USB_POWER_CLIENT); - } + disable_interrupts(); + clock_init(); + detect_external_debug_serial(); + detect_board_type(); if (enter_bootloader_mode == ENTER_SOFTLOADER_MAGIC) { enter_bootloader_mode = 0; @@ -70,6 +55,13 @@ int main() { 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; @@ -88,7 +80,6 @@ int main() { return 0; good: // jump to flash - ((void(*)()) _app_start[1])(); + ((void(*)(void)) _app_start[1])(); return 0; } - diff --git a/panda/board/bootstub_declarations.h b/panda/board/bootstub_declarations.h new file mode 100644 index 00000000000000..8e9f07312f0a30 --- /dev/null +++ b/panda/board/bootstub_declarations.h @@ -0,0 +1,15 @@ +// ******************** Prototypes ******************** +void puts(const char *a){ UNUSED(a); } +void puth(uint8_t i){ UNUSED(i); } +void puth2(uint8_t i){ UNUSED(i); } +void puth4(uint8_t i){ UNUSED(i); } +typedef struct board board; +typedef struct harness_configuration harness_configuration; +// No CAN support on bootloader +void can_flip_buses(uint8_t bus1, uint8_t bus2){UNUSED(bus1); UNUSED(bus2);} +void pwm_init(TIM_TypeDef *TIM, uint8_t channel); +void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage); + +// ********************* Globals ********************** +uint8_t hw_type = 0; +const board *current_board; diff --git a/panda/board/build.mk b/panda/board/build.mk deleted file mode 100644 index af2bffeb0a4616..00000000000000 --- a/panda/board/build.mk +++ /dev/null @@ -1,84 +0,0 @@ -CFLAGS += -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -Os - -CFLAGS += -Tstm32_flash.ld - -DFU_UTIL = "dfu-util" - -# Compile fast charge (DCP) only not on EON -ifeq (,$(wildcard /EON)) - BUILDER = DEV -else - CFLAGS += "-DEON" - BUILDER = EON - DFU_UTIL = "tools/dfu-util-aarch64" -endif - -CC = arm-none-eabi-gcc -OBJCOPY = arm-none-eabi-objcopy -OBJDUMP = arm-none-eabi-objdump - -ifeq ($(RELEASE),1) - CERT = ../../pandaextra/certs/release -else - # enable the debug cert - CERT = ../certs/debug - CFLAGS += "-DALLOW_DEBUG" -endif - - -DEPDIR = generated_dependencies -$(shell mkdir -p -m 777 $(DEPDIR) >/dev/null) -DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td -POSTCOMPILE = @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@ - -# this no longer pushes the bootstub -flash: obj/$(PROJ_NAME).bin - PYTHONPATH=../ python -c "from python import Panda; Panda().flash('obj/$(PROJ_NAME).bin')" - -ota: obj/$(PROJ_NAME).bin - curl http://192.168.0.10/stupdate --upload-file $< - -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 - $(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 - -include ../common/version.mk - -obj/cert.h: ../crypto/getcertheader.py - ../crypto/getcertheader.py ../certs/debug.pub ../certs/release.pub > $@ - -obj/%.$(PROJ_NAME).o: %.c obj/gitversion.h obj/cert.h $(DEPDIR)/%.d - $(CC) $(DEPFLAGS) $(CFLAGS) -o $@ -c $< - $(POSTCOMPILE) - -obj/%.$(PROJ_NAME).o: ../crypto/%.c - $(CC) $(CFLAGS) -o $@ -c $< - -obj/$(STARTUP_FILE).o: $(STARTUP_FILE).s - $(CC) $(CFLAGS) -o $@ -c $< - -obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.$(PROJ_NAME).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) - @BINSIZE=$$(du -b "obj/$(PROJ_NAME).bin" | cut -f 1) ; \ - if [ $$BINSIZE -ge 32768 ]; then echo "ERROR obj/$(PROJ_NAME).bin is too big!"; exit 1; fi; - -obj/bootstub.$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/bootstub.$(PROJ_NAME).o obj/sha.$(PROJ_NAME).o obj/rsa.$(PROJ_NAME).o - $(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^ - $(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@ - -$(DEPDIR)/%.d: ; -.PRECIOUS: $(DEPDIR)/%.d - -include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(wildcard *.c)))) - -clean: - @$(RM) obj/* - @rm -rf $(DEPDIR) diff --git a/panda/board/build_all.sh b/panda/board/build_all.sh new file mode 100755 index 00000000000000..a461f6fa7085e0 --- /dev/null +++ b/panda/board/build_all.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +set -e + +scons -u +PEDAL=1 scons -u +PEDAL=1 PEDAL_USB=1 scons -u diff --git a/panda/board/can_definitions.h b/panda/board/can_definitions.h new file mode 100644 index 00000000000000..074f4e7a662c4b --- /dev/null +++ b/panda/board/can_definitions.h @@ -0,0 +1,29 @@ +#include "dlc_to_len.h" + +#define CAN_PACKET_VERSION 2 +typedef struct { + unsigned char reserved : 1; + unsigned char bus : 3; + unsigned char data_len_code : 4; + unsigned char rejected : 1; + unsigned char returned : 1; + unsigned char extended : 1; + unsigned int addr : 29; + unsigned char data[CANPACKET_DATA_SIZE_MAX]; +} __attribute__((packed, aligned(4))) CANPacket_t; + +#define GET_BUS(msg) ((msg)->bus) +#define GET_LEN(msg) (dlc_to_len[(msg)->data_len_code]) +#define GET_ADDR(msg) ((msg)->addr) + +// Flasher and pedal use raw mailbox access +#define GET_MAILBOX_BYTE(msg, b) (((int)(b) > 3) ? (((msg)->RDHR >> (8U * ((unsigned int)(b) % 4U))) & 0xFFU) : (((msg)->RDLR >> (8U * (unsigned int)(b))) & 0xFFU)) +#define GET_MAILBOX_BYTES_04(msg) ((msg)->RDLR) +#define GET_MAILBOX_BYTES_48(msg) ((msg)->RDHR) + +#define CAN_INIT_TIMEOUT_MS 500U + +#define CANPACKET_HEAD_SIZE 5U + +#define WORD_TO_BYTE_ARRAY(dst8, src32) 0[dst8] = ((src32) & 0xFFU); 1[dst8] = (((src32) >> 8U) & 0xFFU); 2[dst8] = (((src32) >> 16U) & 0xFFU); 3[dst8] = (((src32) >> 24U) & 0xFFU) +#define BYTE_ARRAY_TO_WORD(dst32, src8) ((dst32) = 0[src8] | (1[src8] << 8U) | (2[src8] << 16U) | (3[src8] << 24U)) diff --git a/panda/board/config.h b/panda/board/config.h index 219ce64c24a938..311a0a2e179533 100644 --- a/panda/board/config.h +++ b/panda/board/config.h @@ -2,27 +2,21 @@ #define PANDA_CONFIG_H //#define DEBUG +//#define DEBUG_UART //#define DEBUG_USB //#define DEBUG_SPI +//#define DEBUG_FAULTS -#ifdef STM32F4 - #define PANDA - #include "stm32f4xx.h" -#else - #include "stm32f2xx.h" -#endif - -#define USB_VID 0xbbaa +#define USB_VID 0xbbaaU #ifdef BOOTSTUB -#define USB_PID 0xddee + #define USB_PID 0xddeeU #else -#define USB_PID 0xddcc + #define USB_PID 0xddccU #endif -#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 +28,17 @@ __typeof__ (b) _b = (b); \ (_a > _b) ? _a : _b; }) -#define MAX_RESP_LEN 0x40 +#define ABS(a) \ + ({ __typeof__ (a) _a = (a); \ + (_a > 0) ? _a : (-_a); }) +#define MAX_RESP_LEN 0x40U + +#include +#ifdef STM32H7 + #include "stm32h7/stm32h7_config.h" +#else + #include "stm32fx/stm32fx_config.h" #endif +#endif diff --git a/panda/board/crc.h b/panda/board/crc.h new file mode 100644 index 00000000000000..0d62dd316e3c24 --- /dev/null +++ b/panda/board/crc.h @@ -0,0 +1,17 @@ +uint8_t crc_checksum(uint8_t *dat, int len, const uint8_t poly) { + uint8_t crc = 0xFFU; + int i; + int 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/dlc_to_len.h b/panda/board/dlc_to_len.h new file mode 100644 index 00000000000000..82d743ffb895ca --- /dev/null +++ b/panda/board/dlc_to_len.h @@ -0,0 +1 @@ +unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; diff --git a/panda/board/drivers/adc.h b/panda/board/drivers/adc.h deleted file mode 100644 index 3e5f1b32a059c7..00000000000000 --- a/panda/board/drivers/adc.h +++ /dev/null @@ -1,38 +0,0 @@ -// ACCEL1 = ADC10 -// ACCEL2 = ADC11 -// VOLT_S = ADC12 -// CURR_S = ADC13 - -#define ADCCHAN_ACCEL0 10 -#define ADCCHAN_ACCEL1 11 -#define ADCCHAN_VOLTAGE 12 -#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; -} - -uint32_t adc_get(int channel) { - // includes length - //ADC1->SQR1 = 0; - - // select channel - ADC1->JSQR = channel << 15; - - //ADC1->CR1 = ADC_CR1_DISCNUM_0; - //ADC1->CR1 = ADC_CR1_EOCIE; - - ADC1->SR &= ~(ADC_SR_JEOC); - ADC1->CR2 |= ADC_CR2_JSWSTART; - while (!(ADC1->SR & ADC_SR_JEOC)); - - return ADC1->JDR1; -} - diff --git a/panda/board/drivers/bxcan.h b/panda/board/drivers/bxcan.h new file mode 100644 index 00000000000000..4733491d0ab310 --- /dev/null +++ b/panda/board/drivers/bxcan.h @@ -0,0 +1,241 @@ +// IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE +// CAN2_TX, CAN2_RX0, CAN2_SCE +// CAN3_TX, CAN3_RX0, CAN3_SCE + +CAN_TypeDef *cans[] = {CAN1, CAN2, CAN3}; + +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); + + ret &= llcan_set_speed(CAN, bus_config[bus_number].can_speed, can_loopback, (unsigned int)(can_silent) & (1U << can_number)); + return ret; +} + +// TODO: Cleanup with new abstraction +void can_set_gmlan(uint8_t bus) { + if(current_board->has_hw_gmlan){ + // first, disable GMLAN on prev bus + uint8_t prev_bus = bus_config[3].can_num_lookup; + if (bus != prev_bus) { + switch (prev_bus) { + case 1: + case 2: + puts("Disable GMLAN on CAN"); + puth(prev_bus + 1U); + puts("\n"); + current_board->set_can_mode(CAN_MODE_NORMAL); + bus_config[prev_bus].bus_lookup = prev_bus; + bus_config[prev_bus].can_num_lookup = prev_bus; + bus_config[3].can_num_lookup = -1; + bool ret = can_init(prev_bus); + UNUSED(ret); + break; + default: + // GMLAN was not set on either BUS 1 or 2 + break; + } + } + + // now enable GMLAN on the new bus + switch (bus) { + case 1: + case 2: + puts("Enable GMLAN on CAN"); + puth(bus + 1U); + puts("\n"); + current_board->set_can_mode((bus == 1U) ? CAN_MODE_GMLAN_CAN2 : CAN_MODE_GMLAN_CAN3); + bus_config[bus].bus_lookup = 3; + bus_config[bus].can_num_lookup = -1; + bus_config[3].can_num_lookup = bus; + bool ret = can_init(bus); + UNUSED(ret); + break; + case 0xFF: //-1 unsigned + break; + default: + puts("GMLAN can only be set on CAN2 or CAN3\n"); + break; + } + } else { + puts("GMLAN not available on black panda\n"); + } +} + +// CAN error +void can_sce(CAN_TypeDef *CAN) { + ENTER_CRITICAL(); + + #ifdef DEBUG + if (CAN==CAN1) puts("CAN1: "); + if (CAN==CAN2) puts("CAN2: "); + #ifdef CAN3 + if (CAN==CAN3) puts("CAN3: "); + #endif + puts("MSR:"); + puth(CAN->MSR); + puts(" TSR:"); + puth(CAN->TSR); + puts(" RF0R:"); + puth(CAN->RF0R); + puts(" RF1R:"); + puth(CAN->RF1R); + puts(" ESR:"); + puth(CAN->ESR); + puts("\n"); + #endif + + can_err_cnt += 1; + llcan_clear_send(CAN); + EXIT_CRITICAL(); +} + +// ***************************** CAN ***************************** +void process_can(uint8_t can_number) { + if (can_number != 0xffU) { + + ENTER_CRITICAL(); + + CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); + uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); + + // check for empty mailbox + CANPacket_t to_send; + if ((CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0) { + // add successfully transmitted message to my fifo + if ((CAN->TSR & CAN_TSR_RQCP0) == CAN_TSR_RQCP0) { + can_txd_cnt += 1; + + if ((CAN->TSR & CAN_TSR_TXOK0) == CAN_TSR_TXOK0) { + CANPacket_t to_push; + to_push.returned = 1U; + to_push.rejected = 0U; + to_push.extended = (CAN->sTxMailBox[0].TIR >> 2) & 0x1U; + to_push.addr = (to_push.extended != 0U) ? (CAN->sTxMailBox[0].TIR >> 3) : (CAN->sTxMailBox[0].TIR >> 21); + to_push.data_len_code = CAN->sTxMailBox[0].TDTR & 0xFU; + to_push.bus = bus_number; + WORD_TO_BYTE_ARRAY(&to_push.data[0], CAN->sTxMailBox[0].TDLR); + WORD_TO_BYTE_ARRAY(&to_push.data[4], CAN->sTxMailBox[0].TDHR); + + can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; + } + + if ((CAN->TSR & CAN_TSR_TERR0) == CAN_TSR_TERR0) { + #ifdef DEBUG + puts("CAN TX ERROR!\n"); + #endif + } + + if ((CAN->TSR & CAN_TSR_ALST0) == CAN_TSR_ALST0) { + #ifdef DEBUG + puts("CAN TX ARBITRATION LOST!\n"); + #endif + } + + // clear interrupt + // careful, this can also be cleared by requesting a transmission + CAN->TSR |= CAN_TSR_RQCP0; + } + + if (can_pop(can_queues[bus_number], &to_send)) { + can_tx_cnt += 1; + // only send if we have received a packet + CAN->sTxMailBox[0].TIR = ((to_send.extended != 0U) ? (to_send.addr << 3) : (to_send.addr << 21)) | (to_send.extended << 2); + CAN->sTxMailBox[0].TDTR = to_send.data_len_code; + BYTE_ARRAY_TO_WORD(CAN->sTxMailBox[0].TDLR, &to_send.data[0]); + BYTE_ARRAY_TO_WORD(CAN->sTxMailBox[0].TDHR, &to_send.data[4]); + // Send request TXRQ + CAN->sTxMailBox[0].TIR |= 0x1U; + + usb_cb_ep3_out_complete(); + } + } + + EXIT_CRITICAL(); + } +} + +// CAN receive handlers +// blink blue when we are receiving CAN messages +void can_rx(uint8_t can_number) { + CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); + uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); + while ((CAN->RF0R & CAN_RF0R_FMP0) != 0) { + can_rx_cnt += 1; + + // can is live + pending_can_live = 1; + + // add to my fifo + CANPacket_t to_push; + + to_push.returned = 0U; + to_push.rejected = 0U; + to_push.extended = (CAN->sFIFOMailBox[0].RIR >> 2) & 0x1U; + to_push.addr = (to_push.extended != 0U) ? (CAN->sFIFOMailBox[0].RIR >> 3) : (CAN->sFIFOMailBox[0].RIR >> 21); + to_push.data_len_code = CAN->sFIFOMailBox[0].RDTR & 0xFU; + to_push.bus = bus_number; + WORD_TO_BYTE_ARRAY(&to_push.data[0], CAN->sFIFOMailBox[0].RDLR); + WORD_TO_BYTE_ARRAY(&to_push.data[4], CAN->sFIFOMailBox[0].RDHR); + + // forwarding (panda only) + int bus_fwd_num = safety_fwd_hook(bus_number, &to_push); + if (bus_fwd_num != -1) { + CANPacket_t to_send; + + to_send.returned = 0U; + to_send.rejected = 0U; + to_send.extended = to_push.extended; // TXRQ + to_send.addr = to_push.addr; + to_send.bus = to_push.bus; + to_send.data_len_code = to_push.data_len_code; + (void)memcpy(to_send.data, to_push.data, dlc_to_len[to_push.data_len_code]); + can_send(&to_send, bus_fwd_num, true); + } + + 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) ? 0U : 1U; + + // next + CAN->RF0R |= CAN_RF0R_RFOM0; + } +} + +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_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_IRQ_Handler(void) { process_can(2); } +void CAN3_RX0_IRQ_Handler(void) { can_rx(2); } +void CAN3_SCE_IRQ_Handler(void) { can_sce(CAN3); } + +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/can.h b/panda/board/drivers/can.h deleted file mode 100644 index 7d0e63058a5e98..00000000000000 --- a/panda/board/drivers/can.h +++ /dev/null @@ -1,363 +0,0 @@ -// IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE -// CAN2_TX, CAN2_RX0, CAN2_SCE -// CAN3_TX, CAN3_RX0, CAN3_SCE - -typedef struct { - volatile uint32_t w_ptr; - volatile uint32_t r_ptr; - uint32_t fifo_size; - CAN_FIFOMailBox_TypeDef *elems; -} can_ring; - -#define CAN_BUS_RET_FLAG 0x80 -#define CAN_BUS_NUM_MASK 0x7F - -#define BUS_MAX 4 - -extern int can_live, pending_can_live; - -// must reinit after changing these -extern int can_loopback, can_silent; -extern uint32_t can_speed[4]; - -void can_set_forwarding(int from, int to); - -void 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_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem); - -// end API - -#define ALL_CAN_SILENT 0xFF -#define ALL_CAN_BUT_MAIN_SILENT 0xFE -#define ALL_CAN_LIVE 0 - -int can_live = 0, pending_can_live = 0, can_loopback = 0, can_silent = ALL_CAN_SILENT; - -// ********************* instantiate queues ********************* - -#define can_buffer(x, size) \ - CAN_FIFOMailBox_TypeDef elems_##x[size]; \ - can_ring can_##x = { .w_ptr = 0, .r_ptr = 0, .fifo_size = size, .elems = (CAN_FIFOMailBox_TypeDef *)&elems_##x }; - -can_buffer(rx_q, 0x1000) -can_buffer(tx1_q, 0x100) -can_buffer(tx2_q, 0x100) -can_buffer(tx3_q, 0x100) -can_buffer(txgmlan_q, 0x100) -can_ring *can_queues[] = {&can_tx1_q, &can_tx2_q, &can_tx3_q, &can_txgmlan_q}; - -// global CAN stats -int can_rx_cnt = 0; -int can_tx_cnt = 0; -int can_txd_cnt = 0; -int can_err_cnt = 0; -int can_overflow_cnt = 0; - -// ********************* interrupt safe queue ********************* - -bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { - bool ret = 0; - - enter_critical_section(); - if (q->w_ptr != q->r_ptr) { - *elem = q->elems[q->r_ptr]; - if ((q->r_ptr + 1) == q->fifo_size) q->r_ptr = 0; - else q->r_ptr += 1; - ret = 1; - } - exit_critical_section(); - - return ret; -} - -int can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { - int ret = 0; - uint32_t next_w_ptr; - - enter_critical_section(); - if ((q->w_ptr + 1) == q->fifo_size) next_w_ptr = 0; - else next_w_ptr = q->w_ptr + 1; - if (next_w_ptr != q->r_ptr) { - q->elems[q->w_ptr] = *elem; - q->w_ptr = next_w_ptr; - ret = 1; - } - exit_critical_section(); - if (ret == 0) { - can_overflow_cnt++; - #ifdef DEBUG - puts("can_push failed!\n"); - #endif - } - return ret; -} - -void can_clear(can_ring *q) { - enter_critical_section(); - q->w_ptr = 0; - q->r_ptr = 0; - exit_critical_section(); -} - -// assign CAN numbering -// bus num: Can bus number on ODB connector. Sent to/from USB -// Min: 0; Max: 127; Bit 7 marks message as receipt (bus 129 is receipt for but 1) -// cans: Look up MCU can interface from bus number -// can number: numeric lookup for MCU CAN interfaces (0 = CAN1, 1 = CAN2, etc); -// bus_lookup: Translates from 'can number' to 'bus number'. -// can_num_lookup: Translates from 'bus number' to 'can number'. -// can_forwarding: Given a bus num, lookup bus num to forward to. -1 means no forward. - -// Panda: Bus 0=CAN1 Bus 1=CAN2 Bus 2=CAN3 -CAN_TypeDef *cans[] = {CAN1, CAN2, CAN3}; -uint8_t bus_lookup[] = {0,1,2}; -uint8_t can_num_lookup[] = {0,1,2,-1}; -int8_t can_forwarding[] = {-1,-1,-1,-1}; -uint32_t can_speed[] = {5000, 5000, 5000, 333}; -#define CAN_MAX 3 - -#define CANIF_FROM_CAN_NUM(num) (cans[num]) -#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) { - 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, can_silent & (1 << 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 != 0xff) { - CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); - set_can_enable(CAN, 1); - can_set_speed(can_number); - - llcan_init(CAN); - - // in case there are queued up messages - process_can(can_number); - } -} - -void can_init_all(void) { - for (int i=0; i < CAN_MAX; i++) { - can_init(i); - } -} - -void can_set_gmlan(int bus) { - if ((bus == -1) || (bus != can_num_lookup[3])) { - // GMLAN OFF - switch (can_num_lookup[3]) { - case 1: - puts("disable GMLAN on CAN2\n"); - set_can_mode(1, 0); - bus_lookup[1] = 1; - can_num_lookup[1] = 1; - can_num_lookup[3] = -1; - can_init(1); - break; - case 2: - puts("disable GMLAN on CAN3\n"); - set_can_mode(2, 0); - bus_lookup[2] = 2; - can_num_lookup[2] = 2; - can_num_lookup[3] = -1; - can_init(2); - break; - default: - puts("GMLAN bus value invalid\n"); - break; - } - } - - if (bus == 1) { - puts("GMLAN on CAN2\n"); - // GMLAN on CAN2 - set_can_mode(1, 1); - bus_lookup[1] = 3; - can_num_lookup[1] = -1; - can_num_lookup[3] = 1; - can_init(1); - } else if (bus == 2) { - puts("GMLAN on CAN3\n"); - // GMLAN on CAN3 - set_can_mode(2, 1); - bus_lookup[2] = 3; - can_num_lookup[2] = -1; - can_num_lookup[3] = 2; - can_init(2); - } -} - -// CAN error -void can_sce(CAN_TypeDef *CAN) { - enter_critical_section(); - - #ifdef DEBUG - if (CAN==CAN1) puts("CAN1: "); - if (CAN==CAN2) puts("CAN2: "); - #ifdef CAN3 - if (CAN==CAN3) puts("CAN3: "); - #endif - puts("MSR:"); - puth(CAN->MSR); - puts(" TSR:"); - puth(CAN->TSR); - puts(" RF0R:"); - puth(CAN->RF0R); - puts(" RF1R:"); - puth(CAN->RF1R); - puts(" ESR:"); - puth(CAN->ESR); - puts("\n"); - #endif - - can_err_cnt += 1; - llcan_clear_send(CAN); - exit_critical_section(); -} - -// ***************************** CAN ***************************** - -void process_can(uint8_t can_number) { - if (can_number != 0xff) { - - enter_critical_section(); - - CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); - uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); - - // check for empty mailbox - CAN_FIFOMailBox_TypeDef to_send; - if ((CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0) { - // add successfully transmitted message to my fifo - if ((CAN->TSR & CAN_TSR_RQCP0) == CAN_TSR_RQCP0) { - can_txd_cnt += 1; - - if ((CAN->TSR & CAN_TSR_TXOK0) == CAN_TSR_TXOK0) { - CAN_FIFOMailBox_TypeDef to_push; - to_push.RIR = CAN->sTxMailBox[0].TIR; - to_push.RDTR = (CAN->sTxMailBox[0].TDTR & 0xFFFF000F) | ((CAN_BUS_RET_FLAG | bus_number) << 4); - to_push.RDLR = CAN->sTxMailBox[0].TDLR; - to_push.RDHR = CAN->sTxMailBox[0].TDHR; - can_push(&can_rx_q, &to_push); - } - - if ((CAN->TSR & CAN_TSR_TERR0) == CAN_TSR_TERR0) { - #ifdef DEBUG - puts("CAN TX ERROR!\n"); - #endif - } - - if ((CAN->TSR & CAN_TSR_ALST0) == CAN_TSR_ALST0) { - #ifdef DEBUG - puts("CAN TX ARBITRATION LOST!\n"); - #endif - } - - // clear interrupt - // careful, this can also be cleared by requesting a transmission - CAN->TSR |= CAN_TSR_RQCP0; - } - - if (can_pop(can_queues[bus_number], &to_send)) { - can_tx_cnt += 1; - // only send if we have received a packet - CAN->sTxMailBox[0].TDLR = to_send.RDLR; - CAN->sTxMailBox[0].TDHR = to_send.RDHR; - CAN->sTxMailBox[0].TDTR = to_send.RDTR; - CAN->sTxMailBox[0].TIR = to_send.RIR; - } - } - - exit_critical_section(); - } -} - -// CAN receive handlers -// blink blue when we are receiving CAN messages -void can_rx(uint8_t can_number) { - CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); - uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); - while ((CAN->RF0R & CAN_RF0R_FMP0) != 0) { - can_rx_cnt += 1; - - // can is live - pending_can_live = 1; - - // add to my fifo - CAN_FIFOMailBox_TypeDef to_push; - to_push.RIR = CAN->sFIFOMailBox[0].RIR; - to_push.RDTR = CAN->sFIFOMailBox[0].RDTR; - to_push.RDLR = CAN->sFIFOMailBox[0].RDLR; - to_push.RDHR = CAN->sFIFOMailBox[0].RDHR; - - // modify RDTR for our API - to_push.RDTR = (to_push.RDTR & 0xFFFF000F) | (bus_number << 4); - - // forwarding (panda only) - int bus_fwd_num = (can_forwarding[bus_number] != -1) ? can_forwarding[bus_number] : safety_fwd_hook(bus_number, &to_push); - if (bus_fwd_num != -1) { - CAN_FIFOMailBox_TypeDef to_send; - to_send.RIR = to_push.RIR | 1; // TXRQ - to_send.RDTR = to_push.RDTR; - to_send.RDLR = to_push.RDLR; - to_send.RDHR = to_push.RDHR; - can_send(&to_send, bus_fwd_num); - } - - safety_rx_hook(&to_push); - - set_led(LED_BLUE, 1); - can_push(&can_rx_q, &to_push); - - // 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 CAN2_TX_IRQHandler(void) { process_can(1); } -void CAN2_RX0_IRQHandler(void) { can_rx(1); } -void CAN2_SCE_IRQHandler(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 can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number) { - if (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 == 3) && (can_num_lookup[3] == 0xFF)) { - // TODO: why uint8 bro? only int8? - bitbang_gmlan(to_push); - } else { - can_push(can_queues[bus_number], to_push); - process_can(CAN_NUM_FROM_BUS_NUM(bus_number)); - } - } - } -} - -void can_set_forwarding(int from, int to) { - can_forwarding[from] = to; -} - diff --git a/panda/board/drivers/can_common.h b/panda/board/drivers/can_common.h new file mode 100644 index 00000000000000..5ec84056833e59 --- /dev/null +++ b/panda/board/drivers/can_common.h @@ -0,0 +1,254 @@ +typedef struct { + volatile uint32_t w_ptr; + volatile uint32_t r_ptr; + uint32_t fifo_size; + CANPacket_t *elems; +} can_ring; + +typedef struct { + uint8_t bus_lookup; + uint8_t can_num_lookup; + uint32_t can_speed; + uint32_t can_data_speed; + bool canfd_enabled; + bool brs_enabled; +} bus_config_t; + +#define CAN_BUS_NUM_MASK 0x3FU + +#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; + +extern int can_live; +extern int pending_can_live; + +// must reinit after changing these +extern int can_loopback; +extern int can_silent; + +// Ignition detected from CAN meessages +bool ignition_can = false; +bool ignition_cadillac = false; +uint32_t ignition_can_cnt = 0U; + +#define ALL_CAN_SILENT 0xFF +#define ALL_CAN_LIVE 0 + +int can_live = 0; +int pending_can_live = 0; +int can_loopback = 0; +int can_silent = ALL_CAN_SILENT; + +// ******************* functions prototypes ********************* +bool can_init(uint8_t can_number); +void process_can(uint8_t can_number); + +// ********************* instantiate queues ********************* +#define can_buffer(x, size) \ + CANPacket_t elems_##x[size]; \ + can_ring can_##x = { .w_ptr = 0, .r_ptr = 0, .fifo_size = (size), .elems = (CANPacket_t *)&(elems_##x) }; + +#ifdef STM32H7 +__attribute__((section(".ram_d1"))) can_buffer(rx_q, 0x1000) +__attribute__((section(".ram_d1"))) can_buffer(txgmlan_q, 0x1A0) +#else +can_buffer(rx_q, 0x1000) +can_buffer(txgmlan_q, 0x1A0) +#endif +can_buffer(tx1_q, 0x1A0) +can_buffer(tx2_q, 0x1A0) +can_buffer(tx3_q, 0x1A0) +// FIXME: +// cppcheck-suppress misra-c2012-9.3 +can_ring *can_queues[] = {&can_tx1_q, &can_tx2_q, &can_tx3_q, &can_txgmlan_q}; + +// global CAN stats +int can_rx_cnt = 0; +int can_tx_cnt = 0; +int can_txd_cnt = 0; +int can_err_cnt = 0; +int can_overflow_cnt = 0; + +// ********************* interrupt safe queue ********************* +bool can_pop(can_ring *q, CANPacket_t *elem) { + bool ret = 0; + + ENTER_CRITICAL(); + if (q->w_ptr != q->r_ptr) { + *elem = q->elems[q->r_ptr]; + if ((q->r_ptr + 1U) == q->fifo_size) { + q->r_ptr = 0; + } else { + q->r_ptr += 1U; + } + ret = 1; + } + EXIT_CRITICAL(); + + return ret; +} + +bool can_push(can_ring *q, CANPacket_t *elem) { + bool ret = false; + uint32_t next_w_ptr; + + ENTER_CRITICAL(); + if ((q->w_ptr + 1U) == q->fifo_size) { + next_w_ptr = 0; + } else { + next_w_ptr = q->w_ptr + 1U; + } + if (next_w_ptr != q->r_ptr) { + q->elems[q->w_ptr] = *elem; + q->w_ptr = next_w_ptr; + ret = true; + } + EXIT_CRITICAL(); + if (!ret) { + can_overflow_cnt++; + #ifdef DEBUG + puts("can_push to "); + if (q == &can_rx_q) { + puts("can_rx_q"); + } else if (q == &can_tx1_q) { + puts("can_tx1_q"); + } else if (q == &can_tx2_q) { + puts("can_tx2_q"); + } else if (q == &can_tx3_q) { + puts("can_tx3_q"); + } else if (q == &can_txgmlan_q) { + puts("can_txgmlan_q"); + } else { + puts("unknown"); + } + puts(" failed!\n"); + #endif + } + 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(); + q->w_ptr = 0; + q->r_ptr = 0; + EXIT_CRITICAL(); + // handle TX buffer full with zero ECUs awake on the bus + usb_cb_ep3_out_complete(); +} + +// assign CAN numbering +// bus num: Can bus number on ODB connector. Sent to/from USB +// Min: 0; Max: 127; Bit 7 marks message as receipt (bus 129 is receipt for but 1) +// cans: Look up MCU can interface from bus number +// can number: numeric lookup for MCU CAN interfaces (0 = CAN1, 1 = CAN2, etc); +// bus_lookup: Translates from 'can number' to 'bus number'. +// can_num_lookup: Translates from 'bus number' to 'can number'. + +// Helpers +// Panda: Bus 0=CAN1 Bus 1=CAN2 Bus 2=CAN3 +bus_config_t bus_config[] = { + { .bus_lookup = 0U, .can_num_lookup = 0U, .can_speed = 5000U, .can_data_speed = 5000U, .canfd_enabled = false, .brs_enabled = false }, + { .bus_lookup = 1U, .can_num_lookup = 1U, .can_speed = 5000U, .can_data_speed = 5000U, .canfd_enabled = false, .brs_enabled = false }, + { .bus_lookup = 2U, .can_num_lookup = 2U, .can_speed = 5000U, .can_data_speed = 5000U, .canfd_enabled = false, .brs_enabled = false }, + { .bus_lookup = 0xFFU, .can_num_lookup = 0xFFU, .can_speed = 333U, .can_data_speed = 333U, .canfd_enabled = false, .brs_enabled = false }, +}; + +#define CAN_MAX 3U + +#define CANIF_FROM_CAN_NUM(num) (cans[num]) +#define BUS_NUM_FROM_CAN_NUM(num) (bus_config[num].bus_lookup) +#define CAN_NUM_FROM_BUS_NUM(num) (bus_config[num].can_num_lookup) + +void can_init_all(void) { + 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){ + bus_config[bus1].bus_lookup = bus2; + bus_config[bus2].bus_lookup = bus1; + bus_config[bus1].can_num_lookup = bus2; + bus_config[bus2].can_num_lookup = bus1; +} + +void ignition_can_hook(CANPacket_t *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) { + // GM exception + // 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) != 0U; + } + if ((addr == 0x1F1) && (len == 8)) { + // Bit 5 is ignition "on" + bool ignition_gm = ((GET_BYTE(to_push, 0) & 0x20U) != 0U); + ignition_can = ignition_gm || ignition_cadillac; + } + + // Tesla exception + if ((addr == 0x348) && (len == 8)) { + // GTW_status + ignition_can = (GET_BYTE(to_push, 0) & 0x1U) != 0U; + } + + // Mazda exception + if ((addr == 0x9E) && (len == 8)) { + ignition_can = (GET_BYTE(to_push, 0) >> 4) == 0xDU; + } + + } +} + +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(CANPacket_t *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 + if ((bus_number == 3U) && (bus_config[3].can_num_lookup == 0xFFU)) { + gmlan_send_errs += bitbang_gmlan(to_push) ? 0U : 1U; + } else { + can_fwd_errs += can_push(can_queues[bus_number], to_push) ? 0U : 1U; + process_can(CAN_NUM_FROM_BUS_NUM(bus_number)); + } + } + } else { + to_push->rejected = 1U; + can_send_errs += can_push(&can_rx_q, to_push) ? 0U : 1U; + } +} diff --git a/panda/board/drivers/clock.h b/panda/board/drivers/clock.h deleted file mode 100644 index a9f2dea730495f..00000000000000 --- a/panda/board/drivers/clock.h +++ /dev/null @@ -1,40 +0,0 @@ -void clock_init(void) { - // enable external oscillator - RCC->CR |= RCC_CR_HSEON; - while ((RCC->CR & RCC_CR_HSERDY) == 0); - - // divide shit - RCC->CFGR = RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4; - - // 16mhz crystal - RCC->PLLCFGR = RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 | - RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE; - - // start PLL - RCC->CR |= RCC_CR_PLLON; - while ((RCC->CR & RCC_CR_PLLRDY) == 0); - - // Configure Flash prefetch, Instruction cache, Data cache and wait state - // *** without this, it breaks *** - FLASH->ACR = FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS; - - // switch to PLL - RCC->CFGR |= RCC_CFGR_SW_PLL; - while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); - - // *** running on PLL *** -} - -void watchdog_init(void) { - // setup watchdog - IWDG->KR = 0x5555; - IWDG->PR = 0; // divider /4 - // 0 = 0.125 ms, let's have a 50ms watchdog - IWDG->RLR = 400 - 1; - IWDG->KR = 0xCCCC; -} - -void watchdog_feed(void) { - IWDG->KR = 0xAAAA; -} - diff --git a/panda/board/drivers/dac.h b/panda/board/drivers/dac.h deleted file mode 100644 index b8833dc4a62cfe..00000000000000 --- a/panda/board/drivers/dac.h +++ /dev/null @@ -1,16 +0,0 @@ -void dac_init() { - // 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; -} - -void dac_set(int channel, uint32_t value) { - if (channel == 0) { - DAC->DHR12R1 = value; - } else if (channel == 1) { - DAC->DHR12R2 = value; - } -} - diff --git a/panda/board/drivers/fan.h b/panda/board/drivers/fan.h new file mode 100644 index 00000000000000..c273972a1d5e29 --- /dev/null +++ b/panda/board/drivers/fan.h @@ -0,0 +1,14 @@ +uint16_t fan_tach_counter = 0U; +uint16_t fan_rpm = 0U; + +void fan_set_power(uint8_t percentage){ + pwm_set(TIM3, 3, percentage); +} + +// 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; +} diff --git a/panda/board/drivers/fdcan.h b/panda/board/drivers/fdcan.h new file mode 100644 index 00000000000000..c5428d02774017 --- /dev/null +++ b/panda/board/drivers/fdcan.h @@ -0,0 +1,218 @@ +// IRQs: FDCAN1_IT0, FDCAN1_IT1 +// FDCAN2_IT0, FDCAN2_IT1 +// FDCAN3_IT0, FDCAN3_IT1 + +#define BUS_OFF_FAIL_LIMIT 2U +uint8_t bus_off_err[] = {0U, 0U, 0U}; + +typedef struct { + volatile uint32_t header[2]; + volatile uint32_t data_word[CANPACKET_DATA_SIZE_MAX/4U]; +} canfd_fifo; + +FDCAN_GlobalTypeDef *cans[] = {FDCAN1, FDCAN2, FDCAN3}; + +bool can_set_speed(uint8_t can_number) { + bool ret = true; + FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); + uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); + + ret &= llcan_set_speed(CANx, bus_config[bus_number].can_speed, bus_config[bus_number].can_data_speed, can_loopback, (unsigned int)(can_silent) & (1U << can_number)); + return ret; +} + +void can_set_gmlan(uint8_t bus) { + UNUSED(bus); + puts("GMLAN not available on red panda\n"); +} + +void cycle_transceiver(uint8_t can_number) { + // FDCAN1 = trans 1, FDCAN3 = trans 3, FDCAN2 = trans 2 normal or 4 flipped harness + uint8_t transceiver_number = can_number; + if (can_number == 2U) { + uint8_t flip = (car_harness_status == HARNESS_STATUS_FLIPPED) ? 2U : 0U; + transceiver_number += flip; + } + current_board->enable_can_transceiver(transceiver_number, false); + delay(20000); + current_board->enable_can_transceiver(transceiver_number, true); + bus_off_err[can_number] = 0U; + puts("Cycled transceiver number: "); puth(transceiver_number); puts("\n"); +} + +// ***************************** CAN ***************************** +void process_can(uint8_t can_number) { + if (can_number != 0xffU) { + ENTER_CRITICAL(); + + FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); + uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); + + CANx->IR |= FDCAN_IR_TFE; // Clear Tx FIFO Empty flag + + if ((CANx->TXFQS & FDCAN_TXFQS_TFQF) == 0) { + CANPacket_t to_send; + if (can_pop(can_queues[bus_number], &to_send)) { + can_tx_cnt += 1; + uint32_t TxFIFOSA = FDCAN_START_ADDRESS + (can_number * FDCAN_OFFSET) + (FDCAN_RX_FIFO_0_EL_CNT * FDCAN_RX_FIFO_0_EL_SIZE); + uint8_t tx_index = (CANx->TXFQS >> FDCAN_TXFQS_TFQPI_Pos) & 0x1F; + // only send if we have received a packet + canfd_fifo *fifo; + fifo = (canfd_fifo *)(TxFIFOSA + (tx_index * FDCAN_TX_FIFO_EL_SIZE)); + + fifo->header[0] = (to_send.extended << 30) | ((to_send.extended != 0U) ? (to_send.addr) : (to_send.addr << 18)); + fifo->header[1] = (to_send.data_len_code << 16) | (bus_config[can_number].canfd_enabled << 21) | (bus_config[can_number].brs_enabled << 20); + + uint8_t data_len_w = (dlc_to_len[to_send.data_len_code] / 4U); + data_len_w += ((dlc_to_len[to_send.data_len_code] % 4U) > 0U) ? 1U : 0U; + for (unsigned int i = 0; i < data_len_w; i++) { + BYTE_ARRAY_TO_WORD(fifo->data_word[i], &to_send.data[i*4U]); + } + + CANx->TXBAR = (1UL << tx_index); + + // Send back to USB + can_txd_cnt += 1; + CANPacket_t to_push; + + to_push.returned = 1U; + to_push.rejected = 0U; + to_push.extended = to_send.extended; + to_push.addr = to_send.addr; + to_push.bus = to_send.bus; + to_push.data_len_code = to_send.data_len_code; + (void)memcpy(to_push.data, to_send.data, dlc_to_len[to_push.data_len_code]); + can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; + + usb_cb_ep3_out_complete(); + } + } + + // Recover after Bus-off state + if (((CANx->PSR & FDCAN_PSR_BO) != 0) && ((CANx->CCCR & FDCAN_CCCR_INIT) != 0)) { + bus_off_err[can_number] += 1U; + puts("CAN is in Bus_Off state! Resetting... CAN number: "); puth(can_number); puts("\n"); + if (bus_off_err[can_number] > BUS_OFF_FAIL_LIMIT) { + cycle_transceiver(can_number); + } + CANx->IR = 0xFFC60000U; // Reset all flags(Only errors!) + CANx->CCCR &= ~(FDCAN_CCCR_INIT); + uint32_t timeout_counter = 0U; + while((CANx->CCCR & FDCAN_CCCR_INIT) != 0) { + // Delay for about 1ms + delay(10000); + timeout_counter++; + + if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ + puts(CAN_NAME_FROM_CANIF(CANx)); puts(" Bus_Off reset timed out!\n"); + break; + } + } + } + EXIT_CRITICAL(); + } +} + +// CAN receive handlers +// blink blue when we are receiving CAN messages +void can_rx(uint8_t can_number) { + FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); + uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); + uint8_t rx_fifo_idx; + + // Rx FIFO 0 new message + if((CANx->IR & FDCAN_IR_RF0N) != 0) { + CANx->IR |= FDCAN_IR_RF0N; + while((CANx->RXF0S & FDCAN_RXF0S_F0FL) != 0) { + can_rx_cnt += 1; + + // can is live + pending_can_live = 1; + + // getting new message index (0 to 63) + rx_fifo_idx = (uint8_t)((CANx->RXF0S >> FDCAN_RXF0S_F0GI_Pos) & 0x3F); + + uint32_t RxFIFO0SA = FDCAN_START_ADDRESS + (can_number * FDCAN_OFFSET); + CANPacket_t to_push; + canfd_fifo *fifo; + + // getting address + fifo = (canfd_fifo *)(RxFIFO0SA + (rx_fifo_idx * FDCAN_RX_FIFO_0_EL_SIZE)); + + to_push.returned = 0U; + to_push.rejected = 0U; + to_push.extended = (fifo->header[0] >> 30) & 0x1U; + to_push.addr = ((to_push.extended != 0U) ? (fifo->header[0] & 0x1FFFFFFFU) : ((fifo->header[0] >> 18) & 0x7FFU)); + to_push.bus = bus_number; + to_push.data_len_code = ((fifo->header[1] >> 16) & 0xFU); + + uint8_t data_len_w = (dlc_to_len[to_push.data_len_code] / 4U); + data_len_w += ((dlc_to_len[to_push.data_len_code] % 4U) > 0U) ? 1U : 0U; + for (unsigned int i = 0; i < data_len_w; i++) { + WORD_TO_BYTE_ARRAY(&to_push.data[i*4U], fifo->data_word[i]); + } + + // forwarding (panda only) + int bus_fwd_num = safety_fwd_hook(bus_number, &to_push); + if (bus_fwd_num != -1) { + CANPacket_t to_send; + + to_send.returned = 0U; + to_send.rejected = 0U; + to_send.extended = to_push.extended; + to_send.addr = to_push.addr; + to_send.bus = to_push.bus; + to_send.data_len_code = to_push.data_len_code; + (void)memcpy(to_send.data, to_push.data, dlc_to_len[to_push.data_len_code]); + can_send(&to_send, bus_fwd_num, true); + } + + 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) ? 0U : 1U; + + // update read index + CANx->RXF0A = rx_fifo_idx; + } + + } else if((CANx->IR & (FDCAN_IR_PEA | FDCAN_IR_PED | FDCAN_IR_RF0L | FDCAN_IR_RF0F | FDCAN_IR_EW | FDCAN_IR_MRAF | FDCAN_IR_TOO)) != 0) { + #ifdef DEBUG + puts("FDCAN error, FDCAN_IR: ");puth(CANx->IR);puts("\n"); + #endif + CANx->IR |= (FDCAN_IR_PEA | FDCAN_IR_PED | FDCAN_IR_RF0L | FDCAN_IR_RF0F | FDCAN_IR_EW | FDCAN_IR_MRAF | FDCAN_IR_TOO); // Clean all error flags + can_err_cnt += 1; + } else { + + } +} + +void FDCAN1_IT0_IRQ_Handler(void) { can_rx(0); } +void FDCAN1_IT1_IRQ_Handler(void) { process_can(0); } + +void FDCAN2_IT0_IRQ_Handler(void) { can_rx(1); } +void FDCAN2_IT1_IRQ_Handler(void) { process_can(1); } + +void FDCAN3_IT0_IRQ_Handler(void) { can_rx(2); } +void FDCAN3_IT1_IRQ_Handler(void) { process_can(2); } + +bool can_init(uint8_t can_number) { + bool ret = false; + + REGISTER_INTERRUPT(FDCAN1_IT0_IRQn, FDCAN1_IT0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(FDCAN1_IT1_IRQn, FDCAN1_IT1_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) + REGISTER_INTERRUPT(FDCAN2_IT0_IRQn, FDCAN2_IT0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) + REGISTER_INTERRUPT(FDCAN2_IT1_IRQn, FDCAN2_IT1_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) + REGISTER_INTERRUPT(FDCAN3_IT0_IRQn, FDCAN3_IT0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) + REGISTER_INTERRUPT(FDCAN3_IT1_IRQn, FDCAN3_IT1_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) + + if (can_number != 0xffU) { + FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); + ret &= can_set_speed(can_number); + ret &= llcan_init(CANx); + // in case there are queued up messages + process_can(can_number); + } + return ret; +} diff --git a/panda/board/drivers/gmlan_alt.h b/panda/board/drivers/gmlan_alt.h index 357cffcd9984cb..2e5225691144a5 100644 --- a/panda/board/drivers/gmlan_alt.h +++ b/panda/board/drivers/gmlan_alt.h @@ -41,38 +41,41 @@ int do_bitstuff(char *out, char *in, int in_len) { } int append_crc(char *in, int in_len) { - int crc = 0; + unsigned int crc = 0; for (int i = 0; i < in_len; i++) { crc <<= 1; - if ((in[i] ^ ((crc >> 15) & 1)) != 0) { - crc = crc ^ 0x4599; + if (((unsigned int)(in[i]) ^ ((crc >> 15) & 1U)) != 0U) { + crc = crc ^ 0x4599U; } - crc &= 0x7fff; + crc &= 0x7fffU; } + int in_len_copy = in_len; for (int i = 14; i >= 0; i--) { - in[in_len] = (crc>>i)&1; - in_len++; + in[in_len_copy] = (crc >> (unsigned int)(i)) & 1U; + in_len_copy++; } - return in_len; + return in_len_copy; } int append_bits(char *in, int in_len, char *app, int app_len) { + int in_len_copy = in_len; for (int i = 0; i < app_len; i++) { - in[in_len] = app[i]; - in_len++; + in[in_len_copy] = app[i]; + in_len_copy++; } - return in_len; + return in_len_copy; } int append_int(char *in, int in_len, int val, int val_len) { - for (int i = val_len-1; i >= 0; i--) { - in[in_len] = (val&(1<= 0; i--) { + in[in_len_copy] = ((unsigned int)(val) & (1U << (unsigned int)(i))) != 0U; + in_len_copy++; } - return in_len; + return in_len_copy; } -int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) { +int get_bit_message(char *out, CANPacket_t *to_bang) { char pkt[MAX_BITS_CAN_PACKET]; char footer[] = { 1, // CRC delimiter @@ -85,18 +88,18 @@ int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) { int len = 0; // test packet - int dlc_len = to_bang->RDTR & 0xF; + int dlc_len = GET_LEN(to_bang); len = append_int(pkt, len, 0, 1); // Start-of-frame - if ((to_bang->RIR & 4) != 0) { + if (to_bang->extended != 0U) { // extended identifier - len = append_int(pkt, len, to_bang->RIR >> 21, 11); // Identifier + len = append_int(pkt, len, GET_ADDR(to_bang) >> 18, 11); // Identifier len = append_int(pkt, len, 3, 2); // SRR+IDE - len = append_int(pkt, len, (to_bang->RIR >> 3) & ((1<<18)-1), 18); // Identifier + len = append_int(pkt, len, (GET_ADDR(to_bang)) & ((1U << 18) - 1U), 18); // Identifier len = append_int(pkt, len, 0, 3); // RTR+r1+r0 } else { // standard identifier - len = append_int(pkt, len, to_bang->RIR >> 21, 11); // Identifier + len = append_int(pkt, len, GET_ADDR(to_bang), 11); // Identifier len = append_int(pkt, len, 0, 3); // RTR+IDE+reserved } @@ -104,8 +107,7 @@ int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) { // append data for (int i = 0; i < dlc_len; i++) { - unsigned char dat = ((unsigned char *)(&(to_bang->RDLR)))[i]; - len = append_int(pkt, len, dat, 8); + len = append_int(pkt, len, to_bang->data[i], 8); } // append crc @@ -119,18 +121,23 @@ int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) { return len; } -void setup_timer4(void) { +void TIM12_IRQ_Handler(void); + +void setup_timer(void) { + // register interrupt + REGISTER_INTERRUPT(TIM8_BRK_TIM12_IRQn, TIM12_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(&(TIM12->PSC), (48-1), 0xFFFFU); // Tick on 1 us + register_set(&(TIM12->CR1), TIM_CR1_CEN, 0x3FU); // Enable + register_set(&(TIM12->ARR), (30-1), 0xFFFFU); // 33.3 kbps // in case it's disabled - NVIC_EnableIRQ(TIM4_IRQn); + NVIC_EnableIRQ(TIM8_BRK_TIM12_IRQn); // run the interrupt - TIM4->DIER = TIM_DIER_UIE; // update interrupt - TIM4->SR = 0; + register_set(&(TIM12->DIER), TIM_DIER_UIE, 0x5F5FU); // Update interrupt + TIM12->SR = 0; } int gmlan_timeout_counter = GMLAN_TICKS_PER_TIMEOUT_TICKLE; //GMLAN transceiver times out every 17ms held high; tickle every 15ms @@ -146,7 +153,7 @@ void gmlan_switch_init(int timeout_enable) { gmlan_switch_below_timeout = 1; set_gpio_mode(GPIOB, 13, MODE_OUTPUT); - setup_timer4(); + setup_timer(); inverted_bit_to_send = GMLAN_LOW; //We got initialized, set the output low } @@ -168,24 +175,25 @@ void reset_gmlan_switch_timeout(void) { void set_bitbanged_gmlan(int val) { if (val != 0) { - GPIOB->ODR |= (1 << 13); + register_set_bits(&(GPIOB->ODR), (1U << 13)); } else { - GPIOB->ODR &= ~(1 << 13); + register_clear_bits(&(GPIOB->ODR), (1U << 13)); } } char pkt_stuffed[MAX_BITS_CAN_PACKET]; int gmlan_sending = -1; int gmlan_sendmax = -1; +bool gmlan_send_ok = true; int gmlan_silent_count = 0; int gmlan_fail_count = 0; #define REQUIRED_SILENT_TIME 10 #define MAX_FAIL_COUNT 10 -void TIM4_IRQHandler(void) { +void TIM12_IRQ_Handler(void) { if (gmlan_alt_mode == BITBANG) { - if ((TIM4->SR & TIM_SR_UIF) && (gmlan_sendmax != -1)) { + if ((TIM12->SR & TIM_SR_UIF) && (gmlan_sendmax != -1)) { int read = get_gpio_input(GPIOB, 12); if (gmlan_silent_count < REQUIRED_SILENT_TIME) { if (read == 0) { @@ -193,7 +201,7 @@ void TIM4_IRQHandler(void) { } else { gmlan_silent_count++; } - } else if (gmlan_silent_count == REQUIRED_SILENT_TIME) { + } else { bool retry = 0; // in send loop if ((gmlan_sending > 0) && // not first bit @@ -206,6 +214,8 @@ void TIM4_IRQHandler(void) { } else if ((read == 1) && (gmlan_sending == (gmlan_sendmax - 11))) { // recessive during ACK puts("GMLAN ERR: didn't recv ACK\n"); retry = 1; + } else { + // do not retry } if (retry) { // reset sender (retry after 7 silent) @@ -215,6 +225,7 @@ void TIM4_IRQHandler(void) { gmlan_fail_count++; if (gmlan_fail_count == MAX_FAIL_COUNT) { puts("GMLAN ERR: giving up send\n"); + gmlan_send_ok = false; } } else { set_bitbanged_gmlan(pkt_stuffed[gmlan_sending]); @@ -224,16 +235,13 @@ 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(&(TIM12->DIER), TIM_DIER_UIE); // No update interrupt + register_set(&(TIM12->CR1), 0U, 0x3FU); // Disable timer gmlan_sendmax = -1; // exit } } - TIM4->SR = 0; - } //bit bang mode - - else if (gmlan_alt_mode == GPIO_SWITCH) { - if ((TIM4->SR & TIM_SR_UIF) && (gmlan_switch_below_timeout != -1)) { + } else if (gmlan_alt_mode == GPIO_SWITCH) { + if ((TIM12->SR & TIM_SR_UIF) && (gmlan_switch_below_timeout != -1)) { if ((can_timeout_counter == 0) && gmlan_switch_timeout_enable) { //it has been more than 1 second since timeout was reset; disable timer and restore the GMLAN output set_gpio_output(GPIOB, 13, GMLAN_LOW); @@ -254,26 +262,28 @@ void TIM4_IRQHandler(void) { } } } - TIM4->SR = 0; - } //gmlan switch mode + } else { + // Invalid GMLAN mode. Do not put a print statement here, way too fast to keep up with + } + TIM12->SR = 0; } -void bitbang_gmlan(CAN_FIFOMailBox_TypeDef *to_bang) { +bool bitbang_gmlan(CANPacket_t *to_bang) { + gmlan_send_ok = true; gmlan_alt_mode = BITBANG; - // TODO: make failure less silent - if (gmlan_sendmax == -1) { + if (gmlan_sendmax == -1) { int len = get_bit_message(pkt_stuffed, to_bang); gmlan_fail_count = 0; gmlan_silent_count = 0; gmlan_sending = 0; gmlan_sendmax = len; - // setup for bitbang loop set_bitbanged_gmlan(1); // recessive set_gpio_mode(GPIOB, 13, MODE_OUTPUT); - setup_timer4(); + // 33kbps + setup_timer(); } + return gmlan_send_ok; } - diff --git a/panda/board/drivers/gpio.h b/panda/board/drivers/gpio.h new file mode 100644 index 00000000000000..77af87658cae5b --- /dev/null +++ b/panda/board/drivers/gpio.h @@ -0,0 +1,75 @@ +#define MODE_INPUT 0 +#define MODE_OUTPUT 1 +#define MODE_ALTERNATE 2 +#define MODE_ANALOG 3 + +#define PULL_NONE 0 +#define PULL_UP 1 +#define PULL_DOWN 2 + +#define OUTPUT_TYPE_PUSH_PULL 0U +#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)); + register_set(&(GPIO->MODER), tmp, 0xFFFFFFFFU); + EXIT_CRITICAL(); +} + +void set_gpio_output(GPIO_TypeDef *GPIO, unsigned int pin, bool enabled) { + ENTER_CRITICAL(); + if (enabled) { + register_set_bits(&(GPIO->ODR), (1U << pin)); + } else { + 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) { + register_set_bits(&(GPIO->OTYPER), (1U << pin)); + } else { + 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); + 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)); + register_set(&(GPIO->PUPDR), tmp, 0xFFFFFFFFU); + EXIT_CRITICAL(); +} + +int get_gpio_input(GPIO_TypeDef *GPIO, unsigned int pin) { + return (GPIO->IDR & (1U << pin)) == (1U << pin); +} + +// Detection with internal pullup +#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); + for (volatile int i=0; iharness_config->GPIO_relay_SBU2, current_board->harness_config->pin_relay_SBU2, !intercept); + } else { + set_gpio_output(current_board->harness_config->GPIO_relay_SBU1, current_board->harness_config->pin_relay_SBU1, !intercept); + } + } +} + +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_SBU1, current_board->harness_config->pin_SBU1); + break; + case HARNESS_STATUS_FLIPPED: + ret = !get_gpio_input(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2); + break; + default: + break; + } + return ret; +} + +uint8_t harness_detect_orientation(void) { + uint8_t ret = HARNESS_STATUS_NC; + + #ifndef BOOTSTUB + uint32_t sbu1_voltage = adc_get(current_board->harness_config->adc_channel_SBU1); + uint32_t sbu2_voltage = adc_get(current_board->harness_config->adc_channel_SBU2); + + // Detect connection and orientation + if((sbu1_voltage < HARNESS_CONNECTED_THRESHOLD) || (sbu2_voltage < HARNESS_CONNECTED_THRESHOLD)){ + if (sbu1_voltage < sbu2_voltage) { + // 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 + + return ret; +} + +void harness_init(void) { + // delay such that the connection is fully made before trying orientation detection + current_board->set_led(LED_BLUE, true); + delay(10000000); + current_board->set_led(LED_BLUE, false); + + // try to detect orientation + uint8_t ret = harness_detect_orientation(); + if (ret != HARNESS_STATUS_NC) { + puts("detected car harness with orientation "); puth2(ret); puts("\n"); + car_harness_status = ret; + + // set the SBU lines to be inputs before using the relay. The lines are not 5V tolerant in ADC mode! + 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); + + // keep busses connected by default + set_intercept_relay(false); + } else { + puts("failed to detect car harness!\n"); + } +} diff --git a/panda/board/drivers/interrupts.h b/panda/board/drivers/interrupts.h new file mode 100644 index 00000000000000..a9137f76d5016a --- /dev/null +++ b/panda/board/drivers/interrupts.h @@ -0,0 +1,58 @@ +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 interrupt_timer_init(void); + +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); +} + +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 interrupt_timer_handler(void) { + if (INTERRUPT_TIMER->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; iPSC), (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/llcan.h b/panda/board/drivers/llcan.h deleted file mode 100644 index 5d0b8884583afa..00000000000000 --- a/panda/board/drivers/llcan.h +++ /dev/null @@ -1,81 +0,0 @@ -// this is needed for 1 mbps support -#define CAN_QUANTA 8 -#define CAN_SEQ1 6 // roundf(quanta * 0.875f) - 1; -#define CAN_SEQ2 1 // roundf(quanta * 0.125f); - -#define CAN_PCLK 24000 -// 333 = 33.3 kbps -// 5000 = 500 kbps -#define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10 / (x)) - -bool llcan_set_speed(CAN_TypeDef *CAN, uint32_t speed, bool loopback, bool silent) { - // initialization mode - CAN->MCR = CAN_MCR_TTCM | CAN_MCR_INRQ; - while((CAN->MSR & CAN_MSR_INAK) != CAN_MSR_INAK); - - // set time quanta from defines - CAN->BTR = (CAN_BTR_TS1_0 * (CAN_SEQ1-1)) | - (CAN_BTR_TS2_0 * (CAN_SEQ2-1)) | - (can_speed_to_prescaler(speed) - 1); - - // silent loopback mode for debugging - if (loopback) { - CAN->BTR |= CAN_BTR_SILM | CAN_BTR_LBKM; - } - if (silent) { - CAN->BTR |= CAN_BTR_SILM; - } - - // reset - CAN->MCR = CAN_MCR_TTCM | CAN_MCR_ABOM; - - #define CAN_TIMEOUT 1000000 - int tmp = 0; - bool ret = false; - while(((CAN->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) && (tmp < CAN_TIMEOUT)) tmp++; - if (tmp < CAN_TIMEOUT) { - ret = true; - } - - return ret; -} - -void llcan_init(CAN_TypeDef *CAN) { - // accept all filter - CAN->FMR |= CAN_FMR_FINIT; - - // no mask - CAN->sFilterRegister[0].FR1 = 0; - CAN->sFilterRegister[0].FR2 = 0; - CAN->sFilterRegister[14].FR1 = 0; - CAN->sFilterRegister[14].FR2 = 0; - CAN->FA1R |= 1 | (1U << 14); - - CAN->FMR &= ~(CAN_FMR_FINIT); - - // enable certain CAN interrupts - CAN->IER |= CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE; - - if (CAN == CAN1) { - NVIC_EnableIRQ(CAN1_TX_IRQn); - NVIC_EnableIRQ(CAN1_RX0_IRQn); - NVIC_EnableIRQ(CAN1_SCE_IRQn); - } else if (CAN == CAN2) { - NVIC_EnableIRQ(CAN2_TX_IRQn); - NVIC_EnableIRQ(CAN2_RX0_IRQn); - NVIC_EnableIRQ(CAN2_SCE_IRQn); -#ifdef CAN3 - } else if (CAN == CAN3) { - NVIC_EnableIRQ(CAN3_TX_IRQn); - NVIC_EnableIRQ(CAN3_RX0_IRQn); - NVIC_EnableIRQ(CAN3_SCE_IRQn); -#endif - } -} - -void llcan_clear_send(CAN_TypeDef *CAN) { - CAN->TSR |= CAN_TSR_ABRQ0; - CAN->MSR &= ~(CAN_MSR_ERRI); - CAN->MSR = CAN->MSR; -} - diff --git a/panda/board/drivers/llgpio.h b/panda/board/drivers/llgpio.h deleted file mode 100644 index 172776eb35d3cc..00000000000000 --- a/panda/board/drivers/llgpio.h +++ /dev/null @@ -1,44 +0,0 @@ -#define MODE_INPUT 0 -#define MODE_OUTPUT 1 -#define MODE_ALTERNATE 2 -#define MODE_ANALOG 3 - -#define PULL_NONE 0 -#define PULL_UP 1 -#define PULL_DOWN 2 - -void set_gpio_mode(GPIO_TypeDef *GPIO, int pin, int mode) { - uint32_t tmp = GPIO->MODER; - tmp &= ~(3 << (pin*2)); - tmp |= (mode << (pin*2)); - GPIO->MODER = tmp; -} - -void set_gpio_output(GPIO_TypeDef *GPIO, int pin, bool enabled) { - if (enabled) { - GPIO->ODR |= (1 << pin); - } else { - GPIO->ODR &= ~(1 << pin); - } - set_gpio_mode(GPIO, pin, MODE_OUTPUT); -} - -void set_gpio_alternate(GPIO_TypeDef *GPIO, int pin, int mode) { - uint32_t tmp = GPIO->AFR[pin>>3]; - tmp &= ~(0xF << ((pin&7)*4)); - tmp |= mode << ((pin&7)*4); - GPIO->AFR[pin>>3] = tmp; - set_gpio_mode(GPIO, pin, MODE_ALTERNATE); -} - -void set_gpio_pullup(GPIO_TypeDef *GPIO, int pin, int mode) { - uint32_t tmp = GPIO->PUPDR; - tmp &= ~(3 << (pin*2)); - tmp |= (mode << (pin*2)); - GPIO->PUPDR = tmp; -} - -int get_gpio_input(GPIO_TypeDef *GPIO, int pin) { - return (GPIO->IDR & (1U << pin)) == (1U << pin); -} - diff --git a/panda/board/drivers/pwm.h b/panda/board/drivers/pwm.h new file mode 100644 index 00000000000000..67e5181e1a1c7b --- /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; + } +} diff --git a/panda/board/drivers/registers.h b/panda/board/drivers/registers.h new file mode 100644 index 00000000000000..4595a568672309 --- /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(current_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 + disable_bdomain_protection(); + + // 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 + enable_bdomain_protection(); + } + } +} + +void rtc_set_time(timestamp_t time){ + if(current_board->has_rtc){ + puts("Setting RTC time\n"); + + // Disable write protection + disable_bdomain_protection(); + 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; + enable_bdomain_protection(); + } +} + +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(current_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; +} diff --git a/panda/board/drivers/spi.h b/panda/board/drivers/spi.h deleted file mode 100644 index b61cd719a17514..00000000000000 --- a/panda/board/drivers/spi.h +++ /dev/null @@ -1,127 +0,0 @@ -// IRQs: DMA2_Stream2, DMA2_Stream3, EXTI4 - -void spi_init(void); -int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out); - -// end API - -#define SPI_BUF_SIZE 256 -uint8_t spi_buf[SPI_BUF_SIZE]; -int spi_buf_count = 0; -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 |= (1 << 4); - EXTI->FTSR |= (1 << 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; - - // DMA2, stream 3, channel 3 - DMA2_Stream3->M0AR = (uint32_t)addr; - DMA2_Stream3->NDTR = len; - DMA2_Stream3->PAR = (uint32_t)&(SPI1->DR); - - // 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; - delay(0); - DMA2_Stream3->CR |= DMA_SxCR_TCIE; - - SPI1->CR2 |= SPI_CR2_TXDMAEN; - - // signal data is ready by driving low - // esp must be configured as input by this point - set_gpio_output(GPIOB, 0, 0); -} - -void spi_rx_dma(void *addr, int len) { - // disable DMA - SPI1->CR2 &= ~SPI_CR2_RXDMAEN; - 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; - DMA2_Stream2->NDTR = len; - DMA2_Stream2->PAR = (uint32_t)&(SPI1->DR); - - // channel3, increment memory, periph -> memory, enable - DMA2_Stream2->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_EN; - delay(0); - DMA2_Stream2->CR |= DMA_SxCR_TCIE; - - 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) { - int *resp_len = (int*)spi_tx_buf; - memset(spi_tx_buf, 0xaa, 0x44); - *resp_len = spi_cb_rx(spi_buf, 0x14, spi_tx_buf+4); - #ifdef DEBUG_SPI - puts("SPI write: "); - puth(*resp_len); - puts("\n"); - #endif - spi_tx_dma(spi_tx_buf, *resp_len + 4); - - // ack - DMA2->LIFCR = DMA_LIFCR_CTCIF2; -} - -// SPI TX -void DMA2_Stream3_IRQHandler(void) { - #ifdef DEBUG_SPI - puts("SPI handshake\n"); - #endif - - // reset handshake back to pull up - set_gpio_mode(GPIOB, 0, MODE_INPUT); - set_gpio_pullup(GPIOB, 0, PULL_UP); - - // ack - DMA2->LIFCR = DMA_LIFCR_CTCIF3; -} - -void EXTI4_IRQHandler(void) { - volatile int pr = EXTI->PR & (1 << 4); - #ifdef DEBUG_SPI - puts("exti4\n"); - #endif - // SPI CS falling - if ((pr & (1 << 4)) != 0) { - spi_total_count = 0; - spi_rx_dma(spi_buf, 0x14); - } - EXTI->PR = pr; -} - diff --git a/panda/board/drivers/timer.h b/panda/board/drivers/timer.h deleted file mode 100644 index a14b619e4b81e3..00000000000000 --- a/panda/board/drivers/timer.h +++ /dev/null @@ -1,7 +0,0 @@ -void timer_init(TIM_TypeDef *TIM, int psc) { - TIM->PSC = psc-1; - TIM->DIER = TIM_DIER_UIE; - TIM->CR1 = TIM_CR1_CEN; - TIM->SR = 0; -} - diff --git a/panda/board/drivers/timers.h b/panda/board/drivers/timers.h new file mode 100644 index 00000000000000..eb053988631179 --- /dev/null +++ b/panda/board/drivers/timers.h @@ -0,0 +1,31 @@ +void timer_init(TIM_TypeDef *TIM, int psc) { + 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; +} + +void microsecond_timer_init(void) { + MICROSECOND_TIMER->PSC = (APB1_FREQ)-1U; + MICROSECOND_TIMER->CR1 = TIM_CR1_CEN; + MICROSECOND_TIMER->EGR = TIM_EGR_UG; +} + +uint32_t microsecond_timer_get(void) { + return MICROSECOND_TIMER->CNT; +} + +void interrupt_timer_init(void) { + enable_interrupt_timer(); + REGISTER_INTERRUPT(INTERRUPT_TIMER_IRQ, interrupt_timer_handler, 1, FAULT_INTERRUPT_RATE_INTERRUPTS) + register_set(&(INTERRUPT_TIMER->PSC), ((uint16_t)(15.25*APB1_FREQ)-1U), 0xFFFFU); + register_set(&(INTERRUPT_TIMER->DIER), TIM_DIER_UIE, 0x5F5FU); + register_set(&(INTERRUPT_TIMER->CR1), TIM_CR1_CEN, 0x3FU); + INTERRUPT_TIMER->SR = 0; + NVIC_EnableIRQ(INTERRUPT_TIMER_IRQ); +} + +void tick_timer_init(void) { + timer_init(TICK_TIMER, (uint16_t)((15.25*APB2_FREQ)/8U)); + NVIC_EnableIRQ(TICK_TIMER_IRQ); +} diff --git a/panda/board/drivers/uart.h b/panda/board/drivers/uart.h index f86c5f159307e8..d6107a6c3faa42 100644 --- a/panda/board/drivers/uart.h +++ b/panda/board/drivers/uart.h @@ -1,68 +1,72 @@ // IRQs: USART1, USART2, USART3, UART5 -#define FIFO_SIZE 0x400 +// ***************************** 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); - -bool getc(uart_ring *q, char *elem); -bool putc(uart_ring *q, char elem); - -void puts(const char *a); -void puth(unsigned int i); -void hexdump(const void *a, int l); - +#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 debug_ring_callback(uart_ring *ring); +void uart_tx_ring(uart_ring *q); +void uart_send_break(uart_ring *u); -// ***************************** 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 +75,17 @@ 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; - - 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 + 1) % FIFO_SIZE; - } - // there could be more to send - q->uart->CR1 |= USART_CR1_TXEIE; - } else { - // nothing to send - q->uart->CR1 &= ~USART_CR1_TXEIE; - } - - 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 + 1) % 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); - } - } - } - } - - if ((sr & USART_SR_ORE) != 0) { - // set dropped packet flag? - } - - exit_critical_section(); -} - -// interrupt boilerplate - -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); } - +// ************************* 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 + 1) % 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 +94,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 + 1) % 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 +110,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 + 1) % 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,179 +135,78 @@ 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); } } -void uart_send_break(uart_ring *u) { - while ((u->uart->CR1 & USART_CR1_SBK) != 0); - u->uart->CR1 |= USART_CR1_SBK; -} - 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_) * 25) / (4 * (_BAUD_))) -#define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_)) / 100) -#define __DIVFRAQ(_PCLK_, _BAUD_) ((((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16) + 50) / 100) -#define __USART_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4) | (__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) - -void uart_set_baud(USART_TypeDef *u, int baud) { - if (u == USART1) { - // USART1 is on APB2 - u->BRR = __USART_BRR(48000000, baud); - } else { - u->BRR = __USART_BRR(24000000, 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 + 1) % 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); - } + 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 { - injectc(&debug_ring, a); + // misra-c2012-17.7: serial debug function, ok to ignore output + (void)injectc(&uart_ring_debug, a); } } void puts(const char *a) { - for (;*a;a++) { - if (*a == '\n') putch('\r'); - putch(*a); + for (const char *in = a; *in; in++) { + if (*in == '\n') putch('\r'); + putch(*in); } } void putui(uint32_t i) { + uint32_t i_copy = i; char str[11]; uint8_t idx = 10; str[idx] = '\0'; idx--; do { - str[idx] = (i % 10) + 0x30; + str[idx] = (i_copy % 10U) + 0x30U; idx--; - i /= 10; - } while (i != 0); - puts(str + idx + 1); + i_copy /= 10; + } while (i_copy != 0U); + puts(&str[idx + 1U]); } -void puth(unsigned int i) { - int pos; - char c[] = "0123456789abcdef"; - for (pos = 28; pos != -4; pos -= 4) { - putch(c[(i >> pos) & 0xF]); +void puthx(uint32_t i, uint8_t len) { + const char c[] = "0123456789abcdef"; + for (int pos = ((int)len * 4) - 4; pos > -4; pos -= 4) { + putch(c[(i >> (unsigned int)(pos)) & 0xFU]); } } +void puth(unsigned int i) { + puthx(i, 8U); +} + void puth2(unsigned int i) { - int pos; - char c[] = "0123456789abcdef"; - for (pos = 4; pos != -4; pos -= 4) { - putch(c[(i >> pos) & 0xF]); - } + puthx(i, 2U); +} + +void puth4(unsigned int i) { + puthx(i, 4U); } void hexdump(const void *a, int l) { - int i; - for (i=0;i> 8) & 0xFF) + ((num) & 0xFFU), (((num) >> 8) & 0xFFU) // take in string length and return the first 2 bytes of a string descriptor #define STRING_DESCRIPTOR_HEADER(size)\ @@ -137,11 +124,7 @@ uint8_t device_desc[] = { 0xFF, 0xFF, 0xFF, 0x40, // Class, Subclass, Protocol, Max Packet Size TOUSBORDER(USB_VID), // idVendor TOUSBORDER(USB_PID), // idProduct -#ifdef STM32F4 - 0x00, 0x23, // bcdDevice -#else - 0x00, 0x22, // bcdDevice -#endif + 0x00, 0x00, // bcdDevice 0x01, 0x02, // Manufacturer, Product 0x03, 0x01 // Serial Number, Num Configurations }; @@ -158,7 +141,7 @@ uint8_t device_qualifier[] = { uint8_t configuration_desc[] = { DSCR_CONFIG_LEN, USB_DESC_TYPE_CONFIGURATION, // Length, Type, - TOUSBORDER(0x0045), // Total Len (uint16) + TOUSBORDER(0x0045U), // Total Len (uint16) 0x01, 0x01, STRING_OFFSET_ICONFIGURATION, // Num Interface, Config Value, Configuration 0xc0, 0x32, // Attributes, Max Power // interface 0 ALT 0 @@ -169,17 +152,17 @@ uint8_t configuration_desc[] = { // endpoint 1, read CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_RCV | 1, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type - TOUSBORDER(0x0040), // Max Packet (0x0040) + TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval (NA) // endpoint 2, send serial DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 2, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type - TOUSBORDER(0x0040), // Max Packet (0x0040) + TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval // endpoint 3, send CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 3, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type - TOUSBORDER(0x0040), // Max Packet (0x0040) + TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval // interface 0 ALT 1 DSCR_INTERFACE_LEN, USB_DESC_TYPE_INTERFACE, // Length, Type @@ -189,17 +172,17 @@ uint8_t configuration_desc[] = { // endpoint 1, read CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_RCV | 1, ENDPOINT_TYPE_INT, // Endpoint Num/Direction, Type - TOUSBORDER(0x0040), // Max Packet (0x0040) + TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x05, // Polling Interval (5 frames) // endpoint 2, send serial DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 2, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type - TOUSBORDER(0x0040), // Max Packet (0x0040) + TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval // endpoint 3, send CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 3, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type - TOUSBORDER(0x0040), // Max Packet (0x0040) + TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval }; @@ -281,15 +264,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 +363,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; @@ -394,36 +371,38 @@ int current_int0_alt_setting = 0; // packet read and write void *USB_ReadPacket(void *dest, uint16_t len) { - uint32_t i=0; - uint32_t count32b = (len + 3) / 4; + uint32_t *dest_copy = (uint32_t *)dest; + uint32_t count32b = (len + 3U) / 4U; - for ( i = 0; i < count32b; i++) { - // packed? - *(__attribute__((__packed__)) uint32_t *)dest = USBx_DFIFO(0); - dest += 4; + for (uint32_t i = 0; i < count32b; i++) { + *dest_copy = USBx_DFIFO(0); + dest_copy++; } - return ((void *)dest); + return ((void *)dest_copy); } -void USB_WritePacket(const uint8_t *src, uint16_t len, uint32_t ep) { +void USB_WritePacket(const void *src, uint16_t len, uint32_t ep) { #ifdef DEBUG_USB puts("writing "); hexdump(src, len); #endif - uint8_t numpacket = (len+(MAX_RESP_LEN-1))/MAX_RESP_LEN; - uint32_t count32b = 0, i = 0; - count32b = (len + 3) / 4; + uint32_t numpacket = (len + (MAX_RESP_LEN - 1U)) / MAX_RESP_LEN; + uint32_t count32b = 0; + count32b = (len + 3U) / 4U; - // bullshit + // TODO: revisit this USBx_INEP(ep)->DIEPTSIZ = ((numpacket << 19) & USB_OTG_DIEPTSIZ_PKTCNT) | (len & USB_OTG_DIEPTSIZ_XFRSIZ); USBx_INEP(ep)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA); // load the FIFO - for (i = 0; i < count32b; i++) { - USBx_DFIFO(ep) = *((__attribute__((__packed__)) uint32_t *)src); - src += 4; + if (src != NULL) { + const uint32_t *src_copy = (const uint32_t *)src; + for (uint32_t i = 0; i < count32b; i++) { + USBx_DFIFO(ep) = *src_copy; + src_copy++; + } } } @@ -439,7 +418,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 { @@ -471,10 +450,10 @@ void usb_reset(void) { USBx->GRXFSIZ = 0x40; // 0x100 to offset past GRXFSIZ - USBx->DIEPTXF0_HNPTXFSIZ = (0x40 << 16) | 0x40; + USBx->DIEPTXF0_HNPTXFSIZ = (0x40U << 16) | 0x40U; // EP1, massive - USBx->DIEPTXF[0] = (0x40 << 16) | 0x80; + USBx->DIEPTXF[0] = (0x40U << 16) | 0x80U; // flush TX fifo USBx->GRSTCTL = USB_OTG_GRSTCTL_TXFFLSH | USB_OTG_GRSTCTL_TXFNUM_4; @@ -487,7 +466,7 @@ void usb_reset(void) { USBx_DEVICE->DCTL |= USB_OTG_DCTL_CGINAK; // ready to receive setup packets - USBx_OUTEP(0)->DOEPTSIZ = USB_OTG_DOEPTSIZ_STUPCNT | (USB_OTG_DOEPTSIZ_PKTCNT & (1 << 19)) | (3 * 8); + USBx_OUTEP(0)->DOEPTSIZ = USB_OTG_DOEPTSIZ_STUPCNT | (USB_OTG_DOEPTSIZ_PKTCNT & (1U << 19)) | (3U << 3); } char to_hex_char(int a) { @@ -506,17 +485,17 @@ void usb_setup(void) { switch (setup.b.bRequest) { case USB_REQ_SET_CONFIGURATION: // enable other endpoints, has to be here? - USBx_INEP(1)->DIEPCTL = (0x40 & USB_OTG_DIEPCTL_MPSIZ) | (2 << 18) | (1 << 22) | + USBx_INEP(1)->DIEPCTL = (0x40U & USB_OTG_DIEPCTL_MPSIZ) | (2U << 18) | (1U << 22) | USB_OTG_DIEPCTL_SD0PID_SEVNFRM | USB_OTG_DIEPCTL_USBAEP; USBx_INEP(1)->DIEPINT = 0xFF; - USBx_OUTEP(2)->DOEPTSIZ = (1 << 19) | 0x40; - USBx_OUTEP(2)->DOEPCTL = (0x40 & USB_OTG_DOEPCTL_MPSIZ) | (2 << 18) | + USBx_OUTEP(2)->DOEPTSIZ = (1U << 19) | 0x40U; + USBx_OUTEP(2)->DOEPCTL = (0x40U & USB_OTG_DOEPCTL_MPSIZ) | (2U << 18) | USB_OTG_DOEPCTL_SD0PID_SEVNFRM | USB_OTG_DOEPCTL_USBAEP; USBx_OUTEP(2)->DOEPINT = 0xFF; - USBx_OUTEP(3)->DOEPTSIZ = (1 << 19) | 0x40; - USBx_OUTEP(3)->DOEPCTL = (0x40 & USB_OTG_DOEPCTL_MPSIZ) | (2 << 18) | + USBx_OUTEP(3)->DOEPTSIZ = (32U << 19) | 0x800U; + USBx_OUTEP(3)->DOEPCTL = (0x40U & USB_OTG_DOEPCTL_MPSIZ) | (2U << 18) | USB_OTG_DOEPCTL_SD0PID_SEVNFRM | USB_OTG_DOEPCTL_USBAEP; USBx_OUTEP(3)->DOEPINT = 0xFF; @@ -529,7 +508,7 @@ void usb_setup(void) { break; case USB_REQ_SET_ADDRESS: // set now? - USBx_DEVICE->DCFG |= ((setup.b.wValue.w & 0x7f) << 4); + USBx_DEVICE->DCFG |= ((setup.b.wValue.w & 0x7fU) << 4); #ifdef DEBUG_USB puts(" set address\n"); @@ -548,6 +527,8 @@ void usb_setup(void) { case USB_DESC_TYPE_DEVICE: //puts(" writing device descriptor\n"); + // set bcdDevice to hardware type + device_desc[13] = hw_type; // setup transfer USB_WritePacket(device_desc, MIN(sizeof(device_desc), setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; @@ -575,16 +556,16 @@ void usb_setup(void) { break; case STRING_OFFSET_ISERIAL: #ifdef UID_BASE - resp[0] = 0x02 + 12*4; + resp[0] = 0x02 + (12 * 4); resp[1] = 0x03; // 96 bits = 12 bytes for (int i = 0; i < 12; i++){ uint8_t cc = ((uint8_t *)UID_BASE)[i]; - resp[2 + i*4 + 0] = to_hex_char((cc>>4)&0xF); - resp[2 + i*4 + 1] = '\0'; - resp[2 + i*4 + 2] = to_hex_char((cc>>0)&0xF); - resp[2 + i*4 + 3] = '\0'; + resp[2 + (i * 4) + 0] = to_hex_char((cc >> 4) & 0xFU); + resp[2 + (i * 4) + 1] = '\0'; + resp[2 + (i * 4) + 2] = to_hex_char((cc >> 0) & 0xFU); + resp[2 + (i * 4) + 3] = '\0'; } USB_WritePacket(resp, MIN(resp[0], setup.b.wLength.w), 0); @@ -662,82 +643,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 |= (uint32_t)((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 - // THIS IS FUCKING BULLSHIT - USBx_DEVICE->DCTL = 0; - - // enable the IRQ - NVIC_EnableIRQ(OTG_FS_IRQn); -} // ***************************** USB port ***************************** @@ -768,6 +682,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(); @@ -793,21 +711,22 @@ void usb_irqhandler(void) { if ((gintsts & USB_OTG_GINTSTS_RXFLVL) != 0) { // 1. Read the Receive status pop register volatile unsigned int rxst = USBx->GRXSTSP; + int status = (rxst & USB_OTG_GRXSTSP_PKTSTS) >> 17; #ifdef DEBUG_USB puts(" RX FIFO:"); puth(rxst); puts(" status: "); - puth((rxst & USB_OTG_GRXSTSP_PKTSTS) >> 17); + puth(status); puts(" len: "); puth((rxst & USB_OTG_GRXSTSP_BCNT) >> 4); puts("\n"); #endif - if (((rxst & USB_OTG_GRXSTSP_PKTSTS) >> 17) == STS_DATA_UPDT) { + if (status == STS_DATA_UPDT) { int endpoint = (rxst & USB_OTG_GRXSTSP_EPNUM); int len = (rxst & USB_OTG_GRXSTSP_BCNT) >> 4; - USB_ReadPacket(&usbdata, len); + (void)USB_ReadPacket(&usbdata, len); #ifdef DEBUG_USB puts(" data "); puth(len); @@ -820,15 +739,18 @@ void usb_irqhandler(void) { } if (endpoint == 3) { + outep3_processing = true; usb_cb_ep3_out(usbdata, len, 1); } - } else if (((rxst & USB_OTG_GRXSTSP_PKTSTS) >> 17) == STS_SETUP_UPDT) { - USB_ReadPacket(&setup, 8); + } else if (status == STS_SETUP_UPDT) { + (void)USB_ReadPacket(&setup, 8); #ifdef DEBUG_USB puts(" setup "); hexdump(&setup, 8); puts("\n"); #endif + } else { + // status is neither STS_DATA_UPDT or STS_SETUP_UPDT, skip } } @@ -882,7 +804,7 @@ void usb_irqhandler(void) { #ifdef DEBUG_USB puts(" OUT2 PACKET XFRC\n"); #endif - USBx_OUTEP(2)->DOEPTSIZ = (1 << 19) | 0x40; + USBx_OUTEP(2)->DOEPTSIZ = (1U << 19) | 0x40U; USBx_OUTEP(2)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; } @@ -890,24 +812,30 @@ void usb_irqhandler(void) { #ifdef DEBUG_USB puts(" OUT3 PACKET XFRC\n"); #endif - USBx_OUTEP(3)->DOEPTSIZ = (1 << 19) | 0x40; - 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 = (1 << 19) | 0x40; - 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); - puts("\n"); + #ifdef DEBUG_USB + puts("OUTEP3 error "); + puth(USBx_OUTEP(3)->DOEPINT); + puts("\n"); + #endif + } else { + // USBx_OUTEP(3)->DOEPINT is 0, ok to skip } if ((USBx_OUTEP(0)->DOEPINT & USB_OTG_DIEPINT_XFRC) != 0) { // ready for next packet - USBx_OUTEP(0)->DOEPTSIZ = USB_OTG_DOEPTSIZ_STUPCNT | (USB_OTG_DOEPTSIZ_PKTCNT & (1 << 19)) | (1 * 8); + USBx_OUTEP(0)->DOEPTSIZ = USB_OTG_DOEPTSIZ_STUPCNT | (USB_OTG_DOEPTSIZ_PKTCNT & (1U << 19)) | (1U << 3); } // respond to setup packets @@ -978,12 +906,12 @@ void usb_irqhandler(void) { puts(" IN PACKET QUEUE\n"); #endif - if ((ep0_txlen != 0) && ((USBx_INEP(0)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) >= 0x40)) { + 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 == 0) { + if (ep0_txlen == 0U) { ep0_txdata = NULL; USBx_DEVICE->DIEPEMPMSK &= ~1; USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; @@ -1004,11 +932,23 @@ 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) { - NVIC_DisableIRQ(OTG_FS_IRQn); - //__disable_irq(); - usb_irqhandler(); - //__enable_irq(); - NVIC_EnableIRQ(OTG_FS_IRQn); +void usb_outep3_resume_if_paused(void) { + ENTER_CRITICAL(); + if (!outep3_processing && (USBx_OUTEP(3)->DOEPCTL & USB_OTG_DOEPCTL_NAKSTS) != 0) { + USBx_OUTEP(3)->DOEPTSIZ = (32U << 19) | 0x800U; + USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; + } + EXIT_CRITICAL(); } +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; +} diff --git a/panda/board/early_init.h b/panda/board/early_init.h new file mode 100644 index 00000000000000..ae9a903628b1d7 --- /dev/null +++ b/panda/board/early_init.h @@ -0,0 +1,61 @@ +// Early bringup +#define ENTER_BOOTLOADER_MAGIC 0xdeadbeefU +#define ENTER_SOFTLOADER_MAGIC 0xdeadc0deU +#define BOOT_NORMAL 0xdeadb111U + +extern void *g_pfnVectors; +extern uint32_t enter_bootloader_mode; + +void jump_to_bootloader(void) { + // do enter bootloader + enter_bootloader_mode = 0; + void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *)BOOTLOADER_ADDRESS)); + + // jump to bootloader + enable_interrupts(); + bootloader(); + + // reset on exit + enter_bootloader_mode = BOOT_NORMAL; + NVIC_SystemReset(); +} + +void early_initialization(void) { + // Reset global critical depth + disable_interrupts(); + global_critical_depth = 0; + + // Init register and interrupt tables + init_registers(); + + // 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) && + (enter_bootloader_mode != ENTER_SOFTLOADER_MAGIC)) { + enter_bootloader_mode = BOOT_NORMAL; + NVIC_SystemReset(); + } + + // if wrong chip, reboot + volatile unsigned int id = DBGMCU->IDCODE; + if ((id & 0xFFFU) != MCU_IDCODE) { + enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; + } + + // setup interrupt table + SCB->VTOR = (uint32_t)&g_pfnVectors; + + // early GPIOs float everything + early_gpio_float(); + + detect_external_debug_serial(); + detect_board_type(); + + if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) { + #ifdef PANDA + current_board->set_gps_mode(GPS_DISABLED); + #endif + current_board->set_led(LED_GREEN, 1); + jump_to_bootloader(); + } +} diff --git a/panda/board/faults.h b/panda/board/faults.h new file mode 100644 index 00000000000000..2b152fc1e6c42d --- /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_TICK (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"); + } +} diff --git a/panda/board/flash.sh b/panda/board/flash.sh new file mode 100755 index 00000000000000..f6e5a4b712b4a1 --- /dev/null +++ b/panda/board/flash.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +set -e + +scons -u +PYTHONPATH=.. python3 -c "from python import Panda; Panda().flash('obj/panda.bin.signed')" diff --git a/panda/board/flash_h7.sh b/panda/board/flash_h7.sh new file mode 100755 index 00000000000000..a7372c3f3f18fc --- /dev/null +++ b/panda/board/flash_h7.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +set -e + +scons -u +PYTHONPATH=.. python3 -c "from python import Panda; Panda().flash('obj/panda_h7.bin.signed')" diff --git a/panda/board/flasher.h b/panda/board/flasher.h new file mode 100644 index 00000000000000..534b65e7883c01 --- /dev/null +++ b/panda/board/flasher.h @@ -0,0 +1,316 @@ +// flasher state variables +uint32_t *prog_ptr = NULL; +bool unlocked = false; + +#ifdef uart_ring +void debug_ring_callback(uart_ring *ring) {} +#endif + +int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { + int resp_len = 0; + + // flasher machine + memset(resp, 0, 4); + memcpy(resp+4, "\xde\xad\xd0\x0d", 4); + resp[0] = 0xff; + resp[2] = setup->b.bRequest; + resp[3] = ~setup->b.bRequest; + *((uint32_t **)&resp[8]) = prog_ptr; + resp_len = 0xc; + + int sec; + switch (setup->b.bRequest) { + // **** 0xb0: flasher echo + case 0xb0: + resp[1] = 0xff; + break; + // **** 0xb1: unlock flash + case 0xb1: + if (flash_is_locked()) { + flash_unlock(); + resp[1] = 0xff; + } + current_board->set_led(LED_GREEN, 1); + unlocked = true; + prog_ptr = (uint32_t *)APP_START_ADDRESS; + break; + // **** 0xb2: erase sector + case 0xb2: + sec = setup->b.wValue.w; + if (flash_erase_sector(sec, unlocked)) { + resp[1] = 0xff; + } + break; + // **** 0xd0: fetch serial number + case 0xd0: + #ifndef STM32F2 + // addresses are OTP + if (setup->b.wValue.w == 1) { + memcpy(resp, (void *)DEVICE_SERIAL_NUMBER_ADDRESS, 0x10); + resp_len = 0x10; + } else { + get_provision_chunk(resp); + resp_len = PROVISION_CHUNK_LEN; + } + #endif + break; + // **** 0xd1: enter bootloader mode + case 0xd1: + // this allows reflashing of the bootstub + // 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(); + } + break; + case 1: + puts("-> entering softloader\n"); + enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; + NVIC_SystemReset(); + break; + } + break; + // **** 0xd6: get version + case 0xd6: + COMPILE_TIME_ASSERT(sizeof(gitversion) <= MAX_RESP_LEN); + memcpy(resp, gitversion, sizeof(gitversion)); + resp_len = sizeof(gitversion); + break; + // **** 0xd8: reset ST + case 0xd8: + flush_write_buffer(); + NVIC_SystemReset(); + break; + } + return resp_len; +} + +int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { + UNUSED(usbdata); + UNUSED(len); + UNUSED(hardwired); + return 0; +} +void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { + UNUSED(usbdata); + UNUSED(len); + UNUSED(hardwired); +} +void usb_cb_ep3_out_complete(void) {} + +int is_enumerated = 0; +void usb_cb_enumeration_complete(void) { + puts("USB enumeration complete\n"); + is_enumerated = 1; +} + +void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { + UNUSED(hardwired); + current_board->set_led(LED_RED, 0); + for (int i = 0; i < len/4; i++) { + flash_write_word(prog_ptr, *(uint32_t*)(usbdata+(i*4))); + + //*(uint64_t*)(&spi_tx_buf[0x30+(i*4)]) = *prog_ptr; + prog_ptr++; + } + current_board->set_led(LED_RED, 1); +} + + +int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) { + UNUSED(len); + int resp_len = 0; + switch (data[0]) { + case 0: + // control transfer + resp_len = usb_cb_control_msg((USB_Setup_TypeDef *)(data+4), data_out, 0); + break; + case 2: + // ep 2, flash! + usb_cb_ep2_out(data+4, data[2], 0); + break; + } + return resp_len; +} + +#ifdef PEDAL + +#include "stm32fx/llbxcan.h" +#define CAN CAN1 + +#define CAN_BL_INPUT 0x1 +#define CAN_BL_OUTPUT 0x2 + +void CAN1_TX_IRQ_Handler(void) { + // clear interrupt + CAN->TSR |= CAN_TSR_RQCP0; +} + +#define ISOTP_BUF_SIZE 0x110 + +uint8_t isotp_buf[ISOTP_BUF_SIZE]; +uint8_t *isotp_buf_ptr = NULL; +int isotp_buf_remain = 0; + +uint8_t isotp_buf_out[ISOTP_BUF_SIZE]; +uint8_t *isotp_buf_out_ptr = NULL; +int isotp_buf_out_remain = 0; +int isotp_buf_out_idx = 0; + +void bl_can_send(uint8_t *odat) { + // wait for send + while (!(CAN->TSR & CAN_TSR_TME0)); + + // send continue + CAN->sTxMailBox[0].TDLR = ((uint32_t*)odat)[0]; + CAN->sTxMailBox[0].TDHR = ((uint32_t*)odat)[1]; + CAN->sTxMailBox[0].TDTR = 8; + CAN->sTxMailBox[0].TIR = (CAN_BL_OUTPUT << 21) | 1; +} + +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[i] = GET_MAILBOX_BYTE(&CAN->sFIFOMailBox[0], i); + } + uint8_t odat[8]; + uint8_t type = dat[0] & 0xF0; + if (type == 0x30) { + // continue + while (isotp_buf_out_remain > 0) { + // wait for send + while (!(CAN->TSR & CAN_TSR_TME0)); + + odat[0] = 0x20 | isotp_buf_out_idx; + memcpy(odat+1, isotp_buf_out_ptr, 7); + isotp_buf_out_remain -= 7; + isotp_buf_out_ptr += 7; + isotp_buf_out_idx++; + + bl_can_send(odat); + } + } else if (type == 0x20) { + if (isotp_buf_remain > 0) { + memcpy(isotp_buf_ptr, dat+1, 7); + isotp_buf_ptr += 7; + isotp_buf_remain -= 7; + } + if (isotp_buf_remain <= 0) { + int len = isotp_buf_ptr - isotp_buf + isotp_buf_remain; + + // call the function + memset(isotp_buf_out, 0, ISOTP_BUF_SIZE); + isotp_buf_out_remain = spi_cb_rx(isotp_buf, len, isotp_buf_out); + isotp_buf_out_ptr = isotp_buf_out; + isotp_buf_out_idx = 0; + + // send initial + if (isotp_buf_out_remain <= 7) { + odat[0] = isotp_buf_out_remain; + memcpy(odat+1, isotp_buf_out_ptr, isotp_buf_out_remain); + } else { + odat[0] = 0x10 | (isotp_buf_out_remain>>8); + odat[1] = isotp_buf_out_remain & 0xFF; + memcpy(odat+2, isotp_buf_out_ptr, 6); + isotp_buf_out_remain -= 6; + isotp_buf_out_ptr += 6; + isotp_buf_out_idx++; + } + + bl_can_send(odat); + } + } else if (type == 0x10) { + int len = ((dat[0]&0xF)<<8) | dat[1]; + + // setup buffer + isotp_buf_ptr = isotp_buf; + memcpy(isotp_buf_ptr, dat+2, 6); + + if (len < (ISOTP_BUF_SIZE-0x10)) { + isotp_buf_ptr += 6; + isotp_buf_remain = len-6; + } + + memset(odat, 0, 8); + odat[0] = 0x30; + bl_can_send(odat); + } + } + // next + CAN->RF0R |= CAN_RF0R_RFOM0; + } +} + +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; + + flasher_peripherals_init(); + +// pedal has the canloader +#ifdef PEDAL + RCC->APB1ENR |= RCC_APB1ENR_CAN1EN; + + // B8,B9: CAN 1 + set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1); + set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1); + current_board->enable_can_transceiver(1, true); + + // init can + llcan_set_speed(CAN1, 5000, false, false); + llcan_init(CAN1); +#endif + + gpio_usart2_init(); + gpio_usb_init(); + + // enable USB + usb_init(); + + // green LED on for flashing + current_board->set_led(LED_GREEN, 1); + + enable_interrupts(); + + uint64_t cnt = 0; + + for (cnt=0;;cnt++) { + if (cnt == 35 && !is_enumerated && usb_power_mode == USB_POWER_CLIENT) { + // if you are connected through a hub to the phone + // you need power to be able to see the device + puts("USBP: didn't enumerate, switching to CDP mode\n"); + current_board->set_usb_power_mode(USB_POWER_CDP); + current_board->set_led(LED_BLUE, 1); + } + // blink the green LED fast + current_board->set_led(LED_GREEN, 0); + delay(500000); + current_board->set_led(LED_GREEN, 1); + delay(500000); + } +} diff --git a/panda/board/get_sdk.sh b/panda/board/get_sdk.sh index 7b8d1f9154c0ac..c0d05651a9023f 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 apt-get install dfu-util gcc-arm-none-eabi python3-pip +sudo pip install libusb1 pycryptodome requests diff --git a/panda/board/get_sdk_mac.sh b/panda/board/get_sdk_mac.sh index a6f641dce12116..9e4b71590f53b2 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 +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 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 deleted file mode 100644 index 26a82d6275e05f..00000000000000 --- a/panda/board/gpio.h +++ /dev/null @@ -1,447 +0,0 @@ -// this is last place with ifdef PANDA - -#ifdef STM32F4 - #include "stm32f4xx_hal_gpio_ex.h" -#else - #include "stm32f2xx_hal_gpio_ex.h" -#endif - -// ********************* dynamic configuration detection ********************* - -#define PANDA_REV_AB 0 -#define PANDA_REV_C 1 - -#define PULL_EFFECTIVE_DELAY 10 - -void puts(const char *a); - -bool has_external_debug_serial = 0; -bool is_giant_panda = 0; -bool is_entering_bootmode = 0; -int revision = PANDA_REV_AB; -bool is_grey_panda = 0; - -bool detect_with_pull(GPIO_TypeDef *GPIO, int pin, int mode) { - set_gpio_mode(GPIO, pin, MODE_INPUT); - set_gpio_pullup(GPIO, pin, mode); - for (volatile int i=0; iAHB1ENR |= RCC_AHB1ENR_GPIOAEN; - RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; - RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; - RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; - - RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; - RCC->APB1ENR |= RCC_APB1ENR_USART2EN; - RCC->APB1ENR |= RCC_APB1ENR_USART3EN; - #ifdef PANDA - RCC->APB1ENR |= RCC_APB1ENR_UART5EN; - #endif - RCC->APB1ENR |= RCC_APB1ENR_CAN1EN; - RCC->APB1ENR |= RCC_APB1ENR_CAN2EN; - #ifdef CAN3 - RCC->APB1ENR |= RCC_APB1ENR_CAN3EN; - #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->APB2ENR |= RCC_APB2ENR_USART1EN; - RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; - //RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; - RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; - RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; - RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; -} - -// ********************* setters ********************* - -void set_can_enable(CAN_TypeDef *CAN, bool enabled) { - // enable CAN busses - if (CAN == CAN1) { - #ifdef PANDA - // CAN1_EN - set_gpio_output(GPIOC, 1, !enabled); - #else - #ifdef PEDAL - // CAN1_EN (not flipped) - set_gpio_output(GPIOB, 3, !enabled); - #else - // CAN1_EN - set_gpio_output(GPIOB, 3, enabled); - #endif - #endif - } else if (CAN == CAN2) { - #ifdef PANDA - // CAN2_EN - set_gpio_output(GPIOC, 13, !enabled); - #else - // CAN2_EN - set_gpio_output(GPIOB, 4, enabled); - #endif - #ifdef CAN3 - } else if (CAN == CAN3) { - // CAN3_EN - set_gpio_output(GPIOA, 0, !enabled); - #endif - } -} - -#ifdef PANDA - #define LED_RED 9 - #define LED_GREEN 7 - #define LED_BLUE 6 -#else - #define LED_RED 10 - #define LED_GREEN 11 - #define LED_BLUE -1 -#endif - -void set_led(int led_num, int on) { - if (led_num != -1) { - #ifdef PANDA - set_gpio_output(GPIOC, led_num, !on); - #else - set_gpio_output(GPIOB, led_num, !on); - #endif - } -} - -void set_can_mode(int can, bool use_gmlan) { - // connects to CAN2 xcvr or GMLAN xcvr - if (use_gmlan) { - if (can == 1) { - // B5,B6: disable normal mode - set_gpio_mode(GPIOB, 5, MODE_INPUT); - set_gpio_mode(GPIOB, 6, MODE_INPUT); - - // B12,B13: gmlan mode - set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); - set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); -#ifdef CAN3 - } else if (can == 2) { - // A8,A15: disable normal mode - set_gpio_mode(GPIOA, 8, MODE_INPUT); - set_gpio_mode(GPIOA, 15, MODE_INPUT); - - // B3,B4: enable gmlan mode - set_gpio_alternate(GPIOB, 3, GPIO_AF11_CAN3); - set_gpio_alternate(GPIOB, 4, GPIO_AF11_CAN3); -#endif - } - } else { - if (can == 1) { - // B12,B13: disable gmlan mode - set_gpio_mode(GPIOB, 12, MODE_INPUT); - set_gpio_mode(GPIOB, 13, MODE_INPUT); - - // B5,B6: normal mode - set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); - set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); -#ifdef CAN3 - } else if (can == 2) { - // B3,B4: disable gmlan mode - set_gpio_mode(GPIOB, 3, MODE_INPUT); - set_gpio_mode(GPIOB, 4, MODE_INPUT); - // A8,A15: normal mode - set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); - set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); -#endif - } - } -} - -#define USB_POWER_NONE 0 -#define USB_POWER_CLIENT 1 -#define USB_POWER_CDP 2 -#define USB_POWER_DCP 3 - -int usb_power_mode = USB_POWER_NONE; - -void set_usb_power_mode(int mode) { - bool valid_mode = true; - switch (mode) { - case USB_POWER_CLIENT: - // B2,A13: set client mode - set_gpio_output(GPIOB, 2, 0); - set_gpio_output(GPIOA, 13, 1); - break; - case USB_POWER_CDP: - // B2,A13: set CDP mode - set_gpio_output(GPIOB, 2, 1); - set_gpio_output(GPIOA, 13, 1); - break; - case USB_POWER_DCP: - // B2,A13: set DCP mode on the charger (breaks USB!) - set_gpio_output(GPIOB, 2, 0); - set_gpio_output(GPIOA, 13, 0); - break; - default: - valid_mode = false; - puts("Invalid usb power mode\n"); - break; - } - - if (valid_mode) { - usb_power_mode = mode; - } -} - -#define ESP_DISABLED 0 -#define ESP_ENABLED 1 -#define ESP_BOOTMODE 2 - -void set_esp_mode(int mode) { - switch (mode) { - case ESP_DISABLED: - // ESP OFF - set_gpio_output(GPIOC, 14, 0); - set_gpio_output(GPIOC, 5, 0); - break; - case ESP_ENABLED: - // ESP ON - set_gpio_output(GPIOC, 14, 1); - set_gpio_output(GPIOC, 5, 1); - break; - case ESP_BOOTMODE: - set_gpio_output(GPIOC, 14, 1); - set_gpio_output(GPIOC, 5, 0); - break; - default: - puts("Invalid esp mode\n"); - break; - } -} - -// ********************* big init function ********************* - -// board specific -void gpio_init(void) { - // pull low to hold ESP in reset?? - // enable OTG out tied to ground - GPIOA->ODR = 0; - GPIOB->ODR = 0; - GPIOA->PUPDR = 0; - //GPIOC->ODR = 0; - GPIOB->AFR[0] = 0; - GPIOB->AFR[1] = 0; - - // C2,C3: analog mode, voltage and current sense - set_gpio_mode(GPIOC, 2, MODE_ANALOG); - set_gpio_mode(GPIOC, 3, MODE_ANALOG); - -#ifdef PEDAL - // comma pedal has inputs on C0 and C1 - set_gpio_mode(GPIOC, 0, MODE_ANALOG); - set_gpio_mode(GPIOC, 1, MODE_ANALOG); - // DAC outputs on A4 and A5 - // apparently they don't need GPIO setup -#endif - - // C8: FAN aka TIM3_CH4 - set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); - - // turn off LEDs and set mode - set_led(LED_RED, 0); - set_led(LED_GREEN, 0); - set_led(LED_BLUE, 0); - - // A11,A12: USB - set_gpio_alternate(GPIOA, 11, GPIO_AF10_OTG_FS); - set_gpio_alternate(GPIOA, 12, GPIO_AF10_OTG_FS); - GPIOA->OSPEEDR = GPIO_OSPEEDER_OSPEEDR11 | GPIO_OSPEEDER_OSPEEDR12; - -#ifdef PANDA - // enable started_alt on the panda - set_gpio_pullup(GPIOA, 1, PULL_UP); - - // A2,A3: USART 2 for debugging - set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); - set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); - - // A9,A10: USART 1 for talking to the ESP - set_gpio_alternate(GPIOA, 9, GPIO_AF7_USART1); - set_gpio_alternate(GPIOA, 10, GPIO_AF7_USART1); - - // B12: GMLAN, ignition sense, pull up - set_gpio_pullup(GPIOB, 12, PULL_UP); - - // A4,A5,A6,A7: setup SPI - set_gpio_alternate(GPIOA, 4, GPIO_AF5_SPI1); - set_gpio_alternate(GPIOA, 5, GPIO_AF5_SPI1); - set_gpio_alternate(GPIOA, 6, GPIO_AF5_SPI1); - set_gpio_alternate(GPIOA, 7, GPIO_AF5_SPI1); -#endif - - // B8,B9: CAN 1 -#ifdef STM32F4 - set_gpio_alternate(GPIOB, 8, GPIO_AF8_CAN1); - set_gpio_alternate(GPIOB, 9, GPIO_AF8_CAN1); -#else - set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1); - set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1); -#endif - set_can_enable(CAN1, 1); - - // B5,B6: CAN 2 - set_can_mode(1, 0); - set_can_enable(CAN2, 1); - - // A8,A15: CAN 3 - #ifdef CAN3 - set_can_mode(2, 0); - set_can_enable(CAN3, 1); - #endif - - /* GMLAN mode pins: - M0(B15) M1(B14) mode - ======================= - 0 0 sleep - 1 0 100kbit - 0 1 high voltage wakeup - 1 1 33kbit (normal) - */ - - // put gmlan transceiver in normal mode - set_gpio_output(GPIOB, 14, 1); - set_gpio_output(GPIOB, 15, 1); - - #ifdef PANDA - // K-line enable moved from B4->B7 to make room for GMLAN on CAN3 - set_gpio_output(GPIOB, 7, 1); // REV C - - // C12,D2: K-Line setup on UART 5 - set_gpio_alternate(GPIOC, 12, GPIO_AF8_UART5); - set_gpio_alternate(GPIOD, 2, GPIO_AF8_UART5); - set_gpio_pullup(GPIOD, 2, PULL_UP); - - // L-line enable - set_gpio_output(GPIOA, 14, 1); - - // C10,C11: L-Line setup on USART 3 - set_gpio_alternate(GPIOC, 10, GPIO_AF7_USART3); - set_gpio_alternate(GPIOC, 11, GPIO_AF7_USART3); - set_gpio_pullup(GPIOC, 11, PULL_UP); - #endif - - set_usb_power_mode(USB_POWER_CLIENT); -} - -// ********************* early bringup ********************* - -#define ENTER_BOOTLOADER_MAGIC 0xdeadbeef -#define ENTER_SOFTLOADER_MAGIC 0xdeadc0de -#define BOOT_NORMAL 0xdeadb111 - -extern void *g_pfnVectors; -extern uint32_t enter_bootloader_mode; - -void jump_to_bootloader(void) { - // do enter bootloader - enter_bootloader_mode = 0; - void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *)0x1fff0004)); - - // jump to bootloader - bootloader(); - - // reset on exit - enter_bootloader_mode = BOOT_NORMAL; - NVIC_SystemReset(); -} - -void early(void) { - // 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) && - (enter_bootloader_mode != ENTER_SOFTLOADER_MAGIC)) { - enter_bootloader_mode = BOOT_NORMAL; - NVIC_SystemReset(); - } - - // if wrong chip, reboot - volatile unsigned int id = DBGMCU->IDCODE; - #ifdef STM32F4 - if ((id&0xFFF) != 0x463) enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; - #else - if ((id&0xFFF) != 0x411) enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; - #endif - - // setup interrupt table - SCB->VTOR = (uint32_t)&g_pfnVectors; - - // early GPIOs float everything - RCC->AHB1ENR = RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN | RCC_AHB1ENR_GPIOCEN; - - GPIOA->MODER = 0; GPIOB->MODER = 0; GPIOC->MODER = 0; - GPIOA->ODR = 0; GPIOB->ODR = 0; GPIOC->ODR = 0; - GPIOA->PUPDR = 0; GPIOB->PUPDR = 0; GPIOC->PUPDR = 0; - - detect(); - - #ifdef PANDA - // enable the ESP, disable ESP boot mode - // unless we are on a giant panda, then there's no ESP - // dont disable on grey panda - if (is_giant_panda) { - set_esp_mode(ESP_DISABLED); - } else { - set_esp_mode(ESP_ENABLED); - } - #endif - - - if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) { - #ifdef PANDA - set_esp_mode(ESP_DISABLED); - #endif - set_led(LED_GREEN, 1); - jump_to_bootloader(); - } - - if (is_entering_bootmode) { - enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; - } -} diff --git a/panda/board/inc/cmsis_gcc.h b/panda/board/inc/cmsis_gcc.h deleted file mode 100644 index bb89fbba9e4000..00000000000000 --- a/panda/board/inc/cmsis_gcc.h +++ /dev/null @@ -1,1373 +0,0 @@ -/**************************************************************************//** - * @file cmsis_gcc.h - * @brief CMSIS Cortex-M Core Function/Instruction 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. - ---------------------------------------------------------------------------*/ - - -#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" -#endif - - -/* ########################### Core Function Access ########################### */ -/** \ingroup CMSIS_Core_FunctionInterface - \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions - @{ - */ - -/** - \brief Enable IRQ Interrupts - \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) -{ - __ASM volatile ("cpsie i" : : : "memory"); -} - - -/** - \brief Disable IRQ Interrupts - \details Disables IRQ interrupts by setting the I-bit in the CPSR. - Can only be executed in Privileged modes. - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) -{ - __ASM volatile ("cpsid i" : : : "memory"); -} - - -/** - \brief Get Control Register - \details Returns the content of the Control Register. - \return Control Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, control" : "=r" (result) ); - return(result); -} - - -/** - \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) -{ - __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); -} - - -/** - \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) -{ - uint32_t result; - - __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); - return(result); -} - - -/** - \brief Get APSR Register - \details Returns the content of the APSR Register. - \return APSR Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, apsr" : "=r" (result) ); - return(result); -} - - -/** - \brief Get xPSR Register - \details Returns the content of the xPSR Register. - - \return xPSR Register value - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) -{ - uint32_t result; - - __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); - return(result); -} - - -/** - \brief Get Process Stack Pointer - \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) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Process Stack Pointer - \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) -{ - __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); -} - - -/** - \brief Get Main Stack Pointer - \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) -{ - register uint32_t result; - - __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); - return(result); -} - - -/** - \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 - */ -__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) -{ - __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); -} - - -/** - \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) -{ - uint32_t result; - - __ASM volatile ("MRS %0, primask" : "=r" (result) ); - return(result); -} - - -/** - \brief Set Priority Mask - \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) -{ - __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); -} - - -#if (__CORTEX_M >= 0x03U) - -/** - \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) -{ - __ASM volatile ("cpsie f" : : : "memory"); -} - - -/** - \brief Disable FIQ - \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) -{ - __ASM volatile ("cpsid f" : : : "memory"); -} - - -/** - \brief Get Base Priority - \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) -{ - uint32_t result; - - __ASM volatile ("MRS %0, basepri" : "=r" (result) ); - return(result); -} - - -/** - \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) -{ - __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); -} - - -/** - \brief Set Base Priority with condition - \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, - 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) -{ - __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); -} - - -/** - \brief Get Fault Mask - \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) -{ - uint32_t result; - - __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); - return(result); -} - - -/** - \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) -{ - __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); -} - -#endif /* (__CORTEX_M >= 0x03U) */ - - -#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) - uint32_t result; - - /* Empty asm statement works as a scheduling barrier */ - __ASM volatile (""); - __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); - __ASM volatile (""); - return(result); -#else - return(0); -#endif -} - - -/** - \brief Set FPSCR - \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 (""); -#endif -} - -#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ - - - -/*@} end of CMSIS_Core_RegAccFunctions */ - - -/* ########################## Core Instruction Access ######################### */ -/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface - Access to dedicated instructions - @{ -*/ - -/* Define macros for porting to both thumb1 and thumb2. - * For thumb1, use low register (r0-r7), specified by constraint "l" - * Otherwise, use general registers, specified by constraint "r" */ -#if defined (__thumb__) && !defined (__thumb2__) -#define __CMSIS_GCC_OUT_REG(r) "=l" (r) -#define __CMSIS_GCC_USE_REG(r) "l" (r) -#else -#define __CMSIS_GCC_OUT_REG(r) "=r" (r) -#define __CMSIS_GCC_USE_REG(r) "r" (r) -#endif - -/** - \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"); -} - - -/** - \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"); -} - - -/** - \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. - */ -__attribute__((always_inline)) __STATIC_INLINE void __WFE(void) -{ - __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"); -} - - -/** - \brief Instruction Synchronization Barrier - \details Instruction Synchronization Barrier flushes the pipeline in the processor, - 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) -{ - __ASM volatile ("isb 0xF":::"memory"); -} - - -/** - \brief Data Synchronization Barrier - \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) -{ - __ASM volatile ("dsb 0xF":::"memory"); -} - - -/** - \brief Data Memory Barrier - \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) -{ - __ASM volatile ("dmb 0xF":::"memory"); -} - - -/** - \brief Reverse byte order (32 bit) - \details Reverses the byte order in integer value. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value) -{ -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) - return __builtin_bswap32(value); -#else - uint32_t result; - - __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -#endif -} - - -/** - \brief Reverse byte order (16 bit) - \details Reverses the byte order in two unsigned short values. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE 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); -} - - -/** - \brief Reverse byte order in signed short value - \details Reverses the byte order in a signed short value with sign extension to integer. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) -{ -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - return (short)__builtin_bswap16(value); -#else - int32_t result; - - __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -#endif -} - - -/** - \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 - \return Rotated value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) -{ - return (op1 >> op2) | (op1 << (32U - op2)); -} - - -/** - \brief Breakpoint - \details Causes the processor to enter Debug state. - Debug tools can use this to investigate system state when the instruction at a particular address is reached. - \param [in] value is ignored by the processor. - If required, a debugger can use it to store additional information about the breakpoint. - */ -#define __BKPT(value) __ASM volatile ("bkpt "#value) - - -/** - \brief Reverse bit order of value - \details Reverses the bit order of the given value. - \param [in] value Value to reverse - \return Reversed value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) -{ - uint32_t result; - -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) - __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); -#else - int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* 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) - { - result <<= 1U; - result |= value & 1U; - s--; - } - result <<= s; /* shift when v's highest bits are zero */ -#endif - return(result); -} - - -/** - \brief Count leading zeros - \details Counts the number of leading zeros of a data value. - \param [in] value Value to count the leading zeros - \return number of leading zeros in value - */ -#define __CLZ __builtin_clz - - -#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) - -/** - \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) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); -#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 ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); -#endif - return ((uint8_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDR Exclusive (16 bit) - \details Executes a exclusive LDR instruction for 16 bit values. - \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) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); -#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 ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); -#endif - return ((uint16_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDR Exclusive (32 bit) - \details Executes a exclusive LDR instruction for 32 bit values. - \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) -{ - uint32_t result; - - __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); - return(result); -} - - -/** - \brief STR Exclusive (8 bit) - \details Executes a exclusive STR 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 - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) -{ - uint32_t result; - - __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); - return(result); -} - - -/** - \brief STR Exclusive (16 bit) - \details Executes a exclusive STR 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 - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) -{ - uint32_t result; - - __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); - return(result); -} - - -/** - \brief STR Exclusive (32 bit) - \details Executes a exclusive STR 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 - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) -{ - uint32_t result; - - __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); - return(result); -} - - -/** - \brief Remove the exclusive lock - \details Removes the exclusive lock which is created by LDREX. - */ -__attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) -{ - __ASM volatile ("clrex" ::: "memory"); -} - - -/** - \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 - */ -#define __SSAT(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - - -/** - \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 - */ -#define __USAT(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - - -/** - \brief Rotate Right with Extend (32 bit) - \details Moves each bit of a bitstring right by one bit. - The carry input is shifted in at the left end of the bitstring. - \param [in] value Value to rotate - \return Rotated value - */ -__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) -{ - uint32_t result; - - __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); - return(result); -} - - -/** - \brief LDRT Unprivileged (8 bit) - \details Executes a Unprivileged LDRT 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 __LDRBT(volatile uint8_t *addr) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*addr) ); -#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" ); -#endif - return ((uint8_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDRT Unprivileged (16 bit) - \details Executes a Unprivileged LDRT instruction for 16 bit values. - \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) -{ - uint32_t result; - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) - __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*addr) ); -#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" ); -#endif - return ((uint16_t) result); /* Add explicit type cast here */ -} - - -/** - \brief LDRT Unprivileged (32 bit) - \details Executes a Unprivileged LDRT instruction for 32 bit values. - \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) -{ - uint32_t result; - - __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) ); - return(result); -} - - -/** - \brief STRT Unprivileged (8 bit) - \details Executes a Unprivileged STRT instruction for 8 bit values. - \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) -{ - __ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); -} - - -/** - \brief STRT Unprivileged (16 bit) - \details Executes a Unprivileged STRT instruction for 16 bit values. - \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) -{ - __ASM volatile ("strht %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); -} - - -/** - \brief STRT Unprivileged (32 bit) - \details Executes a Unprivileged STRT instruction for 32 bit values. - \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) -{ - __ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) ); -} - -#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ - -/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ - - -/* ################### Compiler specific Intrinsics ########################### */ -/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics - Access to dedicated SIMD instructions - @{ -*/ - -#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -#define __SSAT16(ARG1,ARG2) \ -({ \ - int32_t __RES, __ARG1 = (ARG1); \ - __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - -#define __USAT16(ARG1,ARG2) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1); \ - __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ - __RES; \ - }) - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) -{ - uint32_t result; - - __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) -{ - uint32_t result; - - __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) -{ - uint32_t result; - - __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) -{ - union llreg_u{ - uint32_t w32[2]; - uint64_t w64; - } llr; - llr.w64 = acc; - -#ifndef __ARMEB__ /* Little endian */ - __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); -#else /* Big endian */ - __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); -#endif - - return(llr.w64); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2) -{ - uint32_t result; - - __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2) -{ - int32_t result; - - __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2) -{ - int32_t result; - - __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); - return(result); -} - -#define __PKHBT(ARG1,ARG2,ARG3) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ - __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ - __RES; \ - }) - -#define __PKHTB(ARG1,ARG2,ARG3) \ -({ \ - uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ - if (ARG3 == 0) \ - __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ - else \ - __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ - __RES; \ - }) - -__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) -{ - int32_t result; - - __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); - return(result); -} - -#endif /* (__CORTEX_M >= 0x04) */ -/*@} end of group CMSIS_SIMD_intrinsics */ - - -#if defined ( __GNUC__ ) -#pragma GCC diagnostic pop -#endif - -#endif /* __CMSIS_GCC_H */ 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/libc.h b/panda/board/libc.h index 564d29cd893ca4..1e32d4206e481a 100644 --- a/panda/board/libc.h +++ b/panda/board/libc.h @@ -1,61 +1,64 @@ // **** libc **** -void delay(int a) { - volatile int i; +void delay(uint32_t a) { + volatile uint32_t i; for (i = 0; i < a; i++); } void *memset(void *str, int c, unsigned int n) { - unsigned int i; - for (i = 0; i < n; i++) { - *((uint8_t*)str) = c; - ++str; + uint8_t *s = str; + for (unsigned int i = 0; i < n; i++) { + *s = c; + s++; } return str; } -void *memcpy(void *dest, const void *src, unsigned int n) { - unsigned int i; - // TODO: make not slow - for (i = 0; i < n; i++) { - ((uint8_t*)dest)[i] = *(uint8_t*)src; - ++src; +#define UNALIGNED(X, Y) \ + (((uint32_t)(X) & (sizeof(uint32_t) - 1U)) | ((uint32_t)(Y) & (sizeof(uint32_t) - 1U))) + +void *memcpy(void *dest, const void *src, unsigned int len) { + unsigned int n = len; + uint8_t *d8 = dest; + const uint8_t *s8 = src; + + if ((n >= 4U) && !UNALIGNED(s8, d8)) { + uint32_t *d32 = (uint32_t *)d8; // cppcheck-suppress misra-c2012-11.3 ; already checked that it's properly aligned + const uint32_t *s32 = (const uint32_t *)s8; // cppcheck-suppress misra-c2012-11.3 ; already checked that it's properly aligned + + while(n >= 16U) { + *d32 = *s32; d32++; s32++; + *d32 = *s32; d32++; s32++; + *d32 = *s32; d32++; s32++; + *d32 = *s32; d32++; s32++; + n -= 16U; + } + + while(n >= 4U) { + *d32 = *s32; d32++; s32++; + n -= 4U; + } + + d8 = (uint8_t *)d32; + s8 = (const uint8_t *)s32; + } + while (n-- > 0U) { + *d8 = *s8; d8++; s8++; } return dest; } int memcmp(const void * ptr1, const void * ptr2, unsigned int num) { - unsigned int i; int ret = 0; - for (i = 0; i < num; i++) { - if ( ((uint8_t*)ptr1)[i] != ((uint8_t*)ptr2)[i] ) { + const uint8_t *p1 = ptr1; + const uint8_t *p2 = ptr2; + for (unsigned int i = 0; i < num; i++) { + if (*p1 != *p2) { ret = -1; break; } + p1++; + p2++; } 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 e24df3818d89c3..ac7a75a5e5a7c3 100644 --- a/panda/board/main.c +++ b/panda/board/main.c @@ -1,45 +1,75 @@ -//#define EON - +// ********************* Includes ********************* #include "config.h" -#include "obj/gitversion.h" - -// ********************* includes ********************* +#include "drivers/pwm.h" +#include "drivers/usb.h" +#include "drivers/gmlan_alt.h" +#include "drivers/kline_init.h" -#include "libc.h" +#include "early_init.h" #include "provision.h" -#include "drivers/llcan.h" -#include "drivers/llgpio.h" -#include "gpio.h" +#include "power_saving.h" +#include "safety.h" -#include "drivers/uart.h" -#include "drivers/adc.h" -#include "drivers/usb.h" -#include "drivers/gmlan_alt.h" -#include "drivers/timer.h" -#include "drivers/clock.h" +#include "drivers/can_common.h" -#ifndef EON -#include "drivers/spi.h" +#ifdef STM32H7 + #include "drivers/fdcan.h" +#else + #include "drivers/bxcan.h" #endif -#include "power_saving.h" -#include "safety.h" -#include "drivers/can.h" +#include "usb_protocol.h" -// ********************* serial debugging ********************* +#include "obj/gitversion.h" + +extern int _app_start[0xc000]; // Only first 3 sectors of size 0x4000 are used + +// When changing this struct, boardd and python/__init__.py needs to be kept up to date! +#define HEALTH_PACKET_VERSION 1 +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; + int16_t safety_param_pkt; + uint8_t fault_status_pkt; + uint8_t power_save_enabled_pkt; + uint8_t heartbeat_lost_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)) { - putc(ring, rcv); - - // jump to DFU flash - if (rcv == 'z') { - enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; - NVIC_SystemReset(); - } + (void)putc(ring, rcv); // misra-c2012-17.7: cast to void is ok: debug function + + // 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') { @@ -49,114 +79,133 @@ void debug_ring_callback(uart_ring *ring) { // enable CDP mode if (rcv == 'C') { puts("switching USB to CDP mode\n"); - set_usb_power_mode(USB_POWER_CDP); + current_board->set_usb_power_mode(USB_POWER_CDP); } if (rcv == 'c') { puts("switching USB to client mode\n"); - set_usb_power_mode(USB_POWER_CLIENT); + current_board->set_usb_power_mode(USB_POWER_CLIENT); } if (rcv == 'D') { puts("switching USB to DCP mode\n"); - set_usb_power_mode(USB_POWER_DCP); + current_board->set_usb_power_mode(USB_POWER_DCP); } } } -// ***************************** started logic ***************************** - -bool is_gpio_started(void) { - // ignition is on PA1 - return (GPIOA->IDR & (1U << 1)) == 0; -} - -void EXTI1_IRQHandler(void) { - volatile int pr = EXTI->PR & (1U << 1); - if ((pr & (1U << 1)) != 0) { - #ifdef DEBUG - puts("got started interrupt\n"); - #endif - - // jenky debounce - delay(100000); - - // set power savings mode here - int power_save_state = is_gpio_started() ? POWER_SAVE_STATUS_DISABLED : POWER_SAVE_STATUS_ENABLED; - set_power_save_state(power_save_state); - EXTI->PR = (1U << 1); +// ****************************** safety mode ****************************** + +// this is the only way to leave silent mode +void set_safety_mode(uint16_t mode, int16_t param) { + uint16_t mode_copy = mode; + int err = set_safety_hooks(mode_copy, param); + if (err == -1) { + puts("Error: safety set mode failed. Falling back to SILENT\n"); + mode_copy = SAFETY_SILENT; + err = set_safety_hooks(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 (current_board->has_obd) { + current_board->set_can_mode(CAN_MODE_NORMAL); + } + can_silent = ALL_CAN_SILENT; + break; + case SAFETY_NOOUTPUT: + set_intercept_relay(false); + if (current_board->has_obd) { + current_board->set_can_mode(CAN_MODE_NORMAL); + } + can_silent = ALL_CAN_LIVE; + break; + case SAFETY_ELM327: + set_intercept_relay(false); + heartbeat_counter = 0U; + heartbeat_lost = false; + if (current_board->has_obd) { + if (param == 0) { + current_board->set_can_mode(CAN_MODE_OBD_CAN2); + } else { + current_board->set_can_mode(CAN_MODE_NORMAL); + } + } + can_silent = ALL_CAN_LIVE; + break; + default: + set_intercept_relay(true); + heartbeat_counter = 0U; + heartbeat_lost = false; + if (current_board->has_obd) { + current_board->set_can_mode(CAN_MODE_NORMAL); + } + can_silent = ALL_CAN_LIVE; + break; + } + can_init_all(); } -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); +bool is_car_safety_mode(uint16_t mode) { + return (mode != SAFETY_SILENT) && + (mode != SAFETY_NOOUTPUT) && + (mode != SAFETY_ELM327); } // ***************************** USB port ***************************** int get_health_pkt(void *dat) { - struct __attribute__((packed)) { - 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; - } *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 = (voltage * 8862) / 1000; - - health->current = adc_get(ADCCHAN_CURRENT); - int safety_ignition = safety_ignition_hook(); - if (safety_ignition < 0) { - //Use the GPIO pin to determine ignition - health->started = is_gpio_started(); - } else { - //Current safety hooks want to determine ignition (ex: GM) - health->started = safety_ignition; - } - - health->controls_allowed = controls_allowed; - health->gas_interceptor_detected = gas_interceptor_detected; - - // DEPRECATED - health->started_alt = 0; - health->started_signal_detected = 0; + COMPILE_TIME_ASSERT(sizeof(struct health_t) <= MAX_RESP_LEN); + struct health_t * health = (struct health_t*)dat; + + 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->safety_param_pkt = current_safety_param; + health->power_save_enabled_pkt = (uint8_t)(power_save_status == POWER_SAVE_STATUS_ENABLED); + health->heartbeat_lost_pkt = (uint8_t)(heartbeat_lost); + + health->fault_status_pkt = fault_status; + health->faults_pkt = faults; return sizeof(*health); } -int usb_cb_ep1_in(uint8_t *usbdata, int len, bool hardwired) { - UNUSED(hardwired); - CAN_FIFOMailBox_TypeDef *reply = (CAN_FIFOMailBox_TypeDef *)usbdata; - int ilen = 0; - while (ilen < MIN(len/0x10, 4) && can_pop(&can_rx_q, &reply[ilen])) { - ilen++; - } - return ilen*0x10; +int get_rtc_pkt(void *dat) { + timestamp_t t = rtc_get_time(); + (void)memcpy(dat, &t, sizeof(t)); + return sizeof(t); } + + // send on serial, first byte to select the ring -void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) { +void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { UNUSED(hardwired); - uart_ring *ur = get_ring_by_number(usbdata[0]); + uint8_t *usbdata8 = (uint8_t *)usbdata; + uart_ring *ur = get_ring_by_number(usbdata8[0]); if ((len != 0) && (ur != NULL)) { - if ((usbdata[0] < 2) || safety_tx_lin_hook(usbdata[0]-2, usbdata+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, usbdata[i])) { + while (!putc(ur, usbdata8[i])) { // wait } } @@ -164,37 +213,86 @@ void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) { } } -// send on CAN -void usb_cb_ep3_out(uint8_t *usbdata, int len, bool hardwired) { - UNUSED(hardwired); - int dpkt = 0; - for (dpkt = 0; dpkt < len; dpkt += 0x10) { - uint32_t *tf = (uint32_t*)(&usbdata[dpkt]); - - // make a copy - CAN_FIFOMailBox_TypeDef to_push; - to_push.RDHR = tf[3]; - to_push.RDLR = tf[2]; - to_push.RDTR = tf[1]; - to_push.RIR = tf[0]; - - uint8_t bus_number = (to_push.RDTR >> 4) & CAN_BUS_NUM_MASK; - can_send(&to_push, bus_number); +void usb_cb_ep3_out_complete(void) { + if (can_tx_check_min_slots_free(MAX_CAN_MSGS_PER_BULK_TRANSFER)) { + usb_outep3_resume_if_paused(); } } -bool is_enumerated = 0; - -void usb_cb_enumeration_complete() { +void usb_cb_enumeration_complete(void) { puts("USB enumeration complete\n"); is_enumerated = 1; } int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { - int resp_len = 0; + 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); @@ -203,16 +301,16 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) puts(" err: "); puth(can_err_cnt); puts("\n"); break; - // **** 0xc1: is grey panda + // **** 0xc1: get hardware type case 0xc1: - resp[0] = is_grey_panda; + resp[0] = hw_type; resp_len = 1; break; // **** 0xd0: fetch serial number case 0xd0: // addresses are OTP - if (setup->b.wValue.w == 1) { - memcpy(resp, (void *)0x1fff79c0, 0x10); + if (setup->b.wValue.w == 1U) { + (void)memcpy(resp, (uint8_t *)DEVICE_SERIAL_NUMBER_ADDRESS, 0x10); resp_len = 0x10; } else { get_provision_chunk(resp); @@ -225,11 +323,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"); @@ -245,11 +346,29 @@ 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); - memcpy(resp, gitversion, sizeof(gitversion)); - resp_len = sizeof(gitversion)-1; + (void)memcpy(resp, gitversion, sizeof(gitversion)); + resp_len = sizeof(gitversion) - 1U; break; // **** 0xd8: reset ST case 0xd8: @@ -257,90 +376,82 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) break; // **** 0xd9: set ESP power case 0xd9: - if (setup->b.wValue.w == 1) { - set_esp_mode(ESP_ENABLED); - } else if (setup->b.wValue.w == 2) { - set_esp_mode(ESP_BOOTMODE); + if (setup->b.wValue.w == 1U) { + current_board->set_gps_mode(GPS_ENABLED); + } else if (setup->b.wValue.w == 2U) { + current_board->set_gps_mode(GPS_BOOTMODE); } else { - set_esp_mode(ESP_DISABLED); + current_board->set_gps_mode(GPS_DISABLED); } break; // **** 0xda: reset ESP, with optional boot mode case 0xda: - set_esp_mode(ESP_DISABLED); + current_board->set_gps_mode(GPS_DISABLED); delay(1000000); - if (setup->b.wValue.w == 1) { - set_esp_mode(ESP_BOOTMODE); + if (setup->b.wValue.w == 1U) { + current_board->set_gps_mode(GPS_BOOTMODE); } else { - set_esp_mode(ESP_ENABLED); + current_board->set_gps_mode(GPS_ENABLED); } delay(1000000); - set_esp_mode(ESP_ENABLED); + current_board->set_gps_mode(GPS_ENABLED); break; - // **** 0xdb: set GMLAN multiplexing mode + // **** 0xdb: set GMLAN (white/grey) or OBD CAN (black) multiplexing mode case 0xdb: - if (setup->b.wValue.w == 1) { - // GMLAN ON - if (setup->b.wIndex.w == 1) { - can_set_gmlan(1); - } else if (setup->b.wIndex.w == 2) { - can_set_gmlan(2); + if(current_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 { - can_set_gmlan(-1); + if (setup->b.wValue.w == 1U) { + // GMLAN ON + if (setup->b.wIndex.w == 1U) { + can_set_gmlan(1); + } else if (setup->b.wIndex.w == 2U) { + can_set_gmlan(2); + } else { + puts("Invalid bus num for GMLAN CAN set\n"); + } + } else { + can_set_gmlan(-1); + } } break; + // **** 0xdc: set safety mode case 0xdc: - // this is the only way to leave silent mode - // and it's blocked over WiFi - // Allow ELM security mode to be set over wifi. - if (hardwired || (setup->b.wValue.w == SAFETY_NOOUTPUT) || (setup->b.wValue.w == SAFETY_ELM327)) { - safety_set_mode(setup->b.wValue.w, (int16_t)setup->b.wIndex.w); - 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); - } - #ifndef EON - // always LIVE on EON - switch (setup->b.wValue.w) { - case SAFETY_NOOUTPUT: - can_silent = ALL_CAN_SILENT; - break; - case SAFETY_ELM327: - can_silent = ALL_CAN_BUT_MAIN_SILENT; - break; - default: - can_silent = ALL_CAN_LIVE; - break; - } - #endif - can_init_all(); + // Blocked over WiFi. + // 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; - // **** 0xdd: enable can forwarding + // **** 0xdd: get healthpacket and CANPacket versions case 0xdd: - // wValue = Can Bus Num to forward from - // wIndex = Can Bus Num to forward to - if ((setup->b.wValue.w < BUS_MAX) && (setup->b.wIndex.w < BUS_MAX) && - (setup->b.wValue.w != setup->b.wIndex.w)) { // set forwarding - can_set_forwarding(setup->b.wValue.w, setup->b.wIndex.w & CAN_BUS_NUM_MASK); - } else if((setup->b.wValue.w < BUS_MAX) && (setup->b.wIndex.w == 0xFF)){ //Clear Forwarding - can_set_forwarding(setup->b.wValue.w, -1); - } + resp[0] = HEALTH_PACKET_VERSION; + resp[1] = CAN_PACKET_VERSION; + resp_len = 2; break; // **** 0xde: set can bitrate case 0xde: 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)); + // TODO: add sanity check, ideally check if value is correct(from array of correct values) + bus_config[setup->b.wValue.w].can_speed = setup->b.wIndex.w; + 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 & 1; + // you can only set this if you are in a non car safety mode + if (!is_car_safety_mode(current_safety_mode)) { + unsafe_mode = setup->b.wValue.w; } break; // **** 0xe0: uart read @@ -349,9 +460,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])) { @@ -401,63 +515,37 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) break; // **** 0xe5: set CAN loopback (for testing) case 0xe5: - can_loopback = (setup->b.wValue.w > 0); + can_loopback = (setup->b.wValue.w > 0U); can_init_all(); break; // **** 0xe6: set USB power case 0xe6: - if (setup->b.wValue.w == 1) { - puts("user setting CDP mode\n"); - set_usb_power_mode(USB_POWER_CDP); - } else if (setup->b.wValue.w == 2) { - puts("user setting DCP mode\n"); - set_usb_power_mode(USB_POWER_DCP); - } else { - puts("user setting CLIENT mode\n"); - set_usb_power_mode(USB_POWER_CLIENT); - } + 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 == 1) { - 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 == 1) { - GPIOC->ODR |= (1U << 10); - GPIOC->ODR &= ~(1U << 10); - } else { - GPIOC->ODR |= (1U << 12); - GPIOC->ODR &= ~(1U << 12); + if(current_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 == 1) { - 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: - if (setup->b.wValue.w == 0xFFFF) { + if (setup->b.wValue.w == 0xFFFFU) { puts("Clearing CAN Rx queue\n"); can_clear(&can_rx_q); } else if (setup->b.wValue.w < BUS_MAX) { puts("Clearing CAN Tx queue\n"); can_clear(can_queues[setup->b.wValue.w]); + } else { + puts("Clearing CAN CAN ring buffer failed: wrong bus number\n"); } break; // **** 0xf2: Clear UART ring buffer. @@ -470,6 +558,62 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) } break; } + // **** 0xf3: Heartbeat. Resets heartbeat counter. + case 0xf3: + { + heartbeat_counter = 0U; + heartbeat_lost = false; + heartbeat_disabled = false; + break; + } + // **** 0xf4: k-line/l-line 5 baud initialization + case 0xf4: + if(current_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; + // **** 0xf7: set green led enabled + case 0xf7: + green_led_enabled = (setup->b.wValue.w != 0U); + break; +#ifdef ALLOW_DEBUG + // **** 0xf8: disable heartbeat checks + case 0xf8: + heartbeat_disabled = true; + break; +#endif + // **** 0xde: set CAN FD data bitrate + case 0xf9: + if (setup->b.wValue.w < CAN_MAX) { + // TODO: add sanity check, ideally check if value is correct(from array of correct values) + bus_config[setup->b.wValue.w].can_data_speed = setup->b.wIndex.w; + bus_config[setup->b.wValue.w].canfd_enabled = (setup->b.wIndex.w >= bus_config[setup->b.wValue.w].can_speed) ? true : false; + bus_config[setup->b.wValue.w].brs_enabled = (setup->b.wIndex.w > bus_config[setup->b.wValue.w].can_speed) ? true : false; + bool ret = can_init(CAN_NUM_FROM_BUS_NUM(setup->b.wValue.w)); + UNUSED(ret); + } + break; + // **** 0xfa: check if CAN FD and BRS are enabled + case 0xfa: + if (setup->b.wValue.w < CAN_MAX) { + resp[0] = bus_config[setup->b.wValue.w].canfd_enabled; + resp[1] = bus_config[setup->b.wValue.w].brs_enabled; + resp_len = 2; + } + break; default: puts("NO HANDLER "); puth(setup->b.bRequest); @@ -479,170 +623,170 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) return resp_len; } -int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) { - // data[0] = endpoint - // data[2] = length - // data[4:] = data - UNUSED(len); - int resp_len = 0; - switch (data[0]) { - case 0: - // control transfer - resp_len = usb_cb_control_msg((USB_Setup_TypeDef *)(data+4), data_out, 0); - break; - case 1: - // ep 1, read - resp_len = usb_cb_ep1_in(data_out, 0x40, 0); - break; - case 2: - // ep 2, send serial - usb_cb_ep2_out(data+4, data[2], 0); - break; - case 3: - // ep 3, send CAN - usb_cb_ep3_out(data+4, data[2], 0); - break; - default: - puts("SPI data invalid"); - break; - } - return resp_len; -} - - // ***************************** main code ***************************** +// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck void __initialize_hardware_early(void) { - early(); + early_initialization(); } void __attribute__ ((noinline)) enable_fpu(void) { // enable the FPU - SCB->CPACR |= ((3UL << (10U * 2)) | (3UL << (11U * 2))); + SCB->CPACR |= ((3UL << (10U * 2U)) | (3UL << (11U * 2U))); } -uint64_t tcnt = 0; -uint64_t marker = 0; +// go into SILENT when heartbeat isn't received for this amount of seconds. +#define HEARTBEAT_IGNITION_CNT_ON 5U +#define HEARTBEAT_IGNITION_CNT_OFF 2U -// called once per second -void TIM3_IRQHandler(void) { - #define CURRENT_THRESHOLD 0xF00 - #define CLICKS 5 // 5 seconds to switch modes +// called at 8Hz +uint8_t loop_counter = 0U; +void tick_handler(void) { + if (TICK_TIMER->SR != 0) { + // siren + current_board->set_siren((loop_counter & 1U) && (siren_enabled || (siren_countdown > 0U))); + + // decimated to 1Hz + if (loop_counter == 0U) { + can_live = pending_can_live; + + current_board->usb_power_mode_tick(uptime_cnt); + + //puth(usart1_dma); puts(" "); puth(DMA2_Stream5->M0AR); puts(" "); puth(DMA2_Stream5->NDTR); puts("\n"); + + // reset this every 16th pass + if ((uptime_cnt & 0xFU) == 0U) { + pending_can_live = 0; + } + #ifdef DEBUG + puts("** blink "); + puts("rx:"); puth4(can_rx_q.r_ptr); puts("-"); puth4(can_rx_q.w_ptr); puts(" "); + puts("tx1:"); puth4(can_tx1_q.r_ptr); puts("-"); puth4(can_tx1_q.w_ptr); puts(" "); + puts("tx2:"); puth4(can_tx2_q.r_ptr); puts("-"); puth4(can_tx2_q.w_ptr); puts(" "); + puts("tx3:"); puth4(can_tx3_q.r_ptr); puts("-"); puth4(can_tx3_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 | green_led_enabled); + + // 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; + } + + if (siren_countdown > 0U) { + siren_countdown -= 1U; + } + + if (controls_allowed) { + controls_allowed_countdown = 30U; + } else if (controls_allowed_countdown > 0U) { + controls_allowed_countdown -= 1U; + } else { - if (TIM3->SR != 0) { - can_live = pending_can_live; + } - //puth(usart1_dma); puts(" "); puth(DMA2_Stream5->M0AR); puts(" "); puth(DMA2_Stream5->NDTR); puts("\n"); + if (!heartbeat_disabled) { + // if the heartbeat has been gone for a while, go to SILENT safety mode and enter power save + if (heartbeat_counter >= (check_started() ? HEARTBEAT_IGNITION_CNT_ON : HEARTBEAT_IGNITION_CNT_OFF)) { + puts("device hasn't sent a heartbeat for 0x"); + puth(heartbeat_counter); + puts(" seconds. Safety is set to SILENT mode.\n"); - uint32_t current = adc_get(ADCCHAN_CURRENT); + if (controls_allowed_countdown > 0U) { + siren_countdown = 5U; + controls_allowed_countdown = 0U; + } - switch (usb_power_mode) { - case USB_POWER_CLIENT: - if ((tcnt-marker) >= CLICKS) { - if (!is_enumerated) { - puts("USBP: didn't enumerate, switching to CDP mode\n"); - // switch to CDP - set_usb_power_mode(USB_POWER_CDP); - marker = tcnt; + // set flag to indicate the heartbeat was lost + if (is_car_safety_mode(current_safety_mode)) { + heartbeat_lost = true; } - } - // keep resetting the timer if it's enumerated - if (is_enumerated) { - marker = tcnt; - } - break; - case USB_POWER_CDP: - // On the EON, if we get into CDP mode we stay here. No need to go to DCP. - #ifndef EON - // been CLICKS clicks since we switched to CDP - if ((tcnt-marker) >= CLICKS) { - // measure current draw, if positive and no enumeration, switch to DCP - if (!is_enumerated && (current < CURRENT_THRESHOLD)) { - puts("USBP: no enumeration with current draw, switching to DCP mode\n"); - set_usb_power_mode(USB_POWER_DCP); - marker = tcnt; - } + + if (current_safety_mode != SAFETY_SILENT) { + set_safety_mode(SAFETY_SILENT, 0U); } - // keep resetting the timer if there's no current draw in CDP - if (current >= CURRENT_THRESHOLD) { - marker = tcnt; + if (power_save_status != POWER_SAVE_STATUS_ENABLED) { + set_power_save_state(POWER_SAVE_STATUS_ENABLED); } - #endif - break; - case USB_POWER_DCP: - // been at least CLICKS clicks since we switched to DCP - if ((tcnt-marker) >= CLICKS) { - // if no current draw, switch back to CDP - if (current >= CURRENT_THRESHOLD) { - puts("USBP: no current draw, switching back to CDP mode\n"); - set_usb_power_mode(USB_POWER_CDP); - marker = tcnt; + + // Also disable IR when the heartbeat goes missing + current_board->set_ir_power(0U); + + // 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); } } - // keep resetting the timer if there's current draw in DCP - if (current < CURRENT_THRESHOLD) { - marker = tcnt; + + // 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); } - break; - default: - puts("USB power mode invalid\n"); // set_usb_power_mode prevents assigning invalid values - break; - } + } - // ~0x9a = 500 ma - /*puth(current); - puts("\n");*/ + // check registers + check_registers(); - // reset this every 16th pass - if ((tcnt&0xF) == 0) { - pending_can_live = 0; - } - #ifdef DEBUG - puts("** blink "); - puth(can_rx_q.r_ptr); puts(" "); puth(can_rx_q.w_ptr); puts(" "); - puth(can_tx1_q.r_ptr); puts(" "); puth(can_tx1_q.w_ptr); puts(" "); - puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n"); - #endif + // set ignition_can to false after 2s of no CAN seen + if (ignition_can_cnt > 2U) { + ignition_can = false; + } - // set green LED to be controls allowed - set_led(LED_GREEN, controls_allowed); + // on to the next one + uptime_cnt += 1U; + safety_mode_cnt += 1U; + ignition_can_cnt += 1U; - // turn off the blue LED, turned on by CAN - // unless we are in power saving mode - set_led(LED_BLUE, (tcnt & 1) && (power_save_status == POWER_SAVE_STATUS_ENABLED)); + // synchronous safety check + safety_tick(current_rx_checks); + } - // on to the next one - tcnt += 1; + loop_counter++; + loop_counter %= 8U; } - TIM3->SR = 0; + TICK_TIMER->SR = 0; } + int main(void) { + // Init interrupt table + init_interrupts(true); + // shouldn't have interrupts here, but just in case - __disable_irq(); + disable_interrupts(); // init early devices clock_init(); - periph_init(); - detect(); + peripherals_init(); + detect_external_debug_serial(); + detect_board_type(); + adc_init(); // print hello puts("\n\n\n************************ MAIN START ************************\n"); - // detect the revision and init the GPIOs - puts("config:\n"); - puts((revision == PANDA_REV_C) ? " panda rev c\n" : " panda rev a or b\n"); - puts(has_external_debug_serial ? " real serial\n" : " USB serial\n"); - puts(is_giant_panda ? " GIANTpanda detected\n" : " not GIANTpanda\n"); - puts(is_grey_panda ? " gray panda detected!\n" : " white panda\n"); - puts(is_entering_bootmode ? " ESP wants bootmode\n" : " no bootmode\n"); - - // non rev c panda are no longer supported - while (revision != PANDA_REV_C) { - // hang + // check for non-supported board types + if(hw_type == HW_TYPE_UNKNOWN){ + puts("Unsupported board type\n"); + while (1) { /* hang */ } } - gpio_init(); + puts("Config:\n"); + puts(" Board type: "); puts(current_board->board_type); puts("\n"); + puts(has_external_debug_serial ? " Real serial\n" : " USB serial\n"); + + // init board + current_board->init(); // panda has an FPU, let's use it! enable_fpu(); @@ -651,70 +795,41 @@ 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 (is_grey_panda) { - uart_init(USART1, 9600); + if (current_board->has_gps) { + uart_init(&uart_ring_gps, 9600); } else { // enable ESP uart - uart_init(USART1, 115200); + uart_init(&uart_ring_gps, 115200); } - // enable LIN - uart_init(UART5, 10400); - UART5->CR2 |= USART_CR2_LINEN; - uart_init(USART3, 10400); - USART3->CR2 |= USART_CR2_LINEN; - - // init microsecond system timer - // increments 1000000 times per second - // generate an update to set the prescaler - TIM2->PSC = 48-1; - TIM2->CR1 = TIM_CR1_CEN; - TIM2->EGR = TIM_EGR_UG; - // use TIM2->CNT to read - - // enable USB - usb_init(); + if(current_board->has_lin){ + // enable LIN + uart_init(&uart_ring_lin1, 10400); + UART5->CR2 |= USART_CR2_LINEN; + uart_init(&uart_ring_lin2, 10400); + USART3->CR2 |= USART_CR2_LINEN; + } - // default to silent mode to prevent issues with Ford - // hardcode a specific safety mode if you want to force the panda to be in a specific mode - safety_set_mode(SAFETY_NOOUTPUT, 0); -#ifdef EON - // if we're on an EON, it's fine for CAN to be live for fingerprinting - can_silent = ALL_CAN_LIVE; -#else - can_silent = ALL_CAN_SILENT; -#endif - can_init_all(); + microsecond_timer_init(); - adc_init(); + // init to SILENT and can silent + set_safety_mode(SAFETY_SILENT, 0); -#ifndef EON - spi_init(); -#endif + // enable CAN TXs + current_board->enable_can_transceivers(true); -#ifdef EON - // have to save power - if (!is_grey_panda) { - set_esp_mode(ESP_DISABLED); - } - // only enter power save after the first cycle - /*if (is_gpio_started()) { - set_power_save_state(POWER_SAVE_STATUS_ENABLED); - }*/ - // interrupt on started line - started_interrupt_init(); -#endif - - // 48mhz / 65536 ~= 732 / 732 = 1 - timer_init(TIM3, 732); - NVIC_EnableIRQ(TIM3_IRQn); + // 8Hz timer + REGISTER_INTERRUPT(TICK_TIMER_IRQ, tick_handler, 10U, FAULT_INTERRUPT_RATE_TICK) + tick_timer_init(); #ifdef DEBUG puts("DEBUG ENABLED\n"); #endif + // enable USB (right before interrupts or enum can fail!) + usb_init(); puts("**** INTERRUPTS ON ****\n"); enable_interrupts(); @@ -724,19 +839,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++) { - set_led(LED_RED, 1); - if (fade < 512) { delay(fade); } else { delay(1024-fade); } - set_led(LED_RED, 0); - if (fade < 512) { delay(512-fade); } else { delay(fade-512); } - } + #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_LED_FADE; fade += div_mode){ + current_board->set_led(LED_RED, true); + delay(fade >> 4); + current_board->set_led(LED_RED, false); + delay((MAX_LED_FADE - fade) >> 4); } - } + + for(uint32_t fade = MAX_LED_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_LED_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(); } @@ -744,4 +874,3 @@ int main(void) { return 0; } - diff --git a/panda/board/main_declarations.h b/panda/board/main_declarations.h new file mode 100644 index 00000000000000..c211e598823063 --- /dev/null +++ b/panda/board/main_declarations.h @@ -0,0 +1,28 @@ +// ******************** Prototypes ******************** +void puts(const char *a); +void puth(unsigned int i); +void puth2(unsigned int i); +void puth4(unsigned int i); +typedef struct board board; +typedef struct harness_configuration harness_configuration; +void can_flip_buses(uint8_t bus1, uint8_t bus2); +void pwm_init(TIM_TypeDef *TIM, uint8_t channel); +void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage); + +// ********************* Globals ********************** +uint8_t hw_type = 0; +const board *current_board; +bool is_enumerated = 0; +uint32_t uptime_cnt = 0; +bool green_led_enabled = false; + +// heartbeat state +uint32_t heartbeat_counter = 0; +bool heartbeat_lost = false; +bool heartbeat_disabled = false; // set over USB + +// siren state +bool siren_enabled = false; +uint32_t siren_countdown = 0; // siren plays while countdown > 0 +uint32_t controls_allowed_countdown = 0; + diff --git a/panda/board/pedal/Makefile b/panda/board/pedal/Makefile deleted file mode 100644 index 37b95f90fb1880..00000000000000 --- a/panda/board/pedal/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# :set noet -PROJ_NAME = comma - -CFLAGS = -O2 -Wall -std=gnu11 -DPEDAL -CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3 -CFLAGS += -msoft-float -DSTM32F2 -DSTM32F205xx -CFLAGS += -I ../inc -I ../ -I ../../ -nostdlib -CFLAGS += -T../stm32_flash.ld - -STARTUP_FILE = startup_stm32f205xx - -CC = arm-none-eabi-gcc -OBJCOPY = arm-none-eabi-objcopy -OBJDUMP = arm-none-eabi-objdump -DFU_UTIL = "dfu-util" - -# pedal only uses the debug cert -CERT = ../../certs/debug -CFLAGS += "-DALLOW_DEBUG" - -canflash: obj/$(PROJ_NAME).bin - ../../tests/pedal/enter_canloader.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 - $(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 - -include ../../common/version.mk - -obj/cert.h: ../../crypto/getcertheader.py - ../../crypto/getcertheader.py ../../certs/debug.pub ../../certs/release.pub > $@ - -obj/main.o: main.c ../*.h - mkdir -p obj - $(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 - $(CC) $(CFLAGS) -o $@ -c $< - -obj/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s - $(CC) $(CFLAGS) -o $@ -c $< - -obj/%.o: ../../crypto/%.c - $(CC) $(CFLAGS) -o $@ -c $< - -obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/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) - -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/README b/panda/board/pedal/README index cf779db258fe14..9e004d6bd84dc4 100644 --- a/panda/board/pedal/README +++ b/panda/board/pedal/README @@ -1,8 +1,8 @@ -This is the firmware for the comma pedal. It borrows a lot from panda. +# pedal -The comma pedal is a gas pedal interceptor for Honda/Acura. It allows you to "virtually" press the pedal. +This is the firmware for the comma pedal. -This is the open source software. Note that it is not ready to use yet. +The comma pedal is a gas pedal interceptor for Honda/Acura and Toyota/Lexus. It allows you to "virtually" press the pedal and borrows a lot from panda. == Test Plan == diff --git a/panda/board/pedal/flash_can.sh b/panda/board/pedal/flash_can.sh new file mode 100755 index 00000000000000..1125372766d7f6 --- /dev/null +++ b/panda/board/pedal/flash_can.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +set -e + +cd .. +PEDAL=1 scons -u +cd pedal + +../../tests/pedal/enter_canloader.py ../obj/pedal.bin.signed diff --git a/panda/board/pedal/main.c b/panda/board/pedal/main.c index 4656db283160b4..7553b3e50998ba 100644 --- a/panda/board/pedal/main.c +++ b/panda/board/pedal/main.c @@ -1,33 +1,33 @@ +// ********************* Includes ********************* +//#define PEDAL_USB #include "../config.h" -#include "drivers/llcan.h" -#include "drivers/llgpio.h" -#include "drivers/clock.h" -#include "drivers/adc.h" -#include "drivers/dac.h" -#include "drivers/timer.h" - -#include "gpio.h" -#include "libc.h" +#include "early_init.h" +#include "crc.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) {} - void puth(unsigned int i) {} + 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 +#define ENTER_BOOTLOADER_MAGIC 0xdeadbeefU uint32_t enter_bootloader_mode; -void __initialize_hardware_early() { - early(); +// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck +void __initialize_hardware_early(void) { + early_initialization(); } // ********************* serial debugging ********************* @@ -36,66 +36,72 @@ void __initialize_hardware_early() { 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); } } -int usb_cb_ep1_in(uint8_t *usbdata, int len, bool hardwired) { return 0; } -void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) {} -void usb_cb_ep3_out(uint8_t *usbdata, int len, bool hardwired) {} -void usb_cb_enumeration_complete() {} +int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { + UNUSED(usbdata); + UNUSED(len); + UNUSED(hardwired); + return 0; +} +void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { + UNUSED(usbdata); + UNUSED(len); + UNUSED(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) { - int resp_len = 0; + UNUSED(hardwired); + unsigned int resp_len = 0; uart_ring *ur = NULL; switch (setup->b.bRequest) { + // **** 0xc1: get hardware type + case 0xc1: + resp[0] = hw_type; + resp_len = 1; + break; // **** 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; + } // read 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 -// ***************************** 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 & 0x80) != 0) { - crc = (uint8_t)((crc << 1) ^ poly); - } - else { - crc <<= 1; - } - } - } - return crc; -} - // ***************************** can port ***************************** // addresses to be used on CAN #define CAN_GAS_INPUT 0x200 -#define CAN_GAS_OUTPUT 0x201 +#define CAN_GAS_OUTPUT 0x201U #define CAN_GAS_SIZE 6 -#define COUNTER_CYCLE 0xF +#define COUNTER_CYCLE 0xFU -void CAN1_TX_IRQHandler() { +void CAN1_TX_IRQ_Handler(void) { // clear interrupt CAN->TSR |= CAN_TSR_RQCP0; } @@ -104,54 +110,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; +const uint8_t crc_poly = 0xD5U; // standard crc8 -void CAN1_RX0_IRQHandler() { - while (CAN->RF0R & CAN_RF0R_FMP0) { +void CAN1_RX0_IRQ_Handler(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_MAILBOX_BYTES_04(&CAN->sFIFOMailBox[0]) == 0xdeadface) { + if (GET_MAILBOX_BYTES_48(&CAN->sFIFOMailBox[0]) == 0x0ab00b1e) { enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; NVIC_SystemReset(); - } else if (CAN->sFIFOMailBox[0].RDHR == 0x02b00b1e) { + } else if (GET_MAILBOX_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[8]; - uint8_t *rdlr = (uint8_t *)&CAN->sFIFOMailBox[0].RDLR; - uint8_t *rdhr = (uint8_t *)&CAN->sFIFOMailBox[0].RDHR; - for (int i=0; i<4; i++) { - dat[i] = rdlr[i]; - dat[i+4] = rdhr[i]; + for (int i=0; i<8; i++) { + dat[i] = GET_MAILBOX_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 = (dat[4] >> 7) & 1; + 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 (((current_index + 1) & COUNTER_CYCLE) == index) { + if (crc_checksum(dat, CAN_GAS_SIZE - 1, crc_poly) == dat[5]) { + if (((current_index + 1U) & COUNTER_CYCLE) == index) { #ifdef DEBUG puts("setting gas "); - puth(value); + puth(value_0); puts("\n"); #endif if (enable) { @@ -159,12 +165,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; @@ -180,17 +187,18 @@ void CAN1_RX0_IRQHandler() { } } -void CAN1_SCE_IRQHandler() { +void CAN1_SCE_IRQ_Handler(void) { state = FAULT_SCE; 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() { +void TIM3_IRQ_Handler(void) { #ifdef DEBUG puth(TIM3->CNT); puts(" "); @@ -203,16 +211,16 @@ 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 & 0xF) << 4 | pkt_idx; - dat[5] = pedal_checksum(dat, CAN_GAS_SIZE - 1); - 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] = crc_checksum(dat, CAN_GAS_SIZE - 1, crc_poly); + 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 &= COUNTER_CYCLE; } else { @@ -224,7 +232,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; @@ -233,13 +241,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); @@ -256,13 +264,27 @@ void pedal() { watchdog_feed(); } -int main() { - __disable_irq(); +int main(void) { + // 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(); - periph_init(); - gpio_init(); + peripherals_init(); + detect_external_debug_serial(); + detect_board_type(); + + // init board + current_board->init(); #ifdef PEDAL_USB // enable USB @@ -274,8 +296,13 @@ int main() { adc_init(); // init can - llcan_set_speed(CAN1, 5000, false, false); - llcan_init(CAN1); + bool llcan_speed_set = llcan_set_speed(CAN1, 5000, false, false); + if (!llcan_speed_set) { + puts("Failed to set llcan speed"); + } + + bool ret = llcan_init(CAN1); + UNUSED(ret); // 48mhz / 65536 ~= 732 timer_init(TIM3, 15); @@ -284,7 +311,7 @@ int main() { watchdog_init(); puts("**** INTERRUPTS ON ****\n"); - __enable_irq(); + enable_interrupts(); // main pedal loop while (1) { diff --git a/panda/board/pedal/main_declarations.h b/panda/board/pedal/main_declarations.h new file mode 100644 index 00000000000000..13bf7ebc0eb802 --- /dev/null +++ b/panda/board/pedal/main_declarations.h @@ -0,0 +1,12 @@ +// ******************** Prototypes ******************** +void puts(const char *a); +void puth(unsigned int i); +void puth2(unsigned int i); +void puth4(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; diff --git a/panda/board/pedal/recover.sh b/panda/board/pedal/recover.sh new file mode 100755 index 00000000000000..607a32cea4dd8d --- /dev/null +++ b/panda/board/pedal/recover.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +set -e + +DFU_UTIL="dfu-util" + +cd .. +PEDAL=1 scons -u +cd pedal + +$DFU_UTIL -d 0483:df11 -a 0 -s 0x08004000 -D ../obj/pedal.bin.signed +$DFU_UTIL -d 0483:df11 -a 0 -s 0x08000000:leave -D ../obj/bootstub.pedal.bin diff --git a/panda/board/power_saving.h b/panda/board/power_saving.h index 986adf3ce29ff5..52c65028a43ed5 100644 --- a/panda/board/power_saving.h +++ b/panda/board/power_saving.h @@ -1,3 +1,6 @@ +// 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 0 #define POWER_SAVE_STATUS_ENABLED 1 @@ -10,33 +13,46 @@ void set_power_save_state(int state) { bool enable = false; if (state == POWER_SAVE_STATUS_ENABLED) { puts("enable power savings\n"); - if (is_grey_panda) { - char UBLOX_SLEEP_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x08\x00\x17\x78"; + if (current_board->has_gps) { + const char UBLOX_SLEEP_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x08\x00\x17\x78"; uart_ring *ur = get_ring_by_number(1); - for (unsigned int i = 0; i < sizeof(UBLOX_SLEEP_MSG) - 1; i++) while (!putc(ur, UBLOX_SLEEP_MSG[i])); + for (unsigned int i = 0; i < sizeof(UBLOX_SLEEP_MSG) - 1U; i++) while (!putc(ur, UBLOX_SLEEP_MSG[i])); } } else { puts("disable power savings\n"); - if (is_grey_panda) { - char UBLOX_WAKE_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x09\x00\x18\x7a"; + if (current_board->has_gps) { + const char UBLOX_WAKE_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x09\x00\x18\x7a"; uart_ring *ur = get_ring_by_number(1); - for (unsigned int i = 0; i < sizeof(UBLOX_WAKE_MSG) - 1; i++) while (!putc(ur, UBLOX_WAKE_MSG[i])); + for (unsigned int i = 0; i < sizeof(UBLOX_WAKE_MSG) - 1U; i++) while (!putc(ur, UBLOX_WAKE_MSG[i])); } enable = true; } - // turn on can - set_can_enable(CAN1, enable); - set_can_enable(CAN2, enable); - set_can_enable(CAN3, 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(current_board->has_hw_gmlan){ + // turn on GMLAN + set_gpio_output(GPIOB, 14, enable); + set_gpio_output(GPIOB, 15, enable); + } - // turn on GMLAN - set_gpio_output(GPIOB, 14, enable); - set_gpio_output(GPIOB, 15, enable); + if(current_board->has_lin){ + // turn on LIN + set_gpio_output(GPIOB, 7, enable); + set_gpio_output(GPIOA, 14, enable); + } - // 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 2fad513508132d..ed670a6db89ccc 100644 --- a/panda/board/provision.h +++ b/panda/board/provision.h @@ -5,9 +5,14 @@ // SHA1 checksum = 0x1C - 0x20 void get_provision_chunk(uint8_t *resp) { - memcpy(resp, (void *)0x1fff79e0, PROVISION_CHUNK_LEN); + (void)memcpy(resp, (uint8_t *)PROVISION_CHUNK_ADDRESS, PROVISION_CHUNK_LEN); if (memcmp(resp, "\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) { - memcpy(resp, "unprovisioned\x00\x00\x00testing123\x00\x00\xa3\xa6\x99\xec", 0x20); + (void)memcpy(resp, "unprovisioned\x00\x00\x00testing123\x00\x00\xa3\xa6\x99\xec", 0x20); } } +uint8_t chunk[PROVISION_CHUNK_LEN]; +bool is_provisioned(void) { + (void)memcpy(chunk, (uint8_t *)PROVISION_CHUNK_ADDRESS, 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/recover.sh b/panda/board/recover.sh new file mode 100755 index 00000000000000..9cf68e5da0579e --- /dev/null +++ b/panda/board/recover.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +set -e + +DFU_UTIL="dfu-util" + +scons -u + +PYTHONPATH=.. python3 -c "from python import Panda; Panda().reset(enter_bootstub=True); Panda().reset(enter_bootloader=True)" || true +sleep 1 +$DFU_UTIL -d 0483:df11 -a 0 -s 0x08004000 -D obj/panda.bin.signed +$DFU_UTIL -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.panda.bin diff --git a/panda/board/recover_h7.sh b/panda/board/recover_h7.sh new file mode 100755 index 00000000000000..1ca11884fe2af8 --- /dev/null +++ b/panda/board/recover_h7.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +set -e + +DFU_UTIL="dfu-util" + +scons -u + +PYTHONPATH=.. python3 -c "from python import Panda; Panda().reset(enter_bootstub=True); Panda().reset(enter_bootloader=True)" || true +sleep 1 +$DFU_UTIL -d 0483:df11 -a 0 -s 0x08020000 -D obj/panda_h7.bin.signed +$DFU_UTIL -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.panda_h7.bin diff --git a/panda/board/safety.h b/panda/board/safety.h index dd99e6db2ee6dd..1f1bcba7266ce0 100644 --- a/panda/board/safety.h +++ b/panda/board/safety.h @@ -4,39 +4,230 @@ #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 20U +#define SAFETY_VOLKSWAGEN_PQ 21U +#define SAFETY_SUBARU_LEGACY 22U +#define SAFETY_HYUNDAI_LEGACY 23U +#define SAFETY_HYUNDAI_COMMUNITY 24U +#define SAFETY_STELLANTIS 25U + +uint16_t current_safety_mode = SAFETY_SILENT; +int16_t current_safety_param = 0; const safety_hooks *current_hooks = &nooutput_hooks; +const addr_checks *current_rx_checks = &default_rx_checks; -void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push){ - current_hooks->rx(to_push); +int safety_rx_hook(CANPacket_t *to_push) { + return current_hooks->rx(to_push); } -int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { - return current_hooks->tx(to_send); +int safety_tx_hook(CANPacket_t *to_send) { + return (relay_malfunction ? -1 : current_hooks->tx(to_send)); } -int safety_tx_lin_hook(int lin_num, uint8_t *data, int len){ +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, CANPacket_t *to_fwd) { + return (relay_malfunction ? -1 : current_hooks->fwd(bus_num, to_fwd)); } -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(CANPacket_t *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(CANPacket_t *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 addr_checks *rx_checks) { + uint32_t ts = microsecond_timer_get(); + if (rx_checks != NULL) { + for (int i=0; i < rx_checks->len; i++) { + uint32_t elapsed_time = get_ts_elapsed(ts, rx_checks->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(rx_checks->check[i].msg[rx_checks->check[i].index].expected_timestep * MAX_MISSED_MSGS, 1e6); + rx_checks->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 = microsecond_timer_get(); + addr_list[index].last_timestamp = ts; + } +} + +bool addr_safety_check(CANPacket_t *to_push, + const addr_checks *rx_checks, + uint8_t (*get_checksum)(CANPacket_t *to_push), + uint8_t (*compute_checksum)(CANPacket_t *to_push), + uint8_t (*get_counter)(CANPacket_t *to_push)) { + + int index = get_addr_check_index(to_push, rx_checks->check, rx_checks->len); + update_addr_timestamp(rx_checks->check, index); + + if (index != -1) { + // checksum check + if ((get_checksum != NULL) && (compute_checksum != NULL) && rx_checks->check[index].msg[rx_checks->check[index].index].check_checksum) { + uint8_t checksum = get_checksum(to_push); + uint8_t checksum_comp = compute_checksum(to_push); + rx_checks->check[index].valid_checksum = checksum_comp == checksum; + } else { + rx_checks->check[index].valid_checksum = true; + } + + // counter check (max_counter == 0 means skip check) + if ((get_counter != NULL) && (rx_checks->check[index].msg[rx_checks->check[index].index].max_counter > 0U)) { + uint8_t counter = get_counter(to_push); + update_counter(rx_checks->check, index, counter); + } else { + rx_checks->check[index].wrong_counters = 0U; + } + } + return is_msg_valid(rx_checks->check, 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 { @@ -44,62 +235,78 @@ typedef struct { const safety_hooks *hooks; } safety_hook_config; -#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_GM_ASCM 0x1334 -#define SAFETY_TOYOTA_IPAS 0x1335 -#define SAFETY_ALLOUTPUT 0x1337 -#define SAFETY_ELM327 0xE327 - 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, &honda_bosch_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}, + {SAFETY_MAZDA, &mazda_hooks}, +#ifdef ALLOW_DEBUG {SAFETY_TESLA, &tesla_hooks}, + {SAFETY_SUBARU_LEGACY, &subaru_legacy_hooks}, + {SAFETY_VOLKSWAGEN_PQ, &volkswagen_pq_hooks}, {SAFETY_ALLOUTPUT, &alloutput_hooks}, - {SAFETY_ELM327, &elm327_hooks}, + {SAFETY_FORD, &ford_hooks}, +#endif }; -int safety_set_mode(uint16_t mode, int16_t param) { - int set_status = -1; // not set +int set_safety_hooks(uint16_t mode, int16_t param) { + // reset state set by safety mode + safety_mode_cnt = 0U; + 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; + acc_main_on = 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 = mode; + current_safety_param = param; + set_status = 0; // set } } if ((set_status == 0) && (current_hooks->init != NULL)) { - current_hooks->init(param); + current_rx_checks = current_hooks->init(param); + // reset message index and seen flags in addr struct + for (int j = 0; j < current_rx_checks->len; j++) { + current_rx_checks->check[j].index = 0; + current_rx_checks->check[j].msg_seen = false; + } } 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; @@ -202,7 +409,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 ef114abfe9143e..00000000000000 --- a/panda/board/safety/safety_cadillac.h +++ /dev/null @@ -1,134 +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; - -int 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; -int 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 = ((to_push->RDLR & 0x7) << 8) | ((to_push->RDLR >> 8) & 0xFF); - 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 = to_push->RDLR > 0; - } - - // enter controls on rising edge of ACC, exit controls on ACC off - if ((addr == 0x370) && (bus == 0)) { - int cruise_engaged = to_push->RDLR & 0x800000; // 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 = (to_push->RDHR>>4) & 0x1; - } -} - -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 = ((to_send->RDLR & 0x3f) << 8) + ((to_send->RDLR & 0xff00) >> 8); - 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 19149b6b7a7ae9..f94f75e7b09531 100644 --- a/panda/board/safety/safety_chrysler.h +++ b/panda/board/safety/safety_chrysler.h @@ -4,62 +4,132 @@ 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_addr_checks[] = { + {.msg = {{544, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{514, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{500, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{308, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{320, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, +}; +#define CHRYSLER_ADDR_CHECK_LEN (sizeof(chrysler_addr_checks) / sizeof(chrysler_addr_checks[0])) +addr_checks chrysler_rx_checks = {chrysler_addr_checks, CHRYSLER_ADDR_CHECK_LEN}; -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(CANPacket_t *to_push) { + int checksum_byte = GET_LEN(to_push) - 1U; + 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(CANPacket_t *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 = 0xFFU; + int len = GET_LEN(to_push); + for (int j = 0; j < (len - 1); j++) { + uint8_t shift = 0x80U; + 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(CANPacket_t *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) { - uint32_t rdhr = to_push->RDHR; - int torque_meas_new = ((rdhr & 0x7U) << 8) + ((rdhr & 0xFF00U) >> 8) - 1024U; +static int chrysler_rx_hook(CANPacket_t *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_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 = ((to_push->RDLR & 0x380000) >> 19) == 7; - if (cruise_engaged && !chrysler_cruise_engaged_last) { - controls_allowed = 1; + if (valid && (GET_BUS(to_push) == 0U)) { + 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) & 0x38U) >> 3) == 7U; + 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; + } + + // exit controls on rising edge of gas press + if (addr == 308) { + gas_pressed = ((GET_BYTE(to_push, 5) & 0x7FU) != 0U) && ((int)vehicle_speed > CHRYSLER_GAS_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 brake press + if (addr == 320) { + brake_pressed = (GET_BYTE(to_push, 0) & 0x7U) == 5U; + 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) { +static int chrysler_tx_hook(CANPacket_t *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); - // LKA STEER if (addr == 0x292) { - uint32_t rdlr = to_send->RDLR; - int desired_torque = ((rdlr & 0x7U) << 8) + ((rdlr & 0xFF00U) >> 8) - 1024U; - uint32_t ts = TIM2->CNT; + int desired_torque = ((GET_BYTE(to_send, 0) & 0x7U) << 8) + GET_BYTE(to_send, 1) - 1024U; + uint32_t ts = microsecond_timer_get(); bool violation = 0; if (controls_allowed) { @@ -68,20 +138,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; } } @@ -92,9 +162,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) { @@ -102,42 +172,45 @@ 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) != 1U) || ((GET_BYTE(to_send, 1) & 1U) == 1U)) { + 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) { +static int chrysler_fwd_hook(int bus_num, CANPacket_t *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) { + if (bus_num == 0) { 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)) { + if ((bus_num == 2) && (addr != 658) && (addr != 678)) { bus_fwd = 0; } + return bus_fwd; } +static const addr_checks* chrysler_init(int16_t param) { + UNUSED(param); + controls_allowed = false; + relay_malfunction_reset(); + return &chrysler_rx_checks; +} const safety_hooks chrysler_hooks = { .init = chrysler_init, .rx = chrysler_rx_hook, .tx = chrysler_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = chrysler_fwd_hook, }; diff --git a/panda/board/safety/safety_defaults.h b/panda/board/safety/safety_defaults.h index 9dc23b54b79906..5cda26bc672ea2 100644 --- a/panda/board/safety/safety_defaults.h +++ b/panda/board/safety/safety_defaults.h @@ -1,19 +1,23 @@ -void default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - UNUSED(to_push); -} +const addr_checks default_rx_checks = { + .check = NULL, + .len = 0, +}; -int default_ign_hook(void) { - return -1; // use GPIO to determine ignition +int default_rx_hook(CANPacket_t *to_push) { + UNUSED(to_push); + return true; } // *** no output safety mode *** -static void nooutput_init(int16_t param) { +static const addr_checks* nooutput_init(int16_t param) { UNUSED(param); - controls_allowed = 0; + controls_allowed = false; + relay_malfunction_reset(); + return &default_rx_checks; } -static int nooutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int nooutput_tx_hook(CANPacket_t *to_send) { UNUSED(to_send); return false; } @@ -25,7 +29,7 @@ static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) { return false; } -static int default_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static int default_fwd_hook(int bus_num, CANPacket_t *to_fwd) { UNUSED(bus_num); UNUSED(to_fwd); return -1; @@ -36,18 +40,24 @@ 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, }; // *** all output safety mode *** -static void alloutput_init(int16_t param) { +// Enables passthrough mode where relay is open and bus 0 gets forwarded to bus 2 and vice versa +const uint16_t ALLOUTPUT_PARAM_PASSTHROUGH = 1; +bool alloutput_passthrough = false; + +static const addr_checks* alloutput_init(int16_t param) { UNUSED(param); - controls_allowed = 1; + alloutput_passthrough = GET_FLAG(param, ALLOUTPUT_PARAM_PASSTHROUGH); + controls_allowed = true; + relay_malfunction_reset(); + return &default_rx_checks; } -static int alloutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int alloutput_tx_hook(CANPacket_t *to_send) { UNUSED(to_send); return true; } @@ -59,11 +69,26 @@ static int alloutput_tx_lin_hook(int lin_num, uint8_t *data, int len) { return true; } +static int alloutput_fwd_hook(int bus_num, CANPacket_t *to_fwd) { + UNUSED(to_fwd); + int bus_fwd = -1; + + if (alloutput_passthrough) { + if (bus_num == 0) { + bus_fwd = 2; + } + if (bus_num == 2) { + bus_fwd = 0; + } + } + + return bus_fwd; +} + const safety_hooks alloutput_hooks = { .init = alloutput_init, .rx = default_rx_hook, .tx = alloutput_tx_hook, .tx_lin = alloutput_tx_lin_hook, - .ignition = default_ign_hook, - .fwd = default_fwd_hook, + .fwd = alloutput_fwd_hook, }; diff --git a/panda/board/safety/safety_elm327.h b/panda/board/safety/safety_elm327.h index 1f44e992a0d4e9..d4f562a8302d95 100644 --- a/panda/board/safety/safety_elm327.h +++ b/panda/board/safety/safety_elm327.h @@ -1,15 +1,9 @@ -static int elm327_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int elm327_tx_hook(CANPacket_t *to_send) { int tx = 1; - int bus = GET_BUS(to_send); int addr = GET_ADDR(to_send); int len = GET_LEN(to_send); - //All ELM traffic must appear on CAN0 - if (bus != 0) { - tx = 0; - } - //All ISO 15765-4 messages must be 8 bytes long if (len != 8) { tx = 0; @@ -18,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; @@ -39,11 +33,11 @@ static int elm327_tx_lin_hook(int lin_num, uint8_t *data, int len) { return tx; } +// If current_board->has_obd and safety_param == 0, bus 1 is multiplexed to the OBD-II port const safety_hooks elm327_hooks = { .init = nooutput_init, .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 21c9c54db1300c..ccdc54e6e57a7d 100644 --- a/panda/board/safety/safety_ford.h +++ b/panda/board/safety/safety_ford.h @@ -7,24 +7,25 @@ // brake rising edge // brake > 0mph -int ford_brake_prev = 0; -int ford_gas_prev = 0; -int ford_is_moving = 0; -static void ford_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { +static int ford_rx_hook(CANPacket_t *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_is_moving = 0xFCFF & (to_push->RDLR | (to_push->RDLR >> 16) | - to_push->RDHR | (to_push->RDHR >> 16)); + vehicle_moving = false; + for (int i = 0; i < 8; i += 2) { + vehicle_moving |= GET_BYTE(to_push, i) | (GET_BYTE(to_push, (int)(i + 1)) & 0xFCU); + } } // state machine to enter and exit controls if (addr == 0x83) { - bool cancel = (to_push->RDLR >> 8) & 0x1; - bool set_or_resume = (to_push->RDLR >> 28) & 0x3; + bool cancel = GET_BYTE(to_push, 1) & 0x1U; + bool set_or_resume = GET_BYTE(to_push, 3) & 0x30U; if (cancel) { controls_allowed = 0; } @@ -36,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 = to_push->RDLR & 0x20; - if (brake && (!(ford_brake_prev) || ford_is_moving)) { + brake_pressed = GET_BYTE(to_push, 0) & 0x20U; + 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 = to_push->RDLR & 0xFF03; - if (gas && !(ford_gas_prev)) { + gas_pressed = ((GET_BYTE(to_push, 0) & 0x03U) | GET_BYTE(to_push, 1)) != 0U; + 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 @@ -59,20 +65,25 @@ static void ford_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // else // block all commands that produce actuation -static int ford_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int ford_tx_hook(CANPacket_t *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_is_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); // STEER: safety check if (addr == 0x3CA) { if (!current_controls_allowed) { // bits 7-4 need to be 0xF to disallow lkas commands - if (((to_send->RDLR >> 4) & 0xF) != 0xF) { + if ((GET_BYTE(to_send, 0) & 0xF0U) != 0xF0U) { tx = 0; } } @@ -81,7 +92,7 @@ static int ford_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // FORCE CANCEL: safety check only relevant when spamming the cancel button // ensuring that set and resume aren't sent if (addr == 0x83) { - if (((to_send->RDLR >> 28) & 0x3) != 0) { + if ((GET_BYTE(to_send, 3) & 0x30U) != 0U) { tx = 0; } } @@ -90,11 +101,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 949f5c7e73f09f..9a9fef611ea3fd 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_addr_checks[] = { + {.msg = {{388, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, + {.msg = {{842, 0, 5, .expected_timestep = 100000U}, { 0 }, { 0 }}}, + {.msg = {{481, 0, 7, .expected_timestep = 100000U}, { 0 }, { 0 }}}, + {.msg = {{241, 0, 6, .expected_timestep = 100000U}, { 0 }, { 0 }}}, + {.msg = {{417, 0, 7, .expected_timestep = 100000U}, { 0 }, { 0 }}}, +}; +#define GM_RX_CHECK_LEN (sizeof(gm_addr_checks) / sizeof(gm_addr_checks[0])) +addr_checks gm_rx_checks = {gm_addr_checks, GM_RX_CHECK_LEN}; -int gm_brake_prev = 0; -int gm_gas_prev = 0; -int gm_speed = 0; -// 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 = (((to_push->RDHR >> 16) & 0x7) << 8) | ((to_push->RDHR >> 24) & 0xFF); - 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(CANPacket_t *to_push) { - if ((addr == 0x1F1) && (bus_number == 0)) { - //Bit 5 should be ignition "on" - //Backup plan is Bit 2 (accessory power) - bool ign = ((to_push->RDLR) & 0x20) != 0; - gm_ignition_started = ign; - } + bool valid = addr_safety_check(to_push, &gm_rx_checks, NULL, NULL, NULL); - // sample speed, really only care if car is moving or not - // rear left wheel speed - if (addr == 842) { - gm_speed = to_push->RDLR & 0xFFFF; - } + if (valid && (GET_BUS(to_push) == 0U)) { + 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) & 0x7U) << 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 = (to_push->RDHR >> 12) & 0x7; - 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 = (to_push->RDLR & 0xFF00) >> 8; - // 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) & 0x70U) >> 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_speed)) { - 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) >= 10U; } - gm_brake_prev = brake; - } - // exit controls on rising edge of gas press - if (addr == 417) { - int gas = to_push->RDHR & 0xFF0000; - if (gas && !gm_gas_prev && long_controls_allowed) { - controls_allowed = 0; + if (addr == 417) { + gas_pressed = GET_BYTE(to_push, 6) != 0U; } - gm_gas_prev = gas; - } - // exit controls on regen paddle - if (addr == 189) { - bool regen = to_push->RDLR & 0x20; - if (regen) { - controls_allowed = 0; + // exit controls on regen paddle + if (addr == 189) { + bool regen = GET_BYTE(to_push, 0) & 0x20U; + 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 @@ -118,28 +104,29 @@ static void gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // else // block all commands that produce actuation -static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int gm_tx_hook(CANPacket_t *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; } // 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_speed); + 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) { - uint32_t rdlr = to_send->RDLR; - int brake = ((rdlr & 0xFU) << 8) + ((rdlr & 0xFF00U) >> 8); + 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; } @@ -151,9 +138,8 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // LKA STEER: safety check if (addr == 384) { - uint32_t rdlr = to_send->RDLR; - int desired_torque = ((rdlr & 0x7U) << 8) + ((rdlr & 0xFF00U) >> 8); - uint32_t ts = TIM2->CNT; + int desired_torque = ((GET_BYTE(to_send, 0) & 0x7U) << 8) + GET_BYTE(to_send, 1); + uint32_t ts = microsecond_timer_get(); bool violation = 0; desired_torque = to_signed(desired_torque, 11); @@ -163,21 +149,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; } } @@ -188,9 +174,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) { @@ -198,19 +184,13 @@ 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) { - uint32_t rdlr = to_send->RDLR; - int gas_regen = ((rdlr & 0x7F0000U) >> 11) + ((rdlr & 0xF8000000U) >> 27); - // Disabled message is !engaed with gas + int gas_regen = ((GET_BYTE(to_send, 2) & 0x7FU) << 5) + ((GET_BYTE(to_send, 3) & 0xF8U) >> 3); + // Disabled message is !engaged with gas // value that corresponds to max regen. - if (!current_controls_allowed || !long_controls_allowed) { - bool apply = (rdlr & 1U) != 0U; + if (!current_controls_allowed) { + bool apply = GET_BYTE(to_send, 0) & 1U; if (apply || (gas_regen != GM_MAX_REGEN)) { tx = 0; } @@ -224,14 +204,11 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return tx; } -static void gm_init(int16_t param) { +static const addr_checks* gm_init(int16_t param) { UNUSED(param); - controls_allowed = 0; - gm_ignition_started = 0; -} - -static int gm_ign_hook(void) { - return gm_ignition_started; + controls_allowed = false; + relay_malfunction_reset(); + return &gm_rx_checks; } const safety_hooks gm_hooks = { @@ -239,6 +216,5 @@ const safety_hooks gm_hooks = { .rx = gm_rx_hook, .tx = gm_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = gm_ign_hook, .fwd = default_fwd_hook, }; diff --git a/panda/board/safety/safety_gm_ascm.h b/panda/board/safety/safety_gm_ascm.h deleted file mode 100644 index d452818d69b59d..00000000000000 --- a/panda/board/safety/safety_gm_ascm.h +++ /dev/null @@ -1,45 +0,0 @@ -// BUS 0 is on the LKAS module (ASCM) side -// BUS 2 is on the actuator (EPS) side - -static int gm_ascm_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { - - int bus_fwd = -1; - - if (bus_num == 0) { - int addr = GET_ADDR(to_fwd); - bus_fwd = 2; - // do not propagate lkas messages from ascm to actuators, unless supercruise is on - // block 0x152 and 0x154, which are the lkas command from ASCM1 and ASCM2 - // block 0x315 and 0x2cb, which are the brake and accel commands from ASCM1 - //if ((addr == 0x152) || (addr == 0x154) || (addr == 0x315) || (addr == 0x2cb)) { - if ((addr == 0x152) || (addr == 0x154)) { - int supercruise_on = (to_fwd->RDHR >> 4) & 0x1; // bit 36 - if (!supercruise_on) { - bus_fwd = -1; - } - } - if ((addr == 0x151) || (addr == 0x153) || (addr == 0x314)) { - // on the chassis bus, the OBDII port is on the module side, so we need to read - // the lkas messages sent by openpilot (put on unused 0x151 ane 0x153 addrs) and send it to - // the actuator as 0x152 and 0x154 - uint32_t fwd_addr = addr + 1; - to_fwd->RIR = (fwd_addr << 21) | (to_fwd->RIR & 0x1fffff); - } - } - - if (bus_num == 2) { - bus_fwd = 0; - } - - return bus_fwd; -} - -const safety_hooks gm_ascm_hooks = { - .init = nooutput_init, - .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 44a57ec978ff36..ed19fb8a682bf9 100644 --- a/panda/board/safety/safety_honda.h +++ b/panda/board/safety/safety_honda.h @@ -6,84 +6,201 @@ // 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_BOSCH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}, {0x33DA, 0, 5}, {0x33DB, 0, 8}}; // Bosch +const CanMsg HONDA_BOSCH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x33DA, 1, 5}, {0x33DB, 1, 8}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch 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; -int honda_ego_speed = 0; -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)) / 2U ) / 2U) // 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 has the powertrain bus on bus 0 +AddrCheckStruct honda_nidec_addr_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}, { 0 }}}, + {.msg = {{0x158, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{0x17C, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{0x326, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 100000U}, { 0 }, { 0 }}}, +}; +#define HONDA_NIDEC_ADDR_CHECKS_LEN (sizeof(honda_nidec_addr_checks) / sizeof(honda_nidec_addr_checks[0])) + +// For Nidecs with main on signal on an alternate msg +AddrCheckStruct honda_nidec_alt_addr_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}, { 0 }}}, + {.msg = {{0x158, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{0x17C, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, +}; +#define HONDA_NIDEC_ALT_ADDR_CHECKS_LEN (sizeof(honda_nidec_alt_addr_checks) / sizeof(honda_nidec_alt_addr_checks[0])) + +// Bosch has pt on bus 1 +AddrCheckStruct honda_bosch_addr_checks[] = { + {.msg = {{0x296, 1, 4, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}, { 0 }, { 0 }}}, + {.msg = {{0x158, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{0x17C, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, + {0x1BE, 1, 3, .check_checksum = true, .max_counter = 3U, .expected_timestep = 20000U}, { 0 }}}, + {.msg = {{0x326, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 100000U}, { 0 }, { 0 }}}, +}; +#define HONDA_BOSCH_ADDR_CHECKS_LEN (sizeof(honda_bosch_addr_checks) / sizeof(honda_bosch_addr_checks[0])) + +const uint16_t HONDA_PARAM_ALT_BRAKE = 1; +const uint16_t HONDA_PARAM_BOSCH_LONG = 2; +const uint16_t HONDA_PARAM_NIDEC_ALT = 4; + +int honda_brake = 0; bool honda_alt_brake_msg = false; +bool honda_fwd_brake = false; +bool honda_bosch_long = false; +enum {HONDA_NIDEC, HONDA_BOSCH} honda_hw = HONDA_NIDEC; +addr_checks honda_rx_checks = {honda_nidec_addr_checks, HONDA_NIDEC_ADDR_CHECKS_LEN}; -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(CANPacket_t *to_push) { + int checksum_byte = GET_LEN(to_push) - 1U; + return (uint8_t)(GET_BYTE(to_push, checksum_byte)) & 0xFU; +} - // sample speed - if (addr == 0x158) { - // first 2 bytes - honda_ego_speed = to_push->RDLR & 0xFFFF; +static uint8_t honda_compute_checksum(CANPacket_t *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; } + 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; +} - // state machine to enter and exit controls - // 0x1A6 for the ILX, 0x296 for the Civic Touring - if ((addr == 0x1A6) || (addr == 0x296)) { - int button = (to_push->RDLR & 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 - } - } - - // 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 - #define IS_USER_BRAKE_MSG(addr) (!honda_alt_brake_msg ? ((addr) == 0x17C) : ((addr) == 0x1BE)) - #define USER_BRAKE_VALUE(to_push) (!honda_alt_brake_msg ? ((to_push)->RDHR & 0x200000) : ((to_push)->RDLR & 0x10)) - // exit controls on rising edge of brake press or on brake press when - // speed > 0 - bool is_user_brake_msg = IS_USER_BRAKE_MSG(addr); // needed to enforce type - if (is_user_brake_msg) { - int brake = USER_BRAKE_VALUE(to_push); - if (brake && (!(honda_brake_prev) || honda_ego_speed)) { - controls_allowed = 0; - } - honda_brake_prev = brake; - } - - // 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 = ((to_push->RDLR & 0xFF) << 8) | ((to_push->RDLR & 0xFF00) >> 8); - 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; - } - - // exit controls on rising edge of gas press if no interceptor - if (!gas_interceptor_detected) { - if (addr == 0x17C) { - int gas = to_push->RDLR & 0xFF; - if (gas && !(honda_gas_prev) && long_controls_allowed) { +static uint8_t honda_get_counter(CANPacket_t *to_push) { + int counter_byte = GET_LEN(to_push) - 1U; + return ((uint8_t)(GET_BYTE(to_push, counter_byte)) >> 4U) & 0x3U; +} + +static int honda_rx_hook(CANPacket_t *to_push) { + + bool valid = addr_safety_check(to_push, &honda_rx_checks, + honda_get_checksum, honda_compute_checksum, honda_get_counter); + + 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); + } + + // check ACC main state + // 0x326 for all Bosch and some Nidec, 0x1A6 for some Nidec + if ((addr == 0x326) || (addr == 0x1A6)) { + acc_main_on = GET_BIT(to_push, ((addr == 0x326) ? 28U : 47U)); + if (!acc_main_on) { controls_allowed = 0; } - honda_gas_prev = gas; } + + // state machine to enter and exit controls + // 0x1A6 for the ILX, 0x296 for the Civic Touring + if ((addr == 0x1A6) || (addr == 0x296)) { + // check for button presses + int button = (GET_BYTE(to_push, 0) & 0xE0U) >> 5; + switch (button) { + case 1: // main + case 2: // cancel + controls_allowed = 0; + break; + case 3: // set + case 4: // resume + if (acc_main_on) { + controls_allowed = 1; + } + break; + default: + break; // any other button is irrelevant + } + } + + // 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) & 0x10U) : (GET_BYTE((to_push), 6) & 0x20U); + } + + // 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) != 0U; + } + } + + // 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) & 0x20U; + int honda_stock_brake = (GET_BYTE(to_push, 0) << 2) + ((GET_BYTE(to_push, 1) >> 6) & 0x3U); + + // 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 + } + } + } + + bool stock_ecu_detected = false; + int bus_rdr_car = (honda_hw == HONDA_BOSCH) ? 0 : 2; // radar bus, car side + int pt_bus = (honda_hw == HONDA_BOSCH) ? 1 : 0; + + if (safety_mode_cnt > RELAY_TRNS_TIMEOUT) { + // If steering controls messages are received on the destination bus, it's an indication + // that the relay might be malfunctioning + if ((addr == 0xE4) || (addr == 0x194)) { + if (((honda_hw != HONDA_NIDEC) && (bus == bus_rdr_car)) || ((honda_hw == HONDA_NIDEC) && (bus == 0))) { + stock_ecu_detected = true; + } + } + // If Honda Bosch longitudinal mode is selected we need to ensure the radar is turned off + // Verify this by ensuring ACC_CONTROL (0x1DF) is not received on the PT bus + if (honda_bosch_long && (bus == pt_bus) && (addr == 0x1DF)) { + stock_ecu_detected = true; + } + } + + generic_rx_checks(stock_ecu_detected); } + return valid; } // all commands: gas, brake and steering @@ -92,26 +209,67 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // else // block all commands that produce actuation -static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int honda_tx_hook(CANPacket_t *to_send) { int tx = 1; int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); + if ((honda_hw == HONDA_BOSCH) && !honda_bosch_long) { + tx = msg_allowed(to_send, HONDA_BOSCH_TX_MSGS, sizeof(HONDA_BOSCH_TX_MSGS)/sizeof(HONDA_BOSCH_TX_MSGS[0])); + } else if ((honda_hw == HONDA_BOSCH) && honda_bosch_long) { + tx = msg_allowed(to_send, HONDA_BOSCH_LONG_TX_MSGS, sizeof(HONDA_BOSCH_LONG_TX_MSGS)/sizeof(HONDA_BOSCH_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])); + } + // 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_ego_speed); + 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_BOSCH) ? 1 : 0; - // BRAKE: safety check - if (addr == 0x1FA) { - if (!current_controls_allowed || !long_controls_allowed) { - if ((to_send->RDLR & 0xFFFF0000) != to_send->RDLR) { + // BRAKE: safety check (nidec) + if ((addr == 0x1FA) && (bus == bus_pt)) { + honda_brake = (GET_BYTE(to_send, 0) << 2) + ((GET_BYTE(to_send, 1) >> 6) & 0x3U); + if (!current_controls_allowed) { + if (honda_brake != 0) { + tx = 0; + } + } + if (honda_brake > 255) { + tx = 0; + } + if (honda_fwd_brake) { + tx = 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) & 0x7U); + accel = to_signed(accel, 11); + if (!current_controls_allowed) { + if (accel != 0) { + tx = 0; + } + } + 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 ((to_send->RDLR & 0xFFFFFF3F) != to_send->RDLR) { + if (gas > HONDA_BOSCH_GAS_MAX) { tx = 0; } } @@ -119,16 +277,24 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // STEER: safety check if ((addr == 0xE4) || (addr == 0x194)) { if (!current_controls_allowed) { - if ((to_send->RDLR & 0xFFFF0000) != to_send->RDLR) { + bool steer_applied = GET_BYTE(to_send, 0) | GET_BYTE(to_send, 1); + if (steer_applied) { tx = 0; } } } - // GAS: safety check + // Bosch supplemental control check + if (addr == 0xE5) { + if ((GET_BYTES_04(to_send) != 0x10800004U) || ((GET_BYTES_48(to_send) & 0x00FFFFFFU) != 0x0U)) { + tx = 0; + } + } + + // GAS: safety check (interceptor) if (addr == 0x200) { - if (!current_controls_allowed || !long_controls_allowed) { - if ((to_send->RDLR & 0xFFFF0000) != to_send->RDLR) { + if (!current_controls_allowed) { + if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) { tx = 0; } } @@ -137,9 +303,15 @@ 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 - if ((addr == 0x296) && honda_bosch_hardware && - !current_controls_allowed && (bus == 0)) { - if (((to_send->RDLR >> 5) & 0x7) != 2) { + if ((addr == 0x296) && !current_controls_allowed && (bus == bus_pt)) { + if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) { + tx = 0; + } + } + + // Only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address + if (addr == 0x18DAB0F1) { + if ((GET_BYTES_04(to_send) != 0x00803E02U) || (GET_BYTES_48(to_send) != 0x0U)) { tx = 0; } } @@ -148,66 +320,87 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return tx; } -static void honda_init(int16_t param) { +static const addr_checks* 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_NIDEC; honda_alt_brake_msg = false; + honda_bosch_long = false; + + if (GET_FLAG(param, HONDA_PARAM_NIDEC_ALT)) { + honda_rx_checks = (addr_checks){honda_nidec_alt_addr_checks, HONDA_NIDEC_ALT_ADDR_CHECKS_LEN}; + } else { + honda_rx_checks = (addr_checks){honda_nidec_addr_checks, HONDA_NIDEC_ADDR_CHECKS_LEN}; + } + return &honda_rx_checks; } -static void honda_bosch_init(int16_t param) { - controls_allowed = 0; - honda_bosch_hardware = true; +static const addr_checks* honda_bosch_init(int16_t param) { + controls_allowed = false; + relay_malfunction_reset(); + honda_hw = HONDA_BOSCH; // 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 +#ifdef ALLOW_DEBUG + honda_bosch_long = GET_FLAG(param, HONDA_PARAM_BOSCH_LONG); +#endif + + honda_rx_checks = (addr_checks){honda_bosch_addr_checks, HONDA_BOSCH_ADDR_CHECKS_LEN}; + return &honda_rx_checks; } -static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static int honda_nidec_fwd_hook(int bus_num, CANPacket_t *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); + 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; } -static int honda_bosch_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static int honda_bosch_fwd_hook(int bus_num, CANPacket_t *to_fwd) { int bus_fwd = -1; - if (bus_num == 2) { - bus_fwd = 1; + if (bus_num == 0) { + bus_fwd = 2; } - if (bus_num == 1) { + if (bus_num == 2) { int addr = GET_ADDR(to_fwd); - int is_lkas_msg = (addr == 0xE4) || (addr == 0x33D); + int is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D) || (addr == 0x33DA) || (addr == 0x33DB); if (!is_lkas_msg) { - bus_fwd = 2; + bus_fwd = 0; } } + 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, }; const safety_hooks honda_bosch_hooks = { @@ -215,6 +408,5 @@ const safety_hooks honda_bosch_hooks = { .rx = honda_rx_hook, .tx = honda_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = honda_bosch_fwd_hook, }; diff --git a/panda/board/safety/safety_hyundai.h b/panda/board/safety/safety_hyundai.h index c1b55359bdfe11..883b8c6b203b58 100644 --- a/panda/board/safety/safety_hyundai.h +++ b/panda/board/safety/safety_hyundai.h @@ -1,74 +1,279 @@ -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 -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); +const int HYUNDAI_MAX_ACCEL = 200; // 1/100 m/s2 +const int HYUNDAI_MIN_ACCEL = -350; // 1/100 m/s2 + +const CanMsg HYUNDAI_TX_MSGS[] = { + {832, 0, 8}, // LKAS11 Bus 0 + {1265, 0, 4}, // CLU11 Bus 0 + {1157, 0, 4}, // LFAHDA_MFC Bus 0 + }; + +const CanMsg HYUNDAI_LONG_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, 2}, // FRT_RADAR11 Bus 0 + {909, 0, 8}, // FCA11 Bus 0 + {1155, 0, 8}, // FCA12 Bus 0 + {2000, 0, 8}, // radar UDS TX addr Bus 0 (for radar disable) + }; + +AddrCheckStruct hyundai_addr_checks[] = { + {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, + {881, 0, 8, .expected_timestep = 10000U}, { 0 }}}, + {.msg = {{902, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{916, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, +}; +#define HYUNDAI_ADDR_CHECK_LEN (sizeof(hyundai_addr_checks) / sizeof(hyundai_addr_checks[0])) + +AddrCheckStruct hyundai_long_addr_checks[] = { + {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, + {881, 0, 8, .expected_timestep = 10000U}, { 0 }}}, + {.msg = {{902, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{916, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{1265, 0, 4, .check_checksum = false, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, +}; +#define HYUNDAI_LONG_ADDR_CHECK_LEN (sizeof(hyundai_long_addr_checks) / sizeof(hyundai_long_addr_checks[0])) + +// older hyundai models have less checks due to missing counters and checksums +AddrCheckStruct hyundai_legacy_addr_checks[] = { + {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, + {881, 0, 8, .expected_timestep = 10000U}, { 0 }}}, + {.msg = {{902, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{916, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, +}; +#define HYUNDAI_LEGACY_ADDR_CHECK_LEN (sizeof(hyundai_legacy_addr_checks) / sizeof(hyundai_legacy_addr_checks[0])) + +const int HYUNDAI_PARAM_EV_GAS = 1; +const int HYUNDAI_PARAM_HYBRID_GAS = 2; +const int HYUNDAI_PARAM_LONGITUDINAL = 4; + +bool hyundai_legacy = false; +bool hyundai_ev_gas_signal = false; +bool hyundai_hybrid_gas_signal = false; +bool hyundai_longitudinal = false; + +addr_checks hyundai_rx_checks = {hyundai_addr_checks, HYUNDAI_ADDR_CHECK_LEN}; + +static uint8_t hyundai_get_counter(CANPacket_t *to_push) { int addr = GET_ADDR(to_push); - if (addr == 897) { - int torque_driver_new = ((to_push->RDLR >> 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) & 0x3U; + } 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) & 0x7U; + } else if (addr == 1057) { + cnt = GET_BYTE(to_push, 7) & 0xFU; + } else if (addr == 1265) { + cnt = (GET_BYTE(to_push, 3) >> 4) & 0xFU; + } 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(CANPacket_t *to_push) { + int addr = GET_ADDR(to_push); - // Find out which bus the camera is on - if (addr == 832) { - hyundai_camera_bus = bus; + uint8_t chksum; + if (addr == 608) { + chksum = GET_BYTE(to_push, 7) & 0xFU; + } else if (addr == 902) { + chksum = ((GET_BYTE(to_push, 7) >> 6) << 2) | (GET_BYTE(to_push, 5) >> 6); + } else if (addr == 916) { + chksum = GET_BYTE(to_push, 6) & 0xFU; + } else if (addr == 1057) { + chksum = GET_BYTE(to_push, 7) >> 4; + } else { + chksum = 0; } + return chksum; +} - // enter controls on rising edge of ACC, exit controls on ACC off - if (addr == 1057) { - // 2 bits: 13-14 - int cruise_engaged = (to_push->RDLR >> 13) & 0x3; - if (cruise_engaged && !hyundai_cruise_engaged_last) { - controls_allowed = 1; +static uint8_t hyundai_compute_checksum(CANPacket_t *to_push) { + int addr = GET_ADDR(to_push); + + uint8_t chksum = 0; + if (addr == 902) { + // count the bits + for (int i = 0; i < 8; i++) { + uint8_t b = GET_BYTE(to_push, i); + for (int j = 0; j < 8; j++) { + uint8_t bit = 0; + // exclude checksum and counter + if (((i != 1) || (j < 6)) && ((i != 3) || (j < 6)) && ((i != 5) || (j < 6)) && ((i != 7) || (j < 6))) { + bit = (b >> (uint8_t)j) & 1U; + } + chksum += bit; + } } - if (!cruise_engaged) { - controls_allowed = 0; + chksum = (chksum ^ 9U) & 15U; + } else { + // sum of nibbles + for (int i = 0; i < 8; i++) { + if ((addr == 916) && (i == 7)) { + continue; // exclude + } + 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); } - hyundai_cruise_engaged_last = cruise_engaged; + chksum = (16U - (chksum % 16U)) % 16U; } - // 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; + return chksum; +} + +static int hyundai_rx_hook(CANPacket_t *to_push) { + + bool valid = addr_safety_check(to_push, &hyundai_rx_checks, + hyundai_get_checksum, hyundai_compute_checksum, + hyundai_get_counter); + + if (valid && (GET_BUS(to_push) == 0U)) { + int addr = GET_ADDR(to_push); + + if (addr == 593) { + int torque_driver_new = ((GET_BYTES_04(to_push) & 0x7ffU) * 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 (hyundai_longitudinal) { + // ACC steering wheel buttons + if (addr == 1265) { + int button = GET_BYTE(to_push, 0) & 0x7U; + switch (button) { + case 1: // resume + case 2: // set + controls_allowed = 1; + break; + case 4: // cancel + controls_allowed = 0; + break; + default: + break; // any other button is irrelevant + } + } + } else { + // 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) & 0x3U; + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + } + + // read gas pressed signal + if ((addr == 881) && hyundai_ev_gas_signal) { + gas_pressed = (((GET_BYTE(to_push, 4) & 0x7FU) << 1) | GET_BYTE(to_push, 3) >> 7) != 0U; + } else if ((addr == 881) && hyundai_hybrid_gas_signal) { + gas_pressed = GET_BYTE(to_push, 7) != 0U; + } else if (addr == 608) { // ICE + gas_pressed = (GET_BYTE(to_push, 7) >> 6) != 0U; + } else { + } + + // sample wheel speed, averaging opposite corners + if (addr == 902) { + int hyundai_speed = (GET_BYTES_04(to_push) & 0x3FFFU) + ((GET_BYTES_48(to_push) >> 16) & 0x3FFFU); // FL + RR + hyundai_speed /= 2; + vehicle_moving = hyundai_speed > HYUNDAI_STANDSTILL_THRSLD; + } + + if (addr == 916) { + brake_pressed = (GET_BYTE(to_push, 6) >> 7) != 0U; + } + + bool stock_ecu_detected = (addr == 832); + + // If openpilot is controlling longitudinal we need to ensure the radar is turned off + // Enforce by checking we don't see SCC12 + if (hyundai_longitudinal && (addr == 1057)) { + stock_ecu_detected = true; + } + generic_rx_checks(stock_ecu_detected); } + return valid; } -static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int hyundai_tx_hook(CANPacket_t *to_send) { int tx = 1; int addr = GET_ADDR(to_send); - // There can be only one! (camera) - if (hyundai_camera_detected) { - tx = 0; + if (hyundai_longitudinal) { + tx = msg_allowed(to_send, HYUNDAI_LONG_TX_MSGS, sizeof(HYUNDAI_LONG_TX_MSGS)/sizeof(HYUNDAI_LONG_TX_MSGS[0])); + } else { + tx = msg_allowed(to_send, HYUNDAI_TX_MSGS, sizeof(HYUNDAI_TX_MSGS)/sizeof(HYUNDAI_TX_MSGS[0])); + } + + // FCA11: Block any potential actuation + if (addr == 909) { + int CR_VSM_DecCmd = GET_BYTE(to_send, 1); + int FCA_CmdAct = (GET_BYTE(to_send, 2) >> 5) & 1U; + int CF_VSM_DecCmdAct = (GET_BYTE(to_send, 3) >> 7) & 1U; + + if ((CR_VSM_DecCmd != 0) || (FCA_CmdAct != 0) || (CF_VSM_DecCmdAct != 0)) { + tx = 0; + } + } + + // ACCEL: safety check + if (addr == 1057) { + int desired_accel_raw = (((GET_BYTE(to_send, 4) & 0x7U) << 8) | GET_BYTE(to_send, 3)) - 1023U; + int desired_accel_val = ((GET_BYTE(to_send, 5) << 3) | (GET_BYTE(to_send, 4) >> 5)) - 1023U; + + int aeb_decel_cmd = GET_BYTE(to_send, 2); + int aeb_req = (GET_BYTE(to_send, 6) >> 6) & 1U; + + bool violation = 0; + + if (!controls_allowed) { + if ((desired_accel_raw != 0) || (desired_accel_val != 0)) { + violation = 1; + } + } + violation |= max_limit_check(desired_accel_raw, HYUNDAI_MAX_ACCEL, HYUNDAI_MIN_ACCEL); + violation |= max_limit_check(desired_accel_val, HYUNDAI_MAX_ACCEL, HYUNDAI_MIN_ACCEL); + + violation |= (aeb_decel_cmd != 0); + violation |= (aeb_req != 0); + + if (violation) { + tx = 0; + } } // LKA STEER: safety check if (addr == 832) { - int desired_torque = ((to_send->RDLR >> 16) & 0x7ff) - 1024; - uint32_t ts = TIM2->CNT; + int desired_torque = ((GET_BYTES_04(to_send) >> 16) & 0x7ffU) - 1024U; + uint32_t ts = microsecond_timer_get(); bool violation = 0; if (controls_allowed) { @@ -77,21 +282,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 +307,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) { @@ -112,42 +317,72 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } + // UDS: Only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address + if (addr == 2000) { + if ((GET_BYTES_04(to_send) != 0x00803E02U) || (GET_BYTES_48(to_send) != 0x0U)) { + tx = 0; + } + } + // 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 ((to_send->RDLR & 0x7) != 4) { - // tx = 0; - // } - //} + if ((addr == 1265) && !controls_allowed) { + if ((GET_BYTES_04(to_send) & 0x7U) != 4U) { + tx = 0; + } + } // 1 allows the message through return tx; } -static int hyundai_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static int hyundai_fwd_hook(int bus_num, CANPacket_t *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 (bus_num == 0) { - bus_fwd = hyundai_camera_bus; - } - if (bus_num == hyundai_camera_bus) { - int addr = GET_ADDR(to_fwd); - if (addr != 832) { - bus_fwd = 0; - } - } + if (bus_num == 0) { + bus_fwd = 2; } + if ((bus_num == 2) && (addr != 832) && (addr != 1157)) { + bus_fwd = 0; + } + return bus_fwd; } -static void hyundai_init(int16_t param) { - UNUSED(param); - controls_allowed = 0; - hyundai_giraffe_switch_2 = 0; +static const addr_checks* hyundai_init(int16_t param) { + controls_allowed = false; + relay_malfunction_reset(); + + hyundai_legacy = false; + hyundai_ev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_EV_GAS); + hyundai_hybrid_gas_signal = !hyundai_ev_gas_signal && GET_FLAG(param, HYUNDAI_PARAM_HYBRID_GAS); + +#ifdef ALLOW_DEBUG + hyundai_longitudinal = GET_FLAG(param, HYUNDAI_PARAM_LONGITUDINAL); +#endif + + if (hyundai_longitudinal) { + hyundai_rx_checks = (addr_checks){hyundai_long_addr_checks, HYUNDAI_LONG_ADDR_CHECK_LEN}; + } else { + hyundai_rx_checks = (addr_checks){hyundai_addr_checks, HYUNDAI_ADDR_CHECK_LEN}; + } + return &hyundai_rx_checks; +} + +static const addr_checks* hyundai_legacy_init(int16_t param) { + controls_allowed = false; + relay_malfunction_reset(); + + hyundai_legacy = true; + hyundai_longitudinal = false; + hyundai_ev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_EV_GAS); + hyundai_hybrid_gas_signal = !hyundai_ev_gas_signal && GET_FLAG(param, HYUNDAI_PARAM_HYBRID_GAS); + hyundai_rx_checks = (addr_checks){hyundai_legacy_addr_checks, HYUNDAI_LEGACY_ADDR_CHECK_LEN}; + return &hyundai_rx_checks; } const safety_hooks hyundai_hooks = { @@ -155,6 +390,13 @@ 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, +}; + +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, }; diff --git a/panda/board/safety/safety_mazda.h b/panda/board/safety/safety_mazda.h new file mode 100644 index 00000000000000..48632f83017da2 --- /dev/null +++ b/panda/board/safety/safety_mazda.h @@ -0,0 +1,187 @@ +// CAN msgs we care about +#define MAZDA_LKAS 0x243 +#define MAZDA_LKAS_HUD 0x440 +#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 2048U + +// 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 + +const CanMsg MAZDA_TX_MSGS[] = {{MAZDA_LKAS, 0, 8}, {MAZDA_CRZ_BTNS, 0, 8}, {MAZDA_LKAS_HUD, 0, 8}}; + +AddrCheckStruct mazda_addr_checks[] = { + {.msg = {{MAZDA_CRZ_CTRL, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{MAZDA_CRZ_BTNS, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, + {.msg = {{MAZDA_STEER_TORQUE, 0, 8, .expected_timestep = 12000U}, { 0 }, { 0 }}}, + {.msg = {{MAZDA_ENGINE_DATA, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{MAZDA_PEDALS, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, +}; +#define MAZDA_ADDR_CHECKS_LEN (sizeof(mazda_addr_checks) / sizeof(mazda_addr_checks[0])) +addr_checks mazda_rx_checks = {mazda_addr_checks, MAZDA_ADDR_CHECKS_LEN}; + +// track msgs coming from OP so that we know what CAM msgs to drop and what to forward +static int mazda_rx_hook(CANPacket_t *to_push) { + bool valid = addr_safety_check(to_push, &mazda_rx_checks, NULL, NULL, NULL); + if (valid && ((int)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 + } + + if (addr == MAZDA_STEER_TORQUE) { + int torque_driver_new = GET_BYTE(to_push, 0) - 127U; + // 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) & 0x8U; + if (cruise_engaged) { + if (!cruise_engaged_prev) { + controls_allowed = 1; + } + } 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) & 0xF0U)); + } + + if (addr == MAZDA_PEDALS) { + brake_pressed = (GET_BYTE(to_push, 0) & 0x10U); + } + + generic_rx_checks((addr == MAZDA_LKAS)); + } + return valid; +} + +static int mazda_tx_hook(CANPacket_t *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; + } + + // 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) & 0x0FU) << 8) | GET_BYTE(to_send, 1)) - MAZDA_MAX_STEER; + bool violation = 0; + uint32_t ts = microsecond_timer_get(); + + 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; + } + } + + // cruise buttons check + if (addr == MAZDA_CRZ_BTNS) { + // allow resume spamming while controls allowed, but + // only allow cancel while contrls not allowed + bool cancel_cmd = (GET_BYTE(to_send, 0) == 0x1U); + if (!controls_allowed && !cancel_cmd) { + tx = 0; + } + } + } + + return tx; +} + +static int mazda_fwd_hook(int bus, CANPacket_t *to_fwd) { + int bus_fwd = -1; + int addr = GET_ADDR(to_fwd); + + if (bus == MAZDA_MAIN) { + bus_fwd = MAZDA_CAM; + } else if (bus == MAZDA_CAM) { + bool block = (addr == MAZDA_LKAS) || (addr == MAZDA_LKAS_HUD); + if (!block) { + bus_fwd = MAZDA_MAIN; + } + } else { + // don't fwd + } + + return bus_fwd; +} + +static const addr_checks* mazda_init(int16_t param) { + UNUSED(param); + controls_allowed = false; + relay_malfunction_reset(); + return &mazda_rx_checks; +} + +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, +}; diff --git a/panda/board/safety/safety_nissan.h b/panda/board/safety/safety_nissan.h new file mode 100644 index 00000000000000..920a11a2294a4f --- /dev/null +++ b/panda/board/safety/safety_nissan.h @@ -0,0 +1,204 @@ + +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}, // LKAS + {0x2b1, 0, 8}, // PROPILOT_HUD + {0x4cc, 0, 8}, // PROPILOT_HUD_INFO_MSG + {0x20b, 2, 6}, // CRUISE_THROTTLE (X-Trail) + {0x20b, 1, 6}, // CRUISE_THROTTLE (Altima) + {0x280, 2, 8} // CANCEL_MSG (Leaf) +}; + +// Signals duplicated below due to the fact that these messages can come in on either CAN bus, depending on car model. +AddrCheckStruct nissan_addr_checks[] = { + {.msg = {{0x2, 0, 5, .expected_timestep = 10000U}, + {0x2, 1, 5, .expected_timestep = 10000U}, { 0 }}}, // STEER_ANGLE_SENSOR (100Hz) + {.msg = {{0x285, 0, 8, .expected_timestep = 20000U}, + {0x285, 1, 8, .expected_timestep = 20000U}, { 0 }}}, // WHEEL_SPEEDS_REAR (50Hz) + {.msg = {{0x30f, 2, 3, .expected_timestep = 100000U}, + {0x30f, 1, 3, .expected_timestep = 100000U}, { 0 }}}, // 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) +}; +#define NISSAN_ADDR_CHECK_LEN (sizeof(nissan_addr_checks) / sizeof(nissan_addr_checks[0])) +addr_checks nissan_rx_checks = {nissan_addr_checks, NISSAN_ADDR_CHECK_LEN}; + +// EPS Location. false = V-CAN, true = C-CAN +bool nissan_alt_eps = false; + +static int nissan_rx_hook(CANPacket_t *to_push) { + + bool valid = addr_safety_check(to_push, &nissan_rx_checks, 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) & 0xFFFFU); + // 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) & 0x3U)) > 3U; + } else { + gas_pressed = GET_BYTE(to_push, 0) > 3U; + } + } + } + + // X-trail 0x454, Leaf 0x239 + if ((addr == 0x454) || (addr == 0x239)) { + if (addr == 0x454){ + brake_pressed = (GET_BYTE(to_push, 2) & 0x80U) != 0U; + } else { + brake_pressed = ((GET_BYTE(to_push, 4) >> 5) & 1U) != 0U; + } + } + + // 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) & 1U; + + 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(CANPacket_t *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; + } + + // 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) & 0x3U)); + bool lka_active = (GET_BYTE(to_send, 6) >> 4) & 1U; + + // 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) & 0x3dU) > 0U); + } + + if (violation) { + controls_allowed = 0; + tx = 0; + } + + return tx; +} + + +static int nissan_fwd_hook(int bus_num, CANPacket_t *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 + } + } + + return bus_fwd; +} + +static const addr_checks* nissan_init(int16_t param) { + controls_allowed = 0; + nissan_alt_eps = param ? 1 : 0; + relay_malfunction_reset(); + return &nissan_rx_checks; +} + +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, +}; diff --git a/panda/board/safety/safety_subaru.h b/panda/board/safety/safety_subaru.h index c7a8c20e52c963..6028034380fb77 100644 --- a/panda/board/safety/safety_subaru.h +++ b/panda/board/safety/safety_subaru.h @@ -7,48 +7,160 @@ 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}}; +#define 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_addr_checks[] = { + {.msg = {{ 0x40, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{0x119, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{0x13a, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{0x13c, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{0x240, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 50000U}, { 0 }, { 0 }}}, +}; +#define SUBARU_ADDR_CHECK_LEN (sizeof(subaru_addr_checks) / sizeof(subaru_addr_checks[0])) +addr_checks subaru_rx_checks = {subaru_addr_checks, SUBARU_ADDR_CHECK_LEN}; + +const CanMsg SUBARU_L_TX_MSGS[] = {{0x161, 0, 8}, {0x164, 0, 8}}; +#define 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_addr_checks[] = { + {.msg = {{0x140, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{0x371, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{0x144, 0, 8, .expected_timestep = 50000U}, { 0 }, { 0 }}}, +}; +#define SUBARU_L_ADDR_CHECK_LEN (sizeof(subaru_l_addr_checks) / sizeof(subaru_l_addr_checks[0])) +addr_checks subaru_l_rx_checks = {subaru_l_addr_checks, SUBARU_L_ADDR_CHECK_LEN}; + +static uint8_t subaru_get_checksum(CANPacket_t *to_push) { + return (uint8_t)GET_BYTE(to_push, 0); +} + +static uint8_t subaru_get_counter(CANPacket_t *to_push) { + return (uint8_t)(GET_BYTE(to_push, 1) & 0xFU); +} + +static uint8_t subaru_compute_checksum(CANPacket_t *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 = ((to_push->RDLR >> 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(CANPacket_t *to_push) { + + bool valid = addr_safety_check(to_push, &subaru_rx_checks, + subaru_get_checksum, subaru_compute_checksum, subaru_get_counter); + + if (valid && (GET_BUS(to_push) == 0U)) { + int addr = GET_ADDR(to_push); + if (addr == 0x119) { + int torque_driver_new; + torque_driver_new = ((GET_BYTES_04(to_push) >> 16) & 0x7FFU); + 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) & 1U); + 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) & 0x1FFFU) + ((GET_BYTES_48(to_push) >> 6) & 0x1FFFU); // FR + RL + subaru_speed /= 2; + vehicle_moving = subaru_speed > SUBARU_STANDSTILL_THRSLD; + } + + if (addr == 0x13c) { + brake_pressed = ((GET_BYTE(to_push, 7) >> 6) & 1U); + } + + if (addr == 0x40) { + gas_pressed = GET_BYTE(to_push, 4) != 0U; + } + + generic_rx_checks((addr == 0x122)); } + return valid; +} + +static int subaru_legacy_rx_hook(CANPacket_t *to_push) { - // enter controls on rising edge of ACC, exit controls on ACC off - if ((addr == 0x240) && (bus == 0)) { - int cruise_engaged = (to_push->RDHR >> 9) & 1; - if (cruise_engaged && !subaru_cruise_engaged_last) { - controls_allowed = 1; + bool valid = addr_safety_check(to_push, &subaru_l_rx_checks, NULL, NULL, NULL); + + if (valid && (GET_BUS(to_push) == 0U)) { + 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) & 1U); + 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) & 0xFFFFU) + (GET_BYTES_48(to_push) & 0xFFFFU); // FR + 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) & 0xFFU) > 0U; + } + + if (addr == 0x140) { + gas_pressed = GET_BYTE(to_push, 0) != 0U; } - subaru_cruise_engaged_last = cruise_engaged; + + generic_rx_checks((addr == 0x164)); } + return valid; } -static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { +static int subaru_tx_hook(CANPacket_t *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; + } + // steer cmd checks if (addr == 0x122) { - int desired_torque = ((to_send->RDLR >> 16) & 0x1FFF); + int desired_torque = ((GET_BYTES_04(to_send) >> 16) & 0x1FFFU); bool violation = 0; - uint32_t ts = TIM2->CNT; - desired_torque = to_signed(desired_torque, 13); + uint32_t ts = microsecond_timer_get(); + + desired_torque = -1 * to_signed(desired_torque, 13); if (controls_allowed) { @@ -56,22 +168,81 @@ 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, 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_legacy_tx_hook(CANPacket_t *to_send) { + int tx = 1; + int addr = GET_ADDR(to_send); + + if (!msg_allowed(to_send, SUBARU_L_TX_MSGS, SUBARU_L_TX_MSGS_LEN)) { + tx = 0; + } + + // steer cmd checks + if (addr == 0x164) { + int desired_torque = ((GET_BYTES_04(to_send) >> 8) & 0x1FFFU); + bool violation = 0; + uint32_t ts = microsecond_timer_get(); + + 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, 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 +253,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,33 +266,75 @@ 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_fwd_hook(int bus_num, CANPacket_t *to_fwd) { + int bus_fwd = -1; + + 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 + } + } + + return bus_fwd; +} + +static int subaru_legacy_fwd_hook(int bus_num, CANPacket_t *to_fwd) { int bus_fwd = -1; + if (bus_num == 0) { bus_fwd = 2; // Camera CAN } + if (bus_num == 2) { - // 356 is LKAS for outback 2015 - // 356 is LKAS for Global Platform - // 545 is ES_Distance - // 802 is ES_LKAS + // Preglobal platform + // 0x161 is ES_CruiseThrottle + // 0x164 is ES_LKAS int addr = GET_ADDR(to_fwd); - int block_msg = (addr == 290) || (addr == 356) || (addr == 545) || (addr == 802); + int block_msg = ((addr == 0x161) || (addr == 0x164)); if (!block_msg) { bus_fwd = 0; // Main CAN } } - // fallback to do not forward return bus_fwd; } +static const addr_checks* subaru_init(int16_t param) { + UNUSED(param); + controls_allowed = false; + relay_malfunction_reset(); + return &subaru_rx_checks; +} + const safety_hooks subaru_hooks = { - .init = nooutput_init, + .init = subaru_init, .rx = subaru_rx_hook, .tx = subaru_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, .fwd = subaru_fwd_hook, }; + +static const addr_checks* subaru_legacy_init(int16_t param) { + UNUSED(param); + controls_allowed = false; + relay_malfunction_reset(); + return &subaru_l_rx_checks; +} + +const safety_hooks subaru_legacy_hooks = { + .init = subaru_legacy_init, + .rx = subaru_legacy_rx_hook, + .tx = subaru_legacy_tx_hook, + .tx_lin = nooutput_tx_lin_hook, + .fwd = subaru_legacy_fwd_hook, +}; diff --git a/panda/board/safety/safety_tesla.h b/panda/board/safety/safety_tesla.h index b58e6b2bbf7ad4..ccbff7d60a1b6f 100644 --- a/panda/board/safety/safety_tesla.h +++ b/panda/board/safety/safety_tesla.h @@ -1,18 +1,3 @@ -// board enforces -// in-state -// accel set/resume -// out-state -// cancel button -// regen paddle -// accel rising edge -// brake rising edge -// brake > 0mph -// -bool fmax_limit_check(float val, const float MAX_VAL, const float MIN_VAL) { - return (val > MAX_VAL) || (val < MIN_VAL); -} - -// 2m/s are added to be less restrictive const struct lookup_t TESLA_LOOKUP_ANGLE_RATE_UP = { {2., 7., 17.}, {5., .8, .25}}; @@ -21,209 +6,248 @@ const struct lookup_t TESLA_LOOKUP_ANGLE_RATE_DOWN = { {2., 7., 17.}, {5., 3.5, .8}}; -const struct lookup_t TESLA_LOOKUP_MAX_ANGLE = { - {2., 29., 38.}, - {410., 92., 36.}}; +const int TESLA_DEG_TO_CAN = 10; +const float TESLA_MAX_ACCEL = 2.0; // m/s^2 +const float TESLA_MIN_ACCEL = -3.5; // m/s^2 -const uint32_t TESLA_RT_INTERVAL = 250000; // 250ms between real time checks +const int TESLA_FLAG_POWERTRAIN = 1; +const int TESLA_FLAG_LONGITUDINAL_CONTROL = 2; -// state of angle limits -float tesla_desired_angle_last = 0; // last desired steer angle -float tesla_rt_angle_last = 0.; // last real time angle -float tesla_ts_angle_last = 0; +const CanMsg TESLA_TX_MSGS[] = { + {0x488, 0, 4}, // DAS_steeringControl + {0x45, 0, 8}, // STW_ACTN_RQ + {0x45, 2, 8}, // STW_ACTN_RQ + {0x2b9, 0, 8}, // DAS_control +}; +#define TESLA_TX_LEN (sizeof(TESLA_TX_MSGS) / sizeof(TESLA_TX_MSGS[0])) -int tesla_controls_allowed_last = 0; +const CanMsg TESLA_PT_TX_MSGS[] = { + {0x2bf, 0, 8}, // DAS_control +}; +#define TESLA_PT_TX_LEN (sizeof(TESLA_PT_TX_MSGS) / sizeof(TESLA_PT_TX_MSGS[0])) + +AddrCheckStruct tesla_addr_checks[] = { + {.msg = {{0x370, 0, 8, .expected_timestep = 40000U}, { 0 }, { 0 }}}, // EPAS_sysStatus (25Hz) + {.msg = {{0x108, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, // DI_torque1 (100Hz) + {.msg = {{0x118, 0, 6, .expected_timestep = 10000U}, { 0 }, { 0 }}}, // DI_torque2 (100Hz) + {.msg = {{0x20a, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, // BrakeMessage (50Hz) + {.msg = {{0x368, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, // DI_state (10Hz) + {.msg = {{0x318, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, // GTW_carState (10Hz) +}; +#define TESLA_ADDR_CHECK_LEN (sizeof(tesla_addr_checks) / sizeof(tesla_addr_checks[0])) +addr_checks tesla_rx_checks = {tesla_addr_checks, TESLA_ADDR_CHECK_LEN}; + +AddrCheckStruct tesla_pt_addr_checks[] = { + {.msg = {{0x106, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, // DI_torque1 (100Hz) + {.msg = {{0x116, 0, 6, .expected_timestep = 10000U}, { 0 }, { 0 }}}, // DI_torque2 (100Hz) + {.msg = {{0x1f8, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, // BrakeMessage (50Hz) + {.msg = {{0x256, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, // DI_state (10Hz) +}; +#define TESLA_PT_ADDR_CHECK_LEN (sizeof(tesla_pt_addr_checks) / sizeof(tesla_pt_addr_checks[0])) +addr_checks tesla_pt_rx_checks = {tesla_pt_addr_checks, TESLA_PT_ADDR_CHECK_LEN}; + +bool tesla_longitudinal = false; +bool tesla_powertrain = false; // Are we the second panda intercepting the powertrain bus? + +static int tesla_rx_hook(CANPacket_t *to_push) { + bool valid = addr_safety_check(to_push, tesla_powertrain ? (&tesla_pt_rx_checks) : (&tesla_rx_checks), + NULL, NULL, NULL); + + if(valid) { + int bus = GET_BUS(to_push); + int addr = GET_ADDR(to_push); + + if(bus == 0) { + if (!tesla_powertrain) { + if(addr == 0x370) { + // Steering angle: (0.1 * val) - 819.2 in deg. + // Store it 1/10 deg to match steering request + int angle_meas_new = (((GET_BYTE(to_push, 4) & 0x3FU) << 8) | GET_BYTE(to_push, 5)) - 8192U; + update_sample(&angle_meas, angle_meas_new); + } + } -int tesla_brake_prev = 0; -int tesla_gas_prev = 0; -int tesla_speed = 0; -int eac_status = 0; + if(addr == (tesla_powertrain ? 0x116 : 0x118)) { + // Vehicle speed: ((0.05 * val) - 25) * MPH_TO_MPS + vehicle_speed = (((((GET_BYTE(to_push, 3) & 0x0FU) << 8) | (GET_BYTE(to_push, 2))) * 0.05) - 25) * 0.447; + vehicle_moving = ABS(vehicle_speed) > 0.1; + } -int tesla_ignition_started = 0; + if(addr == (tesla_powertrain ? 0x106 : 0x108)) { + // Gas pressed + gas_pressed = (GET_BYTE(to_push, 6) != 0U); + } + if(addr == (tesla_powertrain ? 0x1f8 : 0x20a)) { + // Brake pressed + brake_pressed = (((GET_BYTE(to_push, 0) & 0x0CU) >> 2) != 1U); + } -void set_gmlan_digital_output(int to_set); -void reset_gmlan_switch_timeout(void); -void gmlan_switch_init(int timeout_enable); + if(addr == (tesla_powertrain ? 0x256 : 0x368)) { + // Cruise state + int cruise_state = (GET_BYTE(to_push, 1) >> 4); + bool cruise_engaged = (cruise_state == 2) || // ENABLED + (cruise_state == 3) || // STANDSTILL + (cruise_state == 4) || // OVERRIDE + (cruise_state == 6) || // PRE_FAULT + (cruise_state == 7); // PRE_CANCEL + + if(cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if(!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + } + if (tesla_powertrain) { + // 0x2bf: DAS_control should not be received on bus 0 + generic_rx_checks((addr == 0x2bf) && (bus == 0)); + } else { + // 0x488: DAS_steeringControl should not be received on bus 0 + generic_rx_checks((addr == 0x488) && (bus == 0)); + } + } -static void tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { - set_gmlan_digital_output(0); // #define GMLAN_HIGH 0 - reset_gmlan_switch_timeout(); //we're still in tesla safety mode, reset the timeout counter and make sure our output is enabled + return valid; +} - int addr = GET_ADDR(to_push); - if (addr == 0x45) { - // 6 bits starting at position 0 - int lever_position = (to_push->RDLR & 0x3F); - if (lever_position == 2) { // pull forward - // activate openpilot - controls_allowed = 1; - } - if (lever_position == 1) { // push towards the back - // deactivate openpilot - controls_allowed = 0; - } - } +static int tesla_tx_hook(CANPacket_t *to_send) { + int tx = 1; + int addr = GET_ADDR(to_send); + bool violation = false; - // Detect drive rail on (ignition) (start recording) - if (addr == 0x348) { - // GTW_status - int drive_rail_on = (to_push->RDLR & 0x0001); - tesla_ignition_started = drive_rail_on == 1; + if(!msg_allowed(to_send, + tesla_powertrain ? TESLA_PT_TX_MSGS : TESLA_TX_MSGS, + tesla_powertrain ? TESLA_PT_TX_LEN : TESLA_TX_LEN)) { + tx = 0; } - // exit controls on brake press - // DI_torque2::DI_brakePedal 0x118 - if (addr == 0x118) { - // 1 bit at position 16 - if ((((to_push->RDLR & 0x8000)) >> 15) == 1) { - // disable break cancel by commenting line below - controls_allowed = 0; + if(!tesla_powertrain && (addr == 0x488)) { + // Steering control: (0.1 * val) - 1638.35 in deg. + // We use 1/10 deg as a unit here + int raw_angle_can = (((GET_BYTE(to_send, 0) & 0x7FU) << 8) | GET_BYTE(to_send, 1)); + int desired_angle = raw_angle_can - 16384; + int steer_control_type = GET_BYTE(to_send, 2) >> 6; + bool steer_control_enabled = (steer_control_type != 0) && // NONE + (steer_control_type != 3); // DISABLED + + // Rate limit while steering + if(controls_allowed && steer_control_enabled) { + // Add 1 to not false trigger the violation + float delta_angle_float; + delta_angle_float = (interpolate(TESLA_LOOKUP_ANGLE_RATE_UP, vehicle_speed) * TESLA_DEG_TO_CAN); + int delta_angle_up = (int)(delta_angle_float) + 1; + delta_angle_float = (interpolate(TESLA_LOOKUP_ANGLE_RATE_DOWN, vehicle_speed) * TESLA_DEG_TO_CAN); + int delta_angle_down = (int)(delta_angle_float) + 1; + 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); } - //get vehicle speed in m/s. Tesla gives MPH - tesla_speed = ((((((to_push->RDLR >> 24) & 0xF) << 8) + ((to_push->RDLR >> 16) & 0xFF)) * 0.05) - 25) * 1.609 / 3.6; - if (tesla_speed < 0) { - tesla_speed = 0; + desired_angle_last = desired_angle; + + // Angle should be the same as current angle while not steering + if(!controls_allowed && ((desired_angle < (angle_meas.min - 1)) || (desired_angle > (angle_meas.max + 1)))) { + violation = true; } - } - // exit controls on EPAS error - // EPAS_sysStatus::EPAS_eacStatus 0x370 - if (addr == 0x370) { - // if EPAS_eacStatus is not 1 or 2, disable control - eac_status = ((to_push->RDHR >> 21)) & 0x7; - // For human steering override we must not disable controls when eac_status == 0 - // Additional safety: we could only allow eac_status == 0 when we have human steering allowed - if (controls_allowed && (eac_status != 0) && (eac_status != 1) && (eac_status != 2)) { - controls_allowed = 0; - //puts("EPAS error! \n"); + // No angle control allowed when controls are not allowed + if(!controls_allowed && steer_control_enabled) { + violation = true; } } - //get latest steering wheel angle - if (addr == 0x00E) { - float angle_meas_now = (int)(((((to_push->RDLR & 0x3F) << 8) + ((to_push->RDLR >> 8) & 0xFF)) * 0.1) - 819.2); - uint32_t ts = TIM2->CNT; - uint32_t ts_elapsed = get_ts_elapsed(ts, tesla_ts_angle_last); - - // *** angle real time check - // add 1 to not false trigger the violation and multiply by 25 since the check is done every 250 ms and steer angle is updated at 100Hz - float rt_delta_angle_up = (interpolate(TESLA_LOOKUP_ANGLE_RATE_UP, tesla_speed) * 25.) + 1.; - float rt_delta_angle_down = (interpolate(TESLA_LOOKUP_ANGLE_RATE_DOWN, tesla_speed) * 25.) + 1.; - float highest_rt_angle = tesla_rt_angle_last + ((tesla_rt_angle_last > 0.) ? rt_delta_angle_up : rt_delta_angle_down); - float lowest_rt_angle = tesla_rt_angle_last - ((tesla_rt_angle_last > 0.) ? rt_delta_angle_down : rt_delta_angle_up); - - if ((ts_elapsed > TESLA_RT_INTERVAL) || (controls_allowed && !tesla_controls_allowed_last)) { - tesla_rt_angle_last = angle_meas_now; - tesla_ts_angle_last = ts; - } - // check for violation; - if (fmax_limit_check(angle_meas_now, highest_rt_angle, lowest_rt_angle)) { - // We should not be able to STEER under these conditions - // Other sending is fine (to allow human override) - controls_allowed = 0; - //puts("WARN: RT Angle - No steer allowed! \n"); - } else { - controls_allowed = 1; + if(!tesla_powertrain && (addr == 0x45)) { + // No button other than cancel can be sent by us + int control_lever_status = (GET_BYTE(to_send, 0) & 0x3FU); + if((control_lever_status != 0) && (control_lever_status != 1)) { + violation = true; } - - tesla_controls_allowed_last = controls_allowed; } -} -// all commands: gas/regen, friction brake and steering -// if controls_allowed and no pedals pressed -// allow all commands up to limit -// else -// block all commands that produce actuation + if(addr == (tesla_powertrain ? 0x2bf : 0x2b9)) { + // DAS_control: longitudinal control message + if (tesla_longitudinal) { + // No AEB events may be sent by openpilot + int aeb_event = GET_BYTE(to_send, 2) & 0x03U; + if (aeb_event != 0) { + violation = true; + } -static int tesla_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { + // Don't allow any acceleration limits above the safety limits + int raw_accel_max = ((GET_BYTE(to_send, 6) & 0x1FU) << 4) | (GET_BYTE(to_send, 5) >> 4); + int raw_accel_min = ((GET_BYTE(to_send, 5) & 0x0FU) << 5) | (GET_BYTE(to_send, 4) >> 3); + float accel_max = (0.04 * raw_accel_max) - 15; + float accel_min = (0.04 * raw_accel_min) - 15; - int tx = 1; - int addr = GET_ADDR(to_send); + if ((accel_max > TESLA_MAX_ACCEL) || (accel_min > TESLA_MAX_ACCEL)){ + violation = true; + } - // do not transmit CAN message if steering angle too high - // DAS_steeringControl::DAS_steeringAngleRequest - if (addr == 0x488) { - float angle_raw = ((to_send->RDLR & 0x7F) << 8) + ((to_send->RDLR & 0xFF00) >> 8); - float desired_angle = (angle_raw * 0.1) - 1638.35; - bool violation = 0; - int st_enabled = (to_send->RDLR & 0x400000) >> 22; - - if (st_enabled == 0) { - //steering is not enabled, do not check angles and do send - tesla_desired_angle_last = desired_angle; - } else if (controls_allowed) { - // add 1 to not false trigger the violation - float delta_angle_up = interpolate(TESLA_LOOKUP_ANGLE_RATE_UP, tesla_speed) + 1.; - float delta_angle_down = interpolate(TESLA_LOOKUP_ANGLE_RATE_DOWN, tesla_speed) + 1.; - float highest_desired_angle = tesla_desired_angle_last + ((tesla_desired_angle_last > 0.) ? delta_angle_up : delta_angle_down); - float lowest_desired_angle = tesla_desired_angle_last - ((tesla_desired_angle_last > 0.) ? delta_angle_down : delta_angle_up); - float TESLA_MAX_ANGLE = interpolate(TESLA_LOOKUP_MAX_ANGLE, tesla_speed) + 1.; - - //check for max angles - violation |= fmax_limit_check(desired_angle, TESLA_MAX_ANGLE, -TESLA_MAX_ANGLE); - - //check for angle delta changes - violation |= fmax_limit_check(desired_angle, highest_desired_angle, lowest_desired_angle); - - if (violation) { - controls_allowed = 0; - tx = 0; + if ((accel_max < TESLA_MIN_ACCEL) || (accel_min < TESLA_MIN_ACCEL)){ + violation = true; } - tesla_desired_angle_last = desired_angle; } else { - tx = 0; + violation = true; } } - return tx; -} -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(violation) { + controls_allowed = 0; + tx = 0; + } -static int tesla_ign_hook(void) { - return tesla_ignition_started; + return tx; } -static int tesla_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { - +static int tesla_fwd_hook(int bus_num, CANPacket_t *to_fwd) { int bus_fwd = -1; int addr = GET_ADDR(to_fwd); - if (bus_num == 0) { - // change inhibit of GTW_epasControl + if(bus_num == 0) { + // Chassis/PT to autopilot + bus_fwd = 2; + } + + if(bus_num == 2) { + // Autopilot to chassis/PT + int das_control_addr = (tesla_powertrain ? 0x2bf : 0x2b9); - if (addr != 0x214) { - // remove EPB_epasControl - bus_fwd = 2; // Custom EPAS bus + bool block_msg = false; + if (!tesla_powertrain && (addr == 0x488)) { + block_msg = true; } - if (addr == 0x101) { - to_fwd->RDLR = to_fwd->RDLR | 0x4000; // 0x4000: WITH_ANGLE, 0xC000: WITH_BOTH (angle and torque) - uint32_t checksum = (((to_fwd->RDLR & 0xFF00) >> 8) + (to_fwd->RDLR & 0xFF) + 2) & 0xFF; - to_fwd->RDLR = to_fwd->RDLR & 0xFFFF; - to_fwd->RDLR = to_fwd->RDLR + (checksum << 16); + + if (tesla_longitudinal && (addr == das_control_addr)) { + block_msg = true; } - } - if (bus_num == 2) { - // remove GTW_epasControl in forwards - if (addr != 0x101) { - bus_fwd = 0; // Chassis CAN + + if(!block_msg) { + bus_fwd = 0; } } + return bus_fwd; } +static const addr_checks* tesla_init(int16_t param) { + tesla_powertrain = GET_FLAG(param, TESLA_FLAG_POWERTRAIN); + tesla_longitudinal = GET_FLAG(param, TESLA_FLAG_LONGITUDINAL_CONTROL); + controls_allowed = 0; + relay_malfunction_reset(); + + return tesla_powertrain ? (&tesla_pt_rx_checks) : (&tesla_rx_checks); +} + const safety_hooks tesla_hooks = { .init = tesla_init, .rx = tesla_rx_hook, .tx = tesla_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .ignition = tesla_ign_hook, .fwd = tesla_fwd_hook, }; diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index c4d57956314384..f3d5eff7eec459 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -13,109 +13,144 @@ const int TOYOTA_MAX_RT_DELTA = 375; // max delta torque allowed for real t 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_MAX_ACCEL = 2000; // 2.0 m/s2 +const int TOYOTA_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)) / 2U) // 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}, {0x191, 0, 8}, {0x411, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, // LKAS + ACC + {0x200, 0, 6}}; // interceptor + +AddrCheckStruct toyota_addr_checks[] = { + {.msg = {{ 0xaa, 0, 8, .check_checksum = false, .expected_timestep = 12000U}, { 0 }, { 0 }}}, + {.msg = {{0x260, 0, 8, .check_checksum = true, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{0x1D2, 0, 8, .check_checksum = true, .expected_timestep = 30000U}, { 0 }, { 0 }}}, + {.msg = {{0x224, 0, 8, .check_checksum = false, .expected_timestep = 25000U}, + {0x226, 0, 8, .check_checksum = false, .expected_timestep = 25000U}, { 0 }}}, +}; +#define TOYOTA_ADDR_CHECKS_LEN (sizeof(toyota_addr_checks) / sizeof(toyota_addr_checks[0])) +addr_checks toyota_rx_checks = {toyota_addr_checks, TOYOTA_ADDR_CHECKS_LEN}; // 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(CANPacket_t *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(CANPacket_t *to_push) { + int checksum_byte = GET_LEN(to_push) - 1U; + return (uint8_t)(GET_BYTE(to_push, checksum_byte)); +} -static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { +static int toyota_rx_hook(CANPacket_t *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_get_checksum, toyota_compute_checksum, NULL); - // get eps motor torque (0.66 factor in dbc) - if (addr == 0x260) { - int torque_meas_new = (((to_push->RDHR) & 0xFF00) | ((to_push->RDHR >> 16) & 0xFF)); - torque_meas_new = to_signed(torque_meas_new, 16); + if (valid && (GET_BUS(to_push) == 0U)) { + 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 = to_push->RDLR & 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) & 0x20U; + 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) & 1U) == 0U; + } } - 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 = ((to_push->RDLR & 0xFF) << 8) | ((to_push->RDLR & 0xFF00) >> 8); - 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 (uint8_t i=0U; i<8U; i+=2U) { + int wheel_speed = (GET_BYTE(to_push, i) << 8U) + GET_BYTE(to_push, (i+1U)); + speed += wheel_speed - 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 = (to_push->RDHR >> 16) & 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) & 1U) != 0U; } - 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) { +static int toyota_tx_hook(CANPacket_t *to_send) { int tx = 1; 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; + } + // 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 ((to_send->RDLR & 0xFFFF0000) != to_send->RDLR) { + if (!controls_allowed) { + if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) { tx = 0; } } @@ -123,26 +158,42 @@ static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // ACCEL: safety check on byte 1-2 if (addr == 0x343) { - int desired_accel = ((to_send->RDLR & 0xFF) << 8) | ((to_send->RDLR >> 8) & 0xFF); + 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); + if (violation) { tx = 0; } } + // LTA steering check + // only sent to prevent dash errors, no actuation is accepted + if (addr == 0x191) { + // check the STEER_REQUEST, STEER_REQUEST_2, and STEER_ANGLE_CMD signals + bool lta_request = (GET_BYTE(to_send, 0) & 1U) != 0U; + bool lta_request2 = ((GET_BYTE(to_send, 3) >> 1) & 1U) != 0U; + int lta_angle = (GET_BYTE(to_send, 1) << 8) | GET_BYTE(to_send, 2); + lta_angle = to_signed(lta_angle, 16); + + // block LTA msgs with actuation requests + if (lta_request || lta_request2 || (lta_angle != 0)) { + tx = 0; + } + } + // STEER: safety check on bytes 2-3 if (addr == 0x2E4) { - int desired_torque = (to_send->RDLR & 0xFF00) | ((to_send->RDLR >> 16) & 0xFF); + int desired_torque = (GET_BYTE(to_send, 1) << 8) | GET_BYTE(to_send, 2); desired_torque = to_signed(desired_torque, 16); bool violation = 0; - uint32_t ts = TIM2->CNT; + uint32_t ts = microsecond_timer_get(); if (controls_allowed) { @@ -150,20 +201,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 +225,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,37 +236,38 @@ static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } - // 1 allows the message through return tx; } -static void toyota_init(int16_t param) { +static const addr_checks* 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; + return &toyota_rx_checks; } -static int toyota_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { +static int toyota_fwd_hook(int bus_num, CANPacket_t *to_fwd) { int bus_fwd = -1; - if (toyota_camera_forwarded && !toyota_giraffe_switch_1) { - 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 - 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); - if (!block_msg) { - bus_fwd = 0; - } + + 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, 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; + if (!block_msg) { + bus_fwd = 0; } } + return bus_fwd; } @@ -224,6 +276,5 @@ 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, }; diff --git a/panda/board/safety/safety_toyota_ipas.h b/panda/board/safety/safety_toyota_ipas.h deleted file mode 100644 index 99e6dae0587a9c..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 = (((to_push->RDLR) & 0xFF00) | ((to_push->RDLR >> 16) & 0xFF)); - - // update array of samples - update_sample(&torque_driver, torque_driver_new); - } - - // get steer angle - if (addr == 0x25) { - int angle_meas_new = ((to_push->RDLR & 0xf) << 8) + ((to_push->RDLR & 0xff00) >> 8); - 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) (((to_push->RDHR) & 0xFF00) | ((to_push->RDHR >> 16) & 0xFF))) * 0.01 / 3.6; - } - - // get ipas state - if (addr == 0x262) { - ipas_state = (to_push->RDLR & 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 = ((to_send->RDLR & 0xf) << 8) + ((to_send->RDLR & 0xff00) >> 8); - int ipas_state_cmd = ((to_send->RDLR & 0xff) >> 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..8666c88076b388 --- /dev/null +++ b/panda/board/safety/safety_volkswagen.h @@ -0,0 +1,416 @@ +// 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_LH_EPS_03 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}}; +#define VOLKSWAGEN_MQB_TX_MSGS_LEN (sizeof(VOLKSWAGEN_MQB_TX_MSGS) / sizeof(VOLKSWAGEN_MQB_TX_MSGS[0])) + +AddrCheckStruct volkswagen_mqb_addr_checks[] = { + {.msg = {{MSG_ESP_19, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{MSG_LH_EPS_03, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{MSG_ESP_05, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{MSG_TSK_06, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{MSG_MOTOR_20, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, +}; +#define VOLKSWAGEN_MQB_ADDR_CHECKS_LEN (sizeof(volkswagen_mqb_addr_checks) / sizeof(volkswagen_mqb_addr_checks[0])) +addr_checks volkswagen_mqb_rx_checks = {volkswagen_mqb_addr_checks, VOLKSWAGEN_MQB_ADDR_CHECKS_LEN}; + +// 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_1 0x1A0 // RX from ABS, for ego speed +#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}}; +#define VOLKSWAGEN_PQ_TX_MSGS_LEN (sizeof(VOLKSWAGEN_PQ_TX_MSGS) / sizeof(VOLKSWAGEN_PQ_TX_MSGS[0])) + +AddrCheckStruct volkswagen_pq_addr_checks[] = { + {.msg = {{MSG_LENKHILFE_3, 0, 6, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{MSG_MOTOR_2, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, + {.msg = {{MSG_MOTOR_3, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, + {.msg = {{MSG_BREMSE_1, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, +}; +#define VOLKSWAGEN_PQ_ADDR_CHECKS_LEN (sizeof(volkswagen_pq_addr_checks) / sizeof(volkswagen_pq_addr_checks[0])) +addr_checks volkswagen_pq_rx_checks = {volkswagen_pq_addr_checks, VOLKSWAGEN_PQ_ADDR_CHECKS_LEN}; + +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(CANPacket_t *to_push) { + return (uint8_t)GET_BYTE(to_push, 0); +} + +static uint8_t volkswagen_mqb_get_counter(CANPacket_t *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(CANPacket_t *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(CANPacket_t *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_LH_EPS_03: + 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(CANPacket_t *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 const addr_checks* 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); + return &volkswagen_mqb_rx_checks; +} + +static const addr_checks* 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; + return &volkswagen_pq_rx_checks; +} + +static int volkswagen_mqb_rx_hook(CANPacket_t *to_push) { + + bool valid = addr_safety_check(to_push, &volkswagen_mqb_rx_checks, + volkswagen_get_checksum, volkswagen_mqb_compute_crc, volkswagen_mqb_get_counter); + + if (valid && (GET_BUS(to_push) == 0U)) { + 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: LH_EPS_03.EPS_Lenkmoment (absolute torque) + // Signal: LH_EPS_03.EPS_VZ_Lenkmoment (direction) + if (addr == MSG_LH_EPS_03) { + int torque_driver_new = GET_BYTE(to_push, 5) | ((GET_BYTE(to_push, 6) & 0x1FU) << 8); + int sign = (GET_BYTE(to_push, 6) & 0x80U) >> 7; + if (sign == 1) { + torque_driver_new *= -1; + } + update_sample(&torque_driver, torque_driver_new); + } + + // Enter controls on rising edge of stock ACC, exit controls if stock ACC disengages + // Signal: TSK_06.TSK_Status + if (addr == MSG_TSK_06) { + int acc_status = (GET_BYTE(to_push, 3) & 0x7U); + int cruise_engaged = ((acc_status == 3) || (acc_status == 4) || (acc_status == 5)) ? 1 : 0; + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + // Signal: Motor_20.MO_Fahrpedalrohwert_01 + if (addr == MSG_MOTOR_20) { + gas_pressed = ((GET_BYTES_04(to_push) >> 12) & 0xFFU) != 0U; + } + + // Signal: ESP_05.ESP_Fahrer_bremst + if (addr == MSG_ESP_05) { + brake_pressed = (GET_BYTE(to_push, 3) & 0x4U) >> 2; + } + + generic_rx_checks((addr == MSG_HCA_01)); + } + return valid; +} + +static int volkswagen_pq_rx_hook(CANPacket_t *to_push) { + + bool valid = addr_safety_check(to_push, &volkswagen_pq_rx_checks, + volkswagen_get_checksum, volkswagen_pq_compute_checksum, volkswagen_pq_get_counter); + + if (valid && (GET_BUS(to_push) == 0U)) { + int addr = GET_ADDR(to_push); + + // Update in-motion state from speed value. + // Signal: Bremse_1.Geschwindigkeit_neu__Bremse_1_ + if (addr == MSG_BREMSE_1) { + int speed = ((GET_BYTE(to_push, 2) & 0xFEU) >> 1) | (GET_BYTE(to_push, 3) << 7); + // DBC speed scale 0.01: 0.3m/s = 108. + vehicle_moving = speed > 108; + } + + // 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) & 0x3U) << 8); + int sign = (GET_BYTE(to_push, 3) & 0x4U) >> 2; + if (sign == 1) { + torque_driver_new *= -1; + } + update_sample(&torque_driver, torque_driver_new); + } + + // Enter controls on rising edge of stock ACC, exit controls if stock ACC disengages + // Signal: Motor_2.GRA_Status + if (addr == MSG_MOTOR_2) { + int acc_status = (GET_BYTE(to_push, 2) & 0xC0U) >> 6; + int cruise_engaged = ((acc_status == 1) || (acc_status == 2)) ? 1 : 0; + if (cruise_engaged && !cruise_engaged_prev) { + controls_allowed = 1; + } + if (!cruise_engaged) { + controls_allowed = 0; + } + cruise_engaged_prev = cruise_engaged; + } + + // 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) & 0x1U); + } + + generic_rx_checks((addr == MSG_HCA_1)); + } + return valid; +} + +static bool volkswagen_steering_check(int desired_torque) { + bool violation = false; + uint32_t ts = microsecond_timer_get(); + + 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(CANPacket_t *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)) { + 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) & 0x3FU) << 8); + int sign = (GET_BYTE(to_send, 3) & 0x80U) >> 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) & 0x9U) != 0U) { + tx = 0; + } + } + + // 1 allows the message through + return tx; +} + +static int volkswagen_pq_tx_hook(CANPacket_t *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)) { + 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) & 0x7FU) << 8); + desired_torque = desired_torque / 32; // DBC scale from PQ network to centi-Nm + int sign = (GET_BYTE(to_send, 3) & 0x80U) >> 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) & 0x3U) != 0U) { + tx = 0; + } + } + + // 1 allows the message through + return tx; +} + +static int volkswagen_fwd_hook(int bus_num, CANPacket_t *to_fwd) { + int addr = GET_ADDR(to_fwd); + int bus_fwd = -1; + + 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, +}; + +// 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, +}; diff --git a/panda/board/safety_declarations.h b/panda/board/safety_declarations.h index 21e863869bae54..11438a486a19f6 100644 --- a/panda/board/safety_declarations.h +++ b/panda/board/safety_declarations.h @@ -1,13 +1,18 @@ -#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_BIT(msg, b) (((msg)->data[((b) / 8U)] >> ((b) % 8U)) & 0x1U) +#define GET_BYTE(msg, b) ((msg)->data[(b)]) +#define GET_BYTES_04(msg) ((msg)->data[0] | ((msg)->data[1] << 8U) | ((msg)->data[2] << 16U) | ((msg)->data[3] << 24U)) +#define GET_BYTES_48(msg) ((msg)->data[4] | ((msg)->data[5] << 8U) | ((msg)->data[6] << 16U) | ((msg)->data[7] << 24U)) +#define GET_FLAG(value, mask) (((__typeof__(mask))(value) & (mask)) == (mask)) + +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]; int min; int max; -} sample_t_default = {{0}, 0, 0}; +} sample_t_default = {.values = {0}, .min = 0, .max = 0}; // safety code requires floats struct lookup_t { @@ -15,10 +20,43 @@ struct lookup_t { float y[3]; }; -void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push); -int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send); +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; + +typedef struct { + AddrCheckStruct *check; + int len; +} addr_checks; + +int safety_rx_hook(CANPacket_t *to_push); +int safety_tx_hook(CANPacket_t *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); @@ -30,27 +68,83 @@ 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(CANPacket_t *to_send, const CanMsg msg_list[], int len); +int get_addr_check_index(CANPacket_t *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(CANPacket_t *to_push, + const addr_checks *rx_checks, + uint8_t (*get_checksum)(CANPacket_t *to_push), + uint8_t (*compute_checksum)(CANPacket_t *to_push), + uint8_t (*get_counter)(CANPacket_t *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 (*tx_hook)(CAN_FIFOMailBox_TypeDef *to_send); +typedef const addr_checks* (*safety_hook_init)(int16_t param); +typedef int (*rx_hook)(CANPacket_t *to_push); +typedef int (*tx_hook)(CANPacket_t *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 int (*fwd_hook)(int bus_num, CANPacket_t *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; } safety_hooks; -// This can be set by the safety hooks. -bool controls_allowed = 0; -bool gas_interceptor_detected = 0; +void safety_tick(const addr_checks *addr_checks); + +// 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; +bool acc_main_on = false; // referred to as "ACC off" in ISO 15622:2018 + +// 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. +// Setting this flag is used for allowing the full -5.0 to +4.0 m/s^2 at lower speeds +// See ISO 15622:2018 for more information. +#define UNSAFE_RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX 8 + +int unsafe_mode = 0; -// This is set by USB command 0xdf -bool long_controls_allowed = 1; +// 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 deleted file mode 100644 index 94d41c7e326c64..00000000000000 --- a/panda/board/spi_flasher.h +++ /dev/null @@ -1,317 +0,0 @@ -// flasher state variables -uint32_t *prog_ptr = NULL; -int unlocked = 0; - -#ifdef uart_ring -void debug_ring_callback(uart_ring *ring) {} -#endif - -int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { - int resp_len = 0; - - // flasher machine - memset(resp, 0, 4); - memcpy(resp+4, "\xde\xad\xd0\x0d", 4); - resp[0] = 0xff; - resp[2] = setup->b.bRequest; - resp[3] = ~setup->b.bRequest; - *((uint32_t **)&resp[8]) = prog_ptr; - resp_len = 0xc; - - int sec; - switch (setup->b.bRequest) { - // **** 0xb0: flasher echo - case 0xb0: - resp[1] = 0xff; - break; - // **** 0xb1: unlock flash - case 0xb1: - if (FLASH->CR & FLASH_CR_LOCK) { - FLASH->KEYR = 0x45670123; - FLASH->KEYR = 0xCDEF89AB; - resp[1] = 0xff; - } - set_led(LED_GREEN, 1); - unlocked = 1; - prog_ptr = (uint32_t *)0x8004000; - break; - // **** 0xb2: erase sector - case 0xb2: - sec = setup->b.wValue.w; - // don't erase the bootloader - if (sec != 0 && sec < 12 && unlocked) { - FLASH->CR = (sec << 3) | FLASH_CR_SER; - FLASH->CR |= FLASH_CR_STRT; - while (FLASH->SR & FLASH_SR_BSY); - resp[1] = 0xff; - } - break; - // **** 0xd0: fetch serial number - case 0xd0: - #ifdef STM32F4 - // addresses are OTP - if (setup->b.wValue.w == 1) { - memcpy(resp, (void *)0x1fff79c0, 0x10); - resp_len = 0x10; - } else { - get_provision_chunk(resp); - resp_len = PROVISION_CHUNK_LEN; - } - #endif - break; - // **** 0xd1: enter bootloader mode - case 0xd1: - // this allows reflashing of the bootstub - // 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(); - } - break; - case 1: - puts("-> entering softloader\n"); - enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; - NVIC_SystemReset(); - break; - } - break; - // **** 0xd6: get version - case 0xd6: - COMPILE_TIME_ASSERT(sizeof(gitversion) <= MAX_RESP_LEN); - memcpy(resp, gitversion, sizeof(gitversion)); - resp_len = sizeof(gitversion); - break; - // **** 0xd8: reset ST - case 0xd8: - NVIC_SystemReset(); - break; - } - return resp_len; -} - -int usb_cb_ep1_in(uint8_t *usbdata, int len, bool hardwired) { return 0; } -void usb_cb_ep3_out(uint8_t *usbdata, int len, bool hardwired) { } - -int is_enumerated = 0; -void usb_cb_enumeration_complete() { - puts("USB enumeration complete\n"); - is_enumerated = 1; -} - -void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) { - set_led(LED_RED, 0); - for (int i = 0; i < len/4; i++) { - // program byte 1 - FLASH->CR = FLASH_CR_PSIZE_1 | FLASH_CR_PG; - - *prog_ptr = *(uint32_t*)(usbdata+(i*4)); - while (FLASH->SR & FLASH_SR_BSY); - - //*(uint64_t*)(&spi_tx_buf[0x30+(i*4)]) = *prog_ptr; - prog_ptr++; - } - set_led(LED_RED, 1); -} - - -int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) { - int resp_len = 0; - switch (data[0]) { - case 0: - // control transfer - resp_len = usb_cb_control_msg((USB_Setup_TypeDef *)(data+4), data_out, 0); - break; - case 2: - // ep 2, flash! - usb_cb_ep2_out(data+4, data[2], 0); - break; - } - return resp_len; -} - -#ifdef PEDAL - -#include "drivers/llcan.h" -#define CAN CAN1 - -#define CAN_BL_INPUT 0x1 -#define CAN_BL_OUTPUT 0x2 - -void CAN1_TX_IRQHandler() { - // clear interrupt - CAN->TSR |= CAN_TSR_RQCP0; -} - -#define ISOTP_BUF_SIZE 0x110 - -uint8_t isotp_buf[ISOTP_BUF_SIZE]; -uint8_t *isotp_buf_ptr = NULL; -int isotp_buf_remain = 0; - -uint8_t isotp_buf_out[ISOTP_BUF_SIZE]; -uint8_t *isotp_buf_out_ptr = NULL; -int isotp_buf_out_remain = 0; -int isotp_buf_out_idx = 0; - -void bl_can_send(uint8_t *odat) { - // wait for send - while (!(CAN->TSR & CAN_TSR_TME0)); - - // send continue - CAN->sTxMailBox[0].TDLR = ((uint32_t*)odat)[0]; - CAN->sTxMailBox[0].TDHR = ((uint32_t*)odat)[1]; - CAN->sTxMailBox[0].TDTR = 8; - CAN->sTxMailBox[0].TIR = (CAN_BL_OUTPUT << 21) | 1; -} - -void CAN1_RX0_IRQHandler() { - while (CAN->RF0R & CAN_RF0R_FMP0) { - if ((CAN->sFIFOMailBox[0].RIR>>21) == CAN_BL_INPUT) { - uint8_t dat[8]; - ((uint32_t*)dat)[0] = CAN->sFIFOMailBox[0].RDLR; - ((uint32_t*)dat)[1] = CAN->sFIFOMailBox[0].RDHR; - uint8_t odat[8]; - uint8_t type = dat[0] & 0xF0; - if (type == 0x30) { - // continue - while (isotp_buf_out_remain > 0) { - // wait for send - while (!(CAN->TSR & CAN_TSR_TME0)); - - odat[0] = 0x20 | isotp_buf_out_idx; - memcpy(odat+1, isotp_buf_out_ptr, 7); - isotp_buf_out_remain -= 7; - isotp_buf_out_ptr += 7; - isotp_buf_out_idx++; - - bl_can_send(odat); - } - } else if (type == 0x20) { - if (isotp_buf_remain > 0) { - memcpy(isotp_buf_ptr, dat+1, 7); - isotp_buf_ptr += 7; - isotp_buf_remain -= 7; - } - if (isotp_buf_remain <= 0) { - int len = isotp_buf_ptr - isotp_buf + isotp_buf_remain; - - // call the function - memset(isotp_buf_out, 0, ISOTP_BUF_SIZE); - isotp_buf_out_remain = spi_cb_rx(isotp_buf, len, isotp_buf_out); - isotp_buf_out_ptr = isotp_buf_out; - isotp_buf_out_idx = 0; - - // send initial - if (isotp_buf_out_remain <= 7) { - odat[0] = isotp_buf_out_remain; - memcpy(odat+1, isotp_buf_out_ptr, isotp_buf_out_remain); - } else { - odat[0] = 0x10 | (isotp_buf_out_remain>>8); - odat[1] = isotp_buf_out_remain & 0xFF; - memcpy(odat+2, isotp_buf_out_ptr, 6); - isotp_buf_out_remain -= 6; - isotp_buf_out_ptr += 6; - isotp_buf_out_idx++; - } - - bl_can_send(odat); - } - } else if (type == 0x10) { - int len = ((dat[0]&0xF)<<8) | dat[1]; - - // setup buffer - isotp_buf_ptr = isotp_buf; - memcpy(isotp_buf_ptr, dat+2, 6); - - if (len < (ISOTP_BUF_SIZE-0x10)) { - isotp_buf_ptr += 6; - isotp_buf_remain = len-6; - } - - memset(odat, 0, 8); - odat[0] = 0x30; - bl_can_send(odat); - } - } - // next - CAN->RF0R |= CAN_RF0R_RFOM0; - } -} - -void CAN1_SCE_IRQHandler() { - llcan_clear_send(CAN); -} - -#endif - -void soft_flasher_start() { - puts("\n\n\n************************ FLASHER START ************************\n"); - - enter_bootloader_mode = 0; - - RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; - RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; - RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; - RCC->APB1ENR |= RCC_APB1ENR_USART2EN; - -// pedal has the canloader -#ifdef PEDAL - RCC->APB1ENR |= RCC_APB1ENR_CAN1EN; - - // B8,B9: CAN 1 - set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1); - set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1); - set_can_enable(CAN1, 1); - - // init can - llcan_set_speed(CAN1, 5000, false, false); - llcan_init(CAN1); -#endif - - // A4,A5,A6,A7: setup SPI - set_gpio_alternate(GPIOA, 4, GPIO_AF5_SPI1); - set_gpio_alternate(GPIOA, 5, GPIO_AF5_SPI1); - set_gpio_alternate(GPIOA, 6, GPIO_AF5_SPI1); - set_gpio_alternate(GPIOA, 7, GPIO_AF5_SPI1); - - // A2,A3: USART 2 for debugging - set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); - set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); - - // A11,A12: USB - set_gpio_alternate(GPIOA, 11, GPIO_AF10_OTG_FS); - set_gpio_alternate(GPIOA, 12, GPIO_AF10_OTG_FS); - GPIOA->OSPEEDR = GPIO_OSPEEDER_OSPEEDR11 | GPIO_OSPEEDER_OSPEEDR12; - - // flasher - spi_init(); - - // enable USB - usb_init(); - - // green LED on for flashing - set_led(LED_GREEN, 1); - - __enable_irq(); - - uint64_t cnt = 0; - - for (cnt=0;;cnt++) { - if (cnt == 35 && !is_enumerated && usb_power_mode == USB_POWER_CLIENT) { - // if you are connected through a hub to the phone - // you need power to be able to see the device - puts("USBP: didn't enumerate, switching to CDP mode\n"); - set_usb_power_mode(USB_POWER_CDP); - set_led(LED_BLUE, 1); - } - // blink the green LED fast - set_led(LED_GREEN, 0); - delay(500000); - set_led(LED_GREEN, 1); - delay(500000); - } -} - diff --git a/panda/board/stm32_flash.ld b/panda/board/stm32_flash.ld deleted file mode 100644 index 500319377efee1..00000000000000 --- a/panda/board/stm32_flash.ld +++ /dev/null @@ -1,165 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32_flash.ld -** -** Abstract : Linker script for STM32F407VG Device with -** 1024KByte FLASH, 192KByte RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Environment : Atollic TrueSTUDIO(R) -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -** (c)Copyright Atollic AB. -** You may use this file as-is or modify it according to the needs of your -** project. Distribution of this file (unmodified or modified) is not -** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the -** rights to distribute the assembled, compiled & linked contents of this -** file as part of an application binary file, provided that it is built -** using the Atollic TrueSTUDIO(R) toolchain. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -enter_bootloader_mode = 0x2001FFFC; -_estack = 0x2001FFFC; /* end of 128K RAM on AHB bus*/ -_app_start = 0x08004000; /* Reserve 16K for bootloader */ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - _exit = .; - } >FLASH - - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = .; - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(4); - } >RAM - - /* MEMORY_bank1 section, code must be located here explicitly */ - /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ - .memory_b1_text : - { - *(.mb1text) /* .mb1text sections (code) */ - *(.mb1text*) /* .mb1text* sections (code) */ - *(.mb1rodata) /* read-only data (constants) */ - *(.mb1rodata*) - } >MEMORY_B1 - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/panda/board/stm32fx/board.h b/panda/board/stm32fx/board.h new file mode 100644 index 00000000000000..90aa739fda901e --- /dev/null +++ b/panda/board/stm32fx/board.h @@ -0,0 +1,61 @@ +// ///////////////////////////////////////////////////////////// // +// Hardware abstraction layer for all different supported boards // +// ///////////////////////////////////////////////////////////// // +#include "boards/board_declarations.h" +#include "boards/unused_funcs.h" + +// ///// Board definition and detection ///// // +#include "drivers/harness.h" +#ifdef PANDA + #include "drivers/fan.h" + #include "stm32fx/llfan.h" + #include "stm32fx/llrtc.h" + #include "drivers/rtc.h" + #include "stm32fx/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? 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; + } + #else + #ifdef PEDAL + hw_type = HW_TYPE_PEDAL; + current_board = &board_pedal; + #else + hw_type = HW_TYPE_UNKNOWN; + puts("Hardware type is UNKNOWN!\n"); + #endif + #endif +} + +bool has_external_debug_serial = 0; + +void detect_external_debug_serial(void) { + // detect if external serial debugging is present + has_external_debug_serial = detect_with_pull(GPIOA, 3, PULL_DOWN); +} diff --git a/panda/board/stm32fx/clock.h b/panda/board/stm32fx/clock.h new file mode 100644 index 00000000000000..4f7beaae47fcaa --- /dev/null +++ b/panda/board/stm32fx/clock.h @@ -0,0 +1,39 @@ +void clock_init(void) { + // enable external oscillator + register_set_bits(&(RCC->CR), RCC_CR_HSEON); + while ((RCC->CR & RCC_CR_HSERDY) == 0); + + // divide things + register_set(&(RCC->CFGR), RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4, 0xFF7FFCF3U); + + // 16mhz crystal + 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 + 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 *** + register_set(&(FLASH->ACR), FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS, 0x1F0FU); + + // switch to PLL + register_set_bits(&(RCC->CFGR), RCC_CFGR_SW_PLL); + while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); + + // *** running on PLL *** +} + +void watchdog_init(void) { + // setup watchdog + IWDG->KR = 0x5555U; + register_set(&(IWDG->PR), 0x0U, 0x7U); // divider/4 + + // 0 = 0.125 ms, let's have a 50ms watchdog + register_set(&(IWDG->RLR), (400U-1U), 0xFFFU); + IWDG->KR = 0xCCCCU; +} + +void watchdog_feed(void) { + IWDG->KR = 0xAAAAU; +} diff --git a/panda/board/stm32fx/clock_source.h b/panda/board/stm32fx/clock_source.h new file mode 100644 index 00000000000000..691010bd3759a7 --- /dev/null +++ b/panda/board/stm32fx/clock_source.h @@ -0,0 +1,102 @@ + +#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); + set_gpio_output(GPIOC, 5, 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); + set_gpio_output(GPIOC, 5, 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), ((APB2_FREQ*100U)-1U), 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; + } +} diff --git a/panda/board/stm32fx/inc/cmsis_compiler.h b/panda/board/stm32fx/inc/cmsis_compiler.h new file mode 100644 index 00000000000000..d0f39eef67ed91 --- /dev/null +++ b/panda/board/stm32fx/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/stm32fx/inc/cmsis_gcc.h b/panda/board/stm32fx/inc/cmsis_gcc.h new file mode 100644 index 00000000000000..2f68473f64e216 --- /dev/null +++ b/panda/board/stm32fx/inc/cmsis_gcc.h @@ -0,0 +1,2169 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS compiler GCC header file + * @version V5.2.0 + * @date 08. May 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. + */ + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#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 + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#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 + */ +__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 + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__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) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__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_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__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) +{ + uint32_t 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) : ); +} + + +#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 + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + 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 + */ +__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_ns" : "=r" (result) :: "memory"); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#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. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#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 + */ +__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_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#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 + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#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)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__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; + + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + return(result); +#endif +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__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 +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * 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 + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#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. + */ +#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. + */ +#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. + */ +#define __SEV() __ASM volatile ("sev") + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__STATIC_FORCEINLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__STATIC_FORCEINLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__STATIC_FORCEINLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \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 + */ +__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; +} + + +/** + \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 + */ +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (int16_t)__builtin_bswap16(value); +#else + int16_t result; + + __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \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] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#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 + 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 != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return result; +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__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 ((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) + */ +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#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 ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#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 ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR 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 __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR 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 __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR 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 __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__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] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1,ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \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) ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__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" (*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" (ptr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__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" (*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" (ptr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__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) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); +} + + +/** + \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 */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#if 0 +#define __PKHBT(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __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) ) + +#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; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#pragma GCC diagnostic pop + +#endif /* __CMSIS_GCC_H */ + diff --git a/panda/board/stm32fx/inc/cmsis_version.h b/panda/board/stm32fx/inc/cmsis_version.h new file mode 100644 index 00000000000000..bf57cf3e805348 --- /dev/null +++ b/panda/board/stm32fx/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/stm32fx/inc/core_cm3.h similarity index 83% rename from panda/board/inc/core_cm3.h rename to panda/board/stm32fx/inc/core_cm3.h index b4ac4c7b05a799..0918c5eb4c827b 100644 --- a/panda/board/inc/core_cm3.h +++ b/panda/board/stm32fx/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/stm32fx/inc/core_cm4.h similarity index 83% rename from panda/board/inc/core_cm4.h rename to panda/board/stm32fx/inc/core_cm4.h index dc840ebf222138..0d40081a385dc1 100644 --- a/panda/board/inc/core_cm4.h +++ b/panda/board/stm32fx/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/stm32fx/inc/mpu_armv7.h b/panda/board/stm32fx/inc/mpu_armv7.h new file mode 100644 index 00000000000000..e72cc4623db517 --- /dev/null +++ b/panda/board/stm32fx/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/stm32f205xx.h b/panda/board/stm32fx/inc/stm32f205xx.h similarity index 88% rename from panda/board/inc/stm32f205xx.h rename to panda/board/stm32fx/inc/stm32f205xx.h index ba825d1970327c..622faead62b0ea 100644 --- a/panda/board/inc/stm32f205xx.h +++ b/panda/board/stm32fx/inc/stm32f205xx.h @@ -4,8 +4,8 @@ * @author MCD Application Team * @version V2.1.2 * @date 29-June-2016 - * @brief CMSIS STM32F205xx Device Peripheral Access Layer Header File. - * This file contains : + * @brief CMSIS STM32F205xx Device Peripheral Access Layer Header File. + * This file contains : * - Data structures and the address mapping for all peripherals * - Peripherals registers declarations and bits definition * - Macros to access peripheral’s registers hardware @@ -47,21 +47,21 @@ /** @addtogroup stm32f205xx * @{ */ - + #ifndef __STM32F205xx_H #define __STM32F205xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - + /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** - * @brief Configuration of the Cortex-M3 Processor and Core Peripherals + * @brief Configuration of the Cortex-M3 Processor and Core Peripherals */ #define __CM3_REV 0x0200U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F2XX provides an MPU */ @@ -71,14 +71,14 @@ /** * @} */ - + /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** - * @brief STM32F2XX Interrupt Number Definition, according to the selected device - * in @ref Library_configuration_section + * @brief STM32F2XX Interrupt Number Definition, according to the selected device + * in @ref Library_configuration_section */ typedef enum { @@ -126,7 +126,7 @@ typedef enum I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ - I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ @@ -134,7 +134,7 @@ typedef enum USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ - OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ + OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ @@ -181,16 +181,16 @@ typedef enum /** @addtogroup Peripheral_registers_structures * @{ - */ + */ -/** - * @brief Analog to Digital Converter +/** + * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ - __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ + __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ @@ -220,8 +220,8 @@ typedef struct } ADC_Common_TypeDef; -/** - * @brief Controller Area Network TxMailBox +/** + * @brief Controller Area Network TxMailBox */ typedef struct @@ -232,10 +232,10 @@ typedef struct __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; -/** - * @brief Controller Area Network FIFOMailBox +/** + * @brief Controller Area Network FIFOMailBox */ - + typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ @@ -244,20 +244,20 @@ typedef struct __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; -/** - * @brief Controller Area Network FilterRegister +/** + * @brief Controller Area Network FilterRegister */ - + typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; -/** - * @brief Controller Area Network +/** + * @brief Controller Area Network */ - + typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ @@ -280,12 +280,12 @@ typedef struct __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ - uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ + uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; -/** - * @brief CRC calculation unit +/** + * @brief CRC calculation unit */ typedef struct @@ -297,7 +297,7 @@ typedef struct __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; -/** +/** * @brief Digital to Analog Converter */ @@ -319,7 +319,7 @@ typedef struct __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; -/** +/** * @brief Debug MCU */ @@ -332,7 +332,7 @@ typedef struct }DBGMCU_TypeDef; -/** +/** * @brief DMA Controller */ @@ -355,7 +355,7 @@ typedef struct } DMA_TypeDef; -/** +/** * @brief External Interrupt/Event Controller */ @@ -369,7 +369,7 @@ typedef struct __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; -/** +/** * @brief FLASH Registers */ @@ -384,28 +384,28 @@ typedef struct } FLASH_TypeDef; -/** +/** * @brief Flexible Static Memory Controller */ typedef struct { - __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ -} FSMC_Bank1_TypeDef; + __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ +} FSMC_Bank1_TypeDef; -/** +/** * @brief Flexible Static Memory Controller Bank1E */ - + typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; -/** +/** * @brief Flexible Static Memory Controller Bank2 */ - + typedef struct { __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ @@ -424,10 +424,10 @@ typedef struct __IO uint32_t ECCR3; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ } FSMC_Bank2_3_TypeDef; -/** +/** * @brief Flexible Static Memory Controller Bank4 */ - + typedef struct { __IO uint32_t PCR4; /*!< PC Card control register 4, Address offset: 0xA0 */ @@ -435,10 +435,10 @@ typedef struct __IO uint32_t PMEM4; /*!< PC Card Common memory space timing register 4, Address offset: 0xA8 */ __IO uint32_t PATT4; /*!< PC Card Attribute memory space timing register 4, Address offset: 0xAC */ __IO uint32_t PIO4; /*!< PC Card I/O space timing register 4, Address offset: 0xB0 */ -} FSMC_Bank4_TypeDef; +} FSMC_Bank4_TypeDef; -/** +/** * @brief General Purpose I/O */ @@ -455,20 +455,20 @@ typedef struct __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; -/** +/** * @brief System configuration controller */ - + typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ - uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ + uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ } SYSCFG_TypeDef; -/** +/** * @brief Inter-integrated Circuit Interface */ @@ -485,7 +485,7 @@ typedef struct __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ } I2C_TypeDef; -/** +/** * @brief Independent WATCHDOG */ @@ -497,7 +497,7 @@ typedef struct __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; -/** +/** * @brief Power Control */ @@ -507,7 +507,7 @@ typedef struct __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; -/** +/** * @brief Reset and Clock Control */ @@ -546,7 +546,7 @@ typedef struct } RCC_TypeDef; -/** +/** * @brief Real-Time Clock */ @@ -595,7 +595,7 @@ typedef struct } RTC_TypeDef; -/** +/** * @brief SD host Interface */ @@ -623,7 +623,7 @@ typedef struct __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; -/** +/** * @brief Serial Peripheral Interface */ @@ -640,7 +640,7 @@ typedef struct __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; -/** +/** * @brief TIM */ @@ -669,10 +669,10 @@ typedef struct __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; -/** +/** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ - + typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ @@ -684,7 +684,7 @@ typedef struct __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; -/** +/** * @brief Window WATCHDOG */ @@ -696,11 +696,11 @@ typedef struct } WWDG_TypeDef; -/** +/** * @brief RNG */ - -typedef struct + +typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ @@ -708,8 +708,8 @@ typedef struct } RNG_TypeDef; - -/** + +/** * @brief __USB_OTG_Core_register */ typedef struct @@ -737,10 +737,10 @@ USB_OTG_GlobalTypeDef; -/** +/** * @brief __device_Registers */ -typedef struct +typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register Address offset : 0x800 */ __IO uint32_t DCTL; /*!< dev Control Register Address offset : 0x804 */ @@ -757,19 +757,19 @@ typedef struct __IO uint32_t DTHRCTL; /*!< dev thr Address offset : 0x830 */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk Address offset : 0x834 */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt Address offset : 0x838 */ - __IO uint32_t DEACHMSK; /*!< dedicated EP msk Address offset : 0x83C */ + __IO uint32_t DEACHMSK; /*!< dedicated EP msk Address offset : 0x83C */ uint32_t Reserved40; /*!< dedicated EP mask Address offset : 0x840 */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask Address offset : 0x844 */ uint32_t Reserved44[15]; /*!< Reserved Address offset : 0x844-0x87C */ - __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk Address offset : 0x884 */ + __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk Address offset : 0x884 */ } USB_OTG_DeviceTypeDef; -/** +/** * @brief __IN_Endpoint-Specific_Register */ -typedef struct +typedef struct { __IO uint32_t DIEPCTL; /* dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /* Reserved 900h + (ep_num * 20h) + 04h */ @@ -783,10 +783,10 @@ typedef struct USB_OTG_INEndpointTypeDef; -/** +/** * @brief __OUT_Endpoint-Specific_Registers */ -typedef struct +typedef struct { __IO uint32_t DOEPCTL; /* dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h*/ uint32_t Reserved04; /* Reserved B00h + (ep_num * 20h) + 04h*/ @@ -799,10 +799,10 @@ typedef struct USB_OTG_OUTEndpointTypeDef; -/** +/** * @brief __Host_Mode_Register_Structures */ -typedef struct +typedef struct { __IO uint32_t HCFG; /* Host Configuration Register 400h*/ __IO uint32_t HFIR; /* Host Frame Interval Register 404h*/ @@ -815,7 +815,7 @@ typedef struct USB_OTG_HostTypeDef; -/** +/** * @brief __Host_Channel_Specific_Registers */ typedef struct @@ -830,8 +830,8 @@ typedef struct } USB_OTG_HostChannelTypeDef; - -/** + +/** * @brief Peripheral_memory_map */ #define FLASH_BASE 0x08000000U /*!< FLASH(up to 1 MB) base address in the alias region */ @@ -965,10 +965,10 @@ USB_OTG_HostChannelTypeDef; /** * @} */ - + /** @addtogroup Peripheral_declaration * @{ - */ + */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) @@ -1003,7 +1003,7 @@ USB_OTG_HostChannelTypeDef; #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define SDIO ((SDIO_TypeDef *) SDIO_BASE) -#define SPI1 ((SPI_TypeDef *) SPI1_BASE) +#define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) @@ -1038,7 +1038,7 @@ USB_OTG_HostChannelTypeDef; #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) -#define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) +#define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) @@ -1057,11 +1057,11 @@ USB_OTG_HostChannelTypeDef; /** @addtogroup Exported_constants * @{ */ - + /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ - + /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ @@ -1104,7 +1104,7 @@ USB_OTG_HostChannelTypeDef; #define ADC_CR1_RES_0 0x01000000U /*!
    © COPYRIGHT(c) 2016 STMicroelectronics
    @@ -32,8 +32,8 @@ * 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. * - ****************************************************************************** - */ + ****************************************************************************** + */ /** @addtogroup CMSIS * @{ @@ -41,8 +41,8 @@ /** @addtogroup stm32f4xx_system * @{ - */ - + */ + /** * @brief Define to prevent recursive inclusion */ @@ -51,7 +51,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /** @addtogroup STM32F4xx_System_Includes * @{ @@ -68,7 +68,7 @@ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetSysClockFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. @@ -101,7 +101,7 @@ extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ /** @addtogroup STM32F4xx_System_Exported_Functions * @{ */ - + extern void SystemInit(void); extern void SystemCoreClockUpdate(void); /** @@ -117,8 +117,8 @@ extern void SystemCoreClockUpdate(void); /** * @} */ - + /** * @} - */ + */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/panda/board/stm32fx/interrupt_handlers.h b/panda/board/stm32fx/interrupt_handlers.h new file mode 100644 index 00000000000000..3b40f4ee527a6c --- /dev/null +++ b/panda/board/stm32fx/interrupt_handlers.h @@ -0,0 +1,100 @@ +// ********************* 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 diff --git a/panda/board/stm32fx/lladc.h b/panda/board/stm32fx/lladc.h new file mode 100644 index 00000000000000..2ae14a2dcbd684 --- /dev/null +++ b/panda/board/stm32fx/lladc.h @@ -0,0 +1,40 @@ +// ACCEL1 = ADC10 +// ACCEL2 = ADC11 +// VOLT_S = ADC12 +// CURR_S = ADC13 + +#define ADCCHAN_ACCEL0 10 +#define ADCCHAN_ACCEL1 11 +#define ADCCHAN_VOLTAGE 12 +#define ADCCHAN_CURRENT 13 + +void register_set(volatile uint32_t *addr, uint32_t val, uint32_t mask); + +void adc_init(void) { + 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) { + // 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)); + + 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/stm32fx/llbxcan.h b/panda/board/stm32fx/llbxcan.h new file mode 100644 index 00000000000000..f1d5187cb205fb --- /dev/null +++ b/panda/board/stm32fx/llbxcan.h @@ -0,0 +1,128 @@ +// this is needed for 1 mbps support +#define CAN_QUANTA 8U +#define CAN_SEQ1 6 // roundf(quanta * 0.875f) - 1; +#define CAN_SEQ2 1 // roundf(quanta * 0.125f); + +#define CAN_PCLK 24000U +// 333 = 33.3 kbps +// 5000 = 500 kbps +#define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10U / (x)) + +#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) { + bool ret = true; + + // 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; + } + } + + 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; +} + +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; + 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/stm32fx/lldac.h b/panda/board/stm32fx/lldac.h new file mode 100644 index 00000000000000..7b2e112bee3604 --- /dev/null +++ b/panda/board/stm32fx/lldac.h @@ -0,0 +1,16 @@ +void dac_init(void) { + // 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) { + register_set(&(DAC->DHR12R1), value, 0xFFFU); + } else if (channel == 1) { + register_set(&(DAC->DHR12R2), value, 0xFFFU); + } else { + puts("Failed to set DAC: invalid channel value: 0x"); puth(value); puts("\n"); + } +} diff --git a/panda/board/stm32fx/llfan.h b/panda/board/stm32fx/llfan.h new file mode 100644 index 00000000000000..a9d21f19b4144a --- /dev/null +++ b/panda/board/stm32fx/llfan.h @@ -0,0 +1,23 @@ +// 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); +} diff --git a/panda/board/stm32fx/llflash.h b/panda/board/stm32fx/llflash.h new file mode 100644 index 00000000000000..61adcd4584c3a6 --- /dev/null +++ b/panda/board/stm32fx/llflash.h @@ -0,0 +1,28 @@ +bool flash_is_locked(void) { + return (FLASH->CR & FLASH_CR_LOCK); +} + +void flash_unlock(void) { + FLASH->KEYR = 0x45670123; + FLASH->KEYR = 0xCDEF89AB; +} + +bool flash_erase_sector(uint8_t sector, bool unlocked) { + // don't erase the bootloader(sector 0) + if (sector != 0 && sector < 12 && unlocked) { + FLASH->CR = (sector << 3) | FLASH_CR_SER; + FLASH->CR |= FLASH_CR_STRT; + while (FLASH->SR & FLASH_SR_BSY); + return true; + } + return false; +} + +void flash_write_word(void *prog_ptr, uint32_t data) { + uint32_t *pp = prog_ptr; + FLASH->CR = FLASH_CR_PSIZE_1 | FLASH_CR_PG; + *pp = data; + while (FLASH->SR & FLASH_SR_BSY); +} + +void flush_write_buffer(void) { } diff --git a/panda/board/stm32fx/llrtc.h b/panda/board/stm32fx/llrtc.h new file mode 100644 index 00000000000000..1dc137369251e5 --- /dev/null +++ b/panda/board/stm32fx/llrtc.h @@ -0,0 +1,9 @@ +#define RCC_BDCR_MASK (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL | RCC_BDCR_LSEMOD | RCC_BDCR_LSEBYP | RCC_BDCR_LSEON) + +void enable_bdomain_protection(void) { + register_clear_bits(&(PWR->CR), PWR_CR_DBP); +} + +void disable_bdomain_protection(void) { + register_set_bits(&(PWR->CR), PWR_CR_DBP); +} diff --git a/panda/board/stm32fx/llspi.h b/panda/board/stm32fx/llspi.h new file mode 100644 index 00000000000000..d07bce352fbb31 --- /dev/null +++ b/panda/board/stm32fx/llspi.h @@ -0,0 +1,131 @@ +// IRQs: DMA2_Stream2, DMA2_Stream3, EXTI4 + +void spi_init(void); +int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out); + +// end API + +#define SPI_BUF_SIZE 256 +uint8_t spi_buf[SPI_BUF_SIZE]; +int spi_buf_count = 0; +int spi_total_count = 0; + +void spi_tx_dma(void *addr, int len) { + // disable DMA + register_clear_bits(&(SPI1->CR2), SPI_CR2_TXDMAEN); + register_clear_bits(&(DMA2_Stream3->CR), DMA_SxCR_EN); + + // DMA2, stream 3, channel 3 + register_set(&(DMA2_Stream3->M0AR), (uint32_t)addr, 0xFFFFFFFFU); + DMA2_Stream3->NDTR = len; + register_set(&(DMA2_Stream3->PAR), (uint32_t)&(SPI1->DR), 0xFFFFFFFFU); + + // channel3, increment memory, memory -> periph, enable + 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); + register_set_bits(&(DMA2_Stream3->CR), DMA_SxCR_TCIE); + + register_set_bits(&(SPI1->CR2), SPI_CR2_TXDMAEN); + + // signal data is ready by driving low + // esp must be configured as input by this point + set_gpio_output(GPIOB, 0, 0); +} + +void spi_rx_dma(void *addr, int len) { + // disable DMA + 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 + register_set(&(DMA2_Stream2->M0AR), (uint32_t)addr, 0xFFFFFFFFU); + DMA2_Stream2->NDTR = len; + register_set(&(DMA2_Stream2->PAR), (uint32_t)&(SPI1->DR), 0xFFFFFFFFU); + + // channel3, increment memory, periph -> memory, enable + register_set(&(DMA2_Stream2->CR), (DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_EN), 0x1E077EFEU); + delay(0); + register_set_bits(&(DMA2_Stream2->CR), DMA_SxCR_TCIE); + + 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_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); + #ifdef DEBUG_SPI + puts("SPI write: "); + puth(*resp_len); + puts("\n"); + #endif + spi_tx_dma(spi_tx_buf, *resp_len + 4); + + // ack + DMA2->LIFCR = DMA_LIFCR_CTCIF2; +} + +// SPI TX +void DMA2_Stream3_IRQ_Handler(void) { + #ifdef DEBUG_SPI + puts("SPI handshake\n"); + #endif + + // reset handshake back to pull up + set_gpio_mode(GPIOB, 0, MODE_INPUT); + set_gpio_pullup(GPIOB, 0, PULL_UP); + + // ack + DMA2->LIFCR = DMA_LIFCR_CTCIF3; +} + +void EXTI4_IRQ_Handler(void) { + volatile unsigned int pr = EXTI->PR & (1U << 4); + #ifdef DEBUG_SPI + puts("exti4\n"); + #endif + // SPI CS falling + if ((pr & (1U << 4)) != 0U) { + spi_total_count = 0; + spi_rx_dma(spi_buf, 0x14); + } + 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); +} diff --git a/panda/board/stm32fx/lluart.h b/panda/board/stm32fx/lluart.h new file mode 100644 index 00000000000000..69959a76f5b9c1 --- /dev/null +++ b/panda/board/stm32fx/lluart.h @@ -0,0 +1,235 @@ +// ***************************** 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) { + // 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; + } + } + EXIT_CRITICAL(); +} + +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(); + } +} + +void uart_send_break(uart_ring *u) { + while ((u->uart->CR1 & USART_CR1_SBK) != 0); + u->uart->CR1 |= USART_CR1_SBK; +} + +// 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; + } + + // Set write pointer + q->w_ptr_rx = w_index; + } + + prev_w_index = w_index; + EXIT_CRITICAL(); +} + +// 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(); + + // 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); + } +} diff --git a/panda/board/stm32fx/llusb.h b/panda/board/stm32fx/llusb.h new file mode 100644 index 00000000000000..df4747312eb2a7 --- /dev/null +++ b/panda/board/stm32fx/llusb.h @@ -0,0 +1,102 @@ +typedef struct +{ + __IO uint32_t HPRT; +} +USB_OTG_HostPortTypeDef; + +USB_OTG_GlobalTypeDef *USBx = USB_OTG_FS; + +#define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE)) +#define USBx_HOST_PORT ((USB_OTG_HostPortTypeDef *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE)) +#define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t)USBx + USB_OTG_DEVICE_BASE)) +#define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) +#define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) +#define USBx_DFIFO(i) *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE)) +#define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE) + +#define USBD_FS_TRDT_VALUE 5U +#define USB_OTG_SPEED_FULL 3 + + +void usb_irqhandler(void); + +void OTG_FS_IRQ_Handler(void) { + NVIC_DisableIRQ(OTG_FS_IRQn); + //__disable_irq(); + usb_irqhandler(); + //__enable_irq(); + NVIC_EnableIRQ(OTG_FS_IRQn); +} + +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); +} diff --git a/panda/board/stm32fx/peripherals.h b/panda/board/stm32fx/peripherals.h new file mode 100644 index 00000000000000..40ef6cb573427d --- /dev/null +++ b/panda/board/stm32fx/peripherals.h @@ -0,0 +1,89 @@ +void gpio_usb_init(void) { + // A11,A12: USB + set_gpio_alternate(GPIOA, 11, GPIO_AF10_OTG_FS); + set_gpio_alternate(GPIOA, 12, GPIO_AF10_OTG_FS); + GPIOA->OSPEEDR = GPIO_OSPEEDER_OSPEEDR11 | GPIO_OSPEEDER_OSPEEDR12; +} + +void gpio_usart2_init(void) { + // A2,A3: USART 2 for debugging + set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); + set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); +} + +// Common GPIO initialization +void common_init_gpio(void) { + // TODO: Is this block actually doing something??? + // pull low to hold ESP in reset?? + // enable OTG out tied to ground + GPIOA->ODR = 0; + GPIOB->ODR = 0; + GPIOA->PUPDR = 0; + GPIOB->AFR[0] = 0; + GPIOB->AFR[1] = 0; + + // C2: Voltage sense line + set_gpio_mode(GPIOC, 2, MODE_ANALOG); + + gpio_usb_init(); + + // 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); + + // B8,B9: CAN 1 + #ifdef STM32F4 + set_gpio_alternate(GPIOB, 8, GPIO_AF8_CAN1); + set_gpio_alternate(GPIOB, 9, GPIO_AF8_CAN1); + #else + set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1); + set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1); + #endif +} + +void flasher_peripherals_init(void) { + RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; + RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; + RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; + RCC->APB1ENR |= RCC_APB1ENR_USART2EN; +} + +// Peripheral initialization +void peripherals_init(void) { + // enable GPIOB, UART2, CAN, USB clock + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; + RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; + + RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; + RCC->APB1ENR |= RCC_APB1ENR_USART2EN; + RCC->APB1ENR |= RCC_APB1ENR_USART3EN; + #ifdef PANDA + RCC->APB1ENR |= RCC_APB1ENR_UART5EN; + #endif + RCC->APB1ENR |= RCC_APB1ENR_CAN1EN; + RCC->APB1ENR |= RCC_APB1ENR_CAN2EN; + #ifdef CAN3 + RCC->APB1ENR |= RCC_APB1ENR_CAN3EN; + #endif + RCC->APB1ENR |= RCC_APB1ENR_DACEN; + RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; // main counter + RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; // pedal and fan PWM + RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // IR PWM + RCC->APB1ENR |= RCC_APB1ENR_TIM5EN; // k-line init + RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; // interrupt timer + RCC->APB1ENR |= RCC_APB1ENR_TIM12EN; // gmlan_alt + RCC->APB1ENR |= RCC_APB1ENR_PWREN; // for RTC config + RCC->APB2ENR |= RCC_APB2ENR_USART1EN; + RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; + 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 +} + +void enable_interrupt_timer(void) { + register_set_bits(&(RCC->APB1ENR), RCC_APB1ENR_TIM6EN); // Enable interrupt timer peripheral +} diff --git a/panda/board/startup_stm32f205xx.s b/panda/board/stm32fx/startup_stm32f205xx.s similarity index 98% rename from panda/board/startup_stm32f205xx.s rename to panda/board/stm32fx/startup_stm32f205xx.s index f4b6c6cb741272..7554efc4c180da 100644 --- a/panda/board/startup_stm32f205xx.s +++ b/panda/board/stm32fx/startup_stm32f205xx.s @@ -4,7 +4,7 @@ * @author MCD Application Team * @version V2.1.2 * @date 29-June-2016 - * @brief STM32F205xx Devices vector table for Atollic TrueSTUDIO toolchain. + * @brief STM32F205xx Devices vector table for Atollic TrueSTUDIO toolchain. * This module performs: * - Set the initial SP * - Set the initial PC == Reset_Handler, @@ -42,7 +42,7 @@ * ****************************************************************************** */ - + .syntax unified .cpu cortex-m3 .thumb @@ -50,10 +50,10 @@ .global g_pfnVectors .global Default_Handler -/* start address for the initialization values of the .data section. +/* start address for the initialization values of the .data section. defined in linker script */ .word _sidata -/* start address for the .data section. defined in linker script */ +/* start address for the .data section. defined in linker script */ .word _sdata /* end address for the .data section. defined in linker script */ .word _edata @@ -67,7 +67,7 @@ defined in linker script */ * @brief This is the code that gets called when the processor first * starts execution following a reset event. Only the absolutely * necessary set is performed, after which the application - * supplied main() routine is called. + * supplied main() routine is called. * @param None * @retval : None */ @@ -75,7 +75,7 @@ defined in linker script */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function -Reset_Handler: +Reset_Handler: ldr sp, =_estack /* set stack pointer */ bl __initialize_hardware_early @@ -88,7 +88,7 @@ CopyDataInit: ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4 - + LoopCopyDataInit: ldr r0, =_sdata ldr r3, =_edata @@ -101,7 +101,7 @@ LoopCopyDataInit: FillZerobss: movs r3, #0 str r3, [r2], #4 - + LoopFillZerobss: ldr r3, = _ebss cmp r2, r3 @@ -113,15 +113,15 @@ LoopFillZerobss: /*bl __libc_init_array*/ /* Call the application's entry point.*/ bl main - bx lr + bx lr .size Reset_Handler, .-Reset_Handler /** - * @brief This is the code that gets called when the processor receives an + * @brief This is the code that gets called when the processor receives an * unexpected interrupt. This simply enters an infinite loop, preserving * the system state for examination by a debugger. - * @param None - * @retval None + * @param None + * @retval None */ .section .text.Default_Handler,"ax",%progbits Default_Handler: @@ -133,14 +133,14 @@ Infinite_Loop: * The minimal vector table for a Cortex M3. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. -* +* *******************************************************************************/ .section .isr_vector,"a",%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors - - + + g_pfnVectors: .word _estack .word Reset_Handler @@ -159,7 +159,7 @@ g_pfnVectors: .word 0 .word PendSV_Handler .word SysTick_Handler - + /* External Interrupts */ .word WWDG_IRQHandler /* Window WatchDog */ .word PVD_IRQHandler /* PVD through EXTI Line detection */ @@ -248,7 +248,7 @@ g_pfnVectors: * Provide weak aliases for each Exception handler to the Default_Handler. * As they are weak aliases, any function with the same name will override * this definition. -* +* *******************************************************************************/ .weak NMI_Handler .thumb_set NMI_Handler,Default_Handler @@ -302,7 +302,7 @@ g_pfnVectors: .thumb_set EXTI1_IRQHandler,Default_Handler .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler + .thumb_set EXTI2_IRQHandler,Default_Handler .weak EXTI3_IRQHandler .thumb_set EXTI3_IRQHandler,Default_Handler @@ -320,7 +320,7 @@ g_pfnVectors: .thumb_set DMA1_Stream2_IRQHandler,Default_Handler .weak DMA1_Stream3_IRQHandler - .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler .weak DMA1_Stream4_IRQHandler .thumb_set DMA1_Stream4_IRQHandler,Default_Handler @@ -432,7 +432,7 @@ g_pfnVectors: .weak SPI3_IRQHandler .thumb_set SPI3_IRQHandler,Default_Handler - + .weak UART4_IRQHandler .thumb_set UART4_IRQHandler,Default_Handler diff --git a/panda/board/startup_stm32f413xx.s b/panda/board/stm32fx/startup_stm32f413xx.s similarity index 97% rename from panda/board/startup_stm32f413xx.s rename to panda/board/stm32fx/startup_stm32f413xx.s index 00b645d11b098b..6e6fb5ffa58bc5 100644 --- a/panda/board/startup_stm32f413xx.s +++ b/panda/board/stm32fx/startup_stm32f413xx.s @@ -4,7 +4,7 @@ * @author MCD Application Team * @version V2.6.0 * @date 04-November-2016 - * @brief STM32F413xx Devices vector table for GCC based toolchains. + * @brief STM32F413xx Devices vector table for GCC based toolchains. * This module performs: * - Set the initial SP * - Set the initial PC == Reset_Handler, @@ -42,7 +42,7 @@ * ****************************************************************************** */ - + .syntax unified .cpu cortex-m4 .fpu softvfp @@ -51,7 +51,7 @@ .global g_pfnVectors .global Default_Handler -/* start address for the initialization values of the .data section. +/* start address for the initialization values of the .data section. defined in linker script */ .word _sidata /* start address for the .data section. defined in linker script */ @@ -68,7 +68,7 @@ defined in linker script */ * @brief This is the code that gets called when the processor first * starts execution following a reset event. Only the absolutely * necessary set is performed, after which the application - * supplied main() routine is called. + * supplied main() routine is called. * @param None * @retval : None */ @@ -76,7 +76,7 @@ defined in linker script */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function -Reset_Handler: +Reset_Handler: ldr sp, =_estack /* set stack pointer */ bl __initialize_hardware_early @@ -89,7 +89,7 @@ CopyDataInit: ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4 - + LoopCopyDataInit: ldr r0, =_sdata ldr r3, =_edata @@ -102,7 +102,7 @@ LoopCopyDataInit: FillZerobss: movs r3, #0 str r3, [r2], #4 - + LoopFillZerobss: ldr r3, = _ebss cmp r2, r3 @@ -114,15 +114,15 @@ LoopFillZerobss: /* bl __libc_init_array */ /* Call the application's entry point.*/ bl main - bx lr + bx lr .size Reset_Handler, .-Reset_Handler /** - * @brief This is the code that gets called when the processor receives an + * @brief This is the code that gets called when the processor receives an * unexpected interrupt. This simply enters an infinite loop, preserving * the system state for examination by a debugger. - * @param None - * @retval None + * @param None + * @retval None */ .section .text.Default_Handler,"ax",%progbits Default_Handler: @@ -134,12 +134,12 @@ Infinite_Loop: * The minimal vector table for a Cortex M3. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. -* +* *******************************************************************************/ .section .isr_vector,"a",%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors - + g_pfnVectors: .word _estack .word Reset_Handler @@ -261,11 +261,11 @@ g_pfnVectors: .word DFSDM2_FLT1_IRQHandler /* DFSDM2 Filter1 */ .word DFSDM2_FLT2_IRQHandler /* DFSDM2 Filter2 */ .word DFSDM2_FLT3_IRQHandler /* DFSDM2 Filter3 */ - + /******************************************************************************* * -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override * this definition. * *******************************************************************************/ @@ -277,7 +277,7 @@ g_pfnVectors: .weak MemManage_Handler .thumb_set MemManage_Handler,Default_Handler - + .weak BusFault_Handler .thumb_set BusFault_Handler,Default_Handler @@ -321,7 +321,7 @@ g_pfnVectors: .thumb_set EXTI1_IRQHandler,Default_Handler .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler + .thumb_set EXTI2_IRQHandler,Default_Handler .weak EXTI3_IRQHandler .thumb_set EXTI3_IRQHandler,Default_Handler @@ -439,9 +439,9 @@ g_pfnVectors: .weak DMA1_Stream7_IRQHandler .thumb_set DMA1_Stream7_IRQHandler,Default_Handler - + .weak FSMC_IRQHandler - .thumb_set FSMC_IRQHandler,Default_Handler + .thumb_set FSMC_IRQHandler,Default_Handler .weak SDIO_IRQHandler .thumb_set SDIO_IRQHandler,Default_Handler @@ -451,12 +451,12 @@ g_pfnVectors: .weak SPI3_IRQHandler .thumb_set SPI3_IRQHandler,Default_Handler - + .weak UART4_IRQHandler .thumb_set UART4_IRQHandler,Default_Handler .weak UART5_IRQHandler - .thumb_set UART5_IRQHandler,Default_Handler + .thumb_set UART5_IRQHandler,Default_Handler .weak TIM6_DAC_IRQHandler .thumb_set TIM6_DAC_IRQHandler,Default_Handler @@ -517,7 +517,7 @@ g_pfnVectors: .weak I2C3_ER_IRQHandler .thumb_set I2C3_ER_IRQHandler,Default_Handler - + .weak CAN3_TX_IRQHandler .thumb_set CAN3_TX_IRQHandler,Default_Handler @@ -528,26 +528,26 @@ g_pfnVectors: .thumb_set CAN3_RX1_IRQHandler,Default_Handler .weak CAN3_SCE_IRQHandler - .thumb_set CAN3_SCE_IRQHandler,Default_Handler + .thumb_set CAN3_SCE_IRQHandler,Default_Handler .weak RNG_IRQHandler .thumb_set RNG_IRQHandler,Default_Handler .weak FPU_IRQHandler .thumb_set FPU_IRQHandler,Default_Handler - + .weak UART7_IRQHandler .thumb_set UART7_IRQHandler,Default_Handler .weak UART8_IRQHandler - .thumb_set UART8_IRQHandler,Default_Handler + .thumb_set UART8_IRQHandler,Default_Handler .weak SPI4_IRQHandler .thumb_set SPI4_IRQHandler,Default_Handler .weak SPI5_IRQHandler .thumb_set SPI5_IRQHandler,Default_Handler - + .weak SAI1_IRQHandler .thumb_set SAI1_IRQHandler,Default_Handler @@ -555,7 +555,7 @@ g_pfnVectors: .thumb_set UART9_IRQHandler,Default_Handler .weak UART10_IRQHandler - .thumb_set UART10_IRQHandler,Default_Handler + .thumb_set UART10_IRQHandler,Default_Handler .weak QUADSPI_IRQHandler .thumb_set QUADSPI_IRQHandler,Default_Handler @@ -565,7 +565,7 @@ g_pfnVectors: .weak FMPI2C1_ER_IRQHandler .thumb_set FMPI2C1_ER_IRQHandler,Default_Handler - + .weak LPTIM1_IRQHandler .thumb_set LPTIM1_IRQHandler,Default_Handler diff --git a/panda/board/stm32fx/stm32fx_config.h b/panda/board/stm32fx/stm32fx_config.h new file mode 100644 index 00000000000000..8c5ca1c717bfb5 --- /dev/null +++ b/panda/board/stm32fx/stm32fx_config.h @@ -0,0 +1,94 @@ +#ifdef STM32F4 + #include "stm32fx/inc/stm32f4xx.h" + #include "stm32fx/inc/stm32f4xx_hal_gpio_ex.h" + #define MCU_IDCODE 0x463U +#else + #include "stm32fx/inc/stm32f2xx.h" + #include "stm32fx/inc/stm32f2xx_hal_gpio_ex.h" + #define MCU_IDCODE 0x411U +#endif +// from the linker script +#define APP_START_ADDRESS 0x8004000U + +#define CORE_FREQ 96U // in Mhz +//APB1 - 48Mhz, APB2 - 96Mhz +#define APB1_FREQ CORE_FREQ/2U +#define APB2_FREQ CORE_FREQ/1U + +#define BOOTLOADER_ADDRESS 0x1FFF0004U + +// Around (1Mbps / 8 bits/byte / 12 bytes per message) +#define CAN_INTERRUPT_RATE 12000U + +#define MAX_LED_FADE 8192U + +// Threshold voltage (mV) for either of the SBUs to be below before deciding harness is connected +#define HARNESS_CONNECTED_THRESHOLD 2500U + +#define NUM_INTERRUPTS 102U // There are 102 external interrupt sources (see stm32f413.h) + +#define TICK_TIMER_IRQ TIM1_BRK_TIM9_IRQn +#define TICK_TIMER TIM9 + +#define MICROSECOND_TIMER TIM2 + +#define INTERRUPT_TIMER_IRQ TIM6_DAC_IRQn +#define INTERRUPT_TIMER TIM6 + +#define PROVISION_CHUNK_ADDRESS 0x1FFF79E0U +#define DEVICE_SERIAL_NUMBER_ADDRESS 0x1FFF79C0U + +#define CANPACKET_DATA_SIZE_MAX 8U + +#include "can_definitions.h" + +#ifndef BOOTSTUB + #ifdef PANDA + #include "main_declarations.h" + #else + #include "pedal/main_declarations.h" + #endif +#else + #include "bootstub_declarations.h" +#endif + +#include "libc.h" +#include "critical.h" +#include "faults.h" + +#include "drivers/registers.h" +#include "drivers/interrupts.h" +#include "drivers/gpio.h" +#include "stm32fx/peripherals.h" +#include "stm32fx/interrupt_handlers.h" +#include "drivers/timers.h" +#include "stm32fx/lladc.h" +#include "stm32fx/board.h" +#include "stm32fx/clock.h" + +#if !defined (BOOTSTUB) && (defined(PANDA) || defined(PEDAL_USB)) + #include "drivers/uart.h" + #include "stm32fx/lluart.h" +#endif + +#ifdef BOOTSTUB + #include "stm32fx/llflash.h" +#else + #include "stm32fx/llbxcan.h" +#endif + +#if defined(PANDA) || defined(BOOTSTUB) || defined(PEDAL_USB) + #include "stm32fx/llusb.h" +#endif + +#ifdef PEDAL + #include "stm32fx/lldac.h" +#endif + +void early_gpio_float(void) { + RCC->AHB1ENR = RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN | RCC_AHB1ENR_GPIOCEN; + + GPIOA->MODER = 0; GPIOB->MODER = 0; GPIOC->MODER = 0; + GPIOA->ODR = 0; GPIOB->ODR = 0; GPIOC->ODR = 0; + GPIOA->PUPDR = 0; GPIOB->PUPDR = 0; GPIOC->PUPDR = 0; +} diff --git a/panda/board/stm32fx/stm32fx_flash.ld b/panda/board/stm32fx/stm32fx_flash.ld new file mode 100644 index 00000000000000..bdc23bc8cefab6 --- /dev/null +++ b/panda/board/stm32fx/stm32fx_flash.ld @@ -0,0 +1,165 @@ +/* +***************************************************************************** +** +** File : stm32f4_flash.ld +** +** Abstract : Linker script for STM32F407VG Device with +** 1024KByte FLASH, 192KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Environment : Atollic TrueSTUDIO(R) +** +** Distribution: The file is distributed "as is," without any warranty +** of any kind. +** +** (c)Copyright Atollic AB. +** You may use this file as-is or modify it according to the needs of your +** project. Distribution of this file (unmodified or modified) is not +** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the +** rights to distribute the assembled, compiled & linked contents of this +** file as part of an application binary file, provided that it is built +** using the Atollic TrueSTUDIO(R) toolchain. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +enter_bootloader_mode = 0x2001FFFC; +_estack = 0x2001FFFC; /* end of 128K RAM on AHB bus*/ +_app_start = 0x08004000; /* Reserve Sector 0(16K) for bootloader */ + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + _exit = .; + } >FLASH + + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array*)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = .; + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : AT ( _sidata ) + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM + + /* MEMORY_bank1 section, code must be located here explicitly */ + /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ + .memory_b1_text : + { + *(.mb1text) /* .mb1text sections (code) */ + *(.mb1text*) /* .mb1text* sections (code) */ + *(.mb1rodata) /* read-only data (constants) */ + *(.mb1rodata*) + } >MEMORY_B1 + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/panda/board/stm32h7/board.h b/panda/board/stm32h7/board.h new file mode 100644 index 00000000000000..769e9789e7c25a --- /dev/null +++ b/panda/board/stm32h7/board.h @@ -0,0 +1,36 @@ +// ///////////////////////////////////////////////////////////// // +// Hardware abstraction layer for all different supported boards // +// ///////////////////////////////////////////////////////////// // +#include "boards/board_declarations.h" +#include "boards/unused_funcs.h" + +// ///// Board definition and detection ///// // +#include "drivers/harness.h" +#include "drivers/fan.h" +#include "stm32h7/llfan.h" +#include "stm32h7/llrtc.h" +#include "drivers/rtc.h" +#include "boards/red.h" + +uint8_t board_id(void) { + return detect_with_pull(GPIOF, 7, PULL_UP) | + (detect_with_pull(GPIOF, 8, PULL_UP) << 1U) | + (detect_with_pull(GPIOF, 9, PULL_UP) << 2U) | + (detect_with_pull(GPIOF, 10, PULL_UP) << 3U); +} + +void detect_board_type(void) { + if(board_id() == 0U){ + hw_type = HW_TYPE_RED_PANDA; + current_board = &board_red; + } else { + hw_type = HW_TYPE_UNKNOWN; + puts("Hardware type is UNKNOWN!\n"); + } +} + +bool has_external_debug_serial = 0; +void detect_external_debug_serial(void) { + // detect if external serial debugging is present + has_external_debug_serial = detect_with_pull(GPIOA, 3, PULL_DOWN); +} diff --git a/panda/board/stm32h7/clock.h b/panda/board/stm32h7/clock.h new file mode 100644 index 00000000000000..10febe15a6e688 --- /dev/null +++ b/panda/board/stm32h7/clock.h @@ -0,0 +1,55 @@ +void clock_init(void) { + //Set power mode to direct SMPS power supply(depends on the board layout) + register_set(&(PWR->CR3), PWR_CR3_SMPSEN, 0xFU); // powered only by SMPS + //Set VOS level (VOS3 to 170Mhz, VOS2 to 300Mhz, VOS1 to 400Mhz, VOS0 to 550Mhz) + register_set(&(PWR->D3CR), PWR_D3CR_VOS_1 | PWR_D3CR_VOS_0, 0xC000U); //VOS1, needed for 80Mhz CAN FD + while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0); + while ((PWR->CSR1 & PWR_CSR1_ACTVOS) != (PWR->D3CR & PWR_D3CR_VOS)); // check that VOS level was actually set + // Configure Flash ACR register LATENCY and WRHIGHFREQ (VOS0 range!) + register_set(&(FLASH->ACR), FLASH_ACR_LATENCY_2WS | 0x20U, 0x3FU); // VOS2, AXI 100MHz-150MHz + // enable external oscillator HSE + register_set_bits(&(RCC->CR), RCC_CR_HSEON); + while ((RCC->CR & RCC_CR_HSERDY) == 0); + // enable internal HSI48 for USB FS kernel + register_set_bits(&(RCC->CR), RCC_CR_HSI48ON); + while ((RCC->CR & RCC_CR_HSI48RDY) == 0); + // Specify the frequency source for PLL1, divider for DIVM1, DIVM2, DIVM3 : HSE, 5, 5, 5 + register_set(&(RCC->PLLCKSELR), RCC_PLLCKSELR_PLLSRC_HSE | RCC_PLLCKSELR_DIVM1_0 | RCC_PLLCKSELR_DIVM1_2 | RCC_PLLCKSELR_DIVM2_0 | RCC_PLLCKSELR_DIVM2_2 | RCC_PLLCKSELR_DIVM3_0 | RCC_PLLCKSELR_DIVM3_2, 0x3F3F3F3U); + + // *** PLL1 start *** + // Specify multiplier N and dividers P, Q, R for PLL1 : 48, 1, 3, 2 (clock 240Mhz, PLL1Q 80Mhz for CAN FD) + register_set(&(RCC->PLL1DIVR), 0x102002FU, 0x7F7FFFFFU); + // Specify the input and output frequency ranges, enable dividers for PLL1 + register_set(&(RCC->PLLCFGR), RCC_PLLCFGR_PLL1RGE_2 | RCC_PLLCFGR_DIVP1EN | RCC_PLLCFGR_DIVQ1EN | RCC_PLLCFGR_DIVR1EN, 0x7000CU); + // Enable PLL1 + register_set_bits(&(RCC->CR), RCC_CR_PLL1ON); + while((RCC->CR & RCC_CR_PLL1RDY) == 0); + // *** PLL1 end *** + + //////////////OTHER CLOCKS//////////////////// + // RCC HCLK Clock Source / RCC APB3 Clock Source / RCC SYS Clock Source + register_set(&(RCC->D1CFGR), RCC_D1CFGR_HPRE_DIV2 | RCC_D1CFGR_D1PPRE_DIV2 | RCC_D1CFGR_D1CPRE_DIV1, 0xF7FU); + // RCC APB1 Clock Source / RCC APB2 Clock Source + register_set(&(RCC->D2CFGR), RCC_D2CFGR_D2PPRE1_DIV2 | RCC_D2CFGR_D2PPRE2_DIV2, 0x770U); + // RCC APB4 Clock Source + register_set(&(RCC->D3CFGR), RCC_D3CFGR_D3PPRE_DIV2, 0x70U); + + // Set SysClock source to PLL + register_set(&(RCC->CFGR), RCC_CFGR_SW_PLL1, 0x7U); + while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL1); + + // SYSCFG peripheral clock enable + register_set_bits(&(RCC->AHB4ENR), RCC_APB4ENR_SYSCFGEN); + //////////////END OTHER CLOCKS//////////////////// + + // Configure clock source for USB (HSI at 48Mhz) + register_set(&(RCC->D2CCIP2R), RCC_D2CCIP2R_USBSEL_1 | RCC_D2CCIP2R_USBSEL_0, RCC_D2CCIP2R_USBSEL); + // Configure clock source for FDCAN (PLL1Q at 80Mhz) + register_set(&(RCC->D2CCIP1R), RCC_D2CCIP1R_FDCANSEL_0, RCC_D2CCIP1R_FDCANSEL); + // Configure clock source for ADC1,2,3 (per_ck(currently HSE)) + register_set(&(RCC->D3CCIPR), RCC_D3CCIPR_ADCSEL_1, RCC_D3CCIPR_ADCSEL); + //Enable the Clock Security System + register_set_bits(&(RCC->CR), RCC_CR_CSSHSEON); + //Enable Vdd33usb supply level detector + register_set_bits(&(PWR->CR3), PWR_CR3_USB33DEN); +} diff --git a/panda/board/stm32h7/inc/cmsis_compiler.h b/panda/board/stm32h7/inc/cmsis_compiler.h new file mode 100644 index 00000000000000..d0f39eef67ed91 --- /dev/null +++ b/panda/board/stm32h7/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/stm32h7/inc/cmsis_gcc.h b/panda/board/stm32h7/inc/cmsis_gcc.h new file mode 100644 index 00000000000000..2f68473f64e216 --- /dev/null +++ b/panda/board/stm32h7/inc/cmsis_gcc.h @@ -0,0 +1,2169 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS compiler GCC header file + * @version V5.2.0 + * @date 08. May 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. + */ + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#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 + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#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 + */ +__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 + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__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) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__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_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__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) +{ + uint32_t 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) : ); +} + + +#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 + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + 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 + */ +__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_ns" : "=r" (result) :: "memory"); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#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. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#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 + */ +__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_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#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 + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#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)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__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; + + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + return(result); +#endif +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__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 +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * 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 + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#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. + */ +#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. + */ +#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. + */ +#define __SEV() __ASM volatile ("sev") + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__STATIC_FORCEINLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__STATIC_FORCEINLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__STATIC_FORCEINLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \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 + */ +__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; +} + + +/** + \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 + */ +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (int16_t)__builtin_bswap16(value); +#else + int16_t result; + + __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \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] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#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 + 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 != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return result; +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__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 ((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) + */ +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#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 ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#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 ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR 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 __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR 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 __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR 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 __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__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] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1,ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \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) ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__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" (*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" (ptr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__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" (*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" (ptr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__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) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); +} + + +/** + \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 */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#if 0 +#define __PKHBT(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __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) ) + +#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; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#pragma GCC diagnostic pop + +#endif /* __CMSIS_GCC_H */ + diff --git a/panda/board/stm32h7/inc/cmsis_version.h b/panda/board/stm32h7/inc/cmsis_version.h new file mode 100644 index 00000000000000..bf57cf3e805348 --- /dev/null +++ b/panda/board/stm32h7/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/stm32h7/inc/core_cm7.h b/panda/board/stm32h7/inc/core_cm7.h new file mode 100644 index 00000000000000..3da3c43e40e18f --- /dev/null +++ b/panda/board/stm32h7/inc/core_cm7.h @@ -0,0 +1,2725 @@ +/**************************************************************************//** + * @file core_cm7.h + * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File + * @version V5.1.1 + * @date 28. March 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 __CORE_CM7_H_GENERIC +#define __CORE_CM7_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
    + Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
    + Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
    + Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M7 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM7 definitions */ +#define __CM7_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM7_CMSIS_VERSION_SUB ( __CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ + __CM7_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (7U) /*!< 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 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)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#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)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #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)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #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)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #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)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #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)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #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)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM7_H_DEPENDANT +#define __CORE_CM7_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM7_REV + #define __CM7_REV 0x0000U + #warning "__CM7_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DTCM_PRESENT + #define __DTCM_PRESENT 0U + #warning "__DTCM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M7 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + 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 */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + 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 */ + 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 */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q 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_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 */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +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 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 */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[1U]; + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED3[93U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + uint32_t RESERVED7[6U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x290 (R/W) Instruction Tightly-Coupled Memory Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x294 (R/W) Data Tightly-Coupled Memory Control Registers */ + __IOM uint32_t AHBPCR; /*!< Offset: 0x298 (R/W) AHBP Control Register */ + __IOM uint32_t CACR; /*!< Offset: 0x29C (R/W) L1 Cache Control Register */ + __IOM uint32_t AHBSCR; /*!< Offset: 0x2A0 (R/W) AHB Slave Control Register */ + uint32_t RESERVED8[1U]; + __IOM uint32_t ABFSR; /*!< Offset: 0x2A8 (R/W) Auxiliary Bus Fault Status Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: Branch prediction enable bit Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: Branch prediction enable bit Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: Instruction cache enable bit Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: Instruction cache enable bit Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: Cache enable bit Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: Cache enable bit Mask */ + +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#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 */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/* Instruction Tightly-Coupled Memory Control Register Definitions */ +#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ +#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ + +#define SCB_ITCMCR_RETEN_Pos 2U /*!< SCB ITCMCR: RETEN Position */ +#define SCB_ITCMCR_RETEN_Msk (1UL << SCB_ITCMCR_RETEN_Pos) /*!< SCB ITCMCR: RETEN Mask */ + +#define SCB_ITCMCR_RMW_Pos 1U /*!< SCB ITCMCR: RMW Position */ +#define SCB_ITCMCR_RMW_Msk (1UL << SCB_ITCMCR_RMW_Pos) /*!< SCB ITCMCR: RMW Mask */ + +#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ +#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ + +/* Data Tightly-Coupled Memory Control Register Definitions */ +#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ +#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ + +#define SCB_DTCMCR_RETEN_Pos 2U /*!< SCB DTCMCR: RETEN Position */ +#define SCB_DTCMCR_RETEN_Msk (1UL << SCB_DTCMCR_RETEN_Pos) /*!< SCB DTCMCR: RETEN Mask */ + +#define SCB_DTCMCR_RMW_Pos 1U /*!< SCB DTCMCR: RMW Position */ +#define SCB_DTCMCR_RMW_Msk (1UL << SCB_DTCMCR_RMW_Pos) /*!< SCB DTCMCR: RMW Mask */ + +#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ +#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ + +/* AHBP Control Register Definitions */ +#define SCB_AHBPCR_SZ_Pos 1U /*!< SCB AHBPCR: SZ Position */ +#define SCB_AHBPCR_SZ_Msk (7UL << SCB_AHBPCR_SZ_Pos) /*!< SCB AHBPCR: SZ Mask */ + +#define SCB_AHBPCR_EN_Pos 0U /*!< SCB AHBPCR: EN Position */ +#define SCB_AHBPCR_EN_Msk (1UL /*<< SCB_AHBPCR_EN_Pos*/) /*!< SCB AHBPCR: EN Mask */ + +/* L1 Cache Control Register Definitions */ +#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ +#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ + +#define SCB_CACR_ECCEN_Pos 1U /*!< SCB CACR: ECCEN Position */ +#define SCB_CACR_ECCEN_Msk (1UL << SCB_CACR_ECCEN_Pos) /*!< SCB CACR: ECCEN Mask */ + +#define SCB_CACR_SIWT_Pos 0U /*!< SCB CACR: SIWT Position */ +#define SCB_CACR_SIWT_Msk (1UL /*<< SCB_CACR_SIWT_Pos*/) /*!< SCB CACR: SIWT Mask */ + +/* AHBS Control Register Definitions */ +#define SCB_AHBSCR_INITCOUNT_Pos 11U /*!< SCB AHBSCR: INITCOUNT Position */ +#define SCB_AHBSCR_INITCOUNT_Msk (0x1FUL << SCB_AHBPCR_INITCOUNT_Pos) /*!< SCB AHBSCR: INITCOUNT Mask */ + +#define SCB_AHBSCR_TPRI_Pos 2U /*!< SCB AHBSCR: TPRI Position */ +#define SCB_AHBSCR_TPRI_Msk (0x1FFUL << SCB_AHBPCR_TPRI_Pos) /*!< SCB AHBSCR: TPRI Mask */ + +#define SCB_AHBSCR_CTL_Pos 0U /*!< SCB AHBSCR: CTL Position*/ +#define SCB_AHBSCR_CTL_Msk (3UL /*<< SCB_AHBPCR_CTL_Pos*/) /*!< SCB AHBSCR: CTL Mask */ + +/* Auxiliary Bus Fault Status Register Definitions */ +#define SCB_ABFSR_AXIMTYPE_Pos 8U /*!< SCB ABFSR: AXIMTYPE Position*/ +#define SCB_ABFSR_AXIMTYPE_Msk (3UL << SCB_ABFSR_AXIMTYPE_Pos) /*!< SCB ABFSR: AXIMTYPE Mask */ + +#define SCB_ABFSR_EPPB_Pos 4U /*!< SCB ABFSR: EPPB Position*/ +#define SCB_ABFSR_EPPB_Msk (1UL << SCB_ABFSR_EPPB_Pos) /*!< SCB ABFSR: EPPB Mask */ + +#define SCB_ABFSR_AXIM_Pos 3U /*!< SCB ABFSR: AXIM Position*/ +#define SCB_ABFSR_AXIM_Msk (1UL << SCB_ABFSR_AXIM_Pos) /*!< SCB ABFSR: AXIM Mask */ + +#define SCB_ABFSR_AHBP_Pos 2U /*!< SCB ABFSR: AHBP Position*/ +#define SCB_ABFSR_AHBP_Msk (1UL << SCB_ABFSR_AHBP_Pos) /*!< SCB ABFSR: AHBP Mask */ + +#define SCB_ABFSR_DTCM_Pos 1U /*!< SCB ABFSR: DTCM Position*/ +#define SCB_ABFSR_DTCM_Msk (1UL << SCB_ABFSR_DTCM_Pos) /*!< SCB ABFSR: DTCM Mask */ + +#define SCB_ABFSR_ITCM_Pos 0U /*!< SCB ABFSR: ITCM Position*/ +#define SCB_ABFSR_ITCM_Msk (1UL /*<< SCB_ABFSR_ITCM_Pos*/) /*!< SCB ABFSR: ITCM Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISDYNADD_Pos 26U /*!< ACTLR: DISDYNADD Position */ +#define SCnSCB_ACTLR_DISDYNADD_Msk (1UL << SCnSCB_ACTLR_DISDYNADD_Pos) /*!< ACTLR: DISDYNADD Mask */ + +#define SCnSCB_ACTLR_DISISSCH1_Pos 21U /*!< ACTLR: DISISSCH1 Position */ +#define SCnSCB_ACTLR_DISISSCH1_Msk (0x1FUL << SCnSCB_ACTLR_DISISSCH1_Pos) /*!< ACTLR: DISISSCH1 Mask */ + +#define SCnSCB_ACTLR_DISDI_Pos 16U /*!< ACTLR: DISDI Position */ +#define SCnSCB_ACTLR_DISDI_Msk (0x1FUL << SCnSCB_ACTLR_DISDI_Pos) /*!< ACTLR: DISDI Mask */ + +#define SCnSCB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define SCnSCB_ACTLR_DISCRITAXIRUR_Msk (1UL << SCnSCB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define SCnSCB_ACTLR_DISBTACALLOC_Pos 14U /*!< ACTLR: DISBTACALLOC Position */ +#define SCnSCB_ACTLR_DISBTACALLOC_Msk (1UL << SCnSCB_ACTLR_DISBTACALLOC_Pos) /*!< ACTLR: DISBTACALLOC Mask */ + +#define SCnSCB_ACTLR_DISBTACREAD_Pos 13U /*!< ACTLR: DISBTACREAD Position */ +#define SCnSCB_ACTLR_DISBTACREAD_Msk (1UL << SCnSCB_ACTLR_DISBTACREAD_Pos) /*!< ACTLR: DISBTACREAD Mask */ + +#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (1UL << SCnSCB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define SCnSCB_ACTLR_DISRAMODE_Pos 11U /*!< ACTLR: DISRAMODE Position */ +#define SCnSCB_ACTLR_DISRAMODE_Msk (1UL << SCnSCB_ACTLR_DISRAMODE_Pos) /*!< ACTLR: DISRAMODE Mask */ + +#define SCnSCB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define SCnSCB_ACTLR_FPEXCODIS_Msk (1UL << SCnSCB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __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[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 */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#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 */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#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 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 */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED3[981U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( W) Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __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 */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __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 Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* 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 (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 (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 */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#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 (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 (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 */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#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 (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#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 defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __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 */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __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 */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#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 */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \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. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#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. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* 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 */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#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 + +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#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. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + 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) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + 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 << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \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) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \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 uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + 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 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) +{ + 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 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) +{ + 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 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) +{ + 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 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) +{ + 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 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) +{ + 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 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) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \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) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \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; + __DSB(); +} + + +/** + \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. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} 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 = SCB->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else 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 */ + + + +/* ########################## Cache functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_CacheFunctions Cache Functions + \brief Functions that configure Instruction and Data cache. + @{ + */ + +/* Cache Size ID Register Macros */ +#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) +#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) + +#define __SCB_DCACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#define __SCB_ICACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */ + + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate I-Cache + \details Invalidates I-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief I-Cache Invalidate by address + \details Invalidates I-Cache for the given address. + I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + I-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] isize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (void *addr, int32_t isize) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if ( isize > 0 ) { + int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_ICACHE_LINE_SIZE; + op_size -= __SCB_ICACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */ + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + __DSB(); + + SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable D-Cache + \details Turns off D-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | + ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address. + D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned and invalidated. + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + +/*@} end of CMSIS_Core_CacheFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +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. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/panda/board/stm32h7/inc/mpu_armv8.h b/panda/board/stm32h7/inc/mpu_armv8.h new file mode 100644 index 00000000000000..2fe28b687f2276 --- /dev/null +++ b/panda/board/stm32h7/inc/mpu_armv8.h @@ -0,0 +1,346 @@ +/****************************************************************************** + * @file mpu_armv8.h + * @brief CMSIS MPU API for Armv8-M and Armv8.1-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_ARMV8_H +#define ARM_MPU_ARMV8_H + +/** \brief Attribute for device memory (outer only) */ +#define ARM_MPU_ATTR_DEVICE ( 0U ) + +/** \brief Attribute for non-cacheable, normal memory */ +#define ARM_MPU_ATTR_NON_CACHEABLE ( 4U ) + +/** \brief Attribute for normal memory (outer and inner) +* \param NT Non-Transient: Set to 1 for non-transient data. +* \param WB Write-Back: Set to 1 to use write-back update policy. +* \param RA Read Allocation: Set to 1 to use cache allocation on read miss. +* \param WA Write Allocation: Set to 1 to use cache allocation on write miss. +*/ +#define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \ + (((NT & 1U) << 3U) | ((WB & 1U) << 2U) | ((RA & 1U) << 1U) | (WA & 1U)) + +/** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRnE (0U) + +/** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRE (1U) + +/** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGRE (2U) + +/** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_GRE (3U) + +/** \brief Memory Attribute +* \param O Outer memory attributes +* \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes +*/ +#define ARM_MPU_ATTR(O, I) (((O & 0xFU) << 4U) | (((O & 0xFU) != 0U) ? (I & 0xFU) : ((I & 0x3U) << 2U))) + +/** \brief Normal memory non-shareable */ +#define ARM_MPU_SH_NON (0U) + +/** \brief Normal memory outer shareable */ +#define ARM_MPU_SH_OUTER (2U) + +/** \brief Normal memory inner shareable */ +#define ARM_MPU_SH_INNER (3U) + +/** \brief Memory access permissions +* \param RO Read-Only: Set to 1 for read-only memory. +* \param NP Non-Privileged: Set to 1 for non-privileged memory. +*/ +#define ARM_MPU_AP_(RO, NP) (((RO & 1U) << 1U) | (NP & 1U)) + +/** \brief Region Base Address Register value +* \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned. +* \param SH Defines the Shareability domain for this memory region. +* \param RO Read-Only: Set to 1 for a read-only memory region. +* \param NP Non-Privileged: Set to 1 for a non-privileged memory region. +* \oaram XN eXecute Never: Set to 1 for a non-executable memory region. +*/ +#define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \ + ((BASE & MPU_RBAR_BASE_Msk) | \ + ((SH << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \ + ((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \ + ((XN << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk)) + +/** \brief Region Limit Address Register value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR(LIMIT, IDX) \ + ((LIMIT & MPU_RLAR_LIMIT_Msk) | \ + ((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#if defined(MPU_RLAR_PXN_Pos) + +/** \brief Region Limit Address Register with PXN value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param PXN Privileged execute never. Defines whether code can be executed from this privileged region. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR_PXN(LIMIT, PXN, IDX) \ + ((LIMIT & MPU_RLAR_LIMIT_Msk) | \ + ((PXN << MPU_RLAR_PXN_Pos) & MPU_RLAR_PXN_Msk) | \ + ((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#endif + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; /*!< Region Base Address Register value */ + uint32_t RLAR; /*!< Region Limit Address Register value */ +} 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; +} + +#ifdef MPU_NS +/** Enable the Non-secure MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control) +{ + MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the Non-secure MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable_NS(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk; +} +#endif + +/** Set the memory attribute encoding to the given MPU. +* \param mpu Pointer to the MPU to be configured. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr) +{ + const uint8_t reg = idx / 4U; + const uint32_t pos = ((idx % 4U) * 8U); + const uint32_t mask = 0xFFU << pos; + + if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) { + return; // invalid index + } + + mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask)); +} + +/** Set the memory attribute encoding. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU, idx, attr); +} + +#ifdef MPU_NS +/** Set the memory attribute encoding to the Non-secure MPU. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr); +} +#endif + +/** Clear and disable the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr) +{ + mpu->RNR = rnr; + mpu->RLAR = 0U; +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU, rnr); +} + +#ifdef MPU_NS +/** Clear and disable the given Non-secure MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU_NS, rnr); +} +#endif + +/** Configure the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + mpu->RNR = rnr; + mpu->RBAR = rbar; + mpu->RLAR = rlar; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar); +} + +#ifdef MPU_NS +/** Configure the given Non-secure MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar); +} +#endif + +/** 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 to the given MPU. +* \param mpu Pointer to the MPU registers to be used. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + if (cnt == 1U) { + mpu->RNR = rnr; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR), &(table->RBAR), rowWordSize); + } else { + uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U); + uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES; + + mpu->RNR = rnrBase; + while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) { + uint32_t c = MPU_TYPE_RALIASES - rnrOffset; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize); + table += c; + cnt -= c; + rnrOffset = 0U; + rnrBase += MPU_TYPE_RALIASES; + mpu->RNR = rnrBase; + } + + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize); + } +} + +/** Load the given number of MPU regions from a table. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU, rnr, table, cnt); +} + +#ifdef MPU_NS +/** Load the given number of MPU regions from a table to the Non-secure MPU. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt); +} +#endif + +#endif + diff --git a/panda/board/stm32h7/inc/stm32h725xx.h b/panda/board/stm32h7/inc/stm32h725xx.h new file mode 100644 index 00000000000000..0631daac0d306f --- /dev/null +++ b/panda/board/stm32h7/inc/stm32h725xx.h @@ -0,0 +1,24740 @@ +/** + ****************************************************************************** + * @file stm32h735xx.h + * @author MCD Application Team + * @brief CMSIS STM32H735xx Device Peripheral Access Layer Header File. + * + * This file contains: + * - Data structures and the address mapping for all peripherals + * - Peripheral's registers declarations and bits definition + * - Macros to access peripheral's registers hardware + * + ****************************************************************************** + * @attention + * + *

    © Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

    + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS_Device + * @{ + */ + +/** @addtogroup stm32h735xx + * @{ + */ + +#ifndef STM32H735xx_H +#define STM32H735xx_H + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + +/** @addtogroup Peripheral_interrupt_number_definition + * @{ + */ + +/** + * @brief STM32H7XX Interrupt Number Definition, according to the selected device + * in @ref Library_configuration_section + */ +typedef enum +{ +/****** Cortex-M Processor Exceptions Numbers *****************************************************************/ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ + HardFault_IRQn = -13, /*!< 4 Cortex-M Memory Management Interrupt */ + MemoryManagement_IRQn = -12, /*!< 4 Cortex-M Memory Management Interrupt */ + BusFault_IRQn = -11, /*!< 5 Cortex-M Bus Fault Interrupt */ + UsageFault_IRQn = -10, /*!< 6 Cortex-M Usage Fault Interrupt */ + SVCall_IRQn = -5, /*!< 11 Cortex-M SV Call Interrupt */ + DebugMonitor_IRQn = -4, /*!< 12 Cortex-M Debug Monitor Interrupt */ + PendSV_IRQn = -2, /*!< 14 Cortex-M Pend SV Interrupt */ + SysTick_IRQn = -1, /*!< 15 Cortex-M System Tick Interrupt */ +/****** STM32 specific Interrupt Numbers **********************************************************************/ + WWDG_IRQn = 0, /*!< Window WatchDog Interrupt ( wwdg1_it, wwdg2_it) */ + PVD_AVD_IRQn = 1, /*!< PVD/AVD through EXTI Line detection Interrupt */ + TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ + RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ + FLASH_IRQn = 4, /*!< FLASH global Interrupt */ + RCC_IRQn = 5, /*!< RCC global Interrupt */ + EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ + EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ + EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ + EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ + EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ + DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ + DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ + DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ + DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ + DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ + DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ + DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ + ADC_IRQn = 18, /*!< ADC1 and ADC2 global Interrupts */ + FDCAN1_IT0_IRQn = 19, /*!< FDCAN1 Interrupt line 0 */ + FDCAN2_IT0_IRQn = 20, /*!< FDCAN2 Interrupt line 0 */ + FDCAN1_IT1_IRQn = 21, /*!< FDCAN1 Interrupt line 1 */ + FDCAN2_IT1_IRQn = 22, /*!< FDCAN2 Interrupt line 1 */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ + TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ + TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ + TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ + TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ + TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ + TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ + DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ + FMC_IRQn = 48, /*!< FMC global Interrupt */ + SDMMC1_IRQn = 49, /*!< SDMMC1 global Interrupt */ + TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ + SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ + UART4_IRQn = 52, /*!< UART4 global Interrupt */ + UART5_IRQn = 53, /*!< UART5 global Interrupt */ + TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ + TIM7_IRQn = 55, /*!< TIM7 global interrupt */ + DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ + DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ + DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ + DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ + DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ + ETH_IRQn = 61, /*!< Ethernet global Interrupt */ + ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */ + FDCAN_CAL_IRQn = 63, /*!< FDCAN Calibration unit Interrupt */ + DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ + DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ + DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ + USART6_IRQn = 71, /*!< USART6 global interrupt */ + I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ + I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ + OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ + OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ + OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ + OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ + DCMI_PSSI_IRQn = 78, /*!< DCMI and PSSI global interrupt */ + CRYP_IRQn = 79, /*!< CRYP crypto global interrupt */ + HASH_RNG_IRQn = 80, /*!< HASH and RNG global interrupt */ + FPU_IRQn = 81, /*!< FPU global interrupt */ + UART7_IRQn = 82, /*!< UART7 global interrupt */ + UART8_IRQn = 83, /*!< UART8 global interrupt */ + SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ + SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ + SPI6_IRQn = 86, /*!< SPI6 global Interrupt */ + SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ + LTDC_IRQn = 88, /*!< LTDC global Interrupt */ + LTDC_ER_IRQn = 89, /*!< LTDC Error global Interrupt */ + DMA2D_IRQn = 90, /*!< DMA2D global Interrupt */ + OCTOSPI1_IRQn = 92, /*!< OCTOSPI1 global interrupt */ + LPTIM1_IRQn = 93, /*!< LP TIM1 interrupt */ + CEC_IRQn = 94, /*!< HDMI-CEC global Interrupt */ + I2C4_EV_IRQn = 95, /*!< I2C4 Event Interrupt */ + I2C4_ER_IRQn = 96, /*!< I2C4 Error Interrupt */ + SPDIF_RX_IRQn = 97, /*!< SPDIF-RX global Interrupt */ + DMAMUX1_OVR_IRQn = 102, /*! + +/** @addtogroup Peripheral_registers_structures + * @{ + */ + +/** + * @brief Analog to Digital Converter + */ + +typedef struct +{ + __IO uint32_t ISR; /*!< ADC Interrupt and Status Register, Address offset: 0x00 */ + __IO uint32_t IER; /*!< ADC Interrupt Enable Register, Address offset: 0x04 */ + __IO uint32_t CR; /*!< ADC control register, Address offset: 0x08 */ + __IO uint32_t CFGR; /*!< ADC Configuration register, Address offset: 0x0C */ + __IO uint32_t CFGR2; /*!< ADC Configuration register 2, Address offset: 0x10 */ + __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x14 */ + __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x18 */ + __IO uint32_t PCSEL_RES0; /*!< Rserved for ADC3, ADC1/2 pre-channel selection, Address offset: 0x1C */ + __IO uint32_t LTR1_TR1; /*!< ADC watchdog Lower threshold register 1, Address offset: 0x20 */ + __IO uint32_t HTR1_TR2; /*!< ADC watchdog higher threshold register 1, Address offset: 0x24 */ + __IO uint32_t RES1_TR3; /*!< Rserved for ADC1/2, ADC3 threshold register, Address offset: 0x28 */ + uint32_t RESERVED2; /*!< Reserved, 0x02C */ + __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x30 */ + __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x34 */ + __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x38 */ + __IO uint32_t SQR4; /*!< ADC regular sequence register 4, Address offset: 0x3C */ + __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x40 */ + uint32_t RESERVED3; /*!< Reserved, 0x044 */ + uint32_t RESERVED4; /*!< Reserved, 0x048 */ + __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x4C */ + uint32_t RESERVED5[4]; /*!< Reserved, 0x050 - 0x05C */ + __IO uint32_t OFR1; /*!< ADC offset register 1, Address offset: 0x60 */ + __IO uint32_t OFR2; /*!< ADC offset register 2, Address offset: 0x64 */ + __IO uint32_t OFR3; /*!< ADC offset register 3, Address offset: 0x68 */ + __IO uint32_t OFR4; /*!< ADC offset register 4, Address offset: 0x6C */ + uint32_t RESERVED6[4]; /*!< Reserved, 0x070 - 0x07C */ + __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x80 */ + __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x84 */ + __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x88 */ + __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x8C */ + uint32_t RESERVED7[4]; /*!< Reserved, 0x090 - 0x09C */ + __IO uint32_t AWD2CR; /*!< ADC Analog Watchdog 2 Configuration Register, Address offset: 0xA0 */ + __IO uint32_t AWD3CR; /*!< ADC Analog Watchdog 3 Configuration Register, Address offset: 0xA4 */ + uint32_t RESERVED8; /*!< Reserved, 0x0A8 */ + uint32_t RESERVED9; /*!< Reserved, 0x0AC */ + __IO uint32_t LTR2_DIFSEL; /*!< ADC watchdog Lower threshold register 2, Difsel for ADC3, Address offset: 0xB0 */ + __IO uint32_t HTR2_CALFACT; /*!< ADC watchdog Higher threshold register 2, Calfact for ADC3, Address offset: 0xB4 */ + __IO uint32_t LTR3_RES10; /*!< ADC watchdog Lower threshold register 3, specific ADC1/2, Address offset: 0xB8 */ + __IO uint32_t HTR3_RES11; /*!< ADC watchdog Higher threshold register 3, specific ADC1/2, Address offset: 0xBC */ + __IO uint32_t DIFSEL_RES12; /*!< ADC Differential Mode Selection Register specific ADC1/2, Address offset: 0xC0 */ + __IO uint32_t CALFACT_RES13; /*!< ADC Calibration Factors specific ADC1/2, Address offset: 0xC4 */ + __IO uint32_t CALFACT2_RES14; /*!< ADC Linearity Calibration Factors specific ADC1/2, Address offset: 0xC8 */ +} ADC_TypeDef; + + +typedef struct +{ +__IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1/3 base address + 0x300 */ +uint32_t RESERVED; /*!< Reserved, ADC1/3 base address + 0x304 */ +__IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1/3 base address + 0x308 */ +__IO uint32_t CDR; /*!< ADC common regular data register for dual Address offset: ADC1/3 base address + 0x30C */ +__IO uint32_t CDR2; /*!< ADC common regular data register for 32-bit dual mode Address offset: ADC1/3 base address + 0x310 */ + +} ADC_Common_TypeDef; + + +/** + * @brief VREFBUF + */ + +typedef struct +{ + __IO uint32_t CSR; /*!< VREFBUF control and status register, Address offset: 0x00 */ + __IO uint32_t CCR; /*!< VREFBUF calibration and control register, Address offset: 0x04 */ +} VREFBUF_TypeDef; + + +/** + * @brief FD Controller Area Network + */ + +typedef struct +{ + __IO uint32_t CREL; /*!< FDCAN Core Release register, Address offset: 0x000 */ + __IO uint32_t ENDN; /*!< FDCAN Endian register, Address offset: 0x004 */ + __IO uint32_t RESERVED1; /*!< Reserved, 0x008 */ + __IO uint32_t DBTP; /*!< FDCAN Data Bit Timing & Prescaler register, Address offset: 0x00C */ + __IO uint32_t TEST; /*!< FDCAN Test register, Address offset: 0x010 */ + __IO uint32_t RWD; /*!< FDCAN RAM Watchdog register, Address offset: 0x014 */ + __IO uint32_t CCCR; /*!< FDCAN CC Control register, Address offset: 0x018 */ + __IO uint32_t NBTP; /*!< FDCAN Nominal Bit Timing & Prescaler register, Address offset: 0x01C */ + __IO uint32_t TSCC; /*!< FDCAN Timestamp Counter Configuration register, Address offset: 0x020 */ + __IO uint32_t TSCV; /*!< FDCAN Timestamp Counter Value register, Address offset: 0x024 */ + __IO uint32_t TOCC; /*!< FDCAN Timeout Counter Configuration register, Address offset: 0x028 */ + __IO uint32_t TOCV; /*!< FDCAN Timeout Counter Value register, Address offset: 0x02C */ + __IO uint32_t RESERVED2[4]; /*!< Reserved, 0x030 - 0x03C */ + __IO uint32_t ECR; /*!< FDCAN Error Counter register, Address offset: 0x040 */ + __IO uint32_t PSR; /*!< FDCAN Protocol Status register, Address offset: 0x044 */ + __IO uint32_t TDCR; /*!< FDCAN Transmitter Delay Compensation register, Address offset: 0x048 */ + __IO uint32_t RESERVED3; /*!< Reserved, 0x04C */ + __IO uint32_t IR; /*!< FDCAN Interrupt register, Address offset: 0x050 */ + __IO uint32_t IE; /*!< FDCAN Interrupt Enable register, Address offset: 0x054 */ + __IO uint32_t ILS; /*!< FDCAN Interrupt Line Select register, Address offset: 0x058 */ + __IO uint32_t ILE; /*!< FDCAN Interrupt Line Enable register, Address offset: 0x05C */ + __IO uint32_t RESERVED4[8]; /*!< Reserved, 0x060 - 0x07C */ + __IO uint32_t GFC; /*!< FDCAN Global Filter Configuration register, Address offset: 0x080 */ + __IO uint32_t SIDFC; /*!< FDCAN Standard ID Filter Configuration register, Address offset: 0x084 */ + __IO uint32_t XIDFC; /*!< FDCAN Extended ID Filter Configuration register, Address offset: 0x088 */ + __IO uint32_t RESERVED5; /*!< Reserved, 0x08C */ + __IO uint32_t XIDAM; /*!< FDCAN Extended ID AND Mask register, Address offset: 0x090 */ + __IO uint32_t HPMS; /*!< FDCAN High Priority Message Status register, Address offset: 0x094 */ + __IO uint32_t NDAT1; /*!< FDCAN New Data 1 register, Address offset: 0x098 */ + __IO uint32_t NDAT2; /*!< FDCAN New Data 2 register, Address offset: 0x09C */ + __IO uint32_t RXF0C; /*!< FDCAN Rx FIFO 0 Configuration register, Address offset: 0x0A0 */ + __IO uint32_t RXF0S; /*!< FDCAN Rx FIFO 0 Status register, Address offset: 0x0A4 */ + __IO uint32_t RXF0A; /*!< FDCAN Rx FIFO 0 Acknowledge register, Address offset: 0x0A8 */ + __IO uint32_t RXBC; /*!< FDCAN Rx Buffer Configuration register, Address offset: 0x0AC */ + __IO uint32_t RXF1C; /*!< FDCAN Rx FIFO 1 Configuration register, Address offset: 0x0B0 */ + __IO uint32_t RXF1S; /*!< FDCAN Rx FIFO 1 Status register, Address offset: 0x0B4 */ + __IO uint32_t RXF1A; /*!< FDCAN Rx FIFO 1 Acknowledge register, Address offset: 0x0B8 */ + __IO uint32_t RXESC; /*!< FDCAN Rx Buffer/FIFO Element Size Configuration register, Address offset: 0x0BC */ + __IO uint32_t TXBC; /*!< FDCAN Tx Buffer Configuration register, Address offset: 0x0C0 */ + __IO uint32_t TXFQS; /*!< FDCAN Tx FIFO/Queue Status register, Address offset: 0x0C4 */ + __IO uint32_t TXESC; /*!< FDCAN Tx Buffer Element Size Configuration register, Address offset: 0x0C8 */ + __IO uint32_t TXBRP; /*!< FDCAN Tx Buffer Request Pending register, Address offset: 0x0CC */ + __IO uint32_t TXBAR; /*!< FDCAN Tx Buffer Add Request register, Address offset: 0x0D0 */ + __IO uint32_t TXBCR; /*!< FDCAN Tx Buffer Cancellation Request register, Address offset: 0x0D4 */ + __IO uint32_t TXBTO; /*!< FDCAN Tx Buffer Transmission Occurred register, Address offset: 0x0D8 */ + __IO uint32_t TXBCF; /*!< FDCAN Tx Buffer Cancellation Finished register, Address offset: 0x0DC */ + __IO uint32_t TXBTIE; /*!< FDCAN Tx Buffer Transmission Interrupt Enable register, Address offset: 0x0E0 */ + __IO uint32_t TXBCIE; /*!< FDCAN Tx Buffer Cancellation Finished Interrupt Enable register, Address offset: 0x0E4 */ + __IO uint32_t RESERVED6[2]; /*!< Reserved, 0x0E8 - 0x0EC */ + __IO uint32_t TXEFC; /*!< FDCAN Tx Event FIFO Configuration register, Address offset: 0x0F0 */ + __IO uint32_t TXEFS; /*!< FDCAN Tx Event FIFO Status register, Address offset: 0x0F4 */ + __IO uint32_t TXEFA; /*!< FDCAN Tx Event FIFO Acknowledge register, Address offset: 0x0F8 */ + __IO uint32_t RESERVED7; /*!< Reserved, 0x0FC */ +} FDCAN_GlobalTypeDef; + +/** + * @brief TTFD Controller Area Network + */ + +typedef struct +{ + __IO uint32_t TTTMC; /*!< TT Trigger Memory Configuration register, Address offset: 0x100 */ + __IO uint32_t TTRMC; /*!< TT Reference Message Configuration register, Address offset: 0x104 */ + __IO uint32_t TTOCF; /*!< TT Operation Configuration register, Address offset: 0x108 */ + __IO uint32_t TTMLM; /*!< TT Matrix Limits register, Address offset: 0x10C */ + __IO uint32_t TURCF; /*!< TUR Configuration register, Address offset: 0x110 */ + __IO uint32_t TTOCN; /*!< TT Operation Control register, Address offset: 0x114 */ + __IO uint32_t TTGTP; /*!< TT Global Time Preset register, Address offset: 0x118 */ + __IO uint32_t TTTMK; /*!< TT Time Mark register, Address offset: 0x11C */ + __IO uint32_t TTIR; /*!< TT Interrupt register, Address offset: 0x120 */ + __IO uint32_t TTIE; /*!< TT Interrupt Enable register, Address offset: 0x124 */ + __IO uint32_t TTILS; /*!< TT Interrupt Line Select register, Address offset: 0x128 */ + __IO uint32_t TTOST; /*!< TT Operation Status register, Address offset: 0x12C */ + __IO uint32_t TURNA; /*!< TT TUR Numerator Actual register, Address offset: 0x130 */ + __IO uint32_t TTLGT; /*!< TT Local and Global Time register, Address offset: 0x134 */ + __IO uint32_t TTCTC; /*!< TT Cycle Time and Count register, Address offset: 0x138 */ + __IO uint32_t TTCPT; /*!< TT Capture Time register, Address offset: 0x13C */ + __IO uint32_t TTCSM; /*!< TT Cycle Sync Mark register, Address offset: 0x140 */ + __IO uint32_t RESERVED1[111]; /*!< Reserved, 0x144 - 0x2FC */ + __IO uint32_t TTTS; /*!< TT Trigger Select register, Address offset: 0x300 */ +} TTCAN_TypeDef; + +/** + * @brief FD Controller Area Network + */ + +typedef struct +{ + __IO uint32_t CREL; /*!< Clock Calibration Unit Core Release register, Address offset: 0x00 */ + __IO uint32_t CCFG; /*!< Calibration Configuration register, Address offset: 0x04 */ + __IO uint32_t CSTAT; /*!< Calibration Status register, Address offset: 0x08 */ + __IO uint32_t CWD; /*!< Calibration Watchdog register, Address offset: 0x0C */ + __IO uint32_t IR; /*!< CCU Interrupt register, Address offset: 0x10 */ + __IO uint32_t IE; /*!< CCU Interrupt Enable register, Address offset: 0x14 */ +} FDCAN_ClockCalibrationUnit_TypeDef; + + +/** + * @brief Consumer Electronics Control + */ + +typedef struct +{ + __IO uint32_t CR; /*!< CEC control register, Address offset:0x00 */ + __IO uint32_t CFGR; /*!< CEC configuration register, Address offset:0x04 */ + __IO uint32_t TXDR; /*!< CEC Tx data register , Address offset:0x08 */ + __IO uint32_t RXDR; /*!< CEC Rx Data Register, Address offset:0x0C */ + __IO uint32_t ISR; /*!< CEC Interrupt and Status Register, Address offset:0x10 */ + __IO uint32_t IER; /*!< CEC interrupt enable register, Address offset:0x14 */ +}CEC_TypeDef; + +/** + * @brief COordincate Rotation DIgital Computer + */ +typedef struct +{ + __IO uint32_t CSR; /*!< CORDIC control and status register, Address offset: 0x00 */ + __IO uint32_t WDATA; /*!< CORDIC argument register, Address offset: 0x04 */ + __IO uint32_t RDATA; /*!< CORDIC result register, Address offset: 0x08 */ +} CORDIC_TypeDef; + +/** + * @brief CRC calculation unit + */ + +typedef struct +{ + __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ + __IO uint32_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ + __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ + uint32_t RESERVED2; /*!< Reserved, 0x0C */ + __IO uint32_t INIT; /*!< Initial CRC value register, Address offset: 0x10 */ + __IO uint32_t POL; /*!< CRC polynomial register, Address offset: 0x14 */ +} CRC_TypeDef; + + +/** + * @brief Clock Recovery System + */ +typedef struct +{ +__IO uint32_t CR; /*!< CRS ccontrol register, Address offset: 0x00 */ +__IO uint32_t CFGR; /*!< CRS configuration register, Address offset: 0x04 */ +__IO uint32_t ISR; /*!< CRS interrupt and status register, Address offset: 0x08 */ +__IO uint32_t ICR; /*!< CRS interrupt flag clear register, Address offset: 0x0C */ +} CRS_TypeDef; + + +/** + * @brief Digital to Analog Converter + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ + __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ + __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ + __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ + __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ + __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ + __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ + __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ + __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ + __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ + __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ + __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ + __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ + __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ + __IO uint32_t CCR; /*!< DAC calibration control register, Address offset: 0x38 */ + __IO uint32_t MCR; /*!< DAC mode control register, Address offset: 0x3C */ + __IO uint32_t SHSR1; /*!< DAC Sample and Hold sample time register 1, Address offset: 0x40 */ + __IO uint32_t SHSR2; /*!< DAC Sample and Hold sample time register 2, Address offset: 0x44 */ + __IO uint32_t SHHR; /*!< DAC Sample and Hold hold time register, Address offset: 0x48 */ + __IO uint32_t SHRR; /*!< DAC Sample and Hold refresh time register, Address offset: 0x4C */ +} DAC_TypeDef; + +/** + * @brief DFSDM module registers + */ +typedef struct +{ + __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ + __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ + __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ + __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ + __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ + __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ + __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ + __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ + __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ + __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ + __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ + __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ + __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ + __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ + __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ +} DFSDM_Filter_TypeDef; + +/** + * @brief DFSDM channel configuration registers + */ +typedef struct +{ + __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ + __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ + __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and + short circuit detector register, Address offset: 0x08 */ + __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ + __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ +} DFSDM_Channel_TypeDef; + +/** + * @brief Debug MCU + */ +typedef struct +{ + __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ + __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ + uint32_t RESERVED4[11]; /*!< Reserved, Address offset: 0x08 */ + __IO uint32_t APB3FZ1; /*!< Debug MCU APB3FZ1 freeze register, Address offset: 0x34 */ + uint32_t RESERVED5; /*!< Reserved, Address offset: 0x38 */ + __IO uint32_t APB1LFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x3C */ + uint32_t RESERVED6; /*!< Reserved, Address offset: 0x40 */ + __IO uint32_t APB1HFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x44 */ + uint32_t RESERVED7; /*!< Reserved, Address offset: 0x48 */ + __IO uint32_t APB2FZ1; /*!< Debug MCU APB2FZ1 freeze register, Address offset: 0x4C */ + uint32_t RESERVED8; /*!< Reserved, Address offset: 0x50 */ + __IO uint32_t APB4FZ1; /*!< Debug MCU APB4FZ1 freeze register, Address offset: 0x54 */ + __IO uint32_t RESERVED9[990]; /*!< Reserved, Address offset: 0x58-0xFCC */ + __IO uint32_t PIDR4; /*!< Debug MCU peripheral identity register 4, Address offset: 0xFD0 */ + __IO uint32_t RESERVED10[3];/*!< Reserved, Address offset: 0xFD4-0xFDC */ + __IO uint32_t PIDR0; /*!< Debug MCU peripheral identity register 0, Address offset: 0xFE0 */ + __IO uint32_t PIDR1; /*!< Debug MCU peripheral identity register 1, Address offset: 0xFE4 */ + __IO uint32_t PIDR2; /*!< Debug MCU peripheral identity register 2, Address offset: 0xFE8 */ + __IO uint32_t PIDR3; /*!< Debug MCU peripheral identity register 3, Address offset: 0xFEC */ + __IO uint32_t CIDR0; /*!< Debug MCU component identity register 0, Address offset: 0xFF0 */ + __IO uint32_t CIDR1; /*!< Debug MCU component identity register 1, Address offset: 0xFF4 */ + __IO uint32_t CIDR2; /*!< Debug MCU component identity register 2, Address offset: 0xFF8 */ + __IO uint32_t CIDR3; /*!< Debug MCU component identity register 3, Address offset: 0xFFC */ +}DBGMCU_TypeDef; +/** + * @brief DCMI + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */ + __IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */ + __IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */ + __IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */ + __IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */ + __IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */ + __IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */ + __IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */ + __IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */ + __IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */ + __IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */ +} DCMI_TypeDef; + +/** + * @brief PSSI + */ + +typedef struct +{ + __IO uint32_t CR; /*!< PSSI control register 1, Address offset: 0x000 */ + __IO uint32_t SR; /*!< PSSI status register, Address offset: 0x004 */ + __IO uint32_t RIS; /*!< PSSI raw interrupt status register, Address offset: 0x008 */ + __IO uint32_t IER; /*!< PSSI interrupt enable register, Address offset: 0x00C */ + __IO uint32_t MIS; /*!< PSSI masked interrupt status register, Address offset: 0x010 */ + __IO uint32_t ICR; /*!< PSSI interrupt clear register, Address offset: 0x014 */ + __IO uint32_t RESERVED1[4]; /*!< Reserved, 0x018 - 0x024 */ + __IO uint32_t DR; /*!< PSSI data register, Address offset: 0x028 */ + __IO uint32_t RESERVED2[241]; /*!< Reserved, 0x02C - 0x3EC */ + __IO uint32_t HWCFGR; /*!< PSSI IP HW configuration register, Address offset: 0x3F0 */ + __IO uint32_t VERR; /*!< PSSI IP version register, Address offset: 0x3F4 */ + __IO uint32_t IPIDR; /*!< PSSI IP ID register, Address offset: 0x3F8 */ + __IO uint32_t SIDR; /*!< PSSI SIZE ID register, Address offset: 0x3FC */ +} PSSI_TypeDef; + +/** + * @brief DMA Controller + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DMA stream x configuration register */ + __IO uint32_t NDTR; /*!< DMA stream x number of data register */ + __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ + __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ + __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ + __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ +} DMA_Stream_TypeDef; + +typedef struct +{ + __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ + __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ + __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ + __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ +} DMA_TypeDef; + +typedef struct +{ + __IO uint32_t CCR; /*!< DMA channel x configuration register */ + __IO uint32_t CNDTR; /*!< DMA channel x number of data register */ + __IO uint32_t CPAR; /*!< DMA channel x peripheral address register */ + __IO uint32_t CM0AR; /*!< DMA channel x memory 0 address register */ + __IO uint32_t CM1AR; /*!< DMA channel x memory 1 address register */ +} BDMA_Channel_TypeDef; + +typedef struct +{ + __IO uint32_t ISR; /*!< DMA interrupt status register, Address offset: 0x00 */ + __IO uint32_t IFCR; /*!< DMA interrupt flag clear register, Address offset: 0x04 */ +} BDMA_TypeDef; + +typedef struct +{ + __IO uint32_t CCR; /*!< DMA Multiplexer Channel x Control Register */ +}DMAMUX_Channel_TypeDef; + +typedef struct +{ + __IO uint32_t CSR; /*!< DMA Channel Status Register */ + __IO uint32_t CFR; /*!< DMA Channel Clear Flag Register */ +}DMAMUX_ChannelStatus_TypeDef; + +typedef struct +{ + __IO uint32_t RGCR; /*!< DMA Request Generator x Control Register */ +}DMAMUX_RequestGen_TypeDef; + +typedef struct +{ + __IO uint32_t RGSR; /*!< DMA Request Generator Status Register */ + __IO uint32_t RGCFR; /*!< DMA Request Generator Clear Flag Register */ +}DMAMUX_RequestGenStatus_TypeDef; + +/** + * @brief MDMA Controller + */ +typedef struct +{ + __IO uint32_t GISR0; /*!< MDMA Global Interrupt/Status Register 0, Address offset: 0x00 */ +}MDMA_TypeDef; + +typedef struct +{ + __IO uint32_t CISR; /*!< MDMA channel x interrupt/status register, Address offset: 0x40 */ + __IO uint32_t CIFCR; /*!< MDMA channel x interrupt flag clear register, Address offset: 0x44 */ + __IO uint32_t CESR; /*!< MDMA Channel x error status register, Address offset: 0x48 */ + __IO uint32_t CCR; /*!< MDMA channel x control register, Address offset: 0x4C */ + __IO uint32_t CTCR; /*!< MDMA channel x Transfer Configuration register, Address offset: 0x50 */ + __IO uint32_t CBNDTR; /*!< MDMA Channel x block number of data register, Address offset: 0x54 */ + __IO uint32_t CSAR; /*!< MDMA channel x source address register, Address offset: 0x58 */ + __IO uint32_t CDAR; /*!< MDMA channel x destination address register, Address offset: 0x5C */ + __IO uint32_t CBRUR; /*!< MDMA channel x Block Repeat address Update register, Address offset: 0x60 */ + __IO uint32_t CLAR; /*!< MDMA channel x Link Address register, Address offset: 0x64 */ + __IO uint32_t CTBR; /*!< MDMA channel x Trigger and Bus selection Register, Address offset: 0x68 */ + uint32_t RESERVED0; /*!< Reserved, 0x6C */ + __IO uint32_t CMAR; /*!< MDMA channel x Mask address register, Address offset: 0x70 */ + __IO uint32_t CMDR; /*!< MDMA channel x Mask Data register, Address offset: 0x74 */ +}MDMA_Channel_TypeDef; + +/** + * @brief DMA2D Controller + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DMA2D Control Register, Address offset: 0x00 */ + __IO uint32_t ISR; /*!< DMA2D Interrupt Status Register, Address offset: 0x04 */ + __IO uint32_t IFCR; /*!< DMA2D Interrupt Flag Clear Register, Address offset: 0x08 */ + __IO uint32_t FGMAR; /*!< DMA2D Foreground Memory Address Register, Address offset: 0x0C */ + __IO uint32_t FGOR; /*!< DMA2D Foreground Offset Register, Address offset: 0x10 */ + __IO uint32_t BGMAR; /*!< DMA2D Background Memory Address Register, Address offset: 0x14 */ + __IO uint32_t BGOR; /*!< DMA2D Background Offset Register, Address offset: 0x18 */ + __IO uint32_t FGPFCCR; /*!< DMA2D Foreground PFC Control Register, Address offset: 0x1C */ + __IO uint32_t FGCOLR; /*!< DMA2D Foreground Color Register, Address offset: 0x20 */ + __IO uint32_t BGPFCCR; /*!< DMA2D Background PFC Control Register, Address offset: 0x24 */ + __IO uint32_t BGCOLR; /*!< DMA2D Background Color Register, Address offset: 0x28 */ + __IO uint32_t FGCMAR; /*!< DMA2D Foreground CLUT Memory Address Register, Address offset: 0x2C */ + __IO uint32_t BGCMAR; /*!< DMA2D Background CLUT Memory Address Register, Address offset: 0x30 */ + __IO uint32_t OPFCCR; /*!< DMA2D Output PFC Control Register, Address offset: 0x34 */ + __IO uint32_t OCOLR; /*!< DMA2D Output Color Register, Address offset: 0x38 */ + __IO uint32_t OMAR; /*!< DMA2D Output Memory Address Register, Address offset: 0x3C */ + __IO uint32_t OOR; /*!< DMA2D Output Offset Register, Address offset: 0x40 */ + __IO uint32_t NLR; /*!< DMA2D Number of Line Register, Address offset: 0x44 */ + __IO uint32_t LWR; /*!< DMA2D Line Watermark Register, Address offset: 0x48 */ + __IO uint32_t AMTCR; /*!< DMA2D AHB Master Timer Configuration Register, Address offset: 0x4C */ + uint32_t RESERVED[236]; /*!< Reserved, 0x50-0x3FF */ + __IO uint32_t FGCLUT[256]; /*!< DMA2D Foreground CLUT, Address offset:400-7FF */ + __IO uint32_t BGCLUT[256]; /*!< DMA2D Background CLUT, Address offset:800-BFF */ +} DMA2D_TypeDef; + + +/** + * @brief Ethernet MAC + */ +typedef struct +{ + __IO uint32_t MACCR; + __IO uint32_t MACECR; + __IO uint32_t MACPFR; + __IO uint32_t MACWTR; + __IO uint32_t MACHT0R; + __IO uint32_t MACHT1R; + uint32_t RESERVED1[14]; + __IO uint32_t MACVTR; + uint32_t RESERVED2; + __IO uint32_t MACVHTR; + uint32_t RESERVED3; + __IO uint32_t MACVIR; + __IO uint32_t MACIVIR; + uint32_t RESERVED4[2]; + __IO uint32_t MACTFCR; + uint32_t RESERVED5[7]; + __IO uint32_t MACRFCR; + uint32_t RESERVED6[7]; + __IO uint32_t MACISR; + __IO uint32_t MACIER; + __IO uint32_t MACRXTXSR; + uint32_t RESERVED7; + __IO uint32_t MACPCSR; + __IO uint32_t MACRWKPFR; + uint32_t RESERVED8[2]; + __IO uint32_t MACLCSR; + __IO uint32_t MACLTCR; + __IO uint32_t MACLETR; + __IO uint32_t MAC1USTCR; + uint32_t RESERVED9[12]; + __IO uint32_t MACVR; + __IO uint32_t MACDR; + uint32_t RESERVED10; + __IO uint32_t MACHWF0R; + __IO uint32_t MACHWF1R; + __IO uint32_t MACHWF2R; + uint32_t RESERVED11[54]; + __IO uint32_t MACMDIOAR; + __IO uint32_t MACMDIODR; + uint32_t RESERVED12[2]; + __IO uint32_t MACARPAR; + uint32_t RESERVED13[59]; + __IO uint32_t MACA0HR; + __IO uint32_t MACA0LR; + __IO uint32_t MACA1HR; + __IO uint32_t MACA1LR; + __IO uint32_t MACA2HR; + __IO uint32_t MACA2LR; + __IO uint32_t MACA3HR; + __IO uint32_t MACA3LR; + uint32_t RESERVED14[248]; + __IO uint32_t MMCCR; + __IO uint32_t MMCRIR; + __IO uint32_t MMCTIR; + __IO uint32_t MMCRIMR; + __IO uint32_t MMCTIMR; + uint32_t RESERVED15[14]; + __IO uint32_t MMCTSCGPR; + __IO uint32_t MMCTMCGPR; + uint32_t RESERVED16[5]; + __IO uint32_t MMCTPCGR; + uint32_t RESERVED17[10]; + __IO uint32_t MMCRCRCEPR; + __IO uint32_t MMCRAEPR; + uint32_t RESERVED18[10]; + __IO uint32_t MMCRUPGR; + uint32_t RESERVED19[9]; + __IO uint32_t MMCTLPIMSTR; + __IO uint32_t MMCTLPITCR; + __IO uint32_t MMCRLPIMSTR; + __IO uint32_t MMCRLPITCR; + uint32_t RESERVED20[65]; + __IO uint32_t MACL3L4C0R; + __IO uint32_t MACL4A0R; + uint32_t RESERVED21[2]; + __IO uint32_t MACL3A0R0R; + __IO uint32_t MACL3A1R0R; + __IO uint32_t MACL3A2R0R; + __IO uint32_t MACL3A3R0R; + uint32_t RESERVED22[4]; + __IO uint32_t MACL3L4C1R; + __IO uint32_t MACL4A1R; + uint32_t RESERVED23[2]; + __IO uint32_t MACL3A0R1R; + __IO uint32_t MACL3A1R1R; + __IO uint32_t MACL3A2R1R; + __IO uint32_t MACL3A3R1R; + uint32_t RESERVED24[108]; + __IO uint32_t MACTSCR; + __IO uint32_t MACSSIR; + __IO uint32_t MACSTSR; + __IO uint32_t MACSTNR; + __IO uint32_t MACSTSUR; + __IO uint32_t MACSTNUR; + __IO uint32_t MACTSAR; + uint32_t RESERVED25; + __IO uint32_t MACTSSR; + uint32_t RESERVED26[3]; + __IO uint32_t MACTTSSNR; + __IO uint32_t MACTTSSSR; + uint32_t RESERVED27[2]; + __IO uint32_t MACACR; + uint32_t RESERVED28; + __IO uint32_t MACATSNR; + __IO uint32_t MACATSSR; + __IO uint32_t MACTSIACR; + __IO uint32_t MACTSEACR; + __IO uint32_t MACTSICNR; + __IO uint32_t MACTSECNR; + uint32_t RESERVED29[4]; + __IO uint32_t MACPPSCR; + uint32_t RESERVED30[3]; + __IO uint32_t MACPPSTTSR; + __IO uint32_t MACPPSTTNR; + __IO uint32_t MACPPSIR; + __IO uint32_t MACPPSWR; + uint32_t RESERVED31[12]; + __IO uint32_t MACPOCR; + __IO uint32_t MACSPI0R; + __IO uint32_t MACSPI1R; + __IO uint32_t MACSPI2R; + __IO uint32_t MACLMIR; + uint32_t RESERVED32[11]; + __IO uint32_t MTLOMR; + uint32_t RESERVED33[7]; + __IO uint32_t MTLISR; + uint32_t RESERVED34[55]; + __IO uint32_t MTLTQOMR; + __IO uint32_t MTLTQUR; + __IO uint32_t MTLTQDR; + uint32_t RESERVED35[8]; + __IO uint32_t MTLQICSR; + __IO uint32_t MTLRQOMR; + __IO uint32_t MTLRQMPOCR; + __IO uint32_t MTLRQDR; + uint32_t RESERVED36[177]; + __IO uint32_t DMAMR; + __IO uint32_t DMASBMR; + __IO uint32_t DMAISR; + __IO uint32_t DMADSR; + uint32_t RESERVED37[60]; + __IO uint32_t DMACCR; + __IO uint32_t DMACTCR; + __IO uint32_t DMACRCR; + uint32_t RESERVED38[2]; + __IO uint32_t DMACTDLAR; + uint32_t RESERVED39; + __IO uint32_t DMACRDLAR; + __IO uint32_t DMACTDTPR; + uint32_t RESERVED40; + __IO uint32_t DMACRDTPR; + __IO uint32_t DMACTDRLR; + __IO uint32_t DMACRDRLR; + __IO uint32_t DMACIER; + __IO uint32_t DMACRIWTR; +__IO uint32_t DMACSFCSR; + uint32_t RESERVED41; + __IO uint32_t DMACCATDR; + uint32_t RESERVED42; + __IO uint32_t DMACCARDR; + uint32_t RESERVED43; + __IO uint32_t DMACCATBR; + uint32_t RESERVED44; + __IO uint32_t DMACCARBR; + __IO uint32_t DMACSR; +uint32_t RESERVED45[2]; +__IO uint32_t DMACMFCR; +}ETH_TypeDef; +/** + * @brief External Interrupt/Event Controller + */ + +typedef struct +{ +__IO uint32_t RTSR1; /*!< EXTI Rising trigger selection register, Address offset: 0x00 */ +__IO uint32_t FTSR1; /*!< EXTI Falling trigger selection register, Address offset: 0x04 */ +__IO uint32_t SWIER1; /*!< EXTI Software interrupt event register, Address offset: 0x08 */ +__IO uint32_t D3PMR1; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR1) Address offset: 0x0C */ +__IO uint32_t D3PCR1L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR1L) Address offset: 0x10 */ +__IO uint32_t D3PCR1H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR1H) Address offset: 0x14 */ +uint32_t RESERVED1[2]; /*!< Reserved, 0x18 to 0x1C */ +__IO uint32_t RTSR2; /*!< EXTI Rising trigger selection register, Address offset: 0x20 */ +__IO uint32_t FTSR2; /*!< EXTI Falling trigger selection register, Address offset: 0x24 */ +__IO uint32_t SWIER2; /*!< EXTI Software interrupt event register, Address offset: 0x28 */ +__IO uint32_t D3PMR2; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR2) Address offset: 0x2C */ +__IO uint32_t D3PCR2L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR2L) Address offset: 0x30 */ +__IO uint32_t D3PCR2H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR2H) Address offset: 0x34 */ +uint32_t RESERVED2[2]; /*!< Reserved, 0x38 to 0x3C */ +__IO uint32_t RTSR3; /*!< EXTI Rising trigger selection register, Address offset: 0x40 */ +__IO uint32_t FTSR3; /*!< EXTI Falling trigger selection register, Address offset: 0x44 */ +__IO uint32_t SWIER3; /*!< EXTI Software interrupt event register, Address offset: 0x48 */ +__IO uint32_t D3PMR3; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR3) Address offset: 0x4C */ +__IO uint32_t D3PCR3L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR3L) Address offset: 0x50 */ +__IO uint32_t D3PCR3H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR3H) Address offset: 0x54 */ +uint32_t RESERVED3[10]; /*!< Reserved, 0x58 to 0x7C */ +__IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x80 */ +__IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x84 */ +__IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x88 */ +uint32_t RESERVED4; /*!< Reserved, 0x8C */ +__IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x90 */ +__IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x94 */ +__IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x98 */ +uint32_t RESERVED5; /*!< Reserved, 0x9C */ +__IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0xA0 */ +__IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0xA4 */ +__IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0xA8 */ +}EXTI_TypeDef; + +/** + * @brief This structure registers corresponds to EXTI_Typdef CPU1/CPU2 registers subset (IMRx, EMRx and PRx), allowing to define EXTI_D1/EXTI_D2 + * with rapid/common access to these IMRx, EMRx, PRx registers for CPU1 and CPU2. + * Note that EXTI_D1 and EXTI_D2 bases addresses are calculated to point to CPUx first register: + * IMR1 in case of EXTI_D1 that is addressing CPU1 (Coretx-M7) + * C2IMR1 in case of EXTI_D2 that is addressing CPU2 (Coretx-M4) + * Note: EXTI_D2 and corresponding C2IMRx, C2EMRx and C2PRx registers are available for Dual Core devices only + */ + +typedef struct +{ +__IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ +__IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x04 */ +__IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x08 */ +uint32_t RESERVED1; /*!< Reserved, 0x0C */ +__IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x10 */ +__IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x14 */ +__IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x18 */ +uint32_t RESERVED2; /*!< Reserved, 0x1C */ +__IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0x20 */ +__IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0x24 */ +__IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0x28 */ +}EXTI_Core_TypeDef; + + +/** + * @brief FLASH Registers + */ + +typedef struct +{ + __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ + __IO uint32_t KEYR1; /*!< Flash Key Register for bank1, Address offset: 0x04 */ + __IO uint32_t OPTKEYR; /*!< Flash Option Key Register, Address offset: 0x08 */ + __IO uint32_t CR1; /*!< Flash Control Register for bank1, Address offset: 0x0C */ + __IO uint32_t SR1; /*!< Flash Status Register for bank1, Address offset: 0x10 */ + __IO uint32_t CCR1; /*!< Flash Control Register for bank1, Address offset: 0x14 */ + __IO uint32_t OPTCR; /*!< Flash Option Control Register, Address offset: 0x18 */ + __IO uint32_t OPTSR_CUR; /*!< Flash Option Status Current Register, Address offset: 0x1C */ + __IO uint32_t OPTSR_PRG; /*!< Flash Option Status to Program Register, Address offset: 0x20 */ + __IO uint32_t OPTCCR; /*!< Flash Option Clear Control Register, Address offset: 0x24 */ + __IO uint32_t PRAR_CUR1; /*!< Flash Current Protection Address Register for bank1, Address offset: 0x28 */ + __IO uint32_t PRAR_PRG1; /*!< Flash Protection Address to Program Register for bank1, Address offset: 0x2C */ + __IO uint32_t SCAR_CUR1; /*!< Flash Current Secure Address Register for bank1, Address offset: 0x30 */ + __IO uint32_t SCAR_PRG1; /*!< Flash Secure Address to Program Register for bank1, Address offset: 0x34 */ + __IO uint32_t WPSN_CUR1; /*!< Flash Current Write Protection Register on bank1, Address offset: 0x38 */ + __IO uint32_t WPSN_PRG1; /*!< Flash Write Protection to Program Register on bank1, Address offset: 0x3C */ + __IO uint32_t BOOT_CUR; /*!< Flash Current Boot Address for Pelican Core Register, Address offset: 0x40 */ + __IO uint32_t BOOT_PRG; /*!< Flash Boot Address to Program for Pelican Core Register, Address offset: 0x44 */ + uint32_t RESERVED0[2]; /*!< Reserved, 0x48 to 0x4C */ + __IO uint32_t CRCCR1; /*!< Flash CRC Control register For Bank1 Register , Address offset: 0x50 */ + __IO uint32_t CRCSADD1; /*!< Flash CRC Start Address Register for Bank1 , Address offset: 0x54 */ + __IO uint32_t CRCEADD1; /*!< Flash CRC End Address Register for Bank1 , Address offset: 0x58 */ + __IO uint32_t CRCDATA; /*!< Flash CRC Data Register for Bank1 , Address offset: 0x5C */ + __IO uint32_t ECC_FA1; /*!< Flash ECC Fail Address For Bank1 Register , Address offset: 0x60 */ + uint32_t RESERVED[3]; /*!< Reserved, 0x64 to 0x6C */ + __IO uint32_t OPTSR2_CUR; /*!< Flash Option Status Current Register 2, Address offset: 0x70 */ + __IO uint32_t OPTSR2_PRG; /*!< Flash Option Status to Program Register 2, Address offset: 0x74 */ +} FLASH_TypeDef; + +/** + * @brief Filter and Mathematical ACcelerator + */ +typedef struct +{ + __IO uint32_t X1BUFCFG; /*!< FMAC X1 Buffer Configuration register, Address offset: 0x00 */ + __IO uint32_t X2BUFCFG; /*!< FMAC X2 Buffer Configuration register, Address offset: 0x04 */ + __IO uint32_t YBUFCFG; /*!< FMAC Y Buffer Configuration register, Address offset: 0x08 */ + __IO uint32_t PARAM; /*!< FMAC Parameter register, Address offset: 0x0C */ + __IO uint32_t CR; /*!< FMAC Control register, Address offset: 0x10 */ + __IO uint32_t SR; /*!< FMAC Status register, Address offset: 0x14 */ + __IO uint32_t WDATA; /*!< FMAC Write Data register, Address offset: 0x18 */ + __IO uint32_t RDATA; /*!< FMAC Read Data register, Address offset: 0x1C */ +} FMAC_TypeDef; + +/** + * @brief Flexible Memory Controller + */ + +typedef struct +{ + __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ +} FMC_Bank1_TypeDef; + +/** + * @brief Flexible Memory Controller Bank1E + */ + +typedef struct +{ + __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ +} FMC_Bank1E_TypeDef; + +/** + * @brief Flexible Memory Controller Bank2 + */ + +typedef struct +{ + __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ + __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ + __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ + __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ + uint32_t RESERVED0; /*!< Reserved, 0x70 */ + __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ +} FMC_Bank2_TypeDef; + +/** + * @brief Flexible Memory Controller Bank3 + */ + +typedef struct +{ + __IO uint32_t PCR; /*!< NAND Flash control register 3, Address offset: 0x80 */ + __IO uint32_t SR; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ + __IO uint32_t PMEM; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ + __IO uint32_t PATT; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ + uint32_t RESERVED; /*!< Reserved, 0x90 */ + __IO uint32_t ECCR; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ +} FMC_Bank3_TypeDef; + +/** + * @brief Flexible Memory Controller Bank5 and 6 + */ + + +typedef struct +{ + __IO uint32_t SDCR[2]; /*!< SDRAM Control registers , Address offset: 0x140-0x144 */ + __IO uint32_t SDTR[2]; /*!< SDRAM Timing registers , Address offset: 0x148-0x14C */ + __IO uint32_t SDCMR; /*!< SDRAM Command Mode register, Address offset: 0x150 */ + __IO uint32_t SDRTR; /*!< SDRAM Refresh Timer register, Address offset: 0x154 */ + __IO uint32_t SDSR; /*!< SDRAM Status register, Address offset: 0x158 */ +} FMC_Bank5_6_TypeDef; + +/** + * @brief General Purpose I/O + */ + +typedef struct +{ + __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ + __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ + __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ + __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ + __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ + __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ + __IO uint32_t BSRR; /*!< GPIO port bit set/reset, Address offset: 0x18 */ + __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ + __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ +} GPIO_TypeDef; + +/** + * @brief Operational Amplifier (OPAMP) + */ + +typedef struct +{ + __IO uint32_t CSR; /*!< OPAMP control/status register, Address offset: 0x00 */ + __IO uint32_t OTR; /*!< OPAMP offset trimming register for normal mode, Address offset: 0x04 */ + __IO uint32_t HSOTR; /*!< OPAMP offset trimming register for high speed mode, Address offset: 0x08 */ +} OPAMP_TypeDef; + +/** + * @brief System configuration controller + */ + +typedef struct +{ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x00 */ + __IO uint32_t PMCR; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ + __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ + __IO uint32_t CFGR; /*!< SYSCFG configuration registers, Address offset: 0x18 */ + uint32_t RESERVED2; /*!< Reserved, Address offset: 0x1C */ + __IO uint32_t CCCSR; /*!< SYSCFG compensation cell control/status register, Address offset: 0x20 */ + __IO uint32_t CCVR; /*!< SYSCFG compensation cell value register, Address offset: 0x24 */ + __IO uint32_t CCCR; /*!< SYSCFG compensation cell code register, Address offset: 0x28 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2C */ + __IO uint32_t ADC2ALT; /*!< ADC2 internal input alternate connection register, Address offset: 0x30 */ + uint32_t RESERVED4[60]; /*!< Reserved, 0x34-0x120 */ + __IO uint32_t PKGR; /*!< SYSCFG package register, Address offset: 0x124 */ + uint32_t RESERVED5[118]; /*!< Reserved, 0x128-0x2FC */ + __IO uint32_t UR0; /*!< SYSCFG user register 0, Address offset: 0x300 */ + __IO uint32_t UR1; /*!< SYSCFG user register 1, Address offset: 0x304 */ + __IO uint32_t UR2; /*!< SYSCFG user register 2, Address offset: 0x308 */ + __IO uint32_t UR3; /*!< SYSCFG user register 3, Address offset: 0x30C */ + __IO uint32_t UR4; /*!< SYSCFG user register 4, Address offset: 0x310 */ + __IO uint32_t UR5; /*!< SYSCFG user register 5, Address offset: 0x314 */ + __IO uint32_t UR6; /*!< SYSCFG user register 6, Address offset: 0x318 */ + __IO uint32_t UR7; /*!< SYSCFG user register 7, Address offset: 0x31C */ + uint32_t RESERVED6[3]; /*!< Reserved, Address offset: 0x320-0x328 */ + __IO uint32_t UR11; /*!< SYSCFG user register 11, Address offset: 0x32C */ + __IO uint32_t UR12; /*!< SYSCFG user register 12, Address offset: 0x330 */ + __IO uint32_t UR13; /*!< SYSCFG user register 13, Address offset: 0x334 */ + __IO uint32_t UR14; /*!< SYSCFG user register 14, Address offset: 0x338 */ + __IO uint32_t UR15; /*!< SYSCFG user register 15, Address offset: 0x33C */ + __IO uint32_t UR16; /*!< SYSCFG user register 16, Address offset: 0x340 */ + __IO uint32_t UR17; /*!< SYSCFG user register 17, Address offset: 0x344 */ + __IO uint32_t UR18; /*!< SYSCFG user register 18, Address offset: 0x348 */ + +} SYSCFG_TypeDef; + +/** + * @brief Inter-integrated Circuit Interface + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ + __IO uint32_t OAR1; /*!< I2C Own address 1 register, Address offset: 0x08 */ + __IO uint32_t OAR2; /*!< I2C Own address 2 register, Address offset: 0x0C */ + __IO uint32_t TIMINGR; /*!< I2C Timing register, Address offset: 0x10 */ + __IO uint32_t TIMEOUTR; /*!< I2C Timeout register, Address offset: 0x14 */ + __IO uint32_t ISR; /*!< I2C Interrupt and status register, Address offset: 0x18 */ + __IO uint32_t ICR; /*!< I2C Interrupt clear register, Address offset: 0x1C */ + __IO uint32_t PECR; /*!< I2C PEC register, Address offset: 0x20 */ + __IO uint32_t RXDR; /*!< I2C Receive data register, Address offset: 0x24 */ + __IO uint32_t TXDR; /*!< I2C Transmit data register, Address offset: 0x28 */ +} I2C_TypeDef; + +/** + * @brief Independent WATCHDOG + */ + +typedef struct +{ + __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ + __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ + __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ + __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ + __IO uint32_t WINR; /*!< IWDG Window register, Address offset: 0x10 */ +} IWDG_TypeDef; + + +/** + * @brief LCD-TFT Display Controller + */ + +typedef struct +{ + uint32_t RESERVED0[2]; /*!< Reserved, 0x00-0x04 */ + __IO uint32_t SSCR; /*!< LTDC Synchronization Size Configuration Register, Address offset: 0x08 */ + __IO uint32_t BPCR; /*!< LTDC Back Porch Configuration Register, Address offset: 0x0C */ + __IO uint32_t AWCR; /*!< LTDC Active Width Configuration Register, Address offset: 0x10 */ + __IO uint32_t TWCR; /*!< LTDC Total Width Configuration Register, Address offset: 0x14 */ + __IO uint32_t GCR; /*!< LTDC Global Control Register, Address offset: 0x18 */ + uint32_t RESERVED1[2]; /*!< Reserved, 0x1C-0x20 */ + __IO uint32_t SRCR; /*!< LTDC Shadow Reload Configuration Register, Address offset: 0x24 */ + uint32_t RESERVED2[1]; /*!< Reserved, 0x28 */ + __IO uint32_t BCCR; /*!< LTDC Background Color Configuration Register, Address offset: 0x2C */ + uint32_t RESERVED3[1]; /*!< Reserved, 0x30 */ + __IO uint32_t IER; /*!< LTDC Interrupt Enable Register, Address offset: 0x34 */ + __IO uint32_t ISR; /*!< LTDC Interrupt Status Register, Address offset: 0x38 */ + __IO uint32_t ICR; /*!< LTDC Interrupt Clear Register, Address offset: 0x3C */ + __IO uint32_t LIPCR; /*!< LTDC Line Interrupt Position Configuration Register, Address offset: 0x40 */ + __IO uint32_t CPSR; /*!< LTDC Current Position Status Register, Address offset: 0x44 */ + __IO uint32_t CDSR; /*!< LTDC Current Display Status Register, Address offset: 0x48 */ +} LTDC_TypeDef; + +/** + * @brief LCD-TFT Display layer x Controller + */ + +typedef struct +{ + __IO uint32_t CR; /*!< LTDC Layerx Control Register Address offset: 0x84 */ + __IO uint32_t WHPCR; /*!< LTDC Layerx Window Horizontal Position Configuration Register Address offset: 0x88 */ + __IO uint32_t WVPCR; /*!< LTDC Layerx Window Vertical Position Configuration Register Address offset: 0x8C */ + __IO uint32_t CKCR; /*!< LTDC Layerx Color Keying Configuration Register Address offset: 0x90 */ + __IO uint32_t PFCR; /*!< LTDC Layerx Pixel Format Configuration Register Address offset: 0x94 */ + __IO uint32_t CACR; /*!< LTDC Layerx Constant Alpha Configuration Register Address offset: 0x98 */ + __IO uint32_t DCCR; /*!< LTDC Layerx Default Color Configuration Register Address offset: 0x9C */ + __IO uint32_t BFCR; /*!< LTDC Layerx Blending Factors Configuration Register Address offset: 0xA0 */ + uint32_t RESERVED0[2]; /*!< Reserved */ + __IO uint32_t CFBAR; /*!< LTDC Layerx Color Frame Buffer Address Register Address offset: 0xAC */ + __IO uint32_t CFBLR; /*!< LTDC Layerx Color Frame Buffer Length Register Address offset: 0xB0 */ + __IO uint32_t CFBLNR; /*!< LTDC Layerx ColorFrame Buffer Line Number Register Address offset: 0xB4 */ + uint32_t RESERVED1[3]; /*!< Reserved */ + __IO uint32_t CLUTWR; /*!< LTDC Layerx CLUT Write Register Address offset: 0x144 */ + +} LTDC_Layer_TypeDef; + +/** + * @brief Power Control + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< PWR power control register 1, Address offset: 0x00 */ + __IO uint32_t CSR1; /*!< PWR power control status register 1, Address offset: 0x04 */ + __IO uint32_t CR2; /*!< PWR power control register 2, Address offset: 0x08 */ + __IO uint32_t CR3; /*!< PWR power control register 3, Address offset: 0x0C */ + __IO uint32_t CPUCR; /*!< PWR CPU control register, Address offset: 0x10 */ + uint32_t RESERVED0; /*!< Reserved, Address offset: 0x14 */ + __IO uint32_t D3CR; /*!< PWR D3 domain control register, Address offset: 0x18 */ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x1C */ + __IO uint32_t WKUPCR; /*!< PWR wakeup clear register, Address offset: 0x20 */ + __IO uint32_t WKUPFR; /*!< PWR wakeup flag register, Address offset: 0x24 */ + __IO uint32_t WKUPEPR; /*!< PWR wakeup enable and polarity register, Address offset: 0x28 */ +} PWR_TypeDef; + +/** + * @brief Reset and Clock Control + */ + +typedef struct +{ + __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ + __IO uint32_t HSICFGR; /*!< HSI Clock Calibration Register, Address offset: 0x04 */ + __IO uint32_t CRRCR; /*!< Clock Recovery RC Register, Address offset: 0x08 */ + __IO uint32_t CSICFGR; /*!< CSI Clock Calibration Register, Address offset: 0x0C */ + __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x10 */ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x14 */ + __IO uint32_t D1CFGR; /*!< RCC Domain 1 configuration register, Address offset: 0x18 */ + __IO uint32_t D2CFGR; /*!< RCC Domain 2 configuration register, Address offset: 0x1C */ + __IO uint32_t D3CFGR; /*!< RCC Domain 3 configuration register, Address offset: 0x20 */ + uint32_t RESERVED2; /*!< Reserved, Address offset: 0x24 */ + __IO uint32_t PLLCKSELR; /*!< RCC PLLs Clock Source Selection Register, Address offset: 0x28 */ + __IO uint32_t PLLCFGR; /*!< RCC PLLs Configuration Register, Address offset: 0x2C */ + __IO uint32_t PLL1DIVR; /*!< RCC PLL1 Dividers Configuration Register, Address offset: 0x30 */ + __IO uint32_t PLL1FRACR; /*!< RCC PLL1 Fractional Divider Configuration Register, Address offset: 0x34 */ + __IO uint32_t PLL2DIVR; /*!< RCC PLL2 Dividers Configuration Register, Address offset: 0x38 */ + __IO uint32_t PLL2FRACR; /*!< RCC PLL2 Fractional Divider Configuration Register, Address offset: 0x3C */ + __IO uint32_t PLL3DIVR; /*!< RCC PLL3 Dividers Configuration Register, Address offset: 0x40 */ + __IO uint32_t PLL3FRACR; /*!< RCC PLL3 Fractional Divider Configuration Register, Address offset: 0x44 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x48 */ + __IO uint32_t D1CCIPR; /*!< RCC Domain 1 Kernel Clock Configuration Register Address offset: 0x4C */ + __IO uint32_t D2CCIP1R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x50 */ + __IO uint32_t D2CCIP2R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x54 */ + __IO uint32_t D3CCIPR; /*!< RCC Domain 3 Kernel Clock Configuration Register Address offset: 0x58 */ + uint32_t RESERVED4; /*!< Reserved, Address offset: 0x5C */ + __IO uint32_t CIER; /*!< RCC Clock Source Interrupt Enable Register Address offset: 0x60 */ + __IO uint32_t CIFR; /*!< RCC Clock Source Interrupt Flag Register Address offset: 0x64 */ + __IO uint32_t CICR; /*!< RCC Clock Source Interrupt Clear Register Address offset: 0x68 */ + uint32_t RESERVED5; /*!< Reserved, Address offset: 0x6C */ + __IO uint32_t BDCR; /*!< RCC Vswitch Backup Domain Control Register, Address offset: 0x70 */ + __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ + uint32_t RESERVED6; /*!< Reserved, Address offset: 0x78 */ + __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x7C */ + __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x80 */ + __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x84 */ + __IO uint32_t AHB4RSTR; /*!< RCC AHB4 peripheral reset register, Address offset: 0x88 */ + __IO uint32_t APB3RSTR; /*!< RCC APB3 peripheral reset register, Address offset: 0x8C */ + __IO uint32_t APB1LRSTR; /*!< RCC APB1 peripheral reset Low Word register, Address offset: 0x90 */ + __IO uint32_t APB1HRSTR; /*!< RCC APB1 peripheral reset High Word register, Address offset: 0x94 */ + __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x98 */ + __IO uint32_t APB4RSTR; /*!< RCC APB4 peripheral reset register, Address offset: 0x9C */ + __IO uint32_t GCR; /*!< RCC RCC Global Control Register, Address offset: 0xA0 */ + uint32_t RESERVED8; /*!< Reserved, Address offset: 0xA4 */ + __IO uint32_t D3AMR; /*!< RCC Domain 3 Autonomous Mode Register, Address offset: 0xA8 */ + uint32_t RESERVED11[9]; /*!< Reserved, 0xAC-0xCC Address offset: 0xAC */ + __IO uint32_t RSR; /*!< RCC Reset status register, Address offset: 0xD0 */ + __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0xD4 */ + __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0xD8 */ + __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0xDC */ + __IO uint32_t AHB4ENR; /*!< RCC AHB4 peripheral clock register, Address offset: 0xE0 */ + __IO uint32_t APB3ENR; /*!< RCC APB3 peripheral clock register, Address offset: 0xE4 */ + __IO uint32_t APB1LENR; /*!< RCC APB1 peripheral clock Low Word register, Address offset: 0xE8 */ + __IO uint32_t APB1HENR; /*!< RCC APB1 peripheral clock High Word register, Address offset: 0xEC */ + __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock register, Address offset: 0xF0 */ + __IO uint32_t APB4ENR; /*!< RCC APB4 peripheral clock register, Address offset: 0xF4 */ + uint32_t RESERVED12; /*!< Reserved, Address offset: 0xF8 */ + __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral sleep clock register, Address offset: 0xFC */ + __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral sleep clock register, Address offset: 0x100 */ + __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral sleep clock register, Address offset: 0x104 */ + __IO uint32_t AHB4LPENR; /*!< RCC AHB4 peripheral sleep clock register, Address offset: 0x108 */ + __IO uint32_t APB3LPENR; /*!< RCC APB3 peripheral sleep clock register, Address offset: 0x10C */ + __IO uint32_t APB1LLPENR; /*!< RCC APB1 peripheral sleep clock Low Word register, Address offset: 0x110 */ + __IO uint32_t APB1HLPENR; /*!< RCC APB1 peripheral sleep clock High Word register, Address offset: 0x114 */ + __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral sleep clock register, Address offset: 0x118 */ + __IO uint32_t APB4LPENR; /*!< RCC APB4 peripheral sleep clock register, Address offset: 0x11C */ + uint32_t RESERVED13[4]; /*!< Reserved, 0x120-0x12C Address offset: 0x120 */ + +} RCC_TypeDef; + + +/** + * @brief Real-Time Clock + */ +typedef struct +{ + __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ + __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ + __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ + __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ + __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ + __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ + uint32_t RESERVED; /*!< Reserved, Address offset: 0x18 */ + __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ + __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ + __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ + __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ + __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ + __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ + __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ + __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ + __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ + __IO uint32_t TAMPCR; /*!< RTC tamper configuration register, Address offset: 0x40 */ + __IO uint32_t ALRMASSR; /*!< RTC alarm A sub second register, Address offset: 0x44 */ + __IO uint32_t ALRMBSSR; /*!< RTC alarm B sub second register, Address offset: 0x48 */ + __IO uint32_t OR; /*!< RTC option register, Address offset: 0x4C */ + __IO uint32_t BKP0R; /*!< RTC backup register 0, Address offset: 0x50 */ + __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ + __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ + __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ + __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ + __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ + __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ + __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ + __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ + __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ + __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ + __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ + __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ + __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ + __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ + __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ + __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ + __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ + __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ + __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ + __IO uint32_t BKP20R; /*!< RTC backup register 20, Address offset: 0xA0 */ + __IO uint32_t BKP21R; /*!< RTC backup register 21, Address offset: 0xA4 */ + __IO uint32_t BKP22R; /*!< RTC backup register 22, Address offset: 0xA8 */ + __IO uint32_t BKP23R; /*!< RTC backup register 23, Address offset: 0xAC */ + __IO uint32_t BKP24R; /*!< RTC backup register 24, Address offset: 0xB0 */ + __IO uint32_t BKP25R; /*!< RTC backup register 25, Address offset: 0xB4 */ + __IO uint32_t BKP26R; /*!< RTC backup register 26, Address offset: 0xB8 */ + __IO uint32_t BKP27R; /*!< RTC backup register 27, Address offset: 0xBC */ + __IO uint32_t BKP28R; /*!< RTC backup register 28, Address offset: 0xC0 */ + __IO uint32_t BKP29R; /*!< RTC backup register 29, Address offset: 0xC4 */ + __IO uint32_t BKP30R; /*!< RTC backup register 30, Address offset: 0xC8 */ + __IO uint32_t BKP31R; /*!< RTC backup register 31, Address offset: 0xCC */ +} RTC_TypeDef; + +/** + * @brief Serial Audio Interface + */ + +typedef struct +{ + __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ + uint32_t RESERVED0[16]; /*!< Reserved, 0x04 - 0x43 */ + __IO uint32_t PDMCR; /*!< SAI PDM control register, Address offset: 0x44 */ + __IO uint32_t PDMDLY; /*!< SAI PDM delay register, Address offset: 0x48 */ +} SAI_TypeDef; + +typedef struct +{ + __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ + __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ + __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ + __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ + __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ + __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ + __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ + __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ +} SAI_Block_TypeDef; + +/** + * @brief SPDIF-RX Interface + */ + +typedef struct +{ + __IO uint32_t CR; /*!< Control register, Address offset: 0x00 */ + __IO uint32_t IMR; /*!< Interrupt mask register, Address offset: 0x04 */ + __IO uint32_t SR; /*!< Status register, Address offset: 0x08 */ + __IO uint32_t IFCR; /*!< Interrupt Flag Clear register, Address offset: 0x0C */ + __IO uint32_t DR; /*!< Data input register, Address offset: 0x10 */ + __IO uint32_t CSR; /*!< Channel Status register, Address offset: 0x14 */ + __IO uint32_t DIR; /*!< Debug Information register, Address offset: 0x18 */ + uint32_t RESERVED2; /*!< Reserved, 0x1A */ +} SPDIFRX_TypeDef; + + +/** + * @brief Secure digital input/output Interface + */ + +typedef struct +{ + __IO uint32_t POWER; /*!< SDMMC power control register, Address offset: 0x00 */ + __IO uint32_t CLKCR; /*!< SDMMC clock control register, Address offset: 0x04 */ + __IO uint32_t ARG; /*!< SDMMC argument register, Address offset: 0x08 */ + __IO uint32_t CMD; /*!< SDMMC command register, Address offset: 0x0C */ + __I uint32_t RESPCMD; /*!< SDMMC command response register, Address offset: 0x10 */ + __I uint32_t RESP1; /*!< SDMMC response 1 register, Address offset: 0x14 */ + __I uint32_t RESP2; /*!< SDMMC response 2 register, Address offset: 0x18 */ + __I uint32_t RESP3; /*!< SDMMC response 3 register, Address offset: 0x1C */ + __I uint32_t RESP4; /*!< SDMMC response 4 register, Address offset: 0x20 */ + __IO uint32_t DTIMER; /*!< SDMMC data timer register, Address offset: 0x24 */ + __IO uint32_t DLEN; /*!< SDMMC data length register, Address offset: 0x28 */ + __IO uint32_t DCTRL; /*!< SDMMC data control register, Address offset: 0x2C */ + __I uint32_t DCOUNT; /*!< SDMMC data counter register, Address offset: 0x30 */ + __I uint32_t STA; /*!< SDMMC status register, Address offset: 0x34 */ + __IO uint32_t ICR; /*!< SDMMC interrupt clear register, Address offset: 0x38 */ + __IO uint32_t MASK; /*!< SDMMC mask register, Address offset: 0x3C */ + __IO uint32_t ACKTIME; /*!< SDMMC Acknowledgement timer register, Address offset: 0x40 */ + uint32_t RESERVED0[3]; /*!< Reserved, 0x44 - 0x4C - 0x4C */ + __IO uint32_t IDMACTRL; /*!< SDMMC DMA control register, Address offset: 0x50 */ + __IO uint32_t IDMABSIZE; /*!< SDMMC DMA buffer size register, Address offset: 0x54 */ + __IO uint32_t IDMABASE0; /*!< SDMMC DMA buffer 0 base address register, Address offset: 0x58 */ + __IO uint32_t IDMABASE1; /*!< SDMMC DMA buffer 1 base address register, Address offset: 0x5C */ + uint32_t RESERVED1[8]; /*!< Reserved, 0x60-0x7C */ + __IO uint32_t FIFO; /*!< SDMMC data FIFO register, Address offset: 0x80 */ + uint32_t RESERVED2[222]; /*!< Reserved, 0x84-0x3F8 */ + __IO uint32_t IPVR; /*!< SDMMC data FIFO register, Address offset: 0x3FC */ +} SDMMC_TypeDef; + + +/** + * @brief Delay Block DLYB + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DELAY BLOCK control register, Address offset: 0x00 */ + __IO uint32_t CFGR; /*!< DELAY BLOCK configuration register, Address offset: 0x04 */ +} DLYB_TypeDef; + +/** + * @brief HW Semaphore HSEM + */ + +typedef struct +{ + __IO uint32_t R[32]; /*!< 2-step write lock and read back registers, Address offset: 00h-7Ch */ + __IO uint32_t RLR[32]; /*!< 1-step read lock registers, Address offset: 80h-FCh */ + __IO uint32_t C1IER; /*!< HSEM Interrupt enable register , Address offset: 100h */ + __IO uint32_t C1ICR; /*!< HSEM Interrupt clear register , Address offset: 104h */ + __IO uint32_t C1ISR; /*!< HSEM Interrupt Status register , Address offset: 108h */ + __IO uint32_t C1MISR; /*!< HSEM Interrupt Masked Status register , Address offset: 10Ch */ + uint32_t Reserved[12]; /* Reserved Address offset: 110h-13Ch */ + __IO uint32_t CR; /*!< HSEM Semaphore clear register , Address offset: 140h */ + __IO uint32_t KEYR; /*!< HSEM Semaphore clear key register , Address offset: 144h */ + +} HSEM_TypeDef; + +typedef struct +{ + __IO uint32_t IER; /*!< HSEM interrupt enable register , Address offset: 0h */ + __IO uint32_t ICR; /*!< HSEM interrupt clear register , Address offset: 4h */ + __IO uint32_t ISR; /*!< HSEM interrupt status register , Address offset: 8h */ + __IO uint32_t MISR; /*!< HSEM masked interrupt status register , Address offset: Ch */ +} HSEM_Common_TypeDef; + +/** + * @brief Serial Peripheral Interface + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< SPI/I2S Control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< SPI Control register 2, Address offset: 0x04 */ + __IO uint32_t CFG1; /*!< SPI Configuration register 1, Address offset: 0x08 */ + __IO uint32_t CFG2; /*!< SPI Configuration register 2, Address offset: 0x0C */ + __IO uint32_t IER; /*!< SPI/I2S Interrupt Enable register, Address offset: 0x10 */ + __IO uint32_t SR; /*!< SPI/I2S Status register, Address offset: 0x14 */ + __IO uint32_t IFCR; /*!< SPI/I2S Interrupt/Status flags clear register, Address offset: 0x18 */ + uint32_t RESERVED0; /*!< Reserved, 0x1C */ + __IO uint32_t TXDR; /*!< SPI/I2S Transmit data register, Address offset: 0x20 */ + uint32_t RESERVED1[3]; /*!< Reserved, 0x24-0x2C */ + __IO uint32_t RXDR; /*!< SPI/I2S Receive data register, Address offset: 0x30 */ + uint32_t RESERVED2[3]; /*!< Reserved, 0x34-0x3C */ + __IO uint32_t CRCPOLY; /*!< SPI CRC Polynomial register, Address offset: 0x40 */ + __IO uint32_t TXCRC; /*!< SPI Transmitter CRC register, Address offset: 0x44 */ + __IO uint32_t RXCRC; /*!< SPI Receiver CRC register, Address offset: 0x48 */ + __IO uint32_t UDRDR; /*!< SPI Underrun data register, Address offset: 0x4C */ + __IO uint32_t I2SCFGR; /*!< I2S Configuration register, Address offset: 0x50 */ + +} SPI_TypeDef; + +/** + * @brief DTS + */ +typedef struct +{ + __IO uint32_t CFGR1; /*!< DTS configuration register, Address offset: 0x00 */ + uint32_t RESERVED0; /*!< Reserved, Address offset: 0x04 */ + __IO uint32_t T0VALR1; /*!< DTS T0 Value register, Address offset: 0x08 */ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x0C */ + __IO uint32_t RAMPVALR; /*!< DTS Ramp value register, Address offset: 0x10 */ + __IO uint32_t ITR1; /*!< DTS Interrupt threshold register, Address offset: 0x14 */ + uint32_t RESERVED2; /*!< Reserved, Address offset: 0x18 */ + __IO uint32_t DR; /*!< DTS data register, Address offset: 0x1C */ + __IO uint32_t SR; /*!< DTS status register Address offset: 0x20 */ + __IO uint32_t ITENR; /*!< DTS Interrupt enable register, Address offset: 0x24 */ + __IO uint32_t ICIFR; /*!< DTS Clear Interrupt flag register, Address offset: 0x28 */ + __IO uint32_t OR; /*!< DTS option register 1, Address offset: 0x2C */ +} +DTS_TypeDef; + +/** + * @brief TIM + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ + __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ + __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ + __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ + __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ + __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ + __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ + __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ + __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ + __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ + __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ + __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ + __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ + __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ + __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ + __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ + __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ + __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ + __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ + uint32_t RESERVED1; /*!< Reserved, 0x50 */ + __IO uint32_t CCMR3; /*!< TIM capture/compare mode register 3, Address offset: 0x54 */ + __IO uint32_t CCR5; /*!< TIM capture/compare register5, Address offset: 0x58 */ + __IO uint32_t CCR6; /*!< TIM capture/compare register6, Address offset: 0x5C */ + __IO uint32_t AF1; /*!< TIM alternate function option register 1, Address offset: 0x60 */ + __IO uint32_t AF2; /*!< TIM alternate function option register 2, Address offset: 0x64 */ + __IO uint32_t TISEL; /*!< TIM Input Selection register, Address offset: 0x68 */ +} TIM_TypeDef; + +/** + * @brief LPTIMIMER + */ +typedef struct +{ + __IO uint32_t ISR; /*!< LPTIM Interrupt and Status register, Address offset: 0x00 */ + __IO uint32_t ICR; /*!< LPTIM Interrupt Clear register, Address offset: 0x04 */ + __IO uint32_t IER; /*!< LPTIM Interrupt Enable register, Address offset: 0x08 */ + __IO uint32_t CFGR; /*!< LPTIM Configuration register, Address offset: 0x0C */ + __IO uint32_t CR; /*!< LPTIM Control register, Address offset: 0x10 */ + __IO uint32_t CMP; /*!< LPTIM Compare register, Address offset: 0x14 */ + __IO uint32_t ARR; /*!< LPTIM Autoreload register, Address offset: 0x18 */ + __IO uint32_t CNT; /*!< LPTIM Counter register, Address offset: 0x1C */ + uint32_t RESERVED1; /*!< Reserved, 0x20 */ + __IO uint32_t CFGR2; /*!< LPTIM Configuration register, Address offset: 0x24 */ +} LPTIM_TypeDef; + +/** + * @brief Comparator + */ +typedef struct +{ + __IO uint32_t SR; /*!< Comparator status register, Address offset: 0x00 */ + __IO uint32_t ICFR; /*!< Comparator interrupt clear flag register, Address offset: 0x04 */ + __IO uint32_t OR; /*!< Comparator option register, Address offset: 0x08 */ +} COMPOPT_TypeDef; + +typedef struct +{ + __IO uint32_t CFGR; /*!< Comparator configuration register , Address offset: 0x00 */ +} COMP_TypeDef; + +typedef struct +{ + __IO uint32_t CFGR; /*!< COMP control and status register, used for bits common to several COMP instances, Address offset: 0x00 */ +} COMP_Common_TypeDef; +/** + * @brief Universal Synchronous Asynchronous Receiver Transmitter + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x04 */ + __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x08 */ + __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x0C */ + __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x10 */ + __IO uint32_t RTOR; /*!< USART Receiver Time Out register, Address offset: 0x14 */ + __IO uint32_t RQR; /*!< USART Request register, Address offset: 0x18 */ + __IO uint32_t ISR; /*!< USART Interrupt and status register, Address offset: 0x1C */ + __IO uint32_t ICR; /*!< USART Interrupt flag Clear register, Address offset: 0x20 */ + __IO uint32_t RDR; /*!< USART Receive Data register, Address offset: 0x24 */ + __IO uint32_t TDR; /*!< USART Transmit Data register, Address offset: 0x28 */ + __IO uint32_t PRESC; /*!< USART clock Prescaler register, Address offset: 0x2C */ +} USART_TypeDef; + +/** + * @brief Single Wire Protocol Master Interface SPWMI + */ +typedef struct +{ + __IO uint32_t CR; /*!< SWPMI Configuration/Control register, Address offset: 0x00 */ + __IO uint32_t BRR; /*!< SWPMI bitrate register, Address offset: 0x04 */ + uint32_t RESERVED1; /*!< Reserved, 0x08 */ + __IO uint32_t ISR; /*!< SWPMI Interrupt and Status register, Address offset: 0x0C */ + __IO uint32_t ICR; /*!< SWPMI Interrupt Flag Clear register, Address offset: 0x10 */ + __IO uint32_t IER; /*!< SWPMI Interrupt Enable register, Address offset: 0x14 */ + __IO uint32_t RFL; /*!< SWPMI Receive Frame Length register, Address offset: 0x18 */ + __IO uint32_t TDR; /*!< SWPMI Transmit data register, Address offset: 0x1C */ + __IO uint32_t RDR; /*!< SWPMI Receive data register, Address offset: 0x20 */ + __IO uint32_t OR; /*!< SWPMI Option register, Address offset: 0x24 */ +} SWPMI_TypeDef; + +/** + * @brief Window WATCHDOG + */ + +typedef struct +{ + __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ + __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ + __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ +} WWDG_TypeDef; + + +/** + * @brief RAM_ECC_Specific_Registers + */ +typedef struct +{ + __IO uint32_t CR; /*!< RAMECC monitor configuration register */ + __IO uint32_t SR; /*!< RAMECC monitor status register */ + __IO uint32_t FAR; /*!< RAMECC monitor failing address register */ + __IO uint32_t FDRL; /*!< RAMECC monitor failing data low register */ + __IO uint32_t FDRH; /*!< RAMECC monitor failing data high register */ + __IO uint32_t FECR; /*!< RAMECC monitor failing ECC error code register */ +} RAMECC_MonitorTypeDef; + +typedef struct +{ + __IO uint32_t IER; /*!< RAMECC interrupt enable register */ +} RAMECC_TypeDef; +/** + * @} + */ + + +/** + * @brief Crypto Processor + */ + +typedef struct +{ + __IO uint32_t CR; /*!< CRYP control register, Address offset: 0x00 */ + __IO uint32_t SR; /*!< CRYP status register, Address offset: 0x04 */ + __IO uint32_t DIN; /*!< CRYP data input register, Address offset: 0x08 */ + __IO uint32_t DOUT; /*!< CRYP data output register, Address offset: 0x0C */ + __IO uint32_t DMACR; /*!< CRYP DMA control register, Address offset: 0x10 */ + __IO uint32_t IMSCR; /*!< CRYP interrupt mask set/clear register, Address offset: 0x14 */ + __IO uint32_t RISR; /*!< CRYP raw interrupt status register, Address offset: 0x18 */ + __IO uint32_t MISR; /*!< CRYP masked interrupt status register, Address offset: 0x1C */ + __IO uint32_t K0LR; /*!< CRYP key left register 0, Address offset: 0x20 */ + __IO uint32_t K0RR; /*!< CRYP key right register 0, Address offset: 0x24 */ + __IO uint32_t K1LR; /*!< CRYP key left register 1, Address offset: 0x28 */ + __IO uint32_t K1RR; /*!< CRYP key right register 1, Address offset: 0x2C */ + __IO uint32_t K2LR; /*!< CRYP key left register 2, Address offset: 0x30 */ + __IO uint32_t K2RR; /*!< CRYP key right register 2, Address offset: 0x34 */ + __IO uint32_t K3LR; /*!< CRYP key left register 3, Address offset: 0x38 */ + __IO uint32_t K3RR; /*!< CRYP key right register 3, Address offset: 0x3C */ + __IO uint32_t IV0LR; /*!< CRYP initialization vector left-word register 0, Address offset: 0x40 */ + __IO uint32_t IV0RR; /*!< CRYP initialization vector right-word register 0, Address offset: 0x44 */ + __IO uint32_t IV1LR; /*!< CRYP initialization vector left-word register 1, Address offset: 0x48 */ + __IO uint32_t IV1RR; /*!< CRYP initialization vector right-word register 1, Address offset: 0x4C */ + __IO uint32_t CSGCMCCM0R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 0, Address offset: 0x50 */ + __IO uint32_t CSGCMCCM1R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 1, Address offset: 0x54 */ + __IO uint32_t CSGCMCCM2R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 2, Address offset: 0x58 */ + __IO uint32_t CSGCMCCM3R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 3, Address offset: 0x5C */ + __IO uint32_t CSGCMCCM4R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 4, Address offset: 0x60 */ + __IO uint32_t CSGCMCCM5R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 5, Address offset: 0x64 */ + __IO uint32_t CSGCMCCM6R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 6, Address offset: 0x68 */ + __IO uint32_t CSGCMCCM7R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 7, Address offset: 0x6C */ + __IO uint32_t CSGCM0R; /*!< CRYP GCM/GMAC context swap register 0, Address offset: 0x70 */ + __IO uint32_t CSGCM1R; /*!< CRYP GCM/GMAC context swap register 1, Address offset: 0x74 */ + __IO uint32_t CSGCM2R; /*!< CRYP GCM/GMAC context swap register 2, Address offset: 0x78 */ + __IO uint32_t CSGCM3R; /*!< CRYP GCM/GMAC context swap register 3, Address offset: 0x7C */ + __IO uint32_t CSGCM4R; /*!< CRYP GCM/GMAC context swap register 4, Address offset: 0x80 */ + __IO uint32_t CSGCM5R; /*!< CRYP GCM/GMAC context swap register 5, Address offset: 0x84 */ + __IO uint32_t CSGCM6R; /*!< CRYP GCM/GMAC context swap register 6, Address offset: 0x88 */ + __IO uint32_t CSGCM7R; /*!< CRYP GCM/GMAC context swap register 7, Address offset: 0x8C */ +} CRYP_TypeDef; + +/** + * @brief HASH + */ + +typedef struct +{ + __IO uint32_t CR; /*!< HASH control register, Address offset: 0x00 */ + __IO uint32_t DIN; /*!< HASH data input register, Address offset: 0x04 */ + __IO uint32_t STR; /*!< HASH start register, Address offset: 0x08 */ + __IO uint32_t HR[5]; /*!< HASH digest registers, Address offset: 0x0C-0x1C */ + __IO uint32_t IMR; /*!< HASH interrupt enable register, Address offset: 0x20 */ + __IO uint32_t SR; /*!< HASH status register, Address offset: 0x24 */ + uint32_t RESERVED[52]; /*!< Reserved, 0x28-0xF4 */ + __IO uint32_t CSR[54]; /*!< HASH context swap registers, Address offset: 0x0F8-0x1CC */ +} HASH_TypeDef; + +/** + * @brief HASH_DIGEST + */ + +typedef struct +{ + __IO uint32_t HR[8]; /*!< HASH digest registers, Address offset: 0x310-0x32C */ +} HASH_DIGEST_TypeDef; + + +/** + * @brief RNG + */ + +typedef struct +{ + __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ + __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ + __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ + uint32_t RESERVED; + __IO uint32_t HTCR; /*!< RNG health test configuration register, Address offset: 0x10 */ +} RNG_TypeDef; + +/** + * @brief MDIOS + */ + +typedef struct +{ + __IO uint32_t CR; + __IO uint32_t WRFR; + __IO uint32_t CWRFR; + __IO uint32_t RDFR; + __IO uint32_t CRDFR; + __IO uint32_t SR; + __IO uint32_t CLRFR; + uint32_t RESERVED[57]; + __IO uint32_t DINR0; + __IO uint32_t DINR1; + __IO uint32_t DINR2; + __IO uint32_t DINR3; + __IO uint32_t DINR4; + __IO uint32_t DINR5; + __IO uint32_t DINR6; + __IO uint32_t DINR7; + __IO uint32_t DINR8; + __IO uint32_t DINR9; + __IO uint32_t DINR10; + __IO uint32_t DINR11; + __IO uint32_t DINR12; + __IO uint32_t DINR13; + __IO uint32_t DINR14; + __IO uint32_t DINR15; + __IO uint32_t DINR16; + __IO uint32_t DINR17; + __IO uint32_t DINR18; + __IO uint32_t DINR19; + __IO uint32_t DINR20; + __IO uint32_t DINR21; + __IO uint32_t DINR22; + __IO uint32_t DINR23; + __IO uint32_t DINR24; + __IO uint32_t DINR25; + __IO uint32_t DINR26; + __IO uint32_t DINR27; + __IO uint32_t DINR28; + __IO uint32_t DINR29; + __IO uint32_t DINR30; + __IO uint32_t DINR31; + __IO uint32_t DOUTR0; + __IO uint32_t DOUTR1; + __IO uint32_t DOUTR2; + __IO uint32_t DOUTR3; + __IO uint32_t DOUTR4; + __IO uint32_t DOUTR5; + __IO uint32_t DOUTR6; + __IO uint32_t DOUTR7; + __IO uint32_t DOUTR8; + __IO uint32_t DOUTR9; + __IO uint32_t DOUTR10; + __IO uint32_t DOUTR11; + __IO uint32_t DOUTR12; + __IO uint32_t DOUTR13; + __IO uint32_t DOUTR14; + __IO uint32_t DOUTR15; + __IO uint32_t DOUTR16; + __IO uint32_t DOUTR17; + __IO uint32_t DOUTR18; + __IO uint32_t DOUTR19; + __IO uint32_t DOUTR20; + __IO uint32_t DOUTR21; + __IO uint32_t DOUTR22; + __IO uint32_t DOUTR23; + __IO uint32_t DOUTR24; + __IO uint32_t DOUTR25; + __IO uint32_t DOUTR26; + __IO uint32_t DOUTR27; + __IO uint32_t DOUTR28; + __IO uint32_t DOUTR29; + __IO uint32_t DOUTR30; + __IO uint32_t DOUTR31; +} MDIOS_TypeDef; + + +/** + * @brief USB_OTG_Core_Registers + */ +typedef struct +{ + __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ + __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ + __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ + __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ + __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ + __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ + __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ + __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ + __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ + __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ + __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ + __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ + uint32_t Reserved30[2]; /*!< Reserved 030h */ + __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ + __IO uint32_t CID; /*!< User ID Register 03Ch */ + __IO uint32_t GSNPSID; /* USB_OTG core ID 040h*/ + __IO uint32_t GHWCFG1; /* User HW config1 044h*/ + __IO uint32_t GHWCFG2; /* User HW config2 048h*/ + __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ + uint32_t Reserved6; /*!< Reserved 050h */ + __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ + __IO uint32_t GPWRDN; /*!< Power Down Register 058h */ + __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ + __IO uint32_t GADPCTL; /*!< ADP Timer, Control and Status Register 60Ch */ + uint32_t Reserved43[39]; /*!< Reserved 058h-0FFh */ + __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ + __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ +} USB_OTG_GlobalTypeDef; + + +/** + * @brief USB_OTG_device_Registers + */ +typedef struct +{ + __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ + __IO uint32_t DCTL; /*!< dev Control Register 804h */ + __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ + uint32_t Reserved0C; /*!< Reserved 80Ch */ + __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ + __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ + __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ + __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ + uint32_t Reserved20; /*!< Reserved 820h */ + uint32_t Reserved9; /*!< Reserved 824h */ + __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ + __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ + __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ + __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ + __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ + __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ + uint32_t Reserved40; /*!< dedicated EP mask 840h */ + __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ + uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ + __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ +} USB_OTG_DeviceTypeDef; + + +/** + * @brief USB_OTG_IN_Endpoint-Specific_Register + */ +typedef struct +{ + __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ + uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ + __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ + uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ + __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ + __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ + __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ + uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ +} USB_OTG_INEndpointTypeDef; + + +/** + * @brief USB_OTG_OUT_Endpoint-Specific_Registers + */ +typedef struct +{ + __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ + uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ + __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ + uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ + __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ + __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ + uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ +} USB_OTG_OUTEndpointTypeDef; + + +/** + * @brief USB_OTG_Host_Mode_Register_Structures + */ +typedef struct +{ + __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ + __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ + __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ + uint32_t Reserved40C; /*!< Reserved 40Ch */ + __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ + __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ + __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ +} USB_OTG_HostTypeDef; + +/** + * @brief USB_OTG_Host_Channel_Specific_Registers + */ +typedef struct +{ + __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ + __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ + __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ + __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ + __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ + __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ + uint32_t Reserved[2]; /*!< Reserved */ +} USB_OTG_HostChannelTypeDef; +/** + * @} + */ + +/** + * @brief OCTO Serial Peripheral Interface + */ + +typedef struct +{ + __IO uint32_t CR; /*!< OCTOSPI Control register, Address offset: 0x000 */ + uint32_t RESERVED; /*!< Reserved, Address offset: 0x004 */ + __IO uint32_t DCR1; /*!< OCTOSPI Device Configuration register 1, Address offset: 0x008 */ + __IO uint32_t DCR2; /*!< OCTOSPI Device Configuration register 2, Address offset: 0x00C */ + __IO uint32_t DCR3; /*!< OCTOSPI Device Configuration register 3, Address offset: 0x010 */ + __IO uint32_t DCR4; /*!< OCTOSPI Device Configuration register 4, Address offset: 0x014 */ + uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x018-0x01C */ + __IO uint32_t SR; /*!< OCTOSPI Status register, Address offset: 0x020 */ + __IO uint32_t FCR; /*!< OCTOSPI Flag Clear register, Address offset: 0x024 */ + uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x028-0x03C */ + __IO uint32_t DLR; /*!< OCTOSPI Data Length register, Address offset: 0x040 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x044 */ + __IO uint32_t AR; /*!< OCTOSPI Address register, Address offset: 0x048 */ + uint32_t RESERVED4; /*!< Reserved, Address offset: 0x04C */ + __IO uint32_t DR; /*!< OCTOSPI Data register, Address offset: 0x050 */ + uint32_t RESERVED5[11]; /*!< Reserved, Address offset: 0x054-0x07C */ + __IO uint32_t PSMKR; /*!< OCTOSPI Polling Status Mask register, Address offset: 0x080 */ + uint32_t RESERVED6; /*!< Reserved, Address offset: 0x084 */ + __IO uint32_t PSMAR; /*!< OCTOSPI Polling Status Match register, Address offset: 0x088 */ + uint32_t RESERVED7; /*!< Reserved, Address offset: 0x08C */ + __IO uint32_t PIR; /*!< OCTOSPI Polling Interval register, Address offset: 0x090 */ + uint32_t RESERVED8[27]; /*!< Reserved, Address offset: 0x094-0x0FC */ + __IO uint32_t CCR; /*!< OCTOSPI Communication Configuration register, Address offset: 0x100 */ + uint32_t RESERVED9; /*!< Reserved, Address offset: 0x104 */ + __IO uint32_t TCR; /*!< OCTOSPI Timing Configuration register, Address offset: 0x108 */ + uint32_t RESERVED10; /*!< Reserved, Address offset: 0x10C */ + __IO uint32_t IR; /*!< OCTOSPI Instruction register, Address offset: 0x110 */ + uint32_t RESERVED11[3]; /*!< Reserved, Address offset: 0x114-0x11C */ + __IO uint32_t ABR; /*!< OCTOSPI Alternate Bytes register, Address offset: 0x120 */ + uint32_t RESERVED12[3]; /*!< Reserved, Address offset: 0x124-0x12C */ + __IO uint32_t LPTR; /*!< OCTOSPI Low Power Timeout register, Address offset: 0x130 */ + uint32_t RESERVED13[3]; /*!< Reserved, Address offset: 0x134-0x13C */ + __IO uint32_t WPCCR; /*!< OCTOSPI Wrap Communication Configuration register, Address offset: 0x140 */ + uint32_t RESERVED14; /*!< Reserved, Address offset: 0x144 */ + __IO uint32_t WPTCR; /*!< OCTOSPI Wrap Timing Configuration register, Address offset: 0x148 */ + uint32_t RESERVED15; /*!< Reserved, Address offset: 0x14C */ + __IO uint32_t WPIR; /*!< OCTOSPI Wrap Instruction register, Address offset: 0x150 */ + uint32_t RESERVED16[3]; /*!< Reserved, Address offset: 0x154-0x15C */ + __IO uint32_t WPABR; /*!< OCTOSPI Wrap Alternate Bytes register, Address offset: 0x160 */ + uint32_t RESERVED17[7]; /*!< Reserved, Address offset: 0x164-0x17C */ + __IO uint32_t WCCR; /*!< OCTOSPI Write Communication Configuration register, Address offset: 0x180 */ + uint32_t RESERVED18; /*!< Reserved, Address offset: 0x184 */ + __IO uint32_t WTCR; /*!< OCTOSPI Write Timing Configuration register, Address offset: 0x188 */ + uint32_t RESERVED19; /*!< Reserved, Address offset: 0x18C */ + __IO uint32_t WIR; /*!< OCTOSPI Write Instruction register, Address offset: 0x190 */ + uint32_t RESERVED20[3]; /*!< Reserved, Address offset: 0x194-0x19C */ + __IO uint32_t WABR; /*!< OCTOSPI Write Alternate Bytes register, Address offset: 0x1A0 */ + uint32_t RESERVED21[23]; /*!< Reserved, Address offset: 0x1A4-0x1FC */ + __IO uint32_t HLCR; /*!< OCTOSPI Hyperbus Latency Configuration register, Address offset: 0x200 */ + uint32_t RESERVED22[122]; /*!< Reserved, Address offset: 0x204-0x3EC */ + __IO uint32_t HWCFGR; /*!< OCTOSPI HW Configuration register, Address offset: 0x3F0 */ + __IO uint32_t VER; /*!< OCTOSPI Version register, Address offset: 0x3F4 */ + __IO uint32_t ID; /*!< OCTOSPI Identification register, Address offset: 0x3F8 */ + __IO uint32_t MID; /*!< OCTOPSI HW Magic ID register, Address offset: 0x3FC */ +} OCTOSPI_TypeDef; + +/** + * @} + */ +/** + * @brief OCTO Serial Peripheral Interface IO Manager + */ + +typedef struct +{ + __IO uint32_t CR; /*!< OCTOSPI IO Manager Control register, Address offset: 0x00 */ + __IO uint32_t PCR[3]; /*!< OCTOSPI IO Manager Port[1:3] Configuration register, Address offset: 0x04-0x20 */ +} OCTOSPIM_TypeDef; + +/** + * @} + */ + +/** + * @brief OTFD register + */ +typedef struct +{ + __IO uint32_t REG_CONFIGR; + __IO uint32_t REG_START_ADDR; + __IO uint32_t REG_END_ADDR; + __IO uint32_t REG_NONCER0; + __IO uint32_t REG_NONCER1; + __IO uint32_t REG_KEYR0; + __IO uint32_t REG_KEYR1; + __IO uint32_t REG_KEYR2; + __IO uint32_t REG_KEYR3; +} OTFDEC_Region_TypeDef; + +typedef struct +{ + __IO uint32_t CR; + uint32_t RESERVED1[191]; + __IO uint32_t ISR; + __IO uint32_t ICR; + __IO uint32_t IER; + uint32_t RESERVED2[56]; + __IO uint32_t HWCFGR2; + __IO uint32_t HWCFGR1; + __IO uint32_t VERR; + __IO uint32_t IPIDR; + __IO uint32_t SIDR; +} OTFDEC_TypeDef; +/** + * @} + */ + +/** + * @brief Global Programmer View + */ + +typedef struct +{ + uint32_t RESERVED0[2036]; /*!< Reserved, Address offset: 0x00-0x1FCC */ + __IO uint32_t AXI_PERIPH_ID_4; /*!< AXI interconnect - peripheral ID4 register, Address offset: 0x1FD0 */ + uint32_t AXI_PERIPH_ID_5; /*!< Reserved, Address offset: 0x1FD4 */ + uint32_t AXI_PERIPH_ID_6; /*!< Reserved, Address offset: 0x1FD8 */ + uint32_t AXI_PERIPH_ID_7; /*!< Reserved, Address offset: 0x1FDC */ + __IO uint32_t AXI_PERIPH_ID_0; /*!< AXI interconnect - peripheral ID0 register, Address offset: 0x1FE0 */ + __IO uint32_t AXI_PERIPH_ID_1; /*!< AXI interconnect - peripheral ID1 register, Address offset: 0x1FE4 */ + __IO uint32_t AXI_PERIPH_ID_2; /*!< AXI interconnect - peripheral ID2 register, Address offset: 0x1FE8 */ + __IO uint32_t AXI_PERIPH_ID_3; /*!< AXI interconnect - peripheral ID3 register, Address offset: 0x1FEC */ + __IO uint32_t AXI_COMP_ID_0; /*!< AXI interconnect - component ID0 register, Address offset: 0x1FF0 */ + __IO uint32_t AXI_COMP_ID_1; /*!< AXI interconnect - component ID1 register, Address offset: 0x1FF4 */ + __IO uint32_t AXI_COMP_ID_2; /*!< AXI interconnect - component ID2 register, Address offset: 0x1FF8 */ + __IO uint32_t AXI_COMP_ID_3; /*!< AXI interconnect - component ID3 register, Address offset: 0x1FFC */ + uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x2000-0x2004 */ + __IO uint32_t AXI_TARG1_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 1 bus matrix issuing functionality register, Address offset: 0x2008 */ + uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x200C-0x2020 */ + __IO uint32_t AXI_TARG1_FN_MOD2; /*!< AXI interconnect - TARG 1 bus matrix functionality 2 register, Address offset: 0x2024 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2028 */ + __IO uint32_t AXI_TARG1_FN_MOD_LB; /*!< AXI interconnect - TARG 1 long burst functionality modification register, Address offset: 0x202C */ + uint32_t RESERVED4[54]; /*!< Reserved, Address offset: 0x2030-0x2104 */ + __IO uint32_t AXI_TARG1_FN_MOD; /*!< AXI interconnect - TARG 1 issuing functionality modification register, Address offset: 0x2108 */ + uint32_t RESERVED5[959]; /*!< Reserved, Address offset: 0x210C-0x3004 */ + __IO uint32_t AXI_TARG2_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 2 bus matrix issuing functionality register, Address offset: 0x3008 */ + uint32_t RESERVED6[6]; /*!< Reserved, Address offset: 0x300C-0x3020 */ + __IO uint32_t AXI_TARG2_FN_MOD2; /*!< AXI interconnect - TARG 2 bus matrix functionality 2 register, Address offset: 0x3024 */ + uint32_t RESERVED7; /*!< Reserved, Address offset: 0x3028 */ + __IO uint32_t AXI_TARG2_FN_MOD_LB; /*!< AXI interconnect - TARG 2 long burst functionality modification register, Address offset: 0x302C */ + uint32_t RESERVED8[54]; /*!< Reserved, Address offset: 0x3030-0x3104 */ + __IO uint32_t AXI_TARG2_FN_MOD; /*!< AXI interconnect - TARG 2 issuing functionality modification register, Address offset: 0x3108 */ + uint32_t RESERVED9[959]; /*!< Reserved, Address offset: 0x310C-0x4004 */ + __IO uint32_t AXI_TARG3_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 3 bus matrix issuing functionality register, Address offset: 0x4008 */ + uint32_t RESERVED10[1023]; /*!< Reserved, Address offset: 0x400C-0x5004 */ + __IO uint32_t AXI_TARG4_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 4 bus matrix issuing functionality register, Address offset: 0x5008 */ + uint32_t RESERVED11[1023]; /*!< Reserved, Address offset: 0x500C-0x6004 */ + __IO uint32_t AXI_TARG5_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 5 bus matrix issuing functionality register, Address offset: 0x6008 */ + uint32_t RESERVED12[1023]; /*!< Reserved, Address offset: 0x600C-0x7004 */ + __IO uint32_t AXI_TARG6_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 6 bus matrix issuing functionality register, Address offset: 0x7008 */ + uint32_t RESERVED13[1023]; /*!< Reserved, Address offset: 0x700C-0x8004 */ + __IO uint32_t AXI_TARG7_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 7 bus matrix issuing functionality register, Address offset: 0x8008 */ + uint32_t RESERVED14[6]; /*!< Reserved, Address offset: 0x800C-0x8020 */ + __IO uint32_t AXI_TARG7_FN_MOD2; /*!< AXI interconnect - TARG 7 bus matrix functionality 2 register, Address offset: 0x8024 */ + uint32_t RESERVED15; /*!< Reserved, Address offset: 0x8028 */ + __IO uint32_t AXI_TARG7_FN_MOD_LB; /*!< AXI interconnect - TARG 7 long burst functionality modification register, Address offset: 0x802C */ + uint32_t RESERVED16[54]; /*!< Reserved, Address offset: 0x8030-0x8104 */ + __IO uint32_t AXI_TARG7_FN_MOD; /*!< AXI interconnect - TARG 7 issuing functionality modification register, Address offset: 0x8108 */ + uint32_t RESERVED17[959]; /*!< Reserved, Address offset: 0x810C-0x9004 */ + __IO uint32_t AXI_TARG8_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 8 bus matrix issuing functionality register, Address offset: 0x9008 */ + uint32_t RESERVED117[6]; /*!< Reserved, Address offset: 0x900C-0x9020 */ + __IO uint32_t AXI_TARG8_FN_MOD2; /*!< AXI interconnect - TARG 8 bus matrix functionality 2 register, Address offset: 0x9024 */ + uint32_t RESERVED118[56]; /*!< Reserved, Address offset: 0x9028-0x9104 */ + __IO uint32_t AXI_TARG8_FN_MOD; /*!< AXI interconnect - TARG 8 issuing functionality modification register, Address offset: 0x9108 */ + uint32_t RESERVED119[58310]; /*!< Reserved, Address offset: 0x910C-0x42020 */ + __IO uint32_t AXI_INI1_FN_MOD2; /*!< AXI interconnect - INI 1 functionality modification 2 register, Address offset: 0x42024 */ + __IO uint32_t AXI_INI1_FN_MOD_AHB; /*!< AXI interconnect - INI 1 AHB functionality modification register, Address offset: 0x42028 */ + uint32_t RESERVED18[53]; /*!< Reserved, Address offset: 0x4202C-0x420FC */ + __IO uint32_t AXI_INI1_READ_QOS; /*!< AXI interconnect - INI 1 read QoS register, Address offset: 0x42100 */ + __IO uint32_t AXI_INI1_WRITE_QOS; /*!< AXI interconnect - INI 1 write QoS register, Address offset: 0x42104 */ + __IO uint32_t AXI_INI1_FN_MOD; /*!< AXI interconnect - INI 1 issuing functionality modification register, Address offset: 0x42108 */ + uint32_t RESERVED19[1021]; /*!< Reserved, Address offset: 0x4210C-0x430FC */ + __IO uint32_t AXI_INI2_READ_QOS; /*!< AXI interconnect - INI 2 read QoS register, Address offset: 0x43100 */ + __IO uint32_t AXI_INI2_WRITE_QOS; /*!< AXI interconnect - INI 2 write QoS register, Address offset: 0x43104 */ + __IO uint32_t AXI_INI2_FN_MOD; /*!< AXI interconnect - INI 2 issuing functionality modification register, Address offset: 0x43108 */ + uint32_t RESERVED20[966]; /*!< Reserved, Address offset: 0x4310C-0x44020 */ + __IO uint32_t AXI_INI3_FN_MOD2; /*!< AXI interconnect - INI 3 functionality modification 2 register, Address offset: 0x44024 */ + __IO uint32_t AXI_INI3_FN_MOD_AHB; /*!< AXI interconnect - INI 3 AHB functionality modification register, Address offset: 0x44028 */ + uint32_t RESERVED21[53]; /*!< Reserved, Address offset: 0x4402C-0x440FC */ + __IO uint32_t AXI_INI3_READ_QOS; /*!< AXI interconnect - INI 3 read QoS register, Address offset: 0x44100 */ + __IO uint32_t AXI_INI3_WRITE_QOS; /*!< AXI interconnect - INI 3 write QoS register, Address offset: 0x44104 */ + __IO uint32_t AXI_INI3_FN_MOD; /*!< AXI interconnect - INI 3 issuing functionality modification register, Address offset: 0x44108 */ + uint32_t RESERVED22[1021]; /*!< Reserved, Address offset: 0x4410C-0x450FC */ + __IO uint32_t AXI_INI4_READ_QOS; /*!< AXI interconnect - INI 4 read QoS register, Address offset: 0x45100 */ + __IO uint32_t AXI_INI4_WRITE_QOS; /*!< AXI interconnect - INI 4 write QoS register, Address offset: 0x45104 */ + __IO uint32_t AXI_INI4_FN_MOD; /*!< AXI interconnect - INI 4 issuing functionality modification register, Address offset: 0x45108 */ + uint32_t RESERVED23[1021]; /*!< Reserved, Address offset: 0x4510C-0x460FC */ + __IO uint32_t AXI_INI5_READ_QOS; /*!< AXI interconnect - INI 5 read QoS register, Address offset: 0x46100 */ + __IO uint32_t AXI_INI5_WRITE_QOS; /*!< AXI interconnect - INI 5 write QoS register, Address offset: 0x46104 */ + __IO uint32_t AXI_INI5_FN_MOD; /*!< AXI interconnect - INI 5 issuing functionality modification register, Address offset: 0x46108 */ + uint32_t RESERVED24[1021]; /*!< Reserved, Address offset: 0x4610C-0x470FC */ + __IO uint32_t AXI_INI6_READ_QOS; /*!< AXI interconnect - INI 6 read QoS register, Address offset: 0x47100 */ + __IO uint32_t AXI_INI6_WRITE_QOS; /*!< AXI interconnect - INI 6 write QoS register, Address offset: 0x47104 */ + __IO uint32_t AXI_INI6_FN_MOD; /*!< AXI interconnect - INI 6 issuing functionality modification register, Address offset: 0x47108 */ + +} GPV_TypeDef; + +/** @addtogroup Peripheral_memory_map + * @{ + */ +#define D1_ITCMRAM_BASE (0x00000000UL) /*!< Base address of : 64KB RAM reserved for CPU execution/instruction accessible over ITCM */ +#define D1_ITCMICP_BASE (0x00100000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over ITCM */ +#define D1_DTCMRAM_BASE (0x20000000UL) /*!< Base address of : 128KB system data RAM accessible over DTCM */ +#define D1_AXIFLASH_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) embedded FLASH memory accessible over AXI */ +#define D1_AXIICP_BASE (0x1FF00000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over AXI */ +#define D1_AXISRAM1_BASE (0x24000000UL) /*!< Base address of : (up to 128KB) system data RAM1 accessible over over AXI */ +#define D1_AXISRAM2_BASE (0x24020000UL) /*!< Base address of : (up to 192KB) system data RAM2 accessible over over AXI to be shared with ITCM (64K granularity) */ +#define D1_AXISRAM_BASE D1_AXISRAM1_BASE /*!< Base address of : (up to 320KB) system data RAM1/2 accessible over over AXI */ + +#define D2_AHBSRAM1_BASE (0x30000000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ +#define D2_AHBSRAM2_BASE (0x30004000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ +#define D2_AHBSRAM_BASE D2_AHBSRAM1_BASE /*!< Base address of : (up to 32KB) system data RAM1/2 accessible over over AXI->AHB Bridge */ + +#define D3_BKPSRAM_BASE (0x38800000UL) /*!< Base address of : Backup SRAM(4 KB) over AXI->AHB Bridge */ +#define D3_SRAM_BASE (0x38000000UL) /*!< Base address of : Backup SRAM(16 KB) over AXI->AHB Bridge */ + +#define PERIPH_BASE (0x40000000UL) /*!< Base address of : AHB/APB Peripherals */ +#define OCTOSPI1_BASE (0x90000000UL) /*!< Base address of : OCTOSPI1 memories accessible over AXI */ +#define OCTOSPI2_BASE (0x70000000UL) /*!< Base address of : OCTOSPI2 memories accessible over AXI */ + +#define FLASH_BANK1_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) Flash Bank1 accessible over AXI */ +#define FLASH_END (0x080FFFFFUL) /*!< FLASH end address */ + + +/* Legacy define */ +#define FLASH_BASE FLASH_BANK1_BASE + +/*!< Device electronic signature memory map */ +#define UID_BASE (0x1FF1E800UL) /*!< Unique device ID register base address */ +#define FLASHSIZE_BASE (0x1FF1E880UL) /*!< FLASH Size register base address */ + + +/*!< Peripheral memory map */ +#define D2_APB1PERIPH_BASE PERIPH_BASE +#define D2_APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) +#define D2_AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) +#define D2_AHB2PERIPH_BASE (PERIPH_BASE + 0x08020000UL) + +#define D1_APB1PERIPH_BASE (PERIPH_BASE + 0x10000000UL) +#define D1_AHB1PERIPH_BASE (PERIPH_BASE + 0x12000000UL) + +#define D3_APB1PERIPH_BASE (PERIPH_BASE + 0x18000000UL) +#define D3_AHB1PERIPH_BASE (PERIPH_BASE + 0x18020000UL) + +/*!< Legacy Peripheral memory map */ +#define APB1PERIPH_BASE PERIPH_BASE +#define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) +#define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) +#define AHB2PERIPH_BASE (PERIPH_BASE + 0x08000000UL) + + +/*!< D1_AHB1PERIPH peripherals */ + +#define MDMA_BASE (D1_AHB1PERIPH_BASE + 0x0000UL) +#define DMA2D_BASE (D1_AHB1PERIPH_BASE + 0x1000UL) +#define FLASH_R_BASE (D1_AHB1PERIPH_BASE + 0x2000UL) +#define FMC_R_BASE (D1_AHB1PERIPH_BASE + 0x4000UL) +#define OCTOSPI1_R_BASE (D1_AHB1PERIPH_BASE + 0x5000UL) +#define DLYB_OCTOSPI1_BASE (D1_AHB1PERIPH_BASE + 0x6000UL) +#define SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x7000UL) +#define DLYB_SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x8000UL) +#define RAMECC1_BASE (D1_AHB1PERIPH_BASE + 0x9000UL) +#define OCTOSPI2_R_BASE (D1_AHB1PERIPH_BASE + 0xA000UL) +#define DLYB_OCTOSPI2_BASE (D1_AHB1PERIPH_BASE + 0xB000UL) +#define OCTOSPIM_BASE (D1_AHB1PERIPH_BASE + 0xB400UL) + +#define OTFDEC1_BASE (D1_AHB1PERIPH_BASE + 0xB800UL) +#define OTFDEC1_REGION1_BASE (OTFDEC1_BASE + 0x20UL) +#define OTFDEC1_REGION2_BASE (OTFDEC1_BASE + 0x50UL) +#define OTFDEC1_REGION3_BASE (OTFDEC1_BASE + 0x80UL) +#define OTFDEC1_REGION4_BASE (OTFDEC1_BASE + 0xB0UL) +#define OTFDEC2_BASE (D1_AHB1PERIPH_BASE + 0xBC00UL) +#define OTFDEC2_REGION1_BASE (OTFDEC2_BASE + 0x20UL) +#define OTFDEC2_REGION2_BASE (OTFDEC2_BASE + 0x50UL) +#define OTFDEC2_REGION3_BASE (OTFDEC2_BASE + 0x80UL) +#define OTFDEC2_REGION4_BASE (OTFDEC2_BASE + 0xB0UL) + +/*!< D2_AHB1PERIPH peripherals */ + +#define DMA1_BASE (D2_AHB1PERIPH_BASE + 0x0000UL) +#define DMA2_BASE (D2_AHB1PERIPH_BASE + 0x0400UL) +#define DMAMUX1_BASE (D2_AHB1PERIPH_BASE + 0x0800UL) +#define ADC1_BASE (D2_AHB1PERIPH_BASE + 0x2000UL) +#define ADC2_BASE (D2_AHB1PERIPH_BASE + 0x2100UL) +#define ADC12_COMMON_BASE (D2_AHB1PERIPH_BASE + 0x2300UL) +#define ETH_BASE (D2_AHB1PERIPH_BASE + 0x8000UL) +#define ETH_MAC_BASE (ETH_BASE) + +/*!< USB registers base address */ +#define USB1_OTG_HS_PERIPH_BASE (0x40040000UL) +#define USB_OTG_GLOBAL_BASE (0x000UL) +#define USB_OTG_DEVICE_BASE (0x800UL) +#define USB_OTG_IN_ENDPOINT_BASE (0x900UL) +#define USB_OTG_OUT_ENDPOINT_BASE (0xB00UL) +#define USB_OTG_EP_REG_SIZE (0x20UL) +#define USB_OTG_HOST_BASE (0x400UL) +#define USB_OTG_HOST_PORT_BASE (0x440UL) +#define USB_OTG_HOST_CHANNEL_BASE (0x500UL) +#define USB_OTG_HOST_CHANNEL_SIZE (0x20UL) +#define USB_OTG_PCGCCTL_BASE (0xE00UL) +#define USB_OTG_FIFO_BASE (0x1000UL) +#define USB_OTG_FIFO_SIZE (0x1000UL) + +/*!< D2_AHB2PERIPH peripherals */ + +#define DCMI_BASE (D2_AHB2PERIPH_BASE + 0x0000UL) +#define PSSI_BASE (D2_AHB2PERIPH_BASE + 0x0400UL) +#define CRYP_BASE (D2_AHB2PERIPH_BASE + 0x1000UL) +#define HASH_BASE (D2_AHB2PERIPH_BASE + 0x1400UL) +#define HASH_DIGEST_BASE (D2_AHB2PERIPH_BASE + 0x1710UL) +#define RNG_BASE (D2_AHB2PERIPH_BASE + 0x1800UL) +#define SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2400UL) +#define DLYB_SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2800UL) +#define RAMECC2_BASE (D2_AHB2PERIPH_BASE + 0x3000UL) +#define FMAC_BASE (D2_AHB2PERIPH_BASE + 0x4000UL) +#define CORDIC_BASE (D2_AHB2PERIPH_BASE + 0x4400UL) + +/*!< D3_AHB1PERIPH peripherals */ +#define GPIOA_BASE (D3_AHB1PERIPH_BASE + 0x0000UL) +#define GPIOB_BASE (D3_AHB1PERIPH_BASE + 0x0400UL) +#define GPIOC_BASE (D3_AHB1PERIPH_BASE + 0x0800UL) +#define GPIOD_BASE (D3_AHB1PERIPH_BASE + 0x0C00UL) +#define GPIOE_BASE (D3_AHB1PERIPH_BASE + 0x1000UL) +#define GPIOF_BASE (D3_AHB1PERIPH_BASE + 0x1400UL) +#define GPIOG_BASE (D3_AHB1PERIPH_BASE + 0x1800UL) +#define GPIOH_BASE (D3_AHB1PERIPH_BASE + 0x1C00UL) +#define GPIOJ_BASE (D3_AHB1PERIPH_BASE + 0x2400UL) +#define GPIOK_BASE (D3_AHB1PERIPH_BASE + 0x2800UL) +#define RCC_BASE (D3_AHB1PERIPH_BASE + 0x4400UL) +#define PWR_BASE (D3_AHB1PERIPH_BASE + 0x4800UL) +#define CRC_BASE (D3_AHB1PERIPH_BASE + 0x4C00UL) +#define BDMA_BASE (D3_AHB1PERIPH_BASE + 0x5400UL) +#define DMAMUX2_BASE (D3_AHB1PERIPH_BASE + 0x5800UL) +#define ADC3_BASE (D3_AHB1PERIPH_BASE + 0x6000UL) +#define ADC3_COMMON_BASE (D3_AHB1PERIPH_BASE + 0x6300UL) +#define HSEM_BASE (D3_AHB1PERIPH_BASE + 0x6400UL) +#define RAMECC3_BASE (D3_AHB1PERIPH_BASE + 0x7000UL) + +/*!< D1_APB1PERIPH peripherals */ +#define LTDC_BASE (D1_APB1PERIPH_BASE + 0x1000UL) +#define LTDC_Layer1_BASE (LTDC_BASE + 0x84UL) +#define LTDC_Layer2_BASE (LTDC_BASE + 0x104UL) +#define WWDG1_BASE (D1_APB1PERIPH_BASE + 0x3000UL) + +/*!< D2_APB1PERIPH peripherals */ +#define TIM2_BASE (D2_APB1PERIPH_BASE + 0x0000UL) +#define TIM3_BASE (D2_APB1PERIPH_BASE + 0x0400UL) +#define TIM4_BASE (D2_APB1PERIPH_BASE + 0x0800UL) +#define TIM5_BASE (D2_APB1PERIPH_BASE + 0x0C00UL) +#define TIM6_BASE (D2_APB1PERIPH_BASE + 0x1000UL) +#define TIM7_BASE (D2_APB1PERIPH_BASE + 0x1400UL) +#define TIM12_BASE (D2_APB1PERIPH_BASE + 0x1800UL) +#define TIM13_BASE (D2_APB1PERIPH_BASE + 0x1C00UL) +#define TIM14_BASE (D2_APB1PERIPH_BASE + 0x2000UL) +#define LPTIM1_BASE (D2_APB1PERIPH_BASE + 0x2400UL) + + +#define SPI2_BASE (D2_APB1PERIPH_BASE + 0x3800UL) +#define SPI3_BASE (D2_APB1PERIPH_BASE + 0x3C00UL) +#define SPDIFRX_BASE (D2_APB1PERIPH_BASE + 0x4000UL) +#define USART2_BASE (D2_APB1PERIPH_BASE + 0x4400UL) +#define USART3_BASE (D2_APB1PERIPH_BASE + 0x4800UL) +#define UART4_BASE (D2_APB1PERIPH_BASE + 0x4C00UL) +#define UART5_BASE (D2_APB1PERIPH_BASE + 0x5000UL) +#define I2C1_BASE (D2_APB1PERIPH_BASE + 0x5400UL) +#define I2C2_BASE (D2_APB1PERIPH_BASE + 0x5800UL) +#define I2C3_BASE (D2_APB1PERIPH_BASE + 0x5C00UL) +#define I2C5_BASE (D2_APB1PERIPH_BASE + 0x6400UL) +#define CEC_BASE (D2_APB1PERIPH_BASE + 0x6C00UL) +#define DAC1_BASE (D2_APB1PERIPH_BASE + 0x7400UL) +#define UART7_BASE (D2_APB1PERIPH_BASE + 0x7800UL) +#define UART8_BASE (D2_APB1PERIPH_BASE + 0x7C00UL) +#define CRS_BASE (D2_APB1PERIPH_BASE + 0x8400UL) +#define SWPMI1_BASE (D2_APB1PERIPH_BASE + 0x8800UL) +#define OPAMP_BASE (D2_APB1PERIPH_BASE + 0x9000UL) +#define OPAMP1_BASE (D2_APB1PERIPH_BASE + 0x9000UL) +#define OPAMP2_BASE (D2_APB1PERIPH_BASE + 0x9010UL) +#define MDIOS_BASE (D2_APB1PERIPH_BASE + 0x9400UL) +#define FDCAN1_BASE (D2_APB1PERIPH_BASE + 0xA000UL) +#define FDCAN2_BASE (D2_APB1PERIPH_BASE + 0xA400UL) +#define FDCAN_CCU_BASE (D2_APB1PERIPH_BASE + 0xA800UL) +#define SRAMCAN_BASE (D2_APB1PERIPH_BASE + 0xAC00UL) +#define FDCAN3_BASE (D2_APB1PERIPH_BASE + 0xD400UL) +#define TIM23_BASE (D2_APB1PERIPH_BASE + 0xE000UL) +#define TIM24_BASE (D2_APB1PERIPH_BASE + 0xE400UL) + +/*!< D2_APB2PERIPH peripherals */ + +#define TIM1_BASE (D2_APB2PERIPH_BASE + 0x0000UL) +#define TIM8_BASE (D2_APB2PERIPH_BASE + 0x0400UL) +#define USART1_BASE (D2_APB2PERIPH_BASE + 0x1000UL) +#define USART6_BASE (D2_APB2PERIPH_BASE + 0x1400UL) +#define UART9_BASE (D2_APB2PERIPH_BASE + 0x1800UL) +#define USART10_BASE (D2_APB2PERIPH_BASE + 0x1C00UL) +#define SPI1_BASE (D2_APB2PERIPH_BASE + 0x3000UL) +#define SPI4_BASE (D2_APB2PERIPH_BASE + 0x3400UL) +#define TIM15_BASE (D2_APB2PERIPH_BASE + 0x4000UL) +#define TIM16_BASE (D2_APB2PERIPH_BASE + 0x4400UL) +#define TIM17_BASE (D2_APB2PERIPH_BASE + 0x4800UL) +#define SPI5_BASE (D2_APB2PERIPH_BASE + 0x5000UL) +#define SAI1_BASE (D2_APB2PERIPH_BASE + 0x5800UL) +#define SAI1_Block_A_BASE (SAI1_BASE + 0x004UL) +#define SAI1_Block_B_BASE (SAI1_BASE + 0x024UL) +#define DFSDM1_BASE (D2_APB2PERIPH_BASE + 0x7800UL) +#define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00UL) +#define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20UL) +#define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40UL) +#define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60UL) +#define DFSDM1_Channel4_BASE (DFSDM1_BASE + 0x80UL) +#define DFSDM1_Channel5_BASE (DFSDM1_BASE + 0xA0UL) +#define DFSDM1_Channel6_BASE (DFSDM1_BASE + 0xC0UL) +#define DFSDM1_Channel7_BASE (DFSDM1_BASE + 0xE0UL) +#define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100UL) +#define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180UL) +#define DFSDM1_Filter2_BASE (DFSDM1_BASE + 0x200UL) +#define DFSDM1_Filter3_BASE (DFSDM1_BASE + 0x280UL) + + +/*!< D3_APB1PERIPH peripherals */ +#define EXTI_BASE (D3_APB1PERIPH_BASE + 0x0000UL) +#define EXTI_D1_BASE (EXTI_BASE + 0x0080UL) +#define EXTI_D2_BASE (EXTI_BASE + 0x00C0UL) +#define SYSCFG_BASE (D3_APB1PERIPH_BASE + 0x0400UL) +#define LPUART1_BASE (D3_APB1PERIPH_BASE + 0x0C00UL) +#define SPI6_BASE (D3_APB1PERIPH_BASE + 0x1400UL) +#define I2C4_BASE (D3_APB1PERIPH_BASE + 0x1C00UL) +#define LPTIM2_BASE (D3_APB1PERIPH_BASE + 0x2400UL) +#define LPTIM3_BASE (D3_APB1PERIPH_BASE + 0x2800UL) +#define LPTIM4_BASE (D3_APB1PERIPH_BASE + 0x2C00UL) +#define LPTIM5_BASE (D3_APB1PERIPH_BASE + 0x3000UL) +#define COMP12_BASE (D3_APB1PERIPH_BASE + 0x3800UL) +#define COMP1_BASE (COMP12_BASE + 0x0CUL) +#define COMP2_BASE (COMP12_BASE + 0x10UL) +#define VREFBUF_BASE (D3_APB1PERIPH_BASE + 0x3C00UL) +#define RTC_BASE (D3_APB1PERIPH_BASE + 0x4000UL) +#define IWDG1_BASE (D3_APB1PERIPH_BASE + 0x4800UL) + + +#define SAI4_BASE (D3_APB1PERIPH_BASE + 0x5400UL) +#define SAI4_Block_A_BASE (SAI4_BASE + 0x004UL) +#define SAI4_Block_B_BASE (SAI4_BASE + 0x024UL) + +#define DTS_BASE (D3_APB1PERIPH_BASE + 0x6800UL) + + + +#define BDMA_Channel0_BASE (BDMA_BASE + 0x0008UL) +#define BDMA_Channel1_BASE (BDMA_BASE + 0x001CUL) +#define BDMA_Channel2_BASE (BDMA_BASE + 0x0030UL) +#define BDMA_Channel3_BASE (BDMA_BASE + 0x0044UL) +#define BDMA_Channel4_BASE (BDMA_BASE + 0x0058UL) +#define BDMA_Channel5_BASE (BDMA_BASE + 0x006CUL) +#define BDMA_Channel6_BASE (BDMA_BASE + 0x0080UL) +#define BDMA_Channel7_BASE (BDMA_BASE + 0x0094UL) + +#define DMAMUX2_Channel0_BASE (DMAMUX2_BASE) +#define DMAMUX2_Channel1_BASE (DMAMUX2_BASE + 0x0004UL) +#define DMAMUX2_Channel2_BASE (DMAMUX2_BASE + 0x0008UL) +#define DMAMUX2_Channel3_BASE (DMAMUX2_BASE + 0x000CUL) +#define DMAMUX2_Channel4_BASE (DMAMUX2_BASE + 0x0010UL) +#define DMAMUX2_Channel5_BASE (DMAMUX2_BASE + 0x0014UL) +#define DMAMUX2_Channel6_BASE (DMAMUX2_BASE + 0x0018UL) +#define DMAMUX2_Channel7_BASE (DMAMUX2_BASE + 0x001CUL) + +#define DMAMUX2_RequestGenerator0_BASE (DMAMUX2_BASE + 0x0100UL) +#define DMAMUX2_RequestGenerator1_BASE (DMAMUX2_BASE + 0x0104UL) +#define DMAMUX2_RequestGenerator2_BASE (DMAMUX2_BASE + 0x0108UL) +#define DMAMUX2_RequestGenerator3_BASE (DMAMUX2_BASE + 0x010CUL) +#define DMAMUX2_RequestGenerator4_BASE (DMAMUX2_BASE + 0x0110UL) +#define DMAMUX2_RequestGenerator5_BASE (DMAMUX2_BASE + 0x0114UL) +#define DMAMUX2_RequestGenerator6_BASE (DMAMUX2_BASE + 0x0118UL) +#define DMAMUX2_RequestGenerator7_BASE (DMAMUX2_BASE + 0x011CUL) + +#define DMAMUX2_ChannelStatus_BASE (DMAMUX2_BASE + 0x0080UL) +#define DMAMUX2_RequestGenStatus_BASE (DMAMUX2_BASE + 0x0140UL) + +#define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) +#define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) +#define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) +#define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) +#define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) +#define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) +#define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) +#define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) + +#define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) +#define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) +#define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) +#define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) +#define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) +#define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) +#define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) +#define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) + +#define DMAMUX1_Channel0_BASE (DMAMUX1_BASE) +#define DMAMUX1_Channel1_BASE (DMAMUX1_BASE + 0x0004UL) +#define DMAMUX1_Channel2_BASE (DMAMUX1_BASE + 0x0008UL) +#define DMAMUX1_Channel3_BASE (DMAMUX1_BASE + 0x000CUL) +#define DMAMUX1_Channel4_BASE (DMAMUX1_BASE + 0x0010UL) +#define DMAMUX1_Channel5_BASE (DMAMUX1_BASE + 0x0014UL) +#define DMAMUX1_Channel6_BASE (DMAMUX1_BASE + 0x0018UL) +#define DMAMUX1_Channel7_BASE (DMAMUX1_BASE + 0x001CUL) +#define DMAMUX1_Channel8_BASE (DMAMUX1_BASE + 0x0020UL) +#define DMAMUX1_Channel9_BASE (DMAMUX1_BASE + 0x0024UL) +#define DMAMUX1_Channel10_BASE (DMAMUX1_BASE + 0x0028UL) +#define DMAMUX1_Channel11_BASE (DMAMUX1_BASE + 0x002CUL) +#define DMAMUX1_Channel12_BASE (DMAMUX1_BASE + 0x0030UL) +#define DMAMUX1_Channel13_BASE (DMAMUX1_BASE + 0x0034UL) +#define DMAMUX1_Channel14_BASE (DMAMUX1_BASE + 0x0038UL) +#define DMAMUX1_Channel15_BASE (DMAMUX1_BASE + 0x003CUL) + +#define DMAMUX1_RequestGenerator0_BASE (DMAMUX1_BASE + 0x0100UL) +#define DMAMUX1_RequestGenerator1_BASE (DMAMUX1_BASE + 0x0104UL) +#define DMAMUX1_RequestGenerator2_BASE (DMAMUX1_BASE + 0x0108UL) +#define DMAMUX1_RequestGenerator3_BASE (DMAMUX1_BASE + 0x010CUL) +#define DMAMUX1_RequestGenerator4_BASE (DMAMUX1_BASE + 0x0110UL) +#define DMAMUX1_RequestGenerator5_BASE (DMAMUX1_BASE + 0x0114UL) +#define DMAMUX1_RequestGenerator6_BASE (DMAMUX1_BASE + 0x0118UL) +#define DMAMUX1_RequestGenerator7_BASE (DMAMUX1_BASE + 0x011CUL) + +#define DMAMUX1_ChannelStatus_BASE (DMAMUX1_BASE + 0x0080UL) +#define DMAMUX1_RequestGenStatus_BASE (DMAMUX1_BASE + 0x0140UL) + +/*!< FMC Banks registers base address */ +#define FMC_Bank1_R_BASE (FMC_R_BASE + 0x0000UL) +#define FMC_Bank1E_R_BASE (FMC_R_BASE + 0x0104UL) +#define FMC_Bank2_R_BASE (FMC_R_BASE + 0x0060UL) +#define FMC_Bank3_R_BASE (FMC_R_BASE + 0x0080UL) +#define FMC_Bank5_6_R_BASE (FMC_R_BASE + 0x0140UL) + +/* Debug MCU registers base address */ +#define DBGMCU_BASE (0x5C001000UL) + +#define MDMA_Channel0_BASE (MDMA_BASE + 0x00000040UL) +#define MDMA_Channel1_BASE (MDMA_BASE + 0x00000080UL) +#define MDMA_Channel2_BASE (MDMA_BASE + 0x000000C0UL) +#define MDMA_Channel3_BASE (MDMA_BASE + 0x00000100UL) +#define MDMA_Channel4_BASE (MDMA_BASE + 0x00000140UL) +#define MDMA_Channel5_BASE (MDMA_BASE + 0x00000180UL) +#define MDMA_Channel6_BASE (MDMA_BASE + 0x000001C0UL) +#define MDMA_Channel7_BASE (MDMA_BASE + 0x00000200UL) +#define MDMA_Channel8_BASE (MDMA_BASE + 0x00000240UL) +#define MDMA_Channel9_BASE (MDMA_BASE + 0x00000280UL) +#define MDMA_Channel10_BASE (MDMA_BASE + 0x000002C0UL) +#define MDMA_Channel11_BASE (MDMA_BASE + 0x00000300UL) +#define MDMA_Channel12_BASE (MDMA_BASE + 0x00000340UL) +#define MDMA_Channel13_BASE (MDMA_BASE + 0x00000380UL) +#define MDMA_Channel14_BASE (MDMA_BASE + 0x000003C0UL) +#define MDMA_Channel15_BASE (MDMA_BASE + 0x00000400UL) + +#define RAMECC1_Monitor1_BASE (RAMECC1_BASE + 0x20UL) +#define RAMECC1_Monitor2_BASE (RAMECC1_BASE + 0x40UL) +#define RAMECC1_Monitor3_BASE (RAMECC1_BASE + 0x60UL) +#define RAMECC1_Monitor4_BASE (RAMECC1_BASE + 0x80UL) +#define RAMECC1_Monitor5_BASE (RAMECC1_BASE + 0xA0UL) +#define RAMECC1_Monitor6_BASE (RAMECC1_BASE + 0xC0UL) + +#define RAMECC2_Monitor1_BASE (RAMECC2_BASE + 0x20UL) +#define RAMECC2_Monitor2_BASE (RAMECC2_BASE + 0x40UL) +#define RAMECC2_Monitor3_BASE (RAMECC2_BASE + 0x60UL) + +#define RAMECC3_Monitor1_BASE (RAMECC3_BASE + 0x20UL) +#define RAMECC3_Monitor2_BASE (RAMECC3_BASE + 0x40UL) + + + +#define GPV_BASE (PERIPH_BASE + 0x11000000UL) /*!< GPV_BASE (PERIPH_BASE + 0x11000000UL) */ + +/** + * @} + */ + +/** @addtogroup Peripheral_declaration + * @{ + */ +#define TIM2 ((TIM_TypeDef *) TIM2_BASE) +#define TIM3 ((TIM_TypeDef *) TIM3_BASE) +#define TIM4 ((TIM_TypeDef *) TIM4_BASE) +#define TIM5 ((TIM_TypeDef *) TIM5_BASE) +#define TIM6 ((TIM_TypeDef *) TIM6_BASE) +#define TIM7 ((TIM_TypeDef *) TIM7_BASE) +#define TIM13 ((TIM_TypeDef *) TIM13_BASE) +#define TIM14 ((TIM_TypeDef *) TIM14_BASE) +#define VREFBUF ((VREFBUF_TypeDef *) VREFBUF_BASE) +#define RTC ((RTC_TypeDef *) RTC_BASE) +#define WWDG1 ((WWDG_TypeDef *) WWDG1_BASE) + + +#define IWDG1 ((IWDG_TypeDef *) IWDG1_BASE) +#define SPI2 ((SPI_TypeDef *) SPI2_BASE) +#define SPI3 ((SPI_TypeDef *) SPI3_BASE) +#define SPI4 ((SPI_TypeDef *) SPI4_BASE) +#define SPI5 ((SPI_TypeDef *) SPI5_BASE) +#define SPI6 ((SPI_TypeDef *) SPI6_BASE) +#define USART2 ((USART_TypeDef *) USART2_BASE) +#define USART3 ((USART_TypeDef *) USART3_BASE) +#define USART6 ((USART_TypeDef *) USART6_BASE) +#define USART10 ((USART_TypeDef *) USART10_BASE) +#define UART7 ((USART_TypeDef *) UART7_BASE) +#define UART8 ((USART_TypeDef *) UART8_BASE) +#define UART9 ((USART_TypeDef *) UART9_BASE) +#define CRS ((CRS_TypeDef *) CRS_BASE) +#define UART4 ((USART_TypeDef *) UART4_BASE) +#define UART5 ((USART_TypeDef *) UART5_BASE) +#define I2C1 ((I2C_TypeDef *) I2C1_BASE) +#define I2C2 ((I2C_TypeDef *) I2C2_BASE) +#define I2C3 ((I2C_TypeDef *) I2C3_BASE) +#define I2C4 ((I2C_TypeDef *) I2C4_BASE) +#define I2C5 ((I2C_TypeDef *) I2C5_BASE) +#define FDCAN1 ((FDCAN_GlobalTypeDef *) FDCAN1_BASE) +#define FDCAN2 ((FDCAN_GlobalTypeDef *) FDCAN2_BASE) +#define FDCAN_CCU ((FDCAN_ClockCalibrationUnit_TypeDef *) FDCAN_CCU_BASE) +#define FDCAN3 ((FDCAN_GlobalTypeDef *) FDCAN3_BASE) +#define TIM23 ((TIM_TypeDef *) TIM23_BASE) +#define TIM24 ((TIM_TypeDef *) TIM24_BASE) +#define CEC ((CEC_TypeDef *) CEC_BASE) +#define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE) +#define PWR ((PWR_TypeDef *) PWR_BASE) +#define DAC1 ((DAC_TypeDef *) DAC1_BASE) +#define LPUART1 ((USART_TypeDef *) LPUART1_BASE) +#define SWPMI1 ((SWPMI_TypeDef *) SWPMI1_BASE) +#define LPTIM2 ((LPTIM_TypeDef *) LPTIM2_BASE) +#define LPTIM3 ((LPTIM_TypeDef *) LPTIM3_BASE) +#define DTS ((DTS_TypeDef *) DTS_BASE) +#define LPTIM4 ((LPTIM_TypeDef *) LPTIM4_BASE) +#define LPTIM5 ((LPTIM_TypeDef *) LPTIM5_BASE) + +#define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) +#define COMP12 ((COMPOPT_TypeDef *) COMP12_BASE) +#define COMP1 ((COMP_TypeDef *) COMP1_BASE) +#define COMP2 ((COMP_TypeDef *) COMP2_BASE) +#define COMP12_COMMON ((COMP_Common_TypeDef *) COMP2_BASE) +#define OPAMP ((OPAMP_TypeDef *) OPAMP_BASE) +#define OPAMP1 ((OPAMP_TypeDef *) OPAMP1_BASE) +#define OPAMP2 ((OPAMP_TypeDef *) OPAMP2_BASE) + + +#define EXTI ((EXTI_TypeDef *) EXTI_BASE) +#define EXTI_D1 ((EXTI_Core_TypeDef *) EXTI_D1_BASE) +#define EXTI_D2 ((EXTI_Core_TypeDef *) EXTI_D2_BASE) +#define TIM1 ((TIM_TypeDef *) TIM1_BASE) +#define SPI1 ((SPI_TypeDef *) SPI1_BASE) +#define TIM8 ((TIM_TypeDef *) TIM8_BASE) +#define USART1 ((USART_TypeDef *) USART1_BASE) +#define TIM12 ((TIM_TypeDef *) TIM12_BASE) +#define TIM15 ((TIM_TypeDef *) TIM15_BASE) +#define TIM16 ((TIM_TypeDef *) TIM16_BASE) +#define TIM17 ((TIM_TypeDef *) TIM17_BASE) +#define SAI1 ((SAI_TypeDef *) SAI1_BASE) +#define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) +#define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) +#define SAI4 ((SAI_TypeDef *) SAI4_BASE) +#define SAI4_Block_A ((SAI_Block_TypeDef *)SAI4_Block_A_BASE) +#define SAI4_Block_B ((SAI_Block_TypeDef *)SAI4_Block_B_BASE) + +#define SPDIFRX ((SPDIFRX_TypeDef *) SPDIFRX_BASE) +#define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) +#define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) +#define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) +#define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) +#define DFSDM1_Channel4 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel4_BASE) +#define DFSDM1_Channel5 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel5_BASE) +#define DFSDM1_Channel6 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel6_BASE) +#define DFSDM1_Channel7 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel7_BASE) +#define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) +#define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) +#define DFSDM1_Filter2 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter2_BASE) +#define DFSDM1_Filter3 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter3_BASE) +#define DMA2D ((DMA2D_TypeDef *) DMA2D_BASE) +#define DCMI ((DCMI_TypeDef *) DCMI_BASE) +#define PSSI ((PSSI_TypeDef *) PSSI_BASE) +#define RCC ((RCC_TypeDef *) RCC_BASE) +#define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) +#define CRC ((CRC_TypeDef *) CRC_BASE) + +#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) +#define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) +#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) +#define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) +#define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) +#define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) +#define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) +#define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) +#define GPIOJ ((GPIO_TypeDef *) GPIOJ_BASE) +#define GPIOK ((GPIO_TypeDef *) GPIOK_BASE) + +#define ADC1 ((ADC_TypeDef *) ADC1_BASE) +#define ADC2 ((ADC_TypeDef *) ADC2_BASE) +#define ADC3 ((ADC_TypeDef *) ADC3_BASE) +#define ADC3_COMMON ((ADC_Common_TypeDef *) ADC3_COMMON_BASE) +#define ADC12_COMMON ((ADC_Common_TypeDef *) ADC12_COMMON_BASE) + +#define CRYP ((CRYP_TypeDef *) CRYP_BASE) +#define HASH ((HASH_TypeDef *) HASH_BASE) +#define HASH_DIGEST ((HASH_DIGEST_TypeDef *) HASH_DIGEST_BASE) +#define RNG ((RNG_TypeDef *) RNG_BASE) +#define SDMMC2 ((SDMMC_TypeDef *) SDMMC2_BASE) +#define DLYB_SDMMC2 ((DLYB_TypeDef *) DLYB_SDMMC2_BASE) +#define FMAC ((FMAC_TypeDef *) FMAC_BASE) +#define CORDIC ((CORDIC_TypeDef *) CORDIC_BASE) + +#define BDMA ((BDMA_TypeDef *) BDMA_BASE) +#define BDMA_Channel0 ((BDMA_Channel_TypeDef *) BDMA_Channel0_BASE) +#define BDMA_Channel1 ((BDMA_Channel_TypeDef *) BDMA_Channel1_BASE) +#define BDMA_Channel2 ((BDMA_Channel_TypeDef *) BDMA_Channel2_BASE) +#define BDMA_Channel3 ((BDMA_Channel_TypeDef *) BDMA_Channel3_BASE) +#define BDMA_Channel4 ((BDMA_Channel_TypeDef *) BDMA_Channel4_BASE) +#define BDMA_Channel5 ((BDMA_Channel_TypeDef *) BDMA_Channel5_BASE) +#define BDMA_Channel6 ((BDMA_Channel_TypeDef *) BDMA_Channel6_BASE) +#define BDMA_Channel7 ((BDMA_Channel_TypeDef *) BDMA_Channel7_BASE) + +#define RAMECC1 ((RAMECC_TypeDef *)RAMECC1_BASE) +#define RAMECC1_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor1_BASE) +#define RAMECC1_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor2_BASE) +#define RAMECC1_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor3_BASE) +#define RAMECC1_Monitor4 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor4_BASE) +#define RAMECC1_Monitor5 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor5_BASE) +#define RAMECC1_Monitor6 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor6_BASE) + +#define RAMECC2 ((RAMECC_TypeDef *)RAMECC2_BASE) +#define RAMECC2_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor1_BASE) +#define RAMECC2_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor2_BASE) +#define RAMECC2_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor3_BASE) + +#define RAMECC3 ((RAMECC_TypeDef *)RAMECC3_BASE) +#define RAMECC3_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor1_BASE) +#define RAMECC3_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor2_BASE) + +#define DMAMUX2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_BASE) +#define DMAMUX2_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel0_BASE) +#define DMAMUX2_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel1_BASE) +#define DMAMUX2_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel2_BASE) +#define DMAMUX2_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel3_BASE) +#define DMAMUX2_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel4_BASE) +#define DMAMUX2_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel5_BASE) +#define DMAMUX2_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel6_BASE) +#define DMAMUX2_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel7_BASE) + + +#define DMAMUX2_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator0_BASE) +#define DMAMUX2_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator1_BASE) +#define DMAMUX2_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator2_BASE) +#define DMAMUX2_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator3_BASE) +#define DMAMUX2_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator4_BASE) +#define DMAMUX2_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator5_BASE) +#define DMAMUX2_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator6_BASE) +#define DMAMUX2_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator7_BASE) + +#define DMAMUX2_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX2_ChannelStatus_BASE) +#define DMAMUX2_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX2_RequestGenStatus_BASE) + +#define DMA2 ((DMA_TypeDef *) DMA2_BASE) +#define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) +#define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) +#define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) +#define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) +#define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) +#define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) +#define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) +#define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) + +#define DMA1 ((DMA_TypeDef *) DMA1_BASE) +#define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) +#define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) +#define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) +#define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) +#define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) +#define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) +#define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) +#define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) + + +#define DMAMUX1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_BASE) +#define DMAMUX1_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel0_BASE) +#define DMAMUX1_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel1_BASE) +#define DMAMUX1_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel2_BASE) +#define DMAMUX1_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel3_BASE) +#define DMAMUX1_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel4_BASE) +#define DMAMUX1_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel5_BASE) +#define DMAMUX1_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel6_BASE) +#define DMAMUX1_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel7_BASE) +#define DMAMUX1_Channel8 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel8_BASE) +#define DMAMUX1_Channel9 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel9_BASE) +#define DMAMUX1_Channel10 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel10_BASE) +#define DMAMUX1_Channel11 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel11_BASE) +#define DMAMUX1_Channel12 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel12_BASE) +#define DMAMUX1_Channel13 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel13_BASE) +#define DMAMUX1_Channel14 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel14_BASE) +#define DMAMUX1_Channel15 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel15_BASE) + +#define DMAMUX1_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator0_BASE) +#define DMAMUX1_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator1_BASE) +#define DMAMUX1_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator2_BASE) +#define DMAMUX1_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator3_BASE) +#define DMAMUX1_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator4_BASE) +#define DMAMUX1_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator5_BASE) +#define DMAMUX1_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator6_BASE) +#define DMAMUX1_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator7_BASE) + +#define DMAMUX1_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX1_ChannelStatus_BASE) +#define DMAMUX1_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX1_RequestGenStatus_BASE) + + +#define FMC_Bank1_R ((FMC_Bank1_TypeDef *) FMC_Bank1_R_BASE) +#define FMC_Bank1E_R ((FMC_Bank1E_TypeDef *) FMC_Bank1E_R_BASE) +#define FMC_Bank2_R ((FMC_Bank2_TypeDef *) FMC_Bank2_R_BASE) +#define FMC_Bank3_R ((FMC_Bank3_TypeDef *) FMC_Bank3_R_BASE) +#define FMC_Bank5_6_R ((FMC_Bank5_6_TypeDef *) FMC_Bank5_6_R_BASE) + +#define OCTOSPI1 ((OCTOSPI_TypeDef *) OCTOSPI1_R_BASE) +#define DLYB_OCTOSPI1 ((DLYB_TypeDef *) DLYB_OCTOSPI1_BASE) +#define OCTOSPI2 ((OCTOSPI_TypeDef *) OCTOSPI2_R_BASE) +#define DLYB_OCTOSPI2 ((DLYB_TypeDef *) DLYB_OCTOSPI2_BASE) +#define OCTOSPIM ((OCTOSPIM_TypeDef *) OCTOSPIM_BASE) + +#define OTFDEC1 ((OTFDEC_TypeDef *) OTFDEC1_BASE) +#define OTFDEC1_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION1_BASE) +#define OTFDEC1_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION2_BASE) +#define OTFDEC1_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION3_BASE) +#define OTFDEC1_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION4_BASE) + +#define OTFDEC2 ((OTFDEC_TypeDef *) OTFDEC2_BASE) +#define OTFDEC2_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION1_BASE) +#define OTFDEC2_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION2_BASE) +#define OTFDEC2_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION3_BASE) +#define OTFDEC2_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION4_BASE) + +#define SDMMC1 ((SDMMC_TypeDef *) SDMMC1_BASE) +#define DLYB_SDMMC1 ((DLYB_TypeDef *) DLYB_SDMMC1_BASE) + +#define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) + +#define HSEM ((HSEM_TypeDef *) HSEM_BASE) +#define HSEM_COMMON ((HSEM_Common_TypeDef *) (HSEM_BASE + 0x100UL)) + +#define LTDC ((LTDC_TypeDef *)LTDC_BASE) +#define LTDC_Layer1 ((LTDC_Layer_TypeDef *)LTDC_Layer1_BASE) +#define LTDC_Layer2 ((LTDC_Layer_TypeDef *)LTDC_Layer2_BASE) + +#define MDIOS ((MDIOS_TypeDef *) MDIOS_BASE) + +#define ETH ((ETH_TypeDef *)ETH_BASE) +#define MDMA ((MDMA_TypeDef *)MDMA_BASE) +#define MDMA_Channel0 ((MDMA_Channel_TypeDef *)MDMA_Channel0_BASE) +#define MDMA_Channel1 ((MDMA_Channel_TypeDef *)MDMA_Channel1_BASE) +#define MDMA_Channel2 ((MDMA_Channel_TypeDef *)MDMA_Channel2_BASE) +#define MDMA_Channel3 ((MDMA_Channel_TypeDef *)MDMA_Channel3_BASE) +#define MDMA_Channel4 ((MDMA_Channel_TypeDef *)MDMA_Channel4_BASE) +#define MDMA_Channel5 ((MDMA_Channel_TypeDef *)MDMA_Channel5_BASE) +#define MDMA_Channel6 ((MDMA_Channel_TypeDef *)MDMA_Channel6_BASE) +#define MDMA_Channel7 ((MDMA_Channel_TypeDef *)MDMA_Channel7_BASE) +#define MDMA_Channel8 ((MDMA_Channel_TypeDef *)MDMA_Channel8_BASE) +#define MDMA_Channel9 ((MDMA_Channel_TypeDef *)MDMA_Channel9_BASE) +#define MDMA_Channel10 ((MDMA_Channel_TypeDef *)MDMA_Channel10_BASE) +#define MDMA_Channel11 ((MDMA_Channel_TypeDef *)MDMA_Channel11_BASE) +#define MDMA_Channel12 ((MDMA_Channel_TypeDef *)MDMA_Channel12_BASE) +#define MDMA_Channel13 ((MDMA_Channel_TypeDef *)MDMA_Channel13_BASE) +#define MDMA_Channel14 ((MDMA_Channel_TypeDef *)MDMA_Channel14_BASE) +#define MDMA_Channel15 ((MDMA_Channel_TypeDef *)MDMA_Channel15_BASE) + + +#define USB1_OTG_HS ((USB_OTG_GlobalTypeDef *) USB1_OTG_HS_PERIPH_BASE) + +/* Legacy defines */ +#define USB_OTG_HS USB1_OTG_HS +#define USB_OTG_HS_PERIPH_BASE USB1_OTG_HS_PERIPH_BASE + +#define GPV ((GPV_TypeDef *) GPV_BASE) + +/** + * @} + */ + +/** @addtogroup Exported_constants + * @{ + */ + + /** @addtogroup Peripheral_Registers_Bits_Definition + * @{ + */ + +/******************************************************************************/ +/* Peripheral Registers_Bits_Definition */ +/******************************************************************************/ + +/******************************************************************************/ +/* */ +/* Analog to Digital Converter */ +/* */ +/******************************************************************************/ +/******************************* ADC VERSION ********************************/ +#define ADC_VER_V5_V90 +/******************** Bit definition for ADC_ISR register ********************/ +#define ADC_ISR_ADRDY_Pos (0U) +#define ADC_ISR_ADRDY_Msk (0x1UL << ADC_ISR_ADRDY_Pos) /*!< 0x00000001 */ +#define ADC_ISR_ADRDY ADC_ISR_ADRDY_Msk /*!< ADC Ready (ADRDY) flag */ +#define ADC_ISR_EOSMP_Pos (1U) +#define ADC_ISR_EOSMP_Msk (0x1UL << ADC_ISR_EOSMP_Pos) /*!< 0x00000002 */ +#define ADC_ISR_EOSMP ADC_ISR_EOSMP_Msk /*!< ADC End of Sampling flag */ +#define ADC_ISR_EOC_Pos (2U) +#define ADC_ISR_EOC_Msk (0x1UL << ADC_ISR_EOC_Pos) /*!< 0x00000004 */ +#define ADC_ISR_EOC ADC_ISR_EOC_Msk /*!< ADC End of Regular Conversion flag */ +#define ADC_ISR_EOS_Pos (3U) +#define ADC_ISR_EOS_Msk (0x1UL << ADC_ISR_EOS_Pos) /*!< 0x00000008 */ +#define ADC_ISR_EOS ADC_ISR_EOS_Msk /*!< ADC End of Regular sequence of Conversions flag */ +#define ADC_ISR_OVR_Pos (4U) +#define ADC_ISR_OVR_Msk (0x1UL << ADC_ISR_OVR_Pos) /*!< 0x00000010 */ +#define ADC_ISR_OVR ADC_ISR_OVR_Msk /*!< ADC overrun flag */ +#define ADC_ISR_JEOC_Pos (5U) +#define ADC_ISR_JEOC_Msk (0x1UL << ADC_ISR_JEOC_Pos) /*!< 0x00000020 */ +#define ADC_ISR_JEOC ADC_ISR_JEOC_Msk /*!< ADC End of Injected Conversion flag */ +#define ADC_ISR_JEOS_Pos (6U) +#define ADC_ISR_JEOS_Msk (0x1UL << ADC_ISR_JEOS_Pos) /*!< 0x00000040 */ +#define ADC_ISR_JEOS ADC_ISR_JEOS_Msk /*!< ADC End of Injected sequence of Conversions flag */ +#define ADC_ISR_AWD1_Pos (7U) +#define ADC_ISR_AWD1_Msk (0x1UL << ADC_ISR_AWD1_Pos) /*!< 0x00000080 */ +#define ADC_ISR_AWD1 ADC_ISR_AWD1_Msk /*!< ADC Analog watchdog 1 flag */ +#define ADC_ISR_AWD2_Pos (8U) +#define ADC_ISR_AWD2_Msk (0x1UL << ADC_ISR_AWD2_Pos) /*!< 0x00000100 */ +#define ADC_ISR_AWD2 ADC_ISR_AWD2_Msk /*!< ADC Analog watchdog 2 flag */ +#define ADC_ISR_AWD3_Pos (9U) +#define ADC_ISR_AWD3_Msk (0x1UL << ADC_ISR_AWD3_Pos) /*!< 0x00000200 */ +#define ADC_ISR_AWD3 ADC_ISR_AWD3_Msk /*!< ADC Analog watchdog 3 flag */ +#define ADC_ISR_JQOVF_Pos (10U) +#define ADC_ISR_JQOVF_Msk (0x1UL << ADC_ISR_JQOVF_Pos) /*!< 0x00000400 */ +#define ADC_ISR_JQOVF ADC_ISR_JQOVF_Msk /*!< ADC Injected Context Queue Overflow flag */ +#define ADC_ISR_LDORDY_Pos (12U) +#define ADC_ISR_LDORDY_Msk (0x1UL << ADC_ISR_LDORDY_Pos) /*!< 0x00001000 */ +#define ADC_ISR_LDORDY ADC_ISR_LDORDY_Msk /*!< ADC LDO Ready (LDORDY) flag */ + +/******************** Bit definition for ADC_IER register ********************/ +#define ADC_IER_ADRDYIE_Pos (0U) +#define ADC_IER_ADRDYIE_Msk (0x1UL << ADC_IER_ADRDYIE_Pos) /*!< 0x00000001 */ +#define ADC_IER_ADRDYIE ADC_IER_ADRDYIE_Msk /*!< ADC Ready (ADRDY) interrupt source */ +#define ADC_IER_EOSMPIE_Pos (1U) +#define ADC_IER_EOSMPIE_Msk (0x1UL << ADC_IER_EOSMPIE_Pos) /*!< 0x00000002 */ +#define ADC_IER_EOSMPIE ADC_IER_EOSMPIE_Msk /*!< ADC End of Sampling interrupt source */ +#define ADC_IER_EOCIE_Pos (2U) +#define ADC_IER_EOCIE_Msk (0x1UL << ADC_IER_EOCIE_Pos) /*!< 0x00000004 */ +#define ADC_IER_EOCIE ADC_IER_EOCIE_Msk /*!< ADC End of Regular Conversion interrupt source */ +#define ADC_IER_EOSIE_Pos (3U) +#define ADC_IER_EOSIE_Msk (0x1UL << ADC_IER_EOSIE_Pos) /*!< 0x00000008 */ +#define ADC_IER_EOSIE ADC_IER_EOSIE_Msk /*!< ADC End of Regular sequence of Conversions interrupt source */ +#define ADC_IER_OVRIE_Pos (4U) +#define ADC_IER_OVRIE_Msk (0x1UL << ADC_IER_OVRIE_Pos) /*!< 0x00000010 */ +#define ADC_IER_OVRIE ADC_IER_OVRIE_Msk /*!< ADC overrun interrupt source */ +#define ADC_IER_JEOCIE_Pos (5U) +#define ADC_IER_JEOCIE_Msk (0x1UL << ADC_IER_JEOCIE_Pos) /*!< 0x00000020 */ +#define ADC_IER_JEOCIE ADC_IER_JEOCIE_Msk /*!< ADC End of Injected Conversion interrupt source */ +#define ADC_IER_JEOSIE_Pos (6U) +#define ADC_IER_JEOSIE_Msk (0x1UL << ADC_IER_JEOSIE_Pos) /*!< 0x00000040 */ +#define ADC_IER_JEOSIE ADC_IER_JEOSIE_Msk /*!< ADC End of Injected sequence of Conversions interrupt source */ +#define ADC_IER_AWD1IE_Pos (7U) +#define ADC_IER_AWD1IE_Msk (0x1UL << ADC_IER_AWD1IE_Pos) /*!< 0x00000080 */ +#define ADC_IER_AWD1IE ADC_IER_AWD1IE_Msk /*!< ADC Analog watchdog 1 interrupt source */ +#define ADC_IER_AWD2IE_Pos (8U) +#define ADC_IER_AWD2IE_Msk (0x1UL << ADC_IER_AWD2IE_Pos) /*!< 0x00000100 */ +#define ADC_IER_AWD2IE ADC_IER_AWD2IE_Msk /*!< ADC Analog watchdog 2 interrupt source */ +#define ADC_IER_AWD3IE_Pos (9U) +#define ADC_IER_AWD3IE_Msk (0x1UL << ADC_IER_AWD3IE_Pos) /*!< 0x00000200 */ +#define ADC_IER_AWD3IE ADC_IER_AWD3IE_Msk /*!< ADC Analog watchdog 3 interrupt source */ +#define ADC_IER_JQOVFIE_Pos (10U) +#define ADC_IER_JQOVFIE_Msk (0x1UL << ADC_IER_JQOVFIE_Pos) /*!< 0x00000400 */ +#define ADC_IER_JQOVFIE ADC_IER_JQOVFIE_Msk /*!< ADC Injected Context Queue Overflow interrupt source */ + +/******************** Bit definition for ADC_CR register ********************/ +#define ADC_CR_ADEN_Pos (0U) +#define ADC_CR_ADEN_Msk (0x1UL << ADC_CR_ADEN_Pos) /*!< 0x00000001 */ +#define ADC_CR_ADEN ADC_CR_ADEN_Msk /*!< ADC Enable control */ +#define ADC_CR_ADDIS_Pos (1U) +#define ADC_CR_ADDIS_Msk (0x1UL << ADC_CR_ADDIS_Pos) /*!< 0x00000002 */ +#define ADC_CR_ADDIS ADC_CR_ADDIS_Msk /*!< ADC Disable command */ +#define ADC_CR_ADSTART_Pos (2U) +#define ADC_CR_ADSTART_Msk (0x1UL << ADC_CR_ADSTART_Pos) /*!< 0x00000004 */ +#define ADC_CR_ADSTART ADC_CR_ADSTART_Msk /*!< ADC Start of Regular conversion */ +#define ADC_CR_JADSTART_Pos (3U) +#define ADC_CR_JADSTART_Msk (0x1UL << ADC_CR_JADSTART_Pos) /*!< 0x00000008 */ +#define ADC_CR_JADSTART ADC_CR_JADSTART_Msk /*!< ADC Start of injected conversion */ +#define ADC_CR_ADSTP_Pos (4U) +#define ADC_CR_ADSTP_Msk (0x1UL << ADC_CR_ADSTP_Pos) /*!< 0x00000010 */ +#define ADC_CR_ADSTP ADC_CR_ADSTP_Msk /*!< ADC Stop of Regular conversion */ +#define ADC_CR_JADSTP_Pos (5U) +#define ADC_CR_JADSTP_Msk (0x1UL << ADC_CR_JADSTP_Pos) /*!< 0x00000020 */ +#define ADC_CR_JADSTP ADC_CR_JADSTP_Msk /*!< ADC Stop of injected conversion */ +#define ADC_CR_BOOST_Pos (8U) +#define ADC_CR_BOOST_Msk (0x3UL << ADC_CR_BOOST_Pos) /*!< 0x00000300 */ +#define ADC_CR_BOOST ADC_CR_BOOST_Msk /*!< ADC Boost Mode configuration */ +#define ADC_CR_BOOST_0 (0x1UL << ADC_CR_BOOST_Pos) /*!< 0x00000100 */ +#define ADC_CR_BOOST_1 (0x2UL << ADC_CR_BOOST_Pos) /*!< 0x00000200 */ +#define ADC_CR_ADCALLIN_Pos (16U) +#define ADC_CR_ADCALLIN_Msk (0x1UL << ADC_CR_ADCALLIN_Pos) /*!< 0x00010000 */ +#define ADC_CR_ADCALLIN ADC_CR_ADCALLIN_Msk /*!< ADC Linearity calibration */ +#define ADC_CR_LINCALRDYW1_Pos (22U) +#define ADC_CR_LINCALRDYW1_Msk (0x1UL << ADC_CR_LINCALRDYW1_Pos) /*!< 0x00400000 */ +#define ADC_CR_LINCALRDYW1 ADC_CR_LINCALRDYW1_Msk /*!< ADC Linearity calibration ready Word 1 */ +#define ADC_CR_LINCALRDYW2_Pos (23U) +#define ADC_CR_LINCALRDYW2_Msk (0x1UL << ADC_CR_LINCALRDYW2_Pos) /*!< 0x00800000 */ +#define ADC_CR_LINCALRDYW2 ADC_CR_LINCALRDYW2_Msk /*!< ADC Linearity calibration ready Word 2 */ +#define ADC_CR_LINCALRDYW3_Pos (24U) +#define ADC_CR_LINCALRDYW3_Msk (0x1UL << ADC_CR_LINCALRDYW3_Pos) /*!< 0x01000000 */ +#define ADC_CR_LINCALRDYW3 ADC_CR_LINCALRDYW3_Msk /*!< ADC Linearity calibration ready Word 3 */ +#define ADC_CR_LINCALRDYW4_Pos (25U) +#define ADC_CR_LINCALRDYW4_Msk (0x1UL << ADC_CR_LINCALRDYW4_Pos) /*!< 0x02000000 */ +#define ADC_CR_LINCALRDYW4 ADC_CR_LINCALRDYW4_Msk /*!< ADC Linearity calibration ready Word 4 */ +#define ADC_CR_LINCALRDYW5_Pos (26U) +#define ADC_CR_LINCALRDYW5_Msk (0x1UL << ADC_CR_LINCALRDYW5_Pos) /*!< 0x04000000 */ +#define ADC_CR_LINCALRDYW5 ADC_CR_LINCALRDYW5_Msk /*!< ADC Linearity calibration ready Word 5 */ +#define ADC_CR_LINCALRDYW6_Pos (27U) +#define ADC_CR_LINCALRDYW6_Msk (0x1UL << ADC_CR_LINCALRDYW6_Pos) /*!< 0x08000000 */ +#define ADC_CR_LINCALRDYW6 ADC_CR_LINCALRDYW6_Msk /*!< ADC Linearity calibration ready Word 6 */ +#define ADC_CR_ADVREGEN_Pos (28U) +#define ADC_CR_ADVREGEN_Msk (0x1UL << ADC_CR_ADVREGEN_Pos) /*!< 0x10000000 */ +#define ADC_CR_ADVREGEN ADC_CR_ADVREGEN_Msk /*!< ADC Voltage regulator Enable */ +#define ADC_CR_DEEPPWD_Pos (29U) +#define ADC_CR_DEEPPWD_Msk (0x1UL << ADC_CR_DEEPPWD_Pos) /*!< 0x20000000 */ +#define ADC_CR_DEEPPWD ADC_CR_DEEPPWD_Msk /*!< ADC Deep power down Enable */ +#define ADC_CR_ADCALDIF_Pos (30U) +#define ADC_CR_ADCALDIF_Msk (0x1UL << ADC_CR_ADCALDIF_Pos) /*!< 0x40000000 */ +#define ADC_CR_ADCALDIF ADC_CR_ADCALDIF_Msk /*!< ADC Differential Mode for calibration */ +#define ADC_CR_ADCAL_Pos (31U) +#define ADC_CR_ADCAL_Msk (0x1UL << ADC_CR_ADCAL_Pos) /*!< 0x80000000 */ +#define ADC_CR_ADCAL ADC_CR_ADCAL_Msk /*!< ADC Calibration */ + +/******************** Bit definition for ADC_CFGR register ********************/ +#define ADC_CFGR_DMNGT_Pos (0U) +#define ADC_CFGR_DMNGT_Msk (0x3UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000003 */ +#define ADC_CFGR_DMNGT ADC_CFGR_DMNGT_Msk /*!< ADC Data Management configuration */ +#define ADC_CFGR_DMNGT_0 (0x1UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000001 */ +#define ADC_CFGR_DMNGT_1 (0x2UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000002 */ + +#define ADC_CFGR_RES_Pos (2U) +#define ADC_CFGR_RES_Msk (0x7UL << ADC_CFGR_RES_Pos) /*!< 0x0000001C */ +#define ADC_CFGR_RES ADC_CFGR_RES_Msk /*!< ADC Data resolution */ +#define ADC_CFGR_RES_0 (0x1UL << ADC_CFGR_RES_Pos) /*!< 0x00000004 */ +#define ADC_CFGR_RES_1 (0x2UL << ADC_CFGR_RES_Pos) /*!< 0x00000008 */ +#define ADC_CFGR_RES_2 (0x4UL << ADC_CFGR_RES_Pos) /*!< 0x00000010 */ + +#define ADC_CFGR_EXTSEL_Pos (5U) +#define ADC_CFGR_EXTSEL_Msk (0x1FUL << ADC_CFGR_EXTSEL_Pos) /*!< 0x000003E0 */ +#define ADC_CFGR_EXTSEL ADC_CFGR_EXTSEL_Msk /*!< ADC External trigger selection for regular group */ +#define ADC_CFGR_EXTSEL_0 (0x01UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000020 */ +#define ADC_CFGR_EXTSEL_1 (0x02UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000040 */ +#define ADC_CFGR_EXTSEL_2 (0x04UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000080 */ +#define ADC_CFGR_EXTSEL_3 (0x08UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000100 */ +#define ADC_CFGR_EXTSEL_4 (0x10UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000200 */ + +#define ADC_CFGR_EXTEN_Pos (10U) +#define ADC_CFGR_EXTEN_Msk (0x3UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000C00 */ +#define ADC_CFGR_EXTEN ADC_CFGR_EXTEN_Msk /*!< ADC External trigger enable and polarity selection for regular channels */ +#define ADC_CFGR_EXTEN_0 (0x1UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000400 */ +#define ADC_CFGR_EXTEN_1 (0x2UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000800 */ + +#define ADC_CFGR_OVRMOD_Pos (12U) +#define ADC_CFGR_OVRMOD_Msk (0x1UL << ADC_CFGR_OVRMOD_Pos) /*!< 0x00001000 */ +#define ADC_CFGR_OVRMOD ADC_CFGR_OVRMOD_Msk /*!< ADC overrun mode */ +#define ADC_CFGR_CONT_Pos (13U) +#define ADC_CFGR_CONT_Msk (0x1UL << ADC_CFGR_CONT_Pos) /*!< 0x00002000 */ +#define ADC_CFGR_CONT ADC_CFGR_CONT_Msk /*!< ADC Single/continuous conversion mode for regular conversion */ +#define ADC_CFGR_AUTDLY_Pos (14U) +#define ADC_CFGR_AUTDLY_Msk (0x1UL << ADC_CFGR_AUTDLY_Pos) /*!< 0x00004000 */ +#define ADC_CFGR_AUTDLY ADC_CFGR_AUTDLY_Msk /*!< ADC Delayed conversion mode */ + +#define ADC_CFGR_DISCEN_Pos (16U) +#define ADC_CFGR_DISCEN_Msk (0x1UL << ADC_CFGR_DISCEN_Pos) /*!< 0x00010000 */ +#define ADC_CFGR_DISCEN ADC_CFGR_DISCEN_Msk /*!< ADC Discontinuous mode for regular channels */ + +#define ADC_CFGR_DISCNUM_Pos (17U) +#define ADC_CFGR_DISCNUM_Msk (0x7UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x000E0000 */ +#define ADC_CFGR_DISCNUM ADC_CFGR_DISCNUM_Msk /*!< ADC Discontinuous mode channel count */ +#define ADC_CFGR_DISCNUM_0 (0x1UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00020000 */ +#define ADC_CFGR_DISCNUM_1 (0x2UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00040000 */ +#define ADC_CFGR_DISCNUM_2 (0x4UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00080000 */ + +#define ADC_CFGR_JDISCEN_Pos (20U) +#define ADC_CFGR_JDISCEN_Msk (0x1UL << ADC_CFGR_JDISCEN_Pos) /*!< 0x00100000 */ +#define ADC_CFGR_JDISCEN ADC_CFGR_JDISCEN_Msk /*!< ADC Discontinuous mode on injected channels */ +#define ADC_CFGR_JQM_Pos (21U) +#define ADC_CFGR_JQM_Msk (0x1UL << ADC_CFGR_JQM_Pos) /*!< 0x00200000 */ +#define ADC_CFGR_JQM ADC_CFGR_JQM_Msk /*!< ADC JSQR Queue mode */ +#define ADC_CFGR_AWD1SGL_Pos (22U) +#define ADC_CFGR_AWD1SGL_Msk (0x1UL << ADC_CFGR_AWD1SGL_Pos) /*!< 0x00400000 */ +#define ADC_CFGR_AWD1SGL ADC_CFGR_AWD1SGL_Msk /*!< Enable the watchdog 1 on a single channel or on all channels */ +#define ADC_CFGR_AWD1EN_Pos (23U) +#define ADC_CFGR_AWD1EN_Msk (0x1UL << ADC_CFGR_AWD1EN_Pos) /*!< 0x00800000 */ +#define ADC_CFGR_AWD1EN ADC_CFGR_AWD1EN_Msk /*!< ADC Analog watchdog 1 enable on regular Channels */ +#define ADC_CFGR_JAWD1EN_Pos (24U) +#define ADC_CFGR_JAWD1EN_Msk (0x1UL << ADC_CFGR_JAWD1EN_Pos) /*!< 0x01000000 */ +#define ADC_CFGR_JAWD1EN ADC_CFGR_JAWD1EN_Msk /*!< ADC Analog watchdog 1 enable on injected Channels */ +#define ADC_CFGR_JAUTO_Pos (25U) +#define ADC_CFGR_JAUTO_Msk (0x1UL << ADC_CFGR_JAUTO_Pos) /*!< 0x02000000 */ +#define ADC_CFGR_JAUTO ADC_CFGR_JAUTO_Msk /*!< ADC Automatic injected group conversion */ + +#define ADC_CFGR_AWD1CH_Pos (26U) +#define ADC_CFGR_AWD1CH_Msk (0x1FUL << ADC_CFGR_AWD1CH_Pos) /*!< 0x7C000000 */ +#define ADC_CFGR_AWD1CH ADC_CFGR_AWD1CH_Msk /*!< ADC Analog watchdog 1 Channel selection */ +#define ADC_CFGR_AWD1CH_0 (0x01UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x04000000 */ +#define ADC_CFGR_AWD1CH_1 (0x02UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x08000000 */ +#define ADC_CFGR_AWD1CH_2 (0x04UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x10000000 */ +#define ADC_CFGR_AWD1CH_3 (0x08UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x20000000 */ +#define ADC_CFGR_AWD1CH_4 (0x10UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x40000000 */ + +#define ADC_CFGR_JQDIS_Pos (31U) +#define ADC_CFGR_JQDIS_Msk (0x1UL << ADC_CFGR_JQDIS_Pos) /*!< 0x80000000 */ +#define ADC_CFGR_JQDIS ADC_CFGR_JQDIS_Msk /*!< ADC Injected queue disable */ + +#define ADC3_CFGR_DMAEN_Pos (0U) +#define ADC3_CFGR_DMAEN_Msk (0x1UL << ADC3_CFGR_DMAEN_Pos) /*!< 0x00000001 */ +#define ADC3_CFGR_DMAEN ADC3_CFGR_DMAEN_Msk /*!< ADC DMA transfer enable */ +#define ADC3_CFGR_DMACFG_Pos (1U) +#define ADC3_CFGR_DMACFG_Msk (0x1UL << ADC3_CFGR_DMACFG_Pos) /*!< 0x00000002 */ +#define ADC3_CFGR_DMACFG ADC3_CFGR_DMACFG_Msk /*!< ADC DMA transfer configuration */ + +#define ADC3_CFGR_RES_Pos (3U) +#define ADC3_CFGR_RES_Msk (0x3UL << ADC3_CFGR_RES_Pos) /*!< 0x00000018 */ +#define ADC3_CFGR_RES ADC3_CFGR_RES_Msk /*!< ADC data resolution */ +#define ADC3_CFGR_RES_0 (0x1UL << ADC3_CFGR_RES_Pos) /*!< 0x00000008 */ +#define ADC3_CFGR_RES_1 (0x2UL << ADC3_CFGR_RES_Pos) /*!< 0x00000010 */ + +#define ADC3_CFGR_ALIGN_Pos (15U) +#define ADC3_CFGR_ALIGN_Msk (0x1UL << ADC3_CFGR_ALIGN_Pos) /*!< 0x00008000 */ +#define ADC3_CFGR_ALIGN ADC3_CFGR_ALIGN_Msk /*!< ADC data alignment */ +/******************** Bit definition for ADC_CFGR2 register ********************/ +#define ADC_CFGR2_ROVSE_Pos (0U) +#define ADC_CFGR2_ROVSE_Msk (0x1UL << ADC_CFGR2_ROVSE_Pos) /*!< 0x00000001 */ +#define ADC_CFGR2_ROVSE ADC_CFGR2_ROVSE_Msk /*!< ADC Regular group oversampler enable */ +#define ADC_CFGR2_JOVSE_Pos (1U) +#define ADC_CFGR2_JOVSE_Msk (0x1UL << ADC_CFGR2_JOVSE_Pos) /*!< 0x00000002 */ +#define ADC_CFGR2_JOVSE ADC_CFGR2_JOVSE_Msk /*!< ADC Injected group oversampler enable */ + +#define ADC_CFGR2_OVSS_Pos (5U) +#define ADC_CFGR2_OVSS_Msk (0xFUL << ADC_CFGR2_OVSS_Pos) /*!< 0x000001E0 */ +#define ADC_CFGR2_OVSS ADC_CFGR2_OVSS_Msk /*!< ADC Regular Oversampling shift */ +#define ADC_CFGR2_OVSS_0 (0x1UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000020 */ +#define ADC_CFGR2_OVSS_1 (0x2UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000040 */ +#define ADC_CFGR2_OVSS_2 (0x4UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000080 */ +#define ADC_CFGR2_OVSS_3 (0x8UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000100 */ + +#define ADC_CFGR2_TROVS_Pos (9U) +#define ADC_CFGR2_TROVS_Msk (0x1UL << ADC_CFGR2_TROVS_Pos) /*!< 0x00000200 */ +#define ADC_CFGR2_TROVS ADC_CFGR2_TROVS_Msk /*!< ADC Triggered regular Oversampling */ +#define ADC_CFGR2_ROVSM_Pos (10U) +#define ADC_CFGR2_ROVSM_Msk (0x1UL << ADC_CFGR2_ROVSM_Pos) /*!< 0x00000400 */ +#define ADC_CFGR2_ROVSM ADC_CFGR2_ROVSM_Msk /*!< ADC Regular oversampling mode */ + +#define ADC_CFGR2_RSHIFT1_Pos (11U) +#define ADC_CFGR2_RSHIFT1_Msk (0x1UL << ADC_CFGR2_RSHIFT1_Pos) /*!< 0x00000800 */ +#define ADC_CFGR2_RSHIFT1 ADC_CFGR2_RSHIFT1_Msk /*!< ADC Right-shift data after Offset 1 correction */ +#define ADC_CFGR2_RSHIFT2_Pos (12U) +#define ADC_CFGR2_RSHIFT2_Msk (0x1UL << ADC_CFGR2_RSHIFT2_Pos) /*!< 0x00001000 */ +#define ADC_CFGR2_RSHIFT2 ADC_CFGR2_RSHIFT2_Msk /*!< ADC Right-shift data after Offset 2 correction */ +#define ADC_CFGR2_RSHIFT3_Pos (13U) +#define ADC_CFGR2_RSHIFT3_Msk (0x1UL << ADC_CFGR2_RSHIFT3_Pos) /*!< 0x00002000 */ +#define ADC_CFGR2_RSHIFT3 ADC_CFGR2_RSHIFT3_Msk /*!< ADC Right-shift data after Offset 3 correction */ +#define ADC_CFGR2_RSHIFT4_Pos (14U) +#define ADC_CFGR2_RSHIFT4_Msk (0x1UL << ADC_CFGR2_RSHIFT4_Pos) /*!< 0x00004000 */ +#define ADC_CFGR2_RSHIFT4 ADC_CFGR2_RSHIFT4_Msk /*!< ADC Right-shift data after Offset 4 correction */ + +#define ADC_CFGR2_OVSR_Pos (16U) +#define ADC_CFGR2_OVSR_Msk (0x3FFUL << ADC_CFGR2_OVSR_Pos) /*!< 0x03FF0000 */ +#define ADC_CFGR2_OVSR ADC_CFGR2_OVSR_Msk /*!< ADC oversampling Ratio */ +#define ADC_CFGR2_OVSR_0 (0x001UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00010000 */ +#define ADC_CFGR2_OVSR_1 (0x002UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00020000 */ +#define ADC_CFGR2_OVSR_2 (0x004UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00040000 */ +#define ADC_CFGR2_OVSR_3 (0x008UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00080000 */ +#define ADC_CFGR2_OVSR_4 (0x010UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00100000 */ +#define ADC_CFGR2_OVSR_5 (0x020UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00200000 */ +#define ADC_CFGR2_OVSR_6 (0x040UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00400000 */ +#define ADC_CFGR2_OVSR_7 (0x080UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00800000 */ +#define ADC_CFGR2_OVSR_8 (0x100UL << ADC_CFGR2_OVSR_Pos) /*!< 0x01000000 */ +#define ADC_CFGR2_OVSR_9 (0x200UL << ADC_CFGR2_OVSR_Pos) /*!< 0x02000000 */ + +#define ADC_CFGR2_LSHIFT_Pos (28U) +#define ADC_CFGR2_LSHIFT_Msk (0xFUL << ADC_CFGR2_LSHIFT_Pos) /*!< 0xF0000000 */ +#define ADC_CFGR2_LSHIFT ADC_CFGR2_LSHIFT_Msk /*!< ADC Left shift factor */ +#define ADC_CFGR2_LSHIFT_0 (0x1UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x10000000 */ +#define ADC_CFGR2_LSHIFT_1 (0x2UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x20000000 */ +#define ADC_CFGR2_LSHIFT_2 (0x4UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x40000000 */ +#define ADC_CFGR2_LSHIFT_3 (0x8UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x80000000 */ + +#define ADC3_CFGR2_OVSR_Pos (2U) +#define ADC3_CFGR2_OVSR_Msk (0x7UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x0000001C */ +#define ADC3_CFGR2_OVSR ADC3_CFGR2_OVSR_Msk /*!< ADC oversampling ratio */ +#define ADC3_CFGR2_OVSR_0 (0x1UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000004 */ +#define ADC3_CFGR2_OVSR_1 (0x2UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000008 */ +#define ADC3_CFGR2_OVSR_2 (0x4UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000010 */ + +#define ADC3_CFGR2_SWTRIG_Pos (25U) +#define ADC3_CFGR2_SWTRIG_Msk (0x1UL << ADC3_CFGR2_SWTRIG_Pos) /*!< 0x02000000 */ +#define ADC3_CFGR2_SWTRIG ADC3_CFGR2_SWTRIG_Msk /*!< ADC Software Trigger Bit for Sample time control trigger mode */ +#define ADC3_CFGR2_BULB_Pos (26U) +#define ADC3_CFGR2_BULB_Msk (0x1UL << ADC3_CFGR2_BULB_Pos) /*!< 0x04000000 */ +#define ADC3_CFGR2_BULB ADC3_CFGR2_BULB_Msk /*!< ADC Bulb sampling mode */ +#define ADC3_CFGR2_SMPTRIG_Pos (27U) +#define ADC3_CFGR2_SMPTRIG_Msk (0x1UL << ADC3_CFGR2_SMPTRIG_Pos) /*!< 0x08000000 */ +#define ADC3_CFGR2_SMPTRIG ADC3_CFGR2_SMPTRIG_Msk /*!< ADC Sample Time Control Trigger mode */ +/******************** Bit definition for ADC_SMPR1 register ********************/ +#define ADC_SMPR1_SMP0_Pos (0U) +#define ADC_SMPR1_SMP0_Msk (0x7UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000007 */ +#define ADC_SMPR1_SMP0 ADC_SMPR1_SMP0_Msk /*!< ADC Channel 0 Sampling time selection */ +#define ADC_SMPR1_SMP0_0 (0x1UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000001 */ +#define ADC_SMPR1_SMP0_1 (0x2UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000002 */ +#define ADC_SMPR1_SMP0_2 (0x4UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000004 */ + +#define ADC_SMPR1_SMP1_Pos (3U) +#define ADC_SMPR1_SMP1_Msk (0x7UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000038 */ +#define ADC_SMPR1_SMP1 ADC_SMPR1_SMP1_Msk /*!< ADC Channel 1 Sampling time selection */ +#define ADC_SMPR1_SMP1_0 (0x1UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000008 */ +#define ADC_SMPR1_SMP1_1 (0x2UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000010 */ +#define ADC_SMPR1_SMP1_2 (0x4UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000020 */ + +#define ADC_SMPR1_SMP2_Pos (6U) +#define ADC_SMPR1_SMP2_Msk (0x7UL << ADC_SMPR1_SMP2_Pos) /*!< 0x000001C0 */ +#define ADC_SMPR1_SMP2 ADC_SMPR1_SMP2_Msk /*!< ADC Channel 2 Sampling time selection */ +#define ADC_SMPR1_SMP2_0 (0x1UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000040 */ +#define ADC_SMPR1_SMP2_1 (0x2UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000080 */ +#define ADC_SMPR1_SMP2_2 (0x4UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000100 */ + +#define ADC_SMPR1_SMP3_Pos (9U) +#define ADC_SMPR1_SMP3_Msk (0x7UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000E00 */ +#define ADC_SMPR1_SMP3 ADC_SMPR1_SMP3_Msk /*!< ADC Channel 3 Sampling time selection */ +#define ADC_SMPR1_SMP3_0 (0x1UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000200 */ +#define ADC_SMPR1_SMP3_1 (0x2UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000400 */ +#define ADC_SMPR1_SMP3_2 (0x4UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000800 */ + +#define ADC_SMPR1_SMP4_Pos (12U) +#define ADC_SMPR1_SMP4_Msk (0x7UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00007000 */ +#define ADC_SMPR1_SMP4 ADC_SMPR1_SMP4_Msk /*!< ADC Channel 4 Sampling time selection */ +#define ADC_SMPR1_SMP4_0 (0x1UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00001000 */ +#define ADC_SMPR1_SMP4_1 (0x2UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00002000 */ +#define ADC_SMPR1_SMP4_2 (0x4UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00004000 */ + +#define ADC_SMPR1_SMP5_Pos (15U) +#define ADC_SMPR1_SMP5_Msk (0x7UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00038000 */ +#define ADC_SMPR1_SMP5 ADC_SMPR1_SMP5_Msk /*!< ADC Channel 5 Sampling time selection */ +#define ADC_SMPR1_SMP5_0 (0x1UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00008000 */ +#define ADC_SMPR1_SMP5_1 (0x2UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00010000 */ +#define ADC_SMPR1_SMP5_2 (0x4UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00020000 */ + +#define ADC_SMPR1_SMP6_Pos (18U) +#define ADC_SMPR1_SMP6_Msk (0x7UL << ADC_SMPR1_SMP6_Pos) /*!< 0x001C0000 */ +#define ADC_SMPR1_SMP6 ADC_SMPR1_SMP6_Msk /*!< ADC Channel 6 Sampling time selection */ +#define ADC_SMPR1_SMP6_0 (0x1UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00040000 */ +#define ADC_SMPR1_SMP6_1 (0x2UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00080000 */ +#define ADC_SMPR1_SMP6_2 (0x4UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00100000 */ + +#define ADC_SMPR1_SMP7_Pos (21U) +#define ADC_SMPR1_SMP7_Msk (0x7UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00E00000 */ +#define ADC_SMPR1_SMP7 ADC_SMPR1_SMP7_Msk /*!< ADC Channel 7 Sampling time selection */ +#define ADC_SMPR1_SMP7_0 (0x1UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00200000 */ +#define ADC_SMPR1_SMP7_1 (0x2UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00400000 */ +#define ADC_SMPR1_SMP7_2 (0x4UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00800000 */ + +#define ADC_SMPR1_SMP8_Pos (24U) +#define ADC_SMPR1_SMP8_Msk (0x7UL << ADC_SMPR1_SMP8_Pos) /*!< 0x07000000 */ +#define ADC_SMPR1_SMP8 ADC_SMPR1_SMP8_Msk /*!< ADC Channel 8 Sampling time selection */ +#define ADC_SMPR1_SMP8_0 (0x1UL << ADC_SMPR1_SMP8_Pos) /*!< 0x01000000 */ +#define ADC_SMPR1_SMP8_1 (0x2UL << ADC_SMPR1_SMP8_Pos) /*!< 0x02000000 */ +#define ADC_SMPR1_SMP8_2 (0x4UL << ADC_SMPR1_SMP8_Pos) /*!< 0x04000000 */ + +#define ADC_SMPR1_SMP9_Pos (27U) +#define ADC_SMPR1_SMP9_Msk (0x7UL << ADC_SMPR1_SMP9_Pos) /*!< 0x38000000 */ +#define ADC_SMPR1_SMP9 ADC_SMPR1_SMP9_Msk /*!< ADC Channel 9 Sampling time selection */ +#define ADC_SMPR1_SMP9_0 (0x1UL << ADC_SMPR1_SMP9_Pos) /*!< 0x08000000 */ +#define ADC_SMPR1_SMP9_1 (0x2UL << ADC_SMPR1_SMP9_Pos) /*!< 0x10000000 */ +#define ADC_SMPR1_SMP9_2 (0x4UL << ADC_SMPR1_SMP9_Pos) /*!< 0x20000000 */ + +/******************** Bit definition for ADC_SMPR2 register ********************/ +#define ADC_SMPR2_SMP10_Pos (0U) +#define ADC_SMPR2_SMP10_Msk (0x7UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000007 */ +#define ADC_SMPR2_SMP10 ADC_SMPR2_SMP10_Msk /*!< ADC Channel 10 Sampling time selection */ +#define ADC_SMPR2_SMP10_0 (0x1UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000001 */ +#define ADC_SMPR2_SMP10_1 (0x2UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000002 */ +#define ADC_SMPR2_SMP10_2 (0x4UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000004 */ + +#define ADC_SMPR2_SMP11_Pos (3U) +#define ADC_SMPR2_SMP11_Msk (0x7UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000038 */ +#define ADC_SMPR2_SMP11 ADC_SMPR2_SMP11_Msk /*!< ADC Channel 11 Sampling time selection */ +#define ADC_SMPR2_SMP11_0 (0x1UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000008 */ +#define ADC_SMPR2_SMP11_1 (0x2UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000010 */ +#define ADC_SMPR2_SMP11_2 (0x4UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000020 */ + +#define ADC_SMPR2_SMP12_Pos (6U) +#define ADC_SMPR2_SMP12_Msk (0x7UL << ADC_SMPR2_SMP12_Pos) /*!< 0x000001C0 */ +#define ADC_SMPR2_SMP12 ADC_SMPR2_SMP12_Msk /*!< ADC Channel 12 Sampling time selection */ +#define ADC_SMPR2_SMP12_0 (0x1UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000040 */ +#define ADC_SMPR2_SMP12_1 (0x2UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000080 */ +#define ADC_SMPR2_SMP12_2 (0x4UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000100 */ + +#define ADC_SMPR2_SMP13_Pos (9U) +#define ADC_SMPR2_SMP13_Msk (0x7UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000E00 */ +#define ADC_SMPR2_SMP13 ADC_SMPR2_SMP13_Msk /*!< ADC Channel 13 Sampling time selection */ +#define ADC_SMPR2_SMP13_0 (0x1UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000200 */ +#define ADC_SMPR2_SMP13_1 (0x2UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000400 */ +#define ADC_SMPR2_SMP13_2 (0x4UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000800 */ + +#define ADC_SMPR2_SMP14_Pos (12U) +#define ADC_SMPR2_SMP14_Msk (0x7UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00007000 */ +#define ADC_SMPR2_SMP14 ADC_SMPR2_SMP14_Msk /*!< ADC Channel 14 Sampling time selection */ +#define ADC_SMPR2_SMP14_0 (0x1UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00001000 */ +#define ADC_SMPR2_SMP14_1 (0x2UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00002000 */ +#define ADC_SMPR2_SMP14_2 (0x4UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00004000 */ + +#define ADC_SMPR2_SMP15_Pos (15U) +#define ADC_SMPR2_SMP15_Msk (0x7UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00038000 */ +#define ADC_SMPR2_SMP15 ADC_SMPR2_SMP15_Msk /*!< ADC Channel 15 Sampling time selection */ +#define ADC_SMPR2_SMP15_0 (0x1UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00008000 */ +#define ADC_SMPR2_SMP15_1 (0x2UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00010000 */ +#define ADC_SMPR2_SMP15_2 (0x4UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00020000 */ + +#define ADC_SMPR2_SMP16_Pos (18U) +#define ADC_SMPR2_SMP16_Msk (0x7UL << ADC_SMPR2_SMP16_Pos) /*!< 0x001C0000 */ +#define ADC_SMPR2_SMP16 ADC_SMPR2_SMP16_Msk /*!< ADC Channel 16 Sampling time selection */ +#define ADC_SMPR2_SMP16_0 (0x1UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00040000 */ +#define ADC_SMPR2_SMP16_1 (0x2UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00080000 */ +#define ADC_SMPR2_SMP16_2 (0x4UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00100000 */ + +#define ADC_SMPR2_SMP17_Pos (21U) +#define ADC_SMPR2_SMP17_Msk (0x7UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00E00000 */ +#define ADC_SMPR2_SMP17 ADC_SMPR2_SMP17_Msk /*!< ADC Channel 17 Sampling time selection */ +#define ADC_SMPR2_SMP17_0 (0x1UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00200000 */ +#define ADC_SMPR2_SMP17_1 (0x2UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00400000 */ +#define ADC_SMPR2_SMP17_2 (0x4UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00800000 */ + +#define ADC_SMPR2_SMP18_Pos (24U) +#define ADC_SMPR2_SMP18_Msk (0x7UL << ADC_SMPR2_SMP18_Pos) /*!< 0x07000000 */ +#define ADC_SMPR2_SMP18 ADC_SMPR2_SMP18_Msk /*!< ADC Channel 18 Sampling time selection */ +#define ADC_SMPR2_SMP18_0 (0x1UL << ADC_SMPR2_SMP18_Pos) /*!< 0x01000000 */ +#define ADC_SMPR2_SMP18_1 (0x2UL << ADC_SMPR2_SMP18_Pos) /*!< 0x02000000 */ +#define ADC_SMPR2_SMP18_2 (0x4UL << ADC_SMPR2_SMP18_Pos) /*!< 0x04000000 */ + +#define ADC_SMPR2_SMP19_Pos (27U) +#define ADC_SMPR2_SMP19_Msk (0x7UL << ADC_SMPR2_SMP19_Pos) /*!< 0x38000000 */ +#define ADC_SMPR2_SMP19 ADC_SMPR2_SMP19_Msk /*!< ADC Channel 19 Sampling time selection */ +#define ADC_SMPR2_SMP19_0 (0x1UL << ADC_SMPR2_SMP19_Pos) /*!< 0x08000000 */ +#define ADC_SMPR2_SMP19_1 (0x2UL << ADC_SMPR2_SMP19_Pos) /*!< 0x10000000 */ +#define ADC_SMPR2_SMP19_2 (0x4UL << ADC_SMPR2_SMP19_Pos) /*!< 0x20000000 */ + +/******************** Bit definition for ADC_PCSEL register ********************/ +#define ADC_PCSEL_PCSEL_Pos (0U) +#define ADC_PCSEL_PCSEL_Msk (0xFFFFFUL << ADC_PCSEL_PCSEL_Pos) /*!< 0x000FFFFF */ +#define ADC_PCSEL_PCSEL ADC_PCSEL_PCSEL_Msk /*!< ADC pre channel selection */ +#define ADC_PCSEL_PCSEL_0 (0x00001UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000001 */ +#define ADC_PCSEL_PCSEL_1 (0x00002UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000002 */ +#define ADC_PCSEL_PCSEL_2 (0x00004UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000004 */ +#define ADC_PCSEL_PCSEL_3 (0x00008UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000008 */ +#define ADC_PCSEL_PCSEL_4 (0x00010UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000010 */ +#define ADC_PCSEL_PCSEL_5 (0x00020UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000020 */ +#define ADC_PCSEL_PCSEL_6 (0x00040UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000040 */ +#define ADC_PCSEL_PCSEL_7 (0x00080UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000080 */ +#define ADC_PCSEL_PCSEL_8 (0x00100UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000100 */ +#define ADC_PCSEL_PCSEL_9 (0x00200UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000200 */ +#define ADC_PCSEL_PCSEL_10 (0x00400UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000400 */ +#define ADC_PCSEL_PCSEL_11 (0x00800UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000800 */ +#define ADC_PCSEL_PCSEL_12 (0x01000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00001000 */ +#define ADC_PCSEL_PCSEL_13 (0x02000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00002000 */ +#define ADC_PCSEL_PCSEL_14 (0x04000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00004000 */ +#define ADC_PCSEL_PCSEL_15 (0x08000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00008000 */ +#define ADC_PCSEL_PCSEL_16 (0x10000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00010000 */ +#define ADC_PCSEL_PCSEL_17 (0x20000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00020000 */ +#define ADC_PCSEL_PCSEL_18 (0x40000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00040000 */ +#define ADC_PCSEL_PCSEL_19 (0x80000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00080000 */ + +/***************** Bit definition for ADC_LTR1, 2, 3 registers *****************/ +#define ADC_LTR_LT_Pos (0U) +#define ADC_LTR_LT_Msk (0x3FFFFFFUL << ADC_LTR_LT_Pos) /*!< 0x03FFFFFF */ +#define ADC_LTR_LT ADC_LTR_LT_Msk /*!< ADC Analog watchdog 1, 2 and 3 lower threshold */ + +/***************** Bit definition for ADC_HTR1, 2, 3 registers ****************/ +#define ADC_HTR_HT_Pos (0U) +#define ADC_HTR_HT_Msk (0x3FFFFFFUL << ADC_HTR_HT_Pos) /*!< 0x03FFFFFF */ +#define ADC_HTR_HT ADC_HTR_HT_Msk /*!< ADC Analog watchdog 1,2 and 3 higher threshold */ + +/******************** Bit definition for ADC3_TR1 register *******************/ +#define ADC3_TR1_LT1_Pos (0U) +#define ADC3_TR1_LT1_Msk (0xFFFUL << ADC3_TR1_LT1_Pos) /*!< 0x00000FFF */ +#define ADC3_TR1_LT1 ADC3_TR1_LT1_Msk /*!< ADC analog watchdog 1 threshold low */ + +#define ADC3_TR1_AWDFILT_Pos (12U) +#define ADC3_TR1_AWDFILT_Msk (0x7UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00007000 */ +#define ADC3_TR1_AWDFILT ADC3_TR1_AWDFILT_Msk /*!< ADC analog watchdog filtering parameter */ +#define ADC3_TR1_AWDFILT_0 (0x1UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00001000 */ +#define ADC3_TR1_AWDFILT_1 (0x2UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00002000 */ +#define ADC3_TR1_AWDFILT_2 (0x4UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00004000 */ + +#define ADC3_TR1_HT1_Pos (16U) +#define ADC3_TR1_HT1_Msk (0xFFFUL << ADC3_TR1_HT1_Pos) /*!< 0x0FFF0000 */ +#define ADC3_TR1_HT1 ADC3_TR1_HT1_Msk /*!< ADC analog watchdog 1 threshold high */ + +/******************** Bit definition for ADC3_TR2 register *******************/ +#define ADC3_TR2_LT2_Pos (0U) +#define ADC3_TR2_LT2_Msk (0xFFUL << ADC3_TR2_LT2_Pos) /*!< 0x000000FF */ +#define ADC3_TR2_LT2 ADC3_TR2_LT2_Msk /*!< ADC analog watchdog 2 threshold low */ + +#define ADC3_TR2_HT2_Pos (16U) +#define ADC3_TR2_HT2_Msk (0xFFUL << ADC3_TR2_HT2_Pos) /*!< 0x00FF0000 */ +#define ADC3_TR2_HT2 ADC3_TR2_HT2_Msk /*!< ADC analog watchdog 2 threshold high */ + +/******************** Bit definition for ADC3_TR3 register *******************/ +#define ADC3_TR3_LT3_Pos (0U) +#define ADC3_TR3_LT3_Msk (0xFFUL << ADC3_TR3_LT3_Pos) /*!< 0x000000FF */ +#define ADC3_TR3_LT3 ADC3_TR3_LT3_Msk /*!< ADC analog watchdog 3 threshold low */ + +#define ADC3_TR3_HT3_Pos (16U) +#define ADC3_TR3_HT3_Msk (0xFFUL << ADC3_TR3_HT3_Pos) /*!< 0x00FF0000 */ +#define ADC3_TR3_HT3 ADC3_TR3_HT3_Msk /*!< ADC analog watchdog 3 threshold high */ + +/******************** Bit definition for ADC_SQR1 register ********************/ +#define ADC_SQR1_L_Pos (0U) +#define ADC_SQR1_L_Msk (0xFUL << ADC_SQR1_L_Pos) /*!< 0x0000000F */ +#define ADC_SQR1_L ADC_SQR1_L_Msk /*!< ADC regular channel sequence length */ +#define ADC_SQR1_L_0 (0x1UL << ADC_SQR1_L_Pos) /*!< 0x00000001 */ +#define ADC_SQR1_L_1 (0x2UL << ADC_SQR1_L_Pos) /*!< 0x00000002 */ +#define ADC_SQR1_L_2 (0x4UL << ADC_SQR1_L_Pos) /*!< 0x00000004 */ +#define ADC_SQR1_L_3 (0x8UL << ADC_SQR1_L_Pos) /*!< 0x00000008 */ + +#define ADC_SQR1_SQ1_Pos (6U) +#define ADC_SQR1_SQ1_Msk (0x1FUL << ADC_SQR1_SQ1_Pos) /*!< 0x000007C0 */ +#define ADC_SQR1_SQ1 ADC_SQR1_SQ1_Msk /*!< ADC 1st conversion in regular sequence */ +#define ADC_SQR1_SQ1_0 (0x01UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000040 */ +#define ADC_SQR1_SQ1_1 (0x02UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000080 */ +#define ADC_SQR1_SQ1_2 (0x04UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000100 */ +#define ADC_SQR1_SQ1_3 (0x08UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000200 */ +#define ADC_SQR1_SQ1_4 (0x10UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000400 */ + +#define ADC_SQR1_SQ2_Pos (12U) +#define ADC_SQR1_SQ2_Msk (0x1FUL << ADC_SQR1_SQ2_Pos) /*!< 0x0001F000 */ +#define ADC_SQR1_SQ2 ADC_SQR1_SQ2_Msk /*!< ADC 2nd conversion in regular sequence */ +#define ADC_SQR1_SQ2_0 (0x01UL << ADC_SQR1_SQ2_Pos) /*!< 0x00001000 */ +#define ADC_SQR1_SQ2_1 (0x02UL << ADC_SQR1_SQ2_Pos) /*!< 0x00002000 */ +#define ADC_SQR1_SQ2_2 (0x04UL << ADC_SQR1_SQ2_Pos) /*!< 0x00004000 */ +#define ADC_SQR1_SQ2_3 (0x08UL << ADC_SQR1_SQ2_Pos) /*!< 0x00008000 */ +#define ADC_SQR1_SQ2_4 (0x10UL << ADC_SQR1_SQ2_Pos) /*!< 0x00010000 */ + +#define ADC_SQR1_SQ3_Pos (18U) +#define ADC_SQR1_SQ3_Msk (0x1FUL << ADC_SQR1_SQ3_Pos) /*!< 0x007C0000 */ +#define ADC_SQR1_SQ3 ADC_SQR1_SQ3_Msk /*!< ADC 3rd conversion in regular sequence */ +#define ADC_SQR1_SQ3_0 (0x01UL << ADC_SQR1_SQ3_Pos) /*!< 0x00040000 */ +#define ADC_SQR1_SQ3_1 (0x02UL << ADC_SQR1_SQ3_Pos) /*!< 0x00080000 */ +#define ADC_SQR1_SQ3_2 (0x04UL << ADC_SQR1_SQ3_Pos) /*!< 0x00100000 */ +#define ADC_SQR1_SQ3_3 (0x08UL << ADC_SQR1_SQ3_Pos) /*!< 0x00200000 */ +#define ADC_SQR1_SQ3_4 (0x10UL << ADC_SQR1_SQ3_Pos) /*!< 0x00400000 */ + +#define ADC_SQR1_SQ4_Pos (24U) +#define ADC_SQR1_SQ4_Msk (0x1FUL << ADC_SQR1_SQ4_Pos) /*!< 0x1F000000 */ +#define ADC_SQR1_SQ4 ADC_SQR1_SQ4_Msk /*!< ADC 4th conversion in regular sequence */ +#define ADC_SQR1_SQ4_0 (0x01UL << ADC_SQR1_SQ4_Pos) /*!< 0x01000000 */ +#define ADC_SQR1_SQ4_1 (0x02UL << ADC_SQR1_SQ4_Pos) /*!< 0x02000000 */ +#define ADC_SQR1_SQ4_2 (0x04UL << ADC_SQR1_SQ4_Pos) /*!< 0x04000000 */ +#define ADC_SQR1_SQ4_3 (0x08UL << ADC_SQR1_SQ4_Pos) /*!< 0x08000000 */ +#define ADC_SQR1_SQ4_4 (0x10UL << ADC_SQR1_SQ4_Pos) /*!< 0x10000000 */ + +/******************** Bit definition for ADC_SQR2 register ********************/ +#define ADC_SQR2_SQ5_Pos (0U) +#define ADC_SQR2_SQ5_Msk (0x1FUL << ADC_SQR2_SQ5_Pos) /*!< 0x0000001F */ +#define ADC_SQR2_SQ5 ADC_SQR2_SQ5_Msk /*!< ADC 5th conversion in regular sequence */ +#define ADC_SQR2_SQ5_0 (0x01UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000001 */ +#define ADC_SQR2_SQ5_1 (0x02UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000002 */ +#define ADC_SQR2_SQ5_2 (0x04UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000004 */ +#define ADC_SQR2_SQ5_3 (0x08UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000008 */ +#define ADC_SQR2_SQ5_4 (0x10UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000010 */ + +#define ADC_SQR2_SQ6_Pos (6U) +#define ADC_SQR2_SQ6_Msk (0x1FUL << ADC_SQR2_SQ6_Pos) /*!< 0x000007C0 */ +#define ADC_SQR2_SQ6 ADC_SQR2_SQ6_Msk /*!< ADC 6th conversion in regular sequence */ +#define ADC_SQR2_SQ6_0 (0x01UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000040 */ +#define ADC_SQR2_SQ6_1 (0x02UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000080 */ +#define ADC_SQR2_SQ6_2 (0x04UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000100 */ +#define ADC_SQR2_SQ6_3 (0x08UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000200 */ +#define ADC_SQR2_SQ6_4 (0x10UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000400 */ + +#define ADC_SQR2_SQ7_Pos (12U) +#define ADC_SQR2_SQ7_Msk (0x1FUL << ADC_SQR2_SQ7_Pos) /*!< 0x0001F000 */ +#define ADC_SQR2_SQ7 ADC_SQR2_SQ7_Msk /*!< ADC 7th conversion in regular sequence */ +#define ADC_SQR2_SQ7_0 (0x01UL << ADC_SQR2_SQ7_Pos) /*!< 0x00001000 */ +#define ADC_SQR2_SQ7_1 (0x02UL << ADC_SQR2_SQ7_Pos) /*!< 0x00002000 */ +#define ADC_SQR2_SQ7_2 (0x04UL << ADC_SQR2_SQ7_Pos) /*!< 0x00004000 */ +#define ADC_SQR2_SQ7_3 (0x08UL << ADC_SQR2_SQ7_Pos) /*!< 0x00008000 */ +#define ADC_SQR2_SQ7_4 (0x10UL << ADC_SQR2_SQ7_Pos) /*!< 0x00010000 */ + +#define ADC_SQR2_SQ8_Pos (18U) +#define ADC_SQR2_SQ8_Msk (0x1FUL << ADC_SQR2_SQ8_Pos) /*!< 0x007C0000 */ +#define ADC_SQR2_SQ8 ADC_SQR2_SQ8_Msk /*!< ADC 8th conversion in regular sequence */ +#define ADC_SQR2_SQ8_0 (0x01UL << ADC_SQR2_SQ8_Pos) /*!< 0x00040000 */ +#define ADC_SQR2_SQ8_1 (0x02UL << ADC_SQR2_SQ8_Pos) /*!< 0x00080000 */ +#define ADC_SQR2_SQ8_2 (0x04UL << ADC_SQR2_SQ8_Pos) /*!< 0x00100000 */ +#define ADC_SQR2_SQ8_3 (0x08UL << ADC_SQR2_SQ8_Pos) /*!< 0x00200000 */ +#define ADC_SQR2_SQ8_4 (0x10UL << ADC_SQR2_SQ8_Pos) /*!< 0x00400000 */ + +#define ADC_SQR2_SQ9_Pos (24U) +#define ADC_SQR2_SQ9_Msk (0x1FUL << ADC_SQR2_SQ9_Pos) /*!< 0x1F000000 */ +#define ADC_SQR2_SQ9 ADC_SQR2_SQ9_Msk /*!< ADC 9th conversion in regular sequence */ +#define ADC_SQR2_SQ9_0 (0x01UL << ADC_SQR2_SQ9_Pos) /*!< 0x01000000 */ +#define ADC_SQR2_SQ9_1 (0x02UL << ADC_SQR2_SQ9_Pos) /*!< 0x02000000 */ +#define ADC_SQR2_SQ9_2 (0x04UL << ADC_SQR2_SQ9_Pos) /*!< 0x04000000 */ +#define ADC_SQR2_SQ9_3 (0x08UL << ADC_SQR2_SQ9_Pos) /*!< 0x08000000 */ +#define ADC_SQR2_SQ9_4 (0x10UL << ADC_SQR2_SQ9_Pos) /*!< 0x10000000 */ + +/******************** Bit definition for ADC_SQR3 register ********************/ +#define ADC_SQR3_SQ10_Pos (0U) +#define ADC_SQR3_SQ10_Msk (0x1FUL << ADC_SQR3_SQ10_Pos) /*!< 0x0000001F */ +#define ADC_SQR3_SQ10 ADC_SQR3_SQ10_Msk /*!< ADC 10th conversion in regular sequence */ +#define ADC_SQR3_SQ10_0 (0x01UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000001 */ +#define ADC_SQR3_SQ10_1 (0x02UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000002 */ +#define ADC_SQR3_SQ10_2 (0x04UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000004 */ +#define ADC_SQR3_SQ10_3 (0x08UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000008 */ +#define ADC_SQR3_SQ10_4 (0x10UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000010 */ + +#define ADC_SQR3_SQ11_Pos (6U) +#define ADC_SQR3_SQ11_Msk (0x1FUL << ADC_SQR3_SQ11_Pos) /*!< 0x000007C0 */ +#define ADC_SQR3_SQ11 ADC_SQR3_SQ11_Msk /*!< ADC 11th conversion in regular sequence */ +#define ADC_SQR3_SQ11_0 (0x01UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000040 */ +#define ADC_SQR3_SQ11_1 (0x02UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000080 */ +#define ADC_SQR3_SQ11_2 (0x04UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000100 */ +#define ADC_SQR3_SQ11_3 (0x08UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000200 */ +#define ADC_SQR3_SQ11_4 (0x10UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000400 */ + +#define ADC_SQR3_SQ12_Pos (12U) +#define ADC_SQR3_SQ12_Msk (0x1FUL << ADC_SQR3_SQ12_Pos) /*!< 0x0001F000 */ +#define ADC_SQR3_SQ12 ADC_SQR3_SQ12_Msk /*!< ADC 12th conversion in regular sequence */ +#define ADC_SQR3_SQ12_0 (0x01UL << ADC_SQR3_SQ12_Pos) /*!< 0x00001000 */ +#define ADC_SQR3_SQ12_1 (0x02UL << ADC_SQR3_SQ12_Pos) /*!< 0x00002000 */ +#define ADC_SQR3_SQ12_2 (0x04UL << ADC_SQR3_SQ12_Pos) /*!< 0x00004000 */ +#define ADC_SQR3_SQ12_3 (0x08UL << ADC_SQR3_SQ12_Pos) /*!< 0x00008000 */ +#define ADC_SQR3_SQ12_4 (0x10UL << ADC_SQR3_SQ12_Pos) /*!< 0x00010000 */ + +#define ADC_SQR3_SQ13_Pos (18U) +#define ADC_SQR3_SQ13_Msk (0x1FUL << ADC_SQR3_SQ13_Pos) /*!< 0x007C0000 */ +#define ADC_SQR3_SQ13 ADC_SQR3_SQ13_Msk /*!< ADC 13th conversion in regular sequence */ +#define ADC_SQR3_SQ13_0 (0x01UL << ADC_SQR3_SQ13_Pos) /*!< 0x00040000 */ +#define ADC_SQR3_SQ13_1 (0x02UL << ADC_SQR3_SQ13_Pos) /*!< 0x00080000 */ +#define ADC_SQR3_SQ13_2 (0x04UL << ADC_SQR3_SQ13_Pos) /*!< 0x00100000 */ +#define ADC_SQR3_SQ13_3 (0x08UL << ADC_SQR3_SQ13_Pos) /*!< 0x00200000 */ +#define ADC_SQR3_SQ13_4 (0x10UL << ADC_SQR3_SQ13_Pos) /*!< 0x00400000 */ + +#define ADC_SQR3_SQ14_Pos (24U) +#define ADC_SQR3_SQ14_Msk (0x1FUL << ADC_SQR3_SQ14_Pos) /*!< 0x1F000000 */ +#define ADC_SQR3_SQ14 ADC_SQR3_SQ14_Msk /*!< ADC 14th conversion in regular sequence */ +#define ADC_SQR3_SQ14_0 (0x01UL << ADC_SQR3_SQ14_Pos) /*!< 0x01000000 */ +#define ADC_SQR3_SQ14_1 (0x02UL << ADC_SQR3_SQ14_Pos) /*!< 0x02000000 */ +#define ADC_SQR3_SQ14_2 (0x04UL << ADC_SQR3_SQ14_Pos) /*!< 0x04000000 */ +#define ADC_SQR3_SQ14_3 (0x08UL << ADC_SQR3_SQ14_Pos) /*!< 0x08000000 */ +#define ADC_SQR3_SQ14_4 (0x10UL << ADC_SQR3_SQ14_Pos) /*!< 0x10000000 */ + +/******************** Bit definition for ADC_SQR4 register ********************/ +#define ADC_SQR4_SQ15_Pos (0U) +#define ADC_SQR4_SQ15_Msk (0x1FUL << ADC_SQR4_SQ15_Pos) /*!< 0x0000001F */ +#define ADC_SQR4_SQ15 ADC_SQR4_SQ15_Msk /*!< ADC 15th conversion in regular sequence */ +#define ADC_SQR4_SQ15_0 (0x01UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000001 */ +#define ADC_SQR4_SQ15_1 (0x02UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000002 */ +#define ADC_SQR4_SQ15_2 (0x04UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000004 */ +#define ADC_SQR4_SQ15_3 (0x08UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000008 */ +#define ADC_SQR4_SQ15_4 (0x10UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000010 */ + +#define ADC_SQR4_SQ16_Pos (6U) +#define ADC_SQR4_SQ16_Msk (0x1FUL << ADC_SQR4_SQ16_Pos) /*!< 0x000007C0 */ +#define ADC_SQR4_SQ16 ADC_SQR4_SQ16_Msk /*!< ADC 16th conversion in regular sequence */ +#define ADC_SQR4_SQ16_0 (0x01UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000040 */ +#define ADC_SQR4_SQ16_1 (0x02UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000080 */ +#define ADC_SQR4_SQ16_2 (0x04UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000100 */ +#define ADC_SQR4_SQ16_3 (0x08UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000200 */ +#define ADC_SQR4_SQ16_4 (0x10UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000400 */ +/******************** Bit definition for ADC_DR register ********************/ +#define ADC_DR_RDATA_Pos (0U) +#define ADC_DR_RDATA_Msk (0xFFFFFFFFUL << ADC_DR_RDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_DR_RDATA ADC_DR_RDATA_Msk /*!< ADC regular Data converted */ + +/******************** Bit definition for ADC_JSQR register ********************/ +#define ADC_JSQR_JL_Pos (0U) +#define ADC_JSQR_JL_Msk (0x3UL << ADC_JSQR_JL_Pos) /*!< 0x00000003 */ +#define ADC_JSQR_JL ADC_JSQR_JL_Msk /*!< ADC injected channel sequence length */ +#define ADC_JSQR_JL_0 (0x1UL << ADC_JSQR_JL_Pos) /*!< 0x00000001 */ +#define ADC_JSQR_JL_1 (0x2UL << ADC_JSQR_JL_Pos) /*!< 0x00000002 */ + +#define ADC_JSQR_JEXTSEL_Pos (2U) +#define ADC_JSQR_JEXTSEL_Msk (0x1FUL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x0000007C */ +#define ADC_JSQR_JEXTSEL ADC_JSQR_JEXTSEL_Msk /*!< ADC external trigger selection for injected group */ +#define ADC_JSQR_JEXTSEL_0 (0x01UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000004 */ +#define ADC_JSQR_JEXTSEL_1 (0x02UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000008 */ +#define ADC_JSQR_JEXTSEL_2 (0x04UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000010 */ +#define ADC_JSQR_JEXTSEL_3 (0x08UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000020 */ +#define ADC_JSQR_JEXTSEL_4 (0x10UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000040 */ + +#define ADC_JSQR_JEXTEN_Pos (7U) +#define ADC_JSQR_JEXTEN_Msk (0x3UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000180 */ +#define ADC_JSQR_JEXTEN ADC_JSQR_JEXTEN_Msk /*!< ADC external trigger enable and polarity selection for injected channels */ +#define ADC_JSQR_JEXTEN_0 (0x1UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000080 */ +#define ADC_JSQR_JEXTEN_1 (0x2UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000100 */ + +#define ADC_JSQR_JSQ1_Pos (9U) +#define ADC_JSQR_JSQ1_Msk (0x1FUL << ADC_JSQR_JSQ1_Pos) /*!< 0x00003E00 */ +#define ADC_JSQR_JSQ1 ADC_JSQR_JSQ1_Msk /*!< ADC 1st conversion in injected sequence */ +#define ADC_JSQR_JSQ1_0 (0x01UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000200 */ +#define ADC_JSQR_JSQ1_1 (0x02UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000400 */ +#define ADC_JSQR_JSQ1_2 (0x04UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000800 */ +#define ADC_JSQR_JSQ1_3 (0x08UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00001000 */ +#define ADC_JSQR_JSQ1_4 (0x10UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00002000 */ + +#define ADC_JSQR_JSQ2_Pos (15U) +#define ADC_JSQR_JSQ2_Msk (0x1FUL << ADC_JSQR_JSQ2_Pos) /*!< 0x000F8000 */ +#define ADC_JSQR_JSQ2 ADC_JSQR_JSQ2_Msk /*!< ADC 2nd conversion in injected sequence */ +#define ADC_JSQR_JSQ2_0 (0x01UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00008000 */ +#define ADC_JSQR_JSQ2_1 (0x02UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00010000 */ +#define ADC_JSQR_JSQ2_2 (0x04UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00020000 */ +#define ADC_JSQR_JSQ2_3 (0x08UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00040000 */ +#define ADC_JSQR_JSQ2_4 (0x10UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00080000 */ + +#define ADC_JSQR_JSQ3_Pos (21U) +#define ADC_JSQR_JSQ3_Msk (0x1FUL << ADC_JSQR_JSQ3_Pos) /*!< 0x03E00000 */ +#define ADC_JSQR_JSQ3 ADC_JSQR_JSQ3_Msk /*!< ADC 3rd conversion in injected sequence */ +#define ADC_JSQR_JSQ3_0 (0x01UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00200000 */ +#define ADC_JSQR_JSQ3_1 (0x02UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00400000 */ +#define ADC_JSQR_JSQ3_2 (0x04UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00800000 */ +#define ADC_JSQR_JSQ3_3 (0x08UL << ADC_JSQR_JSQ3_Pos) /*!< 0x01000000 */ +#define ADC_JSQR_JSQ3_4 (0x10UL << ADC_JSQR_JSQ3_Pos) /*!< 0x02000000 */ + +#define ADC_JSQR_JSQ4_Pos (27U) +#define ADC_JSQR_JSQ4_Msk (0x1FUL << ADC_JSQR_JSQ4_Pos) /*!< 0xF8000000 */ +#define ADC_JSQR_JSQ4 ADC_JSQR_JSQ4_Msk /*!< ADC 4th conversion in injected sequence */ +#define ADC_JSQR_JSQ4_0 (0x01UL << ADC_JSQR_JSQ4_Pos) /*!< 0x08000000 */ +#define ADC_JSQR_JSQ4_1 (0x02UL << ADC_JSQR_JSQ4_Pos) /*!< 0x10000000 */ +#define ADC_JSQR_JSQ4_2 (0x04UL << ADC_JSQR_JSQ4_Pos) /*!< 0x20000000 */ +#define ADC_JSQR_JSQ4_3 (0x08UL << ADC_JSQR_JSQ4_Pos) /*!< 0x40000000 */ +#define ADC_JSQR_JSQ4_4 (0x10UL << ADC_JSQR_JSQ4_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_OFR1 register ********************/ +#define ADC_OFR1_OFFSET1_Pos (0U) +#define ADC_OFR1_OFFSET1_Msk (0x3FFFFFFUL << ADC_OFR1_OFFSET1_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR1_OFFSET1 ADC_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ +#define ADC_OFR1_OFFSET1_0 (0x0000001UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000001 */ +#define ADC_OFR1_OFFSET1_1 (0x0000002UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000002 */ +#define ADC_OFR1_OFFSET1_2 (0x0000004UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000004 */ +#define ADC_OFR1_OFFSET1_3 (0x0000008UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000008 */ +#define ADC_OFR1_OFFSET1_4 (0x0000010UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000010 */ +#define ADC_OFR1_OFFSET1_5 (0x0000020UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000020 */ +#define ADC_OFR1_OFFSET1_6 (0x0000040UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000040 */ +#define ADC_OFR1_OFFSET1_7 (0x0000080UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000080 */ +#define ADC_OFR1_OFFSET1_8 (0x0000100UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000100 */ +#define ADC_OFR1_OFFSET1_9 (0x0000200UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000200 */ +#define ADC_OFR1_OFFSET1_10 (0x0000400UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000400 */ +#define ADC_OFR1_OFFSET1_11 (0x0000800UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000800 */ +#define ADC_OFR1_OFFSET1_12 (0x0001000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00001000 */ +#define ADC_OFR1_OFFSET1_13 (0x0002000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00002000 */ +#define ADC_OFR1_OFFSET1_14 (0x0004000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00004000 */ +#define ADC_OFR1_OFFSET1_15 (0x0008000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00008000 */ +#define ADC_OFR1_OFFSET1_16 (0x0010000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00010000 */ +#define ADC_OFR1_OFFSET1_17 (0x0020000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00020000 */ +#define ADC_OFR1_OFFSET1_18 (0x0040000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00040000 */ +#define ADC_OFR1_OFFSET1_19 (0x0080000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00080000 */ +#define ADC_OFR1_OFFSET1_20 (0x0100000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00100000 */ +#define ADC_OFR1_OFFSET1_21 (0x0200000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00200000 */ +#define ADC_OFR1_OFFSET1_22 (0x0400000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00400000 */ +#define ADC_OFR1_OFFSET1_23 (0x0800000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00800000 */ +#define ADC_OFR1_OFFSET1_24 (0x1000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x01000000 */ +#define ADC_OFR1_OFFSET1_25 (0x2000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x02000000 */ + +#define ADC_OFR1_OFFSET1_CH_Pos (26U) +#define ADC_OFR1_OFFSET1_CH_Msk (0x1FUL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR1_OFFSET1_CH ADC_OFR1_OFFSET1_CH_Msk /*!< ADC Channel selection for the data offset 1 */ +#define ADC_OFR1_OFFSET1_CH_0 (0x01UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR1_OFFSET1_CH_1 (0x02UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR1_OFFSET1_CH_2 (0x04UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR1_OFFSET1_CH_3 (0x08UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR1_OFFSET1_CH_4 (0x10UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR1_SSATE_Pos (31U) +#define ADC_OFR1_SSATE_Msk (0x1UL << ADC_OFR1_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR1_SSATE ADC_OFR1_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR1_OFFSET1_Pos (0U) +#define ADC3_OFR1_OFFSET1_Msk (0xFFFUL << ADC3_OFR1_OFFSET1_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR1_OFFSET1 ADC3_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR1_OFFSETPOS_Pos (24U) +#define ADC3_OFR1_OFFSETPOS_Msk (0x1UL << ADC3_OFR1_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR1_OFFSETPOS ADC3_OFR1_OFFSETPOS_Msk /*!< ADC offset number 1 positive */ +#define ADC3_OFR1_SATEN_Pos (25U) +#define ADC3_OFR1_SATEN_Msk (0x1UL << ADC3_OFR1_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR1_SATEN ADC3_OFR1_SATEN_Msk /*!< ADC offset number 1 saturation enable */ + +#define ADC3_OFR1_OFFSET1_EN_Pos (31U) +#define ADC3_OFR1_OFFSET1_EN_Msk (0x1UL << ADC3_OFR1_OFFSET1_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR1_OFFSET1_EN ADC3_OFR1_OFFSET1_EN_Msk /*!< ADC offset number 1 enable */ + +/******************** Bit definition for ADC_OFR2 register ********************/ +#define ADC_OFR2_OFFSET2_Pos (0U) +#define ADC_OFR2_OFFSET2_Msk (0x3FFFFFFUL << ADC_OFR2_OFFSET2_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR2_OFFSET2 ADC_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET2_CH[4:0] */ +#define ADC_OFR2_OFFSET2_0 (0x0000001UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000001 */ +#define ADC_OFR2_OFFSET2_1 (0x0000002UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000002 */ +#define ADC_OFR2_OFFSET2_2 (0x0000004UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000004 */ +#define ADC_OFR2_OFFSET2_3 (0x0000008UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000008 */ +#define ADC_OFR2_OFFSET2_4 (0x0000010UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000010 */ +#define ADC_OFR2_OFFSET2_5 (0x0000020UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000020 */ +#define ADC_OFR2_OFFSET2_6 (0x0000040UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000040 */ +#define ADC_OFR2_OFFSET2_7 (0x0000080UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000080 */ +#define ADC_OFR2_OFFSET2_8 (0x0000100UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000100 */ +#define ADC_OFR2_OFFSET2_9 (0x0000200UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000200 */ +#define ADC_OFR2_OFFSET2_10 (0x0000400UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000400 */ +#define ADC_OFR2_OFFSET2_11 (0x0000800UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000800 */ +#define ADC_OFR2_OFFSET2_12 (0x0001000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00001000 */ +#define ADC_OFR2_OFFSET2_13 (0x0002000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00002000 */ +#define ADC_OFR2_OFFSET2_14 (0x0004000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00004000 */ +#define ADC_OFR2_OFFSET2_15 (0x0008000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00008000 */ +#define ADC_OFR2_OFFSET2_16 (0x0010000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00010000 */ +#define ADC_OFR2_OFFSET2_17 (0x0020000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00020000 */ +#define ADC_OFR2_OFFSET2_18 (0x0040000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00040000 */ +#define ADC_OFR2_OFFSET2_19 (0x0080000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00080000 */ +#define ADC_OFR2_OFFSET2_20 (0x0100000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00100000 */ +#define ADC_OFR2_OFFSET2_21 (0x0200000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00200000 */ +#define ADC_OFR2_OFFSET2_22 (0x0400000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00400000 */ +#define ADC_OFR2_OFFSET2_23 (0x0800000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00800000 */ +#define ADC_OFR2_OFFSET2_24 (0x1000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x01000000 */ +#define ADC_OFR2_OFFSET2_25 (0x2000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x02000000 */ + +#define ADC_OFR2_OFFSET2_CH_Pos (26U) +#define ADC_OFR2_OFFSET2_CH_Msk (0x1FUL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR2_OFFSET2_CH ADC_OFR2_OFFSET2_CH_Msk /*!< ADC Channel selection for the data offset 2 */ +#define ADC_OFR2_OFFSET2_CH_0 (0x01UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR2_OFFSET2_CH_1 (0x02UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR2_OFFSET2_CH_2 (0x04UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR2_OFFSET2_CH_3 (0x08UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR2_OFFSET2_CH_4 (0x10UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR2_SSATE_Pos (31U) +#define ADC_OFR2_SSATE_Msk (0x1UL << ADC_OFR2_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR2_SSATE ADC_OFR2_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR2_OFFSET2_Pos (0U) +#define ADC3_OFR2_OFFSET2_Msk (0xFFFUL << ADC3_OFR2_OFFSET2_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR2_OFFSET2 ADC3_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR2_OFFSETPOS_Pos (24U) +#define ADC3_OFR2_OFFSETPOS_Msk (0x1UL << ADC3_OFR2_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR2_OFFSETPOS ADC3_OFR2_OFFSETPOS_Msk /*!< ADC offset number 2 positive */ +#define ADC3_OFR2_SATEN_Pos (25U) +#define ADC3_OFR2_SATEN_Msk (0x1UL << ADC3_OFR2_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR2_SATEN ADC3_OFR2_SATEN_Msk /*!< ADC offset number 2 saturation enable */ + +#define ADC3_OFR2_OFFSET2_EN_Pos (31U) +#define ADC3_OFR2_OFFSET2_EN_Msk (0x1UL << ADC3_OFR2_OFFSET2_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR2_OFFSET2_EN ADC3_OFR2_OFFSET2_EN_Msk /*!< ADC offset number 2 enable */ + +/******************** Bit definition for ADC_OFR3 register ********************/ +#define ADC_OFR3_OFFSET3_Pos (0U) +#define ADC_OFR3_OFFSET3_Msk (0x3FFFFFFUL << ADC_OFR3_OFFSET3_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR3_OFFSET3 ADC_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET3_CH[4:0] */ +#define ADC_OFR3_OFFSET3_0 (0x0000001UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000001 */ +#define ADC_OFR3_OFFSET3_1 (0x0000002UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000002 */ +#define ADC_OFR3_OFFSET3_2 (0x0000004UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000004 */ +#define ADC_OFR3_OFFSET3_3 (0x0000008UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000008 */ +#define ADC_OFR3_OFFSET3_4 (0x0000010UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000010 */ +#define ADC_OFR3_OFFSET3_5 (0x0000020UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000020 */ +#define ADC_OFR3_OFFSET3_6 (0x0000040UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000040 */ +#define ADC_OFR3_OFFSET3_7 (0x0000080UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000080 */ +#define ADC_OFR3_OFFSET3_8 (0x0000100UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000100 */ +#define ADC_OFR3_OFFSET3_9 (0x0000200UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000200 */ +#define ADC_OFR3_OFFSET3_10 (0x0000400UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000400 */ +#define ADC_OFR3_OFFSET3_11 (0x0000800UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000800 */ +#define ADC_OFR3_OFFSET3_12 (0x0001000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00001000 */ +#define ADC_OFR3_OFFSET3_13 (0x0002000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00002000 */ +#define ADC_OFR3_OFFSET3_14 (0x0004000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00004000 */ +#define ADC_OFR3_OFFSET3_15 (0x0008000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00008000 */ +#define ADC_OFR3_OFFSET3_16 (0x0010000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00010000 */ +#define ADC_OFR3_OFFSET3_17 (0x0020000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00020000 */ +#define ADC_OFR3_OFFSET3_18 (0x0040000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00040000 */ +#define ADC_OFR3_OFFSET3_19 (0x0080000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00080000 */ +#define ADC_OFR3_OFFSET3_20 (0x0100000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00100000 */ +#define ADC_OFR3_OFFSET3_21 (0x0200000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00200000 */ +#define ADC_OFR3_OFFSET3_22 (0x0400000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00400000 */ +#define ADC_OFR3_OFFSET3_23 (0x0800000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00800000 */ +#define ADC_OFR3_OFFSET3_24 (0x1000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x01000000 */ +#define ADC_OFR3_OFFSET3_25 (0x2000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x02000000 */ + +#define ADC_OFR3_OFFSET3_CH_Pos (26U) +#define ADC_OFR3_OFFSET3_CH_Msk (0x1FUL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR3_OFFSET3_CH ADC_OFR3_OFFSET3_CH_Msk /*!< ADC Channel selection for the data offset 3 */ +#define ADC_OFR3_OFFSET3_CH_0 (0x01UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR3_OFFSET3_CH_1 (0x02UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR3_OFFSET3_CH_2 (0x04UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR3_OFFSET3_CH_3 (0x08UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR3_OFFSET3_CH_4 (0x10UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR3_SSATE_Pos (31U) +#define ADC_OFR3_SSATE_Msk (0x1UL << ADC_OFR3_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR3_SSATE ADC_OFR3_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR3_OFFSET3_Pos (0U) +#define ADC3_OFR3_OFFSET3_Msk (0xFFFUL << ADC3_OFR3_OFFSET3_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR3_OFFSET3 ADC3_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR3_OFFSETPOS_Pos (24U) +#define ADC3_OFR3_OFFSETPOS_Msk (0x1UL << ADC3_OFR3_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR3_OFFSETPOS ADC3_OFR3_OFFSETPOS_Msk /*!< ADC offset number 3 positive */ +#define ADC3_OFR3_SATEN_Pos (25U) +#define ADC3_OFR3_SATEN_Msk (0x1UL << ADC3_OFR3_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR3_SATEN ADC3_OFR3_SATEN_Msk /*!< ADC offset number 3 saturation enable */ + +#define ADC3_OFR3_OFFSET3_EN_Pos (31U) +#define ADC3_OFR3_OFFSET3_EN_Msk (0x1UL << ADC3_OFR3_OFFSET3_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR3_OFFSET3_EN ADC3_OFR3_OFFSET3_EN_Msk /*!< ADC offset number 3 enable */ + +/******************** Bit definition for ADC_OFR4 register ********************/ +#define ADC_OFR4_OFFSET4_Pos (0U) +#define ADC_OFR4_OFFSET4_Msk (0x3FFFFFFUL << ADC_OFR4_OFFSET4_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR4_OFFSET4 ADC_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET4_CH[4:0] */ +#define ADC_OFR4_OFFSET4_0 (0x0000001UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000001 */ +#define ADC_OFR4_OFFSET4_1 (0x0000002UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000002 */ +#define ADC_OFR4_OFFSET4_2 (0x0000004UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000004 */ +#define ADC_OFR4_OFFSET4_3 (0x0000008UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000008 */ +#define ADC_OFR4_OFFSET4_4 (0x0000010UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000010 */ +#define ADC_OFR4_OFFSET4_5 (0x0000020UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000020 */ +#define ADC_OFR4_OFFSET4_6 (0x0000040UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000040 */ +#define ADC_OFR4_OFFSET4_7 (0x0000080UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000080 */ +#define ADC_OFR4_OFFSET4_8 (0x0000100UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000100 */ +#define ADC_OFR4_OFFSET4_9 (0x0000200UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000200 */ +#define ADC_OFR4_OFFSET4_10 (0x0000400UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000400 */ +#define ADC_OFR4_OFFSET4_11 (0x0000800UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000800 */ +#define ADC_OFR4_OFFSET4_12 (0x0001000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00001000 */ +#define ADC_OFR4_OFFSET4_13 (0x0002000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00002000 */ +#define ADC_OFR4_OFFSET4_14 (0x0004000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00004000 */ +#define ADC_OFR4_OFFSET4_15 (0x0008000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00008000 */ +#define ADC_OFR4_OFFSET4_16 (0x0010000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00010000 */ +#define ADC_OFR4_OFFSET4_17 (0x0020000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00020000 */ +#define ADC_OFR4_OFFSET4_18 (0x0040000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00040000 */ +#define ADC_OFR4_OFFSET4_19 (0x0080000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00080000 */ +#define ADC_OFR4_OFFSET4_20 (0x0100000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00100000 */ +#define ADC_OFR4_OFFSET4_21 (0x0200000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00200000 */ +#define ADC_OFR4_OFFSET4_22 (0x0400000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00400000 */ +#define ADC_OFR4_OFFSET4_23 (0x0800000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00800000 */ +#define ADC_OFR4_OFFSET4_24 (0x1000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x01000000 */ +#define ADC_OFR4_OFFSET4_25 (0x2000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x02000000 */ + +#define ADC_OFR4_OFFSET4_CH_Pos (26U) +#define ADC_OFR4_OFFSET4_CH_Msk (0x1FUL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR4_OFFSET4_CH ADC_OFR4_OFFSET4_CH_Msk /*!< ADC Channel selection for the data offset 4 */ +#define ADC_OFR4_OFFSET4_CH_0 (0x01UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR4_OFFSET4_CH_1 (0x02UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR4_OFFSET4_CH_2 (0x04UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR4_OFFSET4_CH_3 (0x08UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR4_OFFSET4_CH_4 (0x10UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR4_SSATE_Pos (31U) +#define ADC_OFR4_SSATE_Msk (0x1UL << ADC_OFR4_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR4_SSATE ADC_OFR4_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR4_OFFSET4_Pos (0U) +#define ADC3_OFR4_OFFSET4_Msk (0xFFFUL << ADC3_OFR4_OFFSET4_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR4_OFFSET4 ADC3_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR4_OFFSETPOS_Pos (24U) +#define ADC3_OFR4_OFFSETPOS_Msk (0x1UL << ADC3_OFR4_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR4_OFFSETPOS ADC3_OFR4_OFFSETPOS_Msk /*!< ADC offset number 4 positive */ +#define ADC3_OFR4_SATEN_Pos (25U) +#define ADC3_OFR4_SATEN_Msk (0x1UL << ADC3_OFR4_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR4_SATEN ADC3_OFR4_SATEN_Msk /*!< ADC offset number 4 saturation enable */ + +#define ADC3_OFR4_OFFSET4_EN_Pos (31U) +#define ADC3_OFR4_OFFSET4_EN_Msk (0x1UL << ADC3_OFR4_OFFSET4_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR4_OFFSET4_EN ADC3_OFR4_OFFSET4_EN_Msk /*!< ADC offset number 4 enable */ + +/******************** Bit definition for ADC_JDR1 register ********************/ +#define ADC_JDR1_JDATA_Pos (0U) +#define ADC_JDR1_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR1_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR1_JDATA ADC_JDR1_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR1_JDATA_0 (0x00000001UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR1_JDATA_1 (0x00000002UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR1_JDATA_2 (0x00000004UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR1_JDATA_3 (0x00000008UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR1_JDATA_4 (0x00000010UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR1_JDATA_5 (0x00000020UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR1_JDATA_6 (0x00000040UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR1_JDATA_7 (0x00000080UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR1_JDATA_8 (0x00000100UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR1_JDATA_9 (0x00000200UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR1_JDATA_10 (0x00000400UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR1_JDATA_11 (0x00000800UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR1_JDATA_12 (0x00001000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR1_JDATA_13 (0x00002000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR1_JDATA_14 (0x00004000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR1_JDATA_15 (0x00008000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR1_JDATA_16 (0x00010000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR1_JDATA_17 (0x00020000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR1_JDATA_18 (0x00040000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR1_JDATA_19 (0x00080000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR1_JDATA_20 (0x00100000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR1_JDATA_21 (0x00200000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR1_JDATA_22 (0x00400000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR1_JDATA_23 (0x00800000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR1_JDATA_24 (0x01000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR1_JDATA_25 (0x02000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR1_JDATA_26 (0x04000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR1_JDATA_27 (0x08000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR1_JDATA_28 (0x10000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR1_JDATA_29 (0x20000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR1_JDATA_30 (0x40000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR1_JDATA_31 (0x80000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_JDR2 register ********************/ +#define ADC_JDR2_JDATA_Pos (0U) +#define ADC_JDR2_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR2_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR2_JDATA ADC_JDR2_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR2_JDATA_0 (0x00000001UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR2_JDATA_1 (0x00000002UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR2_JDATA_2 (0x00000004UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR2_JDATA_3 (0x00000008UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR2_JDATA_4 (0x00000010UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR2_JDATA_5 (0x00000020UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR2_JDATA_6 (0x00000040UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR2_JDATA_7 (0x00000080UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR2_JDATA_8 (0x00000100UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR2_JDATA_9 (0x00000200UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR2_JDATA_10 (0x00000400UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR2_JDATA_11 (0x00000800UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR2_JDATA_12 (0x00001000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR2_JDATA_13 (0x00002000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR2_JDATA_14 (0x00004000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR2_JDATA_15 (0x00008000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR2_JDATA_16 (0x00010000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR2_JDATA_17 (0x00020000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR2_JDATA_18 (0x00040000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR2_JDATA_19 (0x00080000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR2_JDATA_20 (0x00100000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR2_JDATA_21 (0x00200000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR2_JDATA_22 (0x00400000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR2_JDATA_23 (0x00800000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR2_JDATA_24 (0x01000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR2_JDATA_25 (0x02000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR2_JDATA_26 (0x04000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR2_JDATA_27 (0x08000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR2_JDATA_28 (0x10000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR2_JDATA_29 (0x20000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR2_JDATA_30 (0x40000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR2_JDATA_31 (0x80000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_JDR3 register ********************/ +#define ADC_JDR3_JDATA_Pos (0U) +#define ADC_JDR3_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR3_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR3_JDATA ADC_JDR3_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR3_JDATA_0 (0x00000001UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR3_JDATA_1 (0x00000002UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR3_JDATA_2 (0x00000004UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR3_JDATA_3 (0x00000008UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR3_JDATA_4 (0x00000010UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR3_JDATA_5 (0x00000020UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR3_JDATA_6 (0x00000040UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR3_JDATA_7 (0x00000080UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR3_JDATA_8 (0x00000100UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR3_JDATA_9 (0x00000200UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR3_JDATA_10 (0x00000400UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR3_JDATA_11 (0x00000800UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR3_JDATA_12 (0x00001000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR3_JDATA_13 (0x00002000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR3_JDATA_14 (0x00004000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR3_JDATA_15 (0x00008000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR3_JDATA_16 (0x00010000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR3_JDATA_17 (0x00020000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR3_JDATA_18 (0x00040000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR3_JDATA_19 (0x00080000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR3_JDATA_20 (0x00100000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR3_JDATA_21 (0x00200000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR3_JDATA_22 (0x00400000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR3_JDATA_23 (0x00800000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR3_JDATA_24 (0x01000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR3_JDATA_25 (0x02000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR3_JDATA_26 (0x04000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR3_JDATA_27 (0x08000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR3_JDATA_28 (0x10000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR3_JDATA_29 (0x20000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR3_JDATA_30 (0x40000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR3_JDATA_31 (0x80000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_JDR4 register ********************/ +#define ADC_JDR4_JDATA_Pos (0U) +#define ADC_JDR4_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR4_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR4_JDATA ADC_JDR4_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR4_JDATA_0 (0x00000001UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR4_JDATA_1 (0x00000002UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR4_JDATA_2 (0x00000004UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR4_JDATA_3 (0x00000008UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR4_JDATA_4 (0x00000010UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR4_JDATA_5 (0x00000020UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR4_JDATA_6 (0x00000040UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR4_JDATA_7 (0x00000080UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR4_JDATA_8 (0x00000100UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR4_JDATA_9 (0x00000200UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR4_JDATA_10 (0x00000400UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR4_JDATA_11 (0x00000800UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR4_JDATA_12 (0x00001000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR4_JDATA_13 (0x00002000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR4_JDATA_14 (0x00004000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR4_JDATA_15 (0x00008000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR4_JDATA_16 (0x00010000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR4_JDATA_17 (0x00020000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR4_JDATA_18 (0x00040000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR4_JDATA_19 (0x00080000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR4_JDATA_20 (0x00100000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR4_JDATA_21 (0x00200000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR4_JDATA_22 (0x00400000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR4_JDATA_23 (0x00800000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR4_JDATA_24 (0x01000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR4_JDATA_25 (0x02000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR4_JDATA_26 (0x04000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR4_JDATA_27 (0x08000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR4_JDATA_28 (0x10000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR4_JDATA_29 (0x20000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR4_JDATA_30 (0x40000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR4_JDATA_31 (0x80000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_AWD2CR register ********************/ +#define ADC_AWD2CR_AWD2CH_Pos (0U) +#define ADC_AWD2CR_AWD2CH_Msk (0xFFFFFUL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x000FFFFF */ +#define ADC_AWD2CR_AWD2CH ADC_AWD2CR_AWD2CH_Msk /*!< ADC Analog watchdog 2 channel selection */ +#define ADC_AWD2CR_AWD2CH_0 (0x00001UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000001 */ +#define ADC_AWD2CR_AWD2CH_1 (0x00002UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000002 */ +#define ADC_AWD2CR_AWD2CH_2 (0x00004UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000004 */ +#define ADC_AWD2CR_AWD2CH_3 (0x00008UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000008 */ +#define ADC_AWD2CR_AWD2CH_4 (0x00010UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000010 */ +#define ADC_AWD2CR_AWD2CH_5 (0x00020UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000020 */ +#define ADC_AWD2CR_AWD2CH_6 (0x00040UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000040 */ +#define ADC_AWD2CR_AWD2CH_7 (0x00080UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000080 */ +#define ADC_AWD2CR_AWD2CH_8 (0x00100UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000100 */ +#define ADC_AWD2CR_AWD2CH_9 (0x00200UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000200 */ +#define ADC_AWD2CR_AWD2CH_10 (0x00400UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000400 */ +#define ADC_AWD2CR_AWD2CH_11 (0x00800UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000800 */ +#define ADC_AWD2CR_AWD2CH_12 (0x01000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00001000 */ +#define ADC_AWD2CR_AWD2CH_13 (0x02000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00002000 */ +#define ADC_AWD2CR_AWD2CH_14 (0x04000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00004000 */ +#define ADC_AWD2CR_AWD2CH_15 (0x08000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00008000 */ +#define ADC_AWD2CR_AWD2CH_16 (0x10000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00010000 */ +#define ADC_AWD2CR_AWD2CH_17 (0x20000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00020000 */ +#define ADC_AWD2CR_AWD2CH_18 (0x40000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00040000 */ +#define ADC_AWD2CR_AWD2CH_19 (0x80000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00080000 */ + +/******************** Bit definition for ADC_AWD3CR register ********************/ +#define ADC_AWD3CR_AWD3CH_Pos (0U) +#define ADC_AWD3CR_AWD3CH_Msk (0xFFFFFUL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x000FFFFF */ +#define ADC_AWD3CR_AWD3CH ADC_AWD3CR_AWD3CH_Msk /*!< ADC Analog watchdog 2 channel selection */ +#define ADC_AWD3CR_AWD3CH_0 (0x00001UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000001 */ +#define ADC_AWD3CR_AWD3CH_1 (0x00002UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000002 */ +#define ADC_AWD3CR_AWD3CH_2 (0x00004UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000004 */ +#define ADC_AWD3CR_AWD3CH_3 (0x00008UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000008 */ +#define ADC_AWD3CR_AWD3CH_4 (0x00010UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000010 */ +#define ADC_AWD3CR_AWD3CH_5 (0x00020UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000020 */ +#define ADC_AWD3CR_AWD3CH_6 (0x00040UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000040 */ +#define ADC_AWD3CR_AWD3CH_7 (0x00080UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000080 */ +#define ADC_AWD3CR_AWD3CH_8 (0x00100UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000100 */ +#define ADC_AWD3CR_AWD3CH_9 (0x00200UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000200 */ +#define ADC_AWD3CR_AWD3CH_10 (0x00400UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000400 */ +#define ADC_AWD3CR_AWD3CH_11 (0x00800UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000800 */ +#define ADC_AWD3CR_AWD3CH_12 (0x01000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00001000 */ +#define ADC_AWD3CR_AWD3CH_13 (0x02000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00002000 */ +#define ADC_AWD3CR_AWD3CH_14 (0x04000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00004000 */ +#define ADC_AWD3CR_AWD3CH_15 (0x08000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00008000 */ +#define ADC_AWD3CR_AWD3CH_16 (0x10000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00010000 */ +#define ADC_AWD3CR_AWD3CH_17 (0x20000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00020000 */ +#define ADC_AWD3CR_AWD3CH_18 (0x40000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00040000 */ +#define ADC_AWD3CR_AWD3CH_19 (0x80000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00080000 */ + +/******************** Bit definition for ADC_DIFSEL register ********************/ +#define ADC_DIFSEL_DIFSEL_Pos (0U) +#define ADC_DIFSEL_DIFSEL_Msk (0xFFFFFUL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x000FFFFF */ +#define ADC_DIFSEL_DIFSEL ADC_DIFSEL_DIFSEL_Msk /*!< ADC differential modes for channels 1 to 18 */ +#define ADC_DIFSEL_DIFSEL_0 (0x00001UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000001 */ +#define ADC_DIFSEL_DIFSEL_1 (0x00002UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000002 */ +#define ADC_DIFSEL_DIFSEL_2 (0x00004UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000004 */ +#define ADC_DIFSEL_DIFSEL_3 (0x00008UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000008 */ +#define ADC_DIFSEL_DIFSEL_4 (0x00010UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000010 */ +#define ADC_DIFSEL_DIFSEL_5 (0x00020UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000020 */ +#define ADC_DIFSEL_DIFSEL_6 (0x00040UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000040 */ +#define ADC_DIFSEL_DIFSEL_7 (0x00080UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000080 */ +#define ADC_DIFSEL_DIFSEL_8 (0x00100UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000100 */ +#define ADC_DIFSEL_DIFSEL_9 (0x00200UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000200 */ +#define ADC_DIFSEL_DIFSEL_10 (0x00400UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000400 */ +#define ADC_DIFSEL_DIFSEL_11 (0x00800UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000800 */ +#define ADC_DIFSEL_DIFSEL_12 (0x01000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00001000 */ +#define ADC_DIFSEL_DIFSEL_13 (0x02000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00002000 */ +#define ADC_DIFSEL_DIFSEL_14 (0x04000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00004000 */ +#define ADC_DIFSEL_DIFSEL_15 (0x08000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00008000 */ +#define ADC_DIFSEL_DIFSEL_16 (0x10000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00010000 */ +#define ADC_DIFSEL_DIFSEL_17 (0x20000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00020000 */ +#define ADC_DIFSEL_DIFSEL_18 (0x40000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00040000 */ +#define ADC_DIFSEL_DIFSEL_19 (0x80000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00080000 */ + +/******************** Bit definition for ADC_CALFACT register ********************/ +#define ADC_CALFACT_CALFACT_S_Pos (0U) +#define ADC_CALFACT_CALFACT_S_Msk (0x7FFUL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x000007FF */ +#define ADC_CALFACT_CALFACT_S ADC_CALFACT_CALFACT_S_Msk /*!< ADC calibration factors in single-ended mode */ +#define ADC_CALFACT_CALFACT_S_0 (0x001UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000001 */ +#define ADC_CALFACT_CALFACT_S_1 (0x002UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000002 */ +#define ADC_CALFACT_CALFACT_S_2 (0x004UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000004 */ +#define ADC_CALFACT_CALFACT_S_3 (0x008UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000008 */ +#define ADC_CALFACT_CALFACT_S_4 (0x010UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000010 */ +#define ADC_CALFACT_CALFACT_S_5 (0x020UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000020 */ +#define ADC_CALFACT_CALFACT_S_6 (0x040UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000040 */ +#define ADC_CALFACT_CALFACT_S_7 (0x080UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000080 */ +#define ADC_CALFACT_CALFACT_S_8 (0x100UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000100 */ +#define ADC_CALFACT_CALFACT_S_9 (0x200UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000200 */ +#define ADC_CALFACT_CALFACT_S_10 (0x400UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000400 */ +#define ADC_CALFACT_CALFACT_D_Pos (16U) +#define ADC_CALFACT_CALFACT_D_Msk (0x7FFUL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x07FF0000 */ +#define ADC_CALFACT_CALFACT_D ADC_CALFACT_CALFACT_D_Msk /*!< ADC calibration factors in differential mode */ +#define ADC_CALFACT_CALFACT_D_0 (0x001UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00010000 */ +#define ADC_CALFACT_CALFACT_D_1 (0x002UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00020000 */ +#define ADC_CALFACT_CALFACT_D_2 (0x004UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00040000 */ +#define ADC_CALFACT_CALFACT_D_3 (0x008UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00080000 */ +#define ADC_CALFACT_CALFACT_D_4 (0x010UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00100000 */ +#define ADC_CALFACT_CALFACT_D_5 (0x020UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00200000 */ +#define ADC_CALFACT_CALFACT_D_6 (0x040UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00400000 */ +#define ADC_CALFACT_CALFACT_D_7 (0x080UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00800000 */ +#define ADC_CALFACT_CALFACT_D_8 (0x100UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x01000000 */ +#define ADC_CALFACT_CALFACT_D_9 (0x200UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x02000000 */ +#define ADC_CALFACT_CALFACT_D_10 (0x400UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x04000000 */ + +/******************** Bit definition for ADC_CALFACT2 register ********************/ +#define ADC_CALFACT2_LINCALFACT_Pos (0U) +#define ADC_CALFACT2_LINCALFACT_Msk (0x3FFFFFFFUL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x3FFFFFFF */ +#define ADC_CALFACT2_LINCALFACT ADC_CALFACT2_LINCALFACT_Msk /*!< ADC Linearity calibration factors */ +#define ADC_CALFACT2_LINCALFACT_0 (0x00000001UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000001 */ +#define ADC_CALFACT2_LINCALFACT_1 (0x00000002UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000002 */ +#define ADC_CALFACT2_LINCALFACT_2 (0x00000004UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000004 */ +#define ADC_CALFACT2_LINCALFACT_3 (0x00000008UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000008 */ +#define ADC_CALFACT2_LINCALFACT_4 (0x00000010UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000010 */ +#define ADC_CALFACT2_LINCALFACT_5 (0x00000020UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000020 */ +#define ADC_CALFACT2_LINCALFACT_6 (0x00000040UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000040 */ +#define ADC_CALFACT2_LINCALFACT_7 (0x00000080UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000080 */ +#define ADC_CALFACT2_LINCALFACT_8 (0x00000100UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000100 */ +#define ADC_CALFACT2_LINCALFACT_9 (0x00000200UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000200 */ +#define ADC_CALFACT2_LINCALFACT_10 (0x00000400UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000400 */ +#define ADC_CALFACT2_LINCALFACT_11 (0x00000800UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000800 */ +#define ADC_CALFACT2_LINCALFACT_12 (0x00001000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00001000 */ +#define ADC_CALFACT2_LINCALFACT_13 (0x00002000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00002000 */ +#define ADC_CALFACT2_LINCALFACT_14 (0x00004000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00004000 */ +#define ADC_CALFACT2_LINCALFACT_15 (0x00008000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00008000 */ +#define ADC_CALFACT2_LINCALFACT_16 (0x00010000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00010000 */ +#define ADC_CALFACT2_LINCALFACT_17 (0x00020000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00020000 */ +#define ADC_CALFACT2_LINCALFACT_18 (0x00040000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00040000 */ +#define ADC_CALFACT2_LINCALFACT_19 (0x00080000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00080000 */ +#define ADC_CALFACT2_LINCALFACT_20 (0x00100000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00100000 */ +#define ADC_CALFACT2_LINCALFACT_21 (0x00200000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00200000 */ +#define ADC_CALFACT2_LINCALFACT_22 (0x00400000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00400000 */ +#define ADC_CALFACT2_LINCALFACT_23 (0x00800000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00800000 */ +#define ADC_CALFACT2_LINCALFACT_24 (0x01000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x01000000 */ +#define ADC_CALFACT2_LINCALFACT_25 (0x02000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x02000000 */ +#define ADC_CALFACT2_LINCALFACT_26 (0x04000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x04000000 */ +#define ADC_CALFACT2_LINCALFACT_27 (0x08000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x08000000 */ +#define ADC_CALFACT2_LINCALFACT_28 (0x10000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x10000000 */ +#define ADC_CALFACT2_LINCALFACT_29 (0x20000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x20000000 */ + +/************************* ADC Common registers *****************************/ +/******************** Bit definition for ADC_CSR register ********************/ +#define ADC_CSR_ADRDY_MST_Pos (0U) +#define ADC_CSR_ADRDY_MST_Msk (0x1UL << ADC_CSR_ADRDY_MST_Pos) /*!< 0x00000001 */ +#define ADC_CSR_ADRDY_MST ADC_CSR_ADRDY_MST_Msk /*!< Master ADC ready */ +#define ADC_CSR_EOSMP_MST_Pos (1U) +#define ADC_CSR_EOSMP_MST_Msk (0x1UL << ADC_CSR_EOSMP_MST_Pos) /*!< 0x00000002 */ +#define ADC_CSR_EOSMP_MST ADC_CSR_EOSMP_MST_Msk /*!< End of sampling phase flag of the master ADC */ +#define ADC_CSR_EOC_MST_Pos (2U) +#define ADC_CSR_EOC_MST_Msk (0x1UL << ADC_CSR_EOC_MST_Pos) /*!< 0x00000004 */ +#define ADC_CSR_EOC_MST ADC_CSR_EOC_MST_Msk /*!< End of regular conversion of the master ADC */ +#define ADC_CSR_EOS_MST_Pos (3U) +#define ADC_CSR_EOS_MST_Msk (0x1UL << ADC_CSR_EOS_MST_Pos) /*!< 0x00000008 */ +#define ADC_CSR_EOS_MST ADC_CSR_EOS_MST_Msk /*!< End of regular sequence flag of the master ADC */ +#define ADC_CSR_OVR_MST_Pos (4U) +#define ADC_CSR_OVR_MST_Msk (0x1UL << ADC_CSR_OVR_MST_Pos) /*!< 0x00000010 */ +#define ADC_CSR_OVR_MST ADC_CSR_OVR_MST_Msk /*!< Overrun flag of the master ADC */ +#define ADC_CSR_JEOC_MST_Pos (5U) +#define ADC_CSR_JEOC_MST_Msk (0x1UL << ADC_CSR_JEOC_MST_Pos) /*!< 0x00000020 */ +#define ADC_CSR_JEOC_MST ADC_CSR_JEOC_MST_Msk /*!< End of injected conversion of the master ADC */ +#define ADC_CSR_JEOS_MST_Pos (6U) +#define ADC_CSR_JEOS_MST_Msk (0x1UL << ADC_CSR_JEOS_MST_Pos) /*!< 0x00000040 */ +#define ADC_CSR_JEOS_MST ADC_CSR_JEOS_MST_Msk /*!< End of injected sequence flag of the master ADC */ +#define ADC_CSR_AWD1_MST_Pos (7U) +#define ADC_CSR_AWD1_MST_Msk (0x1UL << ADC_CSR_AWD1_MST_Pos) /*!< 0x00000080 */ +#define ADC_CSR_AWD1_MST ADC_CSR_AWD1_MST_Msk /*!< Analog watchdog 1 flag of the master ADC */ +#define ADC_CSR_AWD2_MST_Pos (8U) +#define ADC_CSR_AWD2_MST_Msk (0x1UL << ADC_CSR_AWD2_MST_Pos) /*!< 0x00000100 */ +#define ADC_CSR_AWD2_MST ADC_CSR_AWD2_MST_Msk /*!< Analog watchdog 2 flag of the master ADC */ +#define ADC_CSR_AWD3_MST_Pos (9U) +#define ADC_CSR_AWD3_MST_Msk (0x1UL << ADC_CSR_AWD3_MST_Pos) /*!< 0x00000200 */ +#define ADC_CSR_AWD3_MST ADC_CSR_AWD3_MST_Msk /*!< Analog watchdog 3 flag of the master ADC */ +#define ADC_CSR_JQOVF_MST_Pos (10U) +#define ADC_CSR_JQOVF_MST_Msk (0x1UL << ADC_CSR_JQOVF_MST_Pos) /*!< 0x00000400 */ +#define ADC_CSR_JQOVF_MST ADC_CSR_JQOVF_MST_Msk /*!< Injected context queue overflow flag of the master ADC */ +#define ADC_CSR_ADRDY_SLV_Pos (16U) +#define ADC_CSR_ADRDY_SLV_Msk (0x1UL << ADC_CSR_ADRDY_SLV_Pos) /*!< 0x00010000 */ +#define ADC_CSR_ADRDY_SLV ADC_CSR_ADRDY_SLV_Msk /*!< Slave ADC ready */ +#define ADC_CSR_EOSMP_SLV_Pos (17U) +#define ADC_CSR_EOSMP_SLV_Msk (0x1UL << ADC_CSR_EOSMP_SLV_Pos) /*!< 0x00020000 */ +#define ADC_CSR_EOSMP_SLV ADC_CSR_EOSMP_SLV_Msk /*!< End of sampling phase flag of the slave ADC */ +#define ADC_CSR_EOC_SLV_Pos (18U) +#define ADC_CSR_EOC_SLV_Msk (0x1UL << ADC_CSR_EOC_SLV_Pos) /*!< 0x00040000 */ +#define ADC_CSR_EOC_SLV ADC_CSR_EOC_SLV_Msk /*!< End of regular conversion of the slave ADC */ +#define ADC_CSR_EOS_SLV_Pos (19U) +#define ADC_CSR_EOS_SLV_Msk (0x1UL << ADC_CSR_EOS_SLV_Pos) /*!< 0x00080000 */ +#define ADC_CSR_EOS_SLV ADC_CSR_EOS_SLV_Msk /*!< End of regular sequence flag of the slave ADC */ +#define ADC_CSR_OVR_SLV_Pos (20U) +#define ADC_CSR_OVR_SLV_Msk (0x1UL << ADC_CSR_OVR_SLV_Pos) /*!< 0x00100000 */ +#define ADC_CSR_OVR_SLV ADC_CSR_OVR_SLV_Msk /*!< Overrun flag of the slave ADC */ +#define ADC_CSR_JEOC_SLV_Pos (21U) +#define ADC_CSR_JEOC_SLV_Msk (0x1UL << ADC_CSR_JEOC_SLV_Pos) /*!< 0x00200000 */ +#define ADC_CSR_JEOC_SLV ADC_CSR_JEOC_SLV_Msk /*!< End of injected conversion of the slave ADC */ +#define ADC_CSR_JEOS_SLV_Pos (22U) +#define ADC_CSR_JEOS_SLV_Msk (0x1UL << ADC_CSR_JEOS_SLV_Pos) /*!< 0x00400000 */ +#define ADC_CSR_JEOS_SLV ADC_CSR_JEOS_SLV_Msk /*!< End of injected sequence flag of the slave ADC */ +#define ADC_CSR_AWD1_SLV_Pos (23U) +#define ADC_CSR_AWD1_SLV_Msk (0x1UL << ADC_CSR_AWD1_SLV_Pos) /*!< 0x00800000 */ +#define ADC_CSR_AWD1_SLV ADC_CSR_AWD1_SLV_Msk /*!< Analog watchdog 1 flag of the slave ADC */ +#define ADC_CSR_AWD2_SLV_Pos (24U) +#define ADC_CSR_AWD2_SLV_Msk (0x1UL << ADC_CSR_AWD2_SLV_Pos) /*!< 0x01000000 */ +#define ADC_CSR_AWD2_SLV ADC_CSR_AWD2_SLV_Msk /*!< Analog watchdog 2 flag of the slave ADC */ +#define ADC_CSR_AWD3_SLV_Pos (25U) +#define ADC_CSR_AWD3_SLV_Msk (0x1UL << ADC_CSR_AWD3_SLV_Pos) /*!< 0x02000000 */ +#define ADC_CSR_AWD3_SLV ADC_CSR_AWD3_SLV_Msk /*!< Analog watchdog 3 flag of the slave ADC */ +#define ADC_CSR_JQOVF_SLV_Pos (26U) +#define ADC_CSR_JQOVF_SLV_Msk (0x1UL << ADC_CSR_JQOVF_SLV_Pos) /*!< 0x04000000 */ +#define ADC_CSR_JQOVF_SLV ADC_CSR_JQOVF_SLV_Msk /*!< Injected context queue overflow flag of the slave ADC */ + +/******************** Bit definition for ADC_CCR register ********************/ +#define ADC_CCR_DUAL_Pos (0U) +#define ADC_CCR_DUAL_Msk (0x1FUL << ADC_CCR_DUAL_Pos) /*!< 0x0000001F */ +#define ADC_CCR_DUAL ADC_CCR_DUAL_Msk /*!< Dual ADC mode selection */ +#define ADC_CCR_DUAL_0 (0x01UL << ADC_CCR_DUAL_Pos) /*!< 0x00000001 */ +#define ADC_CCR_DUAL_1 (0x02UL << ADC_CCR_DUAL_Pos) /*!< 0x00000002 */ +#define ADC_CCR_DUAL_2 (0x04UL << ADC_CCR_DUAL_Pos) /*!< 0x00000004 */ +#define ADC_CCR_DUAL_3 (0x08UL << ADC_CCR_DUAL_Pos) /*!< 0x00000008 */ +#define ADC_CCR_DUAL_4 (0x10UL << ADC_CCR_DUAL_Pos) /*!< 0x00000010 */ + +#define ADC_CCR_DELAY_Pos (8U) +#define ADC_CCR_DELAY_Msk (0xFUL << ADC_CCR_DELAY_Pos) /*!< 0x00000F00 */ +#define ADC_CCR_DELAY ADC_CCR_DELAY_Msk /*!< Delay between 2 sampling phases */ +#define ADC_CCR_DELAY_0 (0x1UL << ADC_CCR_DELAY_Pos) /*!< 0x00000100 */ +#define ADC_CCR_DELAY_1 (0x2UL << ADC_CCR_DELAY_Pos) /*!< 0x00000200 */ +#define ADC_CCR_DELAY_2 (0x4UL << ADC_CCR_DELAY_Pos) /*!< 0x00000400 */ +#define ADC_CCR_DELAY_3 (0x8UL << ADC_CCR_DELAY_Pos) /*!< 0x00000800 */ + + +#define ADC_CCR_DAMDF_Pos (14U) +#define ADC_CCR_DAMDF_Msk (0x3UL << ADC_CCR_DAMDF_Pos) /*!< 0x0000C000 */ +#define ADC_CCR_DAMDF ADC_CCR_DAMDF_Msk /*!< Dual ADC mode Data format */ +#define ADC_CCR_DAMDF_0 (0x1UL << ADC_CCR_DAMDF_Pos) /*!< 0x00004000 */ +#define ADC_CCR_DAMDF_1 (0x2UL << ADC_CCR_DAMDF_Pos) /*!< 0x00008000 */ + +#define ADC_CCR_CKMODE_Pos (16U) +#define ADC_CCR_CKMODE_Msk (0x3UL << ADC_CCR_CKMODE_Pos) /*!< 0x00030000 */ +#define ADC_CCR_CKMODE ADC_CCR_CKMODE_Msk /*!< ADC clock mode */ +#define ADC_CCR_CKMODE_0 (0x1UL << ADC_CCR_CKMODE_Pos) /*!< 0x00010000 */ +#define ADC_CCR_CKMODE_1 (0x2UL << ADC_CCR_CKMODE_Pos) /*!< 0x00020000 */ + +#define ADC_CCR_PRESC_Pos (18U) +#define ADC_CCR_PRESC_Msk (0xFUL << ADC_CCR_PRESC_Pos) /*!< 0x003C0000 */ +#define ADC_CCR_PRESC ADC_CCR_PRESC_Msk /*!< ADC prescaler */ +#define ADC_CCR_PRESC_0 (0x1UL << ADC_CCR_PRESC_Pos) /*!< 0x00040000 */ +#define ADC_CCR_PRESC_1 (0x2UL << ADC_CCR_PRESC_Pos) /*!< 0x00080000 */ +#define ADC_CCR_PRESC_2 (0x4UL << ADC_CCR_PRESC_Pos) /*!< 0x00100000 */ +#define ADC_CCR_PRESC_3 (0x8UL << ADC_CCR_PRESC_Pos) /*!< 0x00200000 */ + +#define ADC_CCR_VREFEN_Pos (22U) +#define ADC_CCR_VREFEN_Msk (0x1UL << ADC_CCR_VREFEN_Pos) /*!< 0x00400000 */ +#define ADC_CCR_VREFEN ADC_CCR_VREFEN_Msk /*!< VREFINT enable */ +#define ADC_CCR_TSEN_Pos (23U) +#define ADC_CCR_TSEN_Msk (0x1UL << ADC_CCR_TSEN_Pos) /*!< 0x00800000 */ +#define ADC_CCR_TSEN ADC_CCR_TSEN_Msk /*!< Temperature sensor enable */ +#define ADC_CCR_VBATEN_Pos (24U) +#define ADC_CCR_VBATEN_Msk (0x1UL << ADC_CCR_VBATEN_Pos) /*!< 0x01000000 */ +#define ADC_CCR_VBATEN ADC_CCR_VBATEN_Msk /*!< VBAT enable */ + +/******************** Bit definition for ADC_CDR register *******************/ +#define ADC_CDR_RDATA_MST_Pos (0U) +#define ADC_CDR_RDATA_MST_Msk (0xFFFFUL << ADC_CDR_RDATA_MST_Pos) /*!< 0x0000FFFF */ +#define ADC_CDR_RDATA_MST ADC_CDR_RDATA_MST_Msk /*!< ADC multimode master group regular conversion data */ + +#define ADC_CDR_RDATA_SLV_Pos (16U) +#define ADC_CDR_RDATA_SLV_Msk (0xFFFFUL << ADC_CDR_RDATA_SLV_Pos) /*!< 0xFFFF0000 */ +#define ADC_CDR_RDATA_SLV ADC_CDR_RDATA_SLV_Msk /*!< ADC multimode slave group regular conversion data */ + +/******************** Bit definition for ADC_CDR2 register ******************/ +#define ADC_CDR2_RDATA_ALT_Pos (0U) +#define ADC_CDR2_RDATA_ALT_Msk (0xFFFFFFFFUL << ADC_CDR2_RDATA_ALT_Pos) /*!< 0xFFFFFFFF */ +#define ADC_CDR2_RDATA_ALT ADC_CDR2_RDATA_ALT_Msk /*!< Regular data of the master/slave alternated ADCs */ + + +/******************************************************************************/ +/* */ +/* VREFBUF */ +/* */ +/******************************************************************************/ +/******************* Bit definition for VREFBUF_CSR register ****************/ +#define VREFBUF_CSR_ENVR_Pos (0U) +#define VREFBUF_CSR_ENVR_Msk (0x1UL << VREFBUF_CSR_ENVR_Pos) /*!< 0x00000001 */ +#define VREFBUF_CSR_ENVR VREFBUF_CSR_ENVR_Msk /*!*/ +#define DAC_CR_CEN1_Pos (14U) +#define DAC_CR_CEN1_Msk (0x1UL << DAC_CR_CEN1_Pos) /*!< 0x00004000 */ +#define DAC_CR_CEN1 DAC_CR_CEN1_Msk /*!*/ + +#define DAC_CR_EN2_Pos (16U) +#define DAC_CR_EN2_Msk (0x1UL << DAC_CR_EN2_Pos) /*!< 0x00010000 */ +#define DAC_CR_EN2 DAC_CR_EN2_Msk /*!*/ +#define DAC_CR_CEN2_Pos (30U) +#define DAC_CR_CEN2_Msk (0x1UL << DAC_CR_CEN2_Pos) /*!< 0x40000000 */ +#define DAC_CR_CEN2 DAC_CR_CEN2_Msk /*!*/ + +/***************** Bit definition for DAC_SWTRIGR register ******************/ +#define DAC_SWTRIGR_SWTRIG1_Pos (0U) +#define DAC_SWTRIGR_SWTRIG1_Msk (0x1UL << DAC_SWTRIGR_SWTRIG1_Pos) /*!< 0x00000001 */ +#define DAC_SWTRIGR_SWTRIG1 DAC_SWTRIGR_SWTRIG1_Msk /*!
    © Copyright (c) 2019 STMicroelectronics. + * All rights reserved.
    + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS_Device + * @{ + */ + +/** @addtogroup stm32h735xx + * @{ + */ + +#ifndef STM32H735xx_H +#define STM32H735xx_H + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + +/** @addtogroup Peripheral_interrupt_number_definition + * @{ + */ + +/** + * @brief STM32H7XX Interrupt Number Definition, according to the selected device + * in @ref Library_configuration_section + */ +typedef enum +{ +/****** Cortex-M Processor Exceptions Numbers *****************************************************************/ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ + HardFault_IRQn = -13, /*!< 4 Cortex-M Memory Management Interrupt */ + MemoryManagement_IRQn = -12, /*!< 4 Cortex-M Memory Management Interrupt */ + BusFault_IRQn = -11, /*!< 5 Cortex-M Bus Fault Interrupt */ + UsageFault_IRQn = -10, /*!< 6 Cortex-M Usage Fault Interrupt */ + SVCall_IRQn = -5, /*!< 11 Cortex-M SV Call Interrupt */ + DebugMonitor_IRQn = -4, /*!< 12 Cortex-M Debug Monitor Interrupt */ + PendSV_IRQn = -2, /*!< 14 Cortex-M Pend SV Interrupt */ + SysTick_IRQn = -1, /*!< 15 Cortex-M System Tick Interrupt */ +/****** STM32 specific Interrupt Numbers **********************************************************************/ + WWDG_IRQn = 0, /*!< Window WatchDog Interrupt ( wwdg1_it, wwdg2_it) */ + PVD_AVD_IRQn = 1, /*!< PVD/AVD through EXTI Line detection Interrupt */ + TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ + RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ + FLASH_IRQn = 4, /*!< FLASH global Interrupt */ + RCC_IRQn = 5, /*!< RCC global Interrupt */ + EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ + EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ + EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ + EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ + EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ + DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ + DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ + DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ + DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ + DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ + DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ + DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ + ADC_IRQn = 18, /*!< ADC1 and ADC2 global Interrupts */ + FDCAN1_IT0_IRQn = 19, /*!< FDCAN1 Interrupt line 0 */ + FDCAN2_IT0_IRQn = 20, /*!< FDCAN2 Interrupt line 0 */ + FDCAN1_IT1_IRQn = 21, /*!< FDCAN1 Interrupt line 1 */ + FDCAN2_IT1_IRQn = 22, /*!< FDCAN2 Interrupt line 1 */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ + TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ + TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ + TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ + TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ + TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ + TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ + DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ + FMC_IRQn = 48, /*!< FMC global Interrupt */ + SDMMC1_IRQn = 49, /*!< SDMMC1 global Interrupt */ + TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ + SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ + UART4_IRQn = 52, /*!< UART4 global Interrupt */ + UART5_IRQn = 53, /*!< UART5 global Interrupt */ + TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ + TIM7_IRQn = 55, /*!< TIM7 global interrupt */ + DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ + DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ + DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ + DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ + DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ + ETH_IRQn = 61, /*!< Ethernet global Interrupt */ + ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */ + FDCAN_CAL_IRQn = 63, /*!< FDCAN Calibration unit Interrupt */ + DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ + DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ + DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ + USART6_IRQn = 71, /*!< USART6 global interrupt */ + I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ + I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ + OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ + OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ + OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ + OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ + DCMI_PSSI_IRQn = 78, /*!< DCMI and PSSI global interrupt */ + CRYP_IRQn = 79, /*!< CRYP crypto global interrupt */ + HASH_RNG_IRQn = 80, /*!< HASH and RNG global interrupt */ + FPU_IRQn = 81, /*!< FPU global interrupt */ + UART7_IRQn = 82, /*!< UART7 global interrupt */ + UART8_IRQn = 83, /*!< UART8 global interrupt */ + SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ + SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ + SPI6_IRQn = 86, /*!< SPI6 global Interrupt */ + SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ + LTDC_IRQn = 88, /*!< LTDC global Interrupt */ + LTDC_ER_IRQn = 89, /*!< LTDC Error global Interrupt */ + DMA2D_IRQn = 90, /*!< DMA2D global Interrupt */ + OCTOSPI1_IRQn = 92, /*!< OCTOSPI1 global interrupt */ + LPTIM1_IRQn = 93, /*!< LP TIM1 interrupt */ + CEC_IRQn = 94, /*!< HDMI-CEC global Interrupt */ + I2C4_EV_IRQn = 95, /*!< I2C4 Event Interrupt */ + I2C4_ER_IRQn = 96, /*!< I2C4 Error Interrupt */ + SPDIF_RX_IRQn = 97, /*!< SPDIF-RX global Interrupt */ + DMAMUX1_OVR_IRQn = 102, /*! + +/** @addtogroup Peripheral_registers_structures + * @{ + */ + +/** + * @brief Analog to Digital Converter + */ + +typedef struct +{ + __IO uint32_t ISR; /*!< ADC Interrupt and Status Register, Address offset: 0x00 */ + __IO uint32_t IER; /*!< ADC Interrupt Enable Register, Address offset: 0x04 */ + __IO uint32_t CR; /*!< ADC control register, Address offset: 0x08 */ + __IO uint32_t CFGR; /*!< ADC Configuration register, Address offset: 0x0C */ + __IO uint32_t CFGR2; /*!< ADC Configuration register 2, Address offset: 0x10 */ + __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x14 */ + __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x18 */ + __IO uint32_t PCSEL_RES0; /*!< Rserved for ADC3, ADC1/2 pre-channel selection, Address offset: 0x1C */ + __IO uint32_t LTR1_TR1; /*!< ADC watchdog Lower threshold register 1, Address offset: 0x20 */ + __IO uint32_t HTR1_TR2; /*!< ADC watchdog higher threshold register 1, Address offset: 0x24 */ + __IO uint32_t RES1_TR3; /*!< Rserved for ADC1/2, ADC3 threshold register, Address offset: 0x28 */ + uint32_t RESERVED2; /*!< Reserved, 0x02C */ + __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x30 */ + __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x34 */ + __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x38 */ + __IO uint32_t SQR4; /*!< ADC regular sequence register 4, Address offset: 0x3C */ + __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x40 */ + uint32_t RESERVED3; /*!< Reserved, 0x044 */ + uint32_t RESERVED4; /*!< Reserved, 0x048 */ + __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x4C */ + uint32_t RESERVED5[4]; /*!< Reserved, 0x050 - 0x05C */ + __IO uint32_t OFR1; /*!< ADC offset register 1, Address offset: 0x60 */ + __IO uint32_t OFR2; /*!< ADC offset register 2, Address offset: 0x64 */ + __IO uint32_t OFR3; /*!< ADC offset register 3, Address offset: 0x68 */ + __IO uint32_t OFR4; /*!< ADC offset register 4, Address offset: 0x6C */ + uint32_t RESERVED6[4]; /*!< Reserved, 0x070 - 0x07C */ + __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x80 */ + __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x84 */ + __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x88 */ + __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x8C */ + uint32_t RESERVED7[4]; /*!< Reserved, 0x090 - 0x09C */ + __IO uint32_t AWD2CR; /*!< ADC Analog Watchdog 2 Configuration Register, Address offset: 0xA0 */ + __IO uint32_t AWD3CR; /*!< ADC Analog Watchdog 3 Configuration Register, Address offset: 0xA4 */ + uint32_t RESERVED8; /*!< Reserved, 0x0A8 */ + uint32_t RESERVED9; /*!< Reserved, 0x0AC */ + __IO uint32_t LTR2_DIFSEL; /*!< ADC watchdog Lower threshold register 2, Difsel for ADC3, Address offset: 0xB0 */ + __IO uint32_t HTR2_CALFACT; /*!< ADC watchdog Higher threshold register 2, Calfact for ADC3, Address offset: 0xB4 */ + __IO uint32_t LTR3_RES10; /*!< ADC watchdog Lower threshold register 3, specific ADC1/2, Address offset: 0xB8 */ + __IO uint32_t HTR3_RES11; /*!< ADC watchdog Higher threshold register 3, specific ADC1/2, Address offset: 0xBC */ + __IO uint32_t DIFSEL_RES12; /*!< ADC Differential Mode Selection Register specific ADC1/2, Address offset: 0xC0 */ + __IO uint32_t CALFACT_RES13; /*!< ADC Calibration Factors specific ADC1/2, Address offset: 0xC4 */ + __IO uint32_t CALFACT2_RES14; /*!< ADC Linearity Calibration Factors specific ADC1/2, Address offset: 0xC8 */ +} ADC_TypeDef; + + +typedef struct +{ +__IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1/3 base address + 0x300 */ +uint32_t RESERVED; /*!< Reserved, ADC1/3 base address + 0x304 */ +__IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1/3 base address + 0x308 */ +__IO uint32_t CDR; /*!< ADC common regular data register for dual Address offset: ADC1/3 base address + 0x30C */ +__IO uint32_t CDR2; /*!< ADC common regular data register for 32-bit dual mode Address offset: ADC1/3 base address + 0x310 */ + +} ADC_Common_TypeDef; + + +/** + * @brief VREFBUF + */ + +typedef struct +{ + __IO uint32_t CSR; /*!< VREFBUF control and status register, Address offset: 0x00 */ + __IO uint32_t CCR; /*!< VREFBUF calibration and control register, Address offset: 0x04 */ +} VREFBUF_TypeDef; + + +/** + * @brief FD Controller Area Network + */ + +typedef struct +{ + __IO uint32_t CREL; /*!< FDCAN Core Release register, Address offset: 0x000 */ + __IO uint32_t ENDN; /*!< FDCAN Endian register, Address offset: 0x004 */ + __IO uint32_t RESERVED1; /*!< Reserved, 0x008 */ + __IO uint32_t DBTP; /*!< FDCAN Data Bit Timing & Prescaler register, Address offset: 0x00C */ + __IO uint32_t TEST; /*!< FDCAN Test register, Address offset: 0x010 */ + __IO uint32_t RWD; /*!< FDCAN RAM Watchdog register, Address offset: 0x014 */ + __IO uint32_t CCCR; /*!< FDCAN CC Control register, Address offset: 0x018 */ + __IO uint32_t NBTP; /*!< FDCAN Nominal Bit Timing & Prescaler register, Address offset: 0x01C */ + __IO uint32_t TSCC; /*!< FDCAN Timestamp Counter Configuration register, Address offset: 0x020 */ + __IO uint32_t TSCV; /*!< FDCAN Timestamp Counter Value register, Address offset: 0x024 */ + __IO uint32_t TOCC; /*!< FDCAN Timeout Counter Configuration register, Address offset: 0x028 */ + __IO uint32_t TOCV; /*!< FDCAN Timeout Counter Value register, Address offset: 0x02C */ + __IO uint32_t RESERVED2[4]; /*!< Reserved, 0x030 - 0x03C */ + __IO uint32_t ECR; /*!< FDCAN Error Counter register, Address offset: 0x040 */ + __IO uint32_t PSR; /*!< FDCAN Protocol Status register, Address offset: 0x044 */ + __IO uint32_t TDCR; /*!< FDCAN Transmitter Delay Compensation register, Address offset: 0x048 */ + __IO uint32_t RESERVED3; /*!< Reserved, 0x04C */ + __IO uint32_t IR; /*!< FDCAN Interrupt register, Address offset: 0x050 */ + __IO uint32_t IE; /*!< FDCAN Interrupt Enable register, Address offset: 0x054 */ + __IO uint32_t ILS; /*!< FDCAN Interrupt Line Select register, Address offset: 0x058 */ + __IO uint32_t ILE; /*!< FDCAN Interrupt Line Enable register, Address offset: 0x05C */ + __IO uint32_t RESERVED4[8]; /*!< Reserved, 0x060 - 0x07C */ + __IO uint32_t GFC; /*!< FDCAN Global Filter Configuration register, Address offset: 0x080 */ + __IO uint32_t SIDFC; /*!< FDCAN Standard ID Filter Configuration register, Address offset: 0x084 */ + __IO uint32_t XIDFC; /*!< FDCAN Extended ID Filter Configuration register, Address offset: 0x088 */ + __IO uint32_t RESERVED5; /*!< Reserved, 0x08C */ + __IO uint32_t XIDAM; /*!< FDCAN Extended ID AND Mask register, Address offset: 0x090 */ + __IO uint32_t HPMS; /*!< FDCAN High Priority Message Status register, Address offset: 0x094 */ + __IO uint32_t NDAT1; /*!< FDCAN New Data 1 register, Address offset: 0x098 */ + __IO uint32_t NDAT2; /*!< FDCAN New Data 2 register, Address offset: 0x09C */ + __IO uint32_t RXF0C; /*!< FDCAN Rx FIFO 0 Configuration register, Address offset: 0x0A0 */ + __IO uint32_t RXF0S; /*!< FDCAN Rx FIFO 0 Status register, Address offset: 0x0A4 */ + __IO uint32_t RXF0A; /*!< FDCAN Rx FIFO 0 Acknowledge register, Address offset: 0x0A8 */ + __IO uint32_t RXBC; /*!< FDCAN Rx Buffer Configuration register, Address offset: 0x0AC */ + __IO uint32_t RXF1C; /*!< FDCAN Rx FIFO 1 Configuration register, Address offset: 0x0B0 */ + __IO uint32_t RXF1S; /*!< FDCAN Rx FIFO 1 Status register, Address offset: 0x0B4 */ + __IO uint32_t RXF1A; /*!< FDCAN Rx FIFO 1 Acknowledge register, Address offset: 0x0B8 */ + __IO uint32_t RXESC; /*!< FDCAN Rx Buffer/FIFO Element Size Configuration register, Address offset: 0x0BC */ + __IO uint32_t TXBC; /*!< FDCAN Tx Buffer Configuration register, Address offset: 0x0C0 */ + __IO uint32_t TXFQS; /*!< FDCAN Tx FIFO/Queue Status register, Address offset: 0x0C4 */ + __IO uint32_t TXESC; /*!< FDCAN Tx Buffer Element Size Configuration register, Address offset: 0x0C8 */ + __IO uint32_t TXBRP; /*!< FDCAN Tx Buffer Request Pending register, Address offset: 0x0CC */ + __IO uint32_t TXBAR; /*!< FDCAN Tx Buffer Add Request register, Address offset: 0x0D0 */ + __IO uint32_t TXBCR; /*!< FDCAN Tx Buffer Cancellation Request register, Address offset: 0x0D4 */ + __IO uint32_t TXBTO; /*!< FDCAN Tx Buffer Transmission Occurred register, Address offset: 0x0D8 */ + __IO uint32_t TXBCF; /*!< FDCAN Tx Buffer Cancellation Finished register, Address offset: 0x0DC */ + __IO uint32_t TXBTIE; /*!< FDCAN Tx Buffer Transmission Interrupt Enable register, Address offset: 0x0E0 */ + __IO uint32_t TXBCIE; /*!< FDCAN Tx Buffer Cancellation Finished Interrupt Enable register, Address offset: 0x0E4 */ + __IO uint32_t RESERVED6[2]; /*!< Reserved, 0x0E8 - 0x0EC */ + __IO uint32_t TXEFC; /*!< FDCAN Tx Event FIFO Configuration register, Address offset: 0x0F0 */ + __IO uint32_t TXEFS; /*!< FDCAN Tx Event FIFO Status register, Address offset: 0x0F4 */ + __IO uint32_t TXEFA; /*!< FDCAN Tx Event FIFO Acknowledge register, Address offset: 0x0F8 */ + __IO uint32_t RESERVED7; /*!< Reserved, 0x0FC */ +} FDCAN_GlobalTypeDef; + +/** + * @brief TTFD Controller Area Network + */ + +typedef struct +{ + __IO uint32_t TTTMC; /*!< TT Trigger Memory Configuration register, Address offset: 0x100 */ + __IO uint32_t TTRMC; /*!< TT Reference Message Configuration register, Address offset: 0x104 */ + __IO uint32_t TTOCF; /*!< TT Operation Configuration register, Address offset: 0x108 */ + __IO uint32_t TTMLM; /*!< TT Matrix Limits register, Address offset: 0x10C */ + __IO uint32_t TURCF; /*!< TUR Configuration register, Address offset: 0x110 */ + __IO uint32_t TTOCN; /*!< TT Operation Control register, Address offset: 0x114 */ + __IO uint32_t TTGTP; /*!< TT Global Time Preset register, Address offset: 0x118 */ + __IO uint32_t TTTMK; /*!< TT Time Mark register, Address offset: 0x11C */ + __IO uint32_t TTIR; /*!< TT Interrupt register, Address offset: 0x120 */ + __IO uint32_t TTIE; /*!< TT Interrupt Enable register, Address offset: 0x124 */ + __IO uint32_t TTILS; /*!< TT Interrupt Line Select register, Address offset: 0x128 */ + __IO uint32_t TTOST; /*!< TT Operation Status register, Address offset: 0x12C */ + __IO uint32_t TURNA; /*!< TT TUR Numerator Actual register, Address offset: 0x130 */ + __IO uint32_t TTLGT; /*!< TT Local and Global Time register, Address offset: 0x134 */ + __IO uint32_t TTCTC; /*!< TT Cycle Time and Count register, Address offset: 0x138 */ + __IO uint32_t TTCPT; /*!< TT Capture Time register, Address offset: 0x13C */ + __IO uint32_t TTCSM; /*!< TT Cycle Sync Mark register, Address offset: 0x140 */ + __IO uint32_t RESERVED1[111]; /*!< Reserved, 0x144 - 0x2FC */ + __IO uint32_t TTTS; /*!< TT Trigger Select register, Address offset: 0x300 */ +} TTCAN_TypeDef; + +/** + * @brief FD Controller Area Network + */ + +typedef struct +{ + __IO uint32_t CREL; /*!< Clock Calibration Unit Core Release register, Address offset: 0x00 */ + __IO uint32_t CCFG; /*!< Calibration Configuration register, Address offset: 0x04 */ + __IO uint32_t CSTAT; /*!< Calibration Status register, Address offset: 0x08 */ + __IO uint32_t CWD; /*!< Calibration Watchdog register, Address offset: 0x0C */ + __IO uint32_t IR; /*!< CCU Interrupt register, Address offset: 0x10 */ + __IO uint32_t IE; /*!< CCU Interrupt Enable register, Address offset: 0x14 */ +} FDCAN_ClockCalibrationUnit_TypeDef; + + +/** + * @brief Consumer Electronics Control + */ + +typedef struct +{ + __IO uint32_t CR; /*!< CEC control register, Address offset:0x00 */ + __IO uint32_t CFGR; /*!< CEC configuration register, Address offset:0x04 */ + __IO uint32_t TXDR; /*!< CEC Tx data register , Address offset:0x08 */ + __IO uint32_t RXDR; /*!< CEC Rx Data Register, Address offset:0x0C */ + __IO uint32_t ISR; /*!< CEC Interrupt and Status Register, Address offset:0x10 */ + __IO uint32_t IER; /*!< CEC interrupt enable register, Address offset:0x14 */ +}CEC_TypeDef; + +/** + * @brief COordincate Rotation DIgital Computer + */ +typedef struct +{ + __IO uint32_t CSR; /*!< CORDIC control and status register, Address offset: 0x00 */ + __IO uint32_t WDATA; /*!< CORDIC argument register, Address offset: 0x04 */ + __IO uint32_t RDATA; /*!< CORDIC result register, Address offset: 0x08 */ +} CORDIC_TypeDef; + +/** + * @brief CRC calculation unit + */ + +typedef struct +{ + __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ + __IO uint32_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ + __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ + uint32_t RESERVED2; /*!< Reserved, 0x0C */ + __IO uint32_t INIT; /*!< Initial CRC value register, Address offset: 0x10 */ + __IO uint32_t POL; /*!< CRC polynomial register, Address offset: 0x14 */ +} CRC_TypeDef; + + +/** + * @brief Clock Recovery System + */ +typedef struct +{ +__IO uint32_t CR; /*!< CRS ccontrol register, Address offset: 0x00 */ +__IO uint32_t CFGR; /*!< CRS configuration register, Address offset: 0x04 */ +__IO uint32_t ISR; /*!< CRS interrupt and status register, Address offset: 0x08 */ +__IO uint32_t ICR; /*!< CRS interrupt flag clear register, Address offset: 0x0C */ +} CRS_TypeDef; + + +/** + * @brief Digital to Analog Converter + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ + __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ + __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ + __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ + __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ + __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ + __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ + __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ + __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ + __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ + __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ + __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ + __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ + __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ + __IO uint32_t CCR; /*!< DAC calibration control register, Address offset: 0x38 */ + __IO uint32_t MCR; /*!< DAC mode control register, Address offset: 0x3C */ + __IO uint32_t SHSR1; /*!< DAC Sample and Hold sample time register 1, Address offset: 0x40 */ + __IO uint32_t SHSR2; /*!< DAC Sample and Hold sample time register 2, Address offset: 0x44 */ + __IO uint32_t SHHR; /*!< DAC Sample and Hold hold time register, Address offset: 0x48 */ + __IO uint32_t SHRR; /*!< DAC Sample and Hold refresh time register, Address offset: 0x4C */ +} DAC_TypeDef; + +/** + * @brief DFSDM module registers + */ +typedef struct +{ + __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ + __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ + __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ + __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ + __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ + __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ + __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ + __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ + __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ + __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ + __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ + __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ + __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ + __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ + __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ +} DFSDM_Filter_TypeDef; + +/** + * @brief DFSDM channel configuration registers + */ +typedef struct +{ + __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ + __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ + __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and + short circuit detector register, Address offset: 0x08 */ + __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ + __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ +} DFSDM_Channel_TypeDef; + +/** + * @brief Debug MCU + */ +typedef struct +{ + __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ + __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ + uint32_t RESERVED4[11]; /*!< Reserved, Address offset: 0x08 */ + __IO uint32_t APB3FZ1; /*!< Debug MCU APB3FZ1 freeze register, Address offset: 0x34 */ + uint32_t RESERVED5; /*!< Reserved, Address offset: 0x38 */ + __IO uint32_t APB1LFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x3C */ + uint32_t RESERVED6; /*!< Reserved, Address offset: 0x40 */ + __IO uint32_t APB1HFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x44 */ + uint32_t RESERVED7; /*!< Reserved, Address offset: 0x48 */ + __IO uint32_t APB2FZ1; /*!< Debug MCU APB2FZ1 freeze register, Address offset: 0x4C */ + uint32_t RESERVED8; /*!< Reserved, Address offset: 0x50 */ + __IO uint32_t APB4FZ1; /*!< Debug MCU APB4FZ1 freeze register, Address offset: 0x54 */ + __IO uint32_t RESERVED9[990]; /*!< Reserved, Address offset: 0x58-0xFCC */ + __IO uint32_t PIDR4; /*!< Debug MCU peripheral identity register 4, Address offset: 0xFD0 */ + __IO uint32_t RESERVED10[3];/*!< Reserved, Address offset: 0xFD4-0xFDC */ + __IO uint32_t PIDR0; /*!< Debug MCU peripheral identity register 0, Address offset: 0xFE0 */ + __IO uint32_t PIDR1; /*!< Debug MCU peripheral identity register 1, Address offset: 0xFE4 */ + __IO uint32_t PIDR2; /*!< Debug MCU peripheral identity register 2, Address offset: 0xFE8 */ + __IO uint32_t PIDR3; /*!< Debug MCU peripheral identity register 3, Address offset: 0xFEC */ + __IO uint32_t CIDR0; /*!< Debug MCU component identity register 0, Address offset: 0xFF0 */ + __IO uint32_t CIDR1; /*!< Debug MCU component identity register 1, Address offset: 0xFF4 */ + __IO uint32_t CIDR2; /*!< Debug MCU component identity register 2, Address offset: 0xFF8 */ + __IO uint32_t CIDR3; /*!< Debug MCU component identity register 3, Address offset: 0xFFC */ +}DBGMCU_TypeDef; +/** + * @brief DCMI + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */ + __IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */ + __IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */ + __IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */ + __IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */ + __IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */ + __IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */ + __IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */ + __IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */ + __IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */ + __IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */ +} DCMI_TypeDef; + +/** + * @brief PSSI + */ + +typedef struct +{ + __IO uint32_t CR; /*!< PSSI control register 1, Address offset: 0x000 */ + __IO uint32_t SR; /*!< PSSI status register, Address offset: 0x004 */ + __IO uint32_t RIS; /*!< PSSI raw interrupt status register, Address offset: 0x008 */ + __IO uint32_t IER; /*!< PSSI interrupt enable register, Address offset: 0x00C */ + __IO uint32_t MIS; /*!< PSSI masked interrupt status register, Address offset: 0x010 */ + __IO uint32_t ICR; /*!< PSSI interrupt clear register, Address offset: 0x014 */ + __IO uint32_t RESERVED1[4]; /*!< Reserved, 0x018 - 0x024 */ + __IO uint32_t DR; /*!< PSSI data register, Address offset: 0x028 */ + __IO uint32_t RESERVED2[241]; /*!< Reserved, 0x02C - 0x3EC */ + __IO uint32_t HWCFGR; /*!< PSSI IP HW configuration register, Address offset: 0x3F0 */ + __IO uint32_t VERR; /*!< PSSI IP version register, Address offset: 0x3F4 */ + __IO uint32_t IPIDR; /*!< PSSI IP ID register, Address offset: 0x3F8 */ + __IO uint32_t SIDR; /*!< PSSI SIZE ID register, Address offset: 0x3FC */ +} PSSI_TypeDef; + +/** + * @brief DMA Controller + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DMA stream x configuration register */ + __IO uint32_t NDTR; /*!< DMA stream x number of data register */ + __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ + __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ + __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ + __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ +} DMA_Stream_TypeDef; + +typedef struct +{ + __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ + __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ + __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ + __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ +} DMA_TypeDef; + +typedef struct +{ + __IO uint32_t CCR; /*!< DMA channel x configuration register */ + __IO uint32_t CNDTR; /*!< DMA channel x number of data register */ + __IO uint32_t CPAR; /*!< DMA channel x peripheral address register */ + __IO uint32_t CM0AR; /*!< DMA channel x memory 0 address register */ + __IO uint32_t CM1AR; /*!< DMA channel x memory 1 address register */ +} BDMA_Channel_TypeDef; + +typedef struct +{ + __IO uint32_t ISR; /*!< DMA interrupt status register, Address offset: 0x00 */ + __IO uint32_t IFCR; /*!< DMA interrupt flag clear register, Address offset: 0x04 */ +} BDMA_TypeDef; + +typedef struct +{ + __IO uint32_t CCR; /*!< DMA Multiplexer Channel x Control Register */ +}DMAMUX_Channel_TypeDef; + +typedef struct +{ + __IO uint32_t CSR; /*!< DMA Channel Status Register */ + __IO uint32_t CFR; /*!< DMA Channel Clear Flag Register */ +}DMAMUX_ChannelStatus_TypeDef; + +typedef struct +{ + __IO uint32_t RGCR; /*!< DMA Request Generator x Control Register */ +}DMAMUX_RequestGen_TypeDef; + +typedef struct +{ + __IO uint32_t RGSR; /*!< DMA Request Generator Status Register */ + __IO uint32_t RGCFR; /*!< DMA Request Generator Clear Flag Register */ +}DMAMUX_RequestGenStatus_TypeDef; + +/** + * @brief MDMA Controller + */ +typedef struct +{ + __IO uint32_t GISR0; /*!< MDMA Global Interrupt/Status Register 0, Address offset: 0x00 */ +}MDMA_TypeDef; + +typedef struct +{ + __IO uint32_t CISR; /*!< MDMA channel x interrupt/status register, Address offset: 0x40 */ + __IO uint32_t CIFCR; /*!< MDMA channel x interrupt flag clear register, Address offset: 0x44 */ + __IO uint32_t CESR; /*!< MDMA Channel x error status register, Address offset: 0x48 */ + __IO uint32_t CCR; /*!< MDMA channel x control register, Address offset: 0x4C */ + __IO uint32_t CTCR; /*!< MDMA channel x Transfer Configuration register, Address offset: 0x50 */ + __IO uint32_t CBNDTR; /*!< MDMA Channel x block number of data register, Address offset: 0x54 */ + __IO uint32_t CSAR; /*!< MDMA channel x source address register, Address offset: 0x58 */ + __IO uint32_t CDAR; /*!< MDMA channel x destination address register, Address offset: 0x5C */ + __IO uint32_t CBRUR; /*!< MDMA channel x Block Repeat address Update register, Address offset: 0x60 */ + __IO uint32_t CLAR; /*!< MDMA channel x Link Address register, Address offset: 0x64 */ + __IO uint32_t CTBR; /*!< MDMA channel x Trigger and Bus selection Register, Address offset: 0x68 */ + uint32_t RESERVED0; /*!< Reserved, 0x6C */ + __IO uint32_t CMAR; /*!< MDMA channel x Mask address register, Address offset: 0x70 */ + __IO uint32_t CMDR; /*!< MDMA channel x Mask Data register, Address offset: 0x74 */ +}MDMA_Channel_TypeDef; + +/** + * @brief DMA2D Controller + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DMA2D Control Register, Address offset: 0x00 */ + __IO uint32_t ISR; /*!< DMA2D Interrupt Status Register, Address offset: 0x04 */ + __IO uint32_t IFCR; /*!< DMA2D Interrupt Flag Clear Register, Address offset: 0x08 */ + __IO uint32_t FGMAR; /*!< DMA2D Foreground Memory Address Register, Address offset: 0x0C */ + __IO uint32_t FGOR; /*!< DMA2D Foreground Offset Register, Address offset: 0x10 */ + __IO uint32_t BGMAR; /*!< DMA2D Background Memory Address Register, Address offset: 0x14 */ + __IO uint32_t BGOR; /*!< DMA2D Background Offset Register, Address offset: 0x18 */ + __IO uint32_t FGPFCCR; /*!< DMA2D Foreground PFC Control Register, Address offset: 0x1C */ + __IO uint32_t FGCOLR; /*!< DMA2D Foreground Color Register, Address offset: 0x20 */ + __IO uint32_t BGPFCCR; /*!< DMA2D Background PFC Control Register, Address offset: 0x24 */ + __IO uint32_t BGCOLR; /*!< DMA2D Background Color Register, Address offset: 0x28 */ + __IO uint32_t FGCMAR; /*!< DMA2D Foreground CLUT Memory Address Register, Address offset: 0x2C */ + __IO uint32_t BGCMAR; /*!< DMA2D Background CLUT Memory Address Register, Address offset: 0x30 */ + __IO uint32_t OPFCCR; /*!< DMA2D Output PFC Control Register, Address offset: 0x34 */ + __IO uint32_t OCOLR; /*!< DMA2D Output Color Register, Address offset: 0x38 */ + __IO uint32_t OMAR; /*!< DMA2D Output Memory Address Register, Address offset: 0x3C */ + __IO uint32_t OOR; /*!< DMA2D Output Offset Register, Address offset: 0x40 */ + __IO uint32_t NLR; /*!< DMA2D Number of Line Register, Address offset: 0x44 */ + __IO uint32_t LWR; /*!< DMA2D Line Watermark Register, Address offset: 0x48 */ + __IO uint32_t AMTCR; /*!< DMA2D AHB Master Timer Configuration Register, Address offset: 0x4C */ + uint32_t RESERVED[236]; /*!< Reserved, 0x50-0x3FF */ + __IO uint32_t FGCLUT[256]; /*!< DMA2D Foreground CLUT, Address offset:400-7FF */ + __IO uint32_t BGCLUT[256]; /*!< DMA2D Background CLUT, Address offset:800-BFF */ +} DMA2D_TypeDef; + + +/** + * @brief Ethernet MAC + */ +typedef struct +{ + __IO uint32_t MACCR; + __IO uint32_t MACECR; + __IO uint32_t MACPFR; + __IO uint32_t MACWTR; + __IO uint32_t MACHT0R; + __IO uint32_t MACHT1R; + uint32_t RESERVED1[14]; + __IO uint32_t MACVTR; + uint32_t RESERVED2; + __IO uint32_t MACVHTR; + uint32_t RESERVED3; + __IO uint32_t MACVIR; + __IO uint32_t MACIVIR; + uint32_t RESERVED4[2]; + __IO uint32_t MACTFCR; + uint32_t RESERVED5[7]; + __IO uint32_t MACRFCR; + uint32_t RESERVED6[7]; + __IO uint32_t MACISR; + __IO uint32_t MACIER; + __IO uint32_t MACRXTXSR; + uint32_t RESERVED7; + __IO uint32_t MACPCSR; + __IO uint32_t MACRWKPFR; + uint32_t RESERVED8[2]; + __IO uint32_t MACLCSR; + __IO uint32_t MACLTCR; + __IO uint32_t MACLETR; + __IO uint32_t MAC1USTCR; + uint32_t RESERVED9[12]; + __IO uint32_t MACVR; + __IO uint32_t MACDR; + uint32_t RESERVED10; + __IO uint32_t MACHWF0R; + __IO uint32_t MACHWF1R; + __IO uint32_t MACHWF2R; + uint32_t RESERVED11[54]; + __IO uint32_t MACMDIOAR; + __IO uint32_t MACMDIODR; + uint32_t RESERVED12[2]; + __IO uint32_t MACARPAR; + uint32_t RESERVED13[59]; + __IO uint32_t MACA0HR; + __IO uint32_t MACA0LR; + __IO uint32_t MACA1HR; + __IO uint32_t MACA1LR; + __IO uint32_t MACA2HR; + __IO uint32_t MACA2LR; + __IO uint32_t MACA3HR; + __IO uint32_t MACA3LR; + uint32_t RESERVED14[248]; + __IO uint32_t MMCCR; + __IO uint32_t MMCRIR; + __IO uint32_t MMCTIR; + __IO uint32_t MMCRIMR; + __IO uint32_t MMCTIMR; + uint32_t RESERVED15[14]; + __IO uint32_t MMCTSCGPR; + __IO uint32_t MMCTMCGPR; + uint32_t RESERVED16[5]; + __IO uint32_t MMCTPCGR; + uint32_t RESERVED17[10]; + __IO uint32_t MMCRCRCEPR; + __IO uint32_t MMCRAEPR; + uint32_t RESERVED18[10]; + __IO uint32_t MMCRUPGR; + uint32_t RESERVED19[9]; + __IO uint32_t MMCTLPIMSTR; + __IO uint32_t MMCTLPITCR; + __IO uint32_t MMCRLPIMSTR; + __IO uint32_t MMCRLPITCR; + uint32_t RESERVED20[65]; + __IO uint32_t MACL3L4C0R; + __IO uint32_t MACL4A0R; + uint32_t RESERVED21[2]; + __IO uint32_t MACL3A0R0R; + __IO uint32_t MACL3A1R0R; + __IO uint32_t MACL3A2R0R; + __IO uint32_t MACL3A3R0R; + uint32_t RESERVED22[4]; + __IO uint32_t MACL3L4C1R; + __IO uint32_t MACL4A1R; + uint32_t RESERVED23[2]; + __IO uint32_t MACL3A0R1R; + __IO uint32_t MACL3A1R1R; + __IO uint32_t MACL3A2R1R; + __IO uint32_t MACL3A3R1R; + uint32_t RESERVED24[108]; + __IO uint32_t MACTSCR; + __IO uint32_t MACSSIR; + __IO uint32_t MACSTSR; + __IO uint32_t MACSTNR; + __IO uint32_t MACSTSUR; + __IO uint32_t MACSTNUR; + __IO uint32_t MACTSAR; + uint32_t RESERVED25; + __IO uint32_t MACTSSR; + uint32_t RESERVED26[3]; + __IO uint32_t MACTTSSNR; + __IO uint32_t MACTTSSSR; + uint32_t RESERVED27[2]; + __IO uint32_t MACACR; + uint32_t RESERVED28; + __IO uint32_t MACATSNR; + __IO uint32_t MACATSSR; + __IO uint32_t MACTSIACR; + __IO uint32_t MACTSEACR; + __IO uint32_t MACTSICNR; + __IO uint32_t MACTSECNR; + uint32_t RESERVED29[4]; + __IO uint32_t MACPPSCR; + uint32_t RESERVED30[3]; + __IO uint32_t MACPPSTTSR; + __IO uint32_t MACPPSTTNR; + __IO uint32_t MACPPSIR; + __IO uint32_t MACPPSWR; + uint32_t RESERVED31[12]; + __IO uint32_t MACPOCR; + __IO uint32_t MACSPI0R; + __IO uint32_t MACSPI1R; + __IO uint32_t MACSPI2R; + __IO uint32_t MACLMIR; + uint32_t RESERVED32[11]; + __IO uint32_t MTLOMR; + uint32_t RESERVED33[7]; + __IO uint32_t MTLISR; + uint32_t RESERVED34[55]; + __IO uint32_t MTLTQOMR; + __IO uint32_t MTLTQUR; + __IO uint32_t MTLTQDR; + uint32_t RESERVED35[8]; + __IO uint32_t MTLQICSR; + __IO uint32_t MTLRQOMR; + __IO uint32_t MTLRQMPOCR; + __IO uint32_t MTLRQDR; + uint32_t RESERVED36[177]; + __IO uint32_t DMAMR; + __IO uint32_t DMASBMR; + __IO uint32_t DMAISR; + __IO uint32_t DMADSR; + uint32_t RESERVED37[60]; + __IO uint32_t DMACCR; + __IO uint32_t DMACTCR; + __IO uint32_t DMACRCR; + uint32_t RESERVED38[2]; + __IO uint32_t DMACTDLAR; + uint32_t RESERVED39; + __IO uint32_t DMACRDLAR; + __IO uint32_t DMACTDTPR; + uint32_t RESERVED40; + __IO uint32_t DMACRDTPR; + __IO uint32_t DMACTDRLR; + __IO uint32_t DMACRDRLR; + __IO uint32_t DMACIER; + __IO uint32_t DMACRIWTR; +__IO uint32_t DMACSFCSR; + uint32_t RESERVED41; + __IO uint32_t DMACCATDR; + uint32_t RESERVED42; + __IO uint32_t DMACCARDR; + uint32_t RESERVED43; + __IO uint32_t DMACCATBR; + uint32_t RESERVED44; + __IO uint32_t DMACCARBR; + __IO uint32_t DMACSR; +uint32_t RESERVED45[2]; +__IO uint32_t DMACMFCR; +}ETH_TypeDef; +/** + * @brief External Interrupt/Event Controller + */ + +typedef struct +{ +__IO uint32_t RTSR1; /*!< EXTI Rising trigger selection register, Address offset: 0x00 */ +__IO uint32_t FTSR1; /*!< EXTI Falling trigger selection register, Address offset: 0x04 */ +__IO uint32_t SWIER1; /*!< EXTI Software interrupt event register, Address offset: 0x08 */ +__IO uint32_t D3PMR1; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR1) Address offset: 0x0C */ +__IO uint32_t D3PCR1L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR1L) Address offset: 0x10 */ +__IO uint32_t D3PCR1H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR1H) Address offset: 0x14 */ +uint32_t RESERVED1[2]; /*!< Reserved, 0x18 to 0x1C */ +__IO uint32_t RTSR2; /*!< EXTI Rising trigger selection register, Address offset: 0x20 */ +__IO uint32_t FTSR2; /*!< EXTI Falling trigger selection register, Address offset: 0x24 */ +__IO uint32_t SWIER2; /*!< EXTI Software interrupt event register, Address offset: 0x28 */ +__IO uint32_t D3PMR2; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR2) Address offset: 0x2C */ +__IO uint32_t D3PCR2L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR2L) Address offset: 0x30 */ +__IO uint32_t D3PCR2H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR2H) Address offset: 0x34 */ +uint32_t RESERVED2[2]; /*!< Reserved, 0x38 to 0x3C */ +__IO uint32_t RTSR3; /*!< EXTI Rising trigger selection register, Address offset: 0x40 */ +__IO uint32_t FTSR3; /*!< EXTI Falling trigger selection register, Address offset: 0x44 */ +__IO uint32_t SWIER3; /*!< EXTI Software interrupt event register, Address offset: 0x48 */ +__IO uint32_t D3PMR3; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR3) Address offset: 0x4C */ +__IO uint32_t D3PCR3L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR3L) Address offset: 0x50 */ +__IO uint32_t D3PCR3H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR3H) Address offset: 0x54 */ +uint32_t RESERVED3[10]; /*!< Reserved, 0x58 to 0x7C */ +__IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x80 */ +__IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x84 */ +__IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x88 */ +uint32_t RESERVED4; /*!< Reserved, 0x8C */ +__IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x90 */ +__IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x94 */ +__IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x98 */ +uint32_t RESERVED5; /*!< Reserved, 0x9C */ +__IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0xA0 */ +__IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0xA4 */ +__IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0xA8 */ +}EXTI_TypeDef; + +/** + * @brief This structure registers corresponds to EXTI_Typdef CPU1/CPU2 registers subset (IMRx, EMRx and PRx), allowing to define EXTI_D1/EXTI_D2 + * with rapid/common access to these IMRx, EMRx, PRx registers for CPU1 and CPU2. + * Note that EXTI_D1 and EXTI_D2 bases addresses are calculated to point to CPUx first register: + * IMR1 in case of EXTI_D1 that is addressing CPU1 (Coretx-M7) + * C2IMR1 in case of EXTI_D2 that is addressing CPU2 (Coretx-M4) + * Note: EXTI_D2 and corresponding C2IMRx, C2EMRx and C2PRx registers are available for Dual Core devices only + */ + +typedef struct +{ +__IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ +__IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x04 */ +__IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x08 */ +uint32_t RESERVED1; /*!< Reserved, 0x0C */ +__IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x10 */ +__IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x14 */ +__IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x18 */ +uint32_t RESERVED2; /*!< Reserved, 0x1C */ +__IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0x20 */ +__IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0x24 */ +__IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0x28 */ +}EXTI_Core_TypeDef; + + +/** + * @brief FLASH Registers + */ + +typedef struct +{ + __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ + __IO uint32_t KEYR1; /*!< Flash Key Register for bank1, Address offset: 0x04 */ + __IO uint32_t OPTKEYR; /*!< Flash Option Key Register, Address offset: 0x08 */ + __IO uint32_t CR1; /*!< Flash Control Register for bank1, Address offset: 0x0C */ + __IO uint32_t SR1; /*!< Flash Status Register for bank1, Address offset: 0x10 */ + __IO uint32_t CCR1; /*!< Flash Control Register for bank1, Address offset: 0x14 */ + __IO uint32_t OPTCR; /*!< Flash Option Control Register, Address offset: 0x18 */ + __IO uint32_t OPTSR_CUR; /*!< Flash Option Status Current Register, Address offset: 0x1C */ + __IO uint32_t OPTSR_PRG; /*!< Flash Option Status to Program Register, Address offset: 0x20 */ + __IO uint32_t OPTCCR; /*!< Flash Option Clear Control Register, Address offset: 0x24 */ + __IO uint32_t PRAR_CUR1; /*!< Flash Current Protection Address Register for bank1, Address offset: 0x28 */ + __IO uint32_t PRAR_PRG1; /*!< Flash Protection Address to Program Register for bank1, Address offset: 0x2C */ + __IO uint32_t SCAR_CUR1; /*!< Flash Current Secure Address Register for bank1, Address offset: 0x30 */ + __IO uint32_t SCAR_PRG1; /*!< Flash Secure Address to Program Register for bank1, Address offset: 0x34 */ + __IO uint32_t WPSN_CUR1; /*!< Flash Current Write Protection Register on bank1, Address offset: 0x38 */ + __IO uint32_t WPSN_PRG1; /*!< Flash Write Protection to Program Register on bank1, Address offset: 0x3C */ + __IO uint32_t BOOT_CUR; /*!< Flash Current Boot Address for Pelican Core Register, Address offset: 0x40 */ + __IO uint32_t BOOT_PRG; /*!< Flash Boot Address to Program for Pelican Core Register, Address offset: 0x44 */ + uint32_t RESERVED0[2]; /*!< Reserved, 0x48 to 0x4C */ + __IO uint32_t CRCCR1; /*!< Flash CRC Control register For Bank1 Register , Address offset: 0x50 */ + __IO uint32_t CRCSADD1; /*!< Flash CRC Start Address Register for Bank1 , Address offset: 0x54 */ + __IO uint32_t CRCEADD1; /*!< Flash CRC End Address Register for Bank1 , Address offset: 0x58 */ + __IO uint32_t CRCDATA; /*!< Flash CRC Data Register for Bank1 , Address offset: 0x5C */ + __IO uint32_t ECC_FA1; /*!< Flash ECC Fail Address For Bank1 Register , Address offset: 0x60 */ + uint32_t RESERVED[3]; /*!< Reserved, 0x64 to 0x6C */ + __IO uint32_t OPTSR2_CUR; /*!< Flash Option Status Current Register 2, Address offset: 0x70 */ + __IO uint32_t OPTSR2_PRG; /*!< Flash Option Status to Program Register 2, Address offset: 0x74 */ +} FLASH_TypeDef; + +/** + * @brief Filter and Mathematical ACcelerator + */ +typedef struct +{ + __IO uint32_t X1BUFCFG; /*!< FMAC X1 Buffer Configuration register, Address offset: 0x00 */ + __IO uint32_t X2BUFCFG; /*!< FMAC X2 Buffer Configuration register, Address offset: 0x04 */ + __IO uint32_t YBUFCFG; /*!< FMAC Y Buffer Configuration register, Address offset: 0x08 */ + __IO uint32_t PARAM; /*!< FMAC Parameter register, Address offset: 0x0C */ + __IO uint32_t CR; /*!< FMAC Control register, Address offset: 0x10 */ + __IO uint32_t SR; /*!< FMAC Status register, Address offset: 0x14 */ + __IO uint32_t WDATA; /*!< FMAC Write Data register, Address offset: 0x18 */ + __IO uint32_t RDATA; /*!< FMAC Read Data register, Address offset: 0x1C */ +} FMAC_TypeDef; + +/** + * @brief Flexible Memory Controller + */ + +typedef struct +{ + __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ +} FMC_Bank1_TypeDef; + +/** + * @brief Flexible Memory Controller Bank1E + */ + +typedef struct +{ + __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ +} FMC_Bank1E_TypeDef; + +/** + * @brief Flexible Memory Controller Bank2 + */ + +typedef struct +{ + __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ + __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ + __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ + __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ + uint32_t RESERVED0; /*!< Reserved, 0x70 */ + __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ +} FMC_Bank2_TypeDef; + +/** + * @brief Flexible Memory Controller Bank3 + */ + +typedef struct +{ + __IO uint32_t PCR; /*!< NAND Flash control register 3, Address offset: 0x80 */ + __IO uint32_t SR; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ + __IO uint32_t PMEM; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ + __IO uint32_t PATT; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ + uint32_t RESERVED; /*!< Reserved, 0x90 */ + __IO uint32_t ECCR; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ +} FMC_Bank3_TypeDef; + +/** + * @brief Flexible Memory Controller Bank5 and 6 + */ + + +typedef struct +{ + __IO uint32_t SDCR[2]; /*!< SDRAM Control registers , Address offset: 0x140-0x144 */ + __IO uint32_t SDTR[2]; /*!< SDRAM Timing registers , Address offset: 0x148-0x14C */ + __IO uint32_t SDCMR; /*!< SDRAM Command Mode register, Address offset: 0x150 */ + __IO uint32_t SDRTR; /*!< SDRAM Refresh Timer register, Address offset: 0x154 */ + __IO uint32_t SDSR; /*!< SDRAM Status register, Address offset: 0x158 */ +} FMC_Bank5_6_TypeDef; + +/** + * @brief General Purpose I/O + */ + +typedef struct +{ + __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ + __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ + __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ + __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ + __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ + __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ + __IO uint32_t BSRR; /*!< GPIO port bit set/reset, Address offset: 0x18 */ + __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ + __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ +} GPIO_TypeDef; + +/** + * @brief Operational Amplifier (OPAMP) + */ + +typedef struct +{ + __IO uint32_t CSR; /*!< OPAMP control/status register, Address offset: 0x00 */ + __IO uint32_t OTR; /*!< OPAMP offset trimming register for normal mode, Address offset: 0x04 */ + __IO uint32_t HSOTR; /*!< OPAMP offset trimming register for high speed mode, Address offset: 0x08 */ +} OPAMP_TypeDef; + +/** + * @brief System configuration controller + */ + +typedef struct +{ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x00 */ + __IO uint32_t PMCR; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ + __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ + __IO uint32_t CFGR; /*!< SYSCFG configuration registers, Address offset: 0x18 */ + uint32_t RESERVED2; /*!< Reserved, Address offset: 0x1C */ + __IO uint32_t CCCSR; /*!< SYSCFG compensation cell control/status register, Address offset: 0x20 */ + __IO uint32_t CCVR; /*!< SYSCFG compensation cell value register, Address offset: 0x24 */ + __IO uint32_t CCCR; /*!< SYSCFG compensation cell code register, Address offset: 0x28 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2C */ + __IO uint32_t ADC2ALT; /*!< ADC2 internal input alternate connection register, Address offset: 0x30 */ + uint32_t RESERVED4[60]; /*!< Reserved, 0x34-0x120 */ + __IO uint32_t PKGR; /*!< SYSCFG package register, Address offset: 0x124 */ + uint32_t RESERVED5[118]; /*!< Reserved, 0x128-0x2FC */ + __IO uint32_t UR0; /*!< SYSCFG user register 0, Address offset: 0x300 */ + __IO uint32_t UR1; /*!< SYSCFG user register 1, Address offset: 0x304 */ + __IO uint32_t UR2; /*!< SYSCFG user register 2, Address offset: 0x308 */ + __IO uint32_t UR3; /*!< SYSCFG user register 3, Address offset: 0x30C */ + __IO uint32_t UR4; /*!< SYSCFG user register 4, Address offset: 0x310 */ + __IO uint32_t UR5; /*!< SYSCFG user register 5, Address offset: 0x314 */ + __IO uint32_t UR6; /*!< SYSCFG user register 6, Address offset: 0x318 */ + __IO uint32_t UR7; /*!< SYSCFG user register 7, Address offset: 0x31C */ + uint32_t RESERVED6[3]; /*!< Reserved, Address offset: 0x320-0x328 */ + __IO uint32_t UR11; /*!< SYSCFG user register 11, Address offset: 0x32C */ + __IO uint32_t UR12; /*!< SYSCFG user register 12, Address offset: 0x330 */ + __IO uint32_t UR13; /*!< SYSCFG user register 13, Address offset: 0x334 */ + __IO uint32_t UR14; /*!< SYSCFG user register 14, Address offset: 0x338 */ + __IO uint32_t UR15; /*!< SYSCFG user register 15, Address offset: 0x33C */ + __IO uint32_t UR16; /*!< SYSCFG user register 16, Address offset: 0x340 */ + __IO uint32_t UR17; /*!< SYSCFG user register 17, Address offset: 0x344 */ + __IO uint32_t UR18; /*!< SYSCFG user register 18, Address offset: 0x348 */ + +} SYSCFG_TypeDef; + +/** + * @brief Inter-integrated Circuit Interface + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ + __IO uint32_t OAR1; /*!< I2C Own address 1 register, Address offset: 0x08 */ + __IO uint32_t OAR2; /*!< I2C Own address 2 register, Address offset: 0x0C */ + __IO uint32_t TIMINGR; /*!< I2C Timing register, Address offset: 0x10 */ + __IO uint32_t TIMEOUTR; /*!< I2C Timeout register, Address offset: 0x14 */ + __IO uint32_t ISR; /*!< I2C Interrupt and status register, Address offset: 0x18 */ + __IO uint32_t ICR; /*!< I2C Interrupt clear register, Address offset: 0x1C */ + __IO uint32_t PECR; /*!< I2C PEC register, Address offset: 0x20 */ + __IO uint32_t RXDR; /*!< I2C Receive data register, Address offset: 0x24 */ + __IO uint32_t TXDR; /*!< I2C Transmit data register, Address offset: 0x28 */ +} I2C_TypeDef; + +/** + * @brief Independent WATCHDOG + */ + +typedef struct +{ + __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ + __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ + __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ + __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ + __IO uint32_t WINR; /*!< IWDG Window register, Address offset: 0x10 */ +} IWDG_TypeDef; + + +/** + * @brief LCD-TFT Display Controller + */ + +typedef struct +{ + uint32_t RESERVED0[2]; /*!< Reserved, 0x00-0x04 */ + __IO uint32_t SSCR; /*!< LTDC Synchronization Size Configuration Register, Address offset: 0x08 */ + __IO uint32_t BPCR; /*!< LTDC Back Porch Configuration Register, Address offset: 0x0C */ + __IO uint32_t AWCR; /*!< LTDC Active Width Configuration Register, Address offset: 0x10 */ + __IO uint32_t TWCR; /*!< LTDC Total Width Configuration Register, Address offset: 0x14 */ + __IO uint32_t GCR; /*!< LTDC Global Control Register, Address offset: 0x18 */ + uint32_t RESERVED1[2]; /*!< Reserved, 0x1C-0x20 */ + __IO uint32_t SRCR; /*!< LTDC Shadow Reload Configuration Register, Address offset: 0x24 */ + uint32_t RESERVED2[1]; /*!< Reserved, 0x28 */ + __IO uint32_t BCCR; /*!< LTDC Background Color Configuration Register, Address offset: 0x2C */ + uint32_t RESERVED3[1]; /*!< Reserved, 0x30 */ + __IO uint32_t IER; /*!< LTDC Interrupt Enable Register, Address offset: 0x34 */ + __IO uint32_t ISR; /*!< LTDC Interrupt Status Register, Address offset: 0x38 */ + __IO uint32_t ICR; /*!< LTDC Interrupt Clear Register, Address offset: 0x3C */ + __IO uint32_t LIPCR; /*!< LTDC Line Interrupt Position Configuration Register, Address offset: 0x40 */ + __IO uint32_t CPSR; /*!< LTDC Current Position Status Register, Address offset: 0x44 */ + __IO uint32_t CDSR; /*!< LTDC Current Display Status Register, Address offset: 0x48 */ +} LTDC_TypeDef; + +/** + * @brief LCD-TFT Display layer x Controller + */ + +typedef struct +{ + __IO uint32_t CR; /*!< LTDC Layerx Control Register Address offset: 0x84 */ + __IO uint32_t WHPCR; /*!< LTDC Layerx Window Horizontal Position Configuration Register Address offset: 0x88 */ + __IO uint32_t WVPCR; /*!< LTDC Layerx Window Vertical Position Configuration Register Address offset: 0x8C */ + __IO uint32_t CKCR; /*!< LTDC Layerx Color Keying Configuration Register Address offset: 0x90 */ + __IO uint32_t PFCR; /*!< LTDC Layerx Pixel Format Configuration Register Address offset: 0x94 */ + __IO uint32_t CACR; /*!< LTDC Layerx Constant Alpha Configuration Register Address offset: 0x98 */ + __IO uint32_t DCCR; /*!< LTDC Layerx Default Color Configuration Register Address offset: 0x9C */ + __IO uint32_t BFCR; /*!< LTDC Layerx Blending Factors Configuration Register Address offset: 0xA0 */ + uint32_t RESERVED0[2]; /*!< Reserved */ + __IO uint32_t CFBAR; /*!< LTDC Layerx Color Frame Buffer Address Register Address offset: 0xAC */ + __IO uint32_t CFBLR; /*!< LTDC Layerx Color Frame Buffer Length Register Address offset: 0xB0 */ + __IO uint32_t CFBLNR; /*!< LTDC Layerx ColorFrame Buffer Line Number Register Address offset: 0xB4 */ + uint32_t RESERVED1[3]; /*!< Reserved */ + __IO uint32_t CLUTWR; /*!< LTDC Layerx CLUT Write Register Address offset: 0x144 */ + +} LTDC_Layer_TypeDef; + +/** + * @brief Power Control + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< PWR power control register 1, Address offset: 0x00 */ + __IO uint32_t CSR1; /*!< PWR power control status register 1, Address offset: 0x04 */ + __IO uint32_t CR2; /*!< PWR power control register 2, Address offset: 0x08 */ + __IO uint32_t CR3; /*!< PWR power control register 3, Address offset: 0x0C */ + __IO uint32_t CPUCR; /*!< PWR CPU control register, Address offset: 0x10 */ + uint32_t RESERVED0; /*!< Reserved, Address offset: 0x14 */ + __IO uint32_t D3CR; /*!< PWR D3 domain control register, Address offset: 0x18 */ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x1C */ + __IO uint32_t WKUPCR; /*!< PWR wakeup clear register, Address offset: 0x20 */ + __IO uint32_t WKUPFR; /*!< PWR wakeup flag register, Address offset: 0x24 */ + __IO uint32_t WKUPEPR; /*!< PWR wakeup enable and polarity register, Address offset: 0x28 */ +} PWR_TypeDef; + +/** + * @brief Reset and Clock Control + */ + +typedef struct +{ + __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ + __IO uint32_t HSICFGR; /*!< HSI Clock Calibration Register, Address offset: 0x04 */ + __IO uint32_t CRRCR; /*!< Clock Recovery RC Register, Address offset: 0x08 */ + __IO uint32_t CSICFGR; /*!< CSI Clock Calibration Register, Address offset: 0x0C */ + __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x10 */ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x14 */ + __IO uint32_t D1CFGR; /*!< RCC Domain 1 configuration register, Address offset: 0x18 */ + __IO uint32_t D2CFGR; /*!< RCC Domain 2 configuration register, Address offset: 0x1C */ + __IO uint32_t D3CFGR; /*!< RCC Domain 3 configuration register, Address offset: 0x20 */ + uint32_t RESERVED2; /*!< Reserved, Address offset: 0x24 */ + __IO uint32_t PLLCKSELR; /*!< RCC PLLs Clock Source Selection Register, Address offset: 0x28 */ + __IO uint32_t PLLCFGR; /*!< RCC PLLs Configuration Register, Address offset: 0x2C */ + __IO uint32_t PLL1DIVR; /*!< RCC PLL1 Dividers Configuration Register, Address offset: 0x30 */ + __IO uint32_t PLL1FRACR; /*!< RCC PLL1 Fractional Divider Configuration Register, Address offset: 0x34 */ + __IO uint32_t PLL2DIVR; /*!< RCC PLL2 Dividers Configuration Register, Address offset: 0x38 */ + __IO uint32_t PLL2FRACR; /*!< RCC PLL2 Fractional Divider Configuration Register, Address offset: 0x3C */ + __IO uint32_t PLL3DIVR; /*!< RCC PLL3 Dividers Configuration Register, Address offset: 0x40 */ + __IO uint32_t PLL3FRACR; /*!< RCC PLL3 Fractional Divider Configuration Register, Address offset: 0x44 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x48 */ + __IO uint32_t D1CCIPR; /*!< RCC Domain 1 Kernel Clock Configuration Register Address offset: 0x4C */ + __IO uint32_t D2CCIP1R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x50 */ + __IO uint32_t D2CCIP2R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x54 */ + __IO uint32_t D3CCIPR; /*!< RCC Domain 3 Kernel Clock Configuration Register Address offset: 0x58 */ + uint32_t RESERVED4; /*!< Reserved, Address offset: 0x5C */ + __IO uint32_t CIER; /*!< RCC Clock Source Interrupt Enable Register Address offset: 0x60 */ + __IO uint32_t CIFR; /*!< RCC Clock Source Interrupt Flag Register Address offset: 0x64 */ + __IO uint32_t CICR; /*!< RCC Clock Source Interrupt Clear Register Address offset: 0x68 */ + uint32_t RESERVED5; /*!< Reserved, Address offset: 0x6C */ + __IO uint32_t BDCR; /*!< RCC Vswitch Backup Domain Control Register, Address offset: 0x70 */ + __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ + uint32_t RESERVED6; /*!< Reserved, Address offset: 0x78 */ + __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x7C */ + __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x80 */ + __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x84 */ + __IO uint32_t AHB4RSTR; /*!< RCC AHB4 peripheral reset register, Address offset: 0x88 */ + __IO uint32_t APB3RSTR; /*!< RCC APB3 peripheral reset register, Address offset: 0x8C */ + __IO uint32_t APB1LRSTR; /*!< RCC APB1 peripheral reset Low Word register, Address offset: 0x90 */ + __IO uint32_t APB1HRSTR; /*!< RCC APB1 peripheral reset High Word register, Address offset: 0x94 */ + __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x98 */ + __IO uint32_t APB4RSTR; /*!< RCC APB4 peripheral reset register, Address offset: 0x9C */ + __IO uint32_t GCR; /*!< RCC RCC Global Control Register, Address offset: 0xA0 */ + uint32_t RESERVED8; /*!< Reserved, Address offset: 0xA4 */ + __IO uint32_t D3AMR; /*!< RCC Domain 3 Autonomous Mode Register, Address offset: 0xA8 */ + uint32_t RESERVED11[9]; /*!< Reserved, 0xAC-0xCC Address offset: 0xAC */ + __IO uint32_t RSR; /*!< RCC Reset status register, Address offset: 0xD0 */ + __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0xD4 */ + __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0xD8 */ + __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0xDC */ + __IO uint32_t AHB4ENR; /*!< RCC AHB4 peripheral clock register, Address offset: 0xE0 */ + __IO uint32_t APB3ENR; /*!< RCC APB3 peripheral clock register, Address offset: 0xE4 */ + __IO uint32_t APB1LENR; /*!< RCC APB1 peripheral clock Low Word register, Address offset: 0xE8 */ + __IO uint32_t APB1HENR; /*!< RCC APB1 peripheral clock High Word register, Address offset: 0xEC */ + __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock register, Address offset: 0xF0 */ + __IO uint32_t APB4ENR; /*!< RCC APB4 peripheral clock register, Address offset: 0xF4 */ + uint32_t RESERVED12; /*!< Reserved, Address offset: 0xF8 */ + __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral sleep clock register, Address offset: 0xFC */ + __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral sleep clock register, Address offset: 0x100 */ + __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral sleep clock register, Address offset: 0x104 */ + __IO uint32_t AHB4LPENR; /*!< RCC AHB4 peripheral sleep clock register, Address offset: 0x108 */ + __IO uint32_t APB3LPENR; /*!< RCC APB3 peripheral sleep clock register, Address offset: 0x10C */ + __IO uint32_t APB1LLPENR; /*!< RCC APB1 peripheral sleep clock Low Word register, Address offset: 0x110 */ + __IO uint32_t APB1HLPENR; /*!< RCC APB1 peripheral sleep clock High Word register, Address offset: 0x114 */ + __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral sleep clock register, Address offset: 0x118 */ + __IO uint32_t APB4LPENR; /*!< RCC APB4 peripheral sleep clock register, Address offset: 0x11C */ + uint32_t RESERVED13[4]; /*!< Reserved, 0x120-0x12C Address offset: 0x120 */ + +} RCC_TypeDef; + + +/** + * @brief Real-Time Clock + */ +typedef struct +{ + __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ + __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ + __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ + __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ + __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ + __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ + uint32_t RESERVED; /*!< Reserved, Address offset: 0x18 */ + __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ + __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ + __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ + __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ + __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ + __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ + __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ + __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ + __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ + __IO uint32_t TAMPCR; /*!< RTC tamper configuration register, Address offset: 0x40 */ + __IO uint32_t ALRMASSR; /*!< RTC alarm A sub second register, Address offset: 0x44 */ + __IO uint32_t ALRMBSSR; /*!< RTC alarm B sub second register, Address offset: 0x48 */ + __IO uint32_t OR; /*!< RTC option register, Address offset: 0x4C */ + __IO uint32_t BKP0R; /*!< RTC backup register 0, Address offset: 0x50 */ + __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ + __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ + __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ + __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ + __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ + __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ + __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ + __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ + __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ + __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ + __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ + __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ + __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ + __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ + __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ + __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ + __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ + __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ + __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ + __IO uint32_t BKP20R; /*!< RTC backup register 20, Address offset: 0xA0 */ + __IO uint32_t BKP21R; /*!< RTC backup register 21, Address offset: 0xA4 */ + __IO uint32_t BKP22R; /*!< RTC backup register 22, Address offset: 0xA8 */ + __IO uint32_t BKP23R; /*!< RTC backup register 23, Address offset: 0xAC */ + __IO uint32_t BKP24R; /*!< RTC backup register 24, Address offset: 0xB0 */ + __IO uint32_t BKP25R; /*!< RTC backup register 25, Address offset: 0xB4 */ + __IO uint32_t BKP26R; /*!< RTC backup register 26, Address offset: 0xB8 */ + __IO uint32_t BKP27R; /*!< RTC backup register 27, Address offset: 0xBC */ + __IO uint32_t BKP28R; /*!< RTC backup register 28, Address offset: 0xC0 */ + __IO uint32_t BKP29R; /*!< RTC backup register 29, Address offset: 0xC4 */ + __IO uint32_t BKP30R; /*!< RTC backup register 30, Address offset: 0xC8 */ + __IO uint32_t BKP31R; /*!< RTC backup register 31, Address offset: 0xCC */ +} RTC_TypeDef; + +/** + * @brief Serial Audio Interface + */ + +typedef struct +{ + __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ + uint32_t RESERVED0[16]; /*!< Reserved, 0x04 - 0x43 */ + __IO uint32_t PDMCR; /*!< SAI PDM control register, Address offset: 0x44 */ + __IO uint32_t PDMDLY; /*!< SAI PDM delay register, Address offset: 0x48 */ +} SAI_TypeDef; + +typedef struct +{ + __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ + __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ + __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ + __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ + __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ + __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ + __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ + __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ +} SAI_Block_TypeDef; + +/** + * @brief SPDIF-RX Interface + */ + +typedef struct +{ + __IO uint32_t CR; /*!< Control register, Address offset: 0x00 */ + __IO uint32_t IMR; /*!< Interrupt mask register, Address offset: 0x04 */ + __IO uint32_t SR; /*!< Status register, Address offset: 0x08 */ + __IO uint32_t IFCR; /*!< Interrupt Flag Clear register, Address offset: 0x0C */ + __IO uint32_t DR; /*!< Data input register, Address offset: 0x10 */ + __IO uint32_t CSR; /*!< Channel Status register, Address offset: 0x14 */ + __IO uint32_t DIR; /*!< Debug Information register, Address offset: 0x18 */ + uint32_t RESERVED2; /*!< Reserved, 0x1A */ +} SPDIFRX_TypeDef; + + +/** + * @brief Secure digital input/output Interface + */ + +typedef struct +{ + __IO uint32_t POWER; /*!< SDMMC power control register, Address offset: 0x00 */ + __IO uint32_t CLKCR; /*!< SDMMC clock control register, Address offset: 0x04 */ + __IO uint32_t ARG; /*!< SDMMC argument register, Address offset: 0x08 */ + __IO uint32_t CMD; /*!< SDMMC command register, Address offset: 0x0C */ + __I uint32_t RESPCMD; /*!< SDMMC command response register, Address offset: 0x10 */ + __I uint32_t RESP1; /*!< SDMMC response 1 register, Address offset: 0x14 */ + __I uint32_t RESP2; /*!< SDMMC response 2 register, Address offset: 0x18 */ + __I uint32_t RESP3; /*!< SDMMC response 3 register, Address offset: 0x1C */ + __I uint32_t RESP4; /*!< SDMMC response 4 register, Address offset: 0x20 */ + __IO uint32_t DTIMER; /*!< SDMMC data timer register, Address offset: 0x24 */ + __IO uint32_t DLEN; /*!< SDMMC data length register, Address offset: 0x28 */ + __IO uint32_t DCTRL; /*!< SDMMC data control register, Address offset: 0x2C */ + __I uint32_t DCOUNT; /*!< SDMMC data counter register, Address offset: 0x30 */ + __I uint32_t STA; /*!< SDMMC status register, Address offset: 0x34 */ + __IO uint32_t ICR; /*!< SDMMC interrupt clear register, Address offset: 0x38 */ + __IO uint32_t MASK; /*!< SDMMC mask register, Address offset: 0x3C */ + __IO uint32_t ACKTIME; /*!< SDMMC Acknowledgement timer register, Address offset: 0x40 */ + uint32_t RESERVED0[3]; /*!< Reserved, 0x44 - 0x4C - 0x4C */ + __IO uint32_t IDMACTRL; /*!< SDMMC DMA control register, Address offset: 0x50 */ + __IO uint32_t IDMABSIZE; /*!< SDMMC DMA buffer size register, Address offset: 0x54 */ + __IO uint32_t IDMABASE0; /*!< SDMMC DMA buffer 0 base address register, Address offset: 0x58 */ + __IO uint32_t IDMABASE1; /*!< SDMMC DMA buffer 1 base address register, Address offset: 0x5C */ + uint32_t RESERVED1[8]; /*!< Reserved, 0x60-0x7C */ + __IO uint32_t FIFO; /*!< SDMMC data FIFO register, Address offset: 0x80 */ + uint32_t RESERVED2[222]; /*!< Reserved, 0x84-0x3F8 */ + __IO uint32_t IPVR; /*!< SDMMC data FIFO register, Address offset: 0x3FC */ +} SDMMC_TypeDef; + + +/** + * @brief Delay Block DLYB + */ + +typedef struct +{ + __IO uint32_t CR; /*!< DELAY BLOCK control register, Address offset: 0x00 */ + __IO uint32_t CFGR; /*!< DELAY BLOCK configuration register, Address offset: 0x04 */ +} DLYB_TypeDef; + +/** + * @brief HW Semaphore HSEM + */ + +typedef struct +{ + __IO uint32_t R[32]; /*!< 2-step write lock and read back registers, Address offset: 00h-7Ch */ + __IO uint32_t RLR[32]; /*!< 1-step read lock registers, Address offset: 80h-FCh */ + __IO uint32_t C1IER; /*!< HSEM Interrupt enable register , Address offset: 100h */ + __IO uint32_t C1ICR; /*!< HSEM Interrupt clear register , Address offset: 104h */ + __IO uint32_t C1ISR; /*!< HSEM Interrupt Status register , Address offset: 108h */ + __IO uint32_t C1MISR; /*!< HSEM Interrupt Masked Status register , Address offset: 10Ch */ + uint32_t Reserved[12]; /* Reserved Address offset: 110h-13Ch */ + __IO uint32_t CR; /*!< HSEM Semaphore clear register , Address offset: 140h */ + __IO uint32_t KEYR; /*!< HSEM Semaphore clear key register , Address offset: 144h */ + +} HSEM_TypeDef; + +typedef struct +{ + __IO uint32_t IER; /*!< HSEM interrupt enable register , Address offset: 0h */ + __IO uint32_t ICR; /*!< HSEM interrupt clear register , Address offset: 4h */ + __IO uint32_t ISR; /*!< HSEM interrupt status register , Address offset: 8h */ + __IO uint32_t MISR; /*!< HSEM masked interrupt status register , Address offset: Ch */ +} HSEM_Common_TypeDef; + +/** + * @brief Serial Peripheral Interface + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< SPI/I2S Control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< SPI Control register 2, Address offset: 0x04 */ + __IO uint32_t CFG1; /*!< SPI Configuration register 1, Address offset: 0x08 */ + __IO uint32_t CFG2; /*!< SPI Configuration register 2, Address offset: 0x0C */ + __IO uint32_t IER; /*!< SPI/I2S Interrupt Enable register, Address offset: 0x10 */ + __IO uint32_t SR; /*!< SPI/I2S Status register, Address offset: 0x14 */ + __IO uint32_t IFCR; /*!< SPI/I2S Interrupt/Status flags clear register, Address offset: 0x18 */ + uint32_t RESERVED0; /*!< Reserved, 0x1C */ + __IO uint32_t TXDR; /*!< SPI/I2S Transmit data register, Address offset: 0x20 */ + uint32_t RESERVED1[3]; /*!< Reserved, 0x24-0x2C */ + __IO uint32_t RXDR; /*!< SPI/I2S Receive data register, Address offset: 0x30 */ + uint32_t RESERVED2[3]; /*!< Reserved, 0x34-0x3C */ + __IO uint32_t CRCPOLY; /*!< SPI CRC Polynomial register, Address offset: 0x40 */ + __IO uint32_t TXCRC; /*!< SPI Transmitter CRC register, Address offset: 0x44 */ + __IO uint32_t RXCRC; /*!< SPI Receiver CRC register, Address offset: 0x48 */ + __IO uint32_t UDRDR; /*!< SPI Underrun data register, Address offset: 0x4C */ + __IO uint32_t I2SCFGR; /*!< I2S Configuration register, Address offset: 0x50 */ + +} SPI_TypeDef; + +/** + * @brief DTS + */ +typedef struct +{ + __IO uint32_t CFGR1; /*!< DTS configuration register, Address offset: 0x00 */ + uint32_t RESERVED0; /*!< Reserved, Address offset: 0x04 */ + __IO uint32_t T0VALR1; /*!< DTS T0 Value register, Address offset: 0x08 */ + uint32_t RESERVED1; /*!< Reserved, Address offset: 0x0C */ + __IO uint32_t RAMPVALR; /*!< DTS Ramp value register, Address offset: 0x10 */ + __IO uint32_t ITR1; /*!< DTS Interrupt threshold register, Address offset: 0x14 */ + uint32_t RESERVED2; /*!< Reserved, Address offset: 0x18 */ + __IO uint32_t DR; /*!< DTS data register, Address offset: 0x1C */ + __IO uint32_t SR; /*!< DTS status register Address offset: 0x20 */ + __IO uint32_t ITENR; /*!< DTS Interrupt enable register, Address offset: 0x24 */ + __IO uint32_t ICIFR; /*!< DTS Clear Interrupt flag register, Address offset: 0x28 */ + __IO uint32_t OR; /*!< DTS option register 1, Address offset: 0x2C */ +} +DTS_TypeDef; + +/** + * @brief TIM + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ + __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ + __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ + __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ + __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ + __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ + __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ + __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ + __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ + __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ + __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ + __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ + __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ + __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ + __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ + __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ + __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ + __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ + __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ + uint32_t RESERVED1; /*!< Reserved, 0x50 */ + __IO uint32_t CCMR3; /*!< TIM capture/compare mode register 3, Address offset: 0x54 */ + __IO uint32_t CCR5; /*!< TIM capture/compare register5, Address offset: 0x58 */ + __IO uint32_t CCR6; /*!< TIM capture/compare register6, Address offset: 0x5C */ + __IO uint32_t AF1; /*!< TIM alternate function option register 1, Address offset: 0x60 */ + __IO uint32_t AF2; /*!< TIM alternate function option register 2, Address offset: 0x64 */ + __IO uint32_t TISEL; /*!< TIM Input Selection register, Address offset: 0x68 */ +} TIM_TypeDef; + +/** + * @brief LPTIMIMER + */ +typedef struct +{ + __IO uint32_t ISR; /*!< LPTIM Interrupt and Status register, Address offset: 0x00 */ + __IO uint32_t ICR; /*!< LPTIM Interrupt Clear register, Address offset: 0x04 */ + __IO uint32_t IER; /*!< LPTIM Interrupt Enable register, Address offset: 0x08 */ + __IO uint32_t CFGR; /*!< LPTIM Configuration register, Address offset: 0x0C */ + __IO uint32_t CR; /*!< LPTIM Control register, Address offset: 0x10 */ + __IO uint32_t CMP; /*!< LPTIM Compare register, Address offset: 0x14 */ + __IO uint32_t ARR; /*!< LPTIM Autoreload register, Address offset: 0x18 */ + __IO uint32_t CNT; /*!< LPTIM Counter register, Address offset: 0x1C */ + uint32_t RESERVED1; /*!< Reserved, 0x20 */ + __IO uint32_t CFGR2; /*!< LPTIM Configuration register, Address offset: 0x24 */ +} LPTIM_TypeDef; + +/** + * @brief Comparator + */ +typedef struct +{ + __IO uint32_t SR; /*!< Comparator status register, Address offset: 0x00 */ + __IO uint32_t ICFR; /*!< Comparator interrupt clear flag register, Address offset: 0x04 */ + __IO uint32_t OR; /*!< Comparator option register, Address offset: 0x08 */ +} COMPOPT_TypeDef; + +typedef struct +{ + __IO uint32_t CFGR; /*!< Comparator configuration register , Address offset: 0x00 */ +} COMP_TypeDef; + +typedef struct +{ + __IO uint32_t CFGR; /*!< COMP control and status register, used for bits common to several COMP instances, Address offset: 0x00 */ +} COMP_Common_TypeDef; +/** + * @brief Universal Synchronous Asynchronous Receiver Transmitter + */ + +typedef struct +{ + __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x00 */ + __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x04 */ + __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x08 */ + __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x0C */ + __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x10 */ + __IO uint32_t RTOR; /*!< USART Receiver Time Out register, Address offset: 0x14 */ + __IO uint32_t RQR; /*!< USART Request register, Address offset: 0x18 */ + __IO uint32_t ISR; /*!< USART Interrupt and status register, Address offset: 0x1C */ + __IO uint32_t ICR; /*!< USART Interrupt flag Clear register, Address offset: 0x20 */ + __IO uint32_t RDR; /*!< USART Receive Data register, Address offset: 0x24 */ + __IO uint32_t TDR; /*!< USART Transmit Data register, Address offset: 0x28 */ + __IO uint32_t PRESC; /*!< USART clock Prescaler register, Address offset: 0x2C */ +} USART_TypeDef; + +/** + * @brief Single Wire Protocol Master Interface SPWMI + */ +typedef struct +{ + __IO uint32_t CR; /*!< SWPMI Configuration/Control register, Address offset: 0x00 */ + __IO uint32_t BRR; /*!< SWPMI bitrate register, Address offset: 0x04 */ + uint32_t RESERVED1; /*!< Reserved, 0x08 */ + __IO uint32_t ISR; /*!< SWPMI Interrupt and Status register, Address offset: 0x0C */ + __IO uint32_t ICR; /*!< SWPMI Interrupt Flag Clear register, Address offset: 0x10 */ + __IO uint32_t IER; /*!< SWPMI Interrupt Enable register, Address offset: 0x14 */ + __IO uint32_t RFL; /*!< SWPMI Receive Frame Length register, Address offset: 0x18 */ + __IO uint32_t TDR; /*!< SWPMI Transmit data register, Address offset: 0x1C */ + __IO uint32_t RDR; /*!< SWPMI Receive data register, Address offset: 0x20 */ + __IO uint32_t OR; /*!< SWPMI Option register, Address offset: 0x24 */ +} SWPMI_TypeDef; + +/** + * @brief Window WATCHDOG + */ + +typedef struct +{ + __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ + __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ + __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ +} WWDG_TypeDef; + + +/** + * @brief RAM_ECC_Specific_Registers + */ +typedef struct +{ + __IO uint32_t CR; /*!< RAMECC monitor configuration register */ + __IO uint32_t SR; /*!< RAMECC monitor status register */ + __IO uint32_t FAR; /*!< RAMECC monitor failing address register */ + __IO uint32_t FDRL; /*!< RAMECC monitor failing data low register */ + __IO uint32_t FDRH; /*!< RAMECC monitor failing data high register */ + __IO uint32_t FECR; /*!< RAMECC monitor failing ECC error code register */ +} RAMECC_MonitorTypeDef; + +typedef struct +{ + __IO uint32_t IER; /*!< RAMECC interrupt enable register */ +} RAMECC_TypeDef; +/** + * @} + */ + + +/** + * @brief Crypto Processor + */ + +typedef struct +{ + __IO uint32_t CR; /*!< CRYP control register, Address offset: 0x00 */ + __IO uint32_t SR; /*!< CRYP status register, Address offset: 0x04 */ + __IO uint32_t DIN; /*!< CRYP data input register, Address offset: 0x08 */ + __IO uint32_t DOUT; /*!< CRYP data output register, Address offset: 0x0C */ + __IO uint32_t DMACR; /*!< CRYP DMA control register, Address offset: 0x10 */ + __IO uint32_t IMSCR; /*!< CRYP interrupt mask set/clear register, Address offset: 0x14 */ + __IO uint32_t RISR; /*!< CRYP raw interrupt status register, Address offset: 0x18 */ + __IO uint32_t MISR; /*!< CRYP masked interrupt status register, Address offset: 0x1C */ + __IO uint32_t K0LR; /*!< CRYP key left register 0, Address offset: 0x20 */ + __IO uint32_t K0RR; /*!< CRYP key right register 0, Address offset: 0x24 */ + __IO uint32_t K1LR; /*!< CRYP key left register 1, Address offset: 0x28 */ + __IO uint32_t K1RR; /*!< CRYP key right register 1, Address offset: 0x2C */ + __IO uint32_t K2LR; /*!< CRYP key left register 2, Address offset: 0x30 */ + __IO uint32_t K2RR; /*!< CRYP key right register 2, Address offset: 0x34 */ + __IO uint32_t K3LR; /*!< CRYP key left register 3, Address offset: 0x38 */ + __IO uint32_t K3RR; /*!< CRYP key right register 3, Address offset: 0x3C */ + __IO uint32_t IV0LR; /*!< CRYP initialization vector left-word register 0, Address offset: 0x40 */ + __IO uint32_t IV0RR; /*!< CRYP initialization vector right-word register 0, Address offset: 0x44 */ + __IO uint32_t IV1LR; /*!< CRYP initialization vector left-word register 1, Address offset: 0x48 */ + __IO uint32_t IV1RR; /*!< CRYP initialization vector right-word register 1, Address offset: 0x4C */ + __IO uint32_t CSGCMCCM0R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 0, Address offset: 0x50 */ + __IO uint32_t CSGCMCCM1R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 1, Address offset: 0x54 */ + __IO uint32_t CSGCMCCM2R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 2, Address offset: 0x58 */ + __IO uint32_t CSGCMCCM3R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 3, Address offset: 0x5C */ + __IO uint32_t CSGCMCCM4R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 4, Address offset: 0x60 */ + __IO uint32_t CSGCMCCM5R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 5, Address offset: 0x64 */ + __IO uint32_t CSGCMCCM6R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 6, Address offset: 0x68 */ + __IO uint32_t CSGCMCCM7R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 7, Address offset: 0x6C */ + __IO uint32_t CSGCM0R; /*!< CRYP GCM/GMAC context swap register 0, Address offset: 0x70 */ + __IO uint32_t CSGCM1R; /*!< CRYP GCM/GMAC context swap register 1, Address offset: 0x74 */ + __IO uint32_t CSGCM2R; /*!< CRYP GCM/GMAC context swap register 2, Address offset: 0x78 */ + __IO uint32_t CSGCM3R; /*!< CRYP GCM/GMAC context swap register 3, Address offset: 0x7C */ + __IO uint32_t CSGCM4R; /*!< CRYP GCM/GMAC context swap register 4, Address offset: 0x80 */ + __IO uint32_t CSGCM5R; /*!< CRYP GCM/GMAC context swap register 5, Address offset: 0x84 */ + __IO uint32_t CSGCM6R; /*!< CRYP GCM/GMAC context swap register 6, Address offset: 0x88 */ + __IO uint32_t CSGCM7R; /*!< CRYP GCM/GMAC context swap register 7, Address offset: 0x8C */ +} CRYP_TypeDef; + +/** + * @brief HASH + */ + +typedef struct +{ + __IO uint32_t CR; /*!< HASH control register, Address offset: 0x00 */ + __IO uint32_t DIN; /*!< HASH data input register, Address offset: 0x04 */ + __IO uint32_t STR; /*!< HASH start register, Address offset: 0x08 */ + __IO uint32_t HR[5]; /*!< HASH digest registers, Address offset: 0x0C-0x1C */ + __IO uint32_t IMR; /*!< HASH interrupt enable register, Address offset: 0x20 */ + __IO uint32_t SR; /*!< HASH status register, Address offset: 0x24 */ + uint32_t RESERVED[52]; /*!< Reserved, 0x28-0xF4 */ + __IO uint32_t CSR[54]; /*!< HASH context swap registers, Address offset: 0x0F8-0x1CC */ +} HASH_TypeDef; + +/** + * @brief HASH_DIGEST + */ + +typedef struct +{ + __IO uint32_t HR[8]; /*!< HASH digest registers, Address offset: 0x310-0x32C */ +} HASH_DIGEST_TypeDef; + + +/** + * @brief RNG + */ + +typedef struct +{ + __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ + __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ + __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ + uint32_t RESERVED; + __IO uint32_t HTCR; /*!< RNG health test configuration register, Address offset: 0x10 */ +} RNG_TypeDef; + +/** + * @brief MDIOS + */ + +typedef struct +{ + __IO uint32_t CR; + __IO uint32_t WRFR; + __IO uint32_t CWRFR; + __IO uint32_t RDFR; + __IO uint32_t CRDFR; + __IO uint32_t SR; + __IO uint32_t CLRFR; + uint32_t RESERVED[57]; + __IO uint32_t DINR0; + __IO uint32_t DINR1; + __IO uint32_t DINR2; + __IO uint32_t DINR3; + __IO uint32_t DINR4; + __IO uint32_t DINR5; + __IO uint32_t DINR6; + __IO uint32_t DINR7; + __IO uint32_t DINR8; + __IO uint32_t DINR9; + __IO uint32_t DINR10; + __IO uint32_t DINR11; + __IO uint32_t DINR12; + __IO uint32_t DINR13; + __IO uint32_t DINR14; + __IO uint32_t DINR15; + __IO uint32_t DINR16; + __IO uint32_t DINR17; + __IO uint32_t DINR18; + __IO uint32_t DINR19; + __IO uint32_t DINR20; + __IO uint32_t DINR21; + __IO uint32_t DINR22; + __IO uint32_t DINR23; + __IO uint32_t DINR24; + __IO uint32_t DINR25; + __IO uint32_t DINR26; + __IO uint32_t DINR27; + __IO uint32_t DINR28; + __IO uint32_t DINR29; + __IO uint32_t DINR30; + __IO uint32_t DINR31; + __IO uint32_t DOUTR0; + __IO uint32_t DOUTR1; + __IO uint32_t DOUTR2; + __IO uint32_t DOUTR3; + __IO uint32_t DOUTR4; + __IO uint32_t DOUTR5; + __IO uint32_t DOUTR6; + __IO uint32_t DOUTR7; + __IO uint32_t DOUTR8; + __IO uint32_t DOUTR9; + __IO uint32_t DOUTR10; + __IO uint32_t DOUTR11; + __IO uint32_t DOUTR12; + __IO uint32_t DOUTR13; + __IO uint32_t DOUTR14; + __IO uint32_t DOUTR15; + __IO uint32_t DOUTR16; + __IO uint32_t DOUTR17; + __IO uint32_t DOUTR18; + __IO uint32_t DOUTR19; + __IO uint32_t DOUTR20; + __IO uint32_t DOUTR21; + __IO uint32_t DOUTR22; + __IO uint32_t DOUTR23; + __IO uint32_t DOUTR24; + __IO uint32_t DOUTR25; + __IO uint32_t DOUTR26; + __IO uint32_t DOUTR27; + __IO uint32_t DOUTR28; + __IO uint32_t DOUTR29; + __IO uint32_t DOUTR30; + __IO uint32_t DOUTR31; +} MDIOS_TypeDef; + + +/** + * @brief USB_OTG_Core_Registers + */ +typedef struct +{ + __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ + __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ + __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ + __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ + __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ + __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ + __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ + __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ + __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ + __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ + __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ + __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ + uint32_t Reserved30[2]; /*!< Reserved 030h */ + __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ + __IO uint32_t CID; /*!< User ID Register 03Ch */ + __IO uint32_t GSNPSID; /* USB_OTG core ID 040h*/ + __IO uint32_t GHWCFG1; /* User HW config1 044h*/ + __IO uint32_t GHWCFG2; /* User HW config2 048h*/ + __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ + uint32_t Reserved6; /*!< Reserved 050h */ + __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ + __IO uint32_t GPWRDN; /*!< Power Down Register 058h */ + __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ + __IO uint32_t GADPCTL; /*!< ADP Timer, Control and Status Register 60Ch */ + uint32_t Reserved43[39]; /*!< Reserved 058h-0FFh */ + __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ + __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ +} USB_OTG_GlobalTypeDef; + + +/** + * @brief USB_OTG_device_Registers + */ +typedef struct +{ + __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ + __IO uint32_t DCTL; /*!< dev Control Register 804h */ + __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ + uint32_t Reserved0C; /*!< Reserved 80Ch */ + __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ + __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ + __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ + __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ + uint32_t Reserved20; /*!< Reserved 820h */ + uint32_t Reserved9; /*!< Reserved 824h */ + __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ + __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ + __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ + __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ + __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ + __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ + uint32_t Reserved40; /*!< dedicated EP mask 840h */ + __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ + uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ + __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ +} USB_OTG_DeviceTypeDef; + + +/** + * @brief USB_OTG_IN_Endpoint-Specific_Register + */ +typedef struct +{ + __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ + uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ + __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ + uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ + __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ + __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ + __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ + uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ +} USB_OTG_INEndpointTypeDef; + + +/** + * @brief USB_OTG_OUT_Endpoint-Specific_Registers + */ +typedef struct +{ + __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ + uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ + __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ + uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ + __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ + __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ + uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ +} USB_OTG_OUTEndpointTypeDef; + + +/** + * @brief USB_OTG_Host_Mode_Register_Structures + */ +typedef struct +{ + __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ + __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ + __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ + uint32_t Reserved40C; /*!< Reserved 40Ch */ + __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ + __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ + __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ +} USB_OTG_HostTypeDef; + +/** + * @brief USB_OTG_Host_Channel_Specific_Registers + */ +typedef struct +{ + __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ + __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ + __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ + __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ + __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ + __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ + uint32_t Reserved[2]; /*!< Reserved */ +} USB_OTG_HostChannelTypeDef; +/** + * @} + */ + +/** + * @brief OCTO Serial Peripheral Interface + */ + +typedef struct +{ + __IO uint32_t CR; /*!< OCTOSPI Control register, Address offset: 0x000 */ + uint32_t RESERVED; /*!< Reserved, Address offset: 0x004 */ + __IO uint32_t DCR1; /*!< OCTOSPI Device Configuration register 1, Address offset: 0x008 */ + __IO uint32_t DCR2; /*!< OCTOSPI Device Configuration register 2, Address offset: 0x00C */ + __IO uint32_t DCR3; /*!< OCTOSPI Device Configuration register 3, Address offset: 0x010 */ + __IO uint32_t DCR4; /*!< OCTOSPI Device Configuration register 4, Address offset: 0x014 */ + uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x018-0x01C */ + __IO uint32_t SR; /*!< OCTOSPI Status register, Address offset: 0x020 */ + __IO uint32_t FCR; /*!< OCTOSPI Flag Clear register, Address offset: 0x024 */ + uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x028-0x03C */ + __IO uint32_t DLR; /*!< OCTOSPI Data Length register, Address offset: 0x040 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x044 */ + __IO uint32_t AR; /*!< OCTOSPI Address register, Address offset: 0x048 */ + uint32_t RESERVED4; /*!< Reserved, Address offset: 0x04C */ + __IO uint32_t DR; /*!< OCTOSPI Data register, Address offset: 0x050 */ + uint32_t RESERVED5[11]; /*!< Reserved, Address offset: 0x054-0x07C */ + __IO uint32_t PSMKR; /*!< OCTOSPI Polling Status Mask register, Address offset: 0x080 */ + uint32_t RESERVED6; /*!< Reserved, Address offset: 0x084 */ + __IO uint32_t PSMAR; /*!< OCTOSPI Polling Status Match register, Address offset: 0x088 */ + uint32_t RESERVED7; /*!< Reserved, Address offset: 0x08C */ + __IO uint32_t PIR; /*!< OCTOSPI Polling Interval register, Address offset: 0x090 */ + uint32_t RESERVED8[27]; /*!< Reserved, Address offset: 0x094-0x0FC */ + __IO uint32_t CCR; /*!< OCTOSPI Communication Configuration register, Address offset: 0x100 */ + uint32_t RESERVED9; /*!< Reserved, Address offset: 0x104 */ + __IO uint32_t TCR; /*!< OCTOSPI Timing Configuration register, Address offset: 0x108 */ + uint32_t RESERVED10; /*!< Reserved, Address offset: 0x10C */ + __IO uint32_t IR; /*!< OCTOSPI Instruction register, Address offset: 0x110 */ + uint32_t RESERVED11[3]; /*!< Reserved, Address offset: 0x114-0x11C */ + __IO uint32_t ABR; /*!< OCTOSPI Alternate Bytes register, Address offset: 0x120 */ + uint32_t RESERVED12[3]; /*!< Reserved, Address offset: 0x124-0x12C */ + __IO uint32_t LPTR; /*!< OCTOSPI Low Power Timeout register, Address offset: 0x130 */ + uint32_t RESERVED13[3]; /*!< Reserved, Address offset: 0x134-0x13C */ + __IO uint32_t WPCCR; /*!< OCTOSPI Wrap Communication Configuration register, Address offset: 0x140 */ + uint32_t RESERVED14; /*!< Reserved, Address offset: 0x144 */ + __IO uint32_t WPTCR; /*!< OCTOSPI Wrap Timing Configuration register, Address offset: 0x148 */ + uint32_t RESERVED15; /*!< Reserved, Address offset: 0x14C */ + __IO uint32_t WPIR; /*!< OCTOSPI Wrap Instruction register, Address offset: 0x150 */ + uint32_t RESERVED16[3]; /*!< Reserved, Address offset: 0x154-0x15C */ + __IO uint32_t WPABR; /*!< OCTOSPI Wrap Alternate Bytes register, Address offset: 0x160 */ + uint32_t RESERVED17[7]; /*!< Reserved, Address offset: 0x164-0x17C */ + __IO uint32_t WCCR; /*!< OCTOSPI Write Communication Configuration register, Address offset: 0x180 */ + uint32_t RESERVED18; /*!< Reserved, Address offset: 0x184 */ + __IO uint32_t WTCR; /*!< OCTOSPI Write Timing Configuration register, Address offset: 0x188 */ + uint32_t RESERVED19; /*!< Reserved, Address offset: 0x18C */ + __IO uint32_t WIR; /*!< OCTOSPI Write Instruction register, Address offset: 0x190 */ + uint32_t RESERVED20[3]; /*!< Reserved, Address offset: 0x194-0x19C */ + __IO uint32_t WABR; /*!< OCTOSPI Write Alternate Bytes register, Address offset: 0x1A0 */ + uint32_t RESERVED21[23]; /*!< Reserved, Address offset: 0x1A4-0x1FC */ + __IO uint32_t HLCR; /*!< OCTOSPI Hyperbus Latency Configuration register, Address offset: 0x200 */ + uint32_t RESERVED22[122]; /*!< Reserved, Address offset: 0x204-0x3EC */ + __IO uint32_t HWCFGR; /*!< OCTOSPI HW Configuration register, Address offset: 0x3F0 */ + __IO uint32_t VER; /*!< OCTOSPI Version register, Address offset: 0x3F4 */ + __IO uint32_t ID; /*!< OCTOSPI Identification register, Address offset: 0x3F8 */ + __IO uint32_t MID; /*!< OCTOPSI HW Magic ID register, Address offset: 0x3FC */ +} OCTOSPI_TypeDef; + +/** + * @} + */ +/** + * @brief OCTO Serial Peripheral Interface IO Manager + */ + +typedef struct +{ + __IO uint32_t CR; /*!< OCTOSPI IO Manager Control register, Address offset: 0x00 */ + __IO uint32_t PCR[3]; /*!< OCTOSPI IO Manager Port[1:3] Configuration register, Address offset: 0x04-0x20 */ +} OCTOSPIM_TypeDef; + +/** + * @} + */ + +/** + * @brief OTFD register + */ +typedef struct +{ + __IO uint32_t REG_CONFIGR; + __IO uint32_t REG_START_ADDR; + __IO uint32_t REG_END_ADDR; + __IO uint32_t REG_NONCER0; + __IO uint32_t REG_NONCER1; + __IO uint32_t REG_KEYR0; + __IO uint32_t REG_KEYR1; + __IO uint32_t REG_KEYR2; + __IO uint32_t REG_KEYR3; +} OTFDEC_Region_TypeDef; + +typedef struct +{ + __IO uint32_t CR; + uint32_t RESERVED1[191]; + __IO uint32_t ISR; + __IO uint32_t ICR; + __IO uint32_t IER; + uint32_t RESERVED2[56]; + __IO uint32_t HWCFGR2; + __IO uint32_t HWCFGR1; + __IO uint32_t VERR; + __IO uint32_t IPIDR; + __IO uint32_t SIDR; +} OTFDEC_TypeDef; +/** + * @} + */ + +/** + * @brief Global Programmer View + */ + +typedef struct +{ + uint32_t RESERVED0[2036]; /*!< Reserved, Address offset: 0x00-0x1FCC */ + __IO uint32_t AXI_PERIPH_ID_4; /*!< AXI interconnect - peripheral ID4 register, Address offset: 0x1FD0 */ + uint32_t AXI_PERIPH_ID_5; /*!< Reserved, Address offset: 0x1FD4 */ + uint32_t AXI_PERIPH_ID_6; /*!< Reserved, Address offset: 0x1FD8 */ + uint32_t AXI_PERIPH_ID_7; /*!< Reserved, Address offset: 0x1FDC */ + __IO uint32_t AXI_PERIPH_ID_0; /*!< AXI interconnect - peripheral ID0 register, Address offset: 0x1FE0 */ + __IO uint32_t AXI_PERIPH_ID_1; /*!< AXI interconnect - peripheral ID1 register, Address offset: 0x1FE4 */ + __IO uint32_t AXI_PERIPH_ID_2; /*!< AXI interconnect - peripheral ID2 register, Address offset: 0x1FE8 */ + __IO uint32_t AXI_PERIPH_ID_3; /*!< AXI interconnect - peripheral ID3 register, Address offset: 0x1FEC */ + __IO uint32_t AXI_COMP_ID_0; /*!< AXI interconnect - component ID0 register, Address offset: 0x1FF0 */ + __IO uint32_t AXI_COMP_ID_1; /*!< AXI interconnect - component ID1 register, Address offset: 0x1FF4 */ + __IO uint32_t AXI_COMP_ID_2; /*!< AXI interconnect - component ID2 register, Address offset: 0x1FF8 */ + __IO uint32_t AXI_COMP_ID_3; /*!< AXI interconnect - component ID3 register, Address offset: 0x1FFC */ + uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x2000-0x2004 */ + __IO uint32_t AXI_TARG1_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 1 bus matrix issuing functionality register, Address offset: 0x2008 */ + uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x200C-0x2020 */ + __IO uint32_t AXI_TARG1_FN_MOD2; /*!< AXI interconnect - TARG 1 bus matrix functionality 2 register, Address offset: 0x2024 */ + uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2028 */ + __IO uint32_t AXI_TARG1_FN_MOD_LB; /*!< AXI interconnect - TARG 1 long burst functionality modification register, Address offset: 0x202C */ + uint32_t RESERVED4[54]; /*!< Reserved, Address offset: 0x2030-0x2104 */ + __IO uint32_t AXI_TARG1_FN_MOD; /*!< AXI interconnect - TARG 1 issuing functionality modification register, Address offset: 0x2108 */ + uint32_t RESERVED5[959]; /*!< Reserved, Address offset: 0x210C-0x3004 */ + __IO uint32_t AXI_TARG2_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 2 bus matrix issuing functionality register, Address offset: 0x3008 */ + uint32_t RESERVED6[6]; /*!< Reserved, Address offset: 0x300C-0x3020 */ + __IO uint32_t AXI_TARG2_FN_MOD2; /*!< AXI interconnect - TARG 2 bus matrix functionality 2 register, Address offset: 0x3024 */ + uint32_t RESERVED7; /*!< Reserved, Address offset: 0x3028 */ + __IO uint32_t AXI_TARG2_FN_MOD_LB; /*!< AXI interconnect - TARG 2 long burst functionality modification register, Address offset: 0x302C */ + uint32_t RESERVED8[54]; /*!< Reserved, Address offset: 0x3030-0x3104 */ + __IO uint32_t AXI_TARG2_FN_MOD; /*!< AXI interconnect - TARG 2 issuing functionality modification register, Address offset: 0x3108 */ + uint32_t RESERVED9[959]; /*!< Reserved, Address offset: 0x310C-0x4004 */ + __IO uint32_t AXI_TARG3_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 3 bus matrix issuing functionality register, Address offset: 0x4008 */ + uint32_t RESERVED10[1023]; /*!< Reserved, Address offset: 0x400C-0x5004 */ + __IO uint32_t AXI_TARG4_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 4 bus matrix issuing functionality register, Address offset: 0x5008 */ + uint32_t RESERVED11[1023]; /*!< Reserved, Address offset: 0x500C-0x6004 */ + __IO uint32_t AXI_TARG5_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 5 bus matrix issuing functionality register, Address offset: 0x6008 */ + uint32_t RESERVED12[1023]; /*!< Reserved, Address offset: 0x600C-0x7004 */ + __IO uint32_t AXI_TARG6_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 6 bus matrix issuing functionality register, Address offset: 0x7008 */ + uint32_t RESERVED13[1023]; /*!< Reserved, Address offset: 0x700C-0x8004 */ + __IO uint32_t AXI_TARG7_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 7 bus matrix issuing functionality register, Address offset: 0x8008 */ + uint32_t RESERVED14[6]; /*!< Reserved, Address offset: 0x800C-0x8020 */ + __IO uint32_t AXI_TARG7_FN_MOD2; /*!< AXI interconnect - TARG 7 bus matrix functionality 2 register, Address offset: 0x8024 */ + uint32_t RESERVED15; /*!< Reserved, Address offset: 0x8028 */ + __IO uint32_t AXI_TARG7_FN_MOD_LB; /*!< AXI interconnect - TARG 7 long burst functionality modification register, Address offset: 0x802C */ + uint32_t RESERVED16[54]; /*!< Reserved, Address offset: 0x8030-0x8104 */ + __IO uint32_t AXI_TARG7_FN_MOD; /*!< AXI interconnect - TARG 7 issuing functionality modification register, Address offset: 0x8108 */ + uint32_t RESERVED17[959]; /*!< Reserved, Address offset: 0x810C-0x9004 */ + __IO uint32_t AXI_TARG8_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 8 bus matrix issuing functionality register, Address offset: 0x9008 */ + uint32_t RESERVED117[6]; /*!< Reserved, Address offset: 0x900C-0x9020 */ + __IO uint32_t AXI_TARG8_FN_MOD2; /*!< AXI interconnect - TARG 8 bus matrix functionality 2 register, Address offset: 0x9024 */ + uint32_t RESERVED118[56]; /*!< Reserved, Address offset: 0x9028-0x9104 */ + __IO uint32_t AXI_TARG8_FN_MOD; /*!< AXI interconnect - TARG 8 issuing functionality modification register, Address offset: 0x9108 */ + uint32_t RESERVED119[58310]; /*!< Reserved, Address offset: 0x910C-0x42020 */ + __IO uint32_t AXI_INI1_FN_MOD2; /*!< AXI interconnect - INI 1 functionality modification 2 register, Address offset: 0x42024 */ + __IO uint32_t AXI_INI1_FN_MOD_AHB; /*!< AXI interconnect - INI 1 AHB functionality modification register, Address offset: 0x42028 */ + uint32_t RESERVED18[53]; /*!< Reserved, Address offset: 0x4202C-0x420FC */ + __IO uint32_t AXI_INI1_READ_QOS; /*!< AXI interconnect - INI 1 read QoS register, Address offset: 0x42100 */ + __IO uint32_t AXI_INI1_WRITE_QOS; /*!< AXI interconnect - INI 1 write QoS register, Address offset: 0x42104 */ + __IO uint32_t AXI_INI1_FN_MOD; /*!< AXI interconnect - INI 1 issuing functionality modification register, Address offset: 0x42108 */ + uint32_t RESERVED19[1021]; /*!< Reserved, Address offset: 0x4210C-0x430FC */ + __IO uint32_t AXI_INI2_READ_QOS; /*!< AXI interconnect - INI 2 read QoS register, Address offset: 0x43100 */ + __IO uint32_t AXI_INI2_WRITE_QOS; /*!< AXI interconnect - INI 2 write QoS register, Address offset: 0x43104 */ + __IO uint32_t AXI_INI2_FN_MOD; /*!< AXI interconnect - INI 2 issuing functionality modification register, Address offset: 0x43108 */ + uint32_t RESERVED20[966]; /*!< Reserved, Address offset: 0x4310C-0x44020 */ + __IO uint32_t AXI_INI3_FN_MOD2; /*!< AXI interconnect - INI 3 functionality modification 2 register, Address offset: 0x44024 */ + __IO uint32_t AXI_INI3_FN_MOD_AHB; /*!< AXI interconnect - INI 3 AHB functionality modification register, Address offset: 0x44028 */ + uint32_t RESERVED21[53]; /*!< Reserved, Address offset: 0x4402C-0x440FC */ + __IO uint32_t AXI_INI3_READ_QOS; /*!< AXI interconnect - INI 3 read QoS register, Address offset: 0x44100 */ + __IO uint32_t AXI_INI3_WRITE_QOS; /*!< AXI interconnect - INI 3 write QoS register, Address offset: 0x44104 */ + __IO uint32_t AXI_INI3_FN_MOD; /*!< AXI interconnect - INI 3 issuing functionality modification register, Address offset: 0x44108 */ + uint32_t RESERVED22[1021]; /*!< Reserved, Address offset: 0x4410C-0x450FC */ + __IO uint32_t AXI_INI4_READ_QOS; /*!< AXI interconnect - INI 4 read QoS register, Address offset: 0x45100 */ + __IO uint32_t AXI_INI4_WRITE_QOS; /*!< AXI interconnect - INI 4 write QoS register, Address offset: 0x45104 */ + __IO uint32_t AXI_INI4_FN_MOD; /*!< AXI interconnect - INI 4 issuing functionality modification register, Address offset: 0x45108 */ + uint32_t RESERVED23[1021]; /*!< Reserved, Address offset: 0x4510C-0x460FC */ + __IO uint32_t AXI_INI5_READ_QOS; /*!< AXI interconnect - INI 5 read QoS register, Address offset: 0x46100 */ + __IO uint32_t AXI_INI5_WRITE_QOS; /*!< AXI interconnect - INI 5 write QoS register, Address offset: 0x46104 */ + __IO uint32_t AXI_INI5_FN_MOD; /*!< AXI interconnect - INI 5 issuing functionality modification register, Address offset: 0x46108 */ + uint32_t RESERVED24[1021]; /*!< Reserved, Address offset: 0x4610C-0x470FC */ + __IO uint32_t AXI_INI6_READ_QOS; /*!< AXI interconnect - INI 6 read QoS register, Address offset: 0x47100 */ + __IO uint32_t AXI_INI6_WRITE_QOS; /*!< AXI interconnect - INI 6 write QoS register, Address offset: 0x47104 */ + __IO uint32_t AXI_INI6_FN_MOD; /*!< AXI interconnect - INI 6 issuing functionality modification register, Address offset: 0x47108 */ + +} GPV_TypeDef; + +/** @addtogroup Peripheral_memory_map + * @{ + */ +#define D1_ITCMRAM_BASE (0x00000000UL) /*!< Base address of : 64KB RAM reserved for CPU execution/instruction accessible over ITCM */ +#define D1_ITCMICP_BASE (0x00100000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over ITCM */ +#define D1_DTCMRAM_BASE (0x20000000UL) /*!< Base address of : 128KB system data RAM accessible over DTCM */ +#define D1_AXIFLASH_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) embedded FLASH memory accessible over AXI */ +#define D1_AXIICP_BASE (0x1FF00000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over AXI */ +#define D1_AXISRAM1_BASE (0x24000000UL) /*!< Base address of : (up to 128KB) system data RAM1 accessible over over AXI */ +#define D1_AXISRAM2_BASE (0x24020000UL) /*!< Base address of : (up to 192KB) system data RAM2 accessible over over AXI to be shared with ITCM (64K granularity) */ +#define D1_AXISRAM_BASE D1_AXISRAM1_BASE /*!< Base address of : (up to 320KB) system data RAM1/2 accessible over over AXI */ + +#define D2_AHBSRAM1_BASE (0x30000000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ +#define D2_AHBSRAM2_BASE (0x30004000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ +#define D2_AHBSRAM_BASE D2_AHBSRAM1_BASE /*!< Base address of : (up to 32KB) system data RAM1/2 accessible over over AXI->AHB Bridge */ + +#define D3_BKPSRAM_BASE (0x38800000UL) /*!< Base address of : Backup SRAM(4 KB) over AXI->AHB Bridge */ +#define D3_SRAM_BASE (0x38000000UL) /*!< Base address of : Backup SRAM(16 KB) over AXI->AHB Bridge */ + +#define PERIPH_BASE (0x40000000UL) /*!< Base address of : AHB/APB Peripherals */ +#define OCTOSPI1_BASE (0x90000000UL) /*!< Base address of : OCTOSPI1 memories accessible over AXI */ +#define OCTOSPI2_BASE (0x70000000UL) /*!< Base address of : OCTOSPI2 memories accessible over AXI */ + +#define FLASH_BANK1_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) Flash Bank1 accessible over AXI */ +#define FLASH_END (0x080FFFFFUL) /*!< FLASH end address */ + + +/* Legacy define */ +#define FLASH_BASE FLASH_BANK1_BASE + +/*!< Device electronic signature memory map */ +#define UID_BASE (0x1FF1E800UL) /*!< Unique device ID register base address */ +#define FLASHSIZE_BASE (0x1FF1E880UL) /*!< FLASH Size register base address */ + + +/*!< Peripheral memory map */ +#define D2_APB1PERIPH_BASE PERIPH_BASE +#define D2_APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) +#define D2_AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) +#define D2_AHB2PERIPH_BASE (PERIPH_BASE + 0x08020000UL) + +#define D1_APB1PERIPH_BASE (PERIPH_BASE + 0x10000000UL) +#define D1_AHB1PERIPH_BASE (PERIPH_BASE + 0x12000000UL) + +#define D3_APB1PERIPH_BASE (PERIPH_BASE + 0x18000000UL) +#define D3_AHB1PERIPH_BASE (PERIPH_BASE + 0x18020000UL) + +/*!< Legacy Peripheral memory map */ +#define APB1PERIPH_BASE PERIPH_BASE +#define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) +#define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) +#define AHB2PERIPH_BASE (PERIPH_BASE + 0x08000000UL) + + +/*!< D1_AHB1PERIPH peripherals */ + +#define MDMA_BASE (D1_AHB1PERIPH_BASE + 0x0000UL) +#define DMA2D_BASE (D1_AHB1PERIPH_BASE + 0x1000UL) +#define FLASH_R_BASE (D1_AHB1PERIPH_BASE + 0x2000UL) +#define FMC_R_BASE (D1_AHB1PERIPH_BASE + 0x4000UL) +#define OCTOSPI1_R_BASE (D1_AHB1PERIPH_BASE + 0x5000UL) +#define DLYB_OCTOSPI1_BASE (D1_AHB1PERIPH_BASE + 0x6000UL) +#define SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x7000UL) +#define DLYB_SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x8000UL) +#define RAMECC1_BASE (D1_AHB1PERIPH_BASE + 0x9000UL) +#define OCTOSPI2_R_BASE (D1_AHB1PERIPH_BASE + 0xA000UL) +#define DLYB_OCTOSPI2_BASE (D1_AHB1PERIPH_BASE + 0xB000UL) +#define OCTOSPIM_BASE (D1_AHB1PERIPH_BASE + 0xB400UL) + +#define OTFDEC1_BASE (D1_AHB1PERIPH_BASE + 0xB800UL) +#define OTFDEC1_REGION1_BASE (OTFDEC1_BASE + 0x20UL) +#define OTFDEC1_REGION2_BASE (OTFDEC1_BASE + 0x50UL) +#define OTFDEC1_REGION3_BASE (OTFDEC1_BASE + 0x80UL) +#define OTFDEC1_REGION4_BASE (OTFDEC1_BASE + 0xB0UL) +#define OTFDEC2_BASE (D1_AHB1PERIPH_BASE + 0xBC00UL) +#define OTFDEC2_REGION1_BASE (OTFDEC2_BASE + 0x20UL) +#define OTFDEC2_REGION2_BASE (OTFDEC2_BASE + 0x50UL) +#define OTFDEC2_REGION3_BASE (OTFDEC2_BASE + 0x80UL) +#define OTFDEC2_REGION4_BASE (OTFDEC2_BASE + 0xB0UL) + +/*!< D2_AHB1PERIPH peripherals */ + +#define DMA1_BASE (D2_AHB1PERIPH_BASE + 0x0000UL) +#define DMA2_BASE (D2_AHB1PERIPH_BASE + 0x0400UL) +#define DMAMUX1_BASE (D2_AHB1PERIPH_BASE + 0x0800UL) +#define ADC1_BASE (D2_AHB1PERIPH_BASE + 0x2000UL) +#define ADC2_BASE (D2_AHB1PERIPH_BASE + 0x2100UL) +#define ADC12_COMMON_BASE (D2_AHB1PERIPH_BASE + 0x2300UL) +#define ETH_BASE (D2_AHB1PERIPH_BASE + 0x8000UL) +#define ETH_MAC_BASE (ETH_BASE) + +/*!< USB registers base address */ +#define USB1_OTG_HS_PERIPH_BASE (0x40040000UL) +#define USB_OTG_GLOBAL_BASE (0x000UL) +#define USB_OTG_DEVICE_BASE (0x800UL) +#define USB_OTG_IN_ENDPOINT_BASE (0x900UL) +#define USB_OTG_OUT_ENDPOINT_BASE (0xB00UL) +#define USB_OTG_EP_REG_SIZE (0x20UL) +#define USB_OTG_HOST_BASE (0x400UL) +#define USB_OTG_HOST_PORT_BASE (0x440UL) +#define USB_OTG_HOST_CHANNEL_BASE (0x500UL) +#define USB_OTG_HOST_CHANNEL_SIZE (0x20UL) +#define USB_OTG_PCGCCTL_BASE (0xE00UL) +#define USB_OTG_FIFO_BASE (0x1000UL) +#define USB_OTG_FIFO_SIZE (0x1000UL) + +/*!< D2_AHB2PERIPH peripherals */ + +#define DCMI_BASE (D2_AHB2PERIPH_BASE + 0x0000UL) +#define PSSI_BASE (D2_AHB2PERIPH_BASE + 0x0400UL) +#define CRYP_BASE (D2_AHB2PERIPH_BASE + 0x1000UL) +#define HASH_BASE (D2_AHB2PERIPH_BASE + 0x1400UL) +#define HASH_DIGEST_BASE (D2_AHB2PERIPH_BASE + 0x1710UL) +#define RNG_BASE (D2_AHB2PERIPH_BASE + 0x1800UL) +#define SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2400UL) +#define DLYB_SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2800UL) +#define RAMECC2_BASE (D2_AHB2PERIPH_BASE + 0x3000UL) +#define FMAC_BASE (D2_AHB2PERIPH_BASE + 0x4000UL) +#define CORDIC_BASE (D2_AHB2PERIPH_BASE + 0x4400UL) + +/*!< D3_AHB1PERIPH peripherals */ +#define GPIOA_BASE (D3_AHB1PERIPH_BASE + 0x0000UL) +#define GPIOB_BASE (D3_AHB1PERIPH_BASE + 0x0400UL) +#define GPIOC_BASE (D3_AHB1PERIPH_BASE + 0x0800UL) +#define GPIOD_BASE (D3_AHB1PERIPH_BASE + 0x0C00UL) +#define GPIOE_BASE (D3_AHB1PERIPH_BASE + 0x1000UL) +#define GPIOF_BASE (D3_AHB1PERIPH_BASE + 0x1400UL) +#define GPIOG_BASE (D3_AHB1PERIPH_BASE + 0x1800UL) +#define GPIOH_BASE (D3_AHB1PERIPH_BASE + 0x1C00UL) +#define GPIOJ_BASE (D3_AHB1PERIPH_BASE + 0x2400UL) +#define GPIOK_BASE (D3_AHB1PERIPH_BASE + 0x2800UL) +#define RCC_BASE (D3_AHB1PERIPH_BASE + 0x4400UL) +#define PWR_BASE (D3_AHB1PERIPH_BASE + 0x4800UL) +#define CRC_BASE (D3_AHB1PERIPH_BASE + 0x4C00UL) +#define BDMA_BASE (D3_AHB1PERIPH_BASE + 0x5400UL) +#define DMAMUX2_BASE (D3_AHB1PERIPH_BASE + 0x5800UL) +#define ADC3_BASE (D3_AHB1PERIPH_BASE + 0x6000UL) +#define ADC3_COMMON_BASE (D3_AHB1PERIPH_BASE + 0x6300UL) +#define HSEM_BASE (D3_AHB1PERIPH_BASE + 0x6400UL) +#define RAMECC3_BASE (D3_AHB1PERIPH_BASE + 0x7000UL) + +/*!< D1_APB1PERIPH peripherals */ +#define LTDC_BASE (D1_APB1PERIPH_BASE + 0x1000UL) +#define LTDC_Layer1_BASE (LTDC_BASE + 0x84UL) +#define LTDC_Layer2_BASE (LTDC_BASE + 0x104UL) +#define WWDG1_BASE (D1_APB1PERIPH_BASE + 0x3000UL) + +/*!< D2_APB1PERIPH peripherals */ +#define TIM2_BASE (D2_APB1PERIPH_BASE + 0x0000UL) +#define TIM3_BASE (D2_APB1PERIPH_BASE + 0x0400UL) +#define TIM4_BASE (D2_APB1PERIPH_BASE + 0x0800UL) +#define TIM5_BASE (D2_APB1PERIPH_BASE + 0x0C00UL) +#define TIM6_BASE (D2_APB1PERIPH_BASE + 0x1000UL) +#define TIM7_BASE (D2_APB1PERIPH_BASE + 0x1400UL) +#define TIM12_BASE (D2_APB1PERIPH_BASE + 0x1800UL) +#define TIM13_BASE (D2_APB1PERIPH_BASE + 0x1C00UL) +#define TIM14_BASE (D2_APB1PERIPH_BASE + 0x2000UL) +#define LPTIM1_BASE (D2_APB1PERIPH_BASE + 0x2400UL) + + +#define SPI2_BASE (D2_APB1PERIPH_BASE + 0x3800UL) +#define SPI3_BASE (D2_APB1PERIPH_BASE + 0x3C00UL) +#define SPDIFRX_BASE (D2_APB1PERIPH_BASE + 0x4000UL) +#define USART2_BASE (D2_APB1PERIPH_BASE + 0x4400UL) +#define USART3_BASE (D2_APB1PERIPH_BASE + 0x4800UL) +#define UART4_BASE (D2_APB1PERIPH_BASE + 0x4C00UL) +#define UART5_BASE (D2_APB1PERIPH_BASE + 0x5000UL) +#define I2C1_BASE (D2_APB1PERIPH_BASE + 0x5400UL) +#define I2C2_BASE (D2_APB1PERIPH_BASE + 0x5800UL) +#define I2C3_BASE (D2_APB1PERIPH_BASE + 0x5C00UL) +#define I2C5_BASE (D2_APB1PERIPH_BASE + 0x6400UL) +#define CEC_BASE (D2_APB1PERIPH_BASE + 0x6C00UL) +#define DAC1_BASE (D2_APB1PERIPH_BASE + 0x7400UL) +#define UART7_BASE (D2_APB1PERIPH_BASE + 0x7800UL) +#define UART8_BASE (D2_APB1PERIPH_BASE + 0x7C00UL) +#define CRS_BASE (D2_APB1PERIPH_BASE + 0x8400UL) +#define SWPMI1_BASE (D2_APB1PERIPH_BASE + 0x8800UL) +#define OPAMP_BASE (D2_APB1PERIPH_BASE + 0x9000UL) +#define OPAMP1_BASE (D2_APB1PERIPH_BASE + 0x9000UL) +#define OPAMP2_BASE (D2_APB1PERIPH_BASE + 0x9010UL) +#define MDIOS_BASE (D2_APB1PERIPH_BASE + 0x9400UL) +#define FDCAN1_BASE (D2_APB1PERIPH_BASE + 0xA000UL) +#define FDCAN2_BASE (D2_APB1PERIPH_BASE + 0xA400UL) +#define FDCAN_CCU_BASE (D2_APB1PERIPH_BASE + 0xA800UL) +#define SRAMCAN_BASE (D2_APB1PERIPH_BASE + 0xAC00UL) +#define FDCAN3_BASE (D2_APB1PERIPH_BASE + 0xD400UL) +#define TIM23_BASE (D2_APB1PERIPH_BASE + 0xE000UL) +#define TIM24_BASE (D2_APB1PERIPH_BASE + 0xE400UL) + +/*!< D2_APB2PERIPH peripherals */ + +#define TIM1_BASE (D2_APB2PERIPH_BASE + 0x0000UL) +#define TIM8_BASE (D2_APB2PERIPH_BASE + 0x0400UL) +#define USART1_BASE (D2_APB2PERIPH_BASE + 0x1000UL) +#define USART6_BASE (D2_APB2PERIPH_BASE + 0x1400UL) +#define UART9_BASE (D2_APB2PERIPH_BASE + 0x1800UL) +#define USART10_BASE (D2_APB2PERIPH_BASE + 0x1C00UL) +#define SPI1_BASE (D2_APB2PERIPH_BASE + 0x3000UL) +#define SPI4_BASE (D2_APB2PERIPH_BASE + 0x3400UL) +#define TIM15_BASE (D2_APB2PERIPH_BASE + 0x4000UL) +#define TIM16_BASE (D2_APB2PERIPH_BASE + 0x4400UL) +#define TIM17_BASE (D2_APB2PERIPH_BASE + 0x4800UL) +#define SPI5_BASE (D2_APB2PERIPH_BASE + 0x5000UL) +#define SAI1_BASE (D2_APB2PERIPH_BASE + 0x5800UL) +#define SAI1_Block_A_BASE (SAI1_BASE + 0x004UL) +#define SAI1_Block_B_BASE (SAI1_BASE + 0x024UL) +#define DFSDM1_BASE (D2_APB2PERIPH_BASE + 0x7800UL) +#define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00UL) +#define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20UL) +#define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40UL) +#define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60UL) +#define DFSDM1_Channel4_BASE (DFSDM1_BASE + 0x80UL) +#define DFSDM1_Channel5_BASE (DFSDM1_BASE + 0xA0UL) +#define DFSDM1_Channel6_BASE (DFSDM1_BASE + 0xC0UL) +#define DFSDM1_Channel7_BASE (DFSDM1_BASE + 0xE0UL) +#define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100UL) +#define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180UL) +#define DFSDM1_Filter2_BASE (DFSDM1_BASE + 0x200UL) +#define DFSDM1_Filter3_BASE (DFSDM1_BASE + 0x280UL) + + +/*!< D3_APB1PERIPH peripherals */ +#define EXTI_BASE (D3_APB1PERIPH_BASE + 0x0000UL) +#define EXTI_D1_BASE (EXTI_BASE + 0x0080UL) +#define EXTI_D2_BASE (EXTI_BASE + 0x00C0UL) +#define SYSCFG_BASE (D3_APB1PERIPH_BASE + 0x0400UL) +#define LPUART1_BASE (D3_APB1PERIPH_BASE + 0x0C00UL) +#define SPI6_BASE (D3_APB1PERIPH_BASE + 0x1400UL) +#define I2C4_BASE (D3_APB1PERIPH_BASE + 0x1C00UL) +#define LPTIM2_BASE (D3_APB1PERIPH_BASE + 0x2400UL) +#define LPTIM3_BASE (D3_APB1PERIPH_BASE + 0x2800UL) +#define LPTIM4_BASE (D3_APB1PERIPH_BASE + 0x2C00UL) +#define LPTIM5_BASE (D3_APB1PERIPH_BASE + 0x3000UL) +#define COMP12_BASE (D3_APB1PERIPH_BASE + 0x3800UL) +#define COMP1_BASE (COMP12_BASE + 0x0CUL) +#define COMP2_BASE (COMP12_BASE + 0x10UL) +#define VREFBUF_BASE (D3_APB1PERIPH_BASE + 0x3C00UL) +#define RTC_BASE (D3_APB1PERIPH_BASE + 0x4000UL) +#define IWDG1_BASE (D3_APB1PERIPH_BASE + 0x4800UL) + + +#define SAI4_BASE (D3_APB1PERIPH_BASE + 0x5400UL) +#define SAI4_Block_A_BASE (SAI4_BASE + 0x004UL) +#define SAI4_Block_B_BASE (SAI4_BASE + 0x024UL) + +#define DTS_BASE (D3_APB1PERIPH_BASE + 0x6800UL) + + + +#define BDMA_Channel0_BASE (BDMA_BASE + 0x0008UL) +#define BDMA_Channel1_BASE (BDMA_BASE + 0x001CUL) +#define BDMA_Channel2_BASE (BDMA_BASE + 0x0030UL) +#define BDMA_Channel3_BASE (BDMA_BASE + 0x0044UL) +#define BDMA_Channel4_BASE (BDMA_BASE + 0x0058UL) +#define BDMA_Channel5_BASE (BDMA_BASE + 0x006CUL) +#define BDMA_Channel6_BASE (BDMA_BASE + 0x0080UL) +#define BDMA_Channel7_BASE (BDMA_BASE + 0x0094UL) + +#define DMAMUX2_Channel0_BASE (DMAMUX2_BASE) +#define DMAMUX2_Channel1_BASE (DMAMUX2_BASE + 0x0004UL) +#define DMAMUX2_Channel2_BASE (DMAMUX2_BASE + 0x0008UL) +#define DMAMUX2_Channel3_BASE (DMAMUX2_BASE + 0x000CUL) +#define DMAMUX2_Channel4_BASE (DMAMUX2_BASE + 0x0010UL) +#define DMAMUX2_Channel5_BASE (DMAMUX2_BASE + 0x0014UL) +#define DMAMUX2_Channel6_BASE (DMAMUX2_BASE + 0x0018UL) +#define DMAMUX2_Channel7_BASE (DMAMUX2_BASE + 0x001CUL) + +#define DMAMUX2_RequestGenerator0_BASE (DMAMUX2_BASE + 0x0100UL) +#define DMAMUX2_RequestGenerator1_BASE (DMAMUX2_BASE + 0x0104UL) +#define DMAMUX2_RequestGenerator2_BASE (DMAMUX2_BASE + 0x0108UL) +#define DMAMUX2_RequestGenerator3_BASE (DMAMUX2_BASE + 0x010CUL) +#define DMAMUX2_RequestGenerator4_BASE (DMAMUX2_BASE + 0x0110UL) +#define DMAMUX2_RequestGenerator5_BASE (DMAMUX2_BASE + 0x0114UL) +#define DMAMUX2_RequestGenerator6_BASE (DMAMUX2_BASE + 0x0118UL) +#define DMAMUX2_RequestGenerator7_BASE (DMAMUX2_BASE + 0x011CUL) + +#define DMAMUX2_ChannelStatus_BASE (DMAMUX2_BASE + 0x0080UL) +#define DMAMUX2_RequestGenStatus_BASE (DMAMUX2_BASE + 0x0140UL) + +#define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) +#define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) +#define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) +#define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) +#define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) +#define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) +#define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) +#define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) + +#define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) +#define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) +#define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) +#define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) +#define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) +#define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) +#define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) +#define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) + +#define DMAMUX1_Channel0_BASE (DMAMUX1_BASE) +#define DMAMUX1_Channel1_BASE (DMAMUX1_BASE + 0x0004UL) +#define DMAMUX1_Channel2_BASE (DMAMUX1_BASE + 0x0008UL) +#define DMAMUX1_Channel3_BASE (DMAMUX1_BASE + 0x000CUL) +#define DMAMUX1_Channel4_BASE (DMAMUX1_BASE + 0x0010UL) +#define DMAMUX1_Channel5_BASE (DMAMUX1_BASE + 0x0014UL) +#define DMAMUX1_Channel6_BASE (DMAMUX1_BASE + 0x0018UL) +#define DMAMUX1_Channel7_BASE (DMAMUX1_BASE + 0x001CUL) +#define DMAMUX1_Channel8_BASE (DMAMUX1_BASE + 0x0020UL) +#define DMAMUX1_Channel9_BASE (DMAMUX1_BASE + 0x0024UL) +#define DMAMUX1_Channel10_BASE (DMAMUX1_BASE + 0x0028UL) +#define DMAMUX1_Channel11_BASE (DMAMUX1_BASE + 0x002CUL) +#define DMAMUX1_Channel12_BASE (DMAMUX1_BASE + 0x0030UL) +#define DMAMUX1_Channel13_BASE (DMAMUX1_BASE + 0x0034UL) +#define DMAMUX1_Channel14_BASE (DMAMUX1_BASE + 0x0038UL) +#define DMAMUX1_Channel15_BASE (DMAMUX1_BASE + 0x003CUL) + +#define DMAMUX1_RequestGenerator0_BASE (DMAMUX1_BASE + 0x0100UL) +#define DMAMUX1_RequestGenerator1_BASE (DMAMUX1_BASE + 0x0104UL) +#define DMAMUX1_RequestGenerator2_BASE (DMAMUX1_BASE + 0x0108UL) +#define DMAMUX1_RequestGenerator3_BASE (DMAMUX1_BASE + 0x010CUL) +#define DMAMUX1_RequestGenerator4_BASE (DMAMUX1_BASE + 0x0110UL) +#define DMAMUX1_RequestGenerator5_BASE (DMAMUX1_BASE + 0x0114UL) +#define DMAMUX1_RequestGenerator6_BASE (DMAMUX1_BASE + 0x0118UL) +#define DMAMUX1_RequestGenerator7_BASE (DMAMUX1_BASE + 0x011CUL) + +#define DMAMUX1_ChannelStatus_BASE (DMAMUX1_BASE + 0x0080UL) +#define DMAMUX1_RequestGenStatus_BASE (DMAMUX1_BASE + 0x0140UL) + +/*!< FMC Banks registers base address */ +#define FMC_Bank1_R_BASE (FMC_R_BASE + 0x0000UL) +#define FMC_Bank1E_R_BASE (FMC_R_BASE + 0x0104UL) +#define FMC_Bank2_R_BASE (FMC_R_BASE + 0x0060UL) +#define FMC_Bank3_R_BASE (FMC_R_BASE + 0x0080UL) +#define FMC_Bank5_6_R_BASE (FMC_R_BASE + 0x0140UL) + +/* Debug MCU registers base address */ +#define DBGMCU_BASE (0x5C001000UL) + +#define MDMA_Channel0_BASE (MDMA_BASE + 0x00000040UL) +#define MDMA_Channel1_BASE (MDMA_BASE + 0x00000080UL) +#define MDMA_Channel2_BASE (MDMA_BASE + 0x000000C0UL) +#define MDMA_Channel3_BASE (MDMA_BASE + 0x00000100UL) +#define MDMA_Channel4_BASE (MDMA_BASE + 0x00000140UL) +#define MDMA_Channel5_BASE (MDMA_BASE + 0x00000180UL) +#define MDMA_Channel6_BASE (MDMA_BASE + 0x000001C0UL) +#define MDMA_Channel7_BASE (MDMA_BASE + 0x00000200UL) +#define MDMA_Channel8_BASE (MDMA_BASE + 0x00000240UL) +#define MDMA_Channel9_BASE (MDMA_BASE + 0x00000280UL) +#define MDMA_Channel10_BASE (MDMA_BASE + 0x000002C0UL) +#define MDMA_Channel11_BASE (MDMA_BASE + 0x00000300UL) +#define MDMA_Channel12_BASE (MDMA_BASE + 0x00000340UL) +#define MDMA_Channel13_BASE (MDMA_BASE + 0x00000380UL) +#define MDMA_Channel14_BASE (MDMA_BASE + 0x000003C0UL) +#define MDMA_Channel15_BASE (MDMA_BASE + 0x00000400UL) + +#define RAMECC1_Monitor1_BASE (RAMECC1_BASE + 0x20UL) +#define RAMECC1_Monitor2_BASE (RAMECC1_BASE + 0x40UL) +#define RAMECC1_Monitor3_BASE (RAMECC1_BASE + 0x60UL) +#define RAMECC1_Monitor4_BASE (RAMECC1_BASE + 0x80UL) +#define RAMECC1_Monitor5_BASE (RAMECC1_BASE + 0xA0UL) +#define RAMECC1_Monitor6_BASE (RAMECC1_BASE + 0xC0UL) + +#define RAMECC2_Monitor1_BASE (RAMECC2_BASE + 0x20UL) +#define RAMECC2_Monitor2_BASE (RAMECC2_BASE + 0x40UL) +#define RAMECC2_Monitor3_BASE (RAMECC2_BASE + 0x60UL) + +#define RAMECC3_Monitor1_BASE (RAMECC3_BASE + 0x20UL) +#define RAMECC3_Monitor2_BASE (RAMECC3_BASE + 0x40UL) + + + +#define GPV_BASE (PERIPH_BASE + 0x11000000UL) /*!< GPV_BASE (PERIPH_BASE + 0x11000000UL) */ + +/** + * @} + */ + +/** @addtogroup Peripheral_declaration + * @{ + */ +#define TIM2 ((TIM_TypeDef *) TIM2_BASE) +#define TIM3 ((TIM_TypeDef *) TIM3_BASE) +#define TIM4 ((TIM_TypeDef *) TIM4_BASE) +#define TIM5 ((TIM_TypeDef *) TIM5_BASE) +#define TIM6 ((TIM_TypeDef *) TIM6_BASE) +#define TIM7 ((TIM_TypeDef *) TIM7_BASE) +#define TIM13 ((TIM_TypeDef *) TIM13_BASE) +#define TIM14 ((TIM_TypeDef *) TIM14_BASE) +#define VREFBUF ((VREFBUF_TypeDef *) VREFBUF_BASE) +#define RTC ((RTC_TypeDef *) RTC_BASE) +#define WWDG1 ((WWDG_TypeDef *) WWDG1_BASE) + + +#define IWDG1 ((IWDG_TypeDef *) IWDG1_BASE) +#define SPI2 ((SPI_TypeDef *) SPI2_BASE) +#define SPI3 ((SPI_TypeDef *) SPI3_BASE) +#define SPI4 ((SPI_TypeDef *) SPI4_BASE) +#define SPI5 ((SPI_TypeDef *) SPI5_BASE) +#define SPI6 ((SPI_TypeDef *) SPI6_BASE) +#define USART2 ((USART_TypeDef *) USART2_BASE) +#define USART3 ((USART_TypeDef *) USART3_BASE) +#define USART6 ((USART_TypeDef *) USART6_BASE) +#define USART10 ((USART_TypeDef *) USART10_BASE) +#define UART7 ((USART_TypeDef *) UART7_BASE) +#define UART8 ((USART_TypeDef *) UART8_BASE) +#define UART9 ((USART_TypeDef *) UART9_BASE) +#define CRS ((CRS_TypeDef *) CRS_BASE) +#define UART4 ((USART_TypeDef *) UART4_BASE) +#define UART5 ((USART_TypeDef *) UART5_BASE) +#define I2C1 ((I2C_TypeDef *) I2C1_BASE) +#define I2C2 ((I2C_TypeDef *) I2C2_BASE) +#define I2C3 ((I2C_TypeDef *) I2C3_BASE) +#define I2C4 ((I2C_TypeDef *) I2C4_BASE) +#define I2C5 ((I2C_TypeDef *) I2C5_BASE) +#define FDCAN1 ((FDCAN_GlobalTypeDef *) FDCAN1_BASE) +#define FDCAN2 ((FDCAN_GlobalTypeDef *) FDCAN2_BASE) +#define FDCAN_CCU ((FDCAN_ClockCalibrationUnit_TypeDef *) FDCAN_CCU_BASE) +#define FDCAN3 ((FDCAN_GlobalTypeDef *) FDCAN3_BASE) +#define TIM23 ((TIM_TypeDef *) TIM23_BASE) +#define TIM24 ((TIM_TypeDef *) TIM24_BASE) +#define CEC ((CEC_TypeDef *) CEC_BASE) +#define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE) +#define PWR ((PWR_TypeDef *) PWR_BASE) +#define DAC1 ((DAC_TypeDef *) DAC1_BASE) +#define LPUART1 ((USART_TypeDef *) LPUART1_BASE) +#define SWPMI1 ((SWPMI_TypeDef *) SWPMI1_BASE) +#define LPTIM2 ((LPTIM_TypeDef *) LPTIM2_BASE) +#define LPTIM3 ((LPTIM_TypeDef *) LPTIM3_BASE) +#define DTS ((DTS_TypeDef *) DTS_BASE) +#define LPTIM4 ((LPTIM_TypeDef *) LPTIM4_BASE) +#define LPTIM5 ((LPTIM_TypeDef *) LPTIM5_BASE) + +#define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) +#define COMP12 ((COMPOPT_TypeDef *) COMP12_BASE) +#define COMP1 ((COMP_TypeDef *) COMP1_BASE) +#define COMP2 ((COMP_TypeDef *) COMP2_BASE) +#define COMP12_COMMON ((COMP_Common_TypeDef *) COMP2_BASE) +#define OPAMP ((OPAMP_TypeDef *) OPAMP_BASE) +#define OPAMP1 ((OPAMP_TypeDef *) OPAMP1_BASE) +#define OPAMP2 ((OPAMP_TypeDef *) OPAMP2_BASE) + + +#define EXTI ((EXTI_TypeDef *) EXTI_BASE) +#define EXTI_D1 ((EXTI_Core_TypeDef *) EXTI_D1_BASE) +#define EXTI_D2 ((EXTI_Core_TypeDef *) EXTI_D2_BASE) +#define TIM1 ((TIM_TypeDef *) TIM1_BASE) +#define SPI1 ((SPI_TypeDef *) SPI1_BASE) +#define TIM8 ((TIM_TypeDef *) TIM8_BASE) +#define USART1 ((USART_TypeDef *) USART1_BASE) +#define TIM12 ((TIM_TypeDef *) TIM12_BASE) +#define TIM15 ((TIM_TypeDef *) TIM15_BASE) +#define TIM16 ((TIM_TypeDef *) TIM16_BASE) +#define TIM17 ((TIM_TypeDef *) TIM17_BASE) +#define SAI1 ((SAI_TypeDef *) SAI1_BASE) +#define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) +#define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) +#define SAI4 ((SAI_TypeDef *) SAI4_BASE) +#define SAI4_Block_A ((SAI_Block_TypeDef *)SAI4_Block_A_BASE) +#define SAI4_Block_B ((SAI_Block_TypeDef *)SAI4_Block_B_BASE) + +#define SPDIFRX ((SPDIFRX_TypeDef *) SPDIFRX_BASE) +#define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) +#define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) +#define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) +#define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) +#define DFSDM1_Channel4 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel4_BASE) +#define DFSDM1_Channel5 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel5_BASE) +#define DFSDM1_Channel6 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel6_BASE) +#define DFSDM1_Channel7 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel7_BASE) +#define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) +#define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) +#define DFSDM1_Filter2 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter2_BASE) +#define DFSDM1_Filter3 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter3_BASE) +#define DMA2D ((DMA2D_TypeDef *) DMA2D_BASE) +#define DCMI ((DCMI_TypeDef *) DCMI_BASE) +#define PSSI ((PSSI_TypeDef *) PSSI_BASE) +#define RCC ((RCC_TypeDef *) RCC_BASE) +#define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) +#define CRC ((CRC_TypeDef *) CRC_BASE) + +#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) +#define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) +#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) +#define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) +#define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) +#define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) +#define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) +#define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) +#define GPIOJ ((GPIO_TypeDef *) GPIOJ_BASE) +#define GPIOK ((GPIO_TypeDef *) GPIOK_BASE) + +#define ADC1 ((ADC_TypeDef *) ADC1_BASE) +#define ADC2 ((ADC_TypeDef *) ADC2_BASE) +#define ADC3 ((ADC_TypeDef *) ADC3_BASE) +#define ADC3_COMMON ((ADC_Common_TypeDef *) ADC3_COMMON_BASE) +#define ADC12_COMMON ((ADC_Common_TypeDef *) ADC12_COMMON_BASE) + +#define CRYP ((CRYP_TypeDef *) CRYP_BASE) +#define HASH ((HASH_TypeDef *) HASH_BASE) +#define HASH_DIGEST ((HASH_DIGEST_TypeDef *) HASH_DIGEST_BASE) +#define RNG ((RNG_TypeDef *) RNG_BASE) +#define SDMMC2 ((SDMMC_TypeDef *) SDMMC2_BASE) +#define DLYB_SDMMC2 ((DLYB_TypeDef *) DLYB_SDMMC2_BASE) +#define FMAC ((FMAC_TypeDef *) FMAC_BASE) +#define CORDIC ((CORDIC_TypeDef *) CORDIC_BASE) + +#define BDMA ((BDMA_TypeDef *) BDMA_BASE) +#define BDMA_Channel0 ((BDMA_Channel_TypeDef *) BDMA_Channel0_BASE) +#define BDMA_Channel1 ((BDMA_Channel_TypeDef *) BDMA_Channel1_BASE) +#define BDMA_Channel2 ((BDMA_Channel_TypeDef *) BDMA_Channel2_BASE) +#define BDMA_Channel3 ((BDMA_Channel_TypeDef *) BDMA_Channel3_BASE) +#define BDMA_Channel4 ((BDMA_Channel_TypeDef *) BDMA_Channel4_BASE) +#define BDMA_Channel5 ((BDMA_Channel_TypeDef *) BDMA_Channel5_BASE) +#define BDMA_Channel6 ((BDMA_Channel_TypeDef *) BDMA_Channel6_BASE) +#define BDMA_Channel7 ((BDMA_Channel_TypeDef *) BDMA_Channel7_BASE) + +#define RAMECC1 ((RAMECC_TypeDef *)RAMECC1_BASE) +#define RAMECC1_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor1_BASE) +#define RAMECC1_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor2_BASE) +#define RAMECC1_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor3_BASE) +#define RAMECC1_Monitor4 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor4_BASE) +#define RAMECC1_Monitor5 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor5_BASE) +#define RAMECC1_Monitor6 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor6_BASE) + +#define RAMECC2 ((RAMECC_TypeDef *)RAMECC2_BASE) +#define RAMECC2_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor1_BASE) +#define RAMECC2_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor2_BASE) +#define RAMECC2_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor3_BASE) + +#define RAMECC3 ((RAMECC_TypeDef *)RAMECC3_BASE) +#define RAMECC3_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor1_BASE) +#define RAMECC3_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor2_BASE) + +#define DMAMUX2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_BASE) +#define DMAMUX2_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel0_BASE) +#define DMAMUX2_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel1_BASE) +#define DMAMUX2_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel2_BASE) +#define DMAMUX2_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel3_BASE) +#define DMAMUX2_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel4_BASE) +#define DMAMUX2_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel5_BASE) +#define DMAMUX2_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel6_BASE) +#define DMAMUX2_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel7_BASE) + + +#define DMAMUX2_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator0_BASE) +#define DMAMUX2_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator1_BASE) +#define DMAMUX2_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator2_BASE) +#define DMAMUX2_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator3_BASE) +#define DMAMUX2_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator4_BASE) +#define DMAMUX2_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator5_BASE) +#define DMAMUX2_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator6_BASE) +#define DMAMUX2_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator7_BASE) + +#define DMAMUX2_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX2_ChannelStatus_BASE) +#define DMAMUX2_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX2_RequestGenStatus_BASE) + +#define DMA2 ((DMA_TypeDef *) DMA2_BASE) +#define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) +#define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) +#define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) +#define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) +#define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) +#define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) +#define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) +#define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) + +#define DMA1 ((DMA_TypeDef *) DMA1_BASE) +#define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) +#define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) +#define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) +#define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) +#define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) +#define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) +#define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) +#define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) + + +#define DMAMUX1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_BASE) +#define DMAMUX1_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel0_BASE) +#define DMAMUX1_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel1_BASE) +#define DMAMUX1_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel2_BASE) +#define DMAMUX1_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel3_BASE) +#define DMAMUX1_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel4_BASE) +#define DMAMUX1_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel5_BASE) +#define DMAMUX1_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel6_BASE) +#define DMAMUX1_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel7_BASE) +#define DMAMUX1_Channel8 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel8_BASE) +#define DMAMUX1_Channel9 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel9_BASE) +#define DMAMUX1_Channel10 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel10_BASE) +#define DMAMUX1_Channel11 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel11_BASE) +#define DMAMUX1_Channel12 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel12_BASE) +#define DMAMUX1_Channel13 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel13_BASE) +#define DMAMUX1_Channel14 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel14_BASE) +#define DMAMUX1_Channel15 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel15_BASE) + +#define DMAMUX1_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator0_BASE) +#define DMAMUX1_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator1_BASE) +#define DMAMUX1_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator2_BASE) +#define DMAMUX1_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator3_BASE) +#define DMAMUX1_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator4_BASE) +#define DMAMUX1_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator5_BASE) +#define DMAMUX1_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator6_BASE) +#define DMAMUX1_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator7_BASE) + +#define DMAMUX1_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX1_ChannelStatus_BASE) +#define DMAMUX1_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX1_RequestGenStatus_BASE) + + +#define FMC_Bank1_R ((FMC_Bank1_TypeDef *) FMC_Bank1_R_BASE) +#define FMC_Bank1E_R ((FMC_Bank1E_TypeDef *) FMC_Bank1E_R_BASE) +#define FMC_Bank2_R ((FMC_Bank2_TypeDef *) FMC_Bank2_R_BASE) +#define FMC_Bank3_R ((FMC_Bank3_TypeDef *) FMC_Bank3_R_BASE) +#define FMC_Bank5_6_R ((FMC_Bank5_6_TypeDef *) FMC_Bank5_6_R_BASE) + +#define OCTOSPI1 ((OCTOSPI_TypeDef *) OCTOSPI1_R_BASE) +#define DLYB_OCTOSPI1 ((DLYB_TypeDef *) DLYB_OCTOSPI1_BASE) +#define OCTOSPI2 ((OCTOSPI_TypeDef *) OCTOSPI2_R_BASE) +#define DLYB_OCTOSPI2 ((DLYB_TypeDef *) DLYB_OCTOSPI2_BASE) +#define OCTOSPIM ((OCTOSPIM_TypeDef *) OCTOSPIM_BASE) + +#define OTFDEC1 ((OTFDEC_TypeDef *) OTFDEC1_BASE) +#define OTFDEC1_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION1_BASE) +#define OTFDEC1_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION2_BASE) +#define OTFDEC1_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION3_BASE) +#define OTFDEC1_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION4_BASE) + +#define OTFDEC2 ((OTFDEC_TypeDef *) OTFDEC2_BASE) +#define OTFDEC2_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION1_BASE) +#define OTFDEC2_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION2_BASE) +#define OTFDEC2_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION3_BASE) +#define OTFDEC2_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION4_BASE) + +#define SDMMC1 ((SDMMC_TypeDef *) SDMMC1_BASE) +#define DLYB_SDMMC1 ((DLYB_TypeDef *) DLYB_SDMMC1_BASE) + +#define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) + +#define HSEM ((HSEM_TypeDef *) HSEM_BASE) +#define HSEM_COMMON ((HSEM_Common_TypeDef *) (HSEM_BASE + 0x100UL)) + +#define LTDC ((LTDC_TypeDef *)LTDC_BASE) +#define LTDC_Layer1 ((LTDC_Layer_TypeDef *)LTDC_Layer1_BASE) +#define LTDC_Layer2 ((LTDC_Layer_TypeDef *)LTDC_Layer2_BASE) + +#define MDIOS ((MDIOS_TypeDef *) MDIOS_BASE) + +#define ETH ((ETH_TypeDef *)ETH_BASE) +#define MDMA ((MDMA_TypeDef *)MDMA_BASE) +#define MDMA_Channel0 ((MDMA_Channel_TypeDef *)MDMA_Channel0_BASE) +#define MDMA_Channel1 ((MDMA_Channel_TypeDef *)MDMA_Channel1_BASE) +#define MDMA_Channel2 ((MDMA_Channel_TypeDef *)MDMA_Channel2_BASE) +#define MDMA_Channel3 ((MDMA_Channel_TypeDef *)MDMA_Channel3_BASE) +#define MDMA_Channel4 ((MDMA_Channel_TypeDef *)MDMA_Channel4_BASE) +#define MDMA_Channel5 ((MDMA_Channel_TypeDef *)MDMA_Channel5_BASE) +#define MDMA_Channel6 ((MDMA_Channel_TypeDef *)MDMA_Channel6_BASE) +#define MDMA_Channel7 ((MDMA_Channel_TypeDef *)MDMA_Channel7_BASE) +#define MDMA_Channel8 ((MDMA_Channel_TypeDef *)MDMA_Channel8_BASE) +#define MDMA_Channel9 ((MDMA_Channel_TypeDef *)MDMA_Channel9_BASE) +#define MDMA_Channel10 ((MDMA_Channel_TypeDef *)MDMA_Channel10_BASE) +#define MDMA_Channel11 ((MDMA_Channel_TypeDef *)MDMA_Channel11_BASE) +#define MDMA_Channel12 ((MDMA_Channel_TypeDef *)MDMA_Channel12_BASE) +#define MDMA_Channel13 ((MDMA_Channel_TypeDef *)MDMA_Channel13_BASE) +#define MDMA_Channel14 ((MDMA_Channel_TypeDef *)MDMA_Channel14_BASE) +#define MDMA_Channel15 ((MDMA_Channel_TypeDef *)MDMA_Channel15_BASE) + + +#define USB1_OTG_HS ((USB_OTG_GlobalTypeDef *) USB1_OTG_HS_PERIPH_BASE) + +/* Legacy defines */ +#define USB_OTG_HS USB1_OTG_HS +#define USB_OTG_HS_PERIPH_BASE USB1_OTG_HS_PERIPH_BASE + +#define GPV ((GPV_TypeDef *) GPV_BASE) + +/** + * @} + */ + +/** @addtogroup Exported_constants + * @{ + */ + + /** @addtogroup Peripheral_Registers_Bits_Definition + * @{ + */ + +/******************************************************************************/ +/* Peripheral Registers_Bits_Definition */ +/******************************************************************************/ + +/******************************************************************************/ +/* */ +/* Analog to Digital Converter */ +/* */ +/******************************************************************************/ +/******************************* ADC VERSION ********************************/ +#define ADC_VER_V5_V90 +/******************** Bit definition for ADC_ISR register ********************/ +#define ADC_ISR_ADRDY_Pos (0U) +#define ADC_ISR_ADRDY_Msk (0x1UL << ADC_ISR_ADRDY_Pos) /*!< 0x00000001 */ +#define ADC_ISR_ADRDY ADC_ISR_ADRDY_Msk /*!< ADC Ready (ADRDY) flag */ +#define ADC_ISR_EOSMP_Pos (1U) +#define ADC_ISR_EOSMP_Msk (0x1UL << ADC_ISR_EOSMP_Pos) /*!< 0x00000002 */ +#define ADC_ISR_EOSMP ADC_ISR_EOSMP_Msk /*!< ADC End of Sampling flag */ +#define ADC_ISR_EOC_Pos (2U) +#define ADC_ISR_EOC_Msk (0x1UL << ADC_ISR_EOC_Pos) /*!< 0x00000004 */ +#define ADC_ISR_EOC ADC_ISR_EOC_Msk /*!< ADC End of Regular Conversion flag */ +#define ADC_ISR_EOS_Pos (3U) +#define ADC_ISR_EOS_Msk (0x1UL << ADC_ISR_EOS_Pos) /*!< 0x00000008 */ +#define ADC_ISR_EOS ADC_ISR_EOS_Msk /*!< ADC End of Regular sequence of Conversions flag */ +#define ADC_ISR_OVR_Pos (4U) +#define ADC_ISR_OVR_Msk (0x1UL << ADC_ISR_OVR_Pos) /*!< 0x00000010 */ +#define ADC_ISR_OVR ADC_ISR_OVR_Msk /*!< ADC overrun flag */ +#define ADC_ISR_JEOC_Pos (5U) +#define ADC_ISR_JEOC_Msk (0x1UL << ADC_ISR_JEOC_Pos) /*!< 0x00000020 */ +#define ADC_ISR_JEOC ADC_ISR_JEOC_Msk /*!< ADC End of Injected Conversion flag */ +#define ADC_ISR_JEOS_Pos (6U) +#define ADC_ISR_JEOS_Msk (0x1UL << ADC_ISR_JEOS_Pos) /*!< 0x00000040 */ +#define ADC_ISR_JEOS ADC_ISR_JEOS_Msk /*!< ADC End of Injected sequence of Conversions flag */ +#define ADC_ISR_AWD1_Pos (7U) +#define ADC_ISR_AWD1_Msk (0x1UL << ADC_ISR_AWD1_Pos) /*!< 0x00000080 */ +#define ADC_ISR_AWD1 ADC_ISR_AWD1_Msk /*!< ADC Analog watchdog 1 flag */ +#define ADC_ISR_AWD2_Pos (8U) +#define ADC_ISR_AWD2_Msk (0x1UL << ADC_ISR_AWD2_Pos) /*!< 0x00000100 */ +#define ADC_ISR_AWD2 ADC_ISR_AWD2_Msk /*!< ADC Analog watchdog 2 flag */ +#define ADC_ISR_AWD3_Pos (9U) +#define ADC_ISR_AWD3_Msk (0x1UL << ADC_ISR_AWD3_Pos) /*!< 0x00000200 */ +#define ADC_ISR_AWD3 ADC_ISR_AWD3_Msk /*!< ADC Analog watchdog 3 flag */ +#define ADC_ISR_JQOVF_Pos (10U) +#define ADC_ISR_JQOVF_Msk (0x1UL << ADC_ISR_JQOVF_Pos) /*!< 0x00000400 */ +#define ADC_ISR_JQOVF ADC_ISR_JQOVF_Msk /*!< ADC Injected Context Queue Overflow flag */ +#define ADC_ISR_LDORDY_Pos (12U) +#define ADC_ISR_LDORDY_Msk (0x1UL << ADC_ISR_LDORDY_Pos) /*!< 0x00001000 */ +#define ADC_ISR_LDORDY ADC_ISR_LDORDY_Msk /*!< ADC LDO Ready (LDORDY) flag */ + +/******************** Bit definition for ADC_IER register ********************/ +#define ADC_IER_ADRDYIE_Pos (0U) +#define ADC_IER_ADRDYIE_Msk (0x1UL << ADC_IER_ADRDYIE_Pos) /*!< 0x00000001 */ +#define ADC_IER_ADRDYIE ADC_IER_ADRDYIE_Msk /*!< ADC Ready (ADRDY) interrupt source */ +#define ADC_IER_EOSMPIE_Pos (1U) +#define ADC_IER_EOSMPIE_Msk (0x1UL << ADC_IER_EOSMPIE_Pos) /*!< 0x00000002 */ +#define ADC_IER_EOSMPIE ADC_IER_EOSMPIE_Msk /*!< ADC End of Sampling interrupt source */ +#define ADC_IER_EOCIE_Pos (2U) +#define ADC_IER_EOCIE_Msk (0x1UL << ADC_IER_EOCIE_Pos) /*!< 0x00000004 */ +#define ADC_IER_EOCIE ADC_IER_EOCIE_Msk /*!< ADC End of Regular Conversion interrupt source */ +#define ADC_IER_EOSIE_Pos (3U) +#define ADC_IER_EOSIE_Msk (0x1UL << ADC_IER_EOSIE_Pos) /*!< 0x00000008 */ +#define ADC_IER_EOSIE ADC_IER_EOSIE_Msk /*!< ADC End of Regular sequence of Conversions interrupt source */ +#define ADC_IER_OVRIE_Pos (4U) +#define ADC_IER_OVRIE_Msk (0x1UL << ADC_IER_OVRIE_Pos) /*!< 0x00000010 */ +#define ADC_IER_OVRIE ADC_IER_OVRIE_Msk /*!< ADC overrun interrupt source */ +#define ADC_IER_JEOCIE_Pos (5U) +#define ADC_IER_JEOCIE_Msk (0x1UL << ADC_IER_JEOCIE_Pos) /*!< 0x00000020 */ +#define ADC_IER_JEOCIE ADC_IER_JEOCIE_Msk /*!< ADC End of Injected Conversion interrupt source */ +#define ADC_IER_JEOSIE_Pos (6U) +#define ADC_IER_JEOSIE_Msk (0x1UL << ADC_IER_JEOSIE_Pos) /*!< 0x00000040 */ +#define ADC_IER_JEOSIE ADC_IER_JEOSIE_Msk /*!< ADC End of Injected sequence of Conversions interrupt source */ +#define ADC_IER_AWD1IE_Pos (7U) +#define ADC_IER_AWD1IE_Msk (0x1UL << ADC_IER_AWD1IE_Pos) /*!< 0x00000080 */ +#define ADC_IER_AWD1IE ADC_IER_AWD1IE_Msk /*!< ADC Analog watchdog 1 interrupt source */ +#define ADC_IER_AWD2IE_Pos (8U) +#define ADC_IER_AWD2IE_Msk (0x1UL << ADC_IER_AWD2IE_Pos) /*!< 0x00000100 */ +#define ADC_IER_AWD2IE ADC_IER_AWD2IE_Msk /*!< ADC Analog watchdog 2 interrupt source */ +#define ADC_IER_AWD3IE_Pos (9U) +#define ADC_IER_AWD3IE_Msk (0x1UL << ADC_IER_AWD3IE_Pos) /*!< 0x00000200 */ +#define ADC_IER_AWD3IE ADC_IER_AWD3IE_Msk /*!< ADC Analog watchdog 3 interrupt source */ +#define ADC_IER_JQOVFIE_Pos (10U) +#define ADC_IER_JQOVFIE_Msk (0x1UL << ADC_IER_JQOVFIE_Pos) /*!< 0x00000400 */ +#define ADC_IER_JQOVFIE ADC_IER_JQOVFIE_Msk /*!< ADC Injected Context Queue Overflow interrupt source */ + +/******************** Bit definition for ADC_CR register ********************/ +#define ADC_CR_ADEN_Pos (0U) +#define ADC_CR_ADEN_Msk (0x1UL << ADC_CR_ADEN_Pos) /*!< 0x00000001 */ +#define ADC_CR_ADEN ADC_CR_ADEN_Msk /*!< ADC Enable control */ +#define ADC_CR_ADDIS_Pos (1U) +#define ADC_CR_ADDIS_Msk (0x1UL << ADC_CR_ADDIS_Pos) /*!< 0x00000002 */ +#define ADC_CR_ADDIS ADC_CR_ADDIS_Msk /*!< ADC Disable command */ +#define ADC_CR_ADSTART_Pos (2U) +#define ADC_CR_ADSTART_Msk (0x1UL << ADC_CR_ADSTART_Pos) /*!< 0x00000004 */ +#define ADC_CR_ADSTART ADC_CR_ADSTART_Msk /*!< ADC Start of Regular conversion */ +#define ADC_CR_JADSTART_Pos (3U) +#define ADC_CR_JADSTART_Msk (0x1UL << ADC_CR_JADSTART_Pos) /*!< 0x00000008 */ +#define ADC_CR_JADSTART ADC_CR_JADSTART_Msk /*!< ADC Start of injected conversion */ +#define ADC_CR_ADSTP_Pos (4U) +#define ADC_CR_ADSTP_Msk (0x1UL << ADC_CR_ADSTP_Pos) /*!< 0x00000010 */ +#define ADC_CR_ADSTP ADC_CR_ADSTP_Msk /*!< ADC Stop of Regular conversion */ +#define ADC_CR_JADSTP_Pos (5U) +#define ADC_CR_JADSTP_Msk (0x1UL << ADC_CR_JADSTP_Pos) /*!< 0x00000020 */ +#define ADC_CR_JADSTP ADC_CR_JADSTP_Msk /*!< ADC Stop of injected conversion */ +#define ADC_CR_BOOST_Pos (8U) +#define ADC_CR_BOOST_Msk (0x3UL << ADC_CR_BOOST_Pos) /*!< 0x00000300 */ +#define ADC_CR_BOOST ADC_CR_BOOST_Msk /*!< ADC Boost Mode configuration */ +#define ADC_CR_BOOST_0 (0x1UL << ADC_CR_BOOST_Pos) /*!< 0x00000100 */ +#define ADC_CR_BOOST_1 (0x2UL << ADC_CR_BOOST_Pos) /*!< 0x00000200 */ +#define ADC_CR_ADCALLIN_Pos (16U) +#define ADC_CR_ADCALLIN_Msk (0x1UL << ADC_CR_ADCALLIN_Pos) /*!< 0x00010000 */ +#define ADC_CR_ADCALLIN ADC_CR_ADCALLIN_Msk /*!< ADC Linearity calibration */ +#define ADC_CR_LINCALRDYW1_Pos (22U) +#define ADC_CR_LINCALRDYW1_Msk (0x1UL << ADC_CR_LINCALRDYW1_Pos) /*!< 0x00400000 */ +#define ADC_CR_LINCALRDYW1 ADC_CR_LINCALRDYW1_Msk /*!< ADC Linearity calibration ready Word 1 */ +#define ADC_CR_LINCALRDYW2_Pos (23U) +#define ADC_CR_LINCALRDYW2_Msk (0x1UL << ADC_CR_LINCALRDYW2_Pos) /*!< 0x00800000 */ +#define ADC_CR_LINCALRDYW2 ADC_CR_LINCALRDYW2_Msk /*!< ADC Linearity calibration ready Word 2 */ +#define ADC_CR_LINCALRDYW3_Pos (24U) +#define ADC_CR_LINCALRDYW3_Msk (0x1UL << ADC_CR_LINCALRDYW3_Pos) /*!< 0x01000000 */ +#define ADC_CR_LINCALRDYW3 ADC_CR_LINCALRDYW3_Msk /*!< ADC Linearity calibration ready Word 3 */ +#define ADC_CR_LINCALRDYW4_Pos (25U) +#define ADC_CR_LINCALRDYW4_Msk (0x1UL << ADC_CR_LINCALRDYW4_Pos) /*!< 0x02000000 */ +#define ADC_CR_LINCALRDYW4 ADC_CR_LINCALRDYW4_Msk /*!< ADC Linearity calibration ready Word 4 */ +#define ADC_CR_LINCALRDYW5_Pos (26U) +#define ADC_CR_LINCALRDYW5_Msk (0x1UL << ADC_CR_LINCALRDYW5_Pos) /*!< 0x04000000 */ +#define ADC_CR_LINCALRDYW5 ADC_CR_LINCALRDYW5_Msk /*!< ADC Linearity calibration ready Word 5 */ +#define ADC_CR_LINCALRDYW6_Pos (27U) +#define ADC_CR_LINCALRDYW6_Msk (0x1UL << ADC_CR_LINCALRDYW6_Pos) /*!< 0x08000000 */ +#define ADC_CR_LINCALRDYW6 ADC_CR_LINCALRDYW6_Msk /*!< ADC Linearity calibration ready Word 6 */ +#define ADC_CR_ADVREGEN_Pos (28U) +#define ADC_CR_ADVREGEN_Msk (0x1UL << ADC_CR_ADVREGEN_Pos) /*!< 0x10000000 */ +#define ADC_CR_ADVREGEN ADC_CR_ADVREGEN_Msk /*!< ADC Voltage regulator Enable */ +#define ADC_CR_DEEPPWD_Pos (29U) +#define ADC_CR_DEEPPWD_Msk (0x1UL << ADC_CR_DEEPPWD_Pos) /*!< 0x20000000 */ +#define ADC_CR_DEEPPWD ADC_CR_DEEPPWD_Msk /*!< ADC Deep power down Enable */ +#define ADC_CR_ADCALDIF_Pos (30U) +#define ADC_CR_ADCALDIF_Msk (0x1UL << ADC_CR_ADCALDIF_Pos) /*!< 0x40000000 */ +#define ADC_CR_ADCALDIF ADC_CR_ADCALDIF_Msk /*!< ADC Differential Mode for calibration */ +#define ADC_CR_ADCAL_Pos (31U) +#define ADC_CR_ADCAL_Msk (0x1UL << ADC_CR_ADCAL_Pos) /*!< 0x80000000 */ +#define ADC_CR_ADCAL ADC_CR_ADCAL_Msk /*!< ADC Calibration */ + +/******************** Bit definition for ADC_CFGR register ********************/ +#define ADC_CFGR_DMNGT_Pos (0U) +#define ADC_CFGR_DMNGT_Msk (0x3UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000003 */ +#define ADC_CFGR_DMNGT ADC_CFGR_DMNGT_Msk /*!< ADC Data Management configuration */ +#define ADC_CFGR_DMNGT_0 (0x1UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000001 */ +#define ADC_CFGR_DMNGT_1 (0x2UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000002 */ + +#define ADC_CFGR_RES_Pos (2U) +#define ADC_CFGR_RES_Msk (0x7UL << ADC_CFGR_RES_Pos) /*!< 0x0000001C */ +#define ADC_CFGR_RES ADC_CFGR_RES_Msk /*!< ADC Data resolution */ +#define ADC_CFGR_RES_0 (0x1UL << ADC_CFGR_RES_Pos) /*!< 0x00000004 */ +#define ADC_CFGR_RES_1 (0x2UL << ADC_CFGR_RES_Pos) /*!< 0x00000008 */ +#define ADC_CFGR_RES_2 (0x4UL << ADC_CFGR_RES_Pos) /*!< 0x00000010 */ + +#define ADC_CFGR_EXTSEL_Pos (5U) +#define ADC_CFGR_EXTSEL_Msk (0x1FUL << ADC_CFGR_EXTSEL_Pos) /*!< 0x000003E0 */ +#define ADC_CFGR_EXTSEL ADC_CFGR_EXTSEL_Msk /*!< ADC External trigger selection for regular group */ +#define ADC_CFGR_EXTSEL_0 (0x01UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000020 */ +#define ADC_CFGR_EXTSEL_1 (0x02UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000040 */ +#define ADC_CFGR_EXTSEL_2 (0x04UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000080 */ +#define ADC_CFGR_EXTSEL_3 (0x08UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000100 */ +#define ADC_CFGR_EXTSEL_4 (0x10UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000200 */ + +#define ADC_CFGR_EXTEN_Pos (10U) +#define ADC_CFGR_EXTEN_Msk (0x3UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000C00 */ +#define ADC_CFGR_EXTEN ADC_CFGR_EXTEN_Msk /*!< ADC External trigger enable and polarity selection for regular channels */ +#define ADC_CFGR_EXTEN_0 (0x1UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000400 */ +#define ADC_CFGR_EXTEN_1 (0x2UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000800 */ + +#define ADC_CFGR_OVRMOD_Pos (12U) +#define ADC_CFGR_OVRMOD_Msk (0x1UL << ADC_CFGR_OVRMOD_Pos) /*!< 0x00001000 */ +#define ADC_CFGR_OVRMOD ADC_CFGR_OVRMOD_Msk /*!< ADC overrun mode */ +#define ADC_CFGR_CONT_Pos (13U) +#define ADC_CFGR_CONT_Msk (0x1UL << ADC_CFGR_CONT_Pos) /*!< 0x00002000 */ +#define ADC_CFGR_CONT ADC_CFGR_CONT_Msk /*!< ADC Single/continuous conversion mode for regular conversion */ +#define ADC_CFGR_AUTDLY_Pos (14U) +#define ADC_CFGR_AUTDLY_Msk (0x1UL << ADC_CFGR_AUTDLY_Pos) /*!< 0x00004000 */ +#define ADC_CFGR_AUTDLY ADC_CFGR_AUTDLY_Msk /*!< ADC Delayed conversion mode */ + +#define ADC_CFGR_DISCEN_Pos (16U) +#define ADC_CFGR_DISCEN_Msk (0x1UL << ADC_CFGR_DISCEN_Pos) /*!< 0x00010000 */ +#define ADC_CFGR_DISCEN ADC_CFGR_DISCEN_Msk /*!< ADC Discontinuous mode for regular channels */ + +#define ADC_CFGR_DISCNUM_Pos (17U) +#define ADC_CFGR_DISCNUM_Msk (0x7UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x000E0000 */ +#define ADC_CFGR_DISCNUM ADC_CFGR_DISCNUM_Msk /*!< ADC Discontinuous mode channel count */ +#define ADC_CFGR_DISCNUM_0 (0x1UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00020000 */ +#define ADC_CFGR_DISCNUM_1 (0x2UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00040000 */ +#define ADC_CFGR_DISCNUM_2 (0x4UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00080000 */ + +#define ADC_CFGR_JDISCEN_Pos (20U) +#define ADC_CFGR_JDISCEN_Msk (0x1UL << ADC_CFGR_JDISCEN_Pos) /*!< 0x00100000 */ +#define ADC_CFGR_JDISCEN ADC_CFGR_JDISCEN_Msk /*!< ADC Discontinuous mode on injected channels */ +#define ADC_CFGR_JQM_Pos (21U) +#define ADC_CFGR_JQM_Msk (0x1UL << ADC_CFGR_JQM_Pos) /*!< 0x00200000 */ +#define ADC_CFGR_JQM ADC_CFGR_JQM_Msk /*!< ADC JSQR Queue mode */ +#define ADC_CFGR_AWD1SGL_Pos (22U) +#define ADC_CFGR_AWD1SGL_Msk (0x1UL << ADC_CFGR_AWD1SGL_Pos) /*!< 0x00400000 */ +#define ADC_CFGR_AWD1SGL ADC_CFGR_AWD1SGL_Msk /*!< Enable the watchdog 1 on a single channel or on all channels */ +#define ADC_CFGR_AWD1EN_Pos (23U) +#define ADC_CFGR_AWD1EN_Msk (0x1UL << ADC_CFGR_AWD1EN_Pos) /*!< 0x00800000 */ +#define ADC_CFGR_AWD1EN ADC_CFGR_AWD1EN_Msk /*!< ADC Analog watchdog 1 enable on regular Channels */ +#define ADC_CFGR_JAWD1EN_Pos (24U) +#define ADC_CFGR_JAWD1EN_Msk (0x1UL << ADC_CFGR_JAWD1EN_Pos) /*!< 0x01000000 */ +#define ADC_CFGR_JAWD1EN ADC_CFGR_JAWD1EN_Msk /*!< ADC Analog watchdog 1 enable on injected Channels */ +#define ADC_CFGR_JAUTO_Pos (25U) +#define ADC_CFGR_JAUTO_Msk (0x1UL << ADC_CFGR_JAUTO_Pos) /*!< 0x02000000 */ +#define ADC_CFGR_JAUTO ADC_CFGR_JAUTO_Msk /*!< ADC Automatic injected group conversion */ + +#define ADC_CFGR_AWD1CH_Pos (26U) +#define ADC_CFGR_AWD1CH_Msk (0x1FUL << ADC_CFGR_AWD1CH_Pos) /*!< 0x7C000000 */ +#define ADC_CFGR_AWD1CH ADC_CFGR_AWD1CH_Msk /*!< ADC Analog watchdog 1 Channel selection */ +#define ADC_CFGR_AWD1CH_0 (0x01UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x04000000 */ +#define ADC_CFGR_AWD1CH_1 (0x02UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x08000000 */ +#define ADC_CFGR_AWD1CH_2 (0x04UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x10000000 */ +#define ADC_CFGR_AWD1CH_3 (0x08UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x20000000 */ +#define ADC_CFGR_AWD1CH_4 (0x10UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x40000000 */ + +#define ADC_CFGR_JQDIS_Pos (31U) +#define ADC_CFGR_JQDIS_Msk (0x1UL << ADC_CFGR_JQDIS_Pos) /*!< 0x80000000 */ +#define ADC_CFGR_JQDIS ADC_CFGR_JQDIS_Msk /*!< ADC Injected queue disable */ + +#define ADC3_CFGR_DMAEN_Pos (0U) +#define ADC3_CFGR_DMAEN_Msk (0x1UL << ADC3_CFGR_DMAEN_Pos) /*!< 0x00000001 */ +#define ADC3_CFGR_DMAEN ADC3_CFGR_DMAEN_Msk /*!< ADC DMA transfer enable */ +#define ADC3_CFGR_DMACFG_Pos (1U) +#define ADC3_CFGR_DMACFG_Msk (0x1UL << ADC3_CFGR_DMACFG_Pos) /*!< 0x00000002 */ +#define ADC3_CFGR_DMACFG ADC3_CFGR_DMACFG_Msk /*!< ADC DMA transfer configuration */ + +#define ADC3_CFGR_RES_Pos (3U) +#define ADC3_CFGR_RES_Msk (0x3UL << ADC3_CFGR_RES_Pos) /*!< 0x00000018 */ +#define ADC3_CFGR_RES ADC3_CFGR_RES_Msk /*!< ADC data resolution */ +#define ADC3_CFGR_RES_0 (0x1UL << ADC3_CFGR_RES_Pos) /*!< 0x00000008 */ +#define ADC3_CFGR_RES_1 (0x2UL << ADC3_CFGR_RES_Pos) /*!< 0x00000010 */ + +#define ADC3_CFGR_ALIGN_Pos (15U) +#define ADC3_CFGR_ALIGN_Msk (0x1UL << ADC3_CFGR_ALIGN_Pos) /*!< 0x00008000 */ +#define ADC3_CFGR_ALIGN ADC3_CFGR_ALIGN_Msk /*!< ADC data alignment */ +/******************** Bit definition for ADC_CFGR2 register ********************/ +#define ADC_CFGR2_ROVSE_Pos (0U) +#define ADC_CFGR2_ROVSE_Msk (0x1UL << ADC_CFGR2_ROVSE_Pos) /*!< 0x00000001 */ +#define ADC_CFGR2_ROVSE ADC_CFGR2_ROVSE_Msk /*!< ADC Regular group oversampler enable */ +#define ADC_CFGR2_JOVSE_Pos (1U) +#define ADC_CFGR2_JOVSE_Msk (0x1UL << ADC_CFGR2_JOVSE_Pos) /*!< 0x00000002 */ +#define ADC_CFGR2_JOVSE ADC_CFGR2_JOVSE_Msk /*!< ADC Injected group oversampler enable */ + +#define ADC_CFGR2_OVSS_Pos (5U) +#define ADC_CFGR2_OVSS_Msk (0xFUL << ADC_CFGR2_OVSS_Pos) /*!< 0x000001E0 */ +#define ADC_CFGR2_OVSS ADC_CFGR2_OVSS_Msk /*!< ADC Regular Oversampling shift */ +#define ADC_CFGR2_OVSS_0 (0x1UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000020 */ +#define ADC_CFGR2_OVSS_1 (0x2UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000040 */ +#define ADC_CFGR2_OVSS_2 (0x4UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000080 */ +#define ADC_CFGR2_OVSS_3 (0x8UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000100 */ + +#define ADC_CFGR2_TROVS_Pos (9U) +#define ADC_CFGR2_TROVS_Msk (0x1UL << ADC_CFGR2_TROVS_Pos) /*!< 0x00000200 */ +#define ADC_CFGR2_TROVS ADC_CFGR2_TROVS_Msk /*!< ADC Triggered regular Oversampling */ +#define ADC_CFGR2_ROVSM_Pos (10U) +#define ADC_CFGR2_ROVSM_Msk (0x1UL << ADC_CFGR2_ROVSM_Pos) /*!< 0x00000400 */ +#define ADC_CFGR2_ROVSM ADC_CFGR2_ROVSM_Msk /*!< ADC Regular oversampling mode */ + +#define ADC_CFGR2_RSHIFT1_Pos (11U) +#define ADC_CFGR2_RSHIFT1_Msk (0x1UL << ADC_CFGR2_RSHIFT1_Pos) /*!< 0x00000800 */ +#define ADC_CFGR2_RSHIFT1 ADC_CFGR2_RSHIFT1_Msk /*!< ADC Right-shift data after Offset 1 correction */ +#define ADC_CFGR2_RSHIFT2_Pos (12U) +#define ADC_CFGR2_RSHIFT2_Msk (0x1UL << ADC_CFGR2_RSHIFT2_Pos) /*!< 0x00001000 */ +#define ADC_CFGR2_RSHIFT2 ADC_CFGR2_RSHIFT2_Msk /*!< ADC Right-shift data after Offset 2 correction */ +#define ADC_CFGR2_RSHIFT3_Pos (13U) +#define ADC_CFGR2_RSHIFT3_Msk (0x1UL << ADC_CFGR2_RSHIFT3_Pos) /*!< 0x00002000 */ +#define ADC_CFGR2_RSHIFT3 ADC_CFGR2_RSHIFT3_Msk /*!< ADC Right-shift data after Offset 3 correction */ +#define ADC_CFGR2_RSHIFT4_Pos (14U) +#define ADC_CFGR2_RSHIFT4_Msk (0x1UL << ADC_CFGR2_RSHIFT4_Pos) /*!< 0x00004000 */ +#define ADC_CFGR2_RSHIFT4 ADC_CFGR2_RSHIFT4_Msk /*!< ADC Right-shift data after Offset 4 correction */ + +#define ADC_CFGR2_OVSR_Pos (16U) +#define ADC_CFGR2_OVSR_Msk (0x3FFUL << ADC_CFGR2_OVSR_Pos) /*!< 0x03FF0000 */ +#define ADC_CFGR2_OVSR ADC_CFGR2_OVSR_Msk /*!< ADC oversampling Ratio */ +#define ADC_CFGR2_OVSR_0 (0x001UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00010000 */ +#define ADC_CFGR2_OVSR_1 (0x002UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00020000 */ +#define ADC_CFGR2_OVSR_2 (0x004UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00040000 */ +#define ADC_CFGR2_OVSR_3 (0x008UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00080000 */ +#define ADC_CFGR2_OVSR_4 (0x010UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00100000 */ +#define ADC_CFGR2_OVSR_5 (0x020UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00200000 */ +#define ADC_CFGR2_OVSR_6 (0x040UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00400000 */ +#define ADC_CFGR2_OVSR_7 (0x080UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00800000 */ +#define ADC_CFGR2_OVSR_8 (0x100UL << ADC_CFGR2_OVSR_Pos) /*!< 0x01000000 */ +#define ADC_CFGR2_OVSR_9 (0x200UL << ADC_CFGR2_OVSR_Pos) /*!< 0x02000000 */ + +#define ADC_CFGR2_LSHIFT_Pos (28U) +#define ADC_CFGR2_LSHIFT_Msk (0xFUL << ADC_CFGR2_LSHIFT_Pos) /*!< 0xF0000000 */ +#define ADC_CFGR2_LSHIFT ADC_CFGR2_LSHIFT_Msk /*!< ADC Left shift factor */ +#define ADC_CFGR2_LSHIFT_0 (0x1UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x10000000 */ +#define ADC_CFGR2_LSHIFT_1 (0x2UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x20000000 */ +#define ADC_CFGR2_LSHIFT_2 (0x4UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x40000000 */ +#define ADC_CFGR2_LSHIFT_3 (0x8UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x80000000 */ + +#define ADC3_CFGR2_OVSR_Pos (2U) +#define ADC3_CFGR2_OVSR_Msk (0x7UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x0000001C */ +#define ADC3_CFGR2_OVSR ADC3_CFGR2_OVSR_Msk /*!< ADC oversampling ratio */ +#define ADC3_CFGR2_OVSR_0 (0x1UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000004 */ +#define ADC3_CFGR2_OVSR_1 (0x2UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000008 */ +#define ADC3_CFGR2_OVSR_2 (0x4UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000010 */ + +#define ADC3_CFGR2_SWTRIG_Pos (25U) +#define ADC3_CFGR2_SWTRIG_Msk (0x1UL << ADC3_CFGR2_SWTRIG_Pos) /*!< 0x02000000 */ +#define ADC3_CFGR2_SWTRIG ADC3_CFGR2_SWTRIG_Msk /*!< ADC Software Trigger Bit for Sample time control trigger mode */ +#define ADC3_CFGR2_BULB_Pos (26U) +#define ADC3_CFGR2_BULB_Msk (0x1UL << ADC3_CFGR2_BULB_Pos) /*!< 0x04000000 */ +#define ADC3_CFGR2_BULB ADC3_CFGR2_BULB_Msk /*!< ADC Bulb sampling mode */ +#define ADC3_CFGR2_SMPTRIG_Pos (27U) +#define ADC3_CFGR2_SMPTRIG_Msk (0x1UL << ADC3_CFGR2_SMPTRIG_Pos) /*!< 0x08000000 */ +#define ADC3_CFGR2_SMPTRIG ADC3_CFGR2_SMPTRIG_Msk /*!< ADC Sample Time Control Trigger mode */ +/******************** Bit definition for ADC_SMPR1 register ********************/ +#define ADC_SMPR1_SMP0_Pos (0U) +#define ADC_SMPR1_SMP0_Msk (0x7UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000007 */ +#define ADC_SMPR1_SMP0 ADC_SMPR1_SMP0_Msk /*!< ADC Channel 0 Sampling time selection */ +#define ADC_SMPR1_SMP0_0 (0x1UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000001 */ +#define ADC_SMPR1_SMP0_1 (0x2UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000002 */ +#define ADC_SMPR1_SMP0_2 (0x4UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000004 */ + +#define ADC_SMPR1_SMP1_Pos (3U) +#define ADC_SMPR1_SMP1_Msk (0x7UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000038 */ +#define ADC_SMPR1_SMP1 ADC_SMPR1_SMP1_Msk /*!< ADC Channel 1 Sampling time selection */ +#define ADC_SMPR1_SMP1_0 (0x1UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000008 */ +#define ADC_SMPR1_SMP1_1 (0x2UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000010 */ +#define ADC_SMPR1_SMP1_2 (0x4UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000020 */ + +#define ADC_SMPR1_SMP2_Pos (6U) +#define ADC_SMPR1_SMP2_Msk (0x7UL << ADC_SMPR1_SMP2_Pos) /*!< 0x000001C0 */ +#define ADC_SMPR1_SMP2 ADC_SMPR1_SMP2_Msk /*!< ADC Channel 2 Sampling time selection */ +#define ADC_SMPR1_SMP2_0 (0x1UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000040 */ +#define ADC_SMPR1_SMP2_1 (0x2UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000080 */ +#define ADC_SMPR1_SMP2_2 (0x4UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000100 */ + +#define ADC_SMPR1_SMP3_Pos (9U) +#define ADC_SMPR1_SMP3_Msk (0x7UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000E00 */ +#define ADC_SMPR1_SMP3 ADC_SMPR1_SMP3_Msk /*!< ADC Channel 3 Sampling time selection */ +#define ADC_SMPR1_SMP3_0 (0x1UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000200 */ +#define ADC_SMPR1_SMP3_1 (0x2UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000400 */ +#define ADC_SMPR1_SMP3_2 (0x4UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000800 */ + +#define ADC_SMPR1_SMP4_Pos (12U) +#define ADC_SMPR1_SMP4_Msk (0x7UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00007000 */ +#define ADC_SMPR1_SMP4 ADC_SMPR1_SMP4_Msk /*!< ADC Channel 4 Sampling time selection */ +#define ADC_SMPR1_SMP4_0 (0x1UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00001000 */ +#define ADC_SMPR1_SMP4_1 (0x2UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00002000 */ +#define ADC_SMPR1_SMP4_2 (0x4UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00004000 */ + +#define ADC_SMPR1_SMP5_Pos (15U) +#define ADC_SMPR1_SMP5_Msk (0x7UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00038000 */ +#define ADC_SMPR1_SMP5 ADC_SMPR1_SMP5_Msk /*!< ADC Channel 5 Sampling time selection */ +#define ADC_SMPR1_SMP5_0 (0x1UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00008000 */ +#define ADC_SMPR1_SMP5_1 (0x2UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00010000 */ +#define ADC_SMPR1_SMP5_2 (0x4UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00020000 */ + +#define ADC_SMPR1_SMP6_Pos (18U) +#define ADC_SMPR1_SMP6_Msk (0x7UL << ADC_SMPR1_SMP6_Pos) /*!< 0x001C0000 */ +#define ADC_SMPR1_SMP6 ADC_SMPR1_SMP6_Msk /*!< ADC Channel 6 Sampling time selection */ +#define ADC_SMPR1_SMP6_0 (0x1UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00040000 */ +#define ADC_SMPR1_SMP6_1 (0x2UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00080000 */ +#define ADC_SMPR1_SMP6_2 (0x4UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00100000 */ + +#define ADC_SMPR1_SMP7_Pos (21U) +#define ADC_SMPR1_SMP7_Msk (0x7UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00E00000 */ +#define ADC_SMPR1_SMP7 ADC_SMPR1_SMP7_Msk /*!< ADC Channel 7 Sampling time selection */ +#define ADC_SMPR1_SMP7_0 (0x1UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00200000 */ +#define ADC_SMPR1_SMP7_1 (0x2UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00400000 */ +#define ADC_SMPR1_SMP7_2 (0x4UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00800000 */ + +#define ADC_SMPR1_SMP8_Pos (24U) +#define ADC_SMPR1_SMP8_Msk (0x7UL << ADC_SMPR1_SMP8_Pos) /*!< 0x07000000 */ +#define ADC_SMPR1_SMP8 ADC_SMPR1_SMP8_Msk /*!< ADC Channel 8 Sampling time selection */ +#define ADC_SMPR1_SMP8_0 (0x1UL << ADC_SMPR1_SMP8_Pos) /*!< 0x01000000 */ +#define ADC_SMPR1_SMP8_1 (0x2UL << ADC_SMPR1_SMP8_Pos) /*!< 0x02000000 */ +#define ADC_SMPR1_SMP8_2 (0x4UL << ADC_SMPR1_SMP8_Pos) /*!< 0x04000000 */ + +#define ADC_SMPR1_SMP9_Pos (27U) +#define ADC_SMPR1_SMP9_Msk (0x7UL << ADC_SMPR1_SMP9_Pos) /*!< 0x38000000 */ +#define ADC_SMPR1_SMP9 ADC_SMPR1_SMP9_Msk /*!< ADC Channel 9 Sampling time selection */ +#define ADC_SMPR1_SMP9_0 (0x1UL << ADC_SMPR1_SMP9_Pos) /*!< 0x08000000 */ +#define ADC_SMPR1_SMP9_1 (0x2UL << ADC_SMPR1_SMP9_Pos) /*!< 0x10000000 */ +#define ADC_SMPR1_SMP9_2 (0x4UL << ADC_SMPR1_SMP9_Pos) /*!< 0x20000000 */ + +/******************** Bit definition for ADC_SMPR2 register ********************/ +#define ADC_SMPR2_SMP10_Pos (0U) +#define ADC_SMPR2_SMP10_Msk (0x7UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000007 */ +#define ADC_SMPR2_SMP10 ADC_SMPR2_SMP10_Msk /*!< ADC Channel 10 Sampling time selection */ +#define ADC_SMPR2_SMP10_0 (0x1UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000001 */ +#define ADC_SMPR2_SMP10_1 (0x2UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000002 */ +#define ADC_SMPR2_SMP10_2 (0x4UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000004 */ + +#define ADC_SMPR2_SMP11_Pos (3U) +#define ADC_SMPR2_SMP11_Msk (0x7UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000038 */ +#define ADC_SMPR2_SMP11 ADC_SMPR2_SMP11_Msk /*!< ADC Channel 11 Sampling time selection */ +#define ADC_SMPR2_SMP11_0 (0x1UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000008 */ +#define ADC_SMPR2_SMP11_1 (0x2UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000010 */ +#define ADC_SMPR2_SMP11_2 (0x4UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000020 */ + +#define ADC_SMPR2_SMP12_Pos (6U) +#define ADC_SMPR2_SMP12_Msk (0x7UL << ADC_SMPR2_SMP12_Pos) /*!< 0x000001C0 */ +#define ADC_SMPR2_SMP12 ADC_SMPR2_SMP12_Msk /*!< ADC Channel 12 Sampling time selection */ +#define ADC_SMPR2_SMP12_0 (0x1UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000040 */ +#define ADC_SMPR2_SMP12_1 (0x2UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000080 */ +#define ADC_SMPR2_SMP12_2 (0x4UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000100 */ + +#define ADC_SMPR2_SMP13_Pos (9U) +#define ADC_SMPR2_SMP13_Msk (0x7UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000E00 */ +#define ADC_SMPR2_SMP13 ADC_SMPR2_SMP13_Msk /*!< ADC Channel 13 Sampling time selection */ +#define ADC_SMPR2_SMP13_0 (0x1UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000200 */ +#define ADC_SMPR2_SMP13_1 (0x2UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000400 */ +#define ADC_SMPR2_SMP13_2 (0x4UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000800 */ + +#define ADC_SMPR2_SMP14_Pos (12U) +#define ADC_SMPR2_SMP14_Msk (0x7UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00007000 */ +#define ADC_SMPR2_SMP14 ADC_SMPR2_SMP14_Msk /*!< ADC Channel 14 Sampling time selection */ +#define ADC_SMPR2_SMP14_0 (0x1UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00001000 */ +#define ADC_SMPR2_SMP14_1 (0x2UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00002000 */ +#define ADC_SMPR2_SMP14_2 (0x4UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00004000 */ + +#define ADC_SMPR2_SMP15_Pos (15U) +#define ADC_SMPR2_SMP15_Msk (0x7UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00038000 */ +#define ADC_SMPR2_SMP15 ADC_SMPR2_SMP15_Msk /*!< ADC Channel 15 Sampling time selection */ +#define ADC_SMPR2_SMP15_0 (0x1UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00008000 */ +#define ADC_SMPR2_SMP15_1 (0x2UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00010000 */ +#define ADC_SMPR2_SMP15_2 (0x4UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00020000 */ + +#define ADC_SMPR2_SMP16_Pos (18U) +#define ADC_SMPR2_SMP16_Msk (0x7UL << ADC_SMPR2_SMP16_Pos) /*!< 0x001C0000 */ +#define ADC_SMPR2_SMP16 ADC_SMPR2_SMP16_Msk /*!< ADC Channel 16 Sampling time selection */ +#define ADC_SMPR2_SMP16_0 (0x1UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00040000 */ +#define ADC_SMPR2_SMP16_1 (0x2UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00080000 */ +#define ADC_SMPR2_SMP16_2 (0x4UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00100000 */ + +#define ADC_SMPR2_SMP17_Pos (21U) +#define ADC_SMPR2_SMP17_Msk (0x7UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00E00000 */ +#define ADC_SMPR2_SMP17 ADC_SMPR2_SMP17_Msk /*!< ADC Channel 17 Sampling time selection */ +#define ADC_SMPR2_SMP17_0 (0x1UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00200000 */ +#define ADC_SMPR2_SMP17_1 (0x2UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00400000 */ +#define ADC_SMPR2_SMP17_2 (0x4UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00800000 */ + +#define ADC_SMPR2_SMP18_Pos (24U) +#define ADC_SMPR2_SMP18_Msk (0x7UL << ADC_SMPR2_SMP18_Pos) /*!< 0x07000000 */ +#define ADC_SMPR2_SMP18 ADC_SMPR2_SMP18_Msk /*!< ADC Channel 18 Sampling time selection */ +#define ADC_SMPR2_SMP18_0 (0x1UL << ADC_SMPR2_SMP18_Pos) /*!< 0x01000000 */ +#define ADC_SMPR2_SMP18_1 (0x2UL << ADC_SMPR2_SMP18_Pos) /*!< 0x02000000 */ +#define ADC_SMPR2_SMP18_2 (0x4UL << ADC_SMPR2_SMP18_Pos) /*!< 0x04000000 */ + +#define ADC_SMPR2_SMP19_Pos (27U) +#define ADC_SMPR2_SMP19_Msk (0x7UL << ADC_SMPR2_SMP19_Pos) /*!< 0x38000000 */ +#define ADC_SMPR2_SMP19 ADC_SMPR2_SMP19_Msk /*!< ADC Channel 19 Sampling time selection */ +#define ADC_SMPR2_SMP19_0 (0x1UL << ADC_SMPR2_SMP19_Pos) /*!< 0x08000000 */ +#define ADC_SMPR2_SMP19_1 (0x2UL << ADC_SMPR2_SMP19_Pos) /*!< 0x10000000 */ +#define ADC_SMPR2_SMP19_2 (0x4UL << ADC_SMPR2_SMP19_Pos) /*!< 0x20000000 */ + +/******************** Bit definition for ADC_PCSEL register ********************/ +#define ADC_PCSEL_PCSEL_Pos (0U) +#define ADC_PCSEL_PCSEL_Msk (0xFFFFFUL << ADC_PCSEL_PCSEL_Pos) /*!< 0x000FFFFF */ +#define ADC_PCSEL_PCSEL ADC_PCSEL_PCSEL_Msk /*!< ADC pre channel selection */ +#define ADC_PCSEL_PCSEL_0 (0x00001UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000001 */ +#define ADC_PCSEL_PCSEL_1 (0x00002UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000002 */ +#define ADC_PCSEL_PCSEL_2 (0x00004UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000004 */ +#define ADC_PCSEL_PCSEL_3 (0x00008UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000008 */ +#define ADC_PCSEL_PCSEL_4 (0x00010UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000010 */ +#define ADC_PCSEL_PCSEL_5 (0x00020UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000020 */ +#define ADC_PCSEL_PCSEL_6 (0x00040UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000040 */ +#define ADC_PCSEL_PCSEL_7 (0x00080UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000080 */ +#define ADC_PCSEL_PCSEL_8 (0x00100UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000100 */ +#define ADC_PCSEL_PCSEL_9 (0x00200UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000200 */ +#define ADC_PCSEL_PCSEL_10 (0x00400UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000400 */ +#define ADC_PCSEL_PCSEL_11 (0x00800UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000800 */ +#define ADC_PCSEL_PCSEL_12 (0x01000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00001000 */ +#define ADC_PCSEL_PCSEL_13 (0x02000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00002000 */ +#define ADC_PCSEL_PCSEL_14 (0x04000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00004000 */ +#define ADC_PCSEL_PCSEL_15 (0x08000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00008000 */ +#define ADC_PCSEL_PCSEL_16 (0x10000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00010000 */ +#define ADC_PCSEL_PCSEL_17 (0x20000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00020000 */ +#define ADC_PCSEL_PCSEL_18 (0x40000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00040000 */ +#define ADC_PCSEL_PCSEL_19 (0x80000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00080000 */ + +/***************** Bit definition for ADC_LTR1, 2, 3 registers *****************/ +#define ADC_LTR_LT_Pos (0U) +#define ADC_LTR_LT_Msk (0x3FFFFFFUL << ADC_LTR_LT_Pos) /*!< 0x03FFFFFF */ +#define ADC_LTR_LT ADC_LTR_LT_Msk /*!< ADC Analog watchdog 1, 2 and 3 lower threshold */ + +/***************** Bit definition for ADC_HTR1, 2, 3 registers ****************/ +#define ADC_HTR_HT_Pos (0U) +#define ADC_HTR_HT_Msk (0x3FFFFFFUL << ADC_HTR_HT_Pos) /*!< 0x03FFFFFF */ +#define ADC_HTR_HT ADC_HTR_HT_Msk /*!< ADC Analog watchdog 1,2 and 3 higher threshold */ + +/******************** Bit definition for ADC3_TR1 register *******************/ +#define ADC3_TR1_LT1_Pos (0U) +#define ADC3_TR1_LT1_Msk (0xFFFUL << ADC3_TR1_LT1_Pos) /*!< 0x00000FFF */ +#define ADC3_TR1_LT1 ADC3_TR1_LT1_Msk /*!< ADC analog watchdog 1 threshold low */ + +#define ADC3_TR1_AWDFILT_Pos (12U) +#define ADC3_TR1_AWDFILT_Msk (0x7UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00007000 */ +#define ADC3_TR1_AWDFILT ADC3_TR1_AWDFILT_Msk /*!< ADC analog watchdog filtering parameter */ +#define ADC3_TR1_AWDFILT_0 (0x1UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00001000 */ +#define ADC3_TR1_AWDFILT_1 (0x2UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00002000 */ +#define ADC3_TR1_AWDFILT_2 (0x4UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00004000 */ + +#define ADC3_TR1_HT1_Pos (16U) +#define ADC3_TR1_HT1_Msk (0xFFFUL << ADC3_TR1_HT1_Pos) /*!< 0x0FFF0000 */ +#define ADC3_TR1_HT1 ADC3_TR1_HT1_Msk /*!< ADC analog watchdog 1 threshold high */ + +/******************** Bit definition for ADC3_TR2 register *******************/ +#define ADC3_TR2_LT2_Pos (0U) +#define ADC3_TR2_LT2_Msk (0xFFUL << ADC3_TR2_LT2_Pos) /*!< 0x000000FF */ +#define ADC3_TR2_LT2 ADC3_TR2_LT2_Msk /*!< ADC analog watchdog 2 threshold low */ + +#define ADC3_TR2_HT2_Pos (16U) +#define ADC3_TR2_HT2_Msk (0xFFUL << ADC3_TR2_HT2_Pos) /*!< 0x00FF0000 */ +#define ADC3_TR2_HT2 ADC3_TR2_HT2_Msk /*!< ADC analog watchdog 2 threshold high */ + +/******************** Bit definition for ADC3_TR3 register *******************/ +#define ADC3_TR3_LT3_Pos (0U) +#define ADC3_TR3_LT3_Msk (0xFFUL << ADC3_TR3_LT3_Pos) /*!< 0x000000FF */ +#define ADC3_TR3_LT3 ADC3_TR3_LT3_Msk /*!< ADC analog watchdog 3 threshold low */ + +#define ADC3_TR3_HT3_Pos (16U) +#define ADC3_TR3_HT3_Msk (0xFFUL << ADC3_TR3_HT3_Pos) /*!< 0x00FF0000 */ +#define ADC3_TR3_HT3 ADC3_TR3_HT3_Msk /*!< ADC analog watchdog 3 threshold high */ + +/******************** Bit definition for ADC_SQR1 register ********************/ +#define ADC_SQR1_L_Pos (0U) +#define ADC_SQR1_L_Msk (0xFUL << ADC_SQR1_L_Pos) /*!< 0x0000000F */ +#define ADC_SQR1_L ADC_SQR1_L_Msk /*!< ADC regular channel sequence length */ +#define ADC_SQR1_L_0 (0x1UL << ADC_SQR1_L_Pos) /*!< 0x00000001 */ +#define ADC_SQR1_L_1 (0x2UL << ADC_SQR1_L_Pos) /*!< 0x00000002 */ +#define ADC_SQR1_L_2 (0x4UL << ADC_SQR1_L_Pos) /*!< 0x00000004 */ +#define ADC_SQR1_L_3 (0x8UL << ADC_SQR1_L_Pos) /*!< 0x00000008 */ + +#define ADC_SQR1_SQ1_Pos (6U) +#define ADC_SQR1_SQ1_Msk (0x1FUL << ADC_SQR1_SQ1_Pos) /*!< 0x000007C0 */ +#define ADC_SQR1_SQ1 ADC_SQR1_SQ1_Msk /*!< ADC 1st conversion in regular sequence */ +#define ADC_SQR1_SQ1_0 (0x01UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000040 */ +#define ADC_SQR1_SQ1_1 (0x02UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000080 */ +#define ADC_SQR1_SQ1_2 (0x04UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000100 */ +#define ADC_SQR1_SQ1_3 (0x08UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000200 */ +#define ADC_SQR1_SQ1_4 (0x10UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000400 */ + +#define ADC_SQR1_SQ2_Pos (12U) +#define ADC_SQR1_SQ2_Msk (0x1FUL << ADC_SQR1_SQ2_Pos) /*!< 0x0001F000 */ +#define ADC_SQR1_SQ2 ADC_SQR1_SQ2_Msk /*!< ADC 2nd conversion in regular sequence */ +#define ADC_SQR1_SQ2_0 (0x01UL << ADC_SQR1_SQ2_Pos) /*!< 0x00001000 */ +#define ADC_SQR1_SQ2_1 (0x02UL << ADC_SQR1_SQ2_Pos) /*!< 0x00002000 */ +#define ADC_SQR1_SQ2_2 (0x04UL << ADC_SQR1_SQ2_Pos) /*!< 0x00004000 */ +#define ADC_SQR1_SQ2_3 (0x08UL << ADC_SQR1_SQ2_Pos) /*!< 0x00008000 */ +#define ADC_SQR1_SQ2_4 (0x10UL << ADC_SQR1_SQ2_Pos) /*!< 0x00010000 */ + +#define ADC_SQR1_SQ3_Pos (18U) +#define ADC_SQR1_SQ3_Msk (0x1FUL << ADC_SQR1_SQ3_Pos) /*!< 0x007C0000 */ +#define ADC_SQR1_SQ3 ADC_SQR1_SQ3_Msk /*!< ADC 3rd conversion in regular sequence */ +#define ADC_SQR1_SQ3_0 (0x01UL << ADC_SQR1_SQ3_Pos) /*!< 0x00040000 */ +#define ADC_SQR1_SQ3_1 (0x02UL << ADC_SQR1_SQ3_Pos) /*!< 0x00080000 */ +#define ADC_SQR1_SQ3_2 (0x04UL << ADC_SQR1_SQ3_Pos) /*!< 0x00100000 */ +#define ADC_SQR1_SQ3_3 (0x08UL << ADC_SQR1_SQ3_Pos) /*!< 0x00200000 */ +#define ADC_SQR1_SQ3_4 (0x10UL << ADC_SQR1_SQ3_Pos) /*!< 0x00400000 */ + +#define ADC_SQR1_SQ4_Pos (24U) +#define ADC_SQR1_SQ4_Msk (0x1FUL << ADC_SQR1_SQ4_Pos) /*!< 0x1F000000 */ +#define ADC_SQR1_SQ4 ADC_SQR1_SQ4_Msk /*!< ADC 4th conversion in regular sequence */ +#define ADC_SQR1_SQ4_0 (0x01UL << ADC_SQR1_SQ4_Pos) /*!< 0x01000000 */ +#define ADC_SQR1_SQ4_1 (0x02UL << ADC_SQR1_SQ4_Pos) /*!< 0x02000000 */ +#define ADC_SQR1_SQ4_2 (0x04UL << ADC_SQR1_SQ4_Pos) /*!< 0x04000000 */ +#define ADC_SQR1_SQ4_3 (0x08UL << ADC_SQR1_SQ4_Pos) /*!< 0x08000000 */ +#define ADC_SQR1_SQ4_4 (0x10UL << ADC_SQR1_SQ4_Pos) /*!< 0x10000000 */ + +/******************** Bit definition for ADC_SQR2 register ********************/ +#define ADC_SQR2_SQ5_Pos (0U) +#define ADC_SQR2_SQ5_Msk (0x1FUL << ADC_SQR2_SQ5_Pos) /*!< 0x0000001F */ +#define ADC_SQR2_SQ5 ADC_SQR2_SQ5_Msk /*!< ADC 5th conversion in regular sequence */ +#define ADC_SQR2_SQ5_0 (0x01UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000001 */ +#define ADC_SQR2_SQ5_1 (0x02UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000002 */ +#define ADC_SQR2_SQ5_2 (0x04UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000004 */ +#define ADC_SQR2_SQ5_3 (0x08UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000008 */ +#define ADC_SQR2_SQ5_4 (0x10UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000010 */ + +#define ADC_SQR2_SQ6_Pos (6U) +#define ADC_SQR2_SQ6_Msk (0x1FUL << ADC_SQR2_SQ6_Pos) /*!< 0x000007C0 */ +#define ADC_SQR2_SQ6 ADC_SQR2_SQ6_Msk /*!< ADC 6th conversion in regular sequence */ +#define ADC_SQR2_SQ6_0 (0x01UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000040 */ +#define ADC_SQR2_SQ6_1 (0x02UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000080 */ +#define ADC_SQR2_SQ6_2 (0x04UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000100 */ +#define ADC_SQR2_SQ6_3 (0x08UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000200 */ +#define ADC_SQR2_SQ6_4 (0x10UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000400 */ + +#define ADC_SQR2_SQ7_Pos (12U) +#define ADC_SQR2_SQ7_Msk (0x1FUL << ADC_SQR2_SQ7_Pos) /*!< 0x0001F000 */ +#define ADC_SQR2_SQ7 ADC_SQR2_SQ7_Msk /*!< ADC 7th conversion in regular sequence */ +#define ADC_SQR2_SQ7_0 (0x01UL << ADC_SQR2_SQ7_Pos) /*!< 0x00001000 */ +#define ADC_SQR2_SQ7_1 (0x02UL << ADC_SQR2_SQ7_Pos) /*!< 0x00002000 */ +#define ADC_SQR2_SQ7_2 (0x04UL << ADC_SQR2_SQ7_Pos) /*!< 0x00004000 */ +#define ADC_SQR2_SQ7_3 (0x08UL << ADC_SQR2_SQ7_Pos) /*!< 0x00008000 */ +#define ADC_SQR2_SQ7_4 (0x10UL << ADC_SQR2_SQ7_Pos) /*!< 0x00010000 */ + +#define ADC_SQR2_SQ8_Pos (18U) +#define ADC_SQR2_SQ8_Msk (0x1FUL << ADC_SQR2_SQ8_Pos) /*!< 0x007C0000 */ +#define ADC_SQR2_SQ8 ADC_SQR2_SQ8_Msk /*!< ADC 8th conversion in regular sequence */ +#define ADC_SQR2_SQ8_0 (0x01UL << ADC_SQR2_SQ8_Pos) /*!< 0x00040000 */ +#define ADC_SQR2_SQ8_1 (0x02UL << ADC_SQR2_SQ8_Pos) /*!< 0x00080000 */ +#define ADC_SQR2_SQ8_2 (0x04UL << ADC_SQR2_SQ8_Pos) /*!< 0x00100000 */ +#define ADC_SQR2_SQ8_3 (0x08UL << ADC_SQR2_SQ8_Pos) /*!< 0x00200000 */ +#define ADC_SQR2_SQ8_4 (0x10UL << ADC_SQR2_SQ8_Pos) /*!< 0x00400000 */ + +#define ADC_SQR2_SQ9_Pos (24U) +#define ADC_SQR2_SQ9_Msk (0x1FUL << ADC_SQR2_SQ9_Pos) /*!< 0x1F000000 */ +#define ADC_SQR2_SQ9 ADC_SQR2_SQ9_Msk /*!< ADC 9th conversion in regular sequence */ +#define ADC_SQR2_SQ9_0 (0x01UL << ADC_SQR2_SQ9_Pos) /*!< 0x01000000 */ +#define ADC_SQR2_SQ9_1 (0x02UL << ADC_SQR2_SQ9_Pos) /*!< 0x02000000 */ +#define ADC_SQR2_SQ9_2 (0x04UL << ADC_SQR2_SQ9_Pos) /*!< 0x04000000 */ +#define ADC_SQR2_SQ9_3 (0x08UL << ADC_SQR2_SQ9_Pos) /*!< 0x08000000 */ +#define ADC_SQR2_SQ9_4 (0x10UL << ADC_SQR2_SQ9_Pos) /*!< 0x10000000 */ + +/******************** Bit definition for ADC_SQR3 register ********************/ +#define ADC_SQR3_SQ10_Pos (0U) +#define ADC_SQR3_SQ10_Msk (0x1FUL << ADC_SQR3_SQ10_Pos) /*!< 0x0000001F */ +#define ADC_SQR3_SQ10 ADC_SQR3_SQ10_Msk /*!< ADC 10th conversion in regular sequence */ +#define ADC_SQR3_SQ10_0 (0x01UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000001 */ +#define ADC_SQR3_SQ10_1 (0x02UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000002 */ +#define ADC_SQR3_SQ10_2 (0x04UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000004 */ +#define ADC_SQR3_SQ10_3 (0x08UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000008 */ +#define ADC_SQR3_SQ10_4 (0x10UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000010 */ + +#define ADC_SQR3_SQ11_Pos (6U) +#define ADC_SQR3_SQ11_Msk (0x1FUL << ADC_SQR3_SQ11_Pos) /*!< 0x000007C0 */ +#define ADC_SQR3_SQ11 ADC_SQR3_SQ11_Msk /*!< ADC 11th conversion in regular sequence */ +#define ADC_SQR3_SQ11_0 (0x01UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000040 */ +#define ADC_SQR3_SQ11_1 (0x02UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000080 */ +#define ADC_SQR3_SQ11_2 (0x04UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000100 */ +#define ADC_SQR3_SQ11_3 (0x08UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000200 */ +#define ADC_SQR3_SQ11_4 (0x10UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000400 */ + +#define ADC_SQR3_SQ12_Pos (12U) +#define ADC_SQR3_SQ12_Msk (0x1FUL << ADC_SQR3_SQ12_Pos) /*!< 0x0001F000 */ +#define ADC_SQR3_SQ12 ADC_SQR3_SQ12_Msk /*!< ADC 12th conversion in regular sequence */ +#define ADC_SQR3_SQ12_0 (0x01UL << ADC_SQR3_SQ12_Pos) /*!< 0x00001000 */ +#define ADC_SQR3_SQ12_1 (0x02UL << ADC_SQR3_SQ12_Pos) /*!< 0x00002000 */ +#define ADC_SQR3_SQ12_2 (0x04UL << ADC_SQR3_SQ12_Pos) /*!< 0x00004000 */ +#define ADC_SQR3_SQ12_3 (0x08UL << ADC_SQR3_SQ12_Pos) /*!< 0x00008000 */ +#define ADC_SQR3_SQ12_4 (0x10UL << ADC_SQR3_SQ12_Pos) /*!< 0x00010000 */ + +#define ADC_SQR3_SQ13_Pos (18U) +#define ADC_SQR3_SQ13_Msk (0x1FUL << ADC_SQR3_SQ13_Pos) /*!< 0x007C0000 */ +#define ADC_SQR3_SQ13 ADC_SQR3_SQ13_Msk /*!< ADC 13th conversion in regular sequence */ +#define ADC_SQR3_SQ13_0 (0x01UL << ADC_SQR3_SQ13_Pos) /*!< 0x00040000 */ +#define ADC_SQR3_SQ13_1 (0x02UL << ADC_SQR3_SQ13_Pos) /*!< 0x00080000 */ +#define ADC_SQR3_SQ13_2 (0x04UL << ADC_SQR3_SQ13_Pos) /*!< 0x00100000 */ +#define ADC_SQR3_SQ13_3 (0x08UL << ADC_SQR3_SQ13_Pos) /*!< 0x00200000 */ +#define ADC_SQR3_SQ13_4 (0x10UL << ADC_SQR3_SQ13_Pos) /*!< 0x00400000 */ + +#define ADC_SQR3_SQ14_Pos (24U) +#define ADC_SQR3_SQ14_Msk (0x1FUL << ADC_SQR3_SQ14_Pos) /*!< 0x1F000000 */ +#define ADC_SQR3_SQ14 ADC_SQR3_SQ14_Msk /*!< ADC 14th conversion in regular sequence */ +#define ADC_SQR3_SQ14_0 (0x01UL << ADC_SQR3_SQ14_Pos) /*!< 0x01000000 */ +#define ADC_SQR3_SQ14_1 (0x02UL << ADC_SQR3_SQ14_Pos) /*!< 0x02000000 */ +#define ADC_SQR3_SQ14_2 (0x04UL << ADC_SQR3_SQ14_Pos) /*!< 0x04000000 */ +#define ADC_SQR3_SQ14_3 (0x08UL << ADC_SQR3_SQ14_Pos) /*!< 0x08000000 */ +#define ADC_SQR3_SQ14_4 (0x10UL << ADC_SQR3_SQ14_Pos) /*!< 0x10000000 */ + +/******************** Bit definition for ADC_SQR4 register ********************/ +#define ADC_SQR4_SQ15_Pos (0U) +#define ADC_SQR4_SQ15_Msk (0x1FUL << ADC_SQR4_SQ15_Pos) /*!< 0x0000001F */ +#define ADC_SQR4_SQ15 ADC_SQR4_SQ15_Msk /*!< ADC 15th conversion in regular sequence */ +#define ADC_SQR4_SQ15_0 (0x01UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000001 */ +#define ADC_SQR4_SQ15_1 (0x02UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000002 */ +#define ADC_SQR4_SQ15_2 (0x04UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000004 */ +#define ADC_SQR4_SQ15_3 (0x08UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000008 */ +#define ADC_SQR4_SQ15_4 (0x10UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000010 */ + +#define ADC_SQR4_SQ16_Pos (6U) +#define ADC_SQR4_SQ16_Msk (0x1FUL << ADC_SQR4_SQ16_Pos) /*!< 0x000007C0 */ +#define ADC_SQR4_SQ16 ADC_SQR4_SQ16_Msk /*!< ADC 16th conversion in regular sequence */ +#define ADC_SQR4_SQ16_0 (0x01UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000040 */ +#define ADC_SQR4_SQ16_1 (0x02UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000080 */ +#define ADC_SQR4_SQ16_2 (0x04UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000100 */ +#define ADC_SQR4_SQ16_3 (0x08UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000200 */ +#define ADC_SQR4_SQ16_4 (0x10UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000400 */ +/******************** Bit definition for ADC_DR register ********************/ +#define ADC_DR_RDATA_Pos (0U) +#define ADC_DR_RDATA_Msk (0xFFFFFFFFUL << ADC_DR_RDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_DR_RDATA ADC_DR_RDATA_Msk /*!< ADC regular Data converted */ + +/******************** Bit definition for ADC_JSQR register ********************/ +#define ADC_JSQR_JL_Pos (0U) +#define ADC_JSQR_JL_Msk (0x3UL << ADC_JSQR_JL_Pos) /*!< 0x00000003 */ +#define ADC_JSQR_JL ADC_JSQR_JL_Msk /*!< ADC injected channel sequence length */ +#define ADC_JSQR_JL_0 (0x1UL << ADC_JSQR_JL_Pos) /*!< 0x00000001 */ +#define ADC_JSQR_JL_1 (0x2UL << ADC_JSQR_JL_Pos) /*!< 0x00000002 */ + +#define ADC_JSQR_JEXTSEL_Pos (2U) +#define ADC_JSQR_JEXTSEL_Msk (0x1FUL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x0000007C */ +#define ADC_JSQR_JEXTSEL ADC_JSQR_JEXTSEL_Msk /*!< ADC external trigger selection for injected group */ +#define ADC_JSQR_JEXTSEL_0 (0x01UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000004 */ +#define ADC_JSQR_JEXTSEL_1 (0x02UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000008 */ +#define ADC_JSQR_JEXTSEL_2 (0x04UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000010 */ +#define ADC_JSQR_JEXTSEL_3 (0x08UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000020 */ +#define ADC_JSQR_JEXTSEL_4 (0x10UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000040 */ + +#define ADC_JSQR_JEXTEN_Pos (7U) +#define ADC_JSQR_JEXTEN_Msk (0x3UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000180 */ +#define ADC_JSQR_JEXTEN ADC_JSQR_JEXTEN_Msk /*!< ADC external trigger enable and polarity selection for injected channels */ +#define ADC_JSQR_JEXTEN_0 (0x1UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000080 */ +#define ADC_JSQR_JEXTEN_1 (0x2UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000100 */ + +#define ADC_JSQR_JSQ1_Pos (9U) +#define ADC_JSQR_JSQ1_Msk (0x1FUL << ADC_JSQR_JSQ1_Pos) /*!< 0x00003E00 */ +#define ADC_JSQR_JSQ1 ADC_JSQR_JSQ1_Msk /*!< ADC 1st conversion in injected sequence */ +#define ADC_JSQR_JSQ1_0 (0x01UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000200 */ +#define ADC_JSQR_JSQ1_1 (0x02UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000400 */ +#define ADC_JSQR_JSQ1_2 (0x04UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000800 */ +#define ADC_JSQR_JSQ1_3 (0x08UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00001000 */ +#define ADC_JSQR_JSQ1_4 (0x10UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00002000 */ + +#define ADC_JSQR_JSQ2_Pos (15U) +#define ADC_JSQR_JSQ2_Msk (0x1FUL << ADC_JSQR_JSQ2_Pos) /*!< 0x000F8000 */ +#define ADC_JSQR_JSQ2 ADC_JSQR_JSQ2_Msk /*!< ADC 2nd conversion in injected sequence */ +#define ADC_JSQR_JSQ2_0 (0x01UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00008000 */ +#define ADC_JSQR_JSQ2_1 (0x02UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00010000 */ +#define ADC_JSQR_JSQ2_2 (0x04UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00020000 */ +#define ADC_JSQR_JSQ2_3 (0x08UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00040000 */ +#define ADC_JSQR_JSQ2_4 (0x10UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00080000 */ + +#define ADC_JSQR_JSQ3_Pos (21U) +#define ADC_JSQR_JSQ3_Msk (0x1FUL << ADC_JSQR_JSQ3_Pos) /*!< 0x03E00000 */ +#define ADC_JSQR_JSQ3 ADC_JSQR_JSQ3_Msk /*!< ADC 3rd conversion in injected sequence */ +#define ADC_JSQR_JSQ3_0 (0x01UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00200000 */ +#define ADC_JSQR_JSQ3_1 (0x02UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00400000 */ +#define ADC_JSQR_JSQ3_2 (0x04UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00800000 */ +#define ADC_JSQR_JSQ3_3 (0x08UL << ADC_JSQR_JSQ3_Pos) /*!< 0x01000000 */ +#define ADC_JSQR_JSQ3_4 (0x10UL << ADC_JSQR_JSQ3_Pos) /*!< 0x02000000 */ + +#define ADC_JSQR_JSQ4_Pos (27U) +#define ADC_JSQR_JSQ4_Msk (0x1FUL << ADC_JSQR_JSQ4_Pos) /*!< 0xF8000000 */ +#define ADC_JSQR_JSQ4 ADC_JSQR_JSQ4_Msk /*!< ADC 4th conversion in injected sequence */ +#define ADC_JSQR_JSQ4_0 (0x01UL << ADC_JSQR_JSQ4_Pos) /*!< 0x08000000 */ +#define ADC_JSQR_JSQ4_1 (0x02UL << ADC_JSQR_JSQ4_Pos) /*!< 0x10000000 */ +#define ADC_JSQR_JSQ4_2 (0x04UL << ADC_JSQR_JSQ4_Pos) /*!< 0x20000000 */ +#define ADC_JSQR_JSQ4_3 (0x08UL << ADC_JSQR_JSQ4_Pos) /*!< 0x40000000 */ +#define ADC_JSQR_JSQ4_4 (0x10UL << ADC_JSQR_JSQ4_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_OFR1 register ********************/ +#define ADC_OFR1_OFFSET1_Pos (0U) +#define ADC_OFR1_OFFSET1_Msk (0x3FFFFFFUL << ADC_OFR1_OFFSET1_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR1_OFFSET1 ADC_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ +#define ADC_OFR1_OFFSET1_0 (0x0000001UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000001 */ +#define ADC_OFR1_OFFSET1_1 (0x0000002UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000002 */ +#define ADC_OFR1_OFFSET1_2 (0x0000004UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000004 */ +#define ADC_OFR1_OFFSET1_3 (0x0000008UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000008 */ +#define ADC_OFR1_OFFSET1_4 (0x0000010UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000010 */ +#define ADC_OFR1_OFFSET1_5 (0x0000020UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000020 */ +#define ADC_OFR1_OFFSET1_6 (0x0000040UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000040 */ +#define ADC_OFR1_OFFSET1_7 (0x0000080UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000080 */ +#define ADC_OFR1_OFFSET1_8 (0x0000100UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000100 */ +#define ADC_OFR1_OFFSET1_9 (0x0000200UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000200 */ +#define ADC_OFR1_OFFSET1_10 (0x0000400UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000400 */ +#define ADC_OFR1_OFFSET1_11 (0x0000800UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000800 */ +#define ADC_OFR1_OFFSET1_12 (0x0001000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00001000 */ +#define ADC_OFR1_OFFSET1_13 (0x0002000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00002000 */ +#define ADC_OFR1_OFFSET1_14 (0x0004000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00004000 */ +#define ADC_OFR1_OFFSET1_15 (0x0008000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00008000 */ +#define ADC_OFR1_OFFSET1_16 (0x0010000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00010000 */ +#define ADC_OFR1_OFFSET1_17 (0x0020000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00020000 */ +#define ADC_OFR1_OFFSET1_18 (0x0040000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00040000 */ +#define ADC_OFR1_OFFSET1_19 (0x0080000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00080000 */ +#define ADC_OFR1_OFFSET1_20 (0x0100000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00100000 */ +#define ADC_OFR1_OFFSET1_21 (0x0200000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00200000 */ +#define ADC_OFR1_OFFSET1_22 (0x0400000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00400000 */ +#define ADC_OFR1_OFFSET1_23 (0x0800000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00800000 */ +#define ADC_OFR1_OFFSET1_24 (0x1000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x01000000 */ +#define ADC_OFR1_OFFSET1_25 (0x2000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x02000000 */ + +#define ADC_OFR1_OFFSET1_CH_Pos (26U) +#define ADC_OFR1_OFFSET1_CH_Msk (0x1FUL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR1_OFFSET1_CH ADC_OFR1_OFFSET1_CH_Msk /*!< ADC Channel selection for the data offset 1 */ +#define ADC_OFR1_OFFSET1_CH_0 (0x01UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR1_OFFSET1_CH_1 (0x02UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR1_OFFSET1_CH_2 (0x04UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR1_OFFSET1_CH_3 (0x08UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR1_OFFSET1_CH_4 (0x10UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR1_SSATE_Pos (31U) +#define ADC_OFR1_SSATE_Msk (0x1UL << ADC_OFR1_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR1_SSATE ADC_OFR1_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR1_OFFSET1_Pos (0U) +#define ADC3_OFR1_OFFSET1_Msk (0xFFFUL << ADC3_OFR1_OFFSET1_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR1_OFFSET1 ADC3_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR1_OFFSETPOS_Pos (24U) +#define ADC3_OFR1_OFFSETPOS_Msk (0x1UL << ADC3_OFR1_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR1_OFFSETPOS ADC3_OFR1_OFFSETPOS_Msk /*!< ADC offset number 1 positive */ +#define ADC3_OFR1_SATEN_Pos (25U) +#define ADC3_OFR1_SATEN_Msk (0x1UL << ADC3_OFR1_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR1_SATEN ADC3_OFR1_SATEN_Msk /*!< ADC offset number 1 saturation enable */ + +#define ADC3_OFR1_OFFSET1_EN_Pos (31U) +#define ADC3_OFR1_OFFSET1_EN_Msk (0x1UL << ADC3_OFR1_OFFSET1_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR1_OFFSET1_EN ADC3_OFR1_OFFSET1_EN_Msk /*!< ADC offset number 1 enable */ + +/******************** Bit definition for ADC_OFR2 register ********************/ +#define ADC_OFR2_OFFSET2_Pos (0U) +#define ADC_OFR2_OFFSET2_Msk (0x3FFFFFFUL << ADC_OFR2_OFFSET2_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR2_OFFSET2 ADC_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET2_CH[4:0] */ +#define ADC_OFR2_OFFSET2_0 (0x0000001UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000001 */ +#define ADC_OFR2_OFFSET2_1 (0x0000002UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000002 */ +#define ADC_OFR2_OFFSET2_2 (0x0000004UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000004 */ +#define ADC_OFR2_OFFSET2_3 (0x0000008UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000008 */ +#define ADC_OFR2_OFFSET2_4 (0x0000010UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000010 */ +#define ADC_OFR2_OFFSET2_5 (0x0000020UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000020 */ +#define ADC_OFR2_OFFSET2_6 (0x0000040UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000040 */ +#define ADC_OFR2_OFFSET2_7 (0x0000080UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000080 */ +#define ADC_OFR2_OFFSET2_8 (0x0000100UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000100 */ +#define ADC_OFR2_OFFSET2_9 (0x0000200UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000200 */ +#define ADC_OFR2_OFFSET2_10 (0x0000400UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000400 */ +#define ADC_OFR2_OFFSET2_11 (0x0000800UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000800 */ +#define ADC_OFR2_OFFSET2_12 (0x0001000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00001000 */ +#define ADC_OFR2_OFFSET2_13 (0x0002000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00002000 */ +#define ADC_OFR2_OFFSET2_14 (0x0004000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00004000 */ +#define ADC_OFR2_OFFSET2_15 (0x0008000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00008000 */ +#define ADC_OFR2_OFFSET2_16 (0x0010000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00010000 */ +#define ADC_OFR2_OFFSET2_17 (0x0020000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00020000 */ +#define ADC_OFR2_OFFSET2_18 (0x0040000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00040000 */ +#define ADC_OFR2_OFFSET2_19 (0x0080000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00080000 */ +#define ADC_OFR2_OFFSET2_20 (0x0100000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00100000 */ +#define ADC_OFR2_OFFSET2_21 (0x0200000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00200000 */ +#define ADC_OFR2_OFFSET2_22 (0x0400000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00400000 */ +#define ADC_OFR2_OFFSET2_23 (0x0800000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00800000 */ +#define ADC_OFR2_OFFSET2_24 (0x1000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x01000000 */ +#define ADC_OFR2_OFFSET2_25 (0x2000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x02000000 */ + +#define ADC_OFR2_OFFSET2_CH_Pos (26U) +#define ADC_OFR2_OFFSET2_CH_Msk (0x1FUL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR2_OFFSET2_CH ADC_OFR2_OFFSET2_CH_Msk /*!< ADC Channel selection for the data offset 2 */ +#define ADC_OFR2_OFFSET2_CH_0 (0x01UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR2_OFFSET2_CH_1 (0x02UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR2_OFFSET2_CH_2 (0x04UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR2_OFFSET2_CH_3 (0x08UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR2_OFFSET2_CH_4 (0x10UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR2_SSATE_Pos (31U) +#define ADC_OFR2_SSATE_Msk (0x1UL << ADC_OFR2_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR2_SSATE ADC_OFR2_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR2_OFFSET2_Pos (0U) +#define ADC3_OFR2_OFFSET2_Msk (0xFFFUL << ADC3_OFR2_OFFSET2_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR2_OFFSET2 ADC3_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR2_OFFSETPOS_Pos (24U) +#define ADC3_OFR2_OFFSETPOS_Msk (0x1UL << ADC3_OFR2_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR2_OFFSETPOS ADC3_OFR2_OFFSETPOS_Msk /*!< ADC offset number 2 positive */ +#define ADC3_OFR2_SATEN_Pos (25U) +#define ADC3_OFR2_SATEN_Msk (0x1UL << ADC3_OFR2_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR2_SATEN ADC3_OFR2_SATEN_Msk /*!< ADC offset number 2 saturation enable */ + +#define ADC3_OFR2_OFFSET2_EN_Pos (31U) +#define ADC3_OFR2_OFFSET2_EN_Msk (0x1UL << ADC3_OFR2_OFFSET2_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR2_OFFSET2_EN ADC3_OFR2_OFFSET2_EN_Msk /*!< ADC offset number 2 enable */ + +/******************** Bit definition for ADC_OFR3 register ********************/ +#define ADC_OFR3_OFFSET3_Pos (0U) +#define ADC_OFR3_OFFSET3_Msk (0x3FFFFFFUL << ADC_OFR3_OFFSET3_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR3_OFFSET3 ADC_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET3_CH[4:0] */ +#define ADC_OFR3_OFFSET3_0 (0x0000001UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000001 */ +#define ADC_OFR3_OFFSET3_1 (0x0000002UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000002 */ +#define ADC_OFR3_OFFSET3_2 (0x0000004UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000004 */ +#define ADC_OFR3_OFFSET3_3 (0x0000008UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000008 */ +#define ADC_OFR3_OFFSET3_4 (0x0000010UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000010 */ +#define ADC_OFR3_OFFSET3_5 (0x0000020UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000020 */ +#define ADC_OFR3_OFFSET3_6 (0x0000040UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000040 */ +#define ADC_OFR3_OFFSET3_7 (0x0000080UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000080 */ +#define ADC_OFR3_OFFSET3_8 (0x0000100UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000100 */ +#define ADC_OFR3_OFFSET3_9 (0x0000200UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000200 */ +#define ADC_OFR3_OFFSET3_10 (0x0000400UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000400 */ +#define ADC_OFR3_OFFSET3_11 (0x0000800UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000800 */ +#define ADC_OFR3_OFFSET3_12 (0x0001000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00001000 */ +#define ADC_OFR3_OFFSET3_13 (0x0002000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00002000 */ +#define ADC_OFR3_OFFSET3_14 (0x0004000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00004000 */ +#define ADC_OFR3_OFFSET3_15 (0x0008000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00008000 */ +#define ADC_OFR3_OFFSET3_16 (0x0010000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00010000 */ +#define ADC_OFR3_OFFSET3_17 (0x0020000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00020000 */ +#define ADC_OFR3_OFFSET3_18 (0x0040000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00040000 */ +#define ADC_OFR3_OFFSET3_19 (0x0080000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00080000 */ +#define ADC_OFR3_OFFSET3_20 (0x0100000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00100000 */ +#define ADC_OFR3_OFFSET3_21 (0x0200000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00200000 */ +#define ADC_OFR3_OFFSET3_22 (0x0400000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00400000 */ +#define ADC_OFR3_OFFSET3_23 (0x0800000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00800000 */ +#define ADC_OFR3_OFFSET3_24 (0x1000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x01000000 */ +#define ADC_OFR3_OFFSET3_25 (0x2000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x02000000 */ + +#define ADC_OFR3_OFFSET3_CH_Pos (26U) +#define ADC_OFR3_OFFSET3_CH_Msk (0x1FUL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR3_OFFSET3_CH ADC_OFR3_OFFSET3_CH_Msk /*!< ADC Channel selection for the data offset 3 */ +#define ADC_OFR3_OFFSET3_CH_0 (0x01UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR3_OFFSET3_CH_1 (0x02UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR3_OFFSET3_CH_2 (0x04UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR3_OFFSET3_CH_3 (0x08UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR3_OFFSET3_CH_4 (0x10UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR3_SSATE_Pos (31U) +#define ADC_OFR3_SSATE_Msk (0x1UL << ADC_OFR3_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR3_SSATE ADC_OFR3_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR3_OFFSET3_Pos (0U) +#define ADC3_OFR3_OFFSET3_Msk (0xFFFUL << ADC3_OFR3_OFFSET3_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR3_OFFSET3 ADC3_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR3_OFFSETPOS_Pos (24U) +#define ADC3_OFR3_OFFSETPOS_Msk (0x1UL << ADC3_OFR3_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR3_OFFSETPOS ADC3_OFR3_OFFSETPOS_Msk /*!< ADC offset number 3 positive */ +#define ADC3_OFR3_SATEN_Pos (25U) +#define ADC3_OFR3_SATEN_Msk (0x1UL << ADC3_OFR3_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR3_SATEN ADC3_OFR3_SATEN_Msk /*!< ADC offset number 3 saturation enable */ + +#define ADC3_OFR3_OFFSET3_EN_Pos (31U) +#define ADC3_OFR3_OFFSET3_EN_Msk (0x1UL << ADC3_OFR3_OFFSET3_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR3_OFFSET3_EN ADC3_OFR3_OFFSET3_EN_Msk /*!< ADC offset number 3 enable */ + +/******************** Bit definition for ADC_OFR4 register ********************/ +#define ADC_OFR4_OFFSET4_Pos (0U) +#define ADC_OFR4_OFFSET4_Msk (0x3FFFFFFUL << ADC_OFR4_OFFSET4_Pos) /*!< 0x03FFFFFF */ +#define ADC_OFR4_OFFSET4 ADC_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET4_CH[4:0] */ +#define ADC_OFR4_OFFSET4_0 (0x0000001UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000001 */ +#define ADC_OFR4_OFFSET4_1 (0x0000002UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000002 */ +#define ADC_OFR4_OFFSET4_2 (0x0000004UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000004 */ +#define ADC_OFR4_OFFSET4_3 (0x0000008UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000008 */ +#define ADC_OFR4_OFFSET4_4 (0x0000010UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000010 */ +#define ADC_OFR4_OFFSET4_5 (0x0000020UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000020 */ +#define ADC_OFR4_OFFSET4_6 (0x0000040UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000040 */ +#define ADC_OFR4_OFFSET4_7 (0x0000080UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000080 */ +#define ADC_OFR4_OFFSET4_8 (0x0000100UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000100 */ +#define ADC_OFR4_OFFSET4_9 (0x0000200UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000200 */ +#define ADC_OFR4_OFFSET4_10 (0x0000400UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000400 */ +#define ADC_OFR4_OFFSET4_11 (0x0000800UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000800 */ +#define ADC_OFR4_OFFSET4_12 (0x0001000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00001000 */ +#define ADC_OFR4_OFFSET4_13 (0x0002000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00002000 */ +#define ADC_OFR4_OFFSET4_14 (0x0004000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00004000 */ +#define ADC_OFR4_OFFSET4_15 (0x0008000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00008000 */ +#define ADC_OFR4_OFFSET4_16 (0x0010000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00010000 */ +#define ADC_OFR4_OFFSET4_17 (0x0020000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00020000 */ +#define ADC_OFR4_OFFSET4_18 (0x0040000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00040000 */ +#define ADC_OFR4_OFFSET4_19 (0x0080000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00080000 */ +#define ADC_OFR4_OFFSET4_20 (0x0100000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00100000 */ +#define ADC_OFR4_OFFSET4_21 (0x0200000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00200000 */ +#define ADC_OFR4_OFFSET4_22 (0x0400000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00400000 */ +#define ADC_OFR4_OFFSET4_23 (0x0800000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00800000 */ +#define ADC_OFR4_OFFSET4_24 (0x1000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x01000000 */ +#define ADC_OFR4_OFFSET4_25 (0x2000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x02000000 */ + +#define ADC_OFR4_OFFSET4_CH_Pos (26U) +#define ADC_OFR4_OFFSET4_CH_Msk (0x1FUL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x7C000000 */ +#define ADC_OFR4_OFFSET4_CH ADC_OFR4_OFFSET4_CH_Msk /*!< ADC Channel selection for the data offset 4 */ +#define ADC_OFR4_OFFSET4_CH_0 (0x01UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x04000000 */ +#define ADC_OFR4_OFFSET4_CH_1 (0x02UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x08000000 */ +#define ADC_OFR4_OFFSET4_CH_2 (0x04UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x10000000 */ +#define ADC_OFR4_OFFSET4_CH_3 (0x08UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x20000000 */ +#define ADC_OFR4_OFFSET4_CH_4 (0x10UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x40000000 */ + +#define ADC_OFR4_SSATE_Pos (31U) +#define ADC_OFR4_SSATE_Msk (0x1UL << ADC_OFR4_SSATE_Pos) /*!< 0x80000000 */ +#define ADC_OFR4_SSATE ADC_OFR4_SSATE_Msk /*!< ADC Signed saturation Enable */ + +#define ADC3_OFR4_OFFSET4_Pos (0U) +#define ADC3_OFR4_OFFSET4_Msk (0xFFFUL << ADC3_OFR4_OFFSET4_Pos) /*!< 0x00000FFF */ +#define ADC3_OFR4_OFFSET4 ADC3_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET1_CH[4:0] */ + +#define ADC3_OFR4_OFFSETPOS_Pos (24U) +#define ADC3_OFR4_OFFSETPOS_Msk (0x1UL << ADC3_OFR4_OFFSETPOS_Pos) /*!< 0x01000000 */ +#define ADC3_OFR4_OFFSETPOS ADC3_OFR4_OFFSETPOS_Msk /*!< ADC offset number 4 positive */ +#define ADC3_OFR4_SATEN_Pos (25U) +#define ADC3_OFR4_SATEN_Msk (0x1UL << ADC3_OFR4_SATEN_Pos) /*!< 0x02000000 */ +#define ADC3_OFR4_SATEN ADC3_OFR4_SATEN_Msk /*!< ADC offset number 4 saturation enable */ + +#define ADC3_OFR4_OFFSET4_EN_Pos (31U) +#define ADC3_OFR4_OFFSET4_EN_Msk (0x1UL << ADC3_OFR4_OFFSET4_EN_Pos) /*!< 0x80000000 */ +#define ADC3_OFR4_OFFSET4_EN ADC3_OFR4_OFFSET4_EN_Msk /*!< ADC offset number 4 enable */ + +/******************** Bit definition for ADC_JDR1 register ********************/ +#define ADC_JDR1_JDATA_Pos (0U) +#define ADC_JDR1_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR1_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR1_JDATA ADC_JDR1_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR1_JDATA_0 (0x00000001UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR1_JDATA_1 (0x00000002UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR1_JDATA_2 (0x00000004UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR1_JDATA_3 (0x00000008UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR1_JDATA_4 (0x00000010UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR1_JDATA_5 (0x00000020UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR1_JDATA_6 (0x00000040UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR1_JDATA_7 (0x00000080UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR1_JDATA_8 (0x00000100UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR1_JDATA_9 (0x00000200UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR1_JDATA_10 (0x00000400UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR1_JDATA_11 (0x00000800UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR1_JDATA_12 (0x00001000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR1_JDATA_13 (0x00002000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR1_JDATA_14 (0x00004000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR1_JDATA_15 (0x00008000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR1_JDATA_16 (0x00010000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR1_JDATA_17 (0x00020000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR1_JDATA_18 (0x00040000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR1_JDATA_19 (0x00080000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR1_JDATA_20 (0x00100000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR1_JDATA_21 (0x00200000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR1_JDATA_22 (0x00400000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR1_JDATA_23 (0x00800000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR1_JDATA_24 (0x01000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR1_JDATA_25 (0x02000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR1_JDATA_26 (0x04000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR1_JDATA_27 (0x08000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR1_JDATA_28 (0x10000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR1_JDATA_29 (0x20000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR1_JDATA_30 (0x40000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR1_JDATA_31 (0x80000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_JDR2 register ********************/ +#define ADC_JDR2_JDATA_Pos (0U) +#define ADC_JDR2_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR2_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR2_JDATA ADC_JDR2_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR2_JDATA_0 (0x00000001UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR2_JDATA_1 (0x00000002UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR2_JDATA_2 (0x00000004UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR2_JDATA_3 (0x00000008UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR2_JDATA_4 (0x00000010UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR2_JDATA_5 (0x00000020UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR2_JDATA_6 (0x00000040UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR2_JDATA_7 (0x00000080UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR2_JDATA_8 (0x00000100UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR2_JDATA_9 (0x00000200UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR2_JDATA_10 (0x00000400UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR2_JDATA_11 (0x00000800UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR2_JDATA_12 (0x00001000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR2_JDATA_13 (0x00002000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR2_JDATA_14 (0x00004000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR2_JDATA_15 (0x00008000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR2_JDATA_16 (0x00010000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR2_JDATA_17 (0x00020000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR2_JDATA_18 (0x00040000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR2_JDATA_19 (0x00080000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR2_JDATA_20 (0x00100000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR2_JDATA_21 (0x00200000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR2_JDATA_22 (0x00400000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR2_JDATA_23 (0x00800000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR2_JDATA_24 (0x01000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR2_JDATA_25 (0x02000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR2_JDATA_26 (0x04000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR2_JDATA_27 (0x08000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR2_JDATA_28 (0x10000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR2_JDATA_29 (0x20000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR2_JDATA_30 (0x40000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR2_JDATA_31 (0x80000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_JDR3 register ********************/ +#define ADC_JDR3_JDATA_Pos (0U) +#define ADC_JDR3_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR3_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR3_JDATA ADC_JDR3_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR3_JDATA_0 (0x00000001UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR3_JDATA_1 (0x00000002UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR3_JDATA_2 (0x00000004UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR3_JDATA_3 (0x00000008UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR3_JDATA_4 (0x00000010UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR3_JDATA_5 (0x00000020UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR3_JDATA_6 (0x00000040UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR3_JDATA_7 (0x00000080UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR3_JDATA_8 (0x00000100UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR3_JDATA_9 (0x00000200UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR3_JDATA_10 (0x00000400UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR3_JDATA_11 (0x00000800UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR3_JDATA_12 (0x00001000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR3_JDATA_13 (0x00002000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR3_JDATA_14 (0x00004000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR3_JDATA_15 (0x00008000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR3_JDATA_16 (0x00010000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR3_JDATA_17 (0x00020000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR3_JDATA_18 (0x00040000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR3_JDATA_19 (0x00080000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR3_JDATA_20 (0x00100000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR3_JDATA_21 (0x00200000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR3_JDATA_22 (0x00400000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR3_JDATA_23 (0x00800000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR3_JDATA_24 (0x01000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR3_JDATA_25 (0x02000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR3_JDATA_26 (0x04000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR3_JDATA_27 (0x08000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR3_JDATA_28 (0x10000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR3_JDATA_29 (0x20000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR3_JDATA_30 (0x40000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR3_JDATA_31 (0x80000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_JDR4 register ********************/ +#define ADC_JDR4_JDATA_Pos (0U) +#define ADC_JDR4_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR4_JDATA_Pos) /*!< 0xFFFFFFFF */ +#define ADC_JDR4_JDATA ADC_JDR4_JDATA_Msk /*!< ADC Injected DATA */ +#define ADC_JDR4_JDATA_0 (0x00000001UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000001 */ +#define ADC_JDR4_JDATA_1 (0x00000002UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000002 */ +#define ADC_JDR4_JDATA_2 (0x00000004UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000004 */ +#define ADC_JDR4_JDATA_3 (0x00000008UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000008 */ +#define ADC_JDR4_JDATA_4 (0x00000010UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000010 */ +#define ADC_JDR4_JDATA_5 (0x00000020UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000020 */ +#define ADC_JDR4_JDATA_6 (0x00000040UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000040 */ +#define ADC_JDR4_JDATA_7 (0x00000080UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000080 */ +#define ADC_JDR4_JDATA_8 (0x00000100UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000100 */ +#define ADC_JDR4_JDATA_9 (0x00000200UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000200 */ +#define ADC_JDR4_JDATA_10 (0x00000400UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000400 */ +#define ADC_JDR4_JDATA_11 (0x00000800UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000800 */ +#define ADC_JDR4_JDATA_12 (0x00001000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00001000 */ +#define ADC_JDR4_JDATA_13 (0x00002000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00002000 */ +#define ADC_JDR4_JDATA_14 (0x00004000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00004000 */ +#define ADC_JDR4_JDATA_15 (0x00008000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00008000 */ +#define ADC_JDR4_JDATA_16 (0x00010000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00010000 */ +#define ADC_JDR4_JDATA_17 (0x00020000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00020000 */ +#define ADC_JDR4_JDATA_18 (0x00040000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00040000 */ +#define ADC_JDR4_JDATA_19 (0x00080000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00080000 */ +#define ADC_JDR4_JDATA_20 (0x00100000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00100000 */ +#define ADC_JDR4_JDATA_21 (0x00200000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00200000 */ +#define ADC_JDR4_JDATA_22 (0x00400000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00400000 */ +#define ADC_JDR4_JDATA_23 (0x00800000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00800000 */ +#define ADC_JDR4_JDATA_24 (0x01000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x01000000 */ +#define ADC_JDR4_JDATA_25 (0x02000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x02000000 */ +#define ADC_JDR4_JDATA_26 (0x04000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x04000000 */ +#define ADC_JDR4_JDATA_27 (0x08000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x08000000 */ +#define ADC_JDR4_JDATA_28 (0x10000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x10000000 */ +#define ADC_JDR4_JDATA_29 (0x20000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x20000000 */ +#define ADC_JDR4_JDATA_30 (0x40000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x40000000 */ +#define ADC_JDR4_JDATA_31 (0x80000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for ADC_AWD2CR register ********************/ +#define ADC_AWD2CR_AWD2CH_Pos (0U) +#define ADC_AWD2CR_AWD2CH_Msk (0xFFFFFUL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x000FFFFF */ +#define ADC_AWD2CR_AWD2CH ADC_AWD2CR_AWD2CH_Msk /*!< ADC Analog watchdog 2 channel selection */ +#define ADC_AWD2CR_AWD2CH_0 (0x00001UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000001 */ +#define ADC_AWD2CR_AWD2CH_1 (0x00002UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000002 */ +#define ADC_AWD2CR_AWD2CH_2 (0x00004UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000004 */ +#define ADC_AWD2CR_AWD2CH_3 (0x00008UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000008 */ +#define ADC_AWD2CR_AWD2CH_4 (0x00010UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000010 */ +#define ADC_AWD2CR_AWD2CH_5 (0x00020UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000020 */ +#define ADC_AWD2CR_AWD2CH_6 (0x00040UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000040 */ +#define ADC_AWD2CR_AWD2CH_7 (0x00080UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000080 */ +#define ADC_AWD2CR_AWD2CH_8 (0x00100UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000100 */ +#define ADC_AWD2CR_AWD2CH_9 (0x00200UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000200 */ +#define ADC_AWD2CR_AWD2CH_10 (0x00400UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000400 */ +#define ADC_AWD2CR_AWD2CH_11 (0x00800UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000800 */ +#define ADC_AWD2CR_AWD2CH_12 (0x01000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00001000 */ +#define ADC_AWD2CR_AWD2CH_13 (0x02000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00002000 */ +#define ADC_AWD2CR_AWD2CH_14 (0x04000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00004000 */ +#define ADC_AWD2CR_AWD2CH_15 (0x08000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00008000 */ +#define ADC_AWD2CR_AWD2CH_16 (0x10000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00010000 */ +#define ADC_AWD2CR_AWD2CH_17 (0x20000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00020000 */ +#define ADC_AWD2CR_AWD2CH_18 (0x40000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00040000 */ +#define ADC_AWD2CR_AWD2CH_19 (0x80000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00080000 */ + +/******************** Bit definition for ADC_AWD3CR register ********************/ +#define ADC_AWD3CR_AWD3CH_Pos (0U) +#define ADC_AWD3CR_AWD3CH_Msk (0xFFFFFUL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x000FFFFF */ +#define ADC_AWD3CR_AWD3CH ADC_AWD3CR_AWD3CH_Msk /*!< ADC Analog watchdog 2 channel selection */ +#define ADC_AWD3CR_AWD3CH_0 (0x00001UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000001 */ +#define ADC_AWD3CR_AWD3CH_1 (0x00002UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000002 */ +#define ADC_AWD3CR_AWD3CH_2 (0x00004UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000004 */ +#define ADC_AWD3CR_AWD3CH_3 (0x00008UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000008 */ +#define ADC_AWD3CR_AWD3CH_4 (0x00010UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000010 */ +#define ADC_AWD3CR_AWD3CH_5 (0x00020UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000020 */ +#define ADC_AWD3CR_AWD3CH_6 (0x00040UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000040 */ +#define ADC_AWD3CR_AWD3CH_7 (0x00080UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000080 */ +#define ADC_AWD3CR_AWD3CH_8 (0x00100UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000100 */ +#define ADC_AWD3CR_AWD3CH_9 (0x00200UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000200 */ +#define ADC_AWD3CR_AWD3CH_10 (0x00400UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000400 */ +#define ADC_AWD3CR_AWD3CH_11 (0x00800UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000800 */ +#define ADC_AWD3CR_AWD3CH_12 (0x01000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00001000 */ +#define ADC_AWD3CR_AWD3CH_13 (0x02000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00002000 */ +#define ADC_AWD3CR_AWD3CH_14 (0x04000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00004000 */ +#define ADC_AWD3CR_AWD3CH_15 (0x08000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00008000 */ +#define ADC_AWD3CR_AWD3CH_16 (0x10000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00010000 */ +#define ADC_AWD3CR_AWD3CH_17 (0x20000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00020000 */ +#define ADC_AWD3CR_AWD3CH_18 (0x40000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00040000 */ +#define ADC_AWD3CR_AWD3CH_19 (0x80000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00080000 */ + +/******************** Bit definition for ADC_DIFSEL register ********************/ +#define ADC_DIFSEL_DIFSEL_Pos (0U) +#define ADC_DIFSEL_DIFSEL_Msk (0xFFFFFUL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x000FFFFF */ +#define ADC_DIFSEL_DIFSEL ADC_DIFSEL_DIFSEL_Msk /*!< ADC differential modes for channels 1 to 18 */ +#define ADC_DIFSEL_DIFSEL_0 (0x00001UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000001 */ +#define ADC_DIFSEL_DIFSEL_1 (0x00002UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000002 */ +#define ADC_DIFSEL_DIFSEL_2 (0x00004UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000004 */ +#define ADC_DIFSEL_DIFSEL_3 (0x00008UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000008 */ +#define ADC_DIFSEL_DIFSEL_4 (0x00010UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000010 */ +#define ADC_DIFSEL_DIFSEL_5 (0x00020UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000020 */ +#define ADC_DIFSEL_DIFSEL_6 (0x00040UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000040 */ +#define ADC_DIFSEL_DIFSEL_7 (0x00080UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000080 */ +#define ADC_DIFSEL_DIFSEL_8 (0x00100UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000100 */ +#define ADC_DIFSEL_DIFSEL_9 (0x00200UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000200 */ +#define ADC_DIFSEL_DIFSEL_10 (0x00400UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000400 */ +#define ADC_DIFSEL_DIFSEL_11 (0x00800UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000800 */ +#define ADC_DIFSEL_DIFSEL_12 (0x01000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00001000 */ +#define ADC_DIFSEL_DIFSEL_13 (0x02000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00002000 */ +#define ADC_DIFSEL_DIFSEL_14 (0x04000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00004000 */ +#define ADC_DIFSEL_DIFSEL_15 (0x08000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00008000 */ +#define ADC_DIFSEL_DIFSEL_16 (0x10000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00010000 */ +#define ADC_DIFSEL_DIFSEL_17 (0x20000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00020000 */ +#define ADC_DIFSEL_DIFSEL_18 (0x40000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00040000 */ +#define ADC_DIFSEL_DIFSEL_19 (0x80000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00080000 */ + +/******************** Bit definition for ADC_CALFACT register ********************/ +#define ADC_CALFACT_CALFACT_S_Pos (0U) +#define ADC_CALFACT_CALFACT_S_Msk (0x7FFUL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x000007FF */ +#define ADC_CALFACT_CALFACT_S ADC_CALFACT_CALFACT_S_Msk /*!< ADC calibration factors in single-ended mode */ +#define ADC_CALFACT_CALFACT_S_0 (0x001UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000001 */ +#define ADC_CALFACT_CALFACT_S_1 (0x002UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000002 */ +#define ADC_CALFACT_CALFACT_S_2 (0x004UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000004 */ +#define ADC_CALFACT_CALFACT_S_3 (0x008UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000008 */ +#define ADC_CALFACT_CALFACT_S_4 (0x010UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000010 */ +#define ADC_CALFACT_CALFACT_S_5 (0x020UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000020 */ +#define ADC_CALFACT_CALFACT_S_6 (0x040UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000040 */ +#define ADC_CALFACT_CALFACT_S_7 (0x080UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000080 */ +#define ADC_CALFACT_CALFACT_S_8 (0x100UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000100 */ +#define ADC_CALFACT_CALFACT_S_9 (0x200UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000200 */ +#define ADC_CALFACT_CALFACT_S_10 (0x400UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000400 */ +#define ADC_CALFACT_CALFACT_D_Pos (16U) +#define ADC_CALFACT_CALFACT_D_Msk (0x7FFUL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x07FF0000 */ +#define ADC_CALFACT_CALFACT_D ADC_CALFACT_CALFACT_D_Msk /*!< ADC calibration factors in differential mode */ +#define ADC_CALFACT_CALFACT_D_0 (0x001UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00010000 */ +#define ADC_CALFACT_CALFACT_D_1 (0x002UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00020000 */ +#define ADC_CALFACT_CALFACT_D_2 (0x004UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00040000 */ +#define ADC_CALFACT_CALFACT_D_3 (0x008UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00080000 */ +#define ADC_CALFACT_CALFACT_D_4 (0x010UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00100000 */ +#define ADC_CALFACT_CALFACT_D_5 (0x020UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00200000 */ +#define ADC_CALFACT_CALFACT_D_6 (0x040UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00400000 */ +#define ADC_CALFACT_CALFACT_D_7 (0x080UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00800000 */ +#define ADC_CALFACT_CALFACT_D_8 (0x100UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x01000000 */ +#define ADC_CALFACT_CALFACT_D_9 (0x200UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x02000000 */ +#define ADC_CALFACT_CALFACT_D_10 (0x400UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x04000000 */ + +/******************** Bit definition for ADC_CALFACT2 register ********************/ +#define ADC_CALFACT2_LINCALFACT_Pos (0U) +#define ADC_CALFACT2_LINCALFACT_Msk (0x3FFFFFFFUL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x3FFFFFFF */ +#define ADC_CALFACT2_LINCALFACT ADC_CALFACT2_LINCALFACT_Msk /*!< ADC Linearity calibration factors */ +#define ADC_CALFACT2_LINCALFACT_0 (0x00000001UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000001 */ +#define ADC_CALFACT2_LINCALFACT_1 (0x00000002UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000002 */ +#define ADC_CALFACT2_LINCALFACT_2 (0x00000004UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000004 */ +#define ADC_CALFACT2_LINCALFACT_3 (0x00000008UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000008 */ +#define ADC_CALFACT2_LINCALFACT_4 (0x00000010UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000010 */ +#define ADC_CALFACT2_LINCALFACT_5 (0x00000020UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000020 */ +#define ADC_CALFACT2_LINCALFACT_6 (0x00000040UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000040 */ +#define ADC_CALFACT2_LINCALFACT_7 (0x00000080UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000080 */ +#define ADC_CALFACT2_LINCALFACT_8 (0x00000100UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000100 */ +#define ADC_CALFACT2_LINCALFACT_9 (0x00000200UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000200 */ +#define ADC_CALFACT2_LINCALFACT_10 (0x00000400UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000400 */ +#define ADC_CALFACT2_LINCALFACT_11 (0x00000800UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000800 */ +#define ADC_CALFACT2_LINCALFACT_12 (0x00001000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00001000 */ +#define ADC_CALFACT2_LINCALFACT_13 (0x00002000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00002000 */ +#define ADC_CALFACT2_LINCALFACT_14 (0x00004000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00004000 */ +#define ADC_CALFACT2_LINCALFACT_15 (0x00008000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00008000 */ +#define ADC_CALFACT2_LINCALFACT_16 (0x00010000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00010000 */ +#define ADC_CALFACT2_LINCALFACT_17 (0x00020000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00020000 */ +#define ADC_CALFACT2_LINCALFACT_18 (0x00040000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00040000 */ +#define ADC_CALFACT2_LINCALFACT_19 (0x00080000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00080000 */ +#define ADC_CALFACT2_LINCALFACT_20 (0x00100000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00100000 */ +#define ADC_CALFACT2_LINCALFACT_21 (0x00200000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00200000 */ +#define ADC_CALFACT2_LINCALFACT_22 (0x00400000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00400000 */ +#define ADC_CALFACT2_LINCALFACT_23 (0x00800000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00800000 */ +#define ADC_CALFACT2_LINCALFACT_24 (0x01000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x01000000 */ +#define ADC_CALFACT2_LINCALFACT_25 (0x02000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x02000000 */ +#define ADC_CALFACT2_LINCALFACT_26 (0x04000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x04000000 */ +#define ADC_CALFACT2_LINCALFACT_27 (0x08000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x08000000 */ +#define ADC_CALFACT2_LINCALFACT_28 (0x10000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x10000000 */ +#define ADC_CALFACT2_LINCALFACT_29 (0x20000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x20000000 */ + +/************************* ADC Common registers *****************************/ +/******************** Bit definition for ADC_CSR register ********************/ +#define ADC_CSR_ADRDY_MST_Pos (0U) +#define ADC_CSR_ADRDY_MST_Msk (0x1UL << ADC_CSR_ADRDY_MST_Pos) /*!< 0x00000001 */ +#define ADC_CSR_ADRDY_MST ADC_CSR_ADRDY_MST_Msk /*!< Master ADC ready */ +#define ADC_CSR_EOSMP_MST_Pos (1U) +#define ADC_CSR_EOSMP_MST_Msk (0x1UL << ADC_CSR_EOSMP_MST_Pos) /*!< 0x00000002 */ +#define ADC_CSR_EOSMP_MST ADC_CSR_EOSMP_MST_Msk /*!< End of sampling phase flag of the master ADC */ +#define ADC_CSR_EOC_MST_Pos (2U) +#define ADC_CSR_EOC_MST_Msk (0x1UL << ADC_CSR_EOC_MST_Pos) /*!< 0x00000004 */ +#define ADC_CSR_EOC_MST ADC_CSR_EOC_MST_Msk /*!< End of regular conversion of the master ADC */ +#define ADC_CSR_EOS_MST_Pos (3U) +#define ADC_CSR_EOS_MST_Msk (0x1UL << ADC_CSR_EOS_MST_Pos) /*!< 0x00000008 */ +#define ADC_CSR_EOS_MST ADC_CSR_EOS_MST_Msk /*!< End of regular sequence flag of the master ADC */ +#define ADC_CSR_OVR_MST_Pos (4U) +#define ADC_CSR_OVR_MST_Msk (0x1UL << ADC_CSR_OVR_MST_Pos) /*!< 0x00000010 */ +#define ADC_CSR_OVR_MST ADC_CSR_OVR_MST_Msk /*!< Overrun flag of the master ADC */ +#define ADC_CSR_JEOC_MST_Pos (5U) +#define ADC_CSR_JEOC_MST_Msk (0x1UL << ADC_CSR_JEOC_MST_Pos) /*!< 0x00000020 */ +#define ADC_CSR_JEOC_MST ADC_CSR_JEOC_MST_Msk /*!< End of injected conversion of the master ADC */ +#define ADC_CSR_JEOS_MST_Pos (6U) +#define ADC_CSR_JEOS_MST_Msk (0x1UL << ADC_CSR_JEOS_MST_Pos) /*!< 0x00000040 */ +#define ADC_CSR_JEOS_MST ADC_CSR_JEOS_MST_Msk /*!< End of injected sequence flag of the master ADC */ +#define ADC_CSR_AWD1_MST_Pos (7U) +#define ADC_CSR_AWD1_MST_Msk (0x1UL << ADC_CSR_AWD1_MST_Pos) /*!< 0x00000080 */ +#define ADC_CSR_AWD1_MST ADC_CSR_AWD1_MST_Msk /*!< Analog watchdog 1 flag of the master ADC */ +#define ADC_CSR_AWD2_MST_Pos (8U) +#define ADC_CSR_AWD2_MST_Msk (0x1UL << ADC_CSR_AWD2_MST_Pos) /*!< 0x00000100 */ +#define ADC_CSR_AWD2_MST ADC_CSR_AWD2_MST_Msk /*!< Analog watchdog 2 flag of the master ADC */ +#define ADC_CSR_AWD3_MST_Pos (9U) +#define ADC_CSR_AWD3_MST_Msk (0x1UL << ADC_CSR_AWD3_MST_Pos) /*!< 0x00000200 */ +#define ADC_CSR_AWD3_MST ADC_CSR_AWD3_MST_Msk /*!< Analog watchdog 3 flag of the master ADC */ +#define ADC_CSR_JQOVF_MST_Pos (10U) +#define ADC_CSR_JQOVF_MST_Msk (0x1UL << ADC_CSR_JQOVF_MST_Pos) /*!< 0x00000400 */ +#define ADC_CSR_JQOVF_MST ADC_CSR_JQOVF_MST_Msk /*!< Injected context queue overflow flag of the master ADC */ +#define ADC_CSR_ADRDY_SLV_Pos (16U) +#define ADC_CSR_ADRDY_SLV_Msk (0x1UL << ADC_CSR_ADRDY_SLV_Pos) /*!< 0x00010000 */ +#define ADC_CSR_ADRDY_SLV ADC_CSR_ADRDY_SLV_Msk /*!< Slave ADC ready */ +#define ADC_CSR_EOSMP_SLV_Pos (17U) +#define ADC_CSR_EOSMP_SLV_Msk (0x1UL << ADC_CSR_EOSMP_SLV_Pos) /*!< 0x00020000 */ +#define ADC_CSR_EOSMP_SLV ADC_CSR_EOSMP_SLV_Msk /*!< End of sampling phase flag of the slave ADC */ +#define ADC_CSR_EOC_SLV_Pos (18U) +#define ADC_CSR_EOC_SLV_Msk (0x1UL << ADC_CSR_EOC_SLV_Pos) /*!< 0x00040000 */ +#define ADC_CSR_EOC_SLV ADC_CSR_EOC_SLV_Msk /*!< End of regular conversion of the slave ADC */ +#define ADC_CSR_EOS_SLV_Pos (19U) +#define ADC_CSR_EOS_SLV_Msk (0x1UL << ADC_CSR_EOS_SLV_Pos) /*!< 0x00080000 */ +#define ADC_CSR_EOS_SLV ADC_CSR_EOS_SLV_Msk /*!< End of regular sequence flag of the slave ADC */ +#define ADC_CSR_OVR_SLV_Pos (20U) +#define ADC_CSR_OVR_SLV_Msk (0x1UL << ADC_CSR_OVR_SLV_Pos) /*!< 0x00100000 */ +#define ADC_CSR_OVR_SLV ADC_CSR_OVR_SLV_Msk /*!< Overrun flag of the slave ADC */ +#define ADC_CSR_JEOC_SLV_Pos (21U) +#define ADC_CSR_JEOC_SLV_Msk (0x1UL << ADC_CSR_JEOC_SLV_Pos) /*!< 0x00200000 */ +#define ADC_CSR_JEOC_SLV ADC_CSR_JEOC_SLV_Msk /*!< End of injected conversion of the slave ADC */ +#define ADC_CSR_JEOS_SLV_Pos (22U) +#define ADC_CSR_JEOS_SLV_Msk (0x1UL << ADC_CSR_JEOS_SLV_Pos) /*!< 0x00400000 */ +#define ADC_CSR_JEOS_SLV ADC_CSR_JEOS_SLV_Msk /*!< End of injected sequence flag of the slave ADC */ +#define ADC_CSR_AWD1_SLV_Pos (23U) +#define ADC_CSR_AWD1_SLV_Msk (0x1UL << ADC_CSR_AWD1_SLV_Pos) /*!< 0x00800000 */ +#define ADC_CSR_AWD1_SLV ADC_CSR_AWD1_SLV_Msk /*!< Analog watchdog 1 flag of the slave ADC */ +#define ADC_CSR_AWD2_SLV_Pos (24U) +#define ADC_CSR_AWD2_SLV_Msk (0x1UL << ADC_CSR_AWD2_SLV_Pos) /*!< 0x01000000 */ +#define ADC_CSR_AWD2_SLV ADC_CSR_AWD2_SLV_Msk /*!< Analog watchdog 2 flag of the slave ADC */ +#define ADC_CSR_AWD3_SLV_Pos (25U) +#define ADC_CSR_AWD3_SLV_Msk (0x1UL << ADC_CSR_AWD3_SLV_Pos) /*!< 0x02000000 */ +#define ADC_CSR_AWD3_SLV ADC_CSR_AWD3_SLV_Msk /*!< Analog watchdog 3 flag of the slave ADC */ +#define ADC_CSR_JQOVF_SLV_Pos (26U) +#define ADC_CSR_JQOVF_SLV_Msk (0x1UL << ADC_CSR_JQOVF_SLV_Pos) /*!< 0x04000000 */ +#define ADC_CSR_JQOVF_SLV ADC_CSR_JQOVF_SLV_Msk /*!< Injected context queue overflow flag of the slave ADC */ + +/******************** Bit definition for ADC_CCR register ********************/ +#define ADC_CCR_DUAL_Pos (0U) +#define ADC_CCR_DUAL_Msk (0x1FUL << ADC_CCR_DUAL_Pos) /*!< 0x0000001F */ +#define ADC_CCR_DUAL ADC_CCR_DUAL_Msk /*!< Dual ADC mode selection */ +#define ADC_CCR_DUAL_0 (0x01UL << ADC_CCR_DUAL_Pos) /*!< 0x00000001 */ +#define ADC_CCR_DUAL_1 (0x02UL << ADC_CCR_DUAL_Pos) /*!< 0x00000002 */ +#define ADC_CCR_DUAL_2 (0x04UL << ADC_CCR_DUAL_Pos) /*!< 0x00000004 */ +#define ADC_CCR_DUAL_3 (0x08UL << ADC_CCR_DUAL_Pos) /*!< 0x00000008 */ +#define ADC_CCR_DUAL_4 (0x10UL << ADC_CCR_DUAL_Pos) /*!< 0x00000010 */ + +#define ADC_CCR_DELAY_Pos (8U) +#define ADC_CCR_DELAY_Msk (0xFUL << ADC_CCR_DELAY_Pos) /*!< 0x00000F00 */ +#define ADC_CCR_DELAY ADC_CCR_DELAY_Msk /*!< Delay between 2 sampling phases */ +#define ADC_CCR_DELAY_0 (0x1UL << ADC_CCR_DELAY_Pos) /*!< 0x00000100 */ +#define ADC_CCR_DELAY_1 (0x2UL << ADC_CCR_DELAY_Pos) /*!< 0x00000200 */ +#define ADC_CCR_DELAY_2 (0x4UL << ADC_CCR_DELAY_Pos) /*!< 0x00000400 */ +#define ADC_CCR_DELAY_3 (0x8UL << ADC_CCR_DELAY_Pos) /*!< 0x00000800 */ + + +#define ADC_CCR_DAMDF_Pos (14U) +#define ADC_CCR_DAMDF_Msk (0x3UL << ADC_CCR_DAMDF_Pos) /*!< 0x0000C000 */ +#define ADC_CCR_DAMDF ADC_CCR_DAMDF_Msk /*!< Dual ADC mode Data format */ +#define ADC_CCR_DAMDF_0 (0x1UL << ADC_CCR_DAMDF_Pos) /*!< 0x00004000 */ +#define ADC_CCR_DAMDF_1 (0x2UL << ADC_CCR_DAMDF_Pos) /*!< 0x00008000 */ + +#define ADC_CCR_CKMODE_Pos (16U) +#define ADC_CCR_CKMODE_Msk (0x3UL << ADC_CCR_CKMODE_Pos) /*!< 0x00030000 */ +#define ADC_CCR_CKMODE ADC_CCR_CKMODE_Msk /*!< ADC clock mode */ +#define ADC_CCR_CKMODE_0 (0x1UL << ADC_CCR_CKMODE_Pos) /*!< 0x00010000 */ +#define ADC_CCR_CKMODE_1 (0x2UL << ADC_CCR_CKMODE_Pos) /*!< 0x00020000 */ + +#define ADC_CCR_PRESC_Pos (18U) +#define ADC_CCR_PRESC_Msk (0xFUL << ADC_CCR_PRESC_Pos) /*!< 0x003C0000 */ +#define ADC_CCR_PRESC ADC_CCR_PRESC_Msk /*!< ADC prescaler */ +#define ADC_CCR_PRESC_0 (0x1UL << ADC_CCR_PRESC_Pos) /*!< 0x00040000 */ +#define ADC_CCR_PRESC_1 (0x2UL << ADC_CCR_PRESC_Pos) /*!< 0x00080000 */ +#define ADC_CCR_PRESC_2 (0x4UL << ADC_CCR_PRESC_Pos) /*!< 0x00100000 */ +#define ADC_CCR_PRESC_3 (0x8UL << ADC_CCR_PRESC_Pos) /*!< 0x00200000 */ + +#define ADC_CCR_VREFEN_Pos (22U) +#define ADC_CCR_VREFEN_Msk (0x1UL << ADC_CCR_VREFEN_Pos) /*!< 0x00400000 */ +#define ADC_CCR_VREFEN ADC_CCR_VREFEN_Msk /*!< VREFINT enable */ +#define ADC_CCR_TSEN_Pos (23U) +#define ADC_CCR_TSEN_Msk (0x1UL << ADC_CCR_TSEN_Pos) /*!< 0x00800000 */ +#define ADC_CCR_TSEN ADC_CCR_TSEN_Msk /*!< Temperature sensor enable */ +#define ADC_CCR_VBATEN_Pos (24U) +#define ADC_CCR_VBATEN_Msk (0x1UL << ADC_CCR_VBATEN_Pos) /*!< 0x01000000 */ +#define ADC_CCR_VBATEN ADC_CCR_VBATEN_Msk /*!< VBAT enable */ + +/******************** Bit definition for ADC_CDR register *******************/ +#define ADC_CDR_RDATA_MST_Pos (0U) +#define ADC_CDR_RDATA_MST_Msk (0xFFFFUL << ADC_CDR_RDATA_MST_Pos) /*!< 0x0000FFFF */ +#define ADC_CDR_RDATA_MST ADC_CDR_RDATA_MST_Msk /*!< ADC multimode master group regular conversion data */ + +#define ADC_CDR_RDATA_SLV_Pos (16U) +#define ADC_CDR_RDATA_SLV_Msk (0xFFFFUL << ADC_CDR_RDATA_SLV_Pos) /*!< 0xFFFF0000 */ +#define ADC_CDR_RDATA_SLV ADC_CDR_RDATA_SLV_Msk /*!< ADC multimode slave group regular conversion data */ + +/******************** Bit definition for ADC_CDR2 register ******************/ +#define ADC_CDR2_RDATA_ALT_Pos (0U) +#define ADC_CDR2_RDATA_ALT_Msk (0xFFFFFFFFUL << ADC_CDR2_RDATA_ALT_Pos) /*!< 0xFFFFFFFF */ +#define ADC_CDR2_RDATA_ALT ADC_CDR2_RDATA_ALT_Msk /*!< Regular data of the master/slave alternated ADCs */ + + +/******************************************************************************/ +/* */ +/* VREFBUF */ +/* */ +/******************************************************************************/ +/******************* Bit definition for VREFBUF_CSR register ****************/ +#define VREFBUF_CSR_ENVR_Pos (0U) +#define VREFBUF_CSR_ENVR_Msk (0x1UL << VREFBUF_CSR_ENVR_Pos) /*!< 0x00000001 */ +#define VREFBUF_CSR_ENVR VREFBUF_CSR_ENVR_Msk /*!*/ +#define DAC_CR_CEN1_Pos (14U) +#define DAC_CR_CEN1_Msk (0x1UL << DAC_CR_CEN1_Pos) /*!< 0x00004000 */ +#define DAC_CR_CEN1 DAC_CR_CEN1_Msk /*!*/ + +#define DAC_CR_EN2_Pos (16U) +#define DAC_CR_EN2_Msk (0x1UL << DAC_CR_EN2_Pos) /*!< 0x00010000 */ +#define DAC_CR_EN2 DAC_CR_EN2_Msk /*!*/ +#define DAC_CR_CEN2_Pos (30U) +#define DAC_CR_CEN2_Msk (0x1UL << DAC_CR_CEN2_Pos) /*!< 0x40000000 */ +#define DAC_CR_CEN2 DAC_CR_CEN2_Msk /*!*/ + +/***************** Bit definition for DAC_SWTRIGR register ******************/ +#define DAC_SWTRIGR_SWTRIG1_Pos (0U) +#define DAC_SWTRIGR_SWTRIG1_Msk (0x1UL << DAC_SWTRIGR_SWTRIG1_Pos) /*!< 0x00000001 */ +#define DAC_SWTRIGR_SWTRIG1 DAC_SWTRIGR_SWTRIG1_Msk /*!
    © Copyright (c) 2017 STMicroelectronics. + * All rights reserved.
    + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32h7xx + * @{ + */ + +#ifndef STM32H7xx_H +#define STM32H7xx_H + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + +/** @addtogroup Library_configuration_section + * @{ + */ + +/** + * @brief STM32 Family + */ +#if !defined (STM32H7) +#define STM32H7 +#endif /* STM32H7 */ + + +/* Uncomment the line below according to the target STM32H7 device used in your + application + */ + +/* #if !defined (STM32H743xx) && !defined (STM32H753xx) && !defined (STM32H750xx) && !defined (STM32H742xx) && \ + !defined (STM32H745xx) && !defined (STM32H755xx) && !defined (STM32H747xx) && !defined (STM32H757xx) && \ + !defined (STM32H7A3xx) && !defined (STM32H7A3xxQ) && !defined (STM32H7B3xx) && !defined (STM32H7B3xxQ) && !defined (STM32H7B0xx) && !defined (STM32H7B0xxQ) && \ + !defined (STM32H735xx) && !defined (STM32H733xx) && !defined (STM32H730xx) && !defined (STM32H730xxQ) && !defined (STM32H725xx) && !defined (STM32H723xx) */ + /* #define STM32H742xx */ /*!< STM32H742VI, STM32H742ZI, STM32H742AI, STM32H742II, STM32H742BI, STM32H742XI Devices */ + /* #define STM32H743xx */ /*!< STM32H743VI, STM32H743ZI, STM32H743AI, STM32H743II, STM32H743BI, STM32H743XI Devices */ + /* #define STM32H753xx */ /*!< STM32H753VI, STM32H753ZI, STM32H753AI, STM32H753II, STM32H753BI, STM32H753XI Devices */ + /* #define STM32H750xx */ /*!< STM32H750V, STM32H750I, STM32H750X Devices */ + /* #define STM32H747xx */ /*!< STM32H747ZI, STM32H747AI, STM32H747II, STM32H747BI, STM32H747XI Devices */ + /* #define STM32H757xx */ /*!< STM32H757ZI, STM32H757AI, STM32H757II, STM32H757BI, STM32H757XI Devices */ + /* #define STM32H745xx */ /*!< STM32H745ZI, STM32H745II, STM32H745BI, STM32H745XI Devices */ + /* #define STM32H755xx */ /*!< STM32H755ZI, STM32H755II, STM32H755BI, STM32H755XI Devices */ + /* #define STM32H7B0xx */ /*!< STM32H7B0ABIxQ, STM32H7B0IBTx, STM32H7B0RBTx, STM32H7B0VBTx, STM32H7B0ZBTx, STM32H7B0IBKxQ */ + /* #define STM32H7A3xx */ /*!< STM32H7A3IIK6, STM32H7A3IIT6, STM32H7A3NIH6, STM32H7A3RIT6, STM32H7A3VIH6, STM32H7A3VIT6, STM32H7A3ZIT6 */ + /* #define STM32H7A3xxQ */ /*!< STM32H7A3QIY6Q, STM32H7A3IIK6Q, STM32H7A3IIT6Q, STM32H7A3LIH6Q, STM32H7A3VIH6Q, STM32H7A3VIT6Q, STM32H7A3AII6Q, STM32H7A3ZIT6Q */ + /* #define STM32H7B3xx */ /*!< STM32H7B3IIK6, STM32H7B3IIT6, STM32H7B3NIH6, STM32H7B3RIT6, STM32H7B3VIH6, STM32H7B3VIT6, STM32H7B3ZIT6 */ + /* #define STM32H7B3xxQ */ /*!< STM32H7B3QIY6Q, STM32H7B3IIK6Q, STM32H7B3IIT6Q, STM32H7B3LIH6Q, STM32H7B3VIH6Q, STM32H7B3VIT6Q, STM32H7B3AII6Q, STM32H7B3ZIT6Q */ + /* #define STM32H735xx */ /*!< STM32H735AGI6, STM32H735IGK6, STM32H735RGV6, STM32H735VGT6, STM32H735VGY6, STM32H735ZGT6 Devices */ + /* #define STM32H733xx */ /*!< STM32H733VGH6, STM32H733VGT6, STM32H733ZGI6, STM32H733ZGT6, Devices */ + /* #define STM32H730xx */ /*!< STM32H730VBH6, STM32H730VBT6, STM32H730ZBT6, STM32H730ZBI6 Devices */ + /* #define STM32H730xxQ */ /*!< STM32H730IBT6Q, STM32H730ABI6Q, STM32H730IBK6Q Devices */ + /* #define STM32H725xx */ /*!< STM32H725AGI6, STM32H725IGK6, STM32H725IGT6, STM32H725RGV6, STM32H725VGT6, STM32H725VGY6, STM32H725ZGT6, STM32H725REV6, SM32H725VET6, STM32H725ZET6, STM32H725AEI6, STM32H725IET6, STM32H725IEK6 Devices */ + /* #define STM32H723xx */ /*!< STM32H723VGH6, STM32H723VGT6, STM32H723ZGI6, STM32H723ZGT6, STM32H723VET6, STM32H723VEH6, STM32H723ZET6, STM32H723ZEI6 Devices */ +/* #endif */ + +/* Tip: To avoid modifying this file each time you need to switch between these + devices, you can define the device in your toolchain compiler preprocessor. + */ + +#if defined(DUAL_CORE) && !defined(CORE_CM4) && !defined(CORE_CM7) + #error "Dual core device, please select CORE_CM4 or CORE_CM7" +#endif + +#if !defined (USE_HAL_DRIVER) +/** + * @brief Comment the line below if you will not use the peripherals drivers. + In this case, these drivers will not be included and the application code will + be based on direct access to peripherals registers + */ + /*#define USE_HAL_DRIVER */ +#endif /* USE_HAL_DRIVER */ + +/** + * @brief CMSIS Device version number V1.10.0 + */ +#define __STM32H7xx_CMSIS_DEVICE_VERSION_MAIN (0x01) /*!< [31:24] main version */ +#define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 (0x0A) /*!< [23:16] sub1 version */ +#define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ +#define __STM32H7xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */ +#define __STM32H7xx_CMSIS_DEVICE_VERSION ((__STM32H7xx_CMSIS_DEVICE_VERSION_MAIN << 24)\ + |(__STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 << 16)\ + |(__STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 << 8 )\ + |(__STM32H7xx_CMSIS_DEVICE_VERSION_RC)) + +/** + * @} + */ + +/** @addtogroup Device_Included + * @{ + */ + +#if defined(STM32H743xx) + #include "stm32h743xx.h" +// #elif defined(STM32H753xx) +// #include "stm32h753xx.h" +// #elif defined(STM32H750xx) +// #include "stm32h750xx.h" +// #elif defined(STM32H742xx) +// #include "stm32h742xx.h" +// #elif defined(STM32H745xx) +// #include "stm32h745xx.h" +// #elif defined(STM32H755xx) +// #include "stm32h755xx.h" +// #elif defined(STM32H747xx) +// #include "stm32h747xx.h" +// #elif defined(STM32H757xx) +// #include "stm32h757xx.h" +// #elif defined(STM32H7B0xx) +// #include "stm32h7b0xx.h" +// #elif defined(STM32H7B0xxQ) +// #include "stm32h7b0xxq.h" +// #elif defined(STM32H7A3xx) +// #include "stm32h7a3xx.h" +// #elif defined(STM32H7B3xx) +// #include "stm32h7b3xx.h" +// #elif defined(STM32H7A3xxQ) +// #include "stm32h7a3xxq.h" +// #elif defined(STM32H7B3xxQ) +// #include "stm32h7b3xxq.h" +#elif defined(STM32H735xx) + #include "stm32h735xx.h" +// #elif defined(STM32H733xx) +// #include "stm32h733xx.h" +// #elif defined(STM32H730xx) +// #include "stm32h730xx.h" +// #elif defined(STM32H730xxQ) +// #include "stm32h730xxq.h" +#elif defined(STM32H725xx) + #include "stm32h725xx.h" +// #elif defined(STM32H723xx) +// #include "stm32h723xx.h" +#else + #error "Please select first the target STM32H7xx device used in your application (in stm32h7xx.h file)" +#endif + +/** + * @} + */ + +/** @addtogroup Exported_types + * @{ + */ +typedef enum +{ + RESET = 0, + SET = !RESET +} FlagStatus, ITStatus; + +typedef enum +{ + DISABLE = 0, + ENABLE = !DISABLE +} FunctionalState; +#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) + +typedef enum +{ + SUCCESS = 0, + ERROR = !SUCCESS +} ErrorStatus; + +/** + * @} + */ + + +/** @addtogroup Exported_macros + * @{ + */ +#define SET_BIT(REG, BIT) ((REG) |= (BIT)) + +#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) + +#define READ_BIT(REG, BIT) ((REG) & (BIT)) + +#define CLEAR_REG(REG) ((REG) = (0x0)) + +#define WRITE_REG(REG, VAL) ((REG) = (VAL)) + +#define READ_REG(REG) ((REG)) + +#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) + +#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) + + +/** + * @} + */ + +#if defined (USE_HAL_DRIVER) + #include "stm32h7xx_hal.h" +#endif /* USE_HAL_DRIVER */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* STM32H7xx_H */ +/** + * @} + */ + +/** + * @} + */ + + + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/panda/board/stm32h7/inc/stm32h7xx_hal_def.h b/panda/board/stm32h7/inc/stm32h7xx_hal_def.h new file mode 100644 index 00000000000000..3854b1cd39df5b --- /dev/null +++ b/panda/board/stm32h7/inc/stm32h7xx_hal_def.h @@ -0,0 +1,221 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_def.h + * @author MCD Application Team + * @brief This file contains HAL common defines, enumeration, macros and + * structures definitions. + ****************************************************************************** + * @attention + * + *

    © Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

    + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32H7xx_HAL_DEF +#define STM32H7xx_HAL_DEF + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +//#include "Legacy/stm32_hal_legacy.h" +//#include +//#include + +/* Exported types ------------------------------------------------------------*/ + +/** + * @brief HAL Status structures definition + */ +typedef enum +{ + HAL_OK = 0x00, + HAL_ERROR = 0x01, + HAL_BUSY = 0x02, + HAL_TIMEOUT = 0x03 +} HAL_StatusTypeDef; + +/** + * @brief HAL Lock structures definition + */ +typedef enum +{ + HAL_UNLOCKED = 0x00, + HAL_LOCKED = 0x01 +} HAL_LockTypeDef; + +/* Exported macro ------------------------------------------------------------*/ + +#define HAL_MAX_DELAY 0xFFFFFFFFU + +#define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) +#define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) + +#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ + do{ \ + (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ + (__DMA_HANDLE__).Parent = (__HANDLE__); \ + } while(0) + +#define UNUSED(x) ((void)(x)) + +/** @brief Reset the Handle's State field. + * @param __HANDLE__: specifies the Peripheral Handle. + * @note This macro can be used for the following purpose: + * - When the Handle is declared as local variable; before passing it as parameter + * to HAL_PPP_Init() for the first time, it is mandatory to use this macro + * to set to 0 the Handle's "State" field. + * Otherwise, "State" field may have any random value and the first time the function + * HAL_PPP_Init() is called, the low level hardware initialization will be missed + * (i.e. HAL_PPP_MspInit() will not be executed). + * - When there is a need to reconfigure the low level hardware: instead of calling + * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). + * In this later function, when the Handle's "State" field is set to 0, it will execute the function + * HAL_PPP_MspInit() which will reconfigure the low level hardware. + * @retval None + */ +#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) + +#if (USE_RTOS == 1) + #error " USE_RTOS should be 0 in the current HAL release " +#else + #define __HAL_LOCK(__HANDLE__) \ + do{ \ + if((__HANDLE__)->Lock == HAL_LOCKED) \ + { \ + return HAL_BUSY; \ + } \ + else \ + { \ + (__HANDLE__)->Lock = HAL_LOCKED; \ + } \ + }while (0) + + #define __HAL_UNLOCK(__HANDLE__) \ + do{ \ + (__HANDLE__)->Lock = HAL_UNLOCKED; \ + }while (0) +#endif /* USE_RTOS */ + + +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ + #ifndef __weak + #define __weak __attribute__((weak)) + #endif + #ifndef __packed + #define __packed __attribute__((packed)) + #endif +#elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ + #ifndef __weak + #define __weak __attribute__((weak)) + #endif /* __weak */ + #ifndef __packed + #define __packed __attribute__((__packed__)) + #endif /* __packed */ +#endif /* __GNUC__ */ + + +/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ + #ifndef __ALIGN_BEGIN + #define __ALIGN_BEGIN + #endif + #ifndef __ALIGN_END + #define __ALIGN_END __attribute__ ((aligned (4))) + #endif +#elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ + #ifndef __ALIGN_END + #define __ALIGN_END __attribute__ ((aligned (4))) + #endif /* __ALIGN_END */ + #ifndef __ALIGN_BEGIN + #define __ALIGN_BEGIN + #endif /* __ALIGN_BEGIN */ +#else + #ifndef __ALIGN_END + #define __ALIGN_END + #endif /* __ALIGN_END */ + #ifndef __ALIGN_BEGIN + #if defined (__CC_ARM) /* ARM Compiler V5 */ + #define __ALIGN_BEGIN __align(4) + #elif defined (__ICCARM__) /* IAR Compiler */ + #define __ALIGN_BEGIN + #endif /* __CC_ARM */ + #endif /* __ALIGN_BEGIN */ +#endif /* __GNUC__ */ + +/* Macro to get variable aligned on 32-bytes,needed for cache maintenance purpose */ +#if defined (__GNUC__) /* GNU Compiler */ + #define ALIGN_32BYTES(buf) buf __attribute__ ((aligned (32))) +#elif defined (__ICCARM__) /* IAR Compiler */ + #define ALIGN_32BYTES(buf) _Pragma("data_alignment=32") buf +#elif defined (__CC_ARM) /* ARM Compiler */ + #define ALIGN_32BYTES(buf) __align(32) buf +#endif + +/** + * @brief __RAM_FUNC definition + */ +#if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) +/* ARM Compiler V4/V5 and V6 + -------------------------- + RAM functions are defined using the toolchain options. + Functions that are executed in RAM should reside in a separate source module. + Using the 'Options for File' dialog you can simply change the 'Code / Const' + area of a module to a memory space in physical RAM. + Available memory areas are declared in the 'Target' tab of the 'Options for Target' + dialog. +*/ +#define __RAM_FUNC + +#elif defined ( __ICCARM__ ) +/* ICCARM Compiler + --------------- + RAM functions are defined using a specific toolchain keyword "__ramfunc". +*/ +#define __RAM_FUNC __ramfunc + +#elif defined ( __GNUC__ ) +/* GNU Compiler + ------------ + RAM functions are defined using a specific toolchain attribute + "__attribute__((section(".RamFunc")))". +*/ +#define __RAM_FUNC __attribute__((section(".RamFunc"))) + +#endif + +/** + * @brief __NOINLINE definition + */ +#if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) +/* ARM V4/V5 and V6 & GNU Compiler + ------------------------------- +*/ +#define __NOINLINE __attribute__ ( (noinline) ) + +#elif defined ( __ICCARM__ ) +/* ICCARM Compiler + --------------- +*/ +#define __NOINLINE _Pragma("optimize = no_inline") + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* STM32H7xx_HAL_DEF */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/panda/board/stm32h7/inc/stm32h7xx_hal_gpio_ex.h b/panda/board/stm32h7/inc/stm32h7xx_hal_gpio_ex.h new file mode 100644 index 00000000000000..14f576a424b344 --- /dev/null +++ b/panda/board/stm32h7/inc/stm32h7xx_hal_gpio_ex.h @@ -0,0 +1,489 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_gpio_ex.h + * @author MCD Application Team + * @brief Header file of GPIO HAL Extension module. + ****************************************************************************** + * @attention + * + *

    © COPYRIGHT(c) 2017 STMicroelectronics. + * All rights reserved.

    + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32H7xx_HAL_GPIO_EX_H +#define STM32H7xx_HAL_GPIO_EX_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx_hal_def.h" + +/** @addtogroup STM32H7xx_HAL_Driver + * @{ + */ + +/** @addtogroup GPIOEx GPIOEx + * @{ + */ + +/* Exported types ------------------------------------------------------------*/ + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants + * @{ + */ + +/** @defgroup GPIO_Alternate_function_selection GPIO Alternate Function Selection + * @{ + */ + +/** + * @brief AF 0 selection + */ +#define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ +#define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ +#define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ +#define GPIO_AF0_LCDBIAS ((uint8_t)0x00) /* LCDBIAS Alternate Function mapping */ +#define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ +#if defined (PWR_CPUCR_PDDS_D2) /* PWR D1 and D2 domains exists */ +#define GPIO_AF0_C1DSLEEP ((uint8_t)0x00) /* Cortex-M7 Deep Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ +#define GPIO_AF0_C1SLEEP ((uint8_t)0x00) /* Cortex-M7 Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ +#define GPIO_AF0_D1PWREN ((uint8_t)0x00) /* Domain 1 PWR enable Alternate Function mapping : available on STM32H7 Rev.B and above */ +#define GPIO_AF0_D2PWREN ((uint8_t)0x00) /* Domain 2 PWR enable Alternate Function mapping : available on STM32H7 Rev.B and above */ +#if defined(DUAL_CORE) +#define GPIO_AF0_C2DSLEEP ((uint8_t)0x00) /* Cortex-M4 Deep Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ +#define GPIO_AF0_C2SLEEP ((uint8_t)0x00) /* Cortex-M4 Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ +#endif /* DUAL_CORE */ +#endif /* PWR_CPUCR_PDDS_D2 */ + +/** + * @brief AF 1 selection + */ +#define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ +#define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ +#define GPIO_AF1_TIM16 ((uint8_t)0x01) /* TIM16 Alternate Function mapping */ +#define GPIO_AF1_TIM17 ((uint8_t)0x01) /* TIM17 Alternate Function mapping */ +#define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */ +#if defined(HRTIM1) +#define GPIO_AF1_HRTIM1 ((uint8_t)0x01) /* HRTIM1 Alternate Function mapping */ +#endif /* HRTIM1 */ +#if defined(SAI4) +#define GPIO_AF1_SAI4 ((uint8_t)0x01) /* SAI4 Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ +#endif /* SAI4 */ +#define GPIO_AF1_FMC ((uint8_t)0x01) /* FMC Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ + + +/** + * @brief AF 2 selection + */ +#define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ +#define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ +#define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ +#define GPIO_AF2_TIM12 ((uint8_t)0x02) /* TIM12 Alternate Function mapping */ +#define GPIO_AF2_SAI1 ((uint8_t)0x02) /* SAI1 Alternate Function mapping */ +#if defined(HRTIM1) +#define GPIO_AF2_HRTIM1 ((uint8_t)0x02) /* HRTIM1 Alternate Function mapping */ +#endif /* HRTIM1 */ +#define GPIO_AF2_TIM15 ((uint8_t)0x02) /* TIM15 Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ +#if defined(FDCAN3) +#define GPIO_AF2_FDCAN3 ((uint8_t)0x02) /* FDCAN3 Alternate Function mapping */ +#endif /*FDCAN3*/ + +/** + * @brief AF 3 selection + */ +#define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ +#define GPIO_AF3_LPTIM2 ((uint8_t)0x03) /* LPTIM2 Alternate Function mapping */ +#define GPIO_AF3_DFSDM1 ((uint8_t)0x03) /* DFSDM Alternate Function mapping */ +#define GPIO_AF3_LPTIM3 ((uint8_t)0x03) /* LPTIM3 Alternate Function mapping */ +#define GPIO_AF3_LPTIM4 ((uint8_t)0x03) /* LPTIM4 Alternate Function mapping */ +#define GPIO_AF3_LPTIM5 ((uint8_t)0x03) /* LPTIM5 Alternate Function mapping */ +#define GPIO_AF3_LPUART ((uint8_t)0x03) /* LPUART Alternate Function mapping */ +#if defined(OCTOSPIM) +#define GPIO_AF3_OCTOSPIM_P1 ((uint8_t)0x03) /* OCTOSPI Manager Port 1 Alternate Function mapping */ +#define GPIO_AF3_OCTOSPIM_P2 ((uint8_t)0x03) /* OCTOSPI Manager Port 2 Alternate Function mapping */ +#endif /* OCTOSPIM */ +#if defined(HRTIM1) +#define GPIO_AF3_HRTIM1 ((uint8_t)0x03) /* HRTIM1 Alternate Function mapping */ +#endif /* HRTIM1 */ +#define GPIO_AF3_LTDC ((uint8_t)0x03) /* LTDC Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ + +/** + * @brief AF 4 selection + */ +#define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ +#define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ +#define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ +#define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */ +#if defined(I2C5) +#define GPIO_AF4_I2C5 ((uint8_t)0x04) /* I2C5 Alternate Function mapping */ +#endif /* I2C5*/ +#define GPIO_AF4_TIM15 ((uint8_t)0x04) /* TIM15 Alternate Function mapping */ +#define GPIO_AF4_CEC ((uint8_t)0x04) /* CEC Alternate Function mapping */ +#define GPIO_AF4_LPTIM2 ((uint8_t)0x04) /* LPTIM2 Alternate Function mapping */ +#define GPIO_AF4_USART1 ((uint8_t)0x04) /* USART1 Alternate Function mapping */ +#if defined(USART10) +#define GPIO_AF4_USART10 ((uint8_t)0x04) /* USART10 Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ +#endif /*USART10*/ +#define GPIO_AF4_DFSDM1 ((uint8_t)0x04) /* DFSDM Alternate Function mapping */ +#if defined(DFSDM2_BASE) +#define GPIO_AF4_DFSDM2 ((uint8_t)0x04) /* DFSDM2 Alternate Function mapping */ +#endif /* DFSDM2_BASE */ +#define GPIO_AF4_DCMI ((uint8_t)0x04) /* DCMI Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ +#if defined(PSSI) +#define GPIO_AF4_PSSI ((uint8_t)0x04) /* PSSI Alternate Function mapping */ +#endif /* PSSI */ +#if defined(OCTOSPIM) +#define GPIO_AF4_OCTOSPIM_P1 ((uint8_t)0x04) /* OCTOSPI Manager Port 1 Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ +#endif /* OCTOSPIM */ + +/** + * @brief AF 5 selection + */ +#define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ +#define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */ +#define GPIO_AF5_SPI3 ((uint8_t)0x05) /* SPI3 Alternate Function mapping */ +#define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */ +#define GPIO_AF5_SPI5 ((uint8_t)0x05) /* SPI5 Alternate Function mapping */ +#define GPIO_AF5_SPI6 ((uint8_t)0x05) /* SPI6 Alternate Function mapping */ +#define GPIO_AF5_CEC ((uint8_t)0x05) /* CEC Alternate Function mapping */ +#if defined(FDCAN3) +#define GPIO_AF5_FDCAN3 ((uint8_t)0x05) /* FDCAN3 Alternate Function mapping */ +#endif /*FDCAN3*/ + +/** + * @brief AF 6 selection + */ +#define GPIO_AF6_SPI2 ((uint8_t)0x06) /* SPI2 Alternate Function mapping */ +#define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */ +#define GPIO_AF6_SAI1 ((uint8_t)0x06) /* SAI1 Alternate Function mapping */ +#define GPIO_AF6_I2C4 ((uint8_t)0x06) /* I2C4 Alternate Function mapping */ +#if defined(I2C5) +#define GPIO_AF6_I2C5 ((uint8_t)0x06) /* I2C5 Alternate Function mapping */ +#endif /* I2C5*/ +#define GPIO_AF6_DFSDM1 ((uint8_t)0x06) /* DFSDM Alternate Function mapping */ +#define GPIO_AF6_UART4 ((uint8_t)0x06) /* UART4 Alternate Function mapping */ +#if defined(DFSDM2_BASE) +#define GPIO_AF6_DFSDM2 ((uint8_t)0x06) /* DFSDM2 Alternate Function mapping */ +#endif /* DFSDM2_BASE */ +#if defined(SAI3) +#define GPIO_AF6_SAI3 ((uint8_t)0x06) /* SAI3 Alternate Function mapping */ +#endif /* SAI3 */ +#if defined(OCTOSPIM) +#define GPIO_AF6_OCTOSPIM_P1 ((uint8_t)0x06) /* OCTOSPI Manager Port 1 Alternate Function mapping */ +#endif /* OCTOSPIM */ + +/** + * @brief AF 7 selection + */ +#define GPIO_AF7_SPI2 ((uint8_t)0x07) /* SPI2 Alternate Function mapping */ +#define GPIO_AF7_SPI3 ((uint8_t)0x07) /* SPI3 Alternate Function mapping */ +#define GPIO_AF7_SPI6 ((uint8_t)0x07) /* SPI6 Alternate Function mapping */ +#define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ +#define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ +#define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ +#define GPIO_AF7_USART6 ((uint8_t)0x07) /* USART6 Alternate Function mapping */ +#define GPIO_AF7_UART7 ((uint8_t)0x07) /* UART7 Alternate Function mapping */ +#define GPIO_AF7_SDMMC1 ((uint8_t)0x07) /* SDMMC1 Alternate Function mapping */ + +/** + * @brief AF 8 selection + */ +#define GPIO_AF8_SPI6 ((uint8_t)0x08) /* SPI6 Alternate Function mapping */ +#if defined(SAI2) +#define GPIO_AF8_SAI2 ((uint8_t)0x08) /* SAI2 Alternate Function mapping */ +#endif /*SAI2*/ +#define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ +#define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ +#define GPIO_AF8_UART8 ((uint8_t)0x08) /* UART8 Alternate Function mapping */ +#define GPIO_AF8_SPDIF ((uint8_t)0x08) /* SPDIF Alternate Function mapping */ +#define GPIO_AF8_LPUART ((uint8_t)0x08) /* LPUART Alternate Function mapping */ +#define GPIO_AF8_SDMMC1 ((uint8_t)0x08) /* SDMMC1 Alternate Function mapping */ +#if defined(SAI4) +#define GPIO_AF8_SAI4 ((uint8_t)0x08) /* SAI4 Alternate Function mapping */ +#endif /* SAI4 */ + +/** + * @brief AF 9 selection + */ +#define GPIO_AF9_FDCAN1 ((uint8_t)0x09) /* FDCAN1 Alternate Function mapping */ +#define GPIO_AF9_FDCAN2 ((uint8_t)0x09) /* FDCAN2 Alternate Function mapping */ +#define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ +#define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ +#define GPIO_AF9_SDMMC2 ((uint8_t)0x09) /* SDMMC2 Alternate Function mapping */ +#define GPIO_AF9_LTDC ((uint8_t)0x09) /* LTDC Alternate Function mapping */ +#define GPIO_AF9_SPDIF ((uint8_t)0x09) /* SPDIF Alternate Function mapping */ +#define GPIO_AF9_FMC ((uint8_t)0x09) /* FMC Alternate Function mapping */ +#if defined(QUADSPI) +#define GPIO_AF9_QUADSPI ((uint8_t)0x09) /* QUADSPI Alternate Function mapping */ +#endif /* QUADSPI */ +#if defined(SAI4) +#define GPIO_AF9_SAI4 ((uint8_t)0x09) /* SAI4 Alternate Function mapping */ +#endif /* SAI4 */ +#if defined(OCTOSPIM) +#define GPIO_AF9_OCTOSPIM_P1 ((uint8_t)0x09) /* OCTOSPI Manager Port 1 Alternate Function mapping */ +#define GPIO_AF9_OCTOSPIM_P2 ((uint8_t)0x09) /* OCTOSPI Manager Port 2 Alternate Function mapping */ +#endif /* OCTOSPIM */ + +/** + * @brief AF 10 selection + */ +#if defined(SAI2) +#define GPIO_AF10_SAI2 ((uint8_t)0x0A) /* SAI2 Alternate Function mapping */ +#endif /*SAI2*/ +#define GPIO_AF10_SDMMC2 ((uint8_t)0x0A) /* SDMMC2 Alternate Function mapping */ +#if defined(USB2_OTG_FS) +#define GPIO_AF10_OTG2_FS ((uint8_t)0x0A) /* OTG2_FS Alternate Function mapping */ +#endif /*USB2_OTG_FS*/ +#define GPIO_AF10_COMP1 ((uint8_t)0x0A) /* COMP1 Alternate Function mapping */ +#define GPIO_AF10_COMP2 ((uint8_t)0x0A) /* COMP2 Alternate Function mapping */ +#if defined(LTDC) +#define GPIO_AF10_LTDC ((uint8_t)0x0A) /* LTDC Alternate Function mapping */ +#endif /*LTDC*/ +#define GPIO_AF10_CRS_SYNC ((uint8_t)0x0A) /* CRS Sync Alternate Function mapping : available on STM32H7 Rev.B and above */ +#if defined(QUADSPI) +#define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* QUADSPI Alternate Function mapping */ +#endif /* QUADSPI */ +#if defined(SAI4) +#define GPIO_AF10_SAI4 ((uint8_t)0x0A) /* SAI4 Alternate Function mapping */ +#endif /* SAI4 */ +#if !defined(USB2_OTG_FS) +#define GPIO_AF10_OTG1_FS ((uint8_t)0x0A) /* OTG1_FS Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ +#endif /* !USB2_OTG_FS */ +#define GPIO_AF10_OTG1_HS ((uint8_t)0x0A) /* OTG1_HS Alternate Function mapping */ +#if defined(OCTOSPIM) +#define GPIO_AF10_OCTOSPIM_P1 ((uint8_t)0x0A) /* OCTOSPI Manager Port 1 Alternate Function mapping */ +#endif /* OCTOSPIM */ +#define GPIO_AF10_TIM8 ((uint8_t)0x0A) /* TIM8 Alternate Function mapping */ +#define GPIO_AF10_FMC ((uint8_t)0x0A) /* FMC Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ + +/** + * @brief AF 11 selection + */ +#define GPIO_AF11_SWP ((uint8_t)0x0B) /* SWP Alternate Function mapping */ +#define GPIO_AF11_MDIOS ((uint8_t)0x0B) /* MDIOS Alternate Function mapping */ +#define GPIO_AF11_UART7 ((uint8_t)0x0B) /* UART7 Alternate Function mapping */ +#define GPIO_AF11_SDMMC2 ((uint8_t)0x0B) /* SDMMC2 Alternate Function mapping */ +#define GPIO_AF11_DFSDM1 ((uint8_t)0x0B) /* DFSDM1 Alternate Function mapping */ +#define GPIO_AF11_COMP1 ((uint8_t)0x0B) /* COMP1 Alternate Function mapping */ +#define GPIO_AF11_COMP2 ((uint8_t)0x0B) /* COMP2 Alternate Function mapping */ +#define GPIO_AF11_TIM1 ((uint8_t)0x0B) /* TIM1 Alternate Function mapping */ +#define GPIO_AF11_TIM8 ((uint8_t)0x0B) /* TIM8 Alternate Function mapping */ +#define GPIO_AF11_I2C4 ((uint8_t)0x0B) /* I2C4 Alternate Function mapping */ +#if defined(DFSDM2_BASE) +#define GPIO_AF11_DFSDM2 ((uint8_t)0x0B) /* DFSDM2 Alternate Function mapping */ +#endif /* DFSDM2_BASE */ +#if defined(USART10) +#define GPIO_AF11_USART10 ((uint8_t)0x0B) /* USART10 Alternate Function mapping */ +#endif /* USART10 */ +#if defined(UART9) +#define GPIO_AF11_UART9 ((uint8_t)0x0B) /* UART9 Alternate Function mapping */ +#endif /* UART9 */ +#if defined(ETH) +#define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETH Alternate Function mapping */ +#endif /* ETH */ +#if defined(LTDC) +#define GPIO_AF11_LTDC ((uint8_t)0x0B) /* LTDC Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ +#endif /*LTDC*/ +#if defined(OCTOSPIM) +#define GPIO_AF11_OCTOSPIM_P1 ((uint8_t)0x0B) /* OCTOSPI Manager Port 1 Alternate Function mapping */ +#endif /* OCTOSPIM */ + +/** + * @brief AF 12 selection + */ +#define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */ +#define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */ +#define GPIO_AF12_MDIOS ((uint8_t)0x0C) /* MDIOS Alternate Function mapping */ +#define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */ +#define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */ +#define GPIO_AF12_TIM1 ((uint8_t)0x0C) /* TIM1 Alternate Function mapping */ +#define GPIO_AF12_TIM8 ((uint8_t)0x0C) /* TIM8 Alternate Function mapping */ +#if defined(LTDC) +#define GPIO_AF12_LTDC ((uint8_t)0x0C) /* LTDC Alternate Function mapping */ +#endif /*LTDC*/ +#if defined(USB2_OTG_FS) +#define GPIO_AF12_OTG1_FS ((uint8_t)0x0C) /* OTG1_FS Alternate Function mapping */ +#endif /* USB2_OTG_FS */ +#if defined(OCTOSPIM) +#define GPIO_AF12_OCTOSPIM_P1 ((uint8_t)0x0C) /* OCTOSPI Manager Port 1 Alternate Function mapping */ +#endif /* OCTOSPIM */ + +/** + * @brief AF 13 selection + */ +#define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ +#define GPIO_AF13_COMP1 ((uint8_t)0x0D) /* COMP1 Alternate Function mapping */ +#define GPIO_AF13_COMP2 ((uint8_t)0x0D) /* COMP2 Alternate Function mapping */ +#if defined(LTDC) +#define GPIO_AF13_LTDC ((uint8_t)0x0D) /* LTDC Alternate Function mapping */ +#endif /*LTDC*/ +#if defined(DSI) +#define GPIO_AF13_DSI ((uint8_t)0x0D) /* DSI Alternate Function mapping */ +#endif /* DSI */ +#if defined(PSSI) +#define GPIO_AF13_PSSI ((uint8_t)0x0D) /* PSSI Alternate Function mapping */ +#endif /* PSSI */ +#define GPIO_AF13_TIM1 ((uint8_t)0x0D) /* TIM1 Alternate Function mapping */ +#if defined(TIM23) +#define GPIO_AF13_TIM23 ((uint8_t)0x0D) /* TIM23 Alternate Function mapping */ +#endif /*TIM23*/ + +/** + * @brief AF 14 selection + */ +#define GPIO_AF14_LTDC ((uint8_t)0x0E) /* LTDC Alternate Function mapping */ +#define GPIO_AF14_UART5 ((uint8_t)0x0E) /* UART5 Alternate Function mapping */ +#if defined(TIM24) +#define GPIO_AF14_TIM24 ((uint8_t)0x0E) /* TIM24 Alternate Function mapping */ +#endif /*TIM24*/ + +/** + * @brief AF 15 selection + */ +#define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ + +#define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) + + + +/** + * @} + */ + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup GPIOEx_Exported_Macros GPIO Exported Macros + * @{ + */ +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup GPIOEx_Exported_Functions GPIO Exported Functions + * @{ + */ +/** + * @} + */ +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/** @defgroup GPIOEx_Private_Constants GPIO Private Constants + * @{ + */ + +/** + * @brief GPIO pin available on the platform + */ +/* Defines the available pins per GPIOs */ +#define GPIOA_PIN_AVAILABLE GPIO_PIN_All +#define GPIOB_PIN_AVAILABLE GPIO_PIN_All +#define GPIOC_PIN_AVAILABLE GPIO_PIN_All +#define GPIOD_PIN_AVAILABLE GPIO_PIN_All +#define GPIOE_PIN_AVAILABLE GPIO_PIN_All +#define GPIOF_PIN_AVAILABLE GPIO_PIN_All +#define GPIOG_PIN_AVAILABLE GPIO_PIN_All +#if defined(GPIOI) +#define GPIOI_PIN_AVAILABLE GPIO_PIN_All +#endif /*GPIOI*/ +#if defined(GPIOI) +#define GPIOJ_PIN_AVAILABLE GPIO_PIN_All +#else +#define GPIOJ_PIN_AVAILABLE (GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 ) +#endif /* GPIOI */ +#define GPIOH_PIN_AVAILABLE GPIO_PIN_All +#if defined(GPIOI) +#define GPIOK_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | \ + GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7) +#else +#define GPIOK_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 ) +#endif /* GPIOI */ + +/** + * @} + */ + +/* Private macros ------------------------------------------------------------*/ +/** @defgroup GPIOEx_Private_Macros GPIO Private Macros + * @{ + */ +/** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index + * @{ + */ +#if defined(GPIOI) +#define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\ + ((__GPIOx__) == (GPIOB))? 1UL :\ + ((__GPIOx__) == (GPIOC))? 2UL :\ + ((__GPIOx__) == (GPIOD))? 3UL :\ + ((__GPIOx__) == (GPIOE))? 4UL :\ + ((__GPIOx__) == (GPIOF))? 5UL :\ + ((__GPIOx__) == (GPIOG))? 6UL :\ + ((__GPIOx__) == (GPIOH))? 7UL :\ + ((__GPIOx__) == (GPIOI))? 8UL :\ + ((__GPIOx__) == (GPIOJ))? 9UL : 10UL) +#else +#define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\ + ((__GPIOx__) == (GPIOB))? 1UL :\ + ((__GPIOx__) == (GPIOC))? 2UL :\ + ((__GPIOx__) == (GPIOD))? 3UL :\ + ((__GPIOx__) == (GPIOE))? 4UL :\ + ((__GPIOx__) == (GPIOF))? 5UL :\ + ((__GPIOx__) == (GPIOG))? 6UL :\ + ((__GPIOx__) == (GPIOH))? 7UL :\ + ((__GPIOx__) == (GPIOJ))? 9UL : 10UL) +#endif /* GPIOI */ + +/** + * @} + */ + +/** @defgroup GPIOEx_IS_Alternat_function_selection GPIO Check Alternate Function + * @{ + */ +/** + * @} + */ + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ +/** @defgroup GPIOEx_Private_Functions GPIO Private Functions + * @{ + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32H7xx_HAL_GPIO_EX_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/panda/board/stm32h7/inc/system_stm32h7xx.h b/panda/board/stm32h7/inc/system_stm32h7xx.h new file mode 100644 index 00000000000000..dd75af67fffea9 --- /dev/null +++ b/panda/board/stm32h7/inc/system_stm32h7xx.h @@ -0,0 +1,105 @@ +/** + ****************************************************************************** + * @file system_stm32h7xx.h + * @author MCD Application Team + * @brief CMSIS Cortex-Mx Device System Source File for STM32H7xx devices. + ****************************************************************************** + * @attention + * + *

    © Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

    + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32h7xx_system + * @{ + */ + +/** + * @brief Define to prevent recursive inclusion + */ +#ifndef SYSTEM_STM32H7XX_H +#define SYSTEM_STM32H7XX_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup STM32H7xx_System_Includes + * @{ + */ + +/** + * @} + */ + + +/** @addtogroup STM32H7xx_System_Exported_types + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetSysClockFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ +extern uint32_t SystemCoreClock; /*!< System Domain1 Clock Frequency */ +extern uint32_t SystemD2Clock; /*!< System Domain2 Clock Frequency */ +extern const uint8_t D1CorePrescTable[16] ; /*!< D1CorePrescTable prescalers table values */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Exported_Constants + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Exported_Functions + * @{ + */ + +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* SYSTEM_STM32H7XX_H */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/panda/board/stm32h7/interrupt_handlers.h b/panda/board/stm32h7/interrupt_handlers.h new file mode 100644 index 00000000000000..2b0a2b428af069 --- /dev/null +++ b/panda/board/stm32h7/interrupt_handlers.h @@ -0,0 +1,74 @@ +// ********************* Bare interrupt handlers ********************* +// Interrupts for STM32H7x5 + +void WWDG_IRQHandler(void) {handle_interrupt(WWDG_IRQn);} +void PVD_AVD_IRQHandler(void) {handle_interrupt(PVD_AVD_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 EXTI9_5_IRQHandler(void) {handle_interrupt(EXTI9_5_IRQn);} +void TIM1_BRK_IRQHandler(void) {handle_interrupt(TIM1_BRK_IRQn);} +void TIM1_UP_TIM10_IRQHandler(void) {handle_interrupt(TIM1_UP_TIM10_IRQn);} +void TIM1_TRG_COM_IRQHandler(void) {handle_interrupt(TIM1_TRG_COM_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 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 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 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);} +void FDCAN1_IT0_IRQHandler(void) {handle_interrupt(FDCAN1_IT0_IRQn);} +void FDCAN1_IT1_IRQHandler(void) {handle_interrupt(FDCAN1_IT1_IRQn);} +void FDCAN2_IT0_IRQHandler(void) {handle_interrupt(FDCAN2_IT0_IRQn);} +void FDCAN2_IT1_IRQHandler(void) {handle_interrupt(FDCAN2_IT1_IRQn);} +void FDCAN3_IT0_IRQHandler(void) {handle_interrupt(FDCAN3_IT0_IRQn);} +void FDCAN3_IT1_IRQHandler(void) {handle_interrupt(FDCAN3_IT1_IRQn);} +void FDCAN_CAL_IRQHandler(void) {handle_interrupt(FDCAN_CAL_IRQn);} +void OTG_HS_EP1_OUT_IRQHandler(void) {handle_interrupt(OTG_HS_EP1_OUT_IRQn);} +void OTG_HS_EP1_IN_IRQHandler(void) {handle_interrupt(OTG_HS_EP1_IN_IRQn);} +void OTG_HS_WKUP_IRQHandler(void) {handle_interrupt(OTG_HS_WKUP_IRQn);} +void OTG_HS_IRQHandler(void) {handle_interrupt(OTG_HS_IRQn);} diff --git a/panda/board/stm32h7/lladc.h b/panda/board/stm32h7/lladc.h new file mode 100644 index 00000000000000..795ca3533fdb03 --- /dev/null +++ b/panda/board/stm32h7/lladc.h @@ -0,0 +1,48 @@ +// 5VOUT_S = ADC12_INP5 +// VOLT_S = ADC1_INP2 +#define ADCCHAN_VOLTAGE 2 + +void adc_init(void) { + ADC1->CR &= ~(ADC_CR_DEEPPWD); //Reset deep-power-down mode + ADC1->CR |= ADC_CR_ADVREGEN; // Enable ADC regulator + while(!(ADC1->ISR & ADC_ISR_LDORDY)); + + ADC1->CR &= ~(ADC_CR_ADCALDIF); // Choose single-ended calibration + ADC1->CR |= ADC_CR_ADCALLIN; // Lineriality calibration + ADC1->CR |= ADC_CR_ADCAL; // Start calibrtation + while((ADC1->CR & ADC_CR_ADCAL) != 0); + + ADC1->ISR |= ADC_ISR_ADRDY; + ADC1->CR |= ADC_CR_ADEN; + while(!(ADC1->ISR & ADC_ISR_ADRDY)); +} + +uint32_t adc_get(unsigned int channel) { + + ADC1->SQR1 &= ~(ADC_SQR1_L); + ADC1->SQR1 = (channel << 6U); + + ADC1->SMPR1 = (0x7U << (channel * 3U) ); + ADC1->PCSEL_RES0 = (0x1U << channel); + + ADC1->CR |= ADC_CR_ADSTART; + while (!(ADC1->ISR & ADC_ISR_EOC)); + + uint16_t res = ADC1->DR; + + while (!(ADC1->ISR & ADC_ISR_EOS)); + ADC1->ISR |= ADC_ISR_EOS; + + return res; +} + +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) * (65535/3.3) + // RETVAL = ADCV * s = VIN_S*1000 + // s = 1000/((65535/3.3)*(1/11)) = 0.553902494 + + // Avoid needing floating point math, so output in mV + return (adc_get(ADCCHAN_VOLTAGE) * 5539U) / 10000U; +} diff --git a/panda/board/stm32h7/llfan.h b/panda/board/stm32h7/llfan.h new file mode 100644 index 00000000000000..fc529dcbe26ff6 --- /dev/null +++ b/panda/board/stm32h7/llfan.h @@ -0,0 +1,2 @@ +void EXTI2_IRQ_Handler(void) { } +void fan_init(void){ } diff --git a/panda/board/stm32h7/llfdcan.h b/panda/board/stm32h7/llfdcan.h new file mode 100644 index 00000000000000..04c9078dc3e969 --- /dev/null +++ b/panda/board/stm32h7/llfdcan.h @@ -0,0 +1,203 @@ +#define FDCAN_MESSAGE_RAM_SIZE 0x2800UL +#define FDCAN_START_ADDRESS 0x4000AC00UL +#define FDCAN_OFFSET 3412UL // bytes for each FDCAN module +#define FDCAN_OFFSET_W 853UL // words for each FDCAN module +#define FDCAN_END_ADDRESS 0x4000D3FCUL // Message RAM has a width of 4 Bytes + +// With this settings we can go up to 5Mbit/s +#define CAN_SYNC_JW 1U // 1 to 4 +#define CAN_PHASE_SEG1 6U // =(PROP_SEG + PHASE_SEG1) , 1 to 16 +#define CAN_PHASE_SEG2 1U // 1 to 8 +#define CAN_PCLK 80000U // Sourced from PLL1Q +#define CAN_QUANTA (1U + CAN_PHASE_SEG1 + CAN_PHASE_SEG2) +// Valid speeds in kbps and their prescalers: +// 10=1000, 20=500, 50=200, 83.333=120, 100=100, 125=80, 250=40, 500=20, 1000=10, 2000=5, 5000=2 +#define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10U / (x)) + +// RX FIFO 0 +#define FDCAN_RX_FIFO_0_EL_CNT 24UL +#define FDCAN_RX_FIFO_0_HEAD_SIZE 8UL // bytes +#define FDCAN_RX_FIFO_0_DATA_SIZE 64UL // bytes +#define FDCAN_RX_FIFO_0_EL_SIZE (FDCAN_RX_FIFO_0_HEAD_SIZE + FDCAN_RX_FIFO_0_DATA_SIZE) +#define FDCAN_RX_FIFO_0_EL_W_SIZE (FDCAN_RX_FIFO_0_EL_SIZE / 4UL) +#define FDCAN_RX_FIFO_0_OFFSET 0UL + +// TX FIFO +#define FDCAN_TX_FIFO_EL_CNT 16UL +#define FDCAN_TX_FIFO_HEAD_SIZE 8UL // bytes +#define FDCAN_TX_FIFO_DATA_SIZE 64UL // bytes +#define FDCAN_TX_FIFO_EL_SIZE (FDCAN_TX_FIFO_HEAD_SIZE + FDCAN_TX_FIFO_DATA_SIZE) +#define FDCAN_TX_FIFO_EL_W_SIZE (FDCAN_TX_FIFO_EL_SIZE / 4UL) +#define FDCAN_TX_FIFO_OFFSET (FDCAN_RX_FIFO_0_OFFSET + (FDCAN_RX_FIFO_0_EL_CNT * FDCAN_RX_FIFO_0_EL_W_SIZE)) + +#define CAN_NAME_FROM_CANIF(CAN_DEV) (((CAN_DEV)==FDCAN1) ? "FDCAN1" : (((CAN_DEV) == FDCAN2) ? "FDCAN2" : "FDCAN3")) +#define CAN_NUM_FROM_CANIF(CAN_DEV) (((CAN_DEV)==FDCAN1) ? 0UL : (((CAN_DEV) == FDCAN2) ? 1UL : 2UL)) + + +void puts(const char *a); + +bool fdcan_request_init(FDCAN_GlobalTypeDef *CANx) { + bool ret = true; + // Exit from sleep mode + CANx->CCCR &= ~(FDCAN_CCCR_CSR); + while ((CANx->CCCR & FDCAN_CCCR_CSA) == FDCAN_CCCR_CSA); + + // Request init + uint32_t timeout_counter = 0U; + CANx->CCCR |= FDCAN_CCCR_INIT; + while ((CANx->CCCR & FDCAN_CCCR_INIT) == 0) { + // Delay for about 1ms + delay(10000); + timeout_counter++; + + if (timeout_counter >= CAN_INIT_TIMEOUT_MS){ + ret = false; + break; + } + } + return ret; +} + +bool fdcan_exit_init(FDCAN_GlobalTypeDef *CANx) { + bool ret = true; + + CANx->CCCR &= ~(FDCAN_CCCR_INIT); + uint32_t timeout_counter = 0U; + while ((CANx->CCCR & FDCAN_CCCR_INIT) != 0) { + // Delay for about 1ms + delay(10000); + timeout_counter++; + + if (timeout_counter >= CAN_INIT_TIMEOUT_MS) { + ret = false; + break; + } + } + return ret; +} + +bool llcan_set_speed(FDCAN_GlobalTypeDef *CANx, uint32_t speed, uint32_t data_speed, bool loopback, bool silent) { + bool ret = fdcan_request_init(CANx); + + if (ret) { + // Enable config change + CANx->CCCR |= FDCAN_CCCR_CCE; + + //Reset operation mode to Normal + CANx->CCCR &= ~(FDCAN_CCCR_TEST); + CANx->TEST &= ~(FDCAN_TEST_LBCK); + CANx->CCCR &= ~(FDCAN_CCCR_MON); + CANx->CCCR &= ~(FDCAN_CCCR_ASM); + + // Set the nominal bit timing register + CANx->NBTP = ((CAN_SYNC_JW-1U)<DBTP = ((CAN_SYNC_JW-1U)<CCCR |= FDCAN_CCCR_TEST; + CANx->TEST |= FDCAN_TEST_LBCK; + CANx->CCCR |= FDCAN_CCCR_MON; + } + // Silent is known as bus monitoring in the docs + if (silent) { + CANx->CCCR |= FDCAN_CCCR_MON; + } + ret = fdcan_exit_init(CANx); + if (!ret) { + puts(CAN_NAME_FROM_CANIF(CANx)); puts(" set_speed timed out! (2)\n"); + } + } else { + puts(CAN_NAME_FROM_CANIF(CANx)); puts(" set_speed timed out! (1)\n"); + } + return ret; +} + +bool llcan_init(FDCAN_GlobalTypeDef *CANx) { + uint32_t can_number = CAN_NUM_FROM_CANIF(CANx); + bool ret = fdcan_request_init(CANx); + + if (ret) { + // Enable config change + CANx->CCCR |= FDCAN_CCCR_CCE; + // Enable automatic retransmission + CANx->CCCR &= ~(FDCAN_CCCR_DAR); + // Enable transmission pause feature + CANx->CCCR |= FDCAN_CCCR_TXP; + // Disable protocol exception handling + CANx->CCCR |= FDCAN_CCCR_PXHD; + // FD with BRS + CANx->CCCR |= (FDCAN_CCCR_FDOE | FDCAN_CCCR_BRSE); + + // Set TX mode to FIFO + CANx->TXBC &= ~(FDCAN_TXBC_TFQM); + // Configure TX element data size + CANx->TXESC |= 0x7U << FDCAN_TXESC_TBDS_Pos; // 64 bytes + //Configure RX FIFO0 element data size + CANx->RXESC |= 0x7U << FDCAN_RXESC_F0DS_Pos; + // Disable filtering, accept all valid frames received + CANx->XIDFC &= ~(FDCAN_XIDFC_LSE); // No extended filters + CANx->SIDFC &= ~(FDCAN_SIDFC_LSS); // No standard filters + CANx->GFC &= ~(FDCAN_GFC_RRFE); // Accept extended remote frames + CANx->GFC &= ~(FDCAN_GFC_RRFS); // Accept standard remote frames + CANx->GFC &= ~(FDCAN_GFC_ANFE); // Accept extended frames to FIFO 0 + CANx->GFC &= ~(FDCAN_GFC_ANFS); // Accept standard frames to FIFO 0 + + uint32_t RxFIFO0SA = FDCAN_START_ADDRESS + (can_number * FDCAN_OFFSET); + uint32_t TxFIFOSA = RxFIFO0SA + (FDCAN_RX_FIFO_0_EL_CNT * FDCAN_RX_FIFO_0_EL_SIZE); + + // RX FIFO 0 + CANx->RXF0C |= (FDCAN_RX_FIFO_0_OFFSET + (can_number * FDCAN_OFFSET_W)) << FDCAN_RXF0C_F0SA_Pos; + CANx->RXF0C |= FDCAN_RX_FIFO_0_EL_CNT << FDCAN_RXF0C_F0S_Pos; + // RX FIFO 0 switch to non-blocking (overwrite) mode + CANx->RXF0C |= FDCAN_RXF0C_F0OM; + + // TX FIFO (mode set earlier) + CANx->TXBC |= (FDCAN_TX_FIFO_OFFSET + (can_number * FDCAN_OFFSET_W)) << FDCAN_TXBC_TBSA_Pos; + CANx->TXBC |= FDCAN_TX_FIFO_EL_CNT << FDCAN_TXBC_TFQS_Pos; + + // Flush allocated RAM + uint32_t EndAddress = TxFIFOSA + (FDCAN_TX_FIFO_EL_CNT * FDCAN_TX_FIFO_EL_SIZE); + for (uint32_t RAMcounter = RxFIFO0SA; RAMcounter < EndAddress; RAMcounter += 4U) { + *(uint32_t *)(RAMcounter) = 0x00000000; + } + + // Enable both interrupts for each module + CANx->ILE = (FDCAN_ILE_EINT0 | FDCAN_ILE_EINT1); + + CANx->IE &= 0x0U; // Reset all interrupts + // Messages for INT0 + CANx->IE |= FDCAN_IE_RF0NE; // Rx FIFO 0 new message + + // Messages for INT1 (Only TFE works??) + CANx->ILS |= FDCAN_ILS_TFEL; + CANx->IE |= FDCAN_IE_TFEE; // Tx FIFO empty + + ret = fdcan_exit_init(CANx); + if(!ret) { + puts(CAN_NAME_FROM_CANIF(CANx)); puts(" llcan_init timed out (2)!\n"); + } + + if (CANx == FDCAN1) { + NVIC_EnableIRQ(FDCAN1_IT0_IRQn); + NVIC_EnableIRQ(FDCAN1_IT1_IRQn); + } else if (CANx == FDCAN2) { + NVIC_EnableIRQ(FDCAN2_IT0_IRQn); + NVIC_EnableIRQ(FDCAN2_IT1_IRQn); + } else if (CANx == FDCAN3) { + NVIC_EnableIRQ(FDCAN3_IT0_IRQn); + NVIC_EnableIRQ(FDCAN3_IT1_IRQn); + } else { + puts("Invalid CAN: initialization failed\n"); + } + + } else { + puts(CAN_NAME_FROM_CANIF(CANx)); puts(" llcan_init timed out (1)!\n"); + } + return ret; +} + +void llcan_clear_send(FDCAN_GlobalTypeDef *CANx) { + // From H7 datasheet: Transmit cancellation is not intended for Tx FIFO operation. + UNUSED(CANx); +} diff --git a/panda/board/stm32h7/llflash.h b/panda/board/stm32h7/llflash.h new file mode 100644 index 00000000000000..b95011a9ed87c2 --- /dev/null +++ b/panda/board/stm32h7/llflash.h @@ -0,0 +1,33 @@ +bool flash_is_locked(void) { + return (FLASH->CR1 & FLASH_CR_LOCK); +} + +void flash_unlock(void) { + FLASH->KEYR1 = 0x45670123; + FLASH->KEYR1 = 0xCDEF89AB; +} + +bool flash_erase_sector(uint8_t sector, bool unlocked) { + // don't erase the bootloader(sector 0) + if (sector != 0 && sector < 8 && unlocked) { + FLASH->CR1 = (sector << 8) | FLASH_CR_SER; + FLASH->CR1 |= FLASH_CR_START; + while (FLASH->SR1 & FLASH_SR_QW); + return true; + } + return false; +} + +void flash_write_word(void *prog_ptr, uint32_t data) { + uint32_t *pp = prog_ptr; + FLASH->CR1 |= FLASH_CR_PG; + *pp = data; + while (FLASH->SR1 & FLASH_SR_QW); +} + +void flush_write_buffer(void) { + if (FLASH->SR1 & FLASH_SR_WBNE) { + FLASH->CR1 |= FLASH_CR_FW; + while (FLASH->SR1 & FLASH_CR_FW); + } +} diff --git a/panda/board/stm32h7/llrtc.h b/panda/board/stm32h7/llrtc.h new file mode 100644 index 00000000000000..8689f895283d80 --- /dev/null +++ b/panda/board/stm32h7/llrtc.h @@ -0,0 +1,9 @@ +#define RCC_BDCR_MASK (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL | RCC_BDCR_LSEDRV | RCC_BDCR_LSEBYP | RCC_BDCR_LSEON) + +void enable_bdomain_protection(void) { + register_clear_bits(&(PWR->CR1), PWR_CR1_DBP); +} + +void disable_bdomain_protection(void) { + register_set_bits(&(PWR->CR1), PWR_CR1_DBP); +} diff --git a/panda/board/stm32h7/lluart.h b/panda/board/stm32h7/lluart.h new file mode 100644 index 00000000000000..aa44f7bb8433d5 --- /dev/null +++ b/panda/board/stm32h7/lluart.h @@ -0,0 +1,5 @@ +void uart_init(uart_ring *q, int baud) { UNUSED(q); UNUSED(baud); } +void uart_set_baud(USART_TypeDef *u, unsigned int baud) { UNUSED(u); UNUSED(baud); } +void dma_pointer_handler(uart_ring *q, uint32_t dma_ndtr) { UNUSED(q); UNUSED(dma_ndtr); } +void uart_rx_ring(uart_ring *q) { UNUSED(q); } +void uart_tx_ring(uart_ring *q) { UNUSED(q); } diff --git a/panda/board/stm32h7/llusb.h b/panda/board/stm32h7/llusb.h new file mode 100644 index 00000000000000..58646574af3f08 --- /dev/null +++ b/panda/board/stm32h7/llusb.h @@ -0,0 +1,98 @@ +typedef struct +{ + __IO uint32_t HPRT; +} +USB_OTG_HostPortTypeDef; + +USB_OTG_GlobalTypeDef *USBx = USB_OTG_HS; + +#define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE)) +#define USBx_HOST_PORT ((USB_OTG_HostPortTypeDef *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE)) +#define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t)USBx + USB_OTG_DEVICE_BASE)) +#define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) +#define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) +#define USBx_DFIFO(i) *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE)) +#define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE) + +#define USBD_FS_TRDT_VALUE 6U +#define USB_OTG_SPEED_FULL 3U +#define DCFG_FRAME_INTERVAL_80 0U + + +void usb_irqhandler(void); + +void OTG_HS_IRQ_Handler(void) { + NVIC_DisableIRQ(OTG_HS_IRQn); + usb_irqhandler(); + NVIC_EnableIRQ(OTG_HS_IRQn); +} + +void usb_init(void) { + REGISTER_INTERRUPT(OTG_HS_IRQn, OTG_HS_IRQ_Handler, 1500000U, FAULT_INTERRUPT_RATE_USB) // TODO: Find out a better rate limit for USB. Now it's the 1.5MB/s rate + + // Disable global interrupt + USBx->GAHBCFG &= ~(USB_OTG_GAHBCFG_GINT); + // Select FS Embedded PHY + USBx->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL; + // Force device mode + USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_FHMOD | USB_OTG_GUSBCFG_FDMOD); + USBx->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; + delay(250000); // Wait for about 25ms (explicitly stated in H7 ref manual) + // Wait for AHB master IDLE state. + while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0); + // Core Soft Reset + USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST; + while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST); + // Activate the USB Transceiver + USBx->GCCFG |= USB_OTG_GCCFG_PWRDWN; + + for (uint8_t i = 0U; i < 15U; i++) { + USBx->DIEPTXF[i] = 0U; + } + + // VBUS Sensing setup + USBx_DEVICE->DCTL |= USB_OTG_DCTL_SDIS; + // Deactivate VBUS Sensing B + USBx->GCCFG &= ~(USB_OTG_GCCFG_VBDEN); + // B-peripheral session valid override enable + USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; + USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; + // Restart the Phy Clock + USBx_PCGCCTL = 0U; + // Device mode configuration + USBx_DEVICE->DCFG |= DCFG_FRAME_INTERVAL_80; + USBx_DEVICE->DCFG |= USB_OTG_SPEED_FULL | USB_OTG_DCFG_NZLSOHSK; + + // Flush FIFOs + USBx->GRSTCTL = (USB_OTG_GRSTCTL_TXFFLSH | (0x10U << 6)); + while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH); + + USBx->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH; + while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH); + + // Clear all pending Device Interrupts + USBx_DEVICE->DIEPMSK = 0U; + USBx_DEVICE->DOEPMSK = 0U; + USBx_DEVICE->DAINTMSK = 0U; + USBx_DEVICE->DIEPMSK &= ~(USB_OTG_DIEPMSK_TXFURM); + + // Disable all interrupts. + USBx->GINTMSK = 0U; + // Clear any pending interrupts + USBx->GINTSTS = 0xBFFFFFFFU; + // Enable interrupts matching to the Device mode ONLY + 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; + + // Set USB Turnaround time + USBx->GUSBCFG |= ((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); + // Enables the controller's Global Int in the AHB Config reg + USBx->GAHBCFG |= USB_OTG_GAHBCFG_GINT; + // Soft disconnect disable: + USBx_DEVICE->DCTL &= ~(USB_OTG_DCTL_SDIS); + + // enable the IRQ + NVIC_EnableIRQ(OTG_HS_IRQn); +} diff --git a/panda/board/stm32h7/peripherals.h b/panda/board/stm32h7/peripherals.h new file mode 100644 index 00000000000000..b50516f79bbbba --- /dev/null +++ b/panda/board/stm32h7/peripherals.h @@ -0,0 +1,123 @@ +void gpio_usb_init(void) { + // A11,A12: USB: + set_gpio_alternate(GPIOA, 11, GPIO_AF10_OTG1_FS); + set_gpio_alternate(GPIOA, 12, GPIO_AF10_OTG1_FS); + GPIOA->OSPEEDR = GPIO_OSPEEDR_OSPEED11 | GPIO_OSPEEDR_OSPEED12; +} + +void gpio_usart2_init(void) { + // A2,A3: USART 2 for debugging + set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); + set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); +} + +// Common GPIO initialization +void common_init_gpio(void) { + /// E2,E3,E4: RGB LED + set_gpio_pullup(GPIOE, 2, PULL_NONE); + set_gpio_mode(GPIOE, 2, MODE_OUTPUT); + + set_gpio_pullup(GPIOE, 3, PULL_NONE); + set_gpio_mode(GPIOE, 3, MODE_OUTPUT); + + set_gpio_pullup(GPIOE, 4, PULL_NONE); + set_gpio_mode(GPIOE, 4, MODE_OUTPUT); + + // F7,F8,F9,F10: BOARD ID + set_gpio_pullup(GPIOF, 7, PULL_NONE); + set_gpio_mode(GPIOF, 7, MODE_INPUT); + + set_gpio_pullup(GPIOF, 8, PULL_NONE); + set_gpio_mode(GPIOF, 8, MODE_INPUT); + + set_gpio_pullup(GPIOF, 9, PULL_NONE); + set_gpio_mode(GPIOF, 9, MODE_INPUT); + + set_gpio_pullup(GPIOF, 10, PULL_NONE); + set_gpio_mode(GPIOF, 10, MODE_INPUT); + + // G11,B3,D7,B4: transceiver enable + set_gpio_pullup(GPIOG, 11, PULL_NONE); + set_gpio_mode(GPIOG, 11, MODE_OUTPUT); + + // Speed was set to high by default after reset, changing to low + GPIOB->OSPEEDR = GPIO_OSPEEDR_OSPEED3; + set_gpio_pullup(GPIOB, 3, PULL_NONE); + set_gpio_mode(GPIOB, 3, MODE_OUTPUT); + + set_gpio_pullup(GPIOD, 7, PULL_NONE); + set_gpio_mode(GPIOD, 7, MODE_OUTPUT); + + set_gpio_pullup(GPIOB, 4, PULL_NONE); + set_gpio_mode(GPIOB, 4, MODE_OUTPUT); + + // B14: usb load switch + set_gpio_pullup(GPIOB, 14, PULL_NONE); + set_gpio_mode(GPIOB, 14, MODE_OUTPUT); + + //B1,F11 5VOUT_S, VOLT_S + set_gpio_pullup(GPIOB, 1, PULL_NONE); + set_gpio_mode(GPIOB, 1, MODE_ANALOG); + + set_gpio_pullup(GPIOF, 11, PULL_NONE); + set_gpio_mode(GPIOF, 11, MODE_ANALOG); + + gpio_usb_init(); + + // B8,B9: FDCAN1 + set_gpio_pullup(GPIOB, 8, PULL_NONE); + set_gpio_alternate(GPIOB, 8, GPIO_AF9_FDCAN1); + + set_gpio_pullup(GPIOB, 9, PULL_NONE); + set_gpio_alternate(GPIOB, 9, GPIO_AF9_FDCAN1); + + // B5,B6 (mplex to B12,B13): FDCAN2 + set_gpio_pullup(GPIOB, 12, PULL_NONE); + set_gpio_pullup(GPIOB, 13, PULL_NONE); + + set_gpio_pullup(GPIOB, 5, PULL_NONE); + set_gpio_alternate(GPIOB, 5, GPIO_AF9_FDCAN2); + + set_gpio_pullup(GPIOB, 6, PULL_NONE); + set_gpio_alternate(GPIOB, 6, GPIO_AF9_FDCAN2); + + // G9,G10: FDCAN3 + set_gpio_pullup(GPIOG, 9, PULL_NONE); + set_gpio_alternate(GPIOG, 9, GPIO_AF2_FDCAN3); + + set_gpio_pullup(GPIOG, 10, PULL_NONE); + set_gpio_alternate(GPIOG, 10, GPIO_AF2_FDCAN3); +} + +void flasher_peripherals_init(void) { + RCC->AHB1ENR |= RCC_AHB1ENR_USB1OTGHSEN; +} + +// Peripheral initialization +void peripherals_init(void) { + // enable GPIO(A,B,C,D,E,F,G,H) + RCC->AHB4ENR |= RCC_AHB4ENR_GPIOAEN; + RCC->AHB4ENR |= RCC_AHB4ENR_GPIOBEN; + RCC->AHB4ENR |= RCC_AHB4ENR_GPIOCEN; + RCC->AHB4ENR |= RCC_AHB4ENR_GPIODEN; + RCC->AHB4ENR |= RCC_AHB4ENR_GPIOEEN; + RCC->AHB4ENR |= RCC_AHB4ENR_GPIOFEN; + RCC->AHB4ENR |= RCC_AHB4ENR_GPIOGEN; + + RCC->APB1LENR |= RCC_APB1LENR_TIM2EN; // main counter + RCC->APB1LENR |= RCC_APB1LENR_TIM6EN; // interrupt timer + RCC->APB2ENR |= RCC_APB2ENR_TIM8EN; // clock source timer + RCC->APB1LENR |= RCC_APB1LENR_TIM12EN; // slow loop + + RCC->APB1HENR |= RCC_APB1HENR_FDCANEN; // FDCAN core enable + RCC->AHB1ENR |= RCC_AHB1ENR_ADC12EN; // Enable ADC clocks + + // HS USB enable, also LP is needed for CSleep state(__WFI()) + RCC->AHB1ENR |= RCC_AHB1ENR_USB1OTGHSEN; + RCC->AHB1LPENR |= RCC_AHB1LPENR_USB1OTGHSLPEN; + RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_USB1OTGHSULPILPEN); +} + +void enable_interrupt_timer(void) { + register_set_bits(&(RCC->APB1LENR), RCC_APB1LENR_TIM6EN); // Enable interrupt timer peripheral +} diff --git a/panda/board/stm32h7/startup_stm32h7x5xx.s b/panda/board/stm32h7/startup_stm32h7x5xx.s new file mode 100644 index 00000000000000..15015a11329d73 --- /dev/null +++ b/panda/board/stm32h7/startup_stm32h7x5xx.s @@ -0,0 +1,767 @@ +/** + ****************************************************************************** + * @file startup_stm32h735xx.s + * @author MCD Application Team + * @brief STM32H735xx Devices vector table for GCC based toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

    © Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

    + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m7 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + bl __initialize_hardware_early + +/* Copy the data segment initializers from flash to SRAM */ + ldr r0, =_sdata + ldr r1, =_edata + ldr r2, =_sidata + movs r3, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r4, [r2, r3] + str r4, [r0, r3] + adds r3, r3, #4 + +LoopCopyDataInit: + adds r4, r0, r3 + cmp r4, r1 + bcc CopyDataInit +/* Zero fill the bss segment. */ + ldr r2, =_sbss + ldr r4, =_ebss + movs r3, #0 + b LoopFillZerobss + +FillZerobss: + str r3, [r2] + adds r2, r2, #4 + +LoopFillZerobss: + cmp r2, r4 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + /* bl SystemInit */ +/* Call static constructors */ + /* bl __libc_init_array */ +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ + .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ + .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ + .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ + .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ + .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word 0 /* Reserved */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDMMC1_IRQHandler /* SDMMC1 */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_PSSI_IRQHandler /* DCMI, PSSI */ + .word CRYP_IRQHandler /* CRYP */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + .word 0 /* Reserved */ + .word OCTOSPI1_IRQHandler /* OCTOSPI1 */ + .word LPTIM1_IRQHandler /* LPTIM1 */ + .word CEC_IRQHandler /* HDMI_CEC */ + .word I2C4_EV_IRQHandler /* I2C4 Event */ + .word I2C4_ER_IRQHandler /* I2C4 Error */ + .word SPDIF_RX_IRQHandler /* SPDIF_RX */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ + .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ + .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ + .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ + .word 0 /* Reserved */ + .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ + .word TIM15_IRQHandler /* TIM15 global Interrupt */ + .word TIM16_IRQHandler /* TIM16 global Interrupt */ + .word TIM17_IRQHandler /* TIM17 global Interrupt */ + .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ + .word MDIOS_IRQHandler /* MDIOS global Interrupt */ + .word 0 /* Reserved */ + .word MDMA_IRQHandler /* MDMA global Interrupt */ + .word 0 /* Reserved */ + .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ + .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ + .word 0 /* Reserved */ + .word ADC3_IRQHandler /* ADC3 global Interrupt */ + .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ + .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ + .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ + .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ + .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ + .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ + .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ + .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ + .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ + .word COMP1_IRQHandler /* COMP1 global Interrupt */ + .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ + .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ + .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ + .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ + .word LPUART1_IRQHandler /* LP UART1 interrupt */ + .word 0 /* Reserved */ + .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ + .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ + .word SAI4_IRQHandler /* SAI4 global interrupt */ + .word DTS_IRQHandler /* Digital Temperature Sensor interrupt */ + .word 0 /* Reserved */ + .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ + .word OCTOSPI2_IRQHandler /* OCTOSPI2 Interrupt */ + .word OTFDEC1_IRQHandler /* OTFDEC1 Interrupt */ + .word OTFDEC2_IRQHandler /* OTFDEC2 Interrupt */ + .word FMAC_IRQHandler /* FMAC Interrupt */ + .word CORDIC_IRQHandler /* CORDIC Interrupt */ + .word UART9_IRQHandler /* UART9 Interrupt */ + .word USART10_IRQHandler /* UART10 Interrupt */ + .word I2C5_EV_IRQHandler /* I2C5 Event Interrupt */ + .word I2C5_ER_IRQHandler /* I2C5 Error Interrupt */ + .word FDCAN3_IT0_IRQHandler /* FDCAN3 interrupt line 0 */ + .word FDCAN3_IT1_IRQHandler /* FDCAN3 interrupt line 1 */ + .word TIM23_IRQHandler /* TIM23 global interrupt */ + .word TIM24_IRQHandler /* TIM24 global interrupt */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_AVD_IRQHandler + .thumb_set PVD_AVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak FDCAN1_IT0_IRQHandler + .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler + + .weak FDCAN2_IT0_IRQHandler + .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler + + .weak FDCAN1_IT1_IRQHandler + .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler + + .weak FDCAN2_IT1_IRQHandler + .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDMMC1_IRQHandler + .thumb_set SDMMC1_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak FDCAN_CAL_IRQHandler + .thumb_set FDCAN_CAL_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_PSSI_IRQHandler + .thumb_set DCMI_PSSI_IRQHandler,Default_Handler + + .weak CRYP_IRQHandler + .thumb_set CRYP_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + + .weak OCTOSPI1_IRQHandler + .thumb_set OCTOSPI1_IRQHandler,Default_Handler + + .weak LPTIM1_IRQHandler + .thumb_set LPTIM1_IRQHandler,Default_Handler + + .weak CEC_IRQHandler + .thumb_set CEC_IRQHandler,Default_Handler + + .weak I2C4_EV_IRQHandler + .thumb_set I2C4_EV_IRQHandler,Default_Handler + + .weak I2C4_ER_IRQHandler + .thumb_set I2C4_ER_IRQHandler,Default_Handler + + .weak SPDIF_RX_IRQHandler + .thumb_set SPDIF_RX_IRQHandler,Default_Handler + + .weak DMAMUX1_OVR_IRQHandler + .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler + + .weak DFSDM1_FLT0_IRQHandler + .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler + + .weak DFSDM1_FLT1_IRQHandler + .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler + + .weak DFSDM1_FLT2_IRQHandler + .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler + + .weak DFSDM1_FLT3_IRQHandler + .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler + + .weak SWPMI1_IRQHandler + .thumb_set SWPMI1_IRQHandler,Default_Handler + + .weak TIM15_IRQHandler + .thumb_set TIM15_IRQHandler,Default_Handler + + .weak TIM16_IRQHandler + .thumb_set TIM16_IRQHandler,Default_Handler + + .weak TIM17_IRQHandler + .thumb_set TIM17_IRQHandler,Default_Handler + + .weak MDIOS_WKUP_IRQHandler + .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler + + .weak MDIOS_IRQHandler + .thumb_set MDIOS_IRQHandler,Default_Handler + + .weak MDMA_IRQHandler + .thumb_set MDMA_IRQHandler,Default_Handler + + .weak SDMMC2_IRQHandler + .thumb_set SDMMC2_IRQHandler,Default_Handler + + .weak HSEM1_IRQHandler + .thumb_set HSEM1_IRQHandler,Default_Handler + + .weak ADC3_IRQHandler + .thumb_set ADC3_IRQHandler,Default_Handler + + .weak DMAMUX2_OVR_IRQHandler + .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler + + .weak BDMA_Channel0_IRQHandler + .thumb_set BDMA_Channel0_IRQHandler,Default_Handler + + .weak BDMA_Channel1_IRQHandler + .thumb_set BDMA_Channel1_IRQHandler,Default_Handler + + .weak BDMA_Channel2_IRQHandler + .thumb_set BDMA_Channel2_IRQHandler,Default_Handler + + .weak BDMA_Channel3_IRQHandler + .thumb_set BDMA_Channel3_IRQHandler,Default_Handler + + .weak BDMA_Channel4_IRQHandler + .thumb_set BDMA_Channel4_IRQHandler,Default_Handler + + .weak BDMA_Channel5_IRQHandler + .thumb_set BDMA_Channel5_IRQHandler,Default_Handler + + .weak BDMA_Channel6_IRQHandler + .thumb_set BDMA_Channel6_IRQHandler,Default_Handler + + .weak BDMA_Channel7_IRQHandler + .thumb_set BDMA_Channel7_IRQHandler,Default_Handler + + .weak COMP1_IRQHandler + .thumb_set COMP1_IRQHandler,Default_Handler + + .weak LPTIM2_IRQHandler + .thumb_set LPTIM2_IRQHandler,Default_Handler + + .weak LPTIM3_IRQHandler + .thumb_set LPTIM3_IRQHandler,Default_Handler + + .weak LPTIM4_IRQHandler + .thumb_set LPTIM4_IRQHandler,Default_Handler + + .weak LPTIM5_IRQHandler + .thumb_set LPTIM5_IRQHandler,Default_Handler + + .weak LPUART1_IRQHandler + .thumb_set LPUART1_IRQHandler,Default_Handler + + .weak CRS_IRQHandler + .thumb_set CRS_IRQHandler,Default_Handler + + .weak ECC_IRQHandler + .thumb_set ECC_IRQHandler,Default_Handler + + .weak SAI4_IRQHandler + .thumb_set SAI4_IRQHandler,Default_Handler + + .weak DTS_IRQHandler + .thumb_set DTS_IRQHandler,Default_Handler + + .weak WAKEUP_PIN_IRQHandler + .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler + + .weak OCTOSPI2_IRQHandler + .thumb_set OCTOSPI2_IRQHandler,Default_Handler + + .weak OTFDEC1_IRQHandler + .thumb_set OTFDEC1_IRQHandler,Default_Handler + + .weak OTFDEC2_IRQHandler + .thumb_set OTFDEC2_IRQHandler,Default_Handler + + .weak FMAC_IRQHandler + .thumb_set FMAC_IRQHandler,Default_Handler + + .weak CORDIC_IRQHandler + .thumb_set CORDIC_IRQHandler,Default_Handler + + .weak UART9_IRQHandler + .thumb_set UART9_IRQHandler,Default_Handler + + .weak USART10_IRQHandler + .thumb_set USART10_IRQHandler,Default_Handler + + .weak I2C5_EV_IRQHandler + .thumb_set I2C5_EV_IRQHandler,Default_Handler + + .weak I2C5_ER_IRQHandler + .thumb_set I2C5_ER_IRQHandler,Default_Handler + + .weak FDCAN3_IT0_IRQHandler + .thumb_set FDCAN3_IT0_IRQHandler,Default_Handler + + .weak FDCAN3_IT1_IRQHandler + .thumb_set FDCAN3_IT1_IRQHandler,Default_Handler + + .weak TIM23_IRQHandler + .thumb_set TIM23_IRQHandler,Default_Handler + + .weak TIM24_IRQHandler + .thumb_set TIM24_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/panda/board/stm32h7/stm32h7_config.h b/panda/board/stm32h7/stm32h7_config.h new file mode 100644 index 00000000000000..cdc2a9dcc29eb7 --- /dev/null +++ b/panda/board/stm32h7/stm32h7_config.h @@ -0,0 +1,79 @@ +#include "stm32h7/inc/stm32h7xx.h" +#include "stm32h7/inc/stm32h7xx_hal_gpio_ex.h" +#define MCU_IDCODE 0x483U + +// from the linker script +#define APP_START_ADDRESS 0x8020000U + +#define CORE_FREQ 240U // in Mhz +//APB1 - 120Mhz, APB2 - 120Mhz +#define APB1_FREQ CORE_FREQ/2U +#define APB2_FREQ CORE_FREQ/2U + +#define BOOTLOADER_ADDRESS 0x1FF09804U + +// Around (1Mbps / 8 bits/byte / 12 bytes per message) +#define CAN_INTERRUPT_RATE 12000U // FIXME: should raise to 16000 ? + +#define MAX_LED_FADE 10240U + +// Threshold voltage (mV) for either of the SBUs to be below before deciding harness is connected +#define HARNESS_CONNECTED_THRESHOLD 40000U + +// There are 163 external interrupt sources (see stm32f735xx.h) +#define NUM_INTERRUPTS 163U + +#define TICK_TIMER_IRQ TIM8_BRK_TIM12_IRQn +#define TICK_TIMER TIM12 + +#define MICROSECOND_TIMER TIM2 + +#define INTERRUPT_TIMER_IRQ TIM6_DAC_IRQn +#define INTERRUPT_TIMER TIM6 + +#define PROVISION_CHUNK_ADDRESS 0x080FFFE0U +#define DEVICE_SERIAL_NUMBER_ADDRESS 0x080FFFC0U + +#define CANPACKET_DATA_SIZE_MAX 64U + +#include "can_definitions.h" + +#ifndef BOOTSTUB + #include "main_declarations.h" +#else + #include "bootstub_declarations.h" +#endif + +#include "libc.h" +#include "critical.h" +#include "faults.h" + +#include "drivers/registers.h" +#include "drivers/interrupts.h" +#include "drivers/gpio.h" +#include "stm32h7/peripherals.h" +#include "stm32h7/interrupt_handlers.h" +#include "drivers/timers.h" +#include "stm32h7/lladc.h" +#include "stm32h7/board.h" +#include "stm32h7/clock.h" + +#if !defined (BOOTSTUB) && defined(PANDA) + #include "drivers/uart.h" + #include "stm32h7/lluart.h" +#endif + +#ifdef BOOTSTUB + #include "stm32h7/llflash.h" +#else + #include "stm32h7/llfdcan.h" +#endif + +#include "stm32h7/llusb.h" + +void early_gpio_float(void) { + RCC->AHB4ENR = RCC_AHB4ENR_GPIOAEN | RCC_AHB4ENR_GPIOBEN | RCC_AHB4ENR_GPIOCEN | RCC_AHB4ENR_GPIODEN | RCC_AHB4ENR_GPIOEEN | RCC_AHB4ENR_GPIOFEN | RCC_AHB4ENR_GPIOGEN | RCC_AHB4ENR_GPIOHEN; + GPIOA->MODER = 0; GPIOB->MODER = 0; GPIOC->MODER = 0; GPIOD->MODER = 0; GPIOE->MODER = 0; GPIOF->MODER = 0; GPIOG->MODER = 0; GPIOH->MODER = 0; + GPIOA->ODR = 0; GPIOB->ODR = 0; GPIOC->ODR = 0; GPIOD->ODR = 0; GPIOE->ODR = 0; GPIOF->ODR = 0; GPIOG->ODR = 0; GPIOH->ODR = 0; + GPIOA->PUPDR = 0; GPIOB->PUPDR = 0; GPIOC->PUPDR = 0; GPIOD->PUPDR = 0; GPIOE->PUPDR = 0; GPIOF->PUPDR = 0; GPIOG->PUPDR = 0; GPIOH->PUPDR = 0; +} diff --git a/panda/board/stm32h7/stm32h7x5_flash.ld b/panda/board/stm32h7/stm32h7x5_flash.ld new file mode 100644 index 00000000000000..aeaa4e3bee4fea --- /dev/null +++ b/panda/board/stm32h7/stm32h7x5_flash.ld @@ -0,0 +1,192 @@ +/* +****************************************************************************** +** + +** File : LinkerScript.ld +** +** Author : Auto-generated by System Workbench for STM32 +** +** Abstract : Linker script for STM32H735ZGTx series +** 1024Kbytes FLASH and 560Kbytes RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed “as is,†without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

    © COPYRIGHT(c) 2019 STMicroelectronics

    +** +** 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. Neither the name of STMicroelectronics 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. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +enter_bootloader_mode = 0x38001FFC; +_estack = 0x20020000; /* end of RAM */ +_app_start = 0x08020000; /* Reserve Sector 0(128K) for bootloader */ + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K +RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K +RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K +ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >DTCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >DTCMRAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >DTCMRAM + + .ram_d1 (NOLOAD) : + { + . = ALIGN(4); + *(.ram_d1*) + } >RAM_D1 + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/panda/board/tests/test_rsa.c b/panda/board/tests/test_rsa.c index f4a7d6be0faba4..5c784e23a4e834 100644 --- a/panda/board/tests/test_rsa.c +++ b/panda/board/tests/test_rsa.c @@ -32,4 +32,3 @@ int main() { return 0; } - diff --git a/panda/board/tools/dfu-util-aarch64 b/panda/board/tools/dfu-util-aarch64 deleted file mode 100755 index 250c592ada9795..00000000000000 Binary files a/panda/board/tools/dfu-util-aarch64 and /dev/null differ diff --git a/panda/board/tools/dfu-util-aarch64-linux b/panda/board/tools/dfu-util-aarch64-linux deleted file mode 100755 index b366f869ace1cd..00000000000000 Binary files a/panda/board/tools/dfu-util-aarch64-linux and /dev/null differ diff --git a/panda/board/tools/dfu-util-x86_64-linux b/panda/board/tools/dfu-util-x86_64-linux deleted file mode 100755 index 7be3dc3a7ef682..00000000000000 Binary files a/panda/board/tools/dfu-util-x86_64-linux and /dev/null differ diff --git a/panda/board/tools/enter_download_mode.py b/panda/board/tools/enter_download_mode.py deleted file mode 100755 index ff3cf84ca97aa3..00000000000000 --- a/panda/board/tools/enter_download_mode.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function - -import sys -import time -import usb1 - -def enter_download_mode(device): - handle = device.open() - handle.claimInterface(0) - - try: - handle.controlWrite(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xd1, 0, 0, b'') - except (usb1.USBErrorIO, usb1.USBErrorPipe) as e: - print("Device download mode enabled.") - time.sleep(1) - else: - print("Device failed to enter download mode.") - sys.exit(1) - -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: - return device - -if __name__ == "__main__": - panda_dev = find_first_panda() - if panda_dev == None: - print("no device found") - sys.exit(0) - print("found device") - enter_download_mode(panda_dev) diff --git a/panda/board/usb_protocol.h b/panda/board/usb_protocol.h new file mode 100644 index 00000000000000..a20b6c1b41be87 --- /dev/null +++ b/panda/board/usb_protocol.h @@ -0,0 +1,108 @@ +typedef struct { + int ptr; + int tail_size; + uint8_t data[72]; + uint8_t counter; +} usb_asm_buffer; + +usb_asm_buffer ep1_buffer = {.ptr = 0, .tail_size = 0, .counter = 0}; +int total_rx_size = 0; + +int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { + UNUSED(hardwired); + int pos = 1; + uint8_t *usbdata8 = (uint8_t *)usbdata; + usbdata8[0] = ep1_buffer.counter; + // Send tail of previous message if it is in buffer + if (ep1_buffer.ptr > 0) { + if (ep1_buffer.ptr <= 63) { + (void)memcpy(&usbdata8[pos], ep1_buffer.data, ep1_buffer.ptr); + pos += ep1_buffer.ptr; + ep1_buffer.ptr = 0; + } else { + (void)memcpy(&usbdata8[pos], ep1_buffer.data, 63); + ep1_buffer.ptr = ep1_buffer.ptr - 63; + (void)memcpy(ep1_buffer.data, &ep1_buffer.data[63], ep1_buffer.ptr); + pos += 63; + } + } + + if (total_rx_size > MAX_EP1_CHUNK_PER_BULK_TRANSFER) { + total_rx_size = 0; + ep1_buffer.counter = 0U; + } else { + CANPacket_t can_packet; + while ((pos < len) && can_pop(&can_rx_q, &can_packet)) { + int pckt_len = CANPACKET_HEAD_SIZE + dlc_to_len[can_packet.data_len_code]; + if ((pos + pckt_len) <= len) { + (void)memcpy(&usbdata8[pos], &can_packet, pckt_len); + pos += pckt_len; + } else { + (void)memcpy(&usbdata8[pos], &can_packet, len - pos); + ep1_buffer.ptr = pckt_len - (len - pos); + //(void)memcpy(ep1_buffer.data, ((uint8_t*)&can_packet + (len - pos)), ep1_buffer.ptr); + // cppcheck-suppress objectIndex + (void)memcpy(ep1_buffer.data, &((uint8_t*)&can_packet)[(len - pos)], ep1_buffer.ptr); + pos = len; + } + } + ep1_buffer.counter++; + total_rx_size += pos; + } + if (pos != len) { + ep1_buffer.counter = 0U; + total_rx_size = 0; + } + if (pos <= 1) { pos = 0; } + return pos; +} + +usb_asm_buffer ep3_buffer = {.ptr = 0, .tail_size = 0, .counter = 0}; + +// send on CAN +void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { + UNUSED(hardwired); + uint8_t *usbdata8 = (uint8_t *)usbdata; + // Got first packet from a stream, resetting buffer and counter + if (usbdata8[0] == 0U) { + ep3_buffer.counter = 0U; + ep3_buffer.ptr = 0; + ep3_buffer.tail_size = 0; + } + // Assembling can message with data from buffer + if (usbdata8[0] == ep3_buffer.counter) { + int pos = 1; + ep3_buffer.counter++; + if (ep3_buffer.ptr != 0) { + if (ep3_buffer.tail_size <= 63) { + CANPacket_t to_push; + (void)memcpy(&ep3_buffer.data[ep3_buffer.ptr], &usbdata8[pos], ep3_buffer.tail_size); + (void)memcpy(&to_push, ep3_buffer.data, ep3_buffer.ptr + ep3_buffer.tail_size); + can_send(&to_push, to_push.bus, false); + pos += ep3_buffer.tail_size; + ep3_buffer.ptr = 0; + ep3_buffer.tail_size = 0; + } else { + (void)memcpy(&ep3_buffer.data[ep3_buffer.ptr], &usbdata8[pos], len - pos); + ep3_buffer.tail_size -= 63; + ep3_buffer.ptr += 63; + pos += 63; + } + } + + while (pos < len) { + int pckt_len = CANPACKET_HEAD_SIZE + dlc_to_len[(usbdata8[pos] >> 4U)]; + if ((pos + pckt_len) <= len) { + CANPacket_t to_push; + (void)memcpy(&to_push, &usbdata8[pos], pckt_len); + can_send(&to_push, to_push.bus, false); + pos += pckt_len; + } else { + (void)memcpy(ep3_buffer.data, &usbdata8[pos], len - pos); + ep3_buffer.ptr = len - pos; + ep3_buffer.tail_size = pckt_len - ep3_buffer.ptr; + pos += ep3_buffer.ptr; + } + } + } +} 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 f855f88c919b64..00000000000000 --- a/panda/boardesp/webserver.c +++ /dev/null @@ -1,381 +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"
    -"Designed to work with our dashcam, chffr\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/common/version.mk b/panda/common/version.mk deleted file mode 100644 index cc66efaa6dbc4b..00000000000000 --- a/panda/common/version.mk +++ /dev/null @@ -1,20 +0,0 @@ -ifeq ($(RELEASE),1) - BUILD_TYPE = "RELEASE" -else - BUILD_TYPE = "DEBUG" -endif - -SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) - -ifneq ($(wildcard $(SELF_DIR)/../.git/HEAD),) -obj/gitversion.h: $(SELF_DIR)/../VERSION $(SELF_DIR)/../.git/HEAD $(SELF_DIR)/../.git/index - echo "const uint8_t gitversion[] = \"$(shell cat $(SELF_DIR)/../VERSION)-$(BUILDER)-$(shell git rev-parse --short=8 HEAD)-$(BUILD_TYPE)\";" > $@ -else -ifneq ($(wildcard $(SELF_DIR)/../../.git/modules/panda/HEAD),) -obj/gitversion.h: $(SELF_DIR)/../VERSION $(SELF_DIR)/../../.git/modules/panda/HEAD $(SELF_DIR)/../../.git/modules/panda/index - echo "const uint8_t gitversion[] = \"$(shell cat $(SELF_DIR)/../VERSION)-$(BUILDER)-$(shell git rev-parse --short=8 HEAD)-$(BUILD_TYPE)\";" > $@ -else -obj/gitversion.h: $(SELF_DIR)/../VERSION - echo "const uint8_t gitversion[] = \"$(shell cat $(SELF_DIR)/../VERSION)-$(BUILDER)-unknown-$(BUILD_TYPE)\";" > $@ -endif -endif diff --git a/panda/crypto/getcertheader.py b/panda/crypto/getcertheader.py deleted file mode 100755 index 75d04e977ad8c1..00000000000000 --- a/panda/crypto/getcertheader.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -import sys -import struct -from Crypto.PublicKey import RSA - -def egcd(a, b): - if a == 0: - return (b, 0, 1) - else: - g, y, x = egcd(b % a, a) - return (g, x - (b // a) * y, y) - -def modinv(a, m): - g, x, y = egcd(a, m) - if g != 1: - raise Exception('modular inverse does not exist') - else: - return x % 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)) - 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 fn in sys.argv[1:]: - rsa = RSA.importKey(open(fn).read()) - rr = pow(2**1024, 2, rsa.n) - n0inv = 2**32 - modinv(rsa.n, 2**32) - - 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 '};' - - diff --git a/panda/crypto/sha.c b/panda/crypto/sha.c index 8e1715525c68a2..a13162c5fac0d3 100644 --- a/panda/crypto/sha.c +++ b/panda/crypto/sha.c @@ -130,7 +130,7 @@ const uint8_t* SHA_final(SHA_CTX* ctx) { /* Hack - right shift operator with non const argument requires * libgcc.a which is missing in EON - * thus expanding for loop from + * thus expanding for loop from for (i = 0; i < 8; ++i) { uint8_t tmp = (uint8_t) (cnt >> ((7 - i) * 8)); 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 4cda1fa2e27fb3..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 771e7b80bc1e81..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 bf316940d3adb9..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 11071d035346be..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_fw_versions.py b/panda/examples/query_fw_versions.py new file mode 100755 index 00000000000000..4132959be50c8f --- /dev/null +++ b/panda/examples/query_fw_versions.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +import argparse +from tqdm import tqdm +from panda import Panda +from panda.python.uds import UdsClient, MessageTimeoutError, NegativeResponseError, SESSION_TYPE, DATA_IDENTIFIER_TYPE + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--rxoffset', default="") + parser.add_argument('--nonstandard', action='store_true') + parser.add_argument('--debug', action='store_true') + parser.add_argument('--addr') + args = parser.parse_args() + + if args.addr: + addrs = [int(args.addr, base=16)] + else: + addrs = [0x700 + i for i in range(256)] + addrs += [0x18da0000 + (i << 8) + 0xf1 for i in range(256)] + results = {} + + uds_data_ids = {} + for std_id in DATA_IDENTIFIER_TYPE: + uds_data_ids[std_id.value] = std_id.name + if args.nonstandard: + for uds_id in range(0xf100,0xf180): + uds_data_ids[uds_id] = "IDENTIFICATION_OPTION_VEHICLE_MANUFACTURER_SPECIFIC_DATA_IDENTIFIER" + for uds_id in range(0xf1a0,0xf1f0): + uds_data_ids[uds_id] = "IDENTIFICATION_OPTION_VEHICLE_MANUFACTURER_SPECIFIC" + for uds_id in range(0xf1f0,0xf200): + uds_data_ids[uds_id] = "IDENTIFICATION_OPTION_SYSTEM_SUPPLIER_SPECIFIC" + + panda = Panda() + panda.set_safety_mode(Panda.SAFETY_ELM327) + print("querying addresses ...") + with tqdm(addrs) as t: + for addr in t: + # skip functional broadcast addrs + if addr == 0x7df or addr == 0x18db33f1: + continue + t.set_description(hex(addr)) + panda.send_heartbeat() + + bus = 1 if panda.has_obd() else 0 + rx_addr = addr + int(args.rxoffset, base=16) if args.rxoffset else None + uds_client = UdsClient(panda, addr, rx_addr, bus, timeout=0.2, debug=args.debug) + # Check for anything alive at this address, and switch to the highest + # available diagnostic session without security access + try: + uds_client.tester_present() + uds_client.diagnostic_session_control(SESSION_TYPE.DEFAULT) + uds_client.diagnostic_session_control(SESSION_TYPE.EXTENDED_DIAGNOSTIC) + except NegativeResponseError: + pass + except MessageTimeoutError: + continue + + # Run queries against all standard UDS data identifiers, plus selected + # non-standardized identifier ranges if requested + resp = {} + for uds_data_id in sorted(uds_data_ids): + try: + data = uds_client.read_data_by_identifier(uds_data_id) # type: ignore + if data: + resp[uds_data_id] = data + except (NegativeResponseError, MessageTimeoutError): + pass + + if resp.keys(): + results[addr] = resp + + if len(results.items()): + for addr, resp in results.items(): + print(f"\n\n*** Results for address 0x{addr:X} ***\n\n") + for rid, dat in resp.items(): + print(f"0x{rid:02X} {uds_data_ids[rid]}: {dat}") + else: + print("no fw versions found!") 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 99d8d92854423b..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 bfca642e8256f7..87c811fea548d9 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 @@ -8,48 +7,114 @@ import os 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 functools import wraps +from .dfu import PandaDFU, MCU_TYPE_F2, MCU_TYPE_F4, MCU_TYPE_H7 # 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 +from .config import DEFAULT_FW_FN, DEFAULT_H7_FW_FN # noqa pylint: disable=import-error -__version__ = '0.0.8' +__version__ = '0.0.10' BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../") DEBUG = os.getenv("PANDADEBUG") is not None -# *** wifi mode *** +CANPACKET_HEAD_SIZE = 0x5 +DLC_TO_LEN = [0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64] +LEN_TO_DLC = {length: dlc for (dlc, length) in enumerate(DLC_TO_LEN)} -def build_st(target, mkfile="Makefile"): - 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 - -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]) - extended = 4 - if f1 & extended: - address = f1 >> 3 - else: - address = f1 >> 21 - dddat = ddat[8:8+(f2&0xF)] +def pack_can_buffer(arr): + snds = [b''] + idx = 0 + for address, _, dat, bus in arr: + assert len(dat) in LEN_TO_DLC if DEBUG: - print(" R %x: %s" % (address, str(dddat).encode("hex"))) - ret.append((address, f2>>16, dddat, (f2>>4)&0xFF)) + print(f" W 0x{address:x}: 0x{dat.hex()}") + extended = 1 if address >= 0x800 else 0 + data_len_code = LEN_TO_DLC[len(dat)] + header = bytearray(5) + word_4b = address << 3 | extended << 2 + header[0] = (data_len_code << 4) | (bus << 1) + header[1] = word_4b & 0xFF + header[2] = (word_4b >> 8) & 0xFF + header[3] = (word_4b >> 16) & 0xFF + header[4] = (word_4b >> 24) & 0xFF + snds[idx] += header + dat + if len(snds[idx]) > 256: # Limit chunks to 256 bytes + snds.append(b'') + idx += 1 + + #Apply counter to each 64 byte packet + for idx in range(len(snds)): + tx = b'' + counter = 0 + for i in range (0, len(snds[idx]), 63): + tx += bytes([counter]) + snds[idx][i:i+63] + counter += 1 + snds[idx] = tx + return snds + +def unpack_can_buffer(dat): + ret = [] + counter = 0 + tail = bytearray() + for i in range(0, len(dat), 64): + if counter != dat[i]: + print("CAN: LOST RECV PACKET COUNTER") + break + counter+=1 + chunk = tail + dat[i+1:i+64] + tail = bytearray() + pos = 0 + while pos>4)] + pckt_len = CANPACKET_HEAD_SIZE + data_len + if pckt_len <= len(chunk[pos:]): + header = chunk[pos:pos+CANPACKET_HEAD_SIZE] + if len(header) < 5: + print("CAN: MALFORMED USB RECV PACKET") + break + bus = (header[0] >> 1) & 0x7 + address = (header[4] << 24 | header[3] << 16 | header[2] << 8 | header[1]) >> 3 + returned = (header[1] >> 1) & 0x1 + rejected = header[1] & 0x1 + data = chunk[pos + CANPACKET_HEAD_SIZE:pos + CANPACKET_HEAD_SIZE + data_len] + if returned: + bus += 128 + if rejected: + bus += 192 + if DEBUG: + print(f" R 0x{address:x}: 0x{data.hex()}") + ret.append((address, 0, data, bus)) + pos += pckt_len + else: + tail = chunk[pos:] + break return ret +def ensure_health_packet_version(fn): + @wraps(fn) + def wrapper(self, *args, **kwargs): + if self.health_version < self.HEALTH_PACKET_VERSION: + raise RuntimeError("Panda firmware has outdated health packet definition. Reflash panda firmware.") + elif self.health_version > self.HEALTH_PACKET_VERSION: + raise RuntimeError("Panda python library has outdated health packet definition. Update panda python library.") + return fn(self, *args, **kwargs) + return wrapper + +def ensure_can_packet_version(fn): + @wraps(fn) + def wrapper(self, *args, **kwargs): + if self.can_version < self.CAN_PACKET_VERSION: + raise RuntimeError("Panda firmware has outdated CAN packet definition. Reflash panda firmware.") + elif self.can_version > self.CAN_PACKET_VERSION: + raise RuntimeError("Panda python library has outdated CAN packet definition. Update panda python library.") + return fn(self, *args, **kwargs) + return wrapper + class PandaWifiStreaming(object): def __init__(self, ip="192.168.0.10", port=1338): self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -66,9 +131,9 @@ 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) + ret += unpack_can_buffer(dat) except socket.error as e: if e.errno != 35 and e.errno != 11: traceback.print_exc() @@ -83,7 +148,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 +161,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 +174,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 = 20 + SAFETY_VOLKSWAGEN_PQ = 21 + SAFETY_SUBARU_LEGACY = 22 + SAFETY_HYUNDAI_LEGACY = 23 SERIAL_DEBUG = 0 SERIAL_ESP = 1 @@ -135,17 +209,48 @@ 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' + HW_TYPE_DOS = b'\x06' + HW_TYPE_RED_PANDA = b'\x07' + + CAN_PACKET_VERSION = 2 + HEALTH_PACKET_VERSION = 1 + + F2_DEVICES = [HW_TYPE_PEDAL] + F4_DEVICES = [HW_TYPE_WHITE_PANDA, HW_TYPE_GREY_PANDA, HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS] + H7_DEVICES = [HW_TYPE_RED_PANDA] + + CLOCK_SOURCE_MODE_DISABLED = 0 + CLOCK_SOURCE_MODE_FREE_RUNNING = 1 + CLOCK_SOURCE_MODE_EXTERNAL_SYNC = 2 + + FLAG_HONDA_ALT_BRAKE = 1 + FLAG_HONDA_BOSCH_LONG = 2 + FLAG_HONDA_NIDEC_ALT = 4 + + FLAG_HYUNDAI_EV_GAS = 1 + FLAG_HYUNDAI_HYBRID_GAS = 2 + FLAG_HYUNDAI_LONG = 4 + FLAG_TESLA_POWERTRAIN = 1 + FLAG_TESLA_LONG_CONTROL = 2 + def __init__(self, serial=None, claim=True): self._serial = serial self._handle = None self.connect(claim) + self._mcu_type = self.get_mcu_type() def close(self): self._handle.close() 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 +265,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() @@ -169,21 +273,22 @@ def connect(self, claim=True, wait=False): if self._serial is None or this_serial == self._serial: self._serial = this_serial print("opening device", self._serial, hex(device.getProductID())) - time.sleep(1) self.bootstub = device.getProductID() == 0xddee - self.legacy = (device.getbcdDevice() != 0x2300) self._handle = device.open() + if sys.platform not in ["win32", "cygwin", "msys", "darwin"]: + 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) + self.health_version, self.can_version = self.get_packets_versions() print("connected") def reset(self, enter_bootstub=False, enter_bootloader=False): @@ -212,9 +317,9 @@ 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 = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type)) dfu.recover() except Exception: pass @@ -222,26 +327,28 @@ def reconnect(self): if not success: raise Exception("reconnect failed") + + @staticmethod 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") handle.controlWrite(Panda.REQUEST_IN, 0xb1, 0, 0, b'') - # erase sectors 1 and 2 + # erase sectors 1 through 3 print("flash: erasing") - handle.controlWrite(Panda.REQUEST_IN, 0xb2, 1, 0, b'') - handle.controlWrite(Panda.REQUEST_IN, 0xb2, 2, 0, b'') + for i in range(1, 4): + handle.controlWrite(Panda.REQUEST_IN, 0xb2, i, 0, b'') # flash over EP2 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") @@ -250,25 +357,16 @@ def flash_static(handle, code): except Exception: pass - def flash(self, fn=None, code=None, reconnect=True): + def flash(self, fn=DEFAULT_FW_FN, code=None, reconnect=True): + if self._mcu_type == MCU_TYPE_H7 and fn == DEFAULT_FW_FN: + fn = DEFAULT_H7_FW_FN print("flash: main version is " + self.get_version()) if not self.bootstub: self.reset(enter_bootstub=True) assert(self.bootstub) - if fn is None and code is None: - if self.legacy: - fn = "obj/comma.bin" - print("building legacy st code") - build_st(fn, "Makefile.legacy") - else: - fn = "obj/panda.bin" - print("building panda st code") - build_st(fn) - 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 +380,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: @@ -290,7 +389,7 @@ def recover(self, timeout=None): if timeout is not None and (time.time() - t_start) > timeout: return False - dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial)) + dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type)) dfu.recover() # reflash after recover @@ -302,14 +401,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 +424,7 @@ def list(): except Exception: pass # TODO: detect if this is real - #ret += ["WIFI"] + # ret += ["WIFI"] return ret def call_control_api(self, msg): @@ -333,14 +432,31 @@ def call_control_api(self, msg): # ******************* health ******************* + @ensure_health_packet_version def health(self): - dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd2, 0, 0, 13) - a = struct.unpack("IIBBBBB", dat) - return {"voltage": a[0], "current": a[1], - "started": a[2], "controls_allowed": a[3], - "gas_interceptor_detected": a[4], - "started_signal_detected": a[5], - "started_alt": a[6]} + dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd2, 0, 0, 44) + a = struct.unpack("= 0x800: - rir = (addr << 3) | transmit | extended - else: - rir = (addr << 21) | transmit - snd = struct.pack("II", rir, len(dat) | (bus << 4)) + dat - snd = snd.ljust(0x10, b'\x00') - snds.append(snd) + # 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 + @ensure_can_packet_version + def can_send_many(self, arr, timeout=CAN_SEND_TIMEOUT_MS): + snds = pack_can_buffer(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)) + for tx in snds: + while True: + bs = self._handle.bulkWrite(3, tx, timeout=timeout) + tx = tx[bs:] + if len(tx) == 0: + break + print("CAN: PARTIAL SEND MANY, RETRYING") 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) + @ensure_can_packet_version def can_recv(self): dat = bytearray() while True: try: - dat = self._handle.bulkRead(1, 0x10*256) + dat = self._handle.bulkRead(1, 16384) # Max receive batch size + 2 extra reserve frames break except (usb1.USBErrorIO, usb1.USBErrorOverflow): print("CAN: BAD RECV, RETRYING") - return parse_can_buffer(dat) + time.sleep(0.1) + return unpack_can_buffer(dat) def can_clear(self, bus): """Clears all messages from the specified internal CAN ringbuffer as @@ -489,7 +684,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): @@ -505,13 +700,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() @@ -520,42 +724,90 @@ 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'') + + # disable heartbeat checks for use outside of openpilot + # sending a heartbeat will reenable the checks + def set_heartbeat_disabled(self): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xf8, 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'') + + # ****************** Debug ***************** + def set_green_led(self, enabled): + self._handle.controlWrite(Panda.REQUEST_OUT, 0xf7, int(enabled), 0, b'') diff --git a/panda/python/ccp.py b/panda/python/ccp.py new file mode 100644 index 00000000000000..a8c00169fc3975 --- /dev/null +++ b/panda/python/ccp.py @@ -0,0 +1,362 @@ +#!/usr/bin/env python3 +import sys +import time +import struct +from enum import IntEnum, Enum + +class COMMAND_CODE(IntEnum): + CONNECT = 0x01 + SET_MTA = 0x02 + DNLOAD = 0x03 + UPLOAD = 0x04 + TEST = 0x05 + START_STOP = 0x06 + DISCONNECT = 0x07 + START_STOP_ALL = 0x08 + GET_ACTIVE_CAL_PAGE = 0x09 + SET_S_STATUS = 0x0C + GET_S_STATUS = 0x0D + BUILD_CHKSUM = 0x0E + SHORT_UP = 0x0F + CLEAR_MEMORY = 0x10 + SELECT_CAL_PAGE = 0x11 + GET_SEED = 0x12 + UNLOCK = 0x13 + GET_DAQ_SIZE = 0x14 + SET_DAQ_PTR = 0x15 + WRITE_DAQ = 0x16 + EXCHANGE_ID = 0x17 + PROGRAM = 0x18 + MOVE = 0x19 + GET_CCP_VERSION = 0x1B + DIAG_SERVICE = 0x20 + ACTION_SERVICE = 0x21 + PROGRAM_6 = 0x22 + DNLOAD_6 = 0x23 + +COMMAND_RETURN_CODES = { + 0x00: "acknowledge / no error", + 0x01: "DAQ processor overload", + 0x10: "command processor busy", + 0x11: "DAQ processor busy", + 0x12: "internal timeout", + 0x18: "key request", + 0x19: "session status request", + 0x20: "cold start request", + 0x21: "cal. data init. request", + 0x22: "DAQ list init. request", + 0x23: "code update request", + 0x30: "unknown command", + 0x31: "command syntax", + 0x32: "parameter(s) out of range", + 0x33: "access denied", + 0x34: "overload", + 0x35: "access locked", + 0x36: "resource/function not available", +} + +class BYTE_ORDER(Enum): + LITTLE_ENDIAN = '<' + BIG_ENDIAN = '>' + +class CommandTimeoutError(Exception): + pass + +class CommandCounterError(Exception): + pass + +class CommandResponseError(Exception): + def __init__(self, message, return_code): + super().__init__() + self.message = message + self.return_code = return_code + + def __str__(self): + return self.message + +class CcpClient(): + def __init__(self, panda, tx_addr: int, rx_addr: int, bus: int=0, byte_order: BYTE_ORDER=BYTE_ORDER.BIG_ENDIAN, debug=False): + self.tx_addr = tx_addr + self.rx_addr = rx_addr + self.can_bus = bus + self.byte_order = byte_order + self.debug = debug + self._panda = panda + self._command_counter = -1 + + def _send_cro(self, cmd: int, dat: bytes = b"") -> None: + self._command_counter = (self._command_counter + 1) & 0xFF + tx_data = (bytes([cmd, self._command_counter]) + dat).ljust(8, b"\x00") + if self.debug: + print(f"CAN-TX: {hex(self.tx_addr)} - 0x{bytes.hex(tx_data)}") + assert len(tx_data) == 8, "data is not 8 bytes" + self._panda.can_clear(self.can_bus) + self._panda.can_clear(0xFFFF) + self._panda.can_send(self.tx_addr, tx_data, self.can_bus) + + def _recv_dto(self, timeout: float) -> bytes: + start_time = time.time() + while time.time() - start_time < timeout: + msgs = self._panda.can_recv() or [] + if len(msgs) >= 256: + print("CAN RX buffer overflow!!!", file=sys.stderr) + for rx_addr, _, rx_data, rx_bus in msgs: + if rx_bus == self.can_bus and rx_addr == self.rx_addr: + rx_data = bytes(rx_data) # convert bytearray to bytes + if self.debug: + print(f"CAN-RX: {hex(rx_addr)} - 0x{bytes.hex(rx_data)}") + assert len(rx_data) == 8, f"message length not 8: {len(rx_data)}" + + pid = rx_data[0] + if pid == 0xFF or pid == 0xFE: + err = rx_data[1] + err_desc = COMMAND_RETURN_CODES.get(err, "unknown error") + ctr = rx_data[2] + dat = rx_data[3:] + + if pid == 0xFF and self._command_counter != ctr: + raise CommandCounterError(f"counter invalid: {ctr} != {self._command_counter}") + + if err >= 0x10 and err <= 0x12: + if self.debug: + print(f"CCP-WAIT: {hex(err)} - {err_desc}") + start_time = time.time() + continue + + if err >= 0x30: + raise CommandResponseError(f"{hex(err)} - {err_desc}", err) + else: + dat = rx_data[1:] + + return dat + time.sleep(0.001) + + raise CommandTimeoutError("timeout waiting for response") + + # commands + def connect(self, station_addr: int) -> None: + if station_addr > 65535: + raise ValueError("station address must be less than 65536") + # NOTE: station address is always little endian + self._send_cro(COMMAND_CODE.CONNECT, struct.pack(" dict: + self._send_cro(COMMAND_CODE.EXCHANGE_ID, device_id_info) + resp = self._recv_dto(0.025) + return { # TODO: define a type + "id_length": resp[0], + "data_type": resp[1], + "available": resp[2], + "protected": resp[3], + } + + def get_seed(self, resource_mask: int) -> bytes: + if resource_mask > 255: + raise ValueError("resource mask must be less than 256") + self._send_cro(COMMAND_CODE.GET_SEED) + resp = self._recv_dto(0.025) + # protected = resp[0] == 0 + seed = resp[1:] + return seed + + def unlock(self, key: bytes) -> int: + if len(key) > 6: + raise ValueError("max key size is 6 bytes") + self._send_cro(COMMAND_CODE.UNLOCK, key) + resp = self._recv_dto(0.025) + status = resp[0] + return status + + def set_memory_transfer_address(self, mta_num: int, addr_ext: int, addr: int) -> None: + if mta_num > 255: + raise ValueError("MTA number must be less than 256") + if addr_ext > 255: + raise ValueError("address extension must be less than 256") + self._send_cro(COMMAND_CODE.SET_MTA, bytes([mta_num, addr_ext]) + struct.pack(f"{self.byte_order.value}I", addr)) + self._recv_dto(0.025) + + def download(self, data: bytes) -> int: + if len(data) > 5: + raise ValueError("max data size is 5 bytes") + self._send_cro(COMMAND_CODE.DNLOAD, bytes([len(data)]) + data) + resp = self._recv_dto(0.025) + # mta_addr_ext = resp[0] + mta_addr = struct.unpack(f"{self.byte_order.value}I", resp[1:5])[0] + return mta_addr + + def download_6_bytes(self, data: bytes) -> int: + if len(data) != 6: + raise ValueError("data size must be 6 bytes") + self._send_cro(COMMAND_CODE.DNLOAD_6, data) + resp = self._recv_dto(0.025) + # mta_addr_ext = resp[0] + mta_addr = struct.unpack(f"{self.byte_order.value}I", resp[1:5])[0] + return mta_addr + + def upload(self, size: int) -> bytes: + if size > 5: + raise ValueError("size must be less than 6") + self._send_cro(COMMAND_CODE.UPLOAD, bytes([size])) + return self._recv_dto(0.025) + + def short_upload(self, size: int, addr_ext: int, addr: int) -> bytes: + if size > 5: + raise ValueError("size must be less than 6") + if addr_ext > 255: + raise ValueError("address extension must be less than 256") + self._send_cro(COMMAND_CODE.SHORT_UP, bytes([size, addr_ext]) + struct.pack(f"{self.byte_order.value}I", addr)) + return self._recv_dto(0.025) + + def select_calibration_page(self) -> None: + self._send_cro(COMMAND_CODE.SELECT_CAL_PAGE) + self._recv_dto(0.025) + + def get_daq_list_size(self, list_num: int, can_id: int = 0) -> dict: + if list_num > 255: + raise ValueError("list number must be less than 256") + self._send_cro(COMMAND_CODE.GET_DAQ_SIZE, bytes([list_num, 0]) + struct.pack(f"{self.byte_order.value}I", can_id)) + resp = self._recv_dto(0.025) + return { # TODO: define a type + "list_size": resp[0], + "first_pid": resp[1], + } + + def set_daq_list_pointer(self, list_num: int, odt_num: int, element_num: int) -> None: + if list_num > 255: + raise ValueError("list number must be less than 256") + if odt_num > 255: + raise ValueError("ODT number must be less than 256") + if element_num > 255: + raise ValueError("element number must be less than 256") + self._send_cro(COMMAND_CODE.SET_DAQ_PTR, bytes([list_num, odt_num, element_num])) + self._recv_dto(0.025) + + def write_daq_list_entry(self, size: int, addr_ext: int, addr: int) -> None: + if size > 255: + raise ValueError("size must be less than 256") + if addr_ext > 255: + raise ValueError("address extension must be less than 256") + self._send_cro(COMMAND_CODE.WRITE_DAQ, bytes([size, addr_ext]) + struct.pack(f"{self.byte_order.value}I", addr)) + self._recv_dto(0.025) + + def start_stop_transmission(self, mode: int, list_num: int, odt_num: int, channel_num: int, rate_prescaler: int = 0) -> None: + if mode > 255: + raise ValueError("mode must be less than 256") + if list_num > 255: + raise ValueError("list number must be less than 256") + if odt_num > 255: + raise ValueError("ODT number must be less than 256") + if channel_num > 255: + raise ValueError("channel number must be less than 256") + if rate_prescaler > 65535: + raise ValueError("rate prescaler must be less than 65536") + self._send_cro(COMMAND_CODE.START_STOP, bytes([mode, list_num, odt_num, channel_num]) + struct.pack(f"{self.byte_order.value}H", rate_prescaler)) + self._recv_dto(0.025) + + def disconnect(self, station_addr: int, temporary: bool = False) -> None: + if station_addr > 65535: + raise ValueError("station address must be less than 65536") + # NOTE: station address is always little endian + self._send_cro(COMMAND_CODE.DISCONNECT, bytes([int(not temporary), 0x00]) + struct.pack(" None: + if status > 255: + raise ValueError("status must be less than 256") + self._send_cro(COMMAND_CODE.SET_S_STATUS, bytes([status])) + self._recv_dto(0.025) + + def get_session_status(self) -> dict: + self._send_cro(COMMAND_CODE.GET_S_STATUS) + resp = self._recv_dto(0.025) + return { # TODO: define a type + "status": resp[0], + "info": resp[2] if resp[1] else None, + } + + def build_checksum(self, size: int) -> bytes: + self._send_cro(COMMAND_CODE.BUILD_CHKSUM, struct.pack(f"{self.byte_order.value}I", size)) + resp = self._recv_dto(30.0) + chksum_size = resp[0] + assert chksum_size <= 4, "checksum more than 4 bytes" + chksum = resp[1:1+chksum_size] + return chksum + + def clear_memory(self, size: int) -> None: + self._send_cro(COMMAND_CODE.CLEAR_MEMORY, struct.pack(f"{self.byte_order.value}I", size)) + self._recv_dto(30.0) + + def program(self, size: int, data: bytes) -> int: + if size > 5: + raise ValueError("size must be less than 6") + if len(data) > 5: + raise ValueError("max data size is 5 bytes") + self._send_cro(COMMAND_CODE.PROGRAM, bytes([size]) + data) + resp = self._recv_dto(0.1) + # mta_addr_ext = resp[0] + mta_addr = struct.unpack(f"{self.byte_order.value}I", resp[1:5])[0] + return mta_addr + + def program_6_bytes(self, data: bytes) -> int: + if len(data) != 6: + raise ValueError("data size must be 6 bytes") + self._send_cro(COMMAND_CODE.PROGRAM_6, data) + resp = self._recv_dto(0.1) + # mta_addr_ext = resp[0] + mta_addr = struct.unpack(f"{self.byte_order.value}I", resp[1:5])[0] + return mta_addr + + def move_memory_block(self, size: int) -> None: + self._send_cro(COMMAND_CODE.MOVE, struct.pack(f"{self.byte_order.value}I", size)) + self._recv_dto(0.025) + + def diagnostic_service(self, service_num: int, data: bytes = b"") -> dict: + if service_num > 65535: + raise ValueError("service number must be less than 65536") + if len(data) > 4: + raise ValueError("max data size is 4 bytes") + self._send_cro(COMMAND_CODE.DIAG_SERVICE, struct.pack(f"{self.byte_order.value}H", service_num) + data) + resp = self._recv_dto(0.025) + return { # TODO: define a type + "length": resp[0], + "type": resp[1], + } + + def action_service(self, service_num: int, data: bytes = b"") -> dict: + if service_num > 65535: + raise ValueError("service number must be less than 65536") + if len(data) > 4: + raise ValueError("max data size is 4 bytes") + self._send_cro(COMMAND_CODE.ACTION_SERVICE, struct.pack(f"{self.byte_order.value}H", service_num) + data) + resp = self._recv_dto(0.025) + return { # TODO: define a type + "length": resp[0], + "type": resp[1], + } + + def test_availability(self, station_addr: int) -> None: + if station_addr > 65535: + raise ValueError("station address must be less than 65536") + # NOTE: station address is always little endian + self._send_cro(COMMAND_CODE.TEST, struct.pack(" None: + if mode > 255: + raise ValueError("mode must be less than 256") + self._send_cro(COMMAND_CODE.START_STOP_ALL, bytes([mode])) + self._recv_dto(0.025) + + def get_active_calibration_page(self): + self._send_cro(COMMAND_CODE.GET_ACTIVE_CAL_PAGE) + resp = self._recv_dto(0.025) + # cal_addr_ext = resp[0] + cal_addr = struct.unpack(f"{self.byte_order.value}I", resp[1:5])[0] + return cal_addr + + def get_version(self, desired_version: float = 2.1) -> float: + major, minor = map(int, str(desired_version).split(".")) + self._send_cro(COMMAND_CODE.GET_CCP_VERSION, bytes([major, minor])) + resp = self._recv_dto(0.025) + return float(f"{resp[0]}.{resp[1]}") diff --git a/panda/python/config.py b/panda/python/config.py new file mode 100644 index 00000000000000..9b890a1314f35e --- /dev/null +++ b/panda/python/config.py @@ -0,0 +1,18 @@ +import os + + +BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../") + +BOOTSTUB_ADDRESS = 0x8000000 + +BLOCK_SIZE_FX = 0x800 +APP_ADDRESS_FX = 0x8004000 +DEVICE_SERIAL_NUMBER_ADDR_FX = 0x1FFF79C0 +DEFAULT_FW_FN = os.path.join(BASEDIR, "board", "obj", "panda.bin.signed") +DEFAULT_BOOTSTUB_FN = os.path.join(BASEDIR, "board", "obj", "bootstub.panda.bin") + +BLOCK_SIZE_H7 = 0x400 +APP_ADDRESS_H7 = 0x8020000 +DEVICE_SERIAL_NUMBER_ADDR_H7 = 0x080FFFC0 +DEFAULT_H7_FW_FN = os.path.join(BASEDIR, "board", "obj", "panda_h7.bin.signed") +DEFAULT_H7_BOOTSTUB_FN = os.path.join(BASEDIR, "board", "obj", "bootstub.panda_h7.bin") diff --git a/panda/python/dfu.py b/panda/python/dfu.py index 02deed47bbe2ec..317780ca8d6898 100644 --- a/panda/python/dfu.py +++ b/panda/python/dfu.py @@ -1,11 +1,14 @@ -from __future__ import print_function -import os import usb1 import struct -import time +import binascii +from .config import BOOTSTUB_ADDRESS, APP_ADDRESS_H7, APP_ADDRESS_FX, BLOCK_SIZE_H7, BLOCK_SIZE_FX, DEFAULT_H7_BOOTSTUB_FN, DEFAULT_BOOTSTUB_FN -# *** DFU mode *** +MCU_TYPE_F2 = 0 +MCU_TYPE_F4 = 1 +MCU_TYPE_H7 = 2 + +# *** DFU mode *** DFU_DNLOAD = 1 DFU_UPLOAD = 2 DFU_GETSTATUS = 3 @@ -22,10 +25,10 @@ def __init__(self, dfu_serial): except Exception: continue if this_dfu_serial == dfu_serial or dfu_serial is None: + self._mcu_type = self.get_mcu_type(device) 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(): @@ -43,79 +46,80 @@ def list(): return dfu_serials @staticmethod - def st_serial_to_dfu_serial(st): - if st == None or st == "none": + def st_serial_to_dfu_serial(st, mcu_type=MCU_TYPE_F4): + 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)) + if mcu_type == MCU_TYPE_H7: + return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4], uid_base[3])).upper().decode("utf-8") + else: + 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") + # TODO: Find a way to detect F4 vs F2 + def get_mcu_type(self, dev): + return MCU_TYPE_H7 if dev.getbcdDevice() == 512 else MCU_TYPE_F4 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): self.clear_status() - self.erase(0x8004000) - self.erase(0x8000000) - self.program(0x8000000, code_bootstub, 0x800) + self.erase(BOOTSTUB_ADDRESS) + if self._mcu_type == MCU_TYPE_H7: + self.erase(APP_ADDRESS_H7) + self.program(BOOTSTUB_ADDRESS, code_bootstub, BLOCK_SIZE_H7) + else: + self.erase(APP_ADDRESS_FX) + self.program(BOOTSTUB_ADDRESS, code_bootstub, BLOCK_SIZE_FX) self.reset() def recover(self): - from panda import BASEDIR, build_st - if self.legacy: - fn = "obj/bootstub.comma.bin" - print("building legacy bootstub") - build_st(fn, "Makefile.legacy") - else: - fn = "obj/bootstub.panda.bin" - print("building panda bootstub") - build_st(fn) - fn = os.path.join(BASEDIR, "board", fn) + fn = DEFAULT_H7_BOOTSTUB_FN if self._mcu_type == MCU_TYPE_H7 else DEFAULT_BOOTSTUB_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", BOOTSTUB_ADDRESS)) 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 e68e6cd6e06779..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 51f6a72e7a6c07..ae50e6dc02d8ba 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().strip() + 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]) @@ -89,7 +69,6 @@ def status(x): # done! status("6. Success!") - + if __name__ == "__main__": flash_release(*sys.argv[1:]) - diff --git a/panda/python/isotp.py b/panda/python/isotp.py index d68aa4d70e0bbe..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 + # TODO: handle other subaddr also communicating + 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..97fe8f1d90d818 100644 --- a/panda/python/serial.py +++ b/panda/python/serial.py @@ -4,24 +4,32 @@ def __init__(self, panda, port, baud): self.panda = panda self.port = port self.panda.set_uart_parity(self.port, 0) + self._baudrate = baud 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 + def flush(self): + pass + + @property + def baudrate(self): + return self._baudrate + @baudrate.setter + def baudrate(self, value): + self.panda.set_uart_baud(self.port, value) + self._baudrate = value diff --git a/panda/python/uds.py b/panda/python/uds.py new file mode 100644 index 00000000000000..d0119612c8e731 --- /dev/null +++ b/panda/python/uds.py @@ -0,0 +1,873 @@ +#!/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 +from functools import partial + +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 number 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 - {hex(self._can_client.tx_addr)} 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(f"ISO-TP: TX - single frame - {hex(self._can_client.tx_addr)}") + 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(f"ISO-TP: TX - first frame - {hex(self._can_client.tx_addr)}") + 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, timeout=None) -> Optional[bytes]: + if timeout is None: + timeout = self.timeout + + start_time = time.monotonic() + try: + while True: + for msg in self._can_client.recv(): + self._isotp_rx_next(msg) + start_time = time.monotonic() + if self.tx_done and self.rx_done: + return self.rx_dat + # no timeout indicates non-blocking + if timeout == 0: + return None + if time.monotonic() - start_time > timeout: + raise MessageTimeoutError("timeout waiting for response") + finally: + if self.debug and self.rx_dat: + print(f"ISO-TP: RESPONSE - {hex(self._can_client.rx_addr)} 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 - {hex(self._can_client.rx_addr)} 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 - {hex(self._can_client.rx_addr)} idx={self.rx_idx} done={self.rx_done}") + if self.debug: + print(f"ISO-TP: TX - flow control continue - {hex(self._can_client.tx_addr)}") + # 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 - {hex(self._can_client.rx_addr)} 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(f"ISO-TP: RX - flow control continue - {hex(self._can_client.tx_addr)}") + 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 - {hex(self._can_client.tx_addr)} 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(f"ISO-TP: TX - flow control wait - {hex(self._can_client.tx_addr)}") + +FUNCTIONAL_ADDRS = [0x7DF, 0x18DB33F1] + +def get_rx_addr_for_tx_addr(tx_addr, rx_offset=0x8): + if tx_addr in FUNCTIONAL_ADDRS: + return None + + if tx_addr < 0xFFF8: + # pseudo-standard 11 bit response addr (add 8) works for most manufacturers + # allow override; some manufacturers use other offsets for non-OBD2 access + return tx_addr + rx_offset + + 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, + tx_timeout: float = 1, response_pending_timeout: float = 10): + 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 + can_send_with_timeout = partial(panda.can_send, timeout=int(tx_timeout*1000)) + self._can_client = CanClient(can_send_with_timeout, panda.can_recv, self.tx_addr, self.rx_addr, self.bus, debug=self.debug) + self.response_pending_timeout = response_pending_timeout + + # 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) + response_pending = False + while True: + timeout = self.response_pending_timeout if response_pending else self.timeout + resp = isotp_msg.recv(timeout) + + if resp is None: + continue + + response_pending = False + 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: + response_pending = True + 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 = b'', data_record: bytes = b''): + request_seed = access_type % 2 != 0 + if request_seed and len(security_key) != 0: + raise ValueError('security_key not allowed') + if not request_seed and len(security_key) == 0: + raise ValueError('security_key is missing') + if not request_seed and len(data_record) != 0: + raise ValueError('data_record not allowed') + data = security_key + data_record + resp = self._uds_request(SERVICE_TYPE.SECURITY_ACCESS, subfunction=access_type, data=data) + 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: {} expected: {}'.format(hex(resp_id), hex(data_identifier_type))) + 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 = b'', 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 4e07d329cace20..00000000000000 --- a/panda/run_automated_tests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -TEST_FILENAME=${TEST_FILENAME:-nosetests.xml} -if [ ! -f "/EON" ]; then - TESTSUITE_NAME="Panda_Test-EON" -else - TESTSUITE_NAME="Panda_Test-DEV" -fi - -cd boardesp -make flashall -cd .. - - -PYTHONPATH="." python $(which nosetests) -v --with-xunit --xunit-file=./$TEST_FILENAME --xunit-testsuite-name=$TESTSUITE_NAME -s tests/automated/$1*.py 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 7860d3290fb0e5..00000000000000 --- a/panda/tests/automated/2_usb_to_can.py +++ /dev/null @@ -1,199 +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: - # 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) - - # 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) - - addrs = range(100, 100+MSG_COUNT) - ts = [(j, 0, "\xaa"*8, 0) for j in addrs] - - # 100 loops - for i in range(LOOP_COUNT): - 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) - - # 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) - - 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) - - # 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]: - 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) - - # enable CAN loopback mode - p.set_can_loopback(True) - - # GMLAN_CAN2 - for bus in [Panda.GMLAN_CAN2, Panda.GMLAN_CAN3]: - 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]: - 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 0cf42d1f3fba17..00000000000000 --- a/panda/tests/automated/4_wifi_functionality.py +++ /dev/null @@ -1,59 +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) - - # enable CAN loopback mode - p.set_can_loopback(True) - - p = Panda("WIFI") - - for speed in [100,250,500,750,1000]: - # 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) - p.set_can_loopback(True) - pwifi = Panda("WIFI") - - # TODO: msg_count=1000 drops packets, is this fixable? - for msg_count in [10,100,200]: - 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 873f78bdb39bf8..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, 15) #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 3c29a0e7a1233d..00000000000000 --- a/panda/tests/automated/6_two_panda.py +++ /dev/null @@ -1,121 +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) - - 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]: - 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) - - 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() - - busses = [0,1,2] - - for bus in busses: - for speed in [100, 250, 500, 750, 1000]: - 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/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/build_strict/Dockerfile b/panda/tests/build_strict/Dockerfile deleted file mode 100644 index b1c75c0258ef64..00000000000000 --- a/panda/tests/build_strict/Dockerfile +++ /dev/null @@ -1,9 +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++ - -RUN pip install pycrypto==2.6.1 - -COPY . /panda - -WORKDIR /panda diff --git a/panda/tests/build_strict/test_build_strict.sh b/panda/tests/build_strict/test_build_strict.sh deleted file mode 100755 index ee57ba8ad80822..00000000000000 --- a/panda/tests/build_strict/test_build_strict.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -e - -cd ../../board/ - -make -f Makefile.strict clean -make -f Makefile.strict bin 2> compiler_output.txt - - -if [[ -s "compiler_output.txt" ]] -then - echo "Found alerts from the compiler:" - cat compiler_output.txt - exit 1 -fi - 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 bcee821cd04d44..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 a398e2780385b1..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) - -# ack any crap 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/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/test_misra.sh b/panda/tests/misra/test_misra.sh deleted file mode 100755 index 835f4ebcfd23df..00000000000000 --- a/panda/tests/misra/test_misra.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -e - -git clone https://github.com/danmar/cppcheck.git || true -cd cppcheck -git fetch -git checkout 44d6066c6fad32e2b0332b3f2b24bd340febaef8 -make -j4 -cd ../../../ - -# whole panda code -tests/misra/cppcheck/cppcheck --dump --enable=all --inline-suppr board/main.c 2>/tmp/misra/cppcheck_output.txt || true -python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2>/tmp/misra/misra_output.txt || true - -# violations in safety files -(cat /tmp/misra/misra_output.txt | grep safety) > /tmp/misra/misra_safety_output.txt || true -(cat /tmp/misra/cppcheck_output.txt | grep safety) > /tmp/misra/cppcheck_safety_output.txt || true - -if [[ -s "/tmp/misra/misra_safety_output.txt" ]] || [[ -s "/tmp/misra/cppcheck_safety_output.txt" ]] -then - echo "Found Misra violations in the safety code:" - cat /tmp/misra/misra_safety_output.txt - cat /tmp/misra/cppcheck_safety_output.txt - exit 1 -fi 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/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 dc5e5be5afb29e..00000000000000 --- a/panda/tests/safety/libpandasafety_py.py +++ /dev/null @@ -1,97 +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); -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); -int get_honda_ego_speed(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); - -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 be13d346afcf6b..00000000000000 --- a/panda/tests/safety/test.c +++ /dev/null @@ -1,290 +0,0 @@ -#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; - -#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; }) - -#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; -} - -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; -} - -int get_honda_ego_speed(void){ - return honda_ego_speed; -} - -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; -} - -void init_tests_toyota(void){ - 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){ - 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){ - 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){ - 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){ - 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){ - 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){ - honda_ego_speed = 0; - 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 83d8f5b31fa420..00000000000000 --- a/panda/tests/safety/test.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env sh -python -m unittest discover . 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 bc5e8d192f1712..00000000000000 --- a/panda/tests/safety/test_honda.py +++ /dev/null @@ -1,273 +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(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 - - 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 - to_send[0].RDLR = ((gas & 0xff) << 8) | ((gas & 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_ego_speed()) - self.safety.safety_rx_hook(self._speed_msg(100)) - self.assertEqual(100, self.safety.get_honda_ego_speed()) - - 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]: - 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(1) - self.safety.safety_rx_hook(self._send_interceptor_msg(0x1000, 0x201)) - 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._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 11c93914039c1d..00000000000000 --- a/panda/tests/safety/test_honda_bosch.py +++ /dev/null @@ -1,42 +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) - - blocked_msgs = [0xE4, 0x33D] - for b in buss: - for m in msgs: - if b == 0: - fwd_bus = -1 - elif b == 1: - fwd_bus = -1 if m in blocked_msgs else 2 - elif b == 2: - 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_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 7dd1601d7712c3..00000000000000 --- a/panda/tests/safety/test_toyota.py +++ /dev/null @@ -1,312 +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 - -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 - to_send[0].RDLR = ((gas & 0xff) << 8) | ((gas & 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]: - 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(0x1000, 0x201)) - 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._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 bf2b7f2c1f1f2c..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 b6461274d684915f39dc45efc5292ea890698da9 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 e13ab48c24ae7b..00000000000000 --- a/panda/tests/safety_replay/install_capnp.sh +++ /dev/null @@ -1,20 +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 - -cd .. -git clone https://github.com/commaai/c-capnproto.git -cd c-capnproto -git checkout 2e625acacf58a5f5c8828d8453d1f8dacc700a96 -git submodule update --init --recursive -autoreconf -f -i -s -CFLAGS="-fPIC" ./configure --prefix=/usr/local -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/android_frameworks_native/get.txt b/phonelibs/android_frameworks_native/get.txt deleted file mode 100644 index 31f42ebe0e3f36..00000000000000 --- a/phonelibs/android_frameworks_native/get.txt +++ /dev/null @@ -1,3 +0,0 @@ -git clone https://github.com/CyanogenMod/android_frameworks_native.git && cd android_frameworks_native -git reset --hard b22bca465e55618a949d9cbdea665a1a3a831241 -cp -r include ~/one/phonelibs/android_frameworks_native/ diff --git a/phonelibs/android_frameworks_native/include/batteryservice/BatteryService.h b/phonelibs/android_frameworks_native/include/batteryservice/BatteryService.h deleted file mode 100644 index 3e6bfb8204f611..00000000000000 --- a/phonelibs/android_frameworks_native/include/batteryservice/BatteryService.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * Copyright (C) 2015 The CyanogenMod Project - * - * 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. - */ - -#ifndef ANDROID_BATTERYSERVICE_H -#define ANDROID_BATTERYSERVICE_H - -#include -#include -#include -#include - -namespace android { - -// must be kept in sync with definitions in BatteryManager.java -enum { - BATTERY_STATUS_UNKNOWN = 1, // equals BatteryManager.BATTERY_STATUS_UNKNOWN constant - BATTERY_STATUS_CHARGING = 2, // equals BatteryManager.BATTERY_STATUS_CHARGING constant - BATTERY_STATUS_DISCHARGING = 3, // equals BatteryManager.BATTERY_STATUS_DISCHARGING constant - BATTERY_STATUS_NOT_CHARGING = 4, // equals BatteryManager.BATTERY_STATUS_NOT_CHARGING constant - BATTERY_STATUS_FULL = 5, // equals BatteryManager.BATTERY_STATUS_FULL constant -}; - -// must be kept in sync with definitions in BatteryManager.java -enum { - BATTERY_HEALTH_UNKNOWN = 1, // equals BatteryManager.BATTERY_HEALTH_UNKNOWN constant - BATTERY_HEALTH_GOOD = 2, // equals BatteryManager.BATTERY_HEALTH_GOOD constant - BATTERY_HEALTH_OVERHEAT = 3, // equals BatteryManager.BATTERY_HEALTH_OVERHEAT constant - BATTERY_HEALTH_DEAD = 4, // equals BatteryManager.BATTERY_HEALTH_DEAD constant - BATTERY_HEALTH_OVER_VOLTAGE = 5, // equals BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE constant - BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6, // equals BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE constant - BATTERY_HEALTH_COLD = 7, // equals BatteryManager.BATTERY_HEALTH_COLD constant -}; - -// must be kept in sync with definitions in BatteryProperty.java -enum { - BATTERY_PROP_CHARGE_COUNTER = 1, // equals BatteryProperty.CHARGE_COUNTER constant - BATTERY_PROP_CURRENT_NOW = 2, // equals BatteryProperty.CURRENT_NOW constant - BATTERY_PROP_CURRENT_AVG = 3, // equals BatteryProperty.CURRENT_AVG constant - BATTERY_PROP_CAPACITY = 4, // equals BatteryProperty.CAPACITY constant - BATTERY_PROP_ENERGY_COUNTER = 5, // equals BatteryProperty.ENERGY_COUNTER constant -}; - -struct BatteryProperties { - bool chargerAcOnline; - bool chargerUsbOnline; - bool chargerWirelessOnline; - int maxChargingCurrent; - int batteryStatus; - int batteryHealth; - bool batteryPresent; - int batteryLevel; - int batteryVoltage; - int batteryTemperature; - String8 batteryTechnology; - - bool dockBatterySupported; - bool chargerDockAcOnline; - int dockBatteryStatus; - int dockBatteryHealth; - bool dockBatteryPresent; - int dockBatteryLevel; - int dockBatteryVoltage; - int dockBatteryTemperature; - String8 dockBatteryTechnology; - - status_t writeToParcel(Parcel* parcel) const; - status_t readFromParcel(Parcel* parcel); -}; - -struct BatteryProperty { - int64_t valueInt64; - - status_t writeToParcel(Parcel* parcel) const; - status_t readFromParcel(Parcel* parcel); -}; - -}; // namespace android - -#endif // ANDROID_BATTERYSERVICE_H diff --git a/phonelibs/android_frameworks_native/include/batteryservice/IBatteryPropertiesListener.h b/phonelibs/android_frameworks_native/include/batteryservice/IBatteryPropertiesListener.h deleted file mode 100644 index b02d8e907335eb..00000000000000 --- a/phonelibs/android_frameworks_native/include/batteryservice/IBatteryPropertiesListener.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * 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. - */ - -#ifndef ANDROID_IBATTERYPROPERTIESLISTENER_H -#define ANDROID_IBATTERYPROPERTIESLISTENER_H - -#include -#include - -#include - -namespace android { - -// must be kept in sync with interface defined in IBatteryPropertiesListener.aidl -enum { - TRANSACT_BATTERYPROPERTIESCHANGED = IBinder::FIRST_CALL_TRANSACTION, -}; - -// ---------------------------------------------------------------------------- - -class IBatteryPropertiesListener : public IInterface { -public: - DECLARE_META_INTERFACE(BatteryPropertiesListener); - - virtual void batteryPropertiesChanged(struct BatteryProperties props) = 0; -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IBATTERYPROPERTIESLISTENER_H diff --git a/phonelibs/android_frameworks_native/include/batteryservice/IBatteryPropertiesRegistrar.h b/phonelibs/android_frameworks_native/include/batteryservice/IBatteryPropertiesRegistrar.h deleted file mode 100644 index f6a7981d54b95a..00000000000000 --- a/phonelibs/android_frameworks_native/include/batteryservice/IBatteryPropertiesRegistrar.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * Copyright (C) 2015 The CyanogenMod Project - * - * 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. - */ - -#ifndef ANDROID_IBATTERYPROPERTIESREGISTRAR_H -#define ANDROID_IBATTERYPROPERTIESREGISTRAR_H - -#include -#include - -namespace android { - -// must be kept in sync with interface defined in IBatteryPropertiesRegistrar.aidl -enum { - REGISTER_LISTENER = IBinder::FIRST_CALL_TRANSACTION, - UNREGISTER_LISTENER, - GET_PROPERTY, - GET_DOCK_PROPERTY, -}; - -class IBatteryPropertiesRegistrar : public IInterface { -public: - DECLARE_META_INTERFACE(BatteryPropertiesRegistrar); - - virtual void registerListener(const sp& listener) = 0; - virtual void unregisterListener(const sp& listener) = 0; - virtual status_t getProperty(int id, struct BatteryProperty *val) = 0; - virtual status_t getDockProperty(int id, struct BatteryProperty *val) = 0; -}; - -class BnBatteryPropertiesRegistrar : public BnInterface { -public: - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -}; // namespace android - -#endif // ANDROID_IBATTERYPROPERTIESREGISTRAR_H diff --git a/phonelibs/android_frameworks_native/include/diskusage/dirsize.h b/phonelibs/android_frameworks_native/include/diskusage/dirsize.h deleted file mode 100644 index 34236c0e6f7006..00000000000000 --- a/phonelibs/android_frameworks_native/include/diskusage/dirsize.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - */ - -#ifndef __LIBDISKUSAGE_DIRSIZE_H -#define __LIBDISKUSAGE_DIRSIZE_H - -#include - -__BEGIN_DECLS - -int64_t stat_size(struct stat *s); -int64_t calculate_dir_size(int dfd); - -__END_DECLS - -#endif /* __LIBDISKUSAGE_DIRSIZE_H */ diff --git a/phonelibs/android_frameworks_native/include/input/IInputFlinger.h b/phonelibs/android_frameworks_native/include/input/IInputFlinger.h deleted file mode 100644 index 629310ff2f236f..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/IInputFlinger.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_IINPUT_FLINGER_H -#define _LIBINPUT_IINPUT_FLINGER_H - -#include -#include - -#include - -namespace android { - -/* - * This class defines the Binder IPC interface for accessing various - * InputFlinger features. - */ -class IInputFlinger : public IInterface { -public: - DECLARE_META_INTERFACE(InputFlinger); -}; - - -/** - * Binder implementation. - */ -class BnInputFlinger : public BnInterface { -public: - enum { - DO_SOMETHING_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, - }; - - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -} // namespace android - -#endif // _LIBINPUT_IINPUT_FLINGER_H diff --git a/phonelibs/android_frameworks_native/include/input/Input.h b/phonelibs/android_frameworks_native/include/input/Input.h deleted file mode 100644 index 82fc6599a7f051..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/Input.h +++ /dev/null @@ -1,681 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_INPUT_H -#define _LIBINPUT_INPUT_H - -/** - * Native input event structures. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Additional private constants not defined in ndk/ui/input.h. - */ -enum { - /* Signifies that the key is being predispatched */ - AKEY_EVENT_FLAG_PREDISPATCH = 0x20000000, - - /* Private control to determine when an app is tracking a key sequence. */ - AKEY_EVENT_FLAG_START_TRACKING = 0x40000000, - - /* Key event is inconsistent with previously sent key events. */ - AKEY_EVENT_FLAG_TAINTED = 0x80000000, -}; - -enum { - - /** - * This flag indicates that the window that received this motion event is partly - * or wholly obscured by another visible window above it. This flag is set to true - * even if the event did not directly pass through the obscured area. - * A security sensitive application can check this flag to identify situations in which - * a malicious application may have covered up part of its content for the purpose - * of misleading the user or hijacking touches. An appropriate response might be - * to drop the suspect touches or to take additional precautions to confirm the user's - * actual intent. - */ - AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2, - - /* Motion event is inconsistent with previously sent motion events. */ - AMOTION_EVENT_FLAG_TAINTED = 0x80000000, -}; - -enum { - /* Used when a motion event is not associated with any display. - * Typically used for non-pointer events. */ - ADISPLAY_ID_NONE = -1, - - /* The default display id. */ - ADISPLAY_ID_DEFAULT = 0, -}; - -enum { - /* - * Indicates that an input device has switches. - * This input source flag is hidden from the API because switches are only used by the system - * and applications have no way to interact with them. - */ - AINPUT_SOURCE_SWITCH = 0x80000000, -}; - -enum { - /** - * Constants for LEDs. Hidden from the API since we don't actually expose a way to interact - * with LEDs to developers - * - * NOTE: If you add LEDs here, you must also add them to InputEventLabels.h - */ - - ALED_NUM_LOCK = 0x00, - ALED_CAPS_LOCK = 0x01, - ALED_SCROLL_LOCK = 0x02, - ALED_COMPOSE = 0x03, - ALED_KANA = 0x04, - ALED_SLEEP = 0x05, - ALED_SUSPEND = 0x06, - ALED_MUTE = 0x07, - ALED_MISC = 0x08, - ALED_MAIL = 0x09, - ALED_CHARGING = 0x0a, - ALED_CONTROLLER_1 = 0x10, - ALED_CONTROLLER_2 = 0x11, - ALED_CONTROLLER_3 = 0x12, - ALED_CONTROLLER_4 = 0x13, -}; - -/* Maximum number of controller LEDs we support */ -#define MAX_CONTROLLER_LEDS 4 - -/* - * SystemUiVisibility constants from View. - */ -enum { - ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE = 0, - ASYSTEM_UI_VISIBILITY_STATUS_BAR_HIDDEN = 0x00000001, -}; - -/* - * Maximum number of pointers supported per motion event. - * Smallest number of pointers is 1. - * (We want at least 10 but some touch controllers obstensibly configured for 10 pointers - * will occasionally emit 11. There is not much harm making this constant bigger.) - */ -#define MAX_POINTERS 16 - -/* - * Maximum number of samples supported per motion event. - */ -#define MAX_SAMPLES UINT16_MAX - -/* - * Maximum pointer id value supported in a motion event. - * Smallest pointer id is 0. - * (This is limited by our use of BitSet32 to track pointer assignments.) - */ -#define MAX_POINTER_ID 31 - -/* - * Declare a concrete type for the NDK's input event forward declaration. - */ -struct AInputEvent { - virtual ~AInputEvent() { } -}; - -/* - * Declare a concrete type for the NDK's input device forward declaration. - */ -struct AInputDevice { - virtual ~AInputDevice() { } -}; - - -namespace android { - -#ifdef HAVE_ANDROID_OS -class Parcel; -#endif - -/* - * Flags that flow alongside events in the input dispatch system to help with certain - * policy decisions such as waking from device sleep. - * - * These flags are also defined in frameworks/base/core/java/android/view/WindowManagerPolicy.java. - */ -enum { - /* These flags originate in RawEvents and are generally set in the key map. - * NOTE: If you want a flag to be able to set in a keylayout file, then you must add it to - * InputEventLabels.h as well. */ - - // Indicates that the event should wake the device. - POLICY_FLAG_WAKE = 0x00000001, - - // Indicates that the key is virtual, such as a capacitive button, and should - // generate haptic feedback. Virtual keys may be suppressed for some time - // after a recent touch to prevent accidental activation of virtual keys adjacent - // to the touch screen during an edge swipe. - POLICY_FLAG_VIRTUAL = 0x00000002, - - // Indicates that the key is the special function modifier. - POLICY_FLAG_FUNCTION = 0x00000004, - - // Indicates that the key represents a special gesture that has been detected by - // the touch firmware or driver. Causes touch events from the same device to be canceled. - POLICY_FLAG_GESTURE = 0x00000008, - - POLICY_FLAG_RAW_MASK = 0x0000ffff, - - /* These flags are set by the input dispatcher. */ - - // Indicates that the input event was injected. - POLICY_FLAG_INJECTED = 0x01000000, - - // Indicates that the input event is from a trusted source such as a directly attached - // input device or an application with system-wide event injection permission. - POLICY_FLAG_TRUSTED = 0x02000000, - - // Indicates that the input event has passed through an input filter. - POLICY_FLAG_FILTERED = 0x04000000, - - // Disables automatic key repeating behavior. - POLICY_FLAG_DISABLE_KEY_REPEAT = 0x08000000, - - /* These flags are set by the input reader policy as it intercepts each event. */ - - // Indicates that the device was in an interactive state when the - // event was intercepted. - POLICY_FLAG_INTERACTIVE = 0x20000000, - - // Indicates that the event should be dispatched to applications. - // The input event should still be sent to the InputDispatcher so that it can see all - // input events received include those that it will not deliver. - POLICY_FLAG_PASS_TO_USER = 0x40000000, -}; - -/* - * Pointer coordinate data. - */ -struct PointerCoords { - enum { MAX_AXES = 30 }; // 30 so that sizeof(PointerCoords) == 128 - - // Bitfield of axes that are present in this structure. - uint64_t bits __attribute__((aligned(8))); - - // Values of axes that are stored in this structure packed in order by axis id - // for each axis that is present in the structure according to 'bits'. - float values[MAX_AXES]; - - inline void clear() { - BitSet64::clear(bits); - } - - bool isEmpty() const { - return BitSet64::isEmpty(bits); - } - - float getAxisValue(int32_t axis) const; - status_t setAxisValue(int32_t axis, float value); - - void scale(float scale); - void applyOffset(float xOffset, float yOffset); - - inline float getX() const { - return getAxisValue(AMOTION_EVENT_AXIS_X); - } - - inline float getY() const { - return getAxisValue(AMOTION_EVENT_AXIS_Y); - } - -#ifdef HAVE_ANDROID_OS - status_t readFromParcel(Parcel* parcel); - status_t writeToParcel(Parcel* parcel) const; -#endif - - bool operator==(const PointerCoords& other) const; - inline bool operator!=(const PointerCoords& other) const { - return !(*this == other); - } - - void copyFrom(const PointerCoords& other); - -private: - void tooManyAxes(int axis); -}; - -/* - * Pointer property data. - */ -struct PointerProperties { - // The id of the pointer. - int32_t id; - - // The pointer tool type. - int32_t toolType; - - inline void clear() { - id = -1; - toolType = 0; - } - - bool operator==(const PointerProperties& other) const; - inline bool operator!=(const PointerProperties& other) const { - return !(*this == other); - } - - void copyFrom(const PointerProperties& other); -}; - -/* - * Input events. - */ -class InputEvent : public AInputEvent { -public: - virtual ~InputEvent() { } - - virtual int32_t getType() const = 0; - - inline int32_t getDeviceId() const { return mDeviceId; } - - inline int32_t getSource() const { return mSource; } - - inline void setSource(int32_t source) { mSource = source; } - -protected: - void initialize(int32_t deviceId, int32_t source); - void initialize(const InputEvent& from); - - int32_t mDeviceId; - int32_t mSource; -}; - -/* - * Key events. - */ -class KeyEvent : public InputEvent { -public: - virtual ~KeyEvent() { } - - virtual int32_t getType() const { return AINPUT_EVENT_TYPE_KEY; } - - inline int32_t getAction() const { return mAction; } - - inline int32_t getFlags() const { return mFlags; } - - inline void setFlags(int32_t flags) { mFlags = flags; } - - inline int32_t getKeyCode() const { return mKeyCode; } - - inline int32_t getScanCode() const { return mScanCode; } - - inline int32_t getMetaState() const { return mMetaState; } - - inline int32_t getRepeatCount() const { return mRepeatCount; } - - inline nsecs_t getDownTime() const { return mDownTime; } - - inline nsecs_t getEventTime() const { return mEventTime; } - - static const char* getLabel(int32_t keyCode); - static int32_t getKeyCodeFromLabel(const char* label); - - void initialize( - int32_t deviceId, - int32_t source, - int32_t action, - int32_t flags, - int32_t keyCode, - int32_t scanCode, - int32_t metaState, - int32_t repeatCount, - nsecs_t downTime, - nsecs_t eventTime); - void initialize(const KeyEvent& from); - -protected: - int32_t mAction; - int32_t mFlags; - int32_t mKeyCode; - int32_t mScanCode; - int32_t mMetaState; - int32_t mRepeatCount; - nsecs_t mDownTime; - nsecs_t mEventTime; -}; - -/* - * Motion events. - */ -class MotionEvent : public InputEvent { -public: - virtual ~MotionEvent() { } - - virtual int32_t getType() const { return AINPUT_EVENT_TYPE_MOTION; } - - inline int32_t getAction() const { return mAction; } - - inline int32_t getActionMasked() const { return mAction & AMOTION_EVENT_ACTION_MASK; } - - inline int32_t getActionIndex() const { - return (mAction & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) - >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; - } - - inline void setAction(int32_t action) { mAction = action; } - - inline int32_t getFlags() const { return mFlags; } - - inline void setFlags(int32_t flags) { mFlags = flags; } - - inline int32_t getEdgeFlags() const { return mEdgeFlags; } - - inline void setEdgeFlags(int32_t edgeFlags) { mEdgeFlags = edgeFlags; } - - inline int32_t getMetaState() const { return mMetaState; } - - inline void setMetaState(int32_t metaState) { mMetaState = metaState; } - - inline int32_t getButtonState() const { return mButtonState; } - - inline int32_t setButtonState(int32_t buttonState) { mButtonState = buttonState; } - - inline int32_t getActionButton() const { return mActionButton; } - - inline void setActionButton(int32_t button) { mActionButton = button; } - - inline float getXOffset() const { return mXOffset; } - - inline float getYOffset() const { return mYOffset; } - - inline float getXPrecision() const { return mXPrecision; } - - inline float getYPrecision() const { return mYPrecision; } - - inline nsecs_t getDownTime() const { return mDownTime; } - - inline void setDownTime(nsecs_t downTime) { mDownTime = downTime; } - - inline size_t getPointerCount() const { return mPointerProperties.size(); } - - inline const PointerProperties* getPointerProperties(size_t pointerIndex) const { - return &mPointerProperties[pointerIndex]; - } - - inline int32_t getPointerId(size_t pointerIndex) const { - return mPointerProperties[pointerIndex].id; - } - - inline int32_t getToolType(size_t pointerIndex) const { - return mPointerProperties[pointerIndex].toolType; - } - - inline nsecs_t getEventTime() const { return mSampleEventTimes[getHistorySize()]; } - - const PointerCoords* getRawPointerCoords(size_t pointerIndex) const; - - float getRawAxisValue(int32_t axis, size_t pointerIndex) const; - - inline float getRawX(size_t pointerIndex) const { - return getRawAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex); - } - - inline float getRawY(size_t pointerIndex) const { - return getRawAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex); - } - - float getAxisValue(int32_t axis, size_t pointerIndex) const; - - inline float getX(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex); - } - - inline float getY(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex); - } - - inline float getPressure(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerIndex); - } - - inline float getSize(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerIndex); - } - - inline float getTouchMajor(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex); - } - - inline float getTouchMinor(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex); - } - - inline float getToolMajor(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex); - } - - inline float getToolMinor(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex); - } - - inline float getOrientation(size_t pointerIndex) const { - return getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex); - } - - inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; } - - inline nsecs_t getHistoricalEventTime(size_t historicalIndex) const { - return mSampleEventTimes[historicalIndex]; - } - - const PointerCoords* getHistoricalRawPointerCoords( - size_t pointerIndex, size_t historicalIndex) const; - - float getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex, - size_t historicalIndex) const; - - inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalRawAxisValue( - AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex); - } - - inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalRawAxisValue( - AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex); - } - - float getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const; - - inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex); - } - - inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex); - } - - inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_PRESSURE, pointerIndex, historicalIndex); - } - - inline float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_SIZE, pointerIndex, historicalIndex); - } - - inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex); - } - - inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex); - } - - inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex); - } - - inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex, historicalIndex); - } - - inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const { - return getHistoricalAxisValue( - AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex, historicalIndex); - } - - ssize_t findPointerIndex(int32_t pointerId) const; - - void initialize( - int32_t deviceId, - int32_t source, - int32_t action, - int32_t actionButton, - int32_t flags, - int32_t edgeFlags, - int32_t metaState, - int32_t buttonState, - float xOffset, - float yOffset, - float xPrecision, - float yPrecision, - nsecs_t downTime, - nsecs_t eventTime, - size_t pointerCount, - const PointerProperties* pointerProperties, - const PointerCoords* pointerCoords); - - void copyFrom(const MotionEvent* other, bool keepHistory); - - void addSample( - nsecs_t eventTime, - const PointerCoords* pointerCoords); - - void offsetLocation(float xOffset, float yOffset); - - void scale(float scaleFactor); - - // Apply 3x3 perspective matrix transformation. - // Matrix is in row-major form and compatible with SkMatrix. - void transform(const float matrix[9]); - -#ifdef HAVE_ANDROID_OS - status_t readFromParcel(Parcel* parcel); - status_t writeToParcel(Parcel* parcel) const; -#endif - - static bool isTouchEvent(int32_t source, int32_t action); - inline bool isTouchEvent() const { - return isTouchEvent(mSource, mAction); - } - - // Low-level accessors. - inline const PointerProperties* getPointerProperties() const { - return mPointerProperties.array(); - } - inline const nsecs_t* getSampleEventTimes() const { return mSampleEventTimes.array(); } - inline const PointerCoords* getSamplePointerCoords() const { - return mSamplePointerCoords.array(); - } - - static const char* getLabel(int32_t axis); - static int32_t getAxisFromLabel(const char* label); - -protected: - int32_t mAction; - int32_t mActionButton; - int32_t mFlags; - int32_t mEdgeFlags; - int32_t mMetaState; - int32_t mButtonState; - float mXOffset; - float mYOffset; - float mXPrecision; - float mYPrecision; - nsecs_t mDownTime; - Vector mPointerProperties; - Vector mSampleEventTimes; - Vector mSamplePointerCoords; -}; - -/* - * Input event factory. - */ -class InputEventFactoryInterface { -protected: - virtual ~InputEventFactoryInterface() { } - -public: - InputEventFactoryInterface() { } - - virtual KeyEvent* createKeyEvent() = 0; - virtual MotionEvent* createMotionEvent() = 0; -}; - -/* - * A simple input event factory implementation that uses a single preallocated instance - * of each type of input event that are reused for each request. - */ -class PreallocatedInputEventFactory : public InputEventFactoryInterface { -public: - PreallocatedInputEventFactory() { } - virtual ~PreallocatedInputEventFactory() { } - - virtual KeyEvent* createKeyEvent() { return & mKeyEvent; } - virtual MotionEvent* createMotionEvent() { return & mMotionEvent; } - -private: - KeyEvent mKeyEvent; - MotionEvent mMotionEvent; -}; - -/* - * An input event factory implementation that maintains a pool of input events. - */ -class PooledInputEventFactory : public InputEventFactoryInterface { -public: - PooledInputEventFactory(size_t maxPoolSize = 20); - virtual ~PooledInputEventFactory(); - - virtual KeyEvent* createKeyEvent(); - virtual MotionEvent* createMotionEvent(); - - void recycle(InputEvent* event); - -private: - const size_t mMaxPoolSize; - - Vector mKeyEventPool; - Vector mMotionEventPool; -}; - -} // namespace android - -#endif // _LIBINPUT_INPUT_H diff --git a/phonelibs/android_frameworks_native/include/input/InputDevice.h b/phonelibs/android_frameworks_native/include/input/InputDevice.h deleted file mode 100644 index 1ea69d352d18d8..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/InputDevice.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_INPUT_DEVICE_H -#define _LIBINPUT_INPUT_DEVICE_H - -#include -#include - -namespace android { - -/* - * Identifies a device. - */ -struct InputDeviceIdentifier { - inline InputDeviceIdentifier() : - bus(0), vendor(0), product(0), version(0) { - } - - // Information provided by the kernel. - String8 name; - String8 location; - String8 uniqueId; - uint16_t bus; - uint16_t vendor; - uint16_t product; - uint16_t version; - - // A composite input device descriptor string that uniquely identifies the device - // even across reboots or reconnections. The value of this field is used by - // upper layers of the input system to associate settings with individual devices. - // It is hashed from whatever kernel provided information is available. - // Ideally, the way this value is computed should not change between Android releases - // because that would invalidate persistent settings that rely on it. - String8 descriptor; - - // A value added to uniquely identify a device in the absence of a unique id. This - // is intended to be a minimum way to distinguish from other active devices and may - // reuse values that are not associated with an input anymore. - uint16_t nonce; -}; - -/* - * Describes the characteristics and capabilities of an input device. - */ -class InputDeviceInfo { -public: - InputDeviceInfo(); - InputDeviceInfo(const InputDeviceInfo& other); - ~InputDeviceInfo(); - - struct MotionRange { - int32_t axis; - uint32_t source; - float min; - float max; - float flat; - float fuzz; - float resolution; - }; - - void initialize(int32_t id, int32_t generation, int32_t controllerNumber, - const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal, - bool hasMic); - - inline int32_t getId() const { return mId; } - inline int32_t getControllerNumber() const { return mControllerNumber; } - inline int32_t getGeneration() const { return mGeneration; } - inline const InputDeviceIdentifier& getIdentifier() const { return mIdentifier; } - inline const String8& getAlias() const { return mAlias; } - inline const String8& getDisplayName() const { - return mAlias.isEmpty() ? mIdentifier.name : mAlias; - } - inline bool isExternal() const { return mIsExternal; } - inline bool hasMic() const { return mHasMic; } - inline uint32_t getSources() const { return mSources; } - - const MotionRange* getMotionRange(int32_t axis, uint32_t source) const; - - void addSource(uint32_t source); - void addMotionRange(int32_t axis, uint32_t source, - float min, float max, float flat, float fuzz, float resolution); - void addMotionRange(const MotionRange& range); - - inline void setKeyboardType(int32_t keyboardType) { mKeyboardType = keyboardType; } - inline int32_t getKeyboardType() const { return mKeyboardType; } - - inline void setKeyCharacterMap(const sp& value) { - mKeyCharacterMap = value; - } - - inline sp getKeyCharacterMap() const { - return mKeyCharacterMap; - } - - inline void setVibrator(bool hasVibrator) { mHasVibrator = hasVibrator; } - inline bool hasVibrator() const { return mHasVibrator; } - - inline void setButtonUnderPad(bool hasButton) { mHasButtonUnderPad = hasButton; } - inline bool hasButtonUnderPad() const { return mHasButtonUnderPad; } - - inline const Vector& getMotionRanges() const { - return mMotionRanges; - } - -private: - int32_t mId; - int32_t mGeneration; - int32_t mControllerNumber; - InputDeviceIdentifier mIdentifier; - String8 mAlias; - bool mIsExternal; - bool mHasMic; - uint32_t mSources; - int32_t mKeyboardType; - sp mKeyCharacterMap; - bool mHasVibrator; - bool mHasButtonUnderPad; - - Vector mMotionRanges; -}; - -/* Types of input device configuration files. */ -enum InputDeviceConfigurationFileType { - INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION = 0, /* .idc file */ - INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_LAYOUT = 1, /* .kl file */ - INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_CHARACTER_MAP = 2, /* .kcm file */ -}; - -/* - * Gets the path of an input device configuration file, if one is available. - * Considers both system provided and user installed configuration files. - * - * The device identifier is used to construct several default configuration file - * names to try based on the device name, vendor, product, and version. - * - * Returns an empty string if not found. - */ -extern String8 getInputDeviceConfigurationFilePathByDeviceIdentifier( - const InputDeviceIdentifier& deviceIdentifier, - InputDeviceConfigurationFileType type); - -/* - * Gets the path of an input device configuration file, if one is available. - * Considers both system provided and user installed configuration files. - * - * The name is case-sensitive and is used to construct the filename to resolve. - * All characters except 'a'-'z', 'A'-'Z', '0'-'9', '-', and '_' are replaced by underscores. - * - * Returns an empty string if not found. - */ -extern String8 getInputDeviceConfigurationFilePathByName( - const String8& name, InputDeviceConfigurationFileType type); - -} // namespace android - -#endif // _LIBINPUT_INPUT_DEVICE_H diff --git a/phonelibs/android_frameworks_native/include/input/InputEventLabels.h b/phonelibs/android_frameworks_native/include/input/InputEventLabels.h deleted file mode 100644 index c03c0f2d584500..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/InputEventLabels.h +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_INPUT_EVENT_LABELS_H -#define _LIBINPUT_INPUT_EVENT_LABELS_H - -#include -#include - -#define DEFINE_KEYCODE(key) { #key, AKEYCODE_##key } -#define DEFINE_AXIS(axis) { #axis, AMOTION_EVENT_AXIS_##axis } -#define DEFINE_LED(led) { #led, ALED_##led } -#define DEFINE_FLAG(flag) { #flag, POLICY_FLAG_##flag } - -namespace android { - -template -size_t size(T (&)[N]) { return N; } - -struct InputEventLabel { - const char *literal; - int value; -}; - - -static const InputEventLabel KEYCODES[] = { - // NOTE: If you add a new keycode here you must also add it to several other files. - // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. - DEFINE_KEYCODE(UNKNOWN), - DEFINE_KEYCODE(SOFT_LEFT), - DEFINE_KEYCODE(SOFT_RIGHT), - DEFINE_KEYCODE(HOME), - DEFINE_KEYCODE(BACK), - DEFINE_KEYCODE(CALL), - DEFINE_KEYCODE(ENDCALL), - DEFINE_KEYCODE(0), - DEFINE_KEYCODE(1), - DEFINE_KEYCODE(2), - DEFINE_KEYCODE(3), - DEFINE_KEYCODE(4), - DEFINE_KEYCODE(5), - DEFINE_KEYCODE(6), - DEFINE_KEYCODE(7), - DEFINE_KEYCODE(8), - DEFINE_KEYCODE(9), - DEFINE_KEYCODE(STAR), - DEFINE_KEYCODE(POUND), - DEFINE_KEYCODE(DPAD_UP), - DEFINE_KEYCODE(DPAD_DOWN), - DEFINE_KEYCODE(DPAD_LEFT), - DEFINE_KEYCODE(DPAD_RIGHT), - DEFINE_KEYCODE(DPAD_CENTER), - DEFINE_KEYCODE(VOLUME_UP), - DEFINE_KEYCODE(VOLUME_DOWN), - DEFINE_KEYCODE(POWER), - DEFINE_KEYCODE(CAMERA), - DEFINE_KEYCODE(CLEAR), - DEFINE_KEYCODE(A), - DEFINE_KEYCODE(B), - DEFINE_KEYCODE(C), - DEFINE_KEYCODE(D), - DEFINE_KEYCODE(E), - DEFINE_KEYCODE(F), - DEFINE_KEYCODE(G), - DEFINE_KEYCODE(H), - DEFINE_KEYCODE(I), - DEFINE_KEYCODE(J), - DEFINE_KEYCODE(K), - DEFINE_KEYCODE(L), - DEFINE_KEYCODE(M), - DEFINE_KEYCODE(N), - DEFINE_KEYCODE(O), - DEFINE_KEYCODE(P), - DEFINE_KEYCODE(Q), - DEFINE_KEYCODE(R), - DEFINE_KEYCODE(S), - DEFINE_KEYCODE(T), - DEFINE_KEYCODE(U), - DEFINE_KEYCODE(V), - DEFINE_KEYCODE(W), - DEFINE_KEYCODE(X), - DEFINE_KEYCODE(Y), - DEFINE_KEYCODE(Z), - DEFINE_KEYCODE(COMMA), - DEFINE_KEYCODE(PERIOD), - DEFINE_KEYCODE(ALT_LEFT), - DEFINE_KEYCODE(ALT_RIGHT), - DEFINE_KEYCODE(SHIFT_LEFT), - DEFINE_KEYCODE(SHIFT_RIGHT), - DEFINE_KEYCODE(TAB), - DEFINE_KEYCODE(SPACE), - DEFINE_KEYCODE(SYM), - DEFINE_KEYCODE(EXPLORER), - DEFINE_KEYCODE(ENVELOPE), - DEFINE_KEYCODE(ENTER), - DEFINE_KEYCODE(DEL), - DEFINE_KEYCODE(GRAVE), - DEFINE_KEYCODE(MINUS), - DEFINE_KEYCODE(EQUALS), - DEFINE_KEYCODE(LEFT_BRACKET), - DEFINE_KEYCODE(RIGHT_BRACKET), - DEFINE_KEYCODE(BACKSLASH), - DEFINE_KEYCODE(SEMICOLON), - DEFINE_KEYCODE(APOSTROPHE), - DEFINE_KEYCODE(SLASH), - DEFINE_KEYCODE(AT), - DEFINE_KEYCODE(NUM), - DEFINE_KEYCODE(HEADSETHOOK), - DEFINE_KEYCODE(FOCUS), // *Camera* focus - DEFINE_KEYCODE(PLUS), - DEFINE_KEYCODE(MENU), - DEFINE_KEYCODE(NOTIFICATION), - DEFINE_KEYCODE(SEARCH), - DEFINE_KEYCODE(MEDIA_PLAY_PAUSE), - DEFINE_KEYCODE(MEDIA_STOP), - DEFINE_KEYCODE(MEDIA_NEXT), - DEFINE_KEYCODE(MEDIA_PREVIOUS), - DEFINE_KEYCODE(MEDIA_REWIND), - DEFINE_KEYCODE(MEDIA_FAST_FORWARD), - DEFINE_KEYCODE(MUTE), - DEFINE_KEYCODE(PAGE_UP), - DEFINE_KEYCODE(PAGE_DOWN), - DEFINE_KEYCODE(PICTSYMBOLS), - DEFINE_KEYCODE(SWITCH_CHARSET), - DEFINE_KEYCODE(BUTTON_A), - DEFINE_KEYCODE(BUTTON_B), - DEFINE_KEYCODE(BUTTON_C), - DEFINE_KEYCODE(BUTTON_X), - DEFINE_KEYCODE(BUTTON_Y), - DEFINE_KEYCODE(BUTTON_Z), - DEFINE_KEYCODE(BUTTON_L1), - DEFINE_KEYCODE(BUTTON_R1), - DEFINE_KEYCODE(BUTTON_L2), - DEFINE_KEYCODE(BUTTON_R2), - DEFINE_KEYCODE(BUTTON_THUMBL), - DEFINE_KEYCODE(BUTTON_THUMBR), - DEFINE_KEYCODE(BUTTON_START), - DEFINE_KEYCODE(BUTTON_SELECT), - DEFINE_KEYCODE(BUTTON_MODE), - DEFINE_KEYCODE(ESCAPE), - DEFINE_KEYCODE(FORWARD_DEL), - DEFINE_KEYCODE(CTRL_LEFT), - DEFINE_KEYCODE(CTRL_RIGHT), - DEFINE_KEYCODE(CAPS_LOCK), - DEFINE_KEYCODE(SCROLL_LOCK), - DEFINE_KEYCODE(META_LEFT), - DEFINE_KEYCODE(META_RIGHT), - DEFINE_KEYCODE(FUNCTION), - DEFINE_KEYCODE(SYSRQ), - DEFINE_KEYCODE(BREAK), - DEFINE_KEYCODE(MOVE_HOME), - DEFINE_KEYCODE(MOVE_END), - DEFINE_KEYCODE(INSERT), - DEFINE_KEYCODE(FORWARD), - DEFINE_KEYCODE(MEDIA_PLAY), - DEFINE_KEYCODE(MEDIA_PAUSE), - DEFINE_KEYCODE(MEDIA_CLOSE), - DEFINE_KEYCODE(MEDIA_EJECT), - DEFINE_KEYCODE(MEDIA_RECORD), - DEFINE_KEYCODE(F1), - DEFINE_KEYCODE(F2), - DEFINE_KEYCODE(F3), - DEFINE_KEYCODE(F4), - DEFINE_KEYCODE(F5), - DEFINE_KEYCODE(F6), - DEFINE_KEYCODE(F7), - DEFINE_KEYCODE(F8), - DEFINE_KEYCODE(F9), - DEFINE_KEYCODE(F10), - DEFINE_KEYCODE(F11), - DEFINE_KEYCODE(F12), - DEFINE_KEYCODE(NUM_LOCK), - DEFINE_KEYCODE(NUMPAD_0), - DEFINE_KEYCODE(NUMPAD_1), - DEFINE_KEYCODE(NUMPAD_2), - DEFINE_KEYCODE(NUMPAD_3), - DEFINE_KEYCODE(NUMPAD_4), - DEFINE_KEYCODE(NUMPAD_5), - DEFINE_KEYCODE(NUMPAD_6), - DEFINE_KEYCODE(NUMPAD_7), - DEFINE_KEYCODE(NUMPAD_8), - DEFINE_KEYCODE(NUMPAD_9), - DEFINE_KEYCODE(NUMPAD_DIVIDE), - DEFINE_KEYCODE(NUMPAD_MULTIPLY), - DEFINE_KEYCODE(NUMPAD_SUBTRACT), - DEFINE_KEYCODE(NUMPAD_ADD), - DEFINE_KEYCODE(NUMPAD_DOT), - DEFINE_KEYCODE(NUMPAD_COMMA), - DEFINE_KEYCODE(NUMPAD_ENTER), - DEFINE_KEYCODE(NUMPAD_EQUALS), - DEFINE_KEYCODE(NUMPAD_LEFT_PAREN), - DEFINE_KEYCODE(NUMPAD_RIGHT_PAREN), - DEFINE_KEYCODE(VOLUME_MUTE), - DEFINE_KEYCODE(INFO), - DEFINE_KEYCODE(CHANNEL_UP), - DEFINE_KEYCODE(CHANNEL_DOWN), - DEFINE_KEYCODE(ZOOM_IN), - DEFINE_KEYCODE(ZOOM_OUT), - DEFINE_KEYCODE(TV), - DEFINE_KEYCODE(WINDOW), - DEFINE_KEYCODE(GUIDE), - DEFINE_KEYCODE(DVR), - DEFINE_KEYCODE(BOOKMARK), - DEFINE_KEYCODE(CAPTIONS), - DEFINE_KEYCODE(SETTINGS), - DEFINE_KEYCODE(TV_POWER), - DEFINE_KEYCODE(TV_INPUT), - DEFINE_KEYCODE(STB_POWER), - DEFINE_KEYCODE(STB_INPUT), - DEFINE_KEYCODE(AVR_POWER), - DEFINE_KEYCODE(AVR_INPUT), - DEFINE_KEYCODE(PROG_RED), - DEFINE_KEYCODE(PROG_GREEN), - DEFINE_KEYCODE(PROG_YELLOW), - DEFINE_KEYCODE(PROG_BLUE), - DEFINE_KEYCODE(APP_SWITCH), - DEFINE_KEYCODE(BUTTON_1), - DEFINE_KEYCODE(BUTTON_2), - DEFINE_KEYCODE(BUTTON_3), - DEFINE_KEYCODE(BUTTON_4), - DEFINE_KEYCODE(BUTTON_5), - DEFINE_KEYCODE(BUTTON_6), - DEFINE_KEYCODE(BUTTON_7), - DEFINE_KEYCODE(BUTTON_8), - DEFINE_KEYCODE(BUTTON_9), - DEFINE_KEYCODE(BUTTON_10), - DEFINE_KEYCODE(BUTTON_11), - DEFINE_KEYCODE(BUTTON_12), - DEFINE_KEYCODE(BUTTON_13), - DEFINE_KEYCODE(BUTTON_14), - DEFINE_KEYCODE(BUTTON_15), - DEFINE_KEYCODE(BUTTON_16), - DEFINE_KEYCODE(LANGUAGE_SWITCH), - DEFINE_KEYCODE(MANNER_MODE), - DEFINE_KEYCODE(3D_MODE), - DEFINE_KEYCODE(CONTACTS), - DEFINE_KEYCODE(CALENDAR), - DEFINE_KEYCODE(MUSIC), - DEFINE_KEYCODE(CALCULATOR), - DEFINE_KEYCODE(ZENKAKU_HANKAKU), - DEFINE_KEYCODE(EISU), - DEFINE_KEYCODE(MUHENKAN), - DEFINE_KEYCODE(HENKAN), - DEFINE_KEYCODE(KATAKANA_HIRAGANA), - DEFINE_KEYCODE(YEN), - DEFINE_KEYCODE(RO), - DEFINE_KEYCODE(KANA), - DEFINE_KEYCODE(ASSIST), - DEFINE_KEYCODE(BRIGHTNESS_DOWN), - DEFINE_KEYCODE(BRIGHTNESS_UP), - DEFINE_KEYCODE(MEDIA_AUDIO_TRACK), - DEFINE_KEYCODE(SLEEP), - DEFINE_KEYCODE(WAKEUP), - DEFINE_KEYCODE(PAIRING), - DEFINE_KEYCODE(MEDIA_TOP_MENU), - DEFINE_KEYCODE(11), - DEFINE_KEYCODE(12), - DEFINE_KEYCODE(LAST_CHANNEL), - DEFINE_KEYCODE(TV_DATA_SERVICE), - DEFINE_KEYCODE(VOICE_ASSIST), - DEFINE_KEYCODE(TV_RADIO_SERVICE), - DEFINE_KEYCODE(TV_TELETEXT), - DEFINE_KEYCODE(TV_NUMBER_ENTRY), - DEFINE_KEYCODE(TV_TERRESTRIAL_ANALOG), - DEFINE_KEYCODE(TV_TERRESTRIAL_DIGITAL), - DEFINE_KEYCODE(TV_SATELLITE), - DEFINE_KEYCODE(TV_SATELLITE_BS), - DEFINE_KEYCODE(TV_SATELLITE_CS), - DEFINE_KEYCODE(TV_SATELLITE_SERVICE), - DEFINE_KEYCODE(TV_NETWORK), - DEFINE_KEYCODE(TV_ANTENNA_CABLE), - DEFINE_KEYCODE(TV_INPUT_HDMI_1), - DEFINE_KEYCODE(TV_INPUT_HDMI_2), - DEFINE_KEYCODE(TV_INPUT_HDMI_3), - DEFINE_KEYCODE(TV_INPUT_HDMI_4), - DEFINE_KEYCODE(TV_INPUT_COMPOSITE_1), - DEFINE_KEYCODE(TV_INPUT_COMPOSITE_2), - DEFINE_KEYCODE(TV_INPUT_COMPONENT_1), - DEFINE_KEYCODE(TV_INPUT_COMPONENT_2), - DEFINE_KEYCODE(TV_INPUT_VGA_1), - DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION), - DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION_MIX_UP), - DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION_MIX_DOWN), - DEFINE_KEYCODE(TV_ZOOM_MODE), - DEFINE_KEYCODE(TV_CONTENTS_MENU), - DEFINE_KEYCODE(TV_MEDIA_CONTEXT_MENU), - DEFINE_KEYCODE(TV_TIMER_PROGRAMMING), - DEFINE_KEYCODE(HELP), - DEFINE_KEYCODE(NAVIGATE_PREVIOUS), - DEFINE_KEYCODE(NAVIGATE_NEXT), - DEFINE_KEYCODE(NAVIGATE_IN), - DEFINE_KEYCODE(NAVIGATE_OUT), - DEFINE_KEYCODE(STEM_PRIMARY), - DEFINE_KEYCODE(STEM_1), - DEFINE_KEYCODE(STEM_2), - DEFINE_KEYCODE(STEM_3), - DEFINE_KEYCODE(MEDIA_SKIP_FORWARD), - DEFINE_KEYCODE(MEDIA_SKIP_BACKWARD), - DEFINE_KEYCODE(MEDIA_STEP_FORWARD), - DEFINE_KEYCODE(MEDIA_STEP_BACKWARD), - DEFINE_KEYCODE(SOFT_SLEEP), - - { NULL, 0 } -}; - -static const InputEventLabel AXES[] = { - DEFINE_AXIS(X), - DEFINE_AXIS(Y), - DEFINE_AXIS(PRESSURE), - DEFINE_AXIS(SIZE), - DEFINE_AXIS(TOUCH_MAJOR), - DEFINE_AXIS(TOUCH_MINOR), - DEFINE_AXIS(TOOL_MAJOR), - DEFINE_AXIS(TOOL_MINOR), - DEFINE_AXIS(ORIENTATION), - DEFINE_AXIS(VSCROLL), - DEFINE_AXIS(HSCROLL), - DEFINE_AXIS(Z), - DEFINE_AXIS(RX), - DEFINE_AXIS(RY), - DEFINE_AXIS(RZ), - DEFINE_AXIS(HAT_X), - DEFINE_AXIS(HAT_Y), - DEFINE_AXIS(LTRIGGER), - DEFINE_AXIS(RTRIGGER), - DEFINE_AXIS(THROTTLE), - DEFINE_AXIS(RUDDER), - DEFINE_AXIS(WHEEL), - DEFINE_AXIS(GAS), - DEFINE_AXIS(BRAKE), - DEFINE_AXIS(DISTANCE), - DEFINE_AXIS(TILT), - DEFINE_AXIS(GENERIC_1), - DEFINE_AXIS(GENERIC_2), - DEFINE_AXIS(GENERIC_3), - DEFINE_AXIS(GENERIC_4), - DEFINE_AXIS(GENERIC_5), - DEFINE_AXIS(GENERIC_6), - DEFINE_AXIS(GENERIC_7), - DEFINE_AXIS(GENERIC_8), - DEFINE_AXIS(GENERIC_9), - DEFINE_AXIS(GENERIC_10), - DEFINE_AXIS(GENERIC_11), - DEFINE_AXIS(GENERIC_12), - DEFINE_AXIS(GENERIC_13), - DEFINE_AXIS(GENERIC_14), - DEFINE_AXIS(GENERIC_15), - DEFINE_AXIS(GENERIC_16), - - // NOTE: If you add a new axis here you must also add it to several other files. - // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. - { NULL, 0 } -}; - -static const InputEventLabel LEDS[] = { - DEFINE_LED(NUM_LOCK), - DEFINE_LED(CAPS_LOCK), - DEFINE_LED(SCROLL_LOCK), - DEFINE_LED(COMPOSE), - DEFINE_LED(KANA), - DEFINE_LED(SLEEP), - DEFINE_LED(SUSPEND), - DEFINE_LED(MUTE), - DEFINE_LED(MISC), - DEFINE_LED(MAIL), - DEFINE_LED(CHARGING), - DEFINE_LED(CONTROLLER_1), - DEFINE_LED(CONTROLLER_2), - DEFINE_LED(CONTROLLER_3), - DEFINE_LED(CONTROLLER_4), - - // NOTE: If you add new LEDs here, you must also add them to Input.h - { NULL, 0 } -}; - -static const InputEventLabel FLAGS[] = { - DEFINE_FLAG(WAKE), - DEFINE_FLAG(VIRTUAL), - DEFINE_FLAG(FUNCTION), - DEFINE_FLAG(GESTURE), - - { NULL, 0 } -}; - -static int lookupValueByLabel(const char* literal, const InputEventLabel *list) { - while (list->literal) { - if (strcmp(literal, list->literal) == 0) { - return list->value; - } - list++; - } - return list->value; -} - -static const char* lookupLabelByValue(int value, const InputEventLabel* list) { - while (list->literal) { - if (list->value == value) { - return list->literal; - } - list++; - } - return NULL; -} - -static int32_t getKeyCodeByLabel(const char* label) { - return int32_t(lookupValueByLabel(label, KEYCODES)); -} - -static const char* getLabelByKeyCode(int32_t keyCode) { - if (keyCode >= 0 && keyCode < size(KEYCODES)) { - return KEYCODES[keyCode].literal; - } - return NULL; -} - -static uint32_t getKeyFlagByLabel(const char* label) { - return uint32_t(lookupValueByLabel(label, FLAGS)); -} - -static int32_t getAxisByLabel(const char* label) { - return int32_t(lookupValueByLabel(label, AXES)); -} - -static const char* getAxisLabel(int32_t axisId) { - return lookupLabelByValue(axisId, AXES); -} - -static int32_t getLedByLabel(const char* label) { - return int32_t(lookupValueByLabel(label, LEDS)); -} - - -} // namespace android -#endif // _LIBINPUT_INPUT_EVENT_LABELS_H diff --git a/phonelibs/android_frameworks_native/include/input/InputTransport.h b/phonelibs/android_frameworks_native/include/input/InputTransport.h deleted file mode 100644 index f31bceabd75c3a..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/InputTransport.h +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_INPUT_TRANSPORT_H -#define _LIBINPUT_INPUT_TRANSPORT_H - -/** - * Native input transport. - * - * The InputChannel provides a mechanism for exchanging InputMessage structures across processes. - * - * The InputPublisher and InputConsumer each handle one end-point of an input channel. - * The InputPublisher is used by the input dispatcher to send events to the application. - * The InputConsumer is used by the application to receive events from the input dispatcher. - */ - -#include -#include -#include -#include -#include -#include -#include - -namespace android { - -/* - * Intermediate representation used to send input events and related signals. - * - * Note that this structure is used for IPCs so its layout must be identical - * on 64 and 32 bit processes. This is tested in StructLayout_test.cpp. - */ -struct InputMessage { - enum { - TYPE_KEY = 1, - TYPE_MOTION = 2, - TYPE_FINISHED = 3, - }; - - struct Header { - uint32_t type; - // We don't need this field in order to align the body below but we - // leave it here because InputMessage::size() and other functions - // compute the size of this structure as sizeof(Header) + sizeof(Body). - uint32_t padding; - } header; - - // Body *must* be 8 byte aligned. - union Body { - struct Key { - uint32_t seq; - nsecs_t eventTime __attribute__((aligned(8))); - int32_t deviceId; - int32_t source; - int32_t action; - int32_t flags; - int32_t keyCode; - int32_t scanCode; - int32_t metaState; - int32_t repeatCount; - nsecs_t downTime __attribute__((aligned(8))); - - inline size_t size() const { - return sizeof(Key); - } - } key; - - struct Motion { - uint32_t seq; - nsecs_t eventTime __attribute__((aligned(8))); - int32_t deviceId; - int32_t source; - int32_t action; - int32_t actionButton; - int32_t flags; - int32_t metaState; - int32_t buttonState; - int32_t edgeFlags; - nsecs_t downTime __attribute__((aligned(8))); - float xOffset; - float yOffset; - float xPrecision; - float yPrecision; - uint32_t pointerCount; - // Note that PointerCoords requires 8 byte alignment. - struct Pointer { - PointerProperties properties; - PointerCoords coords; - } pointers[MAX_POINTERS]; - - int32_t getActionId() const { - uint32_t index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) - >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; - return pointers[index].properties.id; - } - - inline size_t size() const { - return sizeof(Motion) - sizeof(Pointer) * MAX_POINTERS - + sizeof(Pointer) * pointerCount; - } - } motion; - - struct Finished { - uint32_t seq; - bool handled; - - inline size_t size() const { - return sizeof(Finished); - } - } finished; - } __attribute__((aligned(8))) body; - - bool isValid(size_t actualSize) const; - size_t size() const; -}; - -/* - * An input channel consists of a local unix domain socket used to send and receive - * input messages across processes. Each channel has a descriptive name for debugging purposes. - * - * Each endpoint has its own InputChannel object that specifies its file descriptor. - * - * The input channel is closed when all references to it are released. - */ -class InputChannel : public RefBase { -protected: - virtual ~InputChannel(); - -public: - InputChannel(const String8& name, int fd); - - /* Creates a pair of input channels. - * - * Returns OK on success. - */ - static status_t openInputChannelPair(const String8& name, - sp& outServerChannel, sp& outClientChannel); - - inline String8 getName() const { return mName; } - inline int getFd() const { return mFd; } - - /* Sends a message to the other endpoint. - * - * If the channel is full then the message is guaranteed not to have been sent at all. - * Try again after the consumer has sent a finished signal indicating that it has - * consumed some of the pending messages from the channel. - * - * Returns OK on success. - * Returns WOULD_BLOCK if the channel is full. - * Returns DEAD_OBJECT if the channel's peer has been closed. - * Other errors probably indicate that the channel is broken. - */ - status_t sendMessage(const InputMessage* msg); - - /* Receives a message sent by the other endpoint. - * - * If there is no message present, try again after poll() indicates that the fd - * is readable. - * - * Returns OK on success. - * Returns WOULD_BLOCK if there is no message present. - * Returns DEAD_OBJECT if the channel's peer has been closed. - * Other errors probably indicate that the channel is broken. - */ - status_t receiveMessage(InputMessage* msg); - - /* Returns a new object that has a duplicate of this channel's fd. */ - sp dup() const; - -private: - String8 mName; - int mFd; -}; - -/* - * Publishes input events to an input channel. - */ -class InputPublisher { -public: - /* Creates a publisher associated with an input channel. */ - explicit InputPublisher(const sp& channel); - - /* Destroys the publisher and releases its input channel. */ - ~InputPublisher(); - - /* Gets the underlying input channel. */ - inline sp getChannel() { return mChannel; } - - /* Publishes a key event to the input channel. - * - * Returns OK on success. - * Returns WOULD_BLOCK if the channel is full. - * Returns DEAD_OBJECT if the channel's peer has been closed. - * Returns BAD_VALUE if seq is 0. - * Other errors probably indicate that the channel is broken. - */ - status_t publishKeyEvent( - uint32_t seq, - int32_t deviceId, - int32_t source, - int32_t action, - int32_t flags, - int32_t keyCode, - int32_t scanCode, - int32_t metaState, - int32_t repeatCount, - nsecs_t downTime, - nsecs_t eventTime); - - /* Publishes a motion event to the input channel. - * - * Returns OK on success. - * Returns WOULD_BLOCK if the channel is full. - * Returns DEAD_OBJECT if the channel's peer has been closed. - * Returns BAD_VALUE if seq is 0 or if pointerCount is less than 1 or greater than MAX_POINTERS. - * Other errors probably indicate that the channel is broken. - */ - status_t publishMotionEvent( - uint32_t seq, - int32_t deviceId, - int32_t source, - int32_t action, - int32_t actionButton, - int32_t flags, - int32_t edgeFlags, - int32_t metaState, - int32_t buttonState, - float xOffset, - float yOffset, - float xPrecision, - float yPrecision, - nsecs_t downTime, - nsecs_t eventTime, - uint32_t pointerCount, - const PointerProperties* pointerProperties, - const PointerCoords* pointerCoords); - - /* Receives the finished signal from the consumer in reply to the original dispatch signal. - * If a signal was received, returns the message sequence number, - * and whether the consumer handled the message. - * - * The returned sequence number is never 0 unless the operation failed. - * - * Returns OK on success. - * Returns WOULD_BLOCK if there is no signal present. - * Returns DEAD_OBJECT if the channel's peer has been closed. - * Other errors probably indicate that the channel is broken. - */ - status_t receiveFinishedSignal(uint32_t* outSeq, bool* outHandled); - -private: - sp mChannel; -}; - -/* - * Consumes input events from an input channel. - */ -class InputConsumer { -public: - /* Creates a consumer associated with an input channel. */ - explicit InputConsumer(const sp& channel); - - /* Destroys the consumer and releases its input channel. */ - ~InputConsumer(); - - /* Gets the underlying input channel. */ - inline sp getChannel() { return mChannel; } - - /* Consumes an input event from the input channel and copies its contents into - * an InputEvent object created using the specified factory. - * - * Tries to combine a series of move events into larger batches whenever possible. - * - * If consumeBatches is false, then defers consuming pending batched events if it - * is possible for additional samples to be added to them later. Call hasPendingBatch() - * to determine whether a pending batch is available to be consumed. - * - * If consumeBatches is true, then events are still batched but they are consumed - * immediately as soon as the input channel is exhausted. - * - * The frameTime parameter specifies the time when the current display frame started - * rendering in the CLOCK_MONOTONIC time base, or -1 if unknown. - * - * The returned sequence number is never 0 unless the operation failed. - * - * Returns OK on success. - * Returns WOULD_BLOCK if there is no event present. - * Returns DEAD_OBJECT if the channel's peer has been closed. - * Returns NO_MEMORY if the event could not be created. - * Other errors probably indicate that the channel is broken. - */ - status_t consume(InputEventFactoryInterface* factory, bool consumeBatches, - nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent); - - /* Sends a finished signal to the publisher to inform it that the message - * with the specified sequence number has finished being process and whether - * the message was handled by the consumer. - * - * Returns OK on success. - * Returns BAD_VALUE if seq is 0. - * Other errors probably indicate that the channel is broken. - */ - status_t sendFinishedSignal(uint32_t seq, bool handled); - - /* Returns true if there is a deferred event waiting. - * - * Should be called after calling consume() to determine whether the consumer - * has a deferred event to be processed. Deferred events are somewhat special in - * that they have already been removed from the input channel. If the input channel - * becomes empty, the client may need to do extra work to ensure that it processes - * the deferred event despite the fact that the input channel's file descriptor - * is not readable. - * - * One option is simply to call consume() in a loop until it returns WOULD_BLOCK. - * This guarantees that all deferred events will be processed. - * - * Alternately, the caller can call hasDeferredEvent() to determine whether there is - * a deferred event waiting and then ensure that its event loop wakes up at least - * one more time to consume the deferred event. - */ - bool hasDeferredEvent() const; - - /* Returns true if there is a pending batch. - * - * Should be called after calling consume() with consumeBatches == false to determine - * whether consume() should be called again later on with consumeBatches == true. - */ - bool hasPendingBatch() const; - -private: - // True if touch resampling is enabled. - const bool mResampleTouch; - - // The input channel. - sp mChannel; - - // The current input message. - InputMessage mMsg; - - // True if mMsg contains a valid input message that was deferred from the previous - // call to consume and that still needs to be handled. - bool mMsgDeferred; - - // Batched motion events per device and source. - struct Batch { - Vector samples; - }; - Vector mBatches; - - // Touch state per device and source, only for sources of class pointer. - struct History { - nsecs_t eventTime; - BitSet32 idBits; - int32_t idToIndex[MAX_POINTER_ID + 1]; - PointerCoords pointers[MAX_POINTERS]; - - void initializeFrom(const InputMessage* msg) { - eventTime = msg->body.motion.eventTime; - idBits.clear(); - for (uint32_t i = 0; i < msg->body.motion.pointerCount; i++) { - uint32_t id = msg->body.motion.pointers[i].properties.id; - idBits.markBit(id); - idToIndex[id] = i; - pointers[i].copyFrom(msg->body.motion.pointers[i].coords); - } - } - - const PointerCoords& getPointerById(uint32_t id) const { - return pointers[idToIndex[id]]; - } - }; - struct TouchState { - int32_t deviceId; - int32_t source; - size_t historyCurrent; - size_t historySize; - History history[2]; - History lastResample; - - void initialize(int32_t deviceId, int32_t source) { - this->deviceId = deviceId; - this->source = source; - historyCurrent = 0; - historySize = 0; - lastResample.eventTime = 0; - lastResample.idBits.clear(); - } - - void addHistory(const InputMessage* msg) { - historyCurrent ^= 1; - if (historySize < 2) { - historySize += 1; - } - history[historyCurrent].initializeFrom(msg); - } - - const History* getHistory(size_t index) const { - return &history[(historyCurrent + index) & 1]; - } - }; - Vector mTouchStates; - - // Chain of batched sequence numbers. When multiple input messages are combined into - // a batch, we append a record here that associates the last sequence number in the - // batch with the previous one. When the finished signal is sent, we traverse the - // chain to individually finish all input messages that were part of the batch. - struct SeqChain { - uint32_t seq; // sequence number of batched input message - uint32_t chain; // sequence number of previous batched input message - }; - Vector mSeqChains; - - status_t consumeBatch(InputEventFactoryInterface* factory, - nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent); - status_t consumeSamples(InputEventFactoryInterface* factory, - Batch& batch, size_t count, uint32_t* outSeq, InputEvent** outEvent); - - void updateTouchState(InputMessage* msg); - void rewriteMessage(const TouchState& state, InputMessage* msg); - void resampleTouchState(nsecs_t frameTime, MotionEvent* event, - const InputMessage *next); - - ssize_t findBatch(int32_t deviceId, int32_t source) const; - ssize_t findTouchState(int32_t deviceId, int32_t source) const; - - status_t sendUnchainedFinishedSignal(uint32_t seq, bool handled); - - static void initializeKeyEvent(KeyEvent* event, const InputMessage* msg); - static void initializeMotionEvent(MotionEvent* event, const InputMessage* msg); - static void addSample(MotionEvent* event, const InputMessage* msg); - static bool canAddSample(const Batch& batch, const InputMessage* msg); - static ssize_t findSampleNoLaterThan(const Batch& batch, nsecs_t time); - static bool shouldResampleTool(int32_t toolType); - - static bool isTouchResamplingEnabled(); -}; - -} // namespace android - -#endif // _LIBINPUT_INPUT_TRANSPORT_H diff --git a/phonelibs/android_frameworks_native/include/input/KeyCharacterMap.h b/phonelibs/android_frameworks_native/include/input/KeyCharacterMap.h deleted file mode 100644 index 3f0914b67e5d9c..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/KeyCharacterMap.h +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_KEY_CHARACTER_MAP_H -#define _LIBINPUT_KEY_CHARACTER_MAP_H - -#include - -#if HAVE_ANDROID_OS -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -namespace android { - -/** - * Describes a mapping from Android key codes to characters. - * Also specifies other functions of the keyboard such as the keyboard type - * and key modifier semantics. - * - * This object is immutable after it has been loaded. - */ -class KeyCharacterMap : public RefBase { -public: - enum KeyboardType { - KEYBOARD_TYPE_UNKNOWN = 0, - KEYBOARD_TYPE_NUMERIC = 1, - KEYBOARD_TYPE_PREDICTIVE = 2, - KEYBOARD_TYPE_ALPHA = 3, - KEYBOARD_TYPE_FULL = 4, - KEYBOARD_TYPE_SPECIAL_FUNCTION = 5, - KEYBOARD_TYPE_OVERLAY = 6, - }; - - enum Format { - // Base keyboard layout, may contain device-specific options, such as "type" declaration. - FORMAT_BASE = 0, - // Overlay keyboard layout, more restrictive, may be published by applications, - // cannot override device-specific options. - FORMAT_OVERLAY = 1, - // Either base or overlay layout ok. - FORMAT_ANY = 2, - }; - - // Substitute key code and meta state for fallback action. - struct FallbackAction { - int32_t keyCode; - int32_t metaState; - }; - - /* Loads a key character map from a file. */ - static status_t load(const String8& filename, Format format, sp* outMap); - - /* Loads a key character map from its string contents. */ - static status_t loadContents(const String8& filename, - const char* contents, Format format, sp* outMap); - - /* Combines a base key character map and an overlay. */ - static sp combine(const sp& base, - const sp& overlay); - - /* Returns an empty key character map. */ - static sp empty(); - - /* Gets the keyboard type. */ - int32_t getKeyboardType() const; - - /* Gets the primary character for this key as in the label physically printed on it. - * Returns 0 if none (eg. for non-printing keys). */ - char16_t getDisplayLabel(int32_t keyCode) const; - - /* Gets the Unicode character for the number or symbol generated by the key - * when the keyboard is used as a dialing pad. - * Returns 0 if no number or symbol is generated. - */ - char16_t getNumber(int32_t keyCode) const; - - /* Gets the Unicode character generated by the key and meta key modifiers. - * Returns 0 if no character is generated. - */ - char16_t getCharacter(int32_t keyCode, int32_t metaState) const; - - /* Gets the fallback action to use by default if the application does not - * handle the specified key. - * Returns true if an action was available, false if none. - */ - bool getFallbackAction(int32_t keyCode, int32_t metaState, - FallbackAction* outFallbackAction) const; - - /* Gets the first matching Unicode character that can be generated by the key, - * preferring the one with the specified meta key modifiers. - * Returns 0 if no matching character is generated. - */ - char16_t getMatch(int32_t keyCode, const char16_t* chars, - size_t numChars, int32_t metaState) const; - - /* Gets a sequence of key events that could plausibly generate the specified - * character sequence. Returns false if some of the characters cannot be generated. - */ - bool getEvents(int32_t deviceId, const char16_t* chars, size_t numChars, - Vector& outEvents) const; - - /* Maps a scan code and usage code to a key code, in case this key map overrides - * the mapping in some way. */ - status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t* outKeyCode) const; - - /* Tries to find a replacement key code for a given key code and meta state - * in character map. */ - void tryRemapKey(int32_t scanCode, int32_t metaState, - int32_t* outKeyCode, int32_t* outMetaState) const; - -#if HAVE_ANDROID_OS - /* Reads a key map from a parcel. */ - static sp readFromParcel(Parcel* parcel); - - /* Writes a key map to a parcel. */ - void writeToParcel(Parcel* parcel) const; -#endif - -protected: - virtual ~KeyCharacterMap(); - -private: - struct Behavior { - Behavior(); - Behavior(const Behavior& other); - - /* The next behavior in the list, or NULL if none. */ - Behavior* next; - - /* The meta key modifiers for this behavior. */ - int32_t metaState; - - /* The character to insert. */ - char16_t character; - - /* The fallback keycode if the key is not handled. */ - int32_t fallbackKeyCode; - - /* The replacement keycode if the key has to be replaced outright. */ - int32_t replacementKeyCode; - }; - - struct Key { - Key(); - Key(const Key& other); - ~Key(); - - /* The single character label printed on the key, or 0 if none. */ - char16_t label; - - /* The number or symbol character generated by the key, or 0 if none. */ - char16_t number; - - /* The list of key behaviors sorted from most specific to least specific - * meta key binding. */ - Behavior* firstBehavior; - }; - - class Parser { - enum State { - STATE_TOP = 0, - STATE_KEY = 1, - }; - - enum { - PROPERTY_LABEL = 1, - PROPERTY_NUMBER = 2, - PROPERTY_META = 3, - }; - - struct Property { - inline Property(int32_t property = 0, int32_t metaState = 0) : - property(property), metaState(metaState) { } - - int32_t property; - int32_t metaState; - }; - - KeyCharacterMap* mMap; - Tokenizer* mTokenizer; - Format mFormat; - State mState; - int32_t mKeyCode; - - public: - Parser(KeyCharacterMap* map, Tokenizer* tokenizer, Format format); - ~Parser(); - status_t parse(); - - private: - status_t parseType(); - status_t parseMap(); - status_t parseMapKey(); - status_t parseKey(); - status_t parseKeyProperty(); - status_t finishKey(Key* key); - status_t parseModifier(const String8& token, int32_t* outMetaState); - status_t parseCharacterLiteral(char16_t* outCharacter); - }; - - static sp sEmpty; - - KeyedVector mKeys; - int mType; - - KeyedVector mKeysByScanCode; - KeyedVector mKeysByUsageCode; - - KeyCharacterMap(); - KeyCharacterMap(const KeyCharacterMap& other); - - bool getKey(int32_t keyCode, const Key** outKey) const; - bool getKeyBehavior(int32_t keyCode, int32_t metaState, - const Key** outKey, const Behavior** outBehavior) const; - static bool matchesMetaState(int32_t eventMetaState, int32_t behaviorMetaState); - - bool findKey(char16_t ch, int32_t* outKeyCode, int32_t* outMetaState) const; - - static status_t load(Tokenizer* tokenizer, Format format, sp* outMap); - - static void addKey(Vector& outEvents, - int32_t deviceId, int32_t keyCode, int32_t metaState, bool down, nsecs_t time); - static void addMetaKeys(Vector& outEvents, - int32_t deviceId, int32_t metaState, bool down, nsecs_t time, - int32_t* currentMetaState); - static bool addSingleEphemeralMetaKey(Vector& outEvents, - int32_t deviceId, int32_t metaState, bool down, nsecs_t time, - int32_t keyCode, int32_t keyMetaState, - int32_t* currentMetaState); - static void addDoubleEphemeralMetaKey(Vector& outEvents, - int32_t deviceId, int32_t metaState, bool down, nsecs_t time, - int32_t leftKeyCode, int32_t leftKeyMetaState, - int32_t rightKeyCode, int32_t rightKeyMetaState, - int32_t eitherKeyMetaState, - int32_t* currentMetaState); - static void addLockedMetaKey(Vector& outEvents, - int32_t deviceId, int32_t metaState, nsecs_t time, - int32_t keyCode, int32_t keyMetaState, - int32_t* currentMetaState); -}; - -} // namespace android - -#endif // _LIBINPUT_KEY_CHARACTER_MAP_H diff --git a/phonelibs/android_frameworks_native/include/input/KeyLayoutMap.h b/phonelibs/android_frameworks_native/include/input/KeyLayoutMap.h deleted file mode 100644 index 1e8de7173bdb5f..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/KeyLayoutMap.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_KEY_LAYOUT_MAP_H -#define _LIBINPUT_KEY_LAYOUT_MAP_H - -#include -#include -#include -#include -#include - -namespace android { - -struct AxisInfo { - enum Mode { - // Axis value is reported directly. - MODE_NORMAL = 0, - // Axis value should be inverted before reporting. - MODE_INVERT = 1, - // Axis value should be split into two axes - MODE_SPLIT = 2, - }; - - // Axis mode. - Mode mode; - - // Axis id. - // When split, this is the axis used for values smaller than the split position. - int32_t axis; - - // When split, this is the axis used for values after higher than the split position. - int32_t highAxis; - - // The split value, or 0 if not split. - int32_t splitValue; - - // The flat value, or -1 if none. - int32_t flatOverride; - - AxisInfo() : mode(MODE_NORMAL), axis(-1), highAxis(-1), splitValue(0), flatOverride(-1) { - } -}; - -/** - * Describes a mapping from keyboard scan codes and joystick axes to Android key codes and axes. - * - * This object is immutable after it has been loaded. - */ -class KeyLayoutMap : public RefBase { -public: - static status_t load(const String8& filename, sp* outMap); - - status_t mapKey(int32_t scanCode, int32_t usageCode, - int32_t* outKeyCode, uint32_t* outFlags) const; - status_t findScanCodesForKey(int32_t keyCode, Vector* outScanCodes) const; - status_t findScanCodeForLed(int32_t ledCode, int32_t* outScanCode) const; - status_t findUsageCodeForLed(int32_t ledCode, int32_t* outUsageCode) const; - - status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const; - -protected: - virtual ~KeyLayoutMap(); - -private: - struct Key { - int32_t keyCode; - uint32_t flags; - }; - - struct Led { - int32_t ledCode; - }; - - - KeyedVector mKeysByScanCode; - KeyedVector mKeysByUsageCode; - KeyedVector mAxes; - KeyedVector mLedsByScanCode; - KeyedVector mLedsByUsageCode; - - KeyLayoutMap(); - - const Key* getKey(int32_t scanCode, int32_t usageCode) const; - - class Parser { - KeyLayoutMap* mMap; - Tokenizer* mTokenizer; - - public: - Parser(KeyLayoutMap* map, Tokenizer* tokenizer); - ~Parser(); - status_t parse(); - - private: - status_t parseKey(); - status_t parseAxis(); - status_t parseLed(); - }; -}; - -} // namespace android - -#endif // _LIBINPUT_KEY_LAYOUT_MAP_H diff --git a/phonelibs/android_frameworks_native/include/input/Keyboard.h b/phonelibs/android_frameworks_native/include/input/Keyboard.h deleted file mode 100644 index d4903e98dfe3b6..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/Keyboard.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_KEYBOARD_H -#define _LIBINPUT_KEYBOARD_H - -#include -#include -#include -#include -#include -#include - -namespace android { - -enum { - /* Device id of the built in keyboard. */ - DEVICE_ID_BUILT_IN_KEYBOARD = 0, - - /* Device id of a generic virtual keyboard with a full layout that can be used - * to synthesize key events. */ - DEVICE_ID_VIRTUAL_KEYBOARD = -1, -}; - -class KeyLayoutMap; -class KeyCharacterMap; - -/** - * Loads the key layout map and key character map for a keyboard device. - */ -class KeyMap { -public: - String8 keyLayoutFile; - sp keyLayoutMap; - - String8 keyCharacterMapFile; - sp keyCharacterMap; - - KeyMap(); - ~KeyMap(); - - status_t load(const InputDeviceIdentifier& deviceIdenfier, - const PropertyMap* deviceConfiguration); - - inline bool haveKeyLayout() const { - return !keyLayoutFile.isEmpty(); - } - - inline bool haveKeyCharacterMap() const { - return !keyCharacterMapFile.isEmpty(); - } - - inline bool isComplete() const { - return haveKeyLayout() && haveKeyCharacterMap(); - } - -private: - bool probeKeyMap(const InputDeviceIdentifier& deviceIdentifier, const String8& name); - status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const String8& name); - status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier, - const String8& name); - String8 getPath(const InputDeviceIdentifier& deviceIdentifier, - const String8& name, InputDeviceConfigurationFileType type); -}; - -/** - * Returns true if the keyboard is eligible for use as a built-in keyboard. - */ -extern bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentifier, - const PropertyMap* deviceConfiguration, const KeyMap* keyMap); - -/** - * Updates a meta state field when a key is pressed or released. - */ -extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState); - -/** - * Normalizes the meta state such that if either the left or right modifier - * meta state bits are set then the result will also include the universal - * bit for that modifier. - */ -extern int32_t normalizeMetaState(int32_t oldMetaState); - -/** - * Returns true if a key is a meta key like ALT or CAPS_LOCK. - */ -extern bool isMetaKey(int32_t keyCode); - -} // namespace android - -#endif // _LIBINPUT_KEYBOARD_H diff --git a/phonelibs/android_frameworks_native/include/input/VelocityControl.h b/phonelibs/android_frameworks_native/include/input/VelocityControl.h deleted file mode 100644 index 1acc2aef702ad5..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/VelocityControl.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_VELOCITY_CONTROL_H -#define _LIBINPUT_VELOCITY_CONTROL_H - -#include -#include -#include - -namespace android { - -/* - * Specifies parameters that govern pointer or wheel acceleration. - */ -struct VelocityControlParameters { - // A scale factor that is multiplied with the raw velocity deltas - // prior to applying any other velocity control factors. The scale - // factor should be used to adapt the input device resolution - // (eg. counts per inch) to the output device resolution (eg. pixels per inch). - // - // Must be a positive value. - // Default is 1.0 (no scaling). - float scale; - - // The scaled speed at which acceleration begins to be applied. - // This value establishes the upper bound of a low speed regime for - // small precise motions that are performed without any acceleration. - // - // Must be a non-negative value. - // Default is 0.0 (no low threshold). - float lowThreshold; - - // The scaled speed at which maximum acceleration is applied. - // The difference between highThreshold and lowThreshold controls - // the range of speeds over which the acceleration factor is interpolated. - // The wider the range, the smoother the acceleration. - // - // Must be a non-negative value greater than or equal to lowThreshold. - // Default is 0.0 (no high threshold). - float highThreshold; - - // The acceleration factor. - // When the speed is above the low speed threshold, the velocity will scaled - // by an interpolated value between 1.0 and this amount. - // - // Must be a positive greater than or equal to 1.0. - // Default is 1.0 (no acceleration). - float acceleration; - - VelocityControlParameters() : - scale(1.0f), lowThreshold(0.0f), highThreshold(0.0f), acceleration(1.0f) { - } - - VelocityControlParameters(float scale, float lowThreshold, - float highThreshold, float acceleration) : - scale(scale), lowThreshold(lowThreshold), - highThreshold(highThreshold), acceleration(acceleration) { - } -}; - -/* - * Implements mouse pointer and wheel speed control and acceleration. - */ -class VelocityControl { -public: - VelocityControl(); - - /* Sets the various parameters. */ - void setParameters(const VelocityControlParameters& parameters); - - /* Resets the current movement counters to zero. - * This has the effect of nullifying any acceleration. */ - void reset(); - - /* Translates a raw movement delta into an appropriately - * scaled / accelerated delta based on the current velocity. */ - void move(nsecs_t eventTime, float* deltaX, float* deltaY); - -private: - // If no movements are received within this amount of time, - // we assume the movement has stopped and reset the movement counters. - static const nsecs_t STOP_TIME = 500 * 1000000; // 500 ms - - VelocityControlParameters mParameters; - - nsecs_t mLastMovementTime; - VelocityTracker::Position mRawPosition; - VelocityTracker mVelocityTracker; -}; - -} // namespace android - -#endif // _LIBINPUT_VELOCITY_CONTROL_H diff --git a/phonelibs/android_frameworks_native/include/input/VelocityTracker.h b/phonelibs/android_frameworks_native/include/input/VelocityTracker.h deleted file mode 100644 index 795f575a2e377d..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/VelocityTracker.h +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_VELOCITY_TRACKER_H -#define _LIBINPUT_VELOCITY_TRACKER_H - -#include -#include -#include - -namespace android { - -class VelocityTrackerStrategy; - -/* - * Calculates the velocity of pointer movements over time. - */ -class VelocityTracker { -public: - struct Position { - float x, y; - }; - - struct Estimator { - static const size_t MAX_DEGREE = 4; - - // Estimator time base. - nsecs_t time; - - // Polynomial coefficients describing motion in X and Y. - float xCoeff[MAX_DEGREE + 1], yCoeff[MAX_DEGREE + 1]; - - // Polynomial degree (number of coefficients), or zero if no information is - // available. - uint32_t degree; - - // Confidence (coefficient of determination), between 0 (no fit) and 1 (perfect fit). - float confidence; - - inline void clear() { - time = 0; - degree = 0; - confidence = 0; - for (size_t i = 0; i <= MAX_DEGREE; i++) { - xCoeff[i] = 0; - yCoeff[i] = 0; - } - } - }; - - // Creates a velocity tracker using the specified strategy. - // If strategy is NULL, uses the default strategy for the platform. - VelocityTracker(const char* strategy = NULL); - - ~VelocityTracker(); - - // Resets the velocity tracker state. - void clear(); - - // Resets the velocity tracker state for specific pointers. - // Call this method when some pointers have changed and may be reusing - // an id that was assigned to a different pointer earlier. - void clearPointers(BitSet32 idBits); - - // Adds movement information for a set of pointers. - // The idBits bitfield specifies the pointer ids of the pointers whose positions - // are included in the movement. - // The positions array contains position information for each pointer in order by - // increasing id. Its size should be equal to the number of one bits in idBits. - void addMovement(nsecs_t eventTime, BitSet32 idBits, const Position* positions); - - // Adds movement information for all pointers in a MotionEvent, including historical samples. - void addMovement(const MotionEvent* event); - - // Gets the velocity of the specified pointer id in position units per second. - // Returns false and sets the velocity components to zero if there is - // insufficient movement information for the pointer. - bool getVelocity(uint32_t id, float* outVx, float* outVy) const; - - // Gets an estimator for the recent movements of the specified pointer id. - // Returns false and clears the estimator if there is no information available - // about the pointer. - bool getEstimator(uint32_t id, Estimator* outEstimator) const; - - // Gets the active pointer id, or -1 if none. - inline int32_t getActivePointerId() const { return mActivePointerId; } - - // Gets a bitset containing all pointer ids from the most recent movement. - inline BitSet32 getCurrentPointerIdBits() const { return mCurrentPointerIdBits; } - -private: - static const char* DEFAULT_STRATEGY; - - nsecs_t mLastEventTime; - BitSet32 mCurrentPointerIdBits; - int32_t mActivePointerId; - VelocityTrackerStrategy* mStrategy; - - bool configureStrategy(const char* strategy); - - static VelocityTrackerStrategy* createStrategy(const char* strategy); -}; - - -/* - * Implements a particular velocity tracker algorithm. - */ -class VelocityTrackerStrategy { -protected: - VelocityTrackerStrategy() { } - -public: - virtual ~VelocityTrackerStrategy() { } - - virtual void clear() = 0; - virtual void clearPointers(BitSet32 idBits) = 0; - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, - const VelocityTracker::Position* positions) = 0; - virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const = 0; -}; - - -/* - * Velocity tracker algorithm based on least-squares linear regression. - */ -class LeastSquaresVelocityTrackerStrategy : public VelocityTrackerStrategy { -public: - enum Weighting { - // No weights applied. All data points are equally reliable. - WEIGHTING_NONE, - - // Weight by time delta. Data points clustered together are weighted less. - WEIGHTING_DELTA, - - // Weight such that points within a certain horizon are weighed more than those - // outside of that horizon. - WEIGHTING_CENTRAL, - - // Weight such that points older than a certain amount are weighed less. - WEIGHTING_RECENT, - }; - - // Degree must be no greater than Estimator::MAX_DEGREE. - LeastSquaresVelocityTrackerStrategy(uint32_t degree, Weighting weighting = WEIGHTING_NONE); - virtual ~LeastSquaresVelocityTrackerStrategy(); - - virtual void clear(); - virtual void clearPointers(BitSet32 idBits); - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, - const VelocityTracker::Position* positions); - virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const; - -private: - // Sample horizon. - // We don't use too much history by default since we want to react to quick - // changes in direction. - static const nsecs_t HORIZON = 100 * 1000000; // 100 ms - - // Number of samples to keep. - static const uint32_t HISTORY_SIZE = 20; - - struct Movement { - nsecs_t eventTime; - BitSet32 idBits; - VelocityTracker::Position positions[MAX_POINTERS]; - - inline const VelocityTracker::Position& getPosition(uint32_t id) const { - return positions[idBits.getIndexOfBit(id)]; - } - }; - - float chooseWeight(uint32_t index) const; - - const uint32_t mDegree; - const Weighting mWeighting; - uint32_t mIndex; - Movement mMovements[HISTORY_SIZE]; -}; - - -/* - * Velocity tracker algorithm that uses an IIR filter. - */ -class IntegratingVelocityTrackerStrategy : public VelocityTrackerStrategy { -public: - // Degree must be 1 or 2. - IntegratingVelocityTrackerStrategy(uint32_t degree); - ~IntegratingVelocityTrackerStrategy(); - - virtual void clear(); - virtual void clearPointers(BitSet32 idBits); - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, - const VelocityTracker::Position* positions); - virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const; - -private: - // Current state estimate for a particular pointer. - struct State { - nsecs_t updateTime; - uint32_t degree; - - float xpos, xvel, xaccel; - float ypos, yvel, yaccel; - }; - - const uint32_t mDegree; - BitSet32 mPointerIdBits; - State mPointerState[MAX_POINTER_ID + 1]; - - void initState(State& state, nsecs_t eventTime, float xpos, float ypos) const; - void updateState(State& state, nsecs_t eventTime, float xpos, float ypos) const; - void populateEstimator(const State& state, VelocityTracker::Estimator* outEstimator) const; -}; - - -/* - * Velocity tracker strategy used prior to ICS. - */ -class LegacyVelocityTrackerStrategy : public VelocityTrackerStrategy { -public: - LegacyVelocityTrackerStrategy(); - virtual ~LegacyVelocityTrackerStrategy(); - - virtual void clear(); - virtual void clearPointers(BitSet32 idBits); - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, - const VelocityTracker::Position* positions); - virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const; - -private: - // Oldest sample to consider when calculating the velocity. - static const nsecs_t HORIZON = 200 * 1000000; // 100 ms - - // Number of samples to keep. - static const uint32_t HISTORY_SIZE = 20; - - // The minimum duration between samples when estimating velocity. - static const nsecs_t MIN_DURATION = 10 * 1000000; // 10 ms - - struct Movement { - nsecs_t eventTime; - BitSet32 idBits; - VelocityTracker::Position positions[MAX_POINTERS]; - - inline const VelocityTracker::Position& getPosition(uint32_t id) const { - return positions[idBits.getIndexOfBit(id)]; - } - }; - - uint32_t mIndex; - Movement mMovements[HISTORY_SIZE]; -}; - -} // namespace android - -#endif // _LIBINPUT_VELOCITY_TRACKER_H diff --git a/phonelibs/android_frameworks_native/include/input/VirtualKeyMap.h b/phonelibs/android_frameworks_native/include/input/VirtualKeyMap.h deleted file mode 100644 index e245ead682ef7e..00000000000000 --- a/phonelibs/android_frameworks_native/include/input/VirtualKeyMap.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - */ - -#ifndef _LIBINPUT_VIRTUAL_KEY_MAP_H -#define _LIBINPUT_VIRTUAL_KEY_MAP_H - -#include - -#include -#include -#include -#include -#include -#include - -namespace android { - -/* Describes a virtual key. */ -struct VirtualKeyDefinition { - int32_t scanCode; - - // configured position data, specified in display coords - int32_t centerX; - int32_t centerY; - int32_t width; - int32_t height; -}; - - -/** - * Describes a collection of virtual keys on a touch screen in terms of - * virtual scan codes and hit rectangles. - * - * This object is immutable after it has been loaded. - */ -class VirtualKeyMap { -public: - ~VirtualKeyMap(); - - static status_t load(const String8& filename, VirtualKeyMap** outMap); - - inline const Vector& getVirtualKeys() const { - return mVirtualKeys; - } - -private: - class Parser { - VirtualKeyMap* mMap; - Tokenizer* mTokenizer; - - public: - Parser(VirtualKeyMap* map, Tokenizer* tokenizer); - ~Parser(); - status_t parse(); - - private: - bool consumeFieldDelimiterAndSkipWhitespace(); - bool parseNextIntField(int32_t* outValue); - }; - - Vector mVirtualKeys; - - VirtualKeyMap(); -}; - -} // namespace android - -#endif // _LIBINPUT_KEY_CHARACTER_MAP_H diff --git a/phonelibs/android_frameworks_native/include/media/drm/DrmAPI.h b/phonelibs/android_frameworks_native/include/media/drm/DrmAPI.h deleted file mode 100644 index 272881b9f50f55..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/drm/DrmAPI.h +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * 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. - */ - -#ifndef DRM_API_H_ -#define DRM_API_H_ - -#include -#include -#include -#include -#include -#include -#include - -// Loadable DrmEngine shared libraries should define the entry points -// createDrmFactory and createCryptoFactory as shown below: -// -// extern "C" { -// extern android::DrmFactory *createDrmFactory(); -// extern android::CryptoFactory *createCryptoFactory(); -// } - -namespace android { - - class DrmPlugin; - class DrmPluginListener; - - // DRMs are implemented in DrmEngine plugins, which are dynamically - // loadable shared libraries that implement the entry points - // createDrmFactory and createCryptoFactory. createDrmFactory - // constructs and returns an instance of a DrmFactory object. Similarly, - // createCryptoFactory creates an instance of a CryptoFactory object. - // When a MediaCrypto or MediaDrm object needs to be constructed, all - // available DrmEngines present in the plugins directory on the device - // are scanned for a matching DrmEngine that can support the crypto - // scheme. When a match is found, the DrmEngine's createCryptoPlugin and - // createDrmPlugin methods are used to create CryptoPlugin or - // DrmPlugin instances to support that DRM scheme. - - class DrmFactory { - public: - DrmFactory() {} - virtual ~DrmFactory() {} - - // DrmFactory::isCryptoSchemeSupported can be called to determine - // if the plugin factory is able to construct plugins that support a - // given crypto scheme, which is specified by a UUID. - virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) = 0; - - // DrmFactory::isContentTypeSupported can be called to determine - // if the plugin factory is able to construct plugins that support a - // given media container format specified by mimeType - virtual bool isContentTypeSupported(const String8 &mimeType) = 0; - - // Construct a DrmPlugin for the crypto scheme specified by UUID. - virtual status_t createDrmPlugin( - const uint8_t uuid[16], DrmPlugin **plugin) = 0; - - private: - DrmFactory(const DrmFactory &); - DrmFactory &operator=(const DrmFactory &); - }; - - class DrmPlugin { - public: - enum EventType { - kDrmPluginEventProvisionRequired = 1, - kDrmPluginEventKeyNeeded, - kDrmPluginEventKeyExpired, - kDrmPluginEventVendorDefined, - kDrmPluginEventSessionReclaimed, - kDrmPluginEventExpirationUpdate, - kDrmPluginEventKeysChange, - }; - - // Drm keys can be for offline content or for online streaming. - // Offline keys are persisted on the device and may be used when the device - // is disconnected from the network. The Release type is used to request - // that offline keys be no longer restricted to offline use. - enum KeyType { - kKeyType_Offline, - kKeyType_Streaming, - kKeyType_Release - }; - - // Enumerate KeyRequestTypes to allow an app to determine the - // type of a key request returned from getKeyRequest. - enum KeyRequestType { - kKeyRequestType_Unknown, - kKeyRequestType_Initial, - kKeyRequestType_Renewal, - kKeyRequestType_Release - }; - - // Enumerate KeyStatusTypes which indicate the state of a key - enum KeyStatusType - { - kKeyStatusType_Usable, - kKeyStatusType_Expired, - kKeyStatusType_OutputNotAllowed, - kKeyStatusType_StatusPending, - kKeyStatusType_InternalError - }; - - // Used by sendKeysChange to report the usability status of each - // key to the app. - struct KeyStatus - { - Vector mKeyId; - KeyStatusType mType; - }; - - DrmPlugin() {} - virtual ~DrmPlugin() {} - - // Open a new session with the DrmPlugin object. A session ID is returned - // in the sessionId parameter. - virtual status_t openSession(Vector &sessionId) = 0; - - // Close a session on the DrmPlugin object. - virtual status_t closeSession(Vector const &sessionId) = 0; - - // A key request/response exchange occurs between the app and a License - // Server to obtain the keys required to decrypt the content. getKeyRequest() - // is used to obtain an opaque key request blob that is delivered to the - // license server. - // - // The scope parameter may be a sessionId or a keySetId, depending on the - // specified keyType. When the keyType is kKeyType_Offline or - // kKeyType_Streaming, scope should be set to the sessionId the keys will be - // provided to. When the keyType is kKeyType_Release, scope should be set to - // the keySetId of the keys being released. Releasing keys from a device - // invalidates them for all sessions. - // - // The init data passed to getKeyRequest is container-specific and its - // meaning is interpreted based on the mime type provided in the mimeType - // parameter to getKeyRequest. It could contain, for example, the content - // ID, key ID or other data obtained from the content metadata that is required - // in generating the key request. Init may be null when keyType is - // kKeyType_Release. - // - // mimeType identifies the mime type of the content - // - // keyType specifies if the keys are to be used for streaming or offline content - // - // optionalParameters are included in the key request message to allow a - // client application to provide additional message parameters to the server. - // - // If successful, the opaque key request blob is returned to the caller. - virtual status_t - getKeyRequest(Vector const &scope, - Vector const &initData, - String8 const &mimeType, KeyType keyType, - KeyedVector const &optionalParameters, - Vector &request, String8 &defaultUrl, - KeyRequestType *keyRequestType) = 0; - - // - // After a key response is received by the app, it is provided to the - // Drm plugin using provideKeyResponse. - // - // scope may be a sessionId or a keySetId depending on the type of the - // response. Scope should be set to the sessionId when the response is - // for either streaming or offline key requests. Scope should be set to the - // keySetId when the response is for a release request. - // - // When the response is for an offline key request, a keySetId is returned - // in the keySetId vector parameter that can be used to later restore the - // keys to a new session with the method restoreKeys. When the response is - // for a streaming or release request, no keySetId is returned. - // - virtual status_t provideKeyResponse(Vector const &scope, - Vector const &response, - Vector &keySetId) = 0; - - // Remove the current keys from a session - virtual status_t removeKeys(Vector const &sessionId) = 0; - - // Restore persisted offline keys into a new session. keySetId identifies - // the keys to load, obtained from a prior call to provideKeyResponse(). - virtual status_t restoreKeys(Vector const &sessionId, - Vector const &keySetId) = 0; - - // Request an informative description of the license for the session. The status - // is in the form of {name, value} pairs. Since DRM license policies vary by - // vendor, the specific status field names are determined by each DRM vendor. - // Refer to your DRM provider documentation for definitions of the field names - // for a particular DrmEngine. - virtual status_t - queryKeyStatus(Vector const &sessionId, - KeyedVector &infoMap) const = 0; - - // A provision request/response exchange occurs between the app and a - // provisioning server to retrieve a device certificate. getProvisionRequest - // is used to obtain an opaque key request blob that is delivered to the - // provisioning server. - // - // If successful, the opaque provision request blob is returned to the caller. - virtual status_t getProvisionRequest(String8 const &cert_type, - String8 const &cert_authority, - Vector &request, - String8 &defaultUrl) = 0; - - // After a provision response is received by the app, it is provided to the - // Drm plugin using provideProvisionResponse. - virtual status_t provideProvisionResponse(Vector const &response, - Vector &certificate, - Vector &wrapped_key) = 0; - - // Remove device provisioning. - virtual status_t unprovisionDevice() = 0; - - // A means of enforcing the contractual requirement for a concurrent stream - // limit per subscriber across devices is provided via SecureStop. SecureStop - // is a means of securely monitoring the lifetime of sessions. Since playback - // on a device can be interrupted due to reboot, power failure, etc. a means - // of persisting the lifetime information on the device is needed. - // - // A signed version of the sessionID is written to persistent storage on the - // device when each MediaCrypto object is created. The sessionID is signed by - // the device private key to prevent tampering. - // - // In the normal case, playback will be completed, the session destroyed and - // the Secure Stops will be queried. The App queries secure stops and forwards - // the secure stop message to the server which verifies the signature and - // notifies the server side database that the session destruction has been - // confirmed. The persisted record on the client is only removed after positive - // confirmation that the server received the message using releaseSecureStops(). - virtual status_t getSecureStops(List > &secureStops) = 0; - virtual status_t getSecureStop(Vector const &ssid, Vector &secureStop) = 0; - virtual status_t releaseSecureStops(Vector const &ssRelease) = 0; - virtual status_t releaseAllSecureStops() = 0; - - // Read a property value given the device property string. There are a few forms - // of property access methods, depending on the data type returned. - // Since DRM plugin properties may vary, additional field names may be defined - // by each DRM vendor. Refer to your DRM provider documentation for definitions - // of its additional field names. - // - // Standard values are: - // "vendor" [string] identifies the maker of the plugin - // "version" [string] identifies the version of the plugin - // "description" [string] describes the plugin - // 'deviceUniqueId' [byte array] The device unique identifier is established - // during device provisioning and provides a means of uniquely identifying - // each device. - virtual status_t getPropertyString(String8 const &name, String8 &value ) const = 0; - virtual status_t getPropertyByteArray(String8 const &name, - Vector &value ) const = 0; - - // Write a property value given the device property string. There are a few forms - // of property setting methods, depending on the data type. - // Since DRM plugin properties may vary, additional field names may be defined - // by each DRM vendor. Refer to your DRM provider documentation for definitions - // of its field names. - virtual status_t setPropertyString(String8 const &name, - String8 const &value ) = 0; - virtual status_t setPropertyByteArray(String8 const &name, - Vector const &value ) = 0; - - // The following methods implement operations on a CryptoSession to support - // encrypt, decrypt, sign verify operations on operator-provided - // session keys. - - // - // The algorithm string conforms to JCA Standard Names for Cipher - // Transforms and is case insensitive. For example "AES/CBC/PKCS5Padding". - // - // Return OK if the algorithm is supported, otherwise return BAD_VALUE - // - virtual status_t setCipherAlgorithm(Vector const &sessionId, - String8 const &algorithm) = 0; - - // - // The algorithm string conforms to JCA Standard Names for Mac - // Algorithms and is case insensitive. For example "HmacSHA256". - // - // Return OK if the algorithm is supported, otherwise return BAD_VALUE - // - virtual status_t setMacAlgorithm(Vector const &sessionId, - String8 const &algorithm) = 0; - - // Encrypt the provided input buffer with the cipher algorithm - // specified by setCipherAlgorithm and the key selected by keyId, - // and return the encrypted data. - virtual status_t encrypt(Vector const &sessionId, - Vector const &keyId, - Vector const &input, - Vector const &iv, - Vector &output) = 0; - - // Decrypt the provided input buffer with the cipher algorithm - // specified by setCipherAlgorithm and the key selected by keyId, - // and return the decrypted data. - virtual status_t decrypt(Vector const &sessionId, - Vector const &keyId, - Vector const &input, - Vector const &iv, - Vector &output) = 0; - - // Compute a signature on the provided message using the mac algorithm - // specified by setMacAlgorithm and the key selected by keyId, - // and return the signature. - virtual status_t sign(Vector const &sessionId, - Vector const &keyId, - Vector const &message, - Vector &signature) = 0; - - // Compute a signature on the provided message using the mac algorithm - // specified by setMacAlgorithm and the key selected by keyId, - // and compare with the expected result. Set result to true or - // false depending on the outcome. - virtual status_t verify(Vector const &sessionId, - Vector const &keyId, - Vector const &message, - Vector const &signature, - bool &match) = 0; - - - // Compute an RSA signature on the provided message using the algorithm - // specified by algorithm. - virtual status_t signRSA(Vector const &sessionId, - String8 const &algorithm, - Vector const &message, - Vector const &wrapped_key, - Vector &signature) = 0; - - - status_t setListener(const sp& listener) { - Mutex::Autolock lock(mEventLock); - mListener = listener; - return OK; - } - - protected: - // Plugins call these methods to deliver events to the java app - void sendEvent(EventType eventType, int extra, - Vector const *sessionId, - Vector const *data); - - void sendExpirationUpdate(Vector const *sessionId, - int64_t expiryTimeInMS); - - void sendKeysChange(Vector const *sessionId, - Vector const *keyStatusList, - bool hasNewUsableKey); - - private: - Mutex mEventLock; - sp mListener; - - DISALLOW_EVIL_CONSTRUCTORS(DrmPlugin); - }; - - class DrmPluginListener: virtual public RefBase - { - public: - virtual void sendEvent(DrmPlugin::EventType eventType, int extra, - Vector const *sessionId, - Vector const *data) = 0; - - virtual void sendExpirationUpdate(Vector const *sessionId, - int64_t expiryTimeInMS) = 0; - - virtual void sendKeysChange(Vector const *sessionId, - Vector const *keyStatusList, - bool hasNewUsableKey) = 0; - }; - - inline void DrmPlugin::sendEvent(EventType eventType, int extra, - Vector const *sessionId, - Vector const *data) { - mEventLock.lock(); - sp listener = mListener; - mEventLock.unlock(); - - if (listener != NULL) { - listener->sendEvent(eventType, extra, sessionId, data); - } - } - - inline void DrmPlugin::sendExpirationUpdate(Vector const *sessionId, - int64_t expiryTimeInMS) { - mEventLock.lock(); - sp listener = mListener; - mEventLock.unlock(); - - if (listener != NULL) { - listener->sendExpirationUpdate(sessionId, expiryTimeInMS); - } - } - - inline void DrmPlugin::sendKeysChange(Vector const *sessionId, - Vector const *keyStatusList, - bool hasNewUsableKey) { - mEventLock.lock(); - sp listener = mListener; - mEventLock.unlock(); - - if (listener != NULL) { - listener->sendKeysChange(sessionId, keyStatusList, hasNewUsableKey); - } - } -} // namespace android - -#endif // DRM_API_H_ diff --git a/phonelibs/android_frameworks_native/include/media/editor/II420ColorConverter.h b/phonelibs/android_frameworks_native/include/media/editor/II420ColorConverter.h deleted file mode 100644 index 33af61ff9a5276..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/editor/II420ColorConverter.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -#ifndef II420_COLOR_CONVERTER_H - -#define II420_COLOR_CONVERTER_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct II420ColorConverter { - - /* - * getDecoderOutputFormat - * Returns the color format (OMX_COLOR_FORMATTYPE) of the decoder output. - * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, - * and convertDecoderOutputToI420() can be a no-op. - */ - int (*getDecoderOutputFormat)(); - - /* - * convertDecoderOutputToI420 - * @Desc Converts from the decoder output format to I420 format. - * @note Caller (e.g. VideoEditor) owns the buffers - * @param decoderBits (IN) Pointer to the buffer contains decoder output - * @param decoderWidth (IN) Buffer width, as reported by the decoder - * metadata (kKeyWidth) - * @param decoderHeight (IN) Buffer height, as reported by the decoder - * metadata (kKeyHeight) - * @param decoderRect (IN) The rectangle of the actual frame, as - * reported by decoder metadata (kKeyCropRect) - * @param dstBits (OUT) Pointer to the output I420 buffer - * @return -1 Any error - * @return 0 No Error - */ - int (*convertDecoderOutputToI420)( - void* decoderBits, int decoderWidth, int decoderHeight, - ARect decoderRect, void* dstBits); - - /* - * getEncoderIntputFormat - * Returns the color format (OMX_COLOR_FORMATTYPE) of the encoder input. - * If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed, - * and convertI420ToEncoderInput() and getEncoderInputBufferInfo() can - * be no-ops. - */ - int (*getEncoderInputFormat)(); - - /* convertI420ToEncoderInput - * @Desc This function converts from I420 to the encoder input format - * @note Caller (e.g. VideoEditor) owns the buffers - * @param srcBits (IN) Pointer to the input I420 buffer - * @param srcWidth (IN) Width of the I420 frame - * @param srcHeight (IN) Height of the I420 frame - * @param encoderWidth (IN) Encoder buffer width, as calculated by - * getEncoderBufferInfo() - * @param encoderHeight (IN) Encoder buffer height, as calculated by - * getEncoderBufferInfo() - * @param encoderRect (IN) Rect coordinates of the actual frame inside - * the encoder buffer, as calculated by - * getEncoderBufferInfo(). - * @param encoderBits (OUT) Pointer to the output buffer. The size of - * this buffer is calculated by - * getEncoderBufferInfo() - * @return -1 Any error - * @return 0 No Error - */ - int (*convertI420ToEncoderInput)( - void* srcBits, int srcWidth, int srcHeight, - int encoderWidth, int encoderHeight, ARect encoderRect, - void* encoderBits); - - /* getEncoderInputBufferInfo - * @Desc This function returns metadata for the encoder input buffer - * based on the actual I420 frame width and height. - * @note This API should be be used to obtain the necessary information - * before calling convertI420ToEncoderInput(). - * VideoEditor knows only the width and height of the I420 buffer, - * but it also needs know the width, height, and size of the - * encoder input buffer. The encoder input buffer width and height - * are used to set the metadata for the encoder. - * @param srcWidth (IN) Width of the I420 frame - * @param srcHeight (IN) Height of the I420 frame - * @param encoderWidth (OUT) Encoder buffer width needed - * @param encoderHeight (OUT) Encoder buffer height needed - * @param encoderRect (OUT) Rect coordinates of the actual frame inside - * the encoder buffer - * @param encoderBufferSize (OUT) The size of the buffer that need to be - * allocated by the caller before invoking - * convertI420ToEncoderInput(). - * @return -1 Any error - * @return 0 No Error - */ - int (*getEncoderInputBufferInfo)( - int srcWidth, int srcHeight, - int* encoderWidth, int* encoderHeight, - ARect* encoderRect, int* encoderBufferSize); - -} II420ColorConverter; - -/* The only function that the shared library needs to expose: It fills the - function pointers in II420ColorConverter */ -void getI420ColorConverter(II420ColorConverter *converter); - -#if defined(__cplusplus) -} -#endif - -#endif // II420_COLOR_CONVERTER_H diff --git a/phonelibs/android_frameworks_native/include/media/hardware/CryptoAPI.h b/phonelibs/android_frameworks_native/include/media/hardware/CryptoAPI.h deleted file mode 100644 index 3e3257f9568768..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/hardware/CryptoAPI.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * 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. - */ - -#include -#include -#include - -#ifndef CRYPTO_API_H_ - -#define CRYPTO_API_H_ - -namespace android { - -struct AString; -struct CryptoPlugin; - -struct CryptoFactory { - CryptoFactory() {} - virtual ~CryptoFactory() {} - - virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) const = 0; - - virtual status_t createPlugin( - const uint8_t uuid[16], const void *data, size_t size, - CryptoPlugin **plugin) = 0; - -private: - CryptoFactory(const CryptoFactory &); - CryptoFactory &operator=(const CryptoFactory &); -}; - -struct CryptoPlugin { - enum Mode { - kMode_Unencrypted = 0, - kMode_AES_CTR = 1, - - // Neither key nor iv are being used in this mode. - // Each subsample is encrypted w/ an iv of all zeroes. - kMode_AES_WV = 2, // FIX constant - }; - - struct SubSample { - uint32_t mNumBytesOfClearData; - uint32_t mNumBytesOfEncryptedData; - }; - - CryptoPlugin() {} - virtual ~CryptoPlugin() {} - - // If this method returns false, a non-secure decoder will be used to - // decode the data after decryption. The decrypt API below will have - // to support insecure decryption of the data (secure = false) for - // media data of the given mime type. - virtual bool requiresSecureDecoderComponent(const char *mime) const = 0; - - // To implement resolution constraints, the crypto plugin needs to know - // the resolution of the video being decrypted. The media player should - // call this method when the resolution is determined and any time it - // is subsequently changed. - - virtual void notifyResolution(uint32_t /* width */, uint32_t /* height */) {} - - // A MediaDrm session may be associated with a MediaCrypto session. The - // associated MediaDrm session is used to load decryption keys - // into the crypto/drm plugin. The keys are then referenced by key-id - // in the 'key' parameter to the decrypt() method. - // Should return NO_ERROR on success, ERROR_DRM_SESSION_NOT_OPENED if - // the session is not opened and a code from MediaErrors.h otherwise. - virtual status_t setMediaDrmSession(const Vector & /*sessionId */) { - return ERROR_UNSUPPORTED; - } - - // If the error returned falls into the range - // ERROR_DRM_VENDOR_MIN..ERROR_DRM_VENDOR_MAX, errorDetailMsg should be - // filled in with an appropriate string. - // At the java level these special errors will then trigger a - // MediaCodec.CryptoException that gives clients access to both - // the error code and the errorDetailMsg. - // Returns a non-negative result to indicate the number of bytes written - // to the dstPtr, or a negative result to indicate an error. - virtual ssize_t decrypt( - bool secure, - const uint8_t key[16], - const uint8_t iv[16], - Mode mode, - const void *srcPtr, - const SubSample *subSamples, size_t numSubSamples, - void *dstPtr, - AString *errorDetailMsg) = 0; - -private: - CryptoPlugin(const CryptoPlugin &); - CryptoPlugin &operator=(const CryptoPlugin &); -}; - -} // namespace android - -extern "C" { - extern android::CryptoFactory *createCryptoFactory(); -} - -#endif // CRYPTO_API_H_ diff --git a/phonelibs/android_frameworks_native/include/media/hardware/HDCPAPI.h b/phonelibs/android_frameworks_native/include/media/hardware/HDCPAPI.h deleted file mode 100644 index 3a53e9fc9084a9..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/hardware/HDCPAPI.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * 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. - */ - -#ifndef HDCP_API_H_ - -#define HDCP_API_H_ - -#include -#include - -namespace android { - -// Two different kinds of modules are covered under the same HDCPModule -// structure below, a module either implements decryption or encryption. -struct HDCPModule { - typedef void (*ObserverFunc)(void *cookie, int msg, int ext1, int ext2); - - // The msg argument in calls to the observer notification function. - enum { - // Sent in response to a call to "HDCPModule::initAsync" once - // initialization has either been successfully completed, - // i.e. the HDCP session is now fully setup (AKE, Locality Check, - // SKE and any authentication with repeaters completed) or failed. - // ext1 should be a suitable error code (status_t), ext2 is - // unused for ENCRYPTION and in the case of HDCP_INITIALIZATION_COMPLETE - // holds the local TCP port the module is listening on. - HDCP_INITIALIZATION_COMPLETE, - HDCP_INITIALIZATION_FAILED, - - // Sent upon completion of a call to "HDCPModule::shutdownAsync". - // ext1 should be a suitable error code, ext2 is unused. - HDCP_SHUTDOWN_COMPLETE, - HDCP_SHUTDOWN_FAILED, - - HDCP_UNAUTHENTICATED_CONNECTION, - HDCP_UNAUTHORIZED_CONNECTION, - HDCP_REVOKED_CONNECTION, - HDCP_TOPOLOGY_EXECEEDED, - HDCP_UNKNOWN_ERROR, - - // DECRYPTION only: Indicates that a client has successfully connected, - // a secure session established and the module is ready to accept - // future calls to "decrypt". - HDCP_SESSION_ESTABLISHED, - }; - - // HDCPModule capability bit masks - enum { - // HDCP_CAPS_ENCRYPT: mandatory, meaning the HDCP module can encrypt - // from an input byte-array buffer to an output byte-array buffer - HDCP_CAPS_ENCRYPT = (1 << 0), - // HDCP_CAPS_ENCRYPT_NATIVE: the HDCP module supports encryption from - // a native buffer to an output byte-array buffer. The format of the - // input native buffer is specific to vendor's encoder implementation. - // It is the same format as that used by the encoder when - // "storeMetaDataInBuffers" extension is enabled on its output port. - HDCP_CAPS_ENCRYPT_NATIVE = (1 << 1), - }; - - // Module can call the notification function to signal completion/failure - // of asynchronous operations (such as initialization) or out of band - // events. - HDCPModule(void *cookie, ObserverFunc observerNotify) {}; - - virtual ~HDCPModule() {}; - - // ENCRYPTION: Request to setup an HDCP session with the host specified - // by addr and listening on the specified port. - // DECRYPTION: Request to setup an HDCP session, addr is the interface - // address the module should bind its socket to. port will be 0. - // The module will pick the port to listen on itself and report its choice - // in the "ext2" argument of the HDCP_INITIALIZATION_COMPLETE callback. - virtual status_t initAsync(const char *addr, unsigned port) = 0; - - // Request to shutdown the active HDCP session. - virtual status_t shutdownAsync() = 0; - - // Returns the capability bitmask of this HDCP session. - virtual uint32_t getCaps() { - return HDCP_CAPS_ENCRYPT; - } - - // ENCRYPTION only: - // Encrypt data according to the HDCP spec. "size" bytes of data are - // available at "inData" (virtual address), "size" may not be a multiple - // of 128 bits (16 bytes). An equal number of encrypted bytes should be - // written to the buffer at "outData" (virtual address). - // This operation is to be synchronous, i.e. this call does not return - // until outData contains size bytes of encrypted data. - // streamCTR will be assigned by the caller (to 0 for the first PES stream, - // 1 for the second and so on) - // inputCTR _will_be_maintained_by_the_callee_ for each PES stream. - virtual status_t encrypt( - const void *inData, size_t size, uint32_t streamCTR, - uint64_t *outInputCTR, void *outData) { - return INVALID_OPERATION; - } - - // Encrypt data according to the HDCP spec. "size" bytes of data starting - // at location "offset" are available in "buffer" (buffer handle). "size" - // may not be a multiple of 128 bits (16 bytes). An equal number of - // encrypted bytes should be written to the buffer at "outData" (virtual - // address). This operation is to be synchronous, i.e. this call does not - // return until outData contains size bytes of encrypted data. - // streamCTR will be assigned by the caller (to 0 for the first PES stream, - // 1 for the second and so on) - // inputCTR _will_be_maintained_by_the_callee_ for each PES stream. - virtual status_t encryptNative( - buffer_handle_t buffer, size_t offset, size_t size, - uint32_t streamCTR, uint64_t *outInputCTR, void *outData) { - return INVALID_OPERATION; - } - // DECRYPTION only: - // Decrypt data according to the HDCP spec. - // "size" bytes of encrypted data are available at "inData" - // (virtual address), "size" may not be a multiple of 128 bits (16 bytes). - // An equal number of decrypted bytes should be written to the buffer - // at "outData" (virtual address). - // This operation is to be synchronous, i.e. this call does not return - // until outData contains size bytes of decrypted data. - // Both streamCTR and inputCTR will be provided by the caller. - virtual status_t decrypt( - const void *inData, size_t size, - uint32_t streamCTR, uint64_t inputCTR, - void *outData) { - return INVALID_OPERATION; - } - -private: - HDCPModule(const HDCPModule &); - HDCPModule &operator=(const HDCPModule &); -}; - -} // namespace android - -// A shared library exporting the following methods should be included to -// support HDCP functionality. The shared library must be called -// "libstagefright_hdcp.so", it will be dynamically loaded into the -// mediaserver process. -extern "C" { - // Create a module for ENCRYPTION. - extern android::HDCPModule *createHDCPModule( - void *cookie, android::HDCPModule::ObserverFunc); - - // Create a module for DECRYPTION. - extern android::HDCPModule *createHDCPModuleForDecryption( - void *cookie, android::HDCPModule::ObserverFunc); -} - -#endif // HDCP_API_H_ - diff --git a/phonelibs/android_frameworks_native/include/media/hardware/HardwareAPI.h b/phonelibs/android_frameworks_native/include/media/hardware/HardwareAPI.h deleted file mode 100644 index 1008c22d73ba0b..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/hardware/HardwareAPI.h +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * 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. - */ - -#ifndef HARDWARE_API_H_ - -#define HARDWARE_API_H_ - -#include -#include -#include -#include - -#include - -namespace android { - -// A pointer to this struct is passed to the OMX_SetParameter when the extension -// index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension -// is given. -// -// When Android native buffer use is disabled for a port (the default state), -// the OMX node should operate as normal, and expect UseBuffer calls to set its -// buffers. This is the mode that will be used when CPU access to the buffer is -// required. -// -// When Android native buffer use has been enabled for a given port, the video -// color format for the port is to be interpreted as an Android pixel format -// rather than an OMX color format. Enabling Android native buffers may also -// change how the component receives the native buffers. If store-metadata-mode -// is enabled on the port, the component will receive the buffers as specified -// in the section below. Otherwise, unless the node supports the -// 'OMX.google.android.index.useAndroidNativeBuffer2' extension, it should -// expect to receive UseAndroidNativeBuffer calls (via OMX_SetParameter) rather -// than UseBuffer calls for that port. -struct EnableAndroidNativeBuffersParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL enable; -}; - -// A pointer to this struct is passed to OMX_SetParameter() when the extension index -// "OMX.google.android.index.storeMetaDataInBuffers" or -// "OMX.google.android.index.storeANWBufferInMetadata" is given. -// -// When meta data is stored in the video buffers passed between OMX clients -// and OMX components, interpretation of the buffer data is up to the -// buffer receiver, and the data may or may not be the actual video data, but -// some information helpful for the receiver to locate the actual data. -// The buffer receiver thus needs to know how to interpret what is stored -// in these buffers, with mechanisms pre-determined externally. How to -// interpret the meta data is outside of the scope of this parameter. -// -// Currently, this is used to pass meta data from video source (camera component, for instance) to -// video encoder to avoid memcpying of input video frame data, as well as to pass dynamic output -// buffer to video decoder. To do this, bStoreMetaData is set to OMX_TRUE. -// -// If bStoreMetaData is set to false, real YUV frame data will be stored in input buffers, and -// the output buffers contain either real YUV frame data, or are themselves native handles as -// directed by enable/use-android-native-buffer parameter settings. -// In addition, if no OMX_SetParameter() call is made on a port with the corresponding extension -// index, the component should not assume that the client is not using metadata mode for the port. -// -// If the component supports this using the "OMX.google.android.index.storeANWBufferInMetadata" -// extension and bStoreMetaData is set to OMX_TRUE, data is passed using the VideoNativeMetadata -// layout as defined below. Each buffer will be accompanied by a fence. The fence must signal -// before the buffer can be used (e.g. read from or written into). When returning such buffer to -// the client, component must provide a new fence that must signal before the returned buffer can -// be used (e.g. read from or written into). The component owns the incoming fenceFd, and must close -// it when fence has signaled. The client will own and close the returned fence file descriptor. -// -// If the component supports this using the "OMX.google.android.index.storeMetaDataInBuffers" -// extension and bStoreMetaData is set to OMX_TRUE, data is passed using VideoGrallocMetadata -// (the layout of which is the VideoGrallocMetadata defined below). Camera input can be also passed -// as "CameraSource", the layout of which is vendor dependent. -// -// Metadata buffers are registered with the component using UseBuffer calls, or can be allocated -// by the component for encoder-metadata-output buffers. -struct StoreMetaDataInBuffersParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bStoreMetaData; -}; - -// Meta data buffer layout used to transport output frames to the decoder for -// dynamic buffer handling. -struct VideoGrallocMetadata { - MetadataBufferType eType; // must be kMetadataBufferTypeGrallocSource -#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS - OMX_PTR pHandle; -#else - buffer_handle_t pHandle; -#endif -}; - -// Legacy name for VideoGrallocMetadata struct. -struct VideoDecoderOutputMetaData : public VideoGrallocMetadata {}; - -struct VideoNativeMetadata { - MetadataBufferType eType; // must be kMetadataBufferTypeANWBuffer -#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS - OMX_PTR pBuffer; -#else - struct ANativeWindowBuffer* pBuffer; -#endif - int nFenceFd; // -1 if unused -}; - -// A pointer to this struct is passed to OMX_SetParameter() when the extension -// index "OMX.google.android.index.prepareForAdaptivePlayback" is given. -// -// This method is used to signal a video decoder, that the user has requested -// seamless resolution change support (if bEnable is set to OMX_TRUE). -// nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest -// anticipated frames in the video. If bEnable is OMX_FALSE, no resolution -// change is expected, and the nMaxFrameWidth/Height fields are unused. -// -// If the decoder supports dynamic output buffers, it may ignore this -// request. Otherwise, it shall request resources in such a way so that it -// avoids full port-reconfiguration (due to output port-definition change) -// during resolution changes. -// -// DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED. INSTEAD, IMPLEMENT -// METADATA SUPPORT FOR VIDEO DECODERS. -struct PrepareForAdaptivePlaybackParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnable; - OMX_U32 nMaxFrameWidth; - OMX_U32 nMaxFrameHeight; -}; - -// A pointer to this struct is passed to OMX_SetParameter when the extension -// index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is -// given. This call will only be performed if a prior call was made with the -// 'OMX.google.android.index.enableAndroidNativeBuffers' extension index, -// enabling use of Android native buffers. -struct UseAndroidNativeBufferParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_PTR pAppPrivate; - OMX_BUFFERHEADERTYPE **bufferHeader; - const sp& nativeBuffer; -}; - -// A pointer to this struct is passed to OMX_GetParameter when the extension -// index for the 'OMX.google.android.index.getAndroidNativeBufferUsage' -// extension is given. The usage bits returned from this query will be used to -// allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer -// command. -struct GetAndroidNativeBufferUsageParams { - OMX_U32 nSize; // IN - OMX_VERSIONTYPE nVersion; // IN - OMX_U32 nPortIndex; // IN - OMX_U32 nUsage; // OUT -}; - -// An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat -// is declared in media/stagefright/openmax/OMX_IVCommon.h -// This will inform the encoder that the actual -// colorformat will be relayed by the GRalloc Buffers. -// OMX_COLOR_FormatAndroidOpaque = 0x7F000001, - -// A pointer to this struct is passed to OMX_SetParameter when the extension -// index for the 'OMX.google.android.index.prependSPSPPSToIDRFrames' extension -// is given. -// A successful result indicates that future IDR frames will be prefixed by -// SPS/PPS. -struct PrependSPSPPSToIDRFramesParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bEnable; -}; - -// Structure describing a media image (frame) -// Currently only supporting YUV -struct MediaImage { - enum Type { - MEDIA_IMAGE_TYPE_UNKNOWN = 0, - MEDIA_IMAGE_TYPE_YUV, - }; - - enum PlaneIndex { - Y = 0, - U, - V, - MAX_NUM_PLANES - }; - - Type mType; - uint32_t mNumPlanes; // number of planes - uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) - uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) - uint32_t mBitDepth; // useable bit depth - struct PlaneInfo { - uint32_t mOffset; // offset of first pixel of the plane in bytes - // from buffer offset - uint32_t mColInc; // column increment in bytes - uint32_t mRowInc; // row increment in bytes - uint32_t mHorizSubsampling; // subsampling compared to the largest plane - uint32_t mVertSubsampling; // subsampling compared to the largest plane - }; - PlaneInfo mPlane[MAX_NUM_PLANES]; -}; - -// A pointer to this struct is passed to OMX_GetParameter when the extension -// index for the 'OMX.google.android.index.describeColorFormat' -// extension is given. This method can be called from any component state -// other than invalid. The color-format, frame width/height, and stride/ -// slice-height parameters are ones that are associated with a raw video -// port (input or output), but the stride/slice height parameters may be -// incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will -// be used (while specifying this color format). -// -// The component shall fill out the MediaImage structure that -// corresponds to the described raw video format, and the potentially corrected -// stride and slice-height info. -// -// The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE, -// though most implementations can ignore this difference. When using native buffers, -// the component may change the configured color format to an optimized format. -// Additionally, when allocating these buffers for flexible usecase, the framework -// will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers -// is OMX_TRUE), the component shall fill out the MediaImage information for the -// scenario when these SW-readable/writable buffers are locked using gralloc_lock. -// Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must -// be supported for vendor-specific formats. -// -// For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers -// is OMX_TRUE and the component does not support this color format with native -// buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN. -struct DescribeColorFormatParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - OMX_U32 nStride; - OMX_U32 nSliceHeight; - OMX_BOOL bUsingNativeBuffers; - - // output: fill out the MediaImage fields - MediaImage sMediaImage; -}; - -// A pointer to this struct is passed to OMX_SetParameter or OMX_GetParameter -// when the extension index for the -// 'OMX.google.android.index.configureVideoTunnelMode' extension is given. -// If the extension is supported then tunneled playback mode should be supported -// by the codec. If bTunneled is set to OMX_TRUE then the video decoder should -// operate in "tunneled" mode and output its decoded frames directly to the -// sink. In this case nAudioHwSync is the HW SYNC ID of the audio HAL Output -// stream to sync the video with. If bTunneled is set to OMX_FALSE, "tunneled" -// mode should be disabled and nAudioHwSync should be ignored. -// OMX_GetParameter is used to query tunneling configuration. bTunneled should -// return whether decoder is operating in tunneled mode, and if it is, -// pSidebandWindow should contain the codec allocated sideband window handle. -struct ConfigureVideoTunnelModeParams { - OMX_U32 nSize; // IN - OMX_VERSIONTYPE nVersion; // IN - OMX_U32 nPortIndex; // IN - OMX_BOOL bTunneled; // IN/OUT - OMX_U32 nAudioHwSync; // IN - OMX_PTR pSidebandWindow; // OUT -}; - -} // namespace android - -extern android::OMXPluginBase *createOMXPlugin(); - -#endif // HARDWARE_API_H_ diff --git a/phonelibs/android_frameworks_native/include/media/hardware/MetadataBufferType.h b/phonelibs/android_frameworks_native/include/media/hardware/MetadataBufferType.h deleted file mode 100644 index b765203956589a..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/hardware/MetadataBufferType.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -#ifndef METADATA_BUFFER_TYPE_H -#define METADATA_BUFFER_TYPE_H - -#ifdef __cplusplus -extern "C" { -namespace android { -#endif - -/* - * MetadataBufferType defines the type of the metadata buffers that - * can be passed to video encoder component for encoding, via Stagefright - * media recording framework. To see how to work with the metadata buffers - * in media recording framework, please consult HardwareAPI.h - * - * The creator of metadata buffers and video encoder share common knowledge - * on what is actually being stored in these metadata buffers, and - * how the information can be used by the video encoder component - * to locate the actual pixel data as the source input for video - * encoder, plus whatever other information that is necessary. Stagefright - * media recording framework does not need to know anything specific about the - * metadata buffers, except for receving each individual metadata buffer - * as the source input, making a copy of the metadata buffer, and passing the - * copy via OpenMAX API to the video encoder component. - * - * The creator of the metadata buffers must ensure that the first - * 4 bytes in every metadata buffer indicates its buffer type, - * and the rest of the metadata buffer contains the - * actual metadata information. When a video encoder component receives - * a metadata buffer, it uses the first 4 bytes in that buffer to find - * out the type of the metadata buffer, and takes action appropriate - * to that type of metadata buffers (for instance, locate the actual - * pixel data input and then encoding the input data to produce a - * compressed output buffer). - * - * The following shows the layout of a metadata buffer, - * where buffer type is a 4-byte field of MetadataBufferType, - * and the payload is the metadata information. - * - * -------------------------------------------------------------- - * | buffer type | payload | - * -------------------------------------------------------------- - * - */ -typedef enum { - - /* - * kMetadataBufferTypeCameraSource is used to indicate that - * the source of the metadata buffer is the camera component. - */ - kMetadataBufferTypeCameraSource = 0, - - /* - * kMetadataBufferTypeGrallocSource is used to indicate that - * the payload of the metadata buffers can be interpreted as - * a buffer_handle_t. - * So in this case,the metadata that the encoder receives - * will have a byte stream that consists of two parts: - * 1. First, there is an integer indicating that it is a GRAlloc - * source (kMetadataBufferTypeGrallocSource) - * 2. This is followed by the buffer_handle_t that is a handle to the - * GRalloc buffer. The encoder needs to interpret this GRalloc handle - * and encode the frames. - * -------------------------------------------------------------- - * | kMetadataBufferTypeGrallocSource | buffer_handle_t buffer | - * -------------------------------------------------------------- - * - * See the VideoGrallocMetadata structure. - */ - kMetadataBufferTypeGrallocSource = 1, - - /* - * kMetadataBufferTypeGraphicBuffer is used to indicate that - * the payload of the metadata buffers can be interpreted as - * an ANativeWindowBuffer, and that a fence is provided. - * - * In this case, the metadata will have a byte stream that consists of three parts: - * 1. First, there is an integer indicating that the metadata - * contains an ANativeWindowBuffer (kMetadataBufferTypeANWBuffer) - * 2. This is followed by the pointer to the ANativeWindowBuffer. - * Codec must not free this buffer as it does not actually own this buffer. - * 3. Finally, there is an integer containing a fence file descriptor. - * The codec must wait on the fence before encoding or decoding into this - * buffer. When the buffer is returned, codec must replace this file descriptor - * with a new fence, that will be waited on before the buffer is replaced - * (encoder) or read (decoder). - * --------------------------------- - * | kMetadataBufferTypeANWBuffer | - * --------------------------------- - * | ANativeWindowBuffer *buffer | - * --------------------------------- - * | int fenceFd | - * --------------------------------- - * - * See the VideoNativeMetadata structure. - */ - kMetadataBufferTypeANWBuffer = 2, - - /* This value is used by framework, but is never used inside a metadata buffer */ - kMetadataBufferTypeInvalid = -1, - - - // Add more here... - -} MetadataBufferType; - -#ifdef __cplusplus -} // namespace android -} -#endif - -#endif // METADATA_BUFFER_TYPE_H diff --git a/phonelibs/android_frameworks_native/include/media/hardware/OMXPluginBase.h b/phonelibs/android_frameworks_native/include/media/hardware/OMXPluginBase.h deleted file mode 100644 index 7bf414739b85dc..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/hardware/OMXPluginBase.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * 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. - */ - -#ifndef OMX_PLUGIN_BASE_H_ - -#define OMX_PLUGIN_BASE_H_ - -#include - -#include - -#include -#include - -namespace android { - -struct OMXPluginBase { - OMXPluginBase() {} - virtual ~OMXPluginBase() {} - - virtual OMX_ERRORTYPE makeComponentInstance( - const char *name, - const OMX_CALLBACKTYPE *callbacks, - OMX_PTR appData, - OMX_COMPONENTTYPE **component) = 0; - - virtual OMX_ERRORTYPE destroyComponentInstance( - OMX_COMPONENTTYPE *component) = 0; - - virtual OMX_ERRORTYPE enumerateComponents( - OMX_STRING name, - size_t size, - OMX_U32 index) = 0; - - virtual OMX_ERRORTYPE getRolesOfComponent( - const char *name, - Vector *roles) = 0; - -private: - OMXPluginBase(const OMXPluginBase &); - OMXPluginBase &operator=(const OMXPluginBase &); -}; - -} // namespace android - -#endif // OMX_PLUGIN_BASE_H_ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_AsString.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_AsString.h deleted file mode 100644 index ae8430d856124a..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_AsString.h +++ /dev/null @@ -1,947 +0,0 @@ -/* - * Copyright 2014 The Android Open Source Project - * - * 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. - */ - -/* NOTE: This file contains several sections for individual OMX include files. - Each section has its own include guard. This file should be included AFTER - the OMX include files. */ - -#ifdef OMX_Audio_h -/* asString definitions if media/openmax/OMX_Audio.h was included */ - -#ifndef AS_STRING_FOR_OMX_AUDIO_H -#define AS_STRING_FOR_OMX_AUDIO_H - -inline static const char *asString(OMX_AUDIO_CODINGTYPE i, const char *def = "??") { - switch (i) { - case OMX_AUDIO_CodingUnused: return "Unused"; // unused - case OMX_AUDIO_CodingAutoDetect: return "AutoDetect"; // unused - case OMX_AUDIO_CodingPCM: return "PCM"; - case OMX_AUDIO_CodingADPCM: return "ADPCM"; // unused - case OMX_AUDIO_CodingAMR: return "AMR"; - case OMX_AUDIO_CodingGSMFR: return "GSMFR"; - case OMX_AUDIO_CodingGSMEFR: return "GSMEFR"; // unused - case OMX_AUDIO_CodingGSMHR: return "GSMHR"; // unused - case OMX_AUDIO_CodingPDCFR: return "PDCFR"; // unused - case OMX_AUDIO_CodingPDCEFR: return "PDCEFR"; // unused - case OMX_AUDIO_CodingPDCHR: return "PDCHR"; // unused - case OMX_AUDIO_CodingTDMAFR: return "TDMAFR"; // unused - case OMX_AUDIO_CodingTDMAEFR: return "TDMAEFR"; // unused - case OMX_AUDIO_CodingQCELP8: return "QCELP8"; // unused - case OMX_AUDIO_CodingQCELP13: return "QCELP13"; // unused - case OMX_AUDIO_CodingEVRC: return "EVRC"; // unused - case OMX_AUDIO_CodingSMV: return "SMV"; // unused - case OMX_AUDIO_CodingG711: return "G711"; - case OMX_AUDIO_CodingG723: return "G723"; // unused - case OMX_AUDIO_CodingG726: return "G726"; // unused - case OMX_AUDIO_CodingG729: return "G729"; // unused - case OMX_AUDIO_CodingAAC: return "AAC"; - case OMX_AUDIO_CodingMP3: return "MP3"; - case OMX_AUDIO_CodingSBC: return "SBC"; // unused - case OMX_AUDIO_CodingVORBIS: return "VORBIS"; - case OMX_AUDIO_CodingWMA: return "WMA"; // unused - case OMX_AUDIO_CodingRA: return "RA"; // unused - case OMX_AUDIO_CodingMIDI: return "MIDI"; // unused - case OMX_AUDIO_CodingFLAC: return "FLAC"; - default: return def; - } -} - -inline static const char *asString(OMX_AUDIO_PCMMODETYPE i, const char *def = "??") { - switch (i) { - case OMX_AUDIO_PCMModeLinear: return "Linear"; - case OMX_AUDIO_PCMModeALaw: return "ALaw"; - case OMX_AUDIO_PCMModeMULaw: return "MULaw"; - default: return def; - } -} - -inline static const char *asString(OMX_AUDIO_CHANNELTYPE i, const char *def = "??") { - switch (i) { - case OMX_AUDIO_ChannelNone: return "None"; // unused - case OMX_AUDIO_ChannelLF: return "LF"; - case OMX_AUDIO_ChannelRF: return "RF"; - case OMX_AUDIO_ChannelCF: return "CF"; - case OMX_AUDIO_ChannelLS: return "LS"; - case OMX_AUDIO_ChannelRS: return "RS"; - case OMX_AUDIO_ChannelLFE: return "LFE"; - case OMX_AUDIO_ChannelCS: return "CS"; - case OMX_AUDIO_ChannelLR: return "LR"; - case OMX_AUDIO_ChannelRR: return "RR"; - default: return def; - } -} - -inline static const char *asString(OMX_AUDIO_CHANNELMODETYPE i, const char *def = "??") { - switch (i) { - case OMX_AUDIO_ChannelModeStereo: return "Stereo"; -// case OMX_AUDIO_ChannelModeJointStereo: return "JointStereo"; -// case OMX_AUDIO_ChannelModeDual: return "Dual"; - case OMX_AUDIO_ChannelModeMono: return "Mono"; - default: return def; - } -} - -inline static const char *asString(OMX_AUDIO_AACSTREAMFORMATTYPE i, const char *def = "??") { - switch (i) { -// case OMX_AUDIO_AACStreamFormatMP2ADTS: return "MP2ADTS"; - case OMX_AUDIO_AACStreamFormatMP4ADTS: return "MP4ADTS"; -// case OMX_AUDIO_AACStreamFormatMP4LOAS: return "MP4LOAS"; -// case OMX_AUDIO_AACStreamFormatMP4LATM: return "MP4LATM"; -// case OMX_AUDIO_AACStreamFormatADIF: return "ADIF"; - case OMX_AUDIO_AACStreamFormatMP4FF: return "MP4FF"; -// case OMX_AUDIO_AACStreamFormatRAW: return "RAW"; - default: return def; - } -} - -inline static const char *asString(OMX_AUDIO_AMRFRAMEFORMATTYPE i, const char *def = "??") { - switch (i) { -// case OMX_AUDIO_AMRFrameFormatConformance: return "Conformance"; -// case OMX_AUDIO_AMRFrameFormatIF1: return "IF1"; -// case OMX_AUDIO_AMRFrameFormatIF2: return "IF2"; - case OMX_AUDIO_AMRFrameFormatFSF: return "FSF"; -// case OMX_AUDIO_AMRFrameFormatRTPPayload: return "RTPPayload"; -// case OMX_AUDIO_AMRFrameFormatITU: return "ITU"; - default: return def; - } -} - -inline static const char *asString(OMX_AUDIO_AMRBANDMODETYPE i, const char *def = "??") { - switch (i) { - case OMX_AUDIO_AMRBandModeUnused: return "Unused"; - case OMX_AUDIO_AMRBandModeNB0: return "NB0"; - case OMX_AUDIO_AMRBandModeNB1: return "NB1"; - case OMX_AUDIO_AMRBandModeNB2: return "NB2"; - case OMX_AUDIO_AMRBandModeNB3: return "NB3"; - case OMX_AUDIO_AMRBandModeNB4: return "NB4"; - case OMX_AUDIO_AMRBandModeNB5: return "NB5"; - case OMX_AUDIO_AMRBandModeNB6: return "NB6"; - case OMX_AUDIO_AMRBandModeNB7: return "NB7"; - case OMX_AUDIO_AMRBandModeWB0: return "WB0"; - case OMX_AUDIO_AMRBandModeWB1: return "WB1"; - case OMX_AUDIO_AMRBandModeWB2: return "WB2"; - case OMX_AUDIO_AMRBandModeWB3: return "WB3"; - case OMX_AUDIO_AMRBandModeWB4: return "WB4"; - case OMX_AUDIO_AMRBandModeWB5: return "WB5"; - case OMX_AUDIO_AMRBandModeWB6: return "WB6"; - case OMX_AUDIO_AMRBandModeWB7: return "WB7"; - case OMX_AUDIO_AMRBandModeWB8: return "WB8"; - default: return def; - } -} - -inline static const char *asString(OMX_AUDIO_AMRDTXMODETYPE i, const char *def = "??") { - switch (i) { - case OMX_AUDIO_AMRDTXModeOff: return "ModeOff"; -// case OMX_AUDIO_AMRDTXModeOnVAD1: return "ModeOnVAD1"; -// case OMX_AUDIO_AMRDTXModeOnVAD2: return "ModeOnVAD2"; -// case OMX_AUDIO_AMRDTXModeOnAuto: return "ModeOnAuto"; -// case OMX_AUDIO_AMRDTXasEFR: return "asEFR"; - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_AUDIO_H - -#endif // OMX_Audio_h - -#ifdef OMX_AudioExt_h -/* asString definitions if media/openmax/OMX_AudioExt.h was included */ - -#ifndef AS_STRING_FOR_OMX_AUDIOEXT_H -#define AS_STRING_FOR_OMX_AUDIOEXT_H - -inline static const char *asString(OMX_AUDIO_CODINGEXTTYPE i, const char *def = "??") { - switch (i) { - case OMX_AUDIO_CodingAndroidAC3: return "AndroidAC3"; - case OMX_AUDIO_CodingAndroidOPUS: return "AndroidOPUS"; - default: return asString((OMX_AUDIO_CODINGTYPE)i, def); - } -} - -#endif // AS_STRING_FOR_OMX_AUDIOEXT_H - -#endif // OMX_AudioExt_h - -#ifdef OMX_Component_h -/* asString definitions if media/openmax/OMX_Component.h was included */ - -#ifndef AS_STRING_FOR_OMX_COMPONENT_H -#define AS_STRING_FOR_OMX_COMPONENT_H - -inline static const char *asString(OMX_PORTDOMAINTYPE i, const char *def = "??") { - switch (i) { - case OMX_PortDomainAudio: return "Audio"; - case OMX_PortDomainVideo: return "Video"; - case OMX_PortDomainImage: return "Image"; -// case OMX_PortDomainOther: return "Other"; - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_COMPONENT_H - -#endif // OMX_Component_h - -#ifdef OMX_Core_h -/* asString definitions if media/openmax/OMX_Core.h was included */ - -#ifndef AS_STRING_FOR_OMX_CORE_H -#define AS_STRING_FOR_OMX_CORE_H - -inline static const char *asString(OMX_COMMANDTYPE i, const char *def = "??") { - switch (i) { - case OMX_CommandStateSet: return "StateSet"; - case OMX_CommandFlush: return "Flush"; - case OMX_CommandPortDisable: return "PortDisable"; - case OMX_CommandPortEnable: return "PortEnable"; -// case OMX_CommandMarkBuffer: return "MarkBuffer"; - default: return def; - } -} - -inline static const char *asString(OMX_STATETYPE i, const char *def = "??") { - switch (i) { - case OMX_StateInvalid: return "Invalid"; - case OMX_StateLoaded: return "Loaded"; - case OMX_StateIdle: return "Idle"; - case OMX_StateExecuting: return "Executing"; -// case OMX_StatePause: return "Pause"; -// case OMX_StateWaitForResources: return "WaitForResources"; - default: return def; - } -} - -inline static const char *asString(OMX_ERRORTYPE i, const char *def = "??") { - switch (i) { - case OMX_ErrorNone: return "None"; - case OMX_ErrorInsufficientResources: return "InsufficientResources"; - case OMX_ErrorUndefined: return "Undefined"; - case OMX_ErrorInvalidComponentName: return "InvalidComponentName"; - case OMX_ErrorComponentNotFound: return "ComponentNotFound"; - case OMX_ErrorInvalidComponent: return "InvalidComponent"; // unused - case OMX_ErrorBadParameter: return "BadParameter"; - case OMX_ErrorNotImplemented: return "NotImplemented"; - case OMX_ErrorUnderflow: return "Underflow"; // unused - case OMX_ErrorOverflow: return "Overflow"; // unused - case OMX_ErrorHardware: return "Hardware"; // unused - case OMX_ErrorInvalidState: return "InvalidState"; - case OMX_ErrorStreamCorrupt: return "StreamCorrupt"; - case OMX_ErrorPortsNotCompatible: return "PortsNotCompatible"; // unused - case OMX_ErrorResourcesLost: return "ResourcesLost"; - case OMX_ErrorNoMore: return "NoMore"; - case OMX_ErrorVersionMismatch: return "VersionMismatch"; // unused - case OMX_ErrorNotReady: return "NotReady"; // unused - case OMX_ErrorTimeout: return "Timeout"; // unused - case OMX_ErrorSameState: return "SameState"; // unused - case OMX_ErrorResourcesPreempted: return "ResourcesPreempted"; // unused - case OMX_ErrorPortUnresponsiveDuringAllocation: - return "PortUnresponsiveDuringAllocation"; // unused - case OMX_ErrorPortUnresponsiveDuringDeallocation: - return "PortUnresponsiveDuringDeallocation"; // unused - case OMX_ErrorPortUnresponsiveDuringStop: - return "PortUnresponsiveDuringStop"; // unused - case OMX_ErrorIncorrectStateTransition: - return "IncorrectStateTransition"; // unused - case OMX_ErrorIncorrectStateOperation: - return "IncorrectStateOperation"; // unused - case OMX_ErrorUnsupportedSetting: return "UnsupportedSetting"; - case OMX_ErrorUnsupportedIndex: return "UnsupportedIndex"; - case OMX_ErrorBadPortIndex: return "BadPortIndex"; - case OMX_ErrorPortUnpopulated: return "PortUnpopulated"; // unused - case OMX_ErrorComponentSuspended: return "ComponentSuspended"; // unused - case OMX_ErrorDynamicResourcesUnavailable: - return "DynamicResourcesUnavailable"; // unused - case OMX_ErrorMbErrorsInFrame: return "MbErrorsInFrame"; // unused - case OMX_ErrorFormatNotDetected: return "FormatNotDetected"; // unused - case OMX_ErrorContentPipeOpenFailed: return "ContentPipeOpenFailed"; // unused - case OMX_ErrorContentPipeCreationFailed: - return "ContentPipeCreationFailed"; // unused - case OMX_ErrorSeperateTablesUsed: return "SeperateTablesUsed"; // unused - case OMX_ErrorTunnelingUnsupported: return "TunnelingUnsupported"; // unused - default: return def; - } -} - -inline static const char *asString(OMX_EVENTTYPE i, const char *def = "??") { - switch (i) { - case OMX_EventCmdComplete: return "CmdComplete"; - case OMX_EventError: return "Error"; -// case OMX_EventMark: return "Mark"; - case OMX_EventPortSettingsChanged: return "PortSettingsChanged"; - case OMX_EventBufferFlag: return "BufferFlag"; -// case OMX_EventResourcesAcquired: return "ResourcesAcquired"; -// case OMX_EventComponentResumed: return "ComponentResumed"; -// case OMX_EventDynamicResourcesAvailable: return "DynamicResourcesAvailable"; -// case OMX_EventPortFormatDetected: return "PortFormatDetected"; - case OMX_EventOutputRendered: return "OutputRendered"; - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_CORE_H - -#endif // OMX_Core_h - -#ifdef OMX_Image_h -/* asString definitions if media/openmax/OMX_Image.h was included */ - -#ifndef AS_STRING_FOR_OMX_IMAGE_H -#define AS_STRING_FOR_OMX_IMAGE_H - -inline static const char *asString(OMX_IMAGE_CODINGTYPE i, const char *def = "??") { - switch (i) { - case OMX_IMAGE_CodingUnused: return "Unused"; - case OMX_IMAGE_CodingAutoDetect: return "AutoDetect"; // unused - case OMX_IMAGE_CodingJPEG: return "JPEG"; - case OMX_IMAGE_CodingJPEG2K: return "JPEG2K"; // unused - case OMX_IMAGE_CodingEXIF: return "EXIF"; // unused - case OMX_IMAGE_CodingTIFF: return "TIFF"; // unused - case OMX_IMAGE_CodingGIF: return "GIF"; // unused - case OMX_IMAGE_CodingPNG: return "PNG"; // unused - case OMX_IMAGE_CodingLZW: return "LZW"; // unused - case OMX_IMAGE_CodingBMP: return "BMP"; // unused - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_IMAGE_H - -#endif // OMX_Image_h - -#ifdef OMX_Index_h -/* asString definitions if media/openmax/OMX_Index.h was included */ - -#ifndef AS_STRING_FOR_OMX_INDEX_H -#define AS_STRING_FOR_OMX_INDEX_H - -inline static const char *asString(OMX_INDEXTYPE i, const char *def = "??") { - switch (i) { -// case OMX_IndexParamPriorityMgmt: return "ParamPriorityMgmt"; -// case OMX_IndexParamAudioInit: return "ParamAudioInit"; -// case OMX_IndexParamImageInit: return "ParamImageInit"; -// case OMX_IndexParamVideoInit: return "ParamVideoInit"; -// case OMX_IndexParamOtherInit: return "ParamOtherInit"; -// case OMX_IndexParamNumAvailableStreams: return "ParamNumAvailableStreams"; -// case OMX_IndexParamActiveStream: return "ParamActiveStream"; -// case OMX_IndexParamSuspensionPolicy: return "ParamSuspensionPolicy"; -// case OMX_IndexParamComponentSuspended: return "ParamComponentSuspended"; -// case OMX_IndexConfigCapturing: return "ConfigCapturing"; -// case OMX_IndexConfigCaptureMode: return "ConfigCaptureMode"; -// case OMX_IndexAutoPauseAfterCapture: return "AutoPauseAfterCapture"; -// case OMX_IndexParamContentURI: return "ParamContentURI"; -// case OMX_IndexParamCustomContentPipe: return "ParamCustomContentPipe"; -// case OMX_IndexParamDisableResourceConcealment: -// return "ParamDisableResourceConcealment"; -// case OMX_IndexConfigMetadataItemCount: return "ConfigMetadataItemCount"; -// case OMX_IndexConfigContainerNodeCount: return "ConfigContainerNodeCount"; -// case OMX_IndexConfigMetadataItem: return "ConfigMetadataItem"; -// case OMX_IndexConfigCounterNodeID: return "ConfigCounterNodeID"; -// case OMX_IndexParamMetadataFilterType: return "ParamMetadataFilterType"; -// case OMX_IndexParamMetadataKeyFilter: return "ParamMetadataKeyFilter"; -// case OMX_IndexConfigPriorityMgmt: return "ConfigPriorityMgmt"; - case OMX_IndexParamStandardComponentRole: return "ParamStandardComponentRole"; - case OMX_IndexParamPortDefinition: return "ParamPortDefinition"; -// case OMX_IndexParamCompBufferSupplier: return "ParamCompBufferSupplier"; - case OMX_IndexParamAudioPortFormat: return "ParamAudioPortFormat"; - case OMX_IndexParamAudioPcm: return "ParamAudioPcm"; - case OMX_IndexParamAudioAac: return "ParamAudioAac"; -// case OMX_IndexParamAudioRa: return "ParamAudioRa"; - case OMX_IndexParamAudioMp3: return "ParamAudioMp3"; -// case OMX_IndexParamAudioAdpcm: return "ParamAudioAdpcm"; -// case OMX_IndexParamAudioG723: return "ParamAudioG723"; -// case OMX_IndexParamAudioG729: return "ParamAudioG729"; - case OMX_IndexParamAudioAmr: return "ParamAudioAmr"; -// case OMX_IndexParamAudioWma: return "ParamAudioWma"; -// case OMX_IndexParamAudioSbc: return "ParamAudioSbc"; -// case OMX_IndexParamAudioMidi: return "ParamAudioMidi"; -// case OMX_IndexParamAudioGsm_FR: return "ParamAudioGsm_FR"; -// case OMX_IndexParamAudioMidiLoadUserSound: return "ParamAudioMidiLoadUserSound"; -// case OMX_IndexParamAudioG726: return "ParamAudioG726"; -// case OMX_IndexParamAudioGsm_EFR: return "ParamAudioGsm_EFR"; -// case OMX_IndexParamAudioGsm_HR: return "ParamAudioGsm_HR"; -// case OMX_IndexParamAudioPdc_FR: return "ParamAudioPdc_FR"; -// case OMX_IndexParamAudioPdc_EFR: return "ParamAudioPdc_EFR"; -// case OMX_IndexParamAudioPdc_HR: return "ParamAudioPdc_HR"; -// case OMX_IndexParamAudioTdma_FR: return "ParamAudioTdma_FR"; -// case OMX_IndexParamAudioTdma_EFR: return "ParamAudioTdma_EFR"; -// case OMX_IndexParamAudioQcelp8: return "ParamAudioQcelp8"; -// case OMX_IndexParamAudioQcelp13: return "ParamAudioQcelp13"; -// case OMX_IndexParamAudioEvrc: return "ParamAudioEvrc"; -// case OMX_IndexParamAudioSmv: return "ParamAudioSmv"; - case OMX_IndexParamAudioVorbis: return "ParamAudioVorbis"; - case OMX_IndexParamAudioFlac: return "ParamAudioFlac"; -// case OMX_IndexConfigAudioMidiImmediateEvent: return "ConfigAudioMidiImmediateEvent"; -// case OMX_IndexConfigAudioMidiControl: return "ConfigAudioMidiControl"; -// case OMX_IndexConfigAudioMidiSoundBankProgram: -// return "ConfigAudioMidiSoundBankProgram"; -// case OMX_IndexConfigAudioMidiStatus: return "ConfigAudioMidiStatus"; -// case OMX_IndexConfigAudioMidiMetaEvent: return "ConfigAudioMidiMetaEvent"; -// case OMX_IndexConfigAudioMidiMetaEventData: return "ConfigAudioMidiMetaEventData"; -// case OMX_IndexConfigAudioVolume: return "ConfigAudioVolume"; -// case OMX_IndexConfigAudioBalance: return "ConfigAudioBalance"; -// case OMX_IndexConfigAudioChannelMute: return "ConfigAudioChannelMute"; -// case OMX_IndexConfigAudioMute: return "ConfigAudioMute"; -// case OMX_IndexConfigAudioLoudness: return "ConfigAudioLoudness"; -// case OMX_IndexConfigAudioEchoCancelation: return "ConfigAudioEchoCancelation"; -// case OMX_IndexConfigAudioNoiseReduction: return "ConfigAudioNoiseReduction"; -// case OMX_IndexConfigAudioBass: return "ConfigAudioBass"; -// case OMX_IndexConfigAudioTreble: return "ConfigAudioTreble"; -// case OMX_IndexConfigAudioStereoWidening: return "ConfigAudioStereoWidening"; -// case OMX_IndexConfigAudioChorus: return "ConfigAudioChorus"; -// case OMX_IndexConfigAudioEqualizer: return "ConfigAudioEqualizer"; -// case OMX_IndexConfigAudioReverberation: return "ConfigAudioReverberation"; -// case OMX_IndexConfigAudioChannelVolume: return "ConfigAudioChannelVolume"; -// case OMX_IndexParamImagePortFormat: return "ParamImagePortFormat"; -// case OMX_IndexParamFlashControl: return "ParamFlashControl"; -// case OMX_IndexConfigFocusControl: return "ConfigFocusControl"; -// case OMX_IndexParamQFactor: return "ParamQFactor"; -// case OMX_IndexParamQuantizationTable: return "ParamQuantizationTable"; -// case OMX_IndexParamHuffmanTable: return "ParamHuffmanTable"; -// case OMX_IndexConfigFlashControl: return "ConfigFlashControl"; - case OMX_IndexParamVideoPortFormat: return "ParamVideoPortFormat"; -// case OMX_IndexParamVideoQuantization: return "ParamVideoQuantization"; -// case OMX_IndexParamVideoFastUpdate: return "ParamVideoFastUpdate"; - case OMX_IndexParamVideoBitrate: return "ParamVideoBitrate"; -// case OMX_IndexParamVideoMotionVector: return "ParamVideoMotionVector"; - case OMX_IndexParamVideoIntraRefresh: return "ParamVideoIntraRefresh"; - case OMX_IndexParamVideoErrorCorrection: return "ParamVideoErrorCorrection"; -// case OMX_IndexParamVideoVBSMC: return "ParamVideoVBSMC"; -// case OMX_IndexParamVideoMpeg2: return "ParamVideoMpeg2"; - case OMX_IndexParamVideoMpeg4: return "ParamVideoMpeg4"; -// case OMX_IndexParamVideoWmv: return "ParamVideoWmv"; -// case OMX_IndexParamVideoRv: return "ParamVideoRv"; - case OMX_IndexParamVideoAvc: return "ParamVideoAvc"; - case OMX_IndexParamVideoH263: return "ParamVideoH263"; - case OMX_IndexParamVideoProfileLevelQuerySupported: - return "ParamVideoProfileLevelQuerySupported"; - case OMX_IndexParamVideoProfileLevelCurrent: return "ParamVideoProfileLevelCurrent"; - case OMX_IndexConfigVideoBitrate: return "ConfigVideoBitrate"; -// case OMX_IndexConfigVideoFramerate: return "ConfigVideoFramerate"; - case OMX_IndexConfigVideoIntraVOPRefresh: return "ConfigVideoIntraVOPRefresh"; -// case OMX_IndexConfigVideoIntraMBRefresh: return "ConfigVideoIntraMBRefresh"; -// case OMX_IndexConfigVideoMBErrorReporting: return "ConfigVideoMBErrorReporting"; -// case OMX_IndexParamVideoMacroblocksPerFrame: return "ParamVideoMacroblocksPerFrame"; -// case OMX_IndexConfigVideoMacroBlockErrorMap: return "ConfigVideoMacroBlockErrorMap"; -// case OMX_IndexParamVideoSliceFMO: return "ParamVideoSliceFMO"; -// case OMX_IndexConfigVideoAVCIntraPeriod: return "ConfigVideoAVCIntraPeriod"; -// case OMX_IndexConfigVideoNalSize: return "ConfigVideoNalSize"; -// case OMX_IndexParamCommonDeblocking: return "ParamCommonDeblocking"; -// case OMX_IndexParamCommonSensorMode: return "ParamCommonSensorMode"; -// case OMX_IndexParamCommonInterleave: return "ParamCommonInterleave"; -// case OMX_IndexConfigCommonColorFormatConversion: -// return "ConfigCommonColorFormatConversion"; - case OMX_IndexConfigCommonScale: return "ConfigCommonScale"; -// case OMX_IndexConfigCommonImageFilter: return "ConfigCommonImageFilter"; -// case OMX_IndexConfigCommonColorEnhancement: return "ConfigCommonColorEnhancement"; -// case OMX_IndexConfigCommonColorKey: return "ConfigCommonColorKey"; -// case OMX_IndexConfigCommonColorBlend: return "ConfigCommonColorBlend"; -// case OMX_IndexConfigCommonFrameStabilisation: return "ConfigCommonFrameStabilisation"; -// case OMX_IndexConfigCommonRotate: return "ConfigCommonRotate"; -// case OMX_IndexConfigCommonMirror: return "ConfigCommonMirror"; -// case OMX_IndexConfigCommonOutputPosition: return "ConfigCommonOutputPosition"; - case OMX_IndexConfigCommonInputCrop: return "ConfigCommonInputCrop"; - case OMX_IndexConfigCommonOutputCrop: return "ConfigCommonOutputCrop"; -// case OMX_IndexConfigCommonDigitalZoom: return "ConfigCommonDigitalZoom"; -// case OMX_IndexConfigCommonOpticalZoom: return "ConfigCommonOpticalZoom"; -// case OMX_IndexConfigCommonWhiteBalance: return "ConfigCommonWhiteBalance"; -// case OMX_IndexConfigCommonExposure: return "ConfigCommonExposure"; -// case OMX_IndexConfigCommonContrast: return "ConfigCommonContrast"; -// case OMX_IndexConfigCommonBrightness: return "ConfigCommonBrightness"; -// case OMX_IndexConfigCommonBacklight: return "ConfigCommonBacklight"; -// case OMX_IndexConfigCommonGamma: return "ConfigCommonGamma"; -// case OMX_IndexConfigCommonSaturation: return "ConfigCommonSaturation"; -// case OMX_IndexConfigCommonLightness: return "ConfigCommonLightness"; -// case OMX_IndexConfigCommonExclusionRect: return "ConfigCommonExclusionRect"; -// case OMX_IndexConfigCommonDithering: return "ConfigCommonDithering"; -// case OMX_IndexConfigCommonPlaneBlend: return "ConfigCommonPlaneBlend"; -// case OMX_IndexConfigCommonExposureValue: return "ConfigCommonExposureValue"; -// case OMX_IndexConfigCommonOutputSize: return "ConfigCommonOutputSize"; -// case OMX_IndexParamCommonExtraQuantData: return "ParamCommonExtraQuantData"; -// case OMX_IndexConfigCommonFocusRegion: return "ConfigCommonFocusRegion"; -// case OMX_IndexConfigCommonFocusStatus: return "ConfigCommonFocusStatus"; -// case OMX_IndexConfigCommonTransitionEffect: return "ConfigCommonTransitionEffect"; -// case OMX_IndexParamOtherPortFormat: return "ParamOtherPortFormat"; -// case OMX_IndexConfigOtherPower: return "ConfigOtherPower"; -// case OMX_IndexConfigOtherStats: return "ConfigOtherStats"; -// case OMX_IndexConfigTimeScale: return "ConfigTimeScale"; -// case OMX_IndexConfigTimeClockState: return "ConfigTimeClockState"; -// case OMX_IndexConfigTimeActiveRefClock: return "ConfigTimeActiveRefClock"; -// case OMX_IndexConfigTimeCurrentMediaTime: return "ConfigTimeCurrentMediaTime"; -// case OMX_IndexConfigTimeCurrentWallTime: return "ConfigTimeCurrentWallTime"; -// case OMX_IndexConfigTimeCurrentAudioReference: -// return "ConfigTimeCurrentAudioReference"; -// case OMX_IndexConfigTimeCurrentVideoReference: -// return "ConfigTimeCurrentVideoReference"; -// case OMX_IndexConfigTimeMediaTimeRequest: return "ConfigTimeMediaTimeRequest"; -// case OMX_IndexConfigTimeClientStartTime: return "ConfigTimeClientStartTime"; -// case OMX_IndexConfigTimePosition: return "ConfigTimePosition"; -// case OMX_IndexConfigTimeSeekMode: return "ConfigTimeSeekMode"; - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_INDEX_H - -#endif // OMX_Index_h - -#ifdef OMX_IndexExt_h -/* asString definitions if media/openmax/OMX_IndexExt.h was included */ - -#ifndef AS_STRING_FOR_OMX_INDEXEXT_H -#define AS_STRING_FOR_OMX_INDEXEXT_H - -inline static const char *asString(OMX_INDEXEXTTYPE i, const char *def = "??") { - switch (i) { -// case OMX_IndexConfigCallbackRequest: return "ConfigCallbackRequest"; -// case OMX_IndexConfigCommitMode: return "ConfigCommitMode"; -// case OMX_IndexConfigCommit: return "ConfigCommit"; - case OMX_IndexParamAudioAndroidAc3: return "ParamAudioAndroidAc3"; - case OMX_IndexParamAudioAndroidOpus: return "ParamAudioAndroidOpus"; - case OMX_IndexParamAudioAndroidAacPresentation: return "ParamAudioAndroidAacPresentation"; -// case OMX_IndexParamNalStreamFormatSupported: return "ParamNalStreamFormatSupported"; -// case OMX_IndexParamNalStreamFormat: return "ParamNalStreamFormat"; -// case OMX_IndexParamNalStreamFormatSelect: return "ParamNalStreamFormatSelect"; - case OMX_IndexParamVideoVp8: return "ParamVideoVp8"; -// case OMX_IndexConfigVideoVp8ReferenceFrame: return "ConfigVideoVp8ReferenceFrame"; -// case OMX_IndexConfigVideoVp8ReferenceFrameType: return "ConfigVideoVp8ReferenceFrameType"; - case OMX_IndexParamVideoAndroidVp8Encoder: return "ParamVideoAndroidVp8Encoder"; - case OMX_IndexParamVideoHevc: return "ParamVideoHevc"; -// case OMX_IndexParamSliceSegments: return "ParamSliceSegments"; - case OMX_IndexConfigAutoFramerateConversion: return "ConfigAutoFramerateConversion"; - case OMX_IndexConfigPriority: return "ConfigPriority"; - case OMX_IndexConfigOperatingRate: return "ConfigOperatingRate"; - case OMX_IndexParamConsumerUsageBits: return "ParamConsumerUsageBits"; - default: return asString((OMX_INDEXTYPE)i, def); - } -} - -#endif // AS_STRING_FOR_OMX_INDEXEXT_H - -#endif // OMX_IndexExt_h - -#ifdef OMX_IVCommon_h -/* asString definitions if media/openmax/OMX_IVCommon.h was included */ - -#ifndef AS_STRING_FOR_OMX_IVCOMMON_H -#define AS_STRING_FOR_OMX_IVCOMMON_H - -inline static const char *asString(OMX_COLOR_FORMATTYPE i, const char *def = "??") { - switch (i) { - case OMX_COLOR_FormatUnused: - return "COLOR_FormatUnused"; - case OMX_COLOR_FormatMonochrome: - return "COLOR_FormatMonochrome"; - case OMX_COLOR_Format8bitRGB332: - return "COLOR_Format8bitRGB332"; - case OMX_COLOR_Format12bitRGB444: - return "COLOR_Format12bitRGB444"; - case OMX_COLOR_Format16bitARGB4444: - return "COLOR_Format16bitARGB4444"; - case OMX_COLOR_Format16bitARGB1555: - return "COLOR_Format16bitARGB1555"; - case OMX_COLOR_Format16bitRGB565: - return "COLOR_Format16bitRGB565"; - case OMX_COLOR_Format16bitBGR565: - return "COLOR_Format16bitBGR565"; - case OMX_COLOR_Format18bitRGB666: - return "COLOR_Format18bitRGB666"; - case OMX_COLOR_Format18bitARGB1665: - return "COLOR_Format18bitARGB1665"; - case OMX_COLOR_Format19bitARGB1666: - return "COLOR_Format19bitARGB1666"; - case OMX_COLOR_Format24bitRGB888: - return "COLOR_Format24bitRGB888"; - case OMX_COLOR_Format24bitBGR888: - return "COLOR_Format24bitBGR888"; - case OMX_COLOR_Format24bitARGB1887: - return "COLOR_Format24bitARGB1887"; - case OMX_COLOR_Format25bitARGB1888: - return "COLOR_Format25bitARGB1888"; - case OMX_COLOR_Format32bitBGRA8888: - return "COLOR_Format32bitBGRA8888"; - case OMX_COLOR_Format32bitARGB8888: - return "COLOR_Format32bitARGB8888"; - case OMX_COLOR_FormatYUV411Planar: - return "COLOR_FormatYUV411Planar"; - case OMX_COLOR_FormatYUV411PackedPlanar: - return "COLOR_FormatYUV411PackedPlanar"; - case OMX_COLOR_FormatYUV420Planar: - return "COLOR_FormatYUV420Planar"; - case OMX_COLOR_FormatYUV420PackedPlanar: - return "COLOR_FormatYUV420PackedPlanar"; - case OMX_COLOR_FormatYUV420SemiPlanar: - return "COLOR_FormatYUV420SemiPlanar"; - case OMX_COLOR_FormatYUV422Planar: - return "COLOR_FormatYUV422Planar"; - case OMX_COLOR_FormatYUV422PackedPlanar: - return "COLOR_FormatYUV422PackedPlanar"; - case OMX_COLOR_FormatYUV422SemiPlanar: - return "COLOR_FormatYUV422SemiPlanar"; - case OMX_COLOR_FormatYCbYCr: - return "COLOR_FormatYCbYCr"; - case OMX_COLOR_FormatYCrYCb: - return "COLOR_FormatYCrYCb"; - case OMX_COLOR_FormatCbYCrY: - return "COLOR_FormatCbYCrY"; - case OMX_COLOR_FormatCrYCbY: - return "COLOR_FormatCrYCbY"; - case OMX_COLOR_FormatYUV444Interleaved: - return "COLOR_FormatYUV444Interleaved"; - case OMX_COLOR_FormatRawBayer8bit: - return "COLOR_FormatRawBayer8bit"; - case OMX_COLOR_FormatRawBayer10bit: - return "COLOR_FormatRawBayer10bit"; - case OMX_COLOR_FormatRawBayer8bitcompressed: - return "COLOR_FormatRawBayer8bitcompressed"; - case OMX_COLOR_FormatL2: - return "COLOR_FormatL2"; - case OMX_COLOR_FormatL4: - return "COLOR_FormatL4"; - case OMX_COLOR_FormatL8: - return "COLOR_FormatL8"; - case OMX_COLOR_FormatL16: - return "COLOR_FormatL16"; - case OMX_COLOR_FormatL24: - return "COLOR_FormatL24"; - case OMX_COLOR_FormatL32: - return "COLOR_FormatL32"; - case OMX_COLOR_FormatYUV420PackedSemiPlanar: - return "COLOR_FormatYUV420PackedSemiPlanar"; - case OMX_COLOR_FormatYUV422PackedSemiPlanar: - return "COLOR_FormatYUV422PackedSemiPlanar"; - case OMX_COLOR_Format18BitBGR666: - return "COLOR_Format18BitBGR666"; - case OMX_COLOR_Format24BitARGB6666: - return "COLOR_Format24BitARGB6666"; - case OMX_COLOR_Format24BitABGR6666: - return "COLOR_Format24BitABGR6666"; - case OMX_COLOR_FormatAndroidOpaque: - return "COLOR_FormatAndroidOpaque"; - case OMX_COLOR_FormatYUV420Flexible: - return "COLOR_FormatYUV420Flexible"; - case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar: - return "TI_COLOR_FormatYUV420PackedSemiPlanar"; - case OMX_QCOM_COLOR_FormatYVU420SemiPlanar: - return "QCOM_COLOR_FormatYVU420SemiPlanar"; -// case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: -// return "QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka"; -// case OMX_SEC_COLOR_FormatNV12Tiled: -// return "SEC_COLOR_FormatNV12Tiled"; -// case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m: -// return "QCOM_COLOR_FormatYUV420PackedSemiPlanar32m"; - default: - return def; - } -} - -#endif // AS_STRING_FOR_OMX_IVCOMMON_H - -#endif // OMX_IVCommon_h - -#ifdef OMX_Types_h -/* asString definitions if media/openmax/OMX_Types.h was included */ - -#ifndef AS_STRING_FOR_OMX_TYPES_H -#define AS_STRING_FOR_OMX_TYPES_H - -inline static const char *asString(OMX_BOOL i, const char *def = "??") { - switch (i) { - case OMX_FALSE: return "FALSE"; - case OMX_TRUE: return "TRUE"; - default: return def; - } -} - -inline static const char *asString(OMX_DIRTYPE i, const char *def = "??") { - switch (i) { - case OMX_DirInput: return "Input"; - case OMX_DirOutput: return "Output"; - default: return def; - } -} - -inline static const char *asString(OMX_ENDIANTYPE i, const char *def = "??") { - switch (i) { - case OMX_EndianBig: return "Big"; -// case OMX_EndianLittle: return "Little"; - default: return def; - } -} - -inline static const char *asString(OMX_NUMERICALDATATYPE i, const char *def = "??") { - switch (i) { - case OMX_NumericalDataSigned: return "Signed"; -// case OMX_NumericalDataUnsigned: return "Unsigned"; - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_TYPES_H - -#endif // OMX_Types_h - -#ifdef OMX_Video_h -/* asString definitions if media/openmax/OMX_Video.h was included */ - -#ifndef AS_STRING_FOR_OMX_VIDEO_H -#define AS_STRING_FOR_OMX_VIDEO_H - -inline static const char *asString(OMX_VIDEO_CODINGTYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_CodingUnused: return "Unused"; - case OMX_VIDEO_CodingAutoDetect: return "AutoDetect"; // unused - case OMX_VIDEO_CodingMPEG2: return "MPEG2"; - case OMX_VIDEO_CodingH263: return "H263"; - case OMX_VIDEO_CodingMPEG4: return "MPEG4"; - case OMX_VIDEO_CodingWMV: return "WMV"; // unused - case OMX_VIDEO_CodingRV: return "RV"; // unused - case OMX_VIDEO_CodingAVC: return "AVC"; - case OMX_VIDEO_CodingMJPEG: return "MJPEG"; // unused - case OMX_VIDEO_CodingVP8: return "VP8"; - case OMX_VIDEO_CodingVP9: return "VP9"; - case OMX_VIDEO_CodingHEVC: return "HEVC"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_CONTROLRATETYPE i, const char *def = "??") { - switch (i) { -// case OMX_Video_ControlRateDisable: return "Disable"; - case OMX_Video_ControlRateVariable: return "Variable"; - case OMX_Video_ControlRateConstant: return "Constant"; -// case OMX_Video_ControlRateVariableSkipFrames: return "VariableSkipFrames"; -// case OMX_Video_ControlRateConstantSkipFrames: return "ConstantSkipFrames"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_INTRAREFRESHTYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_IntraRefreshCyclic: return "Cyclic"; - case OMX_VIDEO_IntraRefreshAdaptive: return "Adaptive"; - case OMX_VIDEO_IntraRefreshBoth: return "Both"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_H263PROFILETYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_H263ProfileBaseline: return "Baseline"; - case OMX_VIDEO_H263ProfileH320Coding: return "H320Coding"; - case OMX_VIDEO_H263ProfileBackwardCompatible: return "BackwardCompatible"; - case OMX_VIDEO_H263ProfileISWV2: return "ISWV2"; - case OMX_VIDEO_H263ProfileISWV3: return "ISWV3"; - case OMX_VIDEO_H263ProfileHighCompression: return "HighCompression"; - case OMX_VIDEO_H263ProfileInternet: return "Internet"; - case OMX_VIDEO_H263ProfileInterlace: return "Interlace"; - case OMX_VIDEO_H263ProfileHighLatency: return "HighLatency"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_H263LEVELTYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_H263Level10: return "Level10"; - case OMX_VIDEO_H263Level20: return "Level20"; - case OMX_VIDEO_H263Level30: return "Level30"; - case OMX_VIDEO_H263Level40: return "Level40"; - case OMX_VIDEO_H263Level45: return "Level45"; - case OMX_VIDEO_H263Level50: return "Level50"; - case OMX_VIDEO_H263Level60: return "Level60"; - case OMX_VIDEO_H263Level70: return "Level70"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_PICTURETYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_PictureTypeI: return "I"; - case OMX_VIDEO_PictureTypeP: return "P"; - case OMX_VIDEO_PictureTypeB: return "B"; -// case OMX_VIDEO_PictureTypeSI: return "SI"; -// case OMX_VIDEO_PictureTypeSP: return "SP"; -// case OMX_VIDEO_PictureTypeEI: return "EI"; -// case OMX_VIDEO_PictureTypeEP: return "EP"; -// case OMX_VIDEO_PictureTypeS: return "S"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_MPEG4PROFILETYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_MPEG4ProfileSimple: return "Simple"; - case OMX_VIDEO_MPEG4ProfileSimpleScalable: return "SimpleScalable"; - case OMX_VIDEO_MPEG4ProfileCore: return "Core"; - case OMX_VIDEO_MPEG4ProfileMain: return "Main"; - case OMX_VIDEO_MPEG4ProfileNbit: return "Nbit"; - case OMX_VIDEO_MPEG4ProfileScalableTexture: return "ScalableTexture"; - case OMX_VIDEO_MPEG4ProfileSimpleFace: return "SimpleFace"; - case OMX_VIDEO_MPEG4ProfileSimpleFBA: return "SimpleFBA"; - case OMX_VIDEO_MPEG4ProfileBasicAnimated: return "BasicAnimated"; - case OMX_VIDEO_MPEG4ProfileHybrid: return "Hybrid"; - case OMX_VIDEO_MPEG4ProfileAdvancedRealTime: return "AdvancedRealTime"; - case OMX_VIDEO_MPEG4ProfileCoreScalable: return "CoreScalable"; - case OMX_VIDEO_MPEG4ProfileAdvancedCoding: return "AdvancedCoding"; - case OMX_VIDEO_MPEG4ProfileAdvancedCore: return "AdvancedCore"; - case OMX_VIDEO_MPEG4ProfileAdvancedScalable: return "AdvancedScalable"; - case OMX_VIDEO_MPEG4ProfileAdvancedSimple: return "AdvancedSimple"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_MPEG4LEVELTYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_MPEG4Level0: return "Level0"; - case OMX_VIDEO_MPEG4Level0b: return "Level0b"; - case OMX_VIDEO_MPEG4Level1: return "Level1"; - case OMX_VIDEO_MPEG4Level2: return "Level2"; - case OMX_VIDEO_MPEG4Level3: return "Level3"; - case OMX_VIDEO_MPEG4Level4: return "Level4"; - case OMX_VIDEO_MPEG4Level4a: return "Level4a"; - case OMX_VIDEO_MPEG4Level5: return "Level5"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_AVCPROFILETYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_AVCProfileBaseline: return "Baseline"; - case OMX_VIDEO_AVCProfileMain: return "Main"; - case OMX_VIDEO_AVCProfileExtended: return "Extended"; - case OMX_VIDEO_AVCProfileHigh: return "High"; - case OMX_VIDEO_AVCProfileHigh10: return "High10"; - case OMX_VIDEO_AVCProfileHigh422: return "High422"; - case OMX_VIDEO_AVCProfileHigh444: return "High444"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_AVCLEVELTYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_AVCLevel1: return "Level1"; - case OMX_VIDEO_AVCLevel1b: return "Level1b"; - case OMX_VIDEO_AVCLevel11: return "Level11"; - case OMX_VIDEO_AVCLevel12: return "Level12"; - case OMX_VIDEO_AVCLevel13: return "Level13"; - case OMX_VIDEO_AVCLevel2: return "Level2"; - case OMX_VIDEO_AVCLevel21: return "Level21"; - case OMX_VIDEO_AVCLevel22: return "Level22"; - case OMX_VIDEO_AVCLevel3: return "Level3"; - case OMX_VIDEO_AVCLevel31: return "Level31"; - case OMX_VIDEO_AVCLevel32: return "Level32"; - case OMX_VIDEO_AVCLevel4: return "Level4"; - case OMX_VIDEO_AVCLevel41: return "Level41"; - case OMX_VIDEO_AVCLevel42: return "Level42"; - case OMX_VIDEO_AVCLevel5: return "Level5"; - case OMX_VIDEO_AVCLevel51: return "Level51"; - case OMX_VIDEO_AVCLevel52: return "Level52"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_AVCLOOPFILTERTYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_AVCLoopFilterEnable: return "Enable"; -// case OMX_VIDEO_AVCLoopFilterDisable: return "Disable"; -// case OMX_VIDEO_AVCLoopFilterDisableSliceBoundary: return "DisableSliceBoundary"; - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_VIDEO_H - -#endif // OMX_Video_h - -#ifdef OMX_VideoExt_h -/* asString definitions if media/openmax/OMX_VideoExt.h was included */ - -#ifndef AS_STRING_FOR_OMX_VIDEOEXT_H -#define AS_STRING_FOR_OMX_VIDEOEXT_H - -inline static const char *asString(OMX_VIDEO_VP8PROFILETYPE i, const char *def = "!!") { - switch (i) { - case OMX_VIDEO_VP8ProfileMain: return "Main"; - case OMX_VIDEO_VP8ProfileUnknown: return "Unknown"; // unused - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_VP8LEVELTYPE i, const char *def = "!!") { - switch (i) { - case OMX_VIDEO_VP8Level_Version0: return "_Version0"; - case OMX_VIDEO_VP8Level_Version1: return "_Version1"; - case OMX_VIDEO_VP8Level_Version2: return "_Version2"; - case OMX_VIDEO_VP8Level_Version3: return "_Version3"; - case OMX_VIDEO_VP8LevelUnknown: return "Unknown"; // unused - default: return def; - } -} - -inline static const char *asString( - OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE i, const char *def = "??") { - switch (i) { - case OMX_VIDEO_VPXTemporalLayerPatternNone: return "VPXTemporalLayerPatternNone"; - case OMX_VIDEO_VPXTemporalLayerPatternWebRTC: return "VPXTemporalLayerPatternWebRTC"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_HEVCPROFILETYPE i, const char *def = "!!") { - switch (i) { - case OMX_VIDEO_HEVCProfileUnknown: return "Unknown"; // unused - case OMX_VIDEO_HEVCProfileMain: return "Main"; - case OMX_VIDEO_HEVCProfileMain10: return "Main10"; - default: return def; - } -} - -inline static const char *asString(OMX_VIDEO_HEVCLEVELTYPE i, const char *def = "!!") { - switch (i) { - case OMX_VIDEO_HEVCLevelUnknown: return "LevelUnknown"; // unused - case OMX_VIDEO_HEVCMainTierLevel1: return "MainTierLevel1"; - case OMX_VIDEO_HEVCHighTierLevel1: return "HighTierLevel1"; - case OMX_VIDEO_HEVCMainTierLevel2: return "MainTierLevel2"; - case OMX_VIDEO_HEVCHighTierLevel2: return "HighTierLevel2"; - case OMX_VIDEO_HEVCMainTierLevel21: return "MainTierLevel21"; - case OMX_VIDEO_HEVCHighTierLevel21: return "HighTierLevel21"; - case OMX_VIDEO_HEVCMainTierLevel3: return "MainTierLevel3"; - case OMX_VIDEO_HEVCHighTierLevel3: return "HighTierLevel3"; - case OMX_VIDEO_HEVCMainTierLevel31: return "MainTierLevel31"; - case OMX_VIDEO_HEVCHighTierLevel31: return "HighTierLevel31"; - case OMX_VIDEO_HEVCMainTierLevel4: return "MainTierLevel4"; - case OMX_VIDEO_HEVCHighTierLevel4: return "HighTierLevel4"; - case OMX_VIDEO_HEVCMainTierLevel41: return "MainTierLevel41"; - case OMX_VIDEO_HEVCHighTierLevel41: return "HighTierLevel41"; - case OMX_VIDEO_HEVCMainTierLevel5: return "MainTierLevel5"; - case OMX_VIDEO_HEVCHighTierLevel5: return "HighTierLevel5"; - case OMX_VIDEO_HEVCMainTierLevel51: return "MainTierLevel51"; - case OMX_VIDEO_HEVCHighTierLevel51: return "HighTierLevel51"; - case OMX_VIDEO_HEVCMainTierLevel52: return "MainTierLevel52"; - case OMX_VIDEO_HEVCHighTierLevel52: return "HighTierLevel52"; - case OMX_VIDEO_HEVCMainTierLevel6: return "MainTierLevel6"; - case OMX_VIDEO_HEVCHighTierLevel6: return "HighTierLevel6"; - case OMX_VIDEO_HEVCMainTierLevel61: return "MainTierLevel61"; - case OMX_VIDEO_HEVCHighTierLevel61: return "HighTierLevel61"; - case OMX_VIDEO_HEVCMainTierLevel62: return "MainTierLevel62"; - case OMX_VIDEO_HEVCHighTierLevel62: return "HighTierLevel62"; - default: return def; - } -} - -#endif // AS_STRING_FOR_OMX_VIDEOEXT_H - -#endif // OMX_VideoExt_h diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Audio.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_Audio.h deleted file mode 100644 index a0cbd3bb990c0f..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Audio.h +++ /dev/null @@ -1,1342 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/* - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** @file OMX_Audio.h - OpenMax IL version 1.1.2 - * The structures needed by Audio components to exchange - * parameters and configuration data with the componenmilts. - */ - -#ifndef OMX_Audio_h -#define OMX_Audio_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Each OMX header must include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ - -#include - -/** @defgroup midi MIDI - * @ingroup audio - */ - -/** @defgroup effects Audio effects - * @ingroup audio - */ - -/** @defgroup audio OpenMAX IL Audio Domain - * Structures for OpenMAX IL Audio domain - * @{ - */ - -/** Enumeration used to define the possible audio codings. - * If "OMX_AUDIO_CodingUnused" is selected, the coding selection must - * be done in a vendor specific way. Since this is for an audio - * processing element this enum is relevant. However, for another - * type of component other enums would be in this area. - */ -typedef enum OMX_AUDIO_CODINGTYPE { - OMX_AUDIO_CodingUnused = 0, /**< Placeholder value when coding is N/A */ - OMX_AUDIO_CodingAutoDetect, /**< auto detection of audio format */ - OMX_AUDIO_CodingPCM, /**< Any variant of PCM coding */ - OMX_AUDIO_CodingADPCM, /**< Any variant of ADPCM encoded data */ - OMX_AUDIO_CodingAMR, /**< Any variant of AMR encoded data */ - OMX_AUDIO_CodingGSMFR, /**< Any variant of GSM fullrate (i.e. GSM610) */ - OMX_AUDIO_CodingGSMEFR, /**< Any variant of GSM Enhanced Fullrate encoded data*/ - OMX_AUDIO_CodingGSMHR, /**< Any variant of GSM Halfrate encoded data */ - OMX_AUDIO_CodingPDCFR, /**< Any variant of PDC Fullrate encoded data */ - OMX_AUDIO_CodingPDCEFR, /**< Any variant of PDC Enhanced Fullrate encoded data */ - OMX_AUDIO_CodingPDCHR, /**< Any variant of PDC Halfrate encoded data */ - OMX_AUDIO_CodingTDMAFR, /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */ - OMX_AUDIO_CodingTDMAEFR, /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */ - OMX_AUDIO_CodingQCELP8, /**< Any variant of QCELP 8kbps encoded data */ - OMX_AUDIO_CodingQCELP13, /**< Any variant of QCELP 13kbps encoded data */ - OMX_AUDIO_CodingEVRC, /**< Any variant of EVRC encoded data */ - OMX_AUDIO_CodingSMV, /**< Any variant of SMV encoded data */ - OMX_AUDIO_CodingG711, /**< Any variant of G.711 encoded data */ - OMX_AUDIO_CodingG723, /**< Any variant of G.723 dot 1 encoded data */ - OMX_AUDIO_CodingG726, /**< Any variant of G.726 encoded data */ - OMX_AUDIO_CodingG729, /**< Any variant of G.729 encoded data */ - OMX_AUDIO_CodingAAC, /**< Any variant of AAC encoded data */ - OMX_AUDIO_CodingMP3, /**< Any variant of MP3 encoded data */ - OMX_AUDIO_CodingSBC, /**< Any variant of SBC encoded data */ - OMX_AUDIO_CodingVORBIS, /**< Any variant of VORBIS encoded data */ - OMX_AUDIO_CodingWMA, /**< Any variant of WMA encoded data */ - OMX_AUDIO_CodingRA, /**< Any variant of RA encoded data */ - OMX_AUDIO_CodingMIDI, /**< Any variant of MIDI encoded data */ - OMX_AUDIO_CodingFLAC, /**< Any variant of FLAC encoded data */ - OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_CodingMax = 0x7FFFFFFF -} OMX_AUDIO_CODINGTYPE; - - -/** The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output audio - * path. If additional information is needed to define the parameters of the - * port (such as frequency), additional structures must be sent such as the - * OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port. - */ -typedef struct OMX_AUDIO_PORTDEFINITIONTYPE { - OMX_STRING cMIMEType; /**< MIME type of data for the port */ - OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference - for an output device, - otherwise this field is 0 */ - OMX_BOOL bFlagErrorConcealment; /**< Turns on error concealment if it is - supported by the OMX component */ - OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this - port (e.g. PCM, AMR, MP3, etc) */ -} OMX_AUDIO_PORTDEFINITIONTYPE; - - -/** Port format parameter. This structure is used to enumerate - * the various data input/output format supported by the port. - */ -typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Indicates which port to set */ - OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ - OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */ -} OMX_AUDIO_PARAM_PORTFORMATTYPE; - - -/** PCM mode type */ -typedef enum OMX_AUDIO_PCMMODETYPE { - OMX_AUDIO_PCMModeLinear = 0, /**< Linear PCM encoded data */ - OMX_AUDIO_PCMModeALaw, /**< A law PCM encoded data (G.711) */ - OMX_AUDIO_PCMModeMULaw, /**< Mu law PCM encoded data (G.711) */ - OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_PCMModeMax = 0x7FFFFFFF -} OMX_AUDIO_PCMMODETYPE; - - -typedef enum OMX_AUDIO_CHANNELTYPE { - OMX_AUDIO_ChannelNone = 0x0, /**< Unused or empty */ - OMX_AUDIO_ChannelLF = 0x1, /**< Left front */ - OMX_AUDIO_ChannelRF = 0x2, /**< Right front */ - OMX_AUDIO_ChannelCF = 0x3, /**< Center front */ - OMX_AUDIO_ChannelLS = 0x4, /**< Left surround */ - OMX_AUDIO_ChannelRS = 0x5, /**< Right surround */ - OMX_AUDIO_ChannelLFE = 0x6, /**< Low frequency effects */ - OMX_AUDIO_ChannelCS = 0x7, /**< Back surround */ - OMX_AUDIO_ChannelLR = 0x8, /**< Left rear. */ - OMX_AUDIO_ChannelRR = 0x9, /**< Right rear. */ - OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_ChannelMax = 0x7FFFFFFF -} OMX_AUDIO_CHANNELTYPE; - -#define OMX_AUDIO_MAXCHANNELS 16 /**< maximum number distinct audio channels that a buffer may contain */ -#define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */ - -/** PCM format description */ -typedef struct OMX_AUDIO_PARAM_PCMMODETYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels (e.g. 2 for stereo) */ - OMX_NUMERICALDATATYPE eNumData; /**< indicates PCM data as signed or unsigned */ - OMX_ENDIANTYPE eEndian; /**< indicates PCM data as little or big endian */ - OMX_BOOL bInterleaved; /**< True for normal interleaved data; false for - non-interleaved data (e.g. block data) */ - OMX_U32 nBitPerSample; /**< Bit per sample */ - OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_AUDIO_PCMMODETYPE ePCMMode; /**< PCM mode enumeration */ - OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */ - -} OMX_AUDIO_PARAM_PCMMODETYPE; - - -/** Audio channel mode. This is used by both AAC and MP3, although the names are more appropriate - * for the MP3. For example, JointStereo for MP3 is CouplingChannels for AAC. - */ -typedef enum OMX_AUDIO_CHANNELMODETYPE { - OMX_AUDIO_ChannelModeStereo = 0, /**< 2 channels, the bitrate allocation between those - two channels changes accordingly to each channel information */ - OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between - 2 channels for higher compression gain */ - OMX_AUDIO_ChannelModeDual, /**< 2 mono-channels, each channel is encoded with half - the bitrate of the overall bitrate */ - OMX_AUDIO_ChannelModeMono, /**< Mono channel mode */ - OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF -} OMX_AUDIO_CHANNELMODETYPE; - - -typedef enum OMX_AUDIO_MP3STREAMFORMATTYPE { - OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */ - OMX_AUDIO_MP3StreamFormatMP2Layer3, /**< MP3 Audio MPEG 2 Layer 3 Stream format */ - OMX_AUDIO_MP3StreamFormatMP2_5Layer3, /**< MP3 Audio MPEG2.5 Layer 3 Stream format */ - OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF -} OMX_AUDIO_MP3STREAMFORMATTYPE; - -/** MP3 params */ -typedef struct OMX_AUDIO_PARAM_MP3TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should - limit the audio signal. Use 0 to let encoder decide */ - OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ - OMX_AUDIO_MP3STREAMFORMATTYPE eFormat; /**< MP3 stream format */ -} OMX_AUDIO_PARAM_MP3TYPE; - - -typedef enum OMX_AUDIO_AACSTREAMFORMATTYPE { - OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */ - OMX_AUDIO_AACStreamFormatMP4ADTS, /**< AAC Audio Data Transport Stream 4 format */ - OMX_AUDIO_AACStreamFormatMP4LOAS, /**< AAC Low Overhead Audio Stream format */ - OMX_AUDIO_AACStreamFormatMP4LATM, /**< AAC Low overhead Audio Transport Multiplex */ - OMX_AUDIO_AACStreamFormatADIF, /**< AAC Audio Data Interchange Format */ - OMX_AUDIO_AACStreamFormatMP4FF, /**< AAC inside MPEG-4/ISO File Format */ - OMX_AUDIO_AACStreamFormatRAW, /**< AAC Raw Format */ - OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF -} OMX_AUDIO_AACSTREAMFORMATTYPE; - - -/** AAC mode type. Note that the term profile is used with the MPEG-2 - * standard and the term object type and profile is used with MPEG-4 */ -typedef enum OMX_AUDIO_AACPROFILETYPE{ - OMX_AUDIO_AACObjectNull = 0, /**< Null, not used */ - OMX_AUDIO_AACObjectMain = 1, /**< AAC Main object */ - OMX_AUDIO_AACObjectLC, /**< AAC Low Complexity object (AAC profile) */ - OMX_AUDIO_AACObjectSSR, /**< AAC Scalable Sample Rate object */ - OMX_AUDIO_AACObjectLTP, /**< AAC Long Term Prediction object */ - OMX_AUDIO_AACObjectHE, /**< AAC High Efficiency (object type SBR, HE-AAC profile) */ - OMX_AUDIO_AACObjectScalable, /**< AAC Scalable object */ - OMX_AUDIO_AACObjectERLC = 17, /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */ - OMX_AUDIO_AACObjectLD = 23, /**< AAC Low Delay object (Error Resilient) */ - OMX_AUDIO_AACObjectHE_PS = 29, /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */ - OMX_AUDIO_AACObjectELD = 39, /** AAC Enhanced Low Delay. NOTE: Pending Khronos standardization **/ - OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AACObjectMax = 0x7FFFFFFF -} OMX_AUDIO_AACPROFILETYPE; - - -/** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE). - * Required for encoder configuration and optional as decoder info output. - * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */ -#define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */ -#define OMX_AUDIO_AACToolMS 0x00000001 /**< MS: Mid/side joint coding tool allowed or active */ -#define OMX_AUDIO_AACToolIS 0x00000002 /**< IS: Intensity stereo tool allowed or active */ -#define OMX_AUDIO_AACToolTNS 0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */ -#define OMX_AUDIO_AACToolPNS 0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */ -#define OMX_AUDIO_AACToolLTP 0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */ -#define OMX_AUDIO_AACToolVendor 0x00010000 /**< NOT A KHRONOS VALUE, offset for vendor-specific additions */ -#define OMX_AUDIO_AACToolAll 0x7FFFFFFF /**< all AAC tools allowed or active (*/ - -/** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE). - * Required for ER encoder configuration and optional as decoder info output */ -#define OMX_AUDIO_AACERNone 0x00000000 /**< no AAC ER tools allowed/used */ -#define OMX_AUDIO_AACERVCB11 0x00000001 /**< VCB11: Virtual Code Books for AAC section data */ -#define OMX_AUDIO_AACERRVLC 0x00000002 /**< RVLC: Reversible Variable Length Coding */ -#define OMX_AUDIO_AACERHCR 0x00000004 /**< HCR: Huffman Codeword Reordering */ -#define OMX_AUDIO_AACERAll 0x7FFFFFFF /**< all AAC ER tools allowed/used */ - - -/** AAC params */ -typedef struct OMX_AUDIO_PARAM_AACPROFILETYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should - limit the audio signal. Use 0 to let encoder decide */ - OMX_U32 nFrameLength; /**< Frame length (in audio samples per channel) of the codec. - Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD). - Use 0 to let encoder decide */ - OMX_U32 nAACtools; /**< AAC tool usage */ - OMX_U32 nAACERtools; /**< MPEG-4 AAC error resilience tool usage */ - OMX_AUDIO_AACPROFILETYPE eAACProfile; /**< AAC profile enumeration */ - OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */ - OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ -} OMX_AUDIO_PARAM_AACPROFILETYPE; - - -/** VORBIS params */ -typedef struct OMX_AUDIO_PARAM_VORBISTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the encoded data data. Use 0 for variable - rate or unknown bit rates. Encoding is set to the - bitrate closest to specified value (in bps) */ - OMX_U32 nMinBitRate; /**< Sets minimum bitrate (in bps). */ - OMX_U32 nMaxBitRate; /**< Sets maximum bitrate (in bps). */ - - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should - limit the audio signal. Use 0 to let encoder decide */ - OMX_S32 nQuality; /**< Sets encoding quality to n, between -1 (low) and 10 (high). - In the default mode of operation, teh quality level is 3. - Normal quality range is 0 - 10. */ - OMX_BOOL bManaged; /**< Set bitrate management mode. This turns off the - normal VBR encoding, but allows hard or soft bitrate - constraints to be enforced by the encoder. This mode can - be slower, and may also be lower quality. It is - primarily useful for streaming. */ - OMX_BOOL bDownmix; /**< Downmix input from stereo to mono (has no effect on - non-stereo streams). Useful for lower-bitrate encoding. */ -} OMX_AUDIO_PARAM_VORBISTYPE; - - -/** FLAC params */ -typedef struct OMX_AUDIO_PARAM_FLACTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - unknown sampling rate. */ - OMX_U32 nCompressionLevel;/**< FLAC compression level, from 0 (fastest compression) - to 8 (highest compression */ -} OMX_AUDIO_PARAM_FLACTYPE; - - -/** WMA Version */ -typedef enum OMX_AUDIO_WMAFORMATTYPE { - OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */ - OMX_AUDIO_WMAFormat7, /**< Windows Media Audio format 7 */ - OMX_AUDIO_WMAFormat8, /**< Windows Media Audio format 8 */ - OMX_AUDIO_WMAFormat9, /**< Windows Media Audio format 9 */ - OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF -} OMX_AUDIO_WMAFORMATTYPE; - - -/** WMA Profile */ -typedef enum OMX_AUDIO_WMAPROFILETYPE { - OMX_AUDIO_WMAProfileUnused = 0, /**< profile unused or unknown */ - OMX_AUDIO_WMAProfileL1, /**< Windows Media audio version 9 profile L1 */ - OMX_AUDIO_WMAProfileL2, /**< Windows Media audio version 9 profile L2 */ - OMX_AUDIO_WMAProfileL3, /**< Windows Media audio version 9 profile L3 */ - OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF -} OMX_AUDIO_WMAPROFILETYPE; - - -/** WMA params */ -typedef struct OMX_AUDIO_PARAM_WMATYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U16 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */ - OMX_AUDIO_WMAPROFILETYPE eProfile; /**< Profile of WMA stream / data */ - OMX_U32 nSamplingRate; /**< Sampling rate of the source data */ - OMX_U16 nBlockAlign; /**< is the block alignment, or block size, in bytes of the audio codec */ - OMX_U16 nEncodeOptions; /**< WMA Type-specific data */ - OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */ -} OMX_AUDIO_PARAM_WMATYPE; - -/** - * RealAudio format - */ -typedef enum OMX_AUDIO_RAFORMATTYPE { - OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */ - OMX_AUDIO_RA8, /**< RealAudio 8 codec */ - OMX_AUDIO_RA9, /**< RealAudio 9 codec */ - OMX_AUDIO_RA10_AAC, /**< MPEG-4 AAC codec for bitrates of more than 128kbps */ - OMX_AUDIO_RA10_CODEC, /**< RealAudio codec for bitrates less than 128 kbps */ - OMX_AUDIO_RA10_LOSSLESS, /**< RealAudio Lossless */ - OMX_AUDIO_RA10_MULTICHANNEL, /**< RealAudio Multichannel */ - OMX_AUDIO_RA10_VOICE, /**< RealAudio Voice for bitrates below 15 kbps */ - OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_RAFormatMax = 0x7FFFFFFF -} OMX_AUDIO_RAFORMATTYPE; - -/** RA (Real Audio) params */ -typedef struct OMX_AUDIO_PARAM_RATYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nSamplingRate; /**< is the sampling rate of the source data */ - OMX_U32 nBitsPerFrame; /**< is the value for bits per frame */ - OMX_U32 nSamplePerFrame; /**< is the value for samples per frame */ - OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ - OMX_U32 nCouplingStartRegion; /**< is the coupling start region in the stream */ - OMX_U32 nNumRegions; /**< is the number of regions value */ - OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */ -} OMX_AUDIO_PARAM_RATYPE; - - -/** SBC Allocation Method Type */ -typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE { - OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */ - OMX_AUDIO_SBCAllocMethodSNR, /**< SNR allocation method */ - OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF -} OMX_AUDIO_SBCALLOCMETHODTYPE; - - -/** SBC params */ -typedef struct OMX_AUDIO_PARAM_SBCTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nBlocks; /**< Number of blocks */ - OMX_U32 nSubbands; /**< Number of subbands */ - OMX_U32 nBitPool; /**< Bitpool value */ - OMX_BOOL bEnableBitrate; /**< Use bitrate value instead of bitpool */ - OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ - OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType; /**< SBC Allocation method type */ -} OMX_AUDIO_PARAM_SBCTYPE; - - -/** ADPCM stream format parameters */ -typedef struct OMX_AUDIO_PARAM_ADPCMTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_U32 nBitsPerSample; /**< Number of bits in each sample */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ -} OMX_AUDIO_PARAM_ADPCMTYPE; - - -/** G723 rate */ -typedef enum OMX_AUDIO_G723RATE { - OMX_AUDIO_G723ModeUnused = 0, /**< AMRNB Mode unused / unknown */ - OMX_AUDIO_G723ModeLow, /**< 5300 bps */ - OMX_AUDIO_G723ModeHigh, /**< 6300 bps */ - OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_G723ModeMax = 0x7FFFFFFF -} OMX_AUDIO_G723RATE; - - -/** G723 - Sample rate must be 8 KHz */ -typedef struct OMX_AUDIO_PARAM_G723TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_AUDIO_G723RATE eBitRate; /**< todo: Should this be moved to a config? */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ - OMX_BOOL bPostFilter; /**< Enable Post Filter */ -} OMX_AUDIO_PARAM_G723TYPE; - - -/** ITU G726 (ADPCM) rate */ -typedef enum OMX_AUDIO_G726MODE { - OMX_AUDIO_G726ModeUnused = 0, /**< G726 Mode unused / unknown */ - OMX_AUDIO_G726Mode16, /**< 16 kbps */ - OMX_AUDIO_G726Mode24, /**< 24 kbps */ - OMX_AUDIO_G726Mode32, /**< 32 kbps, most common rate, also G721 */ - OMX_AUDIO_G726Mode40, /**< 40 kbps */ - OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_G726ModeMax = 0x7FFFFFFF -} OMX_AUDIO_G726MODE; - - -/** G.726 stream format parameters - must be at 8KHz */ -typedef struct OMX_AUDIO_PARAM_G726TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_G726MODE eG726Mode; -} OMX_AUDIO_PARAM_G726TYPE; - - -/** G729 coder type */ -typedef enum OMX_AUDIO_G729TYPE { - OMX_AUDIO_G729 = 0, /**< ITU G.729 encoded data */ - OMX_AUDIO_G729A, /**< ITU G.729 annex A encoded data */ - OMX_AUDIO_G729B, /**< ITU G.729 with annex B encoded data */ - OMX_AUDIO_G729AB, /**< ITU G.729 annexes A and B encoded data */ - OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_G729Max = 0x7FFFFFFF -} OMX_AUDIO_G729TYPE; - - -/** G729 stream format parameters - fixed 6KHz sample rate */ -typedef struct OMX_AUDIO_PARAM_G729TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_AUDIO_G729TYPE eBitType; -} OMX_AUDIO_PARAM_G729TYPE; - - -/** AMR Frame format */ -typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE { - OMX_AUDIO_AMRFrameFormatConformance = 0, /**< Frame Format is AMR Conformance - (Standard) Format */ - OMX_AUDIO_AMRFrameFormatIF1, /**< Frame Format is AMR Interface - Format 1 */ - OMX_AUDIO_AMRFrameFormatIF2, /**< Frame Format is AMR Interface - Format 2*/ - OMX_AUDIO_AMRFrameFormatFSF, /**< Frame Format is AMR File Storage - Format */ - OMX_AUDIO_AMRFrameFormatRTPPayload, /**< Frame Format is AMR Real-Time - Transport Protocol Payload Format */ - OMX_AUDIO_AMRFrameFormatITU, /**< Frame Format is ITU Format (added at Motorola request) */ - OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF -} OMX_AUDIO_AMRFRAMEFORMATTYPE; - - -/** AMR band mode */ -typedef enum OMX_AUDIO_AMRBANDMODETYPE { - OMX_AUDIO_AMRBandModeUnused = 0, /**< AMRNB Mode unused / unknown */ - OMX_AUDIO_AMRBandModeNB0, /**< AMRNB Mode 0 = 4750 bps */ - OMX_AUDIO_AMRBandModeNB1, /**< AMRNB Mode 1 = 5150 bps */ - OMX_AUDIO_AMRBandModeNB2, /**< AMRNB Mode 2 = 5900 bps */ - OMX_AUDIO_AMRBandModeNB3, /**< AMRNB Mode 3 = 6700 bps */ - OMX_AUDIO_AMRBandModeNB4, /**< AMRNB Mode 4 = 7400 bps */ - OMX_AUDIO_AMRBandModeNB5, /**< AMRNB Mode 5 = 7950 bps */ - OMX_AUDIO_AMRBandModeNB6, /**< AMRNB Mode 6 = 10200 bps */ - OMX_AUDIO_AMRBandModeNB7, /**< AMRNB Mode 7 = 12200 bps */ - OMX_AUDIO_AMRBandModeWB0, /**< AMRWB Mode 0 = 6600 bps */ - OMX_AUDIO_AMRBandModeWB1, /**< AMRWB Mode 1 = 8850 bps */ - OMX_AUDIO_AMRBandModeWB2, /**< AMRWB Mode 2 = 12650 bps */ - OMX_AUDIO_AMRBandModeWB3, /**< AMRWB Mode 3 = 14250 bps */ - OMX_AUDIO_AMRBandModeWB4, /**< AMRWB Mode 4 = 15850 bps */ - OMX_AUDIO_AMRBandModeWB5, /**< AMRWB Mode 5 = 18250 bps */ - OMX_AUDIO_AMRBandModeWB6, /**< AMRWB Mode 6 = 19850 bps */ - OMX_AUDIO_AMRBandModeWB7, /**< AMRWB Mode 7 = 23050 bps */ - OMX_AUDIO_AMRBandModeWB8, /**< AMRWB Mode 8 = 23850 bps */ - OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF -} OMX_AUDIO_AMRBANDMODETYPE; - - -/** AMR Discontinuous Transmission mode */ -typedef enum OMX_AUDIO_AMRDTXMODETYPE { - OMX_AUDIO_AMRDTXModeOff = 0, /**< AMR Discontinuous Transmission Mode is disabled */ - OMX_AUDIO_AMRDTXModeOnVAD1, /**< AMR Discontinuous Transmission Mode using - Voice Activity Detector 1 (VAD1) is enabled */ - OMX_AUDIO_AMRDTXModeOnVAD2, /**< AMR Discontinuous Transmission Mode using - Voice Activity Detector 2 (VAD2) is enabled */ - OMX_AUDIO_AMRDTXModeOnAuto, /**< The codec will automatically select between - Off, VAD1 or VAD2 modes */ - - OMX_AUDIO_AMRDTXasEFR, /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */ - - OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF -} OMX_AUDIO_AMRDTXMODETYPE; - - -/** AMR params */ -typedef struct OMX_AUDIO_PARAM_AMRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate read only field */ - OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ - OMX_AUDIO_AMRDTXMODETYPE eAMRDTXMode; /**< AMR DTX Mode enumeration */ - OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */ -} OMX_AUDIO_PARAM_AMRTYPE; - - -/** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_GSMFRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_GSMFRTYPE; - - -/** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_GSMHRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_GSMHRTYPE; - - -/** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_GSMEFRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_GSMEFRTYPE; - - -/** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_TDMAFRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_TDMAFRTYPE; - - -/** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_TDMAEFRTYPE; - - -/** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_PDCFRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_PDCFRTYPE; - - -/** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_PDCEFRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_PDCEFRTYPE; - -/** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_PDCHRTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_PDCHRTYPE; - - -/** CDMA Rate types */ -typedef enum OMX_AUDIO_CDMARATETYPE { - OMX_AUDIO_CDMARateBlank = 0, /**< CDMA encoded frame is blank */ - OMX_AUDIO_CDMARateFull, /**< CDMA encoded frame in full rate */ - OMX_AUDIO_CDMARateHalf, /**< CDMA encoded frame in half rate */ - OMX_AUDIO_CDMARateQuarter, /**< CDMA encoded frame in quarter rate */ - OMX_AUDIO_CDMARateEighth, /**< CDMA encoded frame in eighth rate (DTX)*/ - OMX_AUDIO_CDMARateErasure, /**< CDMA erasure frame */ - OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_CDMARateMax = 0x7FFFFFFF -} OMX_AUDIO_CDMARATETYPE; - - -/** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_QCELP8TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ -} OMX_AUDIO_PARAM_QCELP8TYPE; - - -/** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_QCELP13TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ -} OMX_AUDIO_PARAM_QCELP13TYPE; - - -/** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_EVRCTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */ - OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ - OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter */ - OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ - OMX_BOOL bPostFilter; /**< Enable decoder's post Filter */ -} OMX_AUDIO_PARAM_EVRCTYPE; - - -/** SMV ( up to 8.55kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_SMVTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ - OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/ - OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter ??*/ - OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ - OMX_BOOL bPostFilter; /**< Enable decoder's post Filter ??*/ -} OMX_AUDIO_PARAM_SMVTYPE; - - -/** MIDI Format - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDIFORMATTYPE -{ - OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */ - OMX_AUDIO_MIDIFormatSMF0, /**< Standard MIDI File Type 0 */ - OMX_AUDIO_MIDIFormatSMF1, /**< Standard MIDI File Type 1 */ - OMX_AUDIO_MIDIFormatSMF2, /**< Standard MIDI File Type 2 */ - OMX_AUDIO_MIDIFormatSPMIDI, /**< SP-MIDI */ - OMX_AUDIO_MIDIFormatXMF0, /**< eXtensible Music Format type 0 */ - OMX_AUDIO_MIDIFormatXMF1, /**< eXtensible Music Format type 1 */ - OMX_AUDIO_MIDIFormatMobileXMF, /**< Mobile XMF (eXtensible Music Format type 2) */ - OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF -} OMX_AUDIO_MIDIFORMATTYPE; - - -/** MIDI params - * @ingroup midi - */ -typedef struct OMX_AUDIO_PARAM_MIDITYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nFileSize; /**< size of the MIDI file in bytes, where the entire - MIDI file passed in, otherwise if 0x0, the MIDI data - is merged and streamed (instead of passed as an - entire MIDI file) */ - OMX_BU32 sMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic - voices. A value of zero indicates that the default - polyphony of the device is used */ - OMX_BOOL bLoadDefaultSound; /**< Whether to load default sound - bank at initialization */ - OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */ -} OMX_AUDIO_PARAM_MIDITYPE; - - -/** Type of the MIDI sound bank - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDISOUNDBANKTYPE { - OMX_AUDIO_MIDISoundBankUnused = 0, /**< unused/unknown soundbank type */ - OMX_AUDIO_MIDISoundBankDLS1, /**< DLS version 1 */ - OMX_AUDIO_MIDISoundBankDLS2, /**< DLS version 2 */ - OMX_AUDIO_MIDISoundBankMobileDLSBase, /**< Mobile DLS, using the base functionality */ - OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */ - OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF -} OMX_AUDIO_MIDISOUNDBANKTYPE; - - -/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE { - OMX_AUDIO_MIDISoundBankLayoutUnused = 0, /**< unused/unknown soundbank type */ - OMX_AUDIO_MIDISoundBankLayoutGM, /**< GS layout (based on bank MSB 0x00) */ - OMX_AUDIO_MIDISoundBankLayoutGM2, /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */ - OMX_AUDIO_MIDISoundBankLayoutUser, /**< Does not conform to any bank numbering standards */ - OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF -} OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE; - - -/** MIDI params to load/unload user soundbank - * @ingroup midi - */ -typedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nDLSIndex; /**< DLS file index to be loaded */ - OMX_U32 nDLSSize; /**< Size in bytes */ - OMX_PTR pDLSData; /**< Pointer to DLS file data */ - OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank; /**< Midi sound bank type enumeration */ - OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */ -} OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE; - - -/** Structure for Live MIDI events and MIP messages. - * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.) - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port that this structure applies to */ - OMX_U32 nMidiEventSize; /**< Size of immediate MIDI events or MIP message in bytes */ - OMX_U8 nMidiEvents[1]; /**< MIDI event array to be rendered immediately, or an - array for the MIP message buffer, where the size is - indicated by nMidiEventSize */ -} OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE; - - -/** MIDI sound bank/ program pair in a given channel - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port that this structure applies to */ - OMX_U32 nChannel; /**< Valid channel values range from 1 to 16 */ - OMX_U16 nIDProgram; /**< Valid program ID range is 1 to 128 */ - OMX_U16 nIDSoundBank; /**< Sound bank ID */ - OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks - by index if multiple banks are present */ -} OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE; - - -/** MIDI control - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10 - format based on JAVA MMAPI (JSR-135) requirement */ - OMX_BU32 sPlayBackRate; /**< Relative playback rate, stored as Q14.17 fixed-point - number based on JSR-135 requirement */ - OMX_BU32 sTempo ; /**< Tempo in beats per minute (BPM), stored as Q22.10 - fixed-point number based on JSR-135 requirement */ - OMX_U32 nMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic - voices. A value of zero indicates that the default - polyphony of the device is used */ - OMX_U32 nNumRepeat; /**< Number of times to repeat playback */ - OMX_U32 nStopTime; /**< Time in milliseconds to indicate when playback - will stop automatically. Set to zero if not used */ - OMX_U16 nChannelMuteMask; /**< 16 bit mask for channel mute status */ - OMX_U16 nChannelSoloMask; /**< 16 bit mask for channel solo status */ - OMX_U32 nTrack0031MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */ - OMX_U32 nTrack3263MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */ - OMX_U32 nTrack0031SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */ - OMX_U32 nTrack3263SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */ - -} OMX_AUDIO_CONFIG_MIDICONTROLTYPE; - - -/** MIDI Playback States - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE { - OMX_AUDIO_MIDIPlayBackStateUnknown = 0, /**< Unknown state or state does not map to - other defined states */ - OMX_AUDIO_MIDIPlayBackStateClosedEngaged, /**< No MIDI resource is currently open. - The MIDI engine is currently processing - MIDI events. */ - OMX_AUDIO_MIDIPlayBackStateParsing, /**< A MIDI resource is open and is being - primed. The MIDI engine is currently - processing MIDI events. */ - OMX_AUDIO_MIDIPlayBackStateOpenEngaged, /**< A MIDI resource is open and primed but - not playing. The MIDI engine is currently - processing MIDI events. The transition to - this state is only possible from the - OMX_AUDIO_MIDIPlayBackStatePlaying state, - when the 'playback head' reaches the end - of media data or the playback stops due - to stop time set.*/ - OMX_AUDIO_MIDIPlayBackStatePlaying, /**< A MIDI resource is open and currently - playing. The MIDI engine is currently - processing MIDI events.*/ - OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS - resource constraints */ - OMX_AUDIO_MIDIPlayBackStatePlayingSilently, /**< Due to system resource constraints and - SP-MIDI content constraints, there is - no audible MIDI content during playback - currently. The situation may change if - resources are freed later.*/ - OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF -} OMX_AUDIO_MIDIPLAYBACKSTATETYPE; - - -/** MIDI status - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U16 nNumTracks; /**< Number of MIDI tracks in the file, read only field. - NOTE: May not return a meaningful value until the entire - file is parsed and buffered. */ - OMX_U32 nDuration; /**< The length of the currently open MIDI resource - in milliseconds. NOTE: May not return a meaningful value - until the entire file is parsed and buffered. */ - OMX_U32 nPosition; /**< Current Position of the MIDI resource being played - in milliseconds */ - OMX_BOOL bVibra; /**< Does Vibra track exist? NOTE: May not return a meaningful - value until the entire file is parsed and buffered. */ - OMX_U32 nNumMetaEvents; /**< Total number of MIDI Meta Events in the currently - open MIDI resource. NOTE: May not return a meaningful value - until the entire file is parsed and buffered. */ - OMX_U32 nNumActiveVoices; /**< Number of active voices in the currently playing - MIDI resource. NOTE: May not return a meaningful value until - the entire file is parsed and buffered. */ - OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState; /**< MIDI playback state enumeration, read only field */ -} OMX_AUDIO_CONFIG_MIDISTATUSTYPE; - - -/** MIDI Meta Event structure one per Meta Event. - * MIDI Meta Events are like audio metadata, except that they are interspersed - * with the MIDI content throughout the file and are not localized in the header. - * As such, it is necessary to retrieve information about these Meta Events from - * the engine, as it encounters these Meta Events within the MIDI content. - * For example, SMF files can have up to 14 types of MIDI Meta Events (copyright, - * author, default tempo, etc.) scattered throughout the file. - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{ - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nIndex; /**< Index of Meta Event */ - OMX_U8 nMetaEventType; /**< Meta Event Type, 7bits (i.e. 0 - 127) */ - OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ - OMX_U32 nTrack; /**< track number for the meta event */ - OMX_U32 nPosition; /**< Position of the meta-event in milliseconds */ -} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE; - - -/** MIDI Meta Event Data structure - one per Meta Event. - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{ - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nIndex; /**< Index of Meta Event */ - OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ - OMX_U8 nData[1]; /**< array of one or more bytes of meta data - as indicated by the nMetaEventSize field */ -} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE; - - -/** Audio Volume adjustment for a port */ -typedef struct OMX_AUDIO_CONFIG_VOLUMETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's volume. Select the - output port to adjust the master - volume. */ - OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) - or logarithmic scale (mB) */ - OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR - Volume logarithmic setting for this port. The values - for volume are in mB (millibels = 1/100 dB) relative - to a gain of 1 (e.g. the output is the same as the - input level). Values are in mB from nMax - (maximum volume) to nMin mB (typically negative). - Since the volume is "voltage" - and not a "power", it takes a setting of - -600 mB to decrease the volume by 1/2. If - a component cannot accurately set the - volume to the requested value, it must - set the volume to the closest value BELOW - the requested value. When getting the - volume setting, the current actual volume - must be returned. */ -} OMX_AUDIO_CONFIG_VOLUMETYPE; - - -/** Audio Volume adjustment for a channel */ -typedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's volume. Select the - output port to adjust the master - volume. */ - OMX_U32 nChannel; /**< channel to select from 0 to N-1, - using OMX_ALL to apply volume settings - to all channels */ - OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) or - logarithmic scale (mB) */ - OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR - Volume logarithmic setting for this port. - The values for volume are in mB - (millibels = 1/100 dB) relative to a gain - of 1 (e.g. the output is the same as the - input level). Values are in mB from nMax - (maximum volume) to nMin mB (typically negative). - Since the volume is "voltage" - and not a "power", it takes a setting of - -600 mB to decrease the volume by 1/2. If - a component cannot accurately set the - volume to the requested value, it must - set the volume to the closest value BELOW - the requested value. When getting the - volume setting, the current actual volume - must be returned. */ - OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, - FALSE otherwise */ -} OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE; - - -/** Audio balance setting */ -typedef struct OMX_AUDIO_CONFIG_BALANCETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's balance. Select the - output port to adjust the master - balance. */ - OMX_S32 nBalance; /**< balance setting for this port - (-100 to 100, where -100 indicates - all left, and no right */ -} OMX_AUDIO_CONFIG_BALANCETYPE; - - -/** Audio Port mute */ -typedef struct OMX_AUDIO_CONFIG_MUTETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's mute. Select the - output port to adjust the master - mute. */ - OMX_BOOL bMute; /**< Mute setting for this port */ -} OMX_AUDIO_CONFIG_MUTETYPE; - - -/** Audio Channel mute */ -typedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannel; /**< channel to select from 0 to N-1, - using OMX_ALL to apply mute settings - to all channels */ - OMX_BOOL bMute; /**< Mute setting for this channel */ - OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, - FALSE otherwise */ -} OMX_AUDIO_CONFIG_CHANNELMUTETYPE; - - - -/** Enable / Disable for loudness control, which boosts bass and to a - * smaller extent high end frequencies to compensate for hearing - * ability at the extreme ends of the audio spectrum - */ -typedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bLoudness; /**< Enable/disable for loudness */ -} OMX_AUDIO_CONFIG_LOUDNESSTYPE; - - -/** Enable / Disable for bass, which controls low frequencies - */ -typedef struct OMX_AUDIO_CONFIG_BASSTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bEnable; /**< Enable/disable for bass control */ - OMX_S32 nBass; /**< bass setting for the port, as a - continuous value from -100 to 100 - (0 means no change in bass level)*/ -} OMX_AUDIO_CONFIG_BASSTYPE; - - -/** Enable / Disable for treble, which controls high frequencies tones - */ -typedef struct OMX_AUDIO_CONFIG_TREBLETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bEnable; /**< Enable/disable for treble control */ - OMX_S32 nTreble; /**< treble setting for the port, as a - continuous value from -100 to 100 - (0 means no change in treble level) */ -} OMX_AUDIO_CONFIG_TREBLETYPE; - - -/** An equalizer is typically used for two reasons: to compensate for an - * sub-optimal frequency response of a system to make it sound more natural - * or to create intentionally some unnatural coloring to the sound to create - * an effect. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bEnable; /**< Enable/disable for equalizer */ - OMX_BU32 sBandIndex; /**< Band number to be set. Upper Limit is - N-1, where N is the number of bands, lower limit is 0 */ - OMX_BU32 sCenterFreq; /**< Center frequecies in Hz. This is a - read only element and is used to determine - the lower, center and upper frequency of - this band. */ - OMX_BS32 sBandLevel; /**< band level in millibels */ -} OMX_AUDIO_CONFIG_EQUALIZERTYPE; - - -/** Stereo widening mode type - * @ingroup effects - */ -typedef enum OMX_AUDIO_STEREOWIDENINGTYPE { - OMX_AUDIO_StereoWideningHeadphones, /**< Stereo widening for loudspeakers */ - OMX_AUDIO_StereoWideningLoudspeakers, /**< Stereo widening for closely spaced loudspeakers */ - OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF -} OMX_AUDIO_STEREOWIDENINGTYPE; - - -/** Control for stereo widening, which is a special 2-channel - * case of the audio virtualizer effect. For example, for 5.1-channel - * output, it translates to virtual surround sound. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bEnable; /**< Enable/disable for stereo widening control */ - OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */ - OMX_U32 nStereoWidening; /**< stereo widening setting for the port, - as a continuous value from 0 to 100 */ -} OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE; - - -/** The chorus effect (or ``choralizer'') is any signal processor which makes - * one sound source (such as a voice) sound like many such sources singing - * (or playing) in unison. Since performance in unison is never exact, chorus - * effects simulate this by making independently modified copies of the input - * signal. Modifications may include (1) delay, (2) frequency shift, and - * (3) amplitude modulation. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_CHORUSTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bEnable; /**< Enable/disable for chorus */ - OMX_BU32 sDelay; /**< average delay in milliseconds */ - OMX_BU32 sModulationRate; /**< rate of modulation in millihertz */ - OMX_U32 nModulationDepth; /**< depth of modulation as a percentage of - delay (i.e. 0 to 100) */ - OMX_BU32 nFeedback; /**< Feedback from chorus output to input in percentage */ -} OMX_AUDIO_CONFIG_CHORUSTYPE; - - -/** Reverberation is part of the reflected sound that follows the early - * reflections. In a typical room, this consists of a dense succession of - * echoes whose energy decays exponentially. The reverberation effect structure - * as defined here includes both (early) reflections as well as (late) reverberations. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bEnable; /**< Enable/disable for reverberation control */ - OMX_BS32 sRoomLevel; /**< Intensity level for the whole room effect - (i.e. both early reflections and late - reverberation) in millibels */ - OMX_BS32 sRoomHighFreqLevel; /**< Attenuation at high frequencies - relative to the intensity at low - frequencies in millibels */ - OMX_BS32 sReflectionsLevel; /**< Intensity level of early reflections - (relative to room value), in millibels */ - OMX_BU32 sReflectionsDelay; /**< Delay time of the first reflection relative - to the direct path, in milliseconds */ - OMX_BS32 sReverbLevel; /**< Intensity level of late reverberation - relative to room level, in millibels */ - OMX_BU32 sReverbDelay; /**< Time delay from the first early reflection - to the beginning of the late reverberation - section, in milliseconds */ - OMX_BU32 sDecayTime; /**< Late reverberation decay time at low - frequencies, in milliseconds */ - OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative - to low frequency decay time in percent */ - OMX_U32 nDensity; /**< Modal density in the late reverberation decay, - in percent (i.e. 0 - 100) */ - OMX_U32 nDiffusion; /**< Echo density in the late reverberation decay, - in percent (i.e. 0 - 100) */ - OMX_BU32 sReferenceHighFreq; /**< Reference high frequency in Hertz. This is - the frequency used as the reference for all - the high-frequency settings above */ - -} OMX_AUDIO_CONFIG_REVERBERATIONTYPE; - - -/** Possible settings for the Echo Cancelation structure to use - * @ingroup effects - */ -typedef enum OMX_AUDIO_ECHOCANTYPE { - OMX_AUDIO_EchoCanOff = 0, /**< Echo Cancellation is disabled */ - OMX_AUDIO_EchoCanNormal, /**< Echo Cancellation normal operation - - echo from plastics and face */ - OMX_AUDIO_EchoCanHFree, /**< Echo Cancellation optimized for - Hands Free operation */ - OMX_AUDIO_EchoCanCarKit, /**< Echo Cancellation optimized for - Car Kit (longer echo) */ - OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_EchoCanMax = 0x7FFFFFFF -} OMX_AUDIO_ECHOCANTYPE; - - -/** Enable / Disable for echo cancelation, which removes undesired echo's - * from the audio - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */ -} OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE; - - -/** Enable / Disable for noise reduction, which undesired noise from - * the audio - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BOOL bNoiseReduction; /**< Enable/disable for noise reduction */ -} OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_AudioExt.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_AudioExt.h deleted file mode 100644 index 2a1c3f2e1815ec..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_AudioExt.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2010 The Khronos Group 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. - * - */ - -/** OMX_AudioExt.h - OpenMax IL version 1.1.2 - * The OMX_AudioExt header file contains extensions to the - * definitions used by both the application and the component to - * access video items. - */ - -#ifndef OMX_AudioExt_h -#define OMX_AudioExt_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Each OMX header shall include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ -#include - -#define OMX_AUDIO_AACToolAndroidSSBR (OMX_AUDIO_AACToolVendor << 0) /**< SSBR: MPEG-4 Single-rate (downsampled) Spectral Band Replication tool allowed or active */ -#define OMX_AUDIO_AACToolAndroidDSBR (OMX_AUDIO_AACToolVendor << 1) /**< DSBR: MPEG-4 Dual-rate Spectral Band Replication tool allowed or active */ - -typedef enum OMX_AUDIO_CODINGEXTTYPE { - OMX_AUDIO_CodingAndroidUnused = OMX_AUDIO_CodingKhronosExtensions + 0x00100000, - OMX_AUDIO_CodingAndroidAC3, /**< AC3 encoded data */ - OMX_AUDIO_CodingAndroidOPUS, /**< OPUS encoded data */ - OMX_AUDIO_CodingAndroidEAC3, /**< EAC3 encoded data */ -} OMX_AUDIO_CODINGEXTTYPE; - -typedef struct OMX_AUDIO_PARAM_ANDROID_AC3TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ -} OMX_AUDIO_PARAM_ANDROID_AC3TYPE; - -typedef struct OMX_AUDIO_PARAM_ANDROID_EAC3TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ -} OMX_AUDIO_PARAM_ANDROID_EAC3TYPE; - -typedef struct OMX_AUDIO_PARAM_ANDROID_OPUSTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the encoded data data. Use 0 for variable - rate or unknown bit rates. Encoding is set to the - bitrate closest to specified value (in bps) */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should - limit the audio signal. Use 0 to let encoder decide */ -} OMX_AUDIO_PARAM_ANDROID_OPUSTYPE; - -typedef struct OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_S32 nMaxOutputChannels; /**< Maximum channel count to be output, -1 if unspecified, 0 if downmixing disabled */ - OMX_S32 nDrcCut; /**< The DRC attenuation factor, between 0 and 127, -1 if unspecified */ - OMX_S32 nDrcBoost; /**< The DRC amplification factor, between 0 and 127, -1 if unspecified */ - OMX_S32 nHeavyCompression; /**< 0 for light compression, 1 for heavy compression, -1 if unspecified */ - OMX_S32 nTargetReferenceLevel; /**< Target reference level, between 0 and 127, -1 if unspecified */ - OMX_S32 nEncodedTargetLevel; /**< Target reference level assumed at the encoder, between 0 and 127, -1 if unspecified */ - OMX_S32 nPCMLimiterEnable; /**< Signal level limiting, 0 for disable, 1 for enable, -1 if unspecified */ -} OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* OMX_AudioExt_h */ -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Component.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_Component.h deleted file mode 100644 index 0dc2c769725e76..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Component.h +++ /dev/null @@ -1,596 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/* - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** OMX_Component.h - OpenMax IL version 1.1.2 - * The OMX_Component header file contains the definitions used to define - * the public interface of a component. This header file is intended to - * be used by both the application and the component. - */ - -#ifndef OMX_Component_h -#define OMX_Component_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - - -/* Each OMX header must include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ - -#include -#include -#include -#include - -/** @ingroup comp */ -typedef enum OMX_PORTDOMAINTYPE { - OMX_PortDomainAudio, - OMX_PortDomainVideo, - OMX_PortDomainImage, - OMX_PortDomainOther, - OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_PortDomainMax = 0x7ffffff -} OMX_PORTDOMAINTYPE; - -/** @ingroup comp */ -typedef struct OMX_PARAM_PORTDEFINITIONTYPE { - OMX_U32 nSize; /**< Size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port number the structure applies to */ - OMX_DIRTYPE eDir; /**< Direction (input or output) of this port */ - OMX_U32 nBufferCountActual; /**< The actual number of buffers allocated on this port */ - OMX_U32 nBufferCountMin; /**< The minimum number of buffers this port requires */ - OMX_U32 nBufferSize; /**< Size, in bytes, for buffers to be used for this channel */ - OMX_BOOL bEnabled; /**< Ports default to enabled and are enabled/disabled by - OMX_CommandPortEnable/OMX_CommandPortDisable. - When disabled a port is unpopulated. A disabled port - is not populated with buffers on a transition to IDLE. */ - OMX_BOOL bPopulated; /**< Port is populated with all of its buffers as indicated by - nBufferCountActual. A disabled port is always unpopulated. - An enabled port is populated on a transition to OMX_StateIdle - and unpopulated on a transition to loaded. */ - OMX_PORTDOMAINTYPE eDomain; /**< Domain of the port. Determines the contents of metadata below. */ - union { - OMX_AUDIO_PORTDEFINITIONTYPE audio; - OMX_VIDEO_PORTDEFINITIONTYPE video; - OMX_IMAGE_PORTDEFINITIONTYPE image; - OMX_OTHER_PORTDEFINITIONTYPE other; - } format; - OMX_BOOL bBuffersContiguous; - OMX_U32 nBufferAlignment; -} OMX_PARAM_PORTDEFINITIONTYPE; - -/** @ingroup comp */ -typedef struct OMX_PARAM_U32TYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nU32; /**< U32 value */ -} OMX_PARAM_U32TYPE; - -/** @ingroup rpm */ -typedef enum OMX_SUSPENSIONPOLICYTYPE { - OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */ - OMX_SuspensionEnabled, /**< Suspension allowed */ - OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_SuspensionPolicyMax = 0x7fffffff -} OMX_SUSPENSIONPOLICYTYPE; - -/** @ingroup rpm */ -typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_SUSPENSIONPOLICYTYPE ePolicy; -} OMX_PARAM_SUSPENSIONPOLICYTYPE; - -/** @ingroup rpm */ -typedef enum OMX_SUSPENSIONTYPE { - OMX_NotSuspended, /**< component is not suspended */ - OMX_Suspended, /**< component is suspended */ - OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_SuspendMax = 0x7FFFFFFF -} OMX_SUSPENSIONTYPE; - -/** @ingroup rpm */ -typedef struct OMX_PARAM_SUSPENSIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_SUSPENSIONTYPE eType; -} OMX_PARAM_SUSPENSIONTYPE ; - -typedef struct OMX_CONFIG_BOOLEANTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bEnabled; -} OMX_CONFIG_BOOLEANTYPE; - -/* Parameter specifying the content uri to use. */ -/** @ingroup cp */ -typedef struct OMX_PARAM_CONTENTURITYPE -{ - OMX_U32 nSize; /**< size of the structure in bytes, including - actual URI name */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U8 contentURI[1]; /**< The URI name */ -} OMX_PARAM_CONTENTURITYPE; - -/* Parameter specifying the pipe to use. */ -/** @ingroup cp */ -typedef struct OMX_PARAM_CONTENTPIPETYPE -{ - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_HANDLETYPE hPipe; /**< The pipe handle*/ -} OMX_PARAM_CONTENTPIPETYPE; - -/** @ingroup rpm */ -typedef struct OMX_RESOURCECONCEALMENTTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment - methods (like degrading algorithm quality to - lower resource consumption or functional bypass) - on a component as a resolution to resource conflicts. */ -} OMX_RESOURCECONCEALMENTTYPE; - - -/** @ingroup metadata */ -typedef enum OMX_METADATACHARSETTYPE { - OMX_MetadataCharsetUnknown = 0, - OMX_MetadataCharsetASCII, - OMX_MetadataCharsetBinary, - OMX_MetadataCharsetCodePage1252, - OMX_MetadataCharsetUTF8, - OMX_MetadataCharsetJavaConformantUTF8, - OMX_MetadataCharsetUTF7, - OMX_MetadataCharsetImapUTF7, - OMX_MetadataCharsetUTF16LE, - OMX_MetadataCharsetUTF16BE, - OMX_MetadataCharsetGB12345, - OMX_MetadataCharsetHZGB2312, - OMX_MetadataCharsetGB2312, - OMX_MetadataCharsetGB18030, - OMX_MetadataCharsetGBK, - OMX_MetadataCharsetBig5, - OMX_MetadataCharsetISO88591, - OMX_MetadataCharsetISO88592, - OMX_MetadataCharsetISO88593, - OMX_MetadataCharsetISO88594, - OMX_MetadataCharsetISO88595, - OMX_MetadataCharsetISO88596, - OMX_MetadataCharsetISO88597, - OMX_MetadataCharsetISO88598, - OMX_MetadataCharsetISO88599, - OMX_MetadataCharsetISO885910, - OMX_MetadataCharsetISO885913, - OMX_MetadataCharsetISO885914, - OMX_MetadataCharsetISO885915, - OMX_MetadataCharsetShiftJIS, - OMX_MetadataCharsetISO2022JP, - OMX_MetadataCharsetISO2022JP1, - OMX_MetadataCharsetISOEUCJP, - OMX_MetadataCharsetSMS7Bit, - OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_MetadataCharsetTypeMax= 0x7FFFFFFF -} OMX_METADATACHARSETTYPE; - -/** @ingroup metadata */ -typedef enum OMX_METADATASCOPETYPE -{ - OMX_MetadataScopeAllLevels, - OMX_MetadataScopeTopLevel, - OMX_MetadataScopePortLevel, - OMX_MetadataScopeNodeLevel, - OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_MetadataScopeTypeMax = 0x7fffffff -} OMX_METADATASCOPETYPE; - -/** @ingroup metadata */ -typedef enum OMX_METADATASEARCHMODETYPE -{ - OMX_MetadataSearchValueSizeByIndex, - OMX_MetadataSearchItemByIndex, - OMX_MetadataSearchNextItemByKey, - OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_MetadataSearchTypeMax = 0x7fffffff -} OMX_METADATASEARCHMODETYPE; -/** @ingroup metadata */ -typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_METADATASCOPETYPE eScopeMode; - OMX_U32 nScopeSpecifier; - OMX_U32 nMetadataItemCount; -} OMX_CONFIG_METADATAITEMCOUNTTYPE; - -/** @ingroup metadata */ -typedef struct OMX_CONFIG_METADATAITEMTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_METADATASCOPETYPE eScopeMode; - OMX_U32 nScopeSpecifier; - OMX_U32 nMetadataItemIndex; - OMX_METADATASEARCHMODETYPE eSearchMode; - OMX_METADATACHARSETTYPE eKeyCharset; - OMX_U8 nKeySizeUsed; - OMX_U8 nKey[128]; - OMX_METADATACHARSETTYPE eValueCharset; - OMX_STRING sLanguageCountry; - OMX_U32 nValueMaxSize; - OMX_U32 nValueSizeUsed; - OMX_U8 nValue[1]; -} OMX_CONFIG_METADATAITEMTYPE; - -/* @ingroup metadata */ -typedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bAllKeys; - OMX_U32 nParentNodeID; - OMX_U32 nNumNodes; -} OMX_CONFIG_CONTAINERNODECOUNTTYPE; - -/** @ingroup metadata */ -typedef struct OMX_CONFIG_CONTAINERNODEIDTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bAllKeys; - OMX_U32 nParentNodeID; - OMX_U32 nNodeIndex; - OMX_U32 nNodeID; - OMX_STRING cNodeName; - OMX_BOOL bIsLeafType; -} OMX_CONFIG_CONTAINERNODEIDTYPE; - -/** @ingroup metadata */ -typedef struct OMX_PARAM_METADATAFILTERTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bAllKeys; /* if true then this structure refers to all keys and - * the three key fields below are ignored */ - OMX_METADATACHARSETTYPE eKeyCharset; - OMX_U32 nKeySizeUsed; - OMX_U8 nKey [128]; - OMX_U32 nLanguageCountrySizeUsed; - OMX_U8 nLanguageCountry[128]; - OMX_BOOL bEnabled; /* if true then key is part of filter (e.g. - * retained for query later). If false then - * key is not part of filter */ -} OMX_PARAM_METADATAFILTERTYPE; - -/** The OMX_HANDLETYPE structure defines the component handle. The component - * handle is used to access all of the component's public methods and also - * contains pointers to the component's private data area. The component - * handle is initialized by the OMX core (with help from the component) - * during the process of loading the component. After the component is - * successfully loaded, the application can safely access any of the - * component's public functions (although some may return an error because - * the state is inappropriate for the access). - * - * @ingroup comp - */ -typedef struct OMX_COMPONENTTYPE -{ - /** The size of this structure, in bytes. It is the responsibility - of the allocator of this structure to fill in this value. Since - this structure is allocated by the GetHandle function, this - function will fill in this value. */ - OMX_U32 nSize; - - /** nVersion is the version of the OMX specification that the structure - is built against. It is the responsibility of the creator of this - structure to initialize this value and every user of this structure - should verify that it knows how to use the exact version of - this structure found herein. */ - OMX_VERSIONTYPE nVersion; - - /** pComponentPrivate is a pointer to the component private data area. - This member is allocated and initialized by the component when the - component is first loaded. The application should not access this - data area. */ - OMX_PTR pComponentPrivate; - - /** pApplicationPrivate is a pointer that is a parameter to the - OMX_GetHandle method, and contains an application private value - provided by the IL client. This application private data is - returned to the IL Client by OMX in all callbacks */ - OMX_PTR pApplicationPrivate; - - /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL - specification for details on the GetComponentVersion method. - */ - OMX_ERRORTYPE (*GetComponentVersion)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STRING pComponentName, - OMX_OUT OMX_VERSIONTYPE* pComponentVersion, - OMX_OUT OMX_VERSIONTYPE* pSpecVersion, - OMX_OUT OMX_UUIDTYPE* pComponentUUID); - - /** refer to OMX_SendCommand in OMX_core.h or the OMX IL - specification for details on the SendCommand method. - */ - OMX_ERRORTYPE (*SendCommand)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE Cmd, - OMX_IN OMX_U32 nParam1, - OMX_IN OMX_PTR pCmdData); - - /** refer to OMX_GetParameter in OMX_core.h or the OMX IL - specification for details on the GetParameter method. - */ - OMX_ERRORTYPE (*GetParameter)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure); - - - /** refer to OMX_SetParameter in OMX_core.h or the OMX IL - specification for details on the SetParameter method. - */ - OMX_ERRORTYPE (*SetParameter)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentParameterStructure); - - - /** refer to OMX_GetConfig in OMX_core.h or the OMX IL - specification for details on the GetConfig method. - */ - OMX_ERRORTYPE (*GetConfig)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_INOUT OMX_PTR pComponentConfigStructure); - - - /** refer to OMX_SetConfig in OMX_core.h or the OMX IL - specification for details on the SetConfig method. - */ - OMX_ERRORTYPE (*SetConfig)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentConfigStructure); - - - /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL - specification for details on the GetExtensionIndex method. - */ - OMX_ERRORTYPE (*GetExtensionIndex)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, - OMX_OUT OMX_INDEXTYPE* pIndexType); - - - /** refer to OMX_GetState in OMX_core.h or the OMX IL - specification for details on the GetState method. - */ - OMX_ERRORTYPE (*GetState)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STATETYPE* pState); - - - /** The ComponentTunnelRequest method will interact with another OMX - component to determine if tunneling is possible and to setup the - tunneling. The return codes for this method can be used to - determine if tunneling is not possible, or if tunneling is not - supported. - - Base profile components (i.e. non-interop) do not support this - method and should return OMX_ErrorNotImplemented - - The interop profile component MUST support tunneling to another - interop profile component with a compatible port parameters. - A component may also support proprietary communication. - - If proprietary communication is supported the negotiation of - proprietary communication is done outside of OMX in a vendor - specific way. It is only required that the proper result be - returned and the details of how the setup is done is left - to the component implementation. - - When this method is invoked when nPort in an output port, the - component will: - 1. Populate the pTunnelSetup structure with the output port's - requirements and constraints for the tunnel. - - When this method is invoked when nPort in an input port, the - component will: - 1. Query the necessary parameters from the output port to - determine if the ports are compatible for tunneling - 2. If the ports are compatible, the component should store - the tunnel step provided by the output port - 3. Determine which port (either input or output) is the buffer - supplier, and call OMX_SetParameter on the output port to - indicate this selection. - - The component will return from this call within 5 msec. - - @param [in] hComp - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle method. - @param [in] nPort - nPort is used to select the port on the component to be used - for tunneling. - @param [in] hTunneledComp - Handle of the component to tunnel with. This is the component - handle returned by the call to the OMX_GetHandle method. When - this parameter is 0x0 the component should setup the port for - communication with the application / IL Client. - @param [in] nPortOutput - nPortOutput is used indicate the port the component should - tunnel with. - @param [in] pTunnelSetup - Pointer to the tunnel setup structure. When nPort is an output port - the component should populate the fields of this structure. When - When nPort is an input port the component should review the setup - provided by the component with the output port. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup tun - */ - - OMX_ERRORTYPE (*ComponentTunnelRequest)( - OMX_IN OMX_HANDLETYPE hComp, - OMX_IN OMX_U32 nPort, - OMX_IN OMX_HANDLETYPE hTunneledComp, - OMX_IN OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup); - - /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL - specification for details on the UseBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*UseBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes, - OMX_IN OMX_U8* pBuffer); - - /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL - specification for details on the AllocateBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*AllocateBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes); - - /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL - specification for details on the FreeBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*FreeBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL - specification for details on the EmptyThisBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*EmptyThisBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL - specification for details on the FillThisBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*FillThisBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** The SetCallbacks method is used by the core to specify the callback - structure from the application to the component. This is a blocking - call. The component will return from this call within 5 msec. - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @param [in] pCallbacks - pointer to an OMX_CALLBACKTYPE structure used to provide the - callback information to the component - @param [in] pAppData - pointer to an application defined value. It is anticipated that - the application will pass a pointer to a data structure or a "this - pointer" in this area to allow the callback (in the application) - to determine the context of the call - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - */ - OMX_ERRORTYPE (*SetCallbacks)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_CALLBACKTYPE* pCallbacks, - OMX_IN OMX_PTR pAppData); - - /** ComponentDeInit method is used to deinitialize the component - providing a means to free any resources allocated at component - initialization. NOTE: After this call the component handle is - not valid for further use. - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - */ - OMX_ERRORTYPE (*ComponentDeInit)( - OMX_IN OMX_HANDLETYPE hComponent); - - /** @ingroup buf */ - OMX_ERRORTYPE (*UseEGLImage)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN void* eglImage); - - OMX_ERRORTYPE (*ComponentRoleEnum)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_U8 *cRole, - OMX_IN OMX_U32 nIndex); - -} OMX_COMPONENTTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_ContentPipe.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_ContentPipe.h deleted file mode 100644 index 0224c8a2eed1bf..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_ContentPipe.h +++ /dev/null @@ -1,212 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/* - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** OMX_ContentPipe.h - OpenMax IL version 1.1.2 - * The OMX_ContentPipe header file contains the definitions used to define - * the public interface for content piples. This header file is intended to - * be used by the component. - */ - -#ifndef OMX_CONTENTPIPE_H -#define OMX_CONTENTPIPE_H - -#ifndef KD_EACCES -/* OpenKODE error codes. CPResult values may be zero (indicating success - or one of the following values) */ -#define KD_EACCES (1) -#define KD_EADDRINUSE (2) -#define KD_EAGAIN (5) -#define KD_EBADF (7) -#define KD_EBUSY (8) -#define KD_ECONNREFUSED (9) -#define KD_ECONNRESET (10) -#define KD_EDEADLK (11) -#define KD_EDESTADDRREQ (12) -#define KD_ERANGE (35) -#define KD_EEXIST (13) -#define KD_EFBIG (14) -#define KD_EHOSTUNREACH (15) -#define KD_EINVAL (17) -#define KD_EIO (18) -#define KD_EISCONN (20) -#define KD_EISDIR (21) -#define KD_EMFILE (22) -#define KD_ENAMETOOLONG (23) -#define KD_ENOENT (24) -#define KD_ENOMEM (25) -#define KD_ENOSPC (26) -#define KD_ENOSYS (27) -#define KD_ENOTCONN (28) -#define KD_EPERM (33) -#define KD_ETIMEDOUT (36) -#define KD_EILSEQ (19) -#endif - -/** Map types from OMX standard types only here so interface is as generic as possible. */ -typedef OMX_U32 CPresult; -typedef char * CPstring; -typedef void * CPhandle; -typedef OMX_U32 CPuint; -typedef OMX_S32 CPint; -typedef char CPbyte; -typedef OMX_BOOL CPbool; - -/** enumeration of origin types used in the CP_PIPETYPE's Seek function - * @ingroup cp - */ -typedef enum CP_ORIGINTYPE { - CP_OriginBegin, - CP_OriginCur, - CP_OriginEnd, - CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_OriginMax = 0X7FFFFFFF -} CP_ORIGINTYPE; - -/** enumeration of contact access types used in the CP_PIPETYPE's Open function - * @ingroup cp - */ -typedef enum CP_ACCESSTYPE { - CP_AccessRead, - CP_AccessWrite, - CP_AccessReadWrite, - CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_AccessMax = 0X7FFFFFFF -} CP_ACCESSTYPE; - -/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function - * @ingroup cp - */ -typedef enum CP_CHECKBYTESRESULTTYPE -{ - CP_CheckBytesOk, /**< There are at least the request number - of bytes available */ - CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes - and presently lacks sufficient bytes. - Client will be called when they are - sufficient bytes are available. */ - CP_CheckBytesInsufficientBytes, /**< The pipe has retrieved all bytes - but those available are less than those - requested */ - CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream - and no more bytes are available. */ - CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */ - CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_CheckBytesMax = 0X7FFFFFFF -} CP_CHECKBYTESRESULTTYPE; - -/** enumeration of content pipe events sent to the client callback. - * @ingroup cp - */ -typedef enum CP_EVENTTYPE{ - CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/ - CP_Overflow, /** enumeration of content pipe events sent to the client callback*/ - CP_PipeDisconnected, /** enumeration of content pipe events sent to the client callback*/ - CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_EventMax = 0X7FFFFFFF -} CP_EVENTTYPE; - -/** content pipe definition - * @ingroup cp - */ -typedef struct CP_PIPETYPE -{ - /** Open a content stream for reading or writing. */ - CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess ); - - /** Close a content stream. */ - CPresult (*Close)( CPhandle hContent ); - - /** Create a content source and open it for writing. */ - CPresult (*Create)( CPhandle *hContent, CPstring szURI ); - - /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/ - CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult ); - - /** Seek to certain position in the content relative to the specified origin. */ - CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin); - - /** Retrieve the current position relative to the start of the content. */ - CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition); - - /** Retrieve data of the specified size from the content stream (advance content pointer by size of data). - Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */ - CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize); - - /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes. - Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also - returns the size of the block actually read. Content pointer advances the by the returned size. - Note: pipe provides pointer. This function is appropriate for large reads. The client must call - ReleaseReadBuffer when done with buffer. - - In some cases the requested block may not reside in contiguous memory within the - pipe implementation. For instance if the pipe leverages a circular buffer then the requested - block may straddle the boundary of the circular buffer. By default a pipe implementation - performs a copy in this case to provide the block to the pipe client in one contiguous buffer. - If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory - boundary. Here the client may retrieve the data in segments over successive calls. */ - CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy); - - /** Release a buffer obtained by ReadBuffer back to the pipe. */ - CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer); - - /** Write data of the specified size to the content (advance content pointer by size of data). - Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */ - CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize); - - /** Retrieve a buffer allocated by the pipe used to write data to the content. - Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate - for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/ - CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize); - - /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the - the contents of the buffer to content and advance content pointer by the size of the buffer */ - CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize); - - /** Register a per-handle client callback with the content pipe. */ - CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam)); - -} CP_PIPETYPE; - -#endif - diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Core.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_Core.h deleted file mode 100644 index f746a69d2ad062..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Core.h +++ /dev/null @@ -1,1464 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/* - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** OMX_Core.h - OpenMax IL version 1.1.2 - * The OMX_Core header file contains the definitions used by both the - * application and the component to access common items. - */ - -#ifndef OMX_Core_h -#define OMX_Core_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/* Each OMX header shall include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ - -#include - - -/** The OMX_COMMANDTYPE enumeration is used to specify the action in the - * OMX_SendCommand macro. - * @ingroup core - */ -typedef enum OMX_COMMANDTYPE -{ - OMX_CommandStateSet, /**< Change the component state */ - OMX_CommandFlush, /**< Flush the data queue(s) of a component */ - OMX_CommandPortDisable, /**< Disable a port on a component. */ - OMX_CommandPortEnable, /**< Enable a port on a component. */ - OMX_CommandMarkBuffer, /**< Mark a component/buffer for observation */ - OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_CommandMax = 0X7FFFFFFF -} OMX_COMMANDTYPE; - - - -/** The OMX_STATETYPE enumeration is used to indicate or change the component - * state. This enumeration reflects the current state of the component when - * used with the OMX_GetState macro or becomes the parameter in a state change - * command when used with the OMX_SendCommand macro. - * - * The component will be in the Loaded state after the component is initially - * loaded into memory. In the Loaded state, the component is not allowed to - * allocate or hold resources other than to build it's internal parameter - * and configuration tables. The application will send one or more - * SetParameters/GetParameters and SetConfig/GetConfig commands to the - * component and the component will record each of these parameter and - * configuration changes for use later. When the application sends the - * Idle command, the component will acquire the resources needed for the - * specified configuration and will transition to the idle state if the - * allocation is successful. If the component cannot successfully - * transition to the idle state for any reason, the state of the component - * shall be fully rolled back to the Loaded state (e.g. all allocated - * resources shall be released). When the component receives the command - * to go to the Executing state, it shall begin processing buffers by - * sending all input buffers it holds to the application. While - * the component is in the Idle state, the application may also send the - * Pause command. If the component receives the pause command while in the - * Idle state, the component shall send all input buffers it holds to the - * application, but shall not begin processing buffers. This will allow the - * application to prefill buffers. - * - * @ingroup comp - */ - -typedef enum OMX_STATETYPE -{ - OMX_StateInvalid, /**< component has detected that it's internal data - structures are corrupted to the point that - it cannot determine it's state properly */ - OMX_StateLoaded, /**< component has been loaded but has not completed - initialization. The OMX_SetParameter macro - and the OMX_GetParameter macro are the only - valid macros allowed to be sent to the - component in this state. */ - OMX_StateIdle, /**< component initialization has been completed - successfully and the component is ready to - to start. */ - OMX_StateExecuting, /**< component has accepted the start command and - is processing data (if data is available) */ - OMX_StatePause, /**< component has received pause command */ - OMX_StateWaitForResources, /**< component is waiting for resources, either after - preemption or before it gets the resources requested. - See specification for complete details. */ - OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_StateMax = 0X7FFFFFFF -} OMX_STATETYPE; - -/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors. These - * errors should cover most of the common failure cases. However, - * vendors are free to add additional error messages of their own as - * long as they follow these rules: - * 1. Vendor error messages shall be in the range of 0x90000000 to - * 0x9000FFFF. - * 2. Vendor error messages shall be defined in a header file provided - * with the component. No error messages are allowed that are - * not defined. - */ -typedef enum OMX_ERRORTYPE -{ - OMX_ErrorNone = 0, - - /** There were insufficient resources to perform the requested operation */ - OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000, - - /** There was an error, but the cause of the error could not be determined */ - OMX_ErrorUndefined = (OMX_S32) 0x80001001, - - /** The component name string was not valid */ - OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002, - - /** No component with the specified name string was found */ - OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003, - - /** The component specified did not have a "OMX_ComponentInit" or - "OMX_ComponentDeInit entry point */ - OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004, - - /** One or more parameters were not valid */ - OMX_ErrorBadParameter = (OMX_S32) 0x80001005, - - /** The requested function is not implemented */ - OMX_ErrorNotImplemented = (OMX_S32) 0x80001006, - - /** The buffer was emptied before the next buffer was ready */ - OMX_ErrorUnderflow = (OMX_S32) 0x80001007, - - /** The buffer was not available when it was needed */ - OMX_ErrorOverflow = (OMX_S32) 0x80001008, - - /** The hardware failed to respond as expected */ - OMX_ErrorHardware = (OMX_S32) 0x80001009, - - /** The component is in the state OMX_StateInvalid */ - OMX_ErrorInvalidState = (OMX_S32) 0x8000100A, - - /** Stream is found to be corrupt */ - OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B, - - /** Ports being connected are not compatible */ - OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C, - - /** Resources allocated to an idle component have been - lost resulting in the component returning to the loaded state */ - OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D, - - /** No more indicies can be enumerated */ - OMX_ErrorNoMore = (OMX_S32) 0x8000100E, - - /** The component detected a version mismatch */ - OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F, - - /** The component is not ready to return data at this time */ - OMX_ErrorNotReady = (OMX_S32) 0x80001010, - - /** There was a timeout that occurred */ - OMX_ErrorTimeout = (OMX_S32) 0x80001011, - - /** This error occurs when trying to transition into the state you are already in */ - OMX_ErrorSameState = (OMX_S32) 0x80001012, - - /** Resources allocated to an executing or paused component have been - preempted, causing the component to return to the idle state */ - OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, - - /** A non-supplier port sends this error to the IL client (via the EventHandler callback) - during the allocation of buffers (on a transition from the LOADED to the IDLE state or - on a port restart) when it deems that it has waited an unusually long time for the supplier - to send it an allocated buffer via a UseBuffer call. */ - OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014, - - /** A non-supplier port sends this error to the IL client (via the EventHandler callback) - during the deallocation of buffers (on a transition from the IDLE to LOADED state or - on a port stop) when it deems that it has waited an unusually long time for the supplier - to request the deallocation of a buffer header via a FreeBuffer call. */ - OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015, - - /** A supplier port sends this error to the IL client (via the EventHandler callback) - during the stopping of a port (either on a transition from the IDLE to LOADED - state or a port stop) when it deems that it has waited an unusually long time for - the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */ - OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016, - - /** Attempting a state transtion that is not allowed */ - OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017, - - /* Attempting a command that is not allowed during the present state. */ - OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, - - /** The values encapsulated in the parameter or config structure are not supported. */ - OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019, - - /** The parameter or config indicated by the given index is not supported. */ - OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A, - - /** The port index supplied is incorrect. */ - OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B, - - /** The port has lost one or more of its buffers and it thus unpopulated. */ - OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C, - - /** Component suspended due to temporary loss of resources */ - OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D, - - /** Component suspended due to an inability to acquire dynamic resources */ - OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E, - - /** When the macroblock error reporting is enabled the component returns new error - for every frame that has errors */ - OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F, - - /** A component reports this error when it cannot parse or determine the format of an input stream. */ - OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, - - /** The content open operation failed. */ - OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021, - - /** The content creation operation failed. */ - OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022, - - /** Separate table information is being used */ - OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023, - - /** Tunneling is unsupported by the component*/ - OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024, - - OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_ErrorMax = 0x7FFFFFFF -} OMX_ERRORTYPE; - -/** @ingroup core */ -typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN OMX_HANDLETYPE hComponent); - -/** @ingroup core */ -typedef struct OMX_COMPONENTREGISTERTYPE -{ - const char * pName; /* Component name, 128 byte limit (including '\0') applies */ - OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */ -} OMX_COMPONENTREGISTERTYPE; - -/** @ingroup core */ -extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[]; - -/** @ingroup rpm */ -typedef struct OMX_PRIORITYMGMTTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nGroupPriority; /**< Priority of the component group */ - OMX_U32 nGroupID; /**< ID of the component group */ -} OMX_PRIORITYMGMTTYPE; - -/* Component name and Role names are limited to 128 characters including the terminating '\0'. */ -#define OMX_MAX_STRINGNAME_SIZE 128 - -/** @ingroup comp */ -typedef struct OMX_PARAM_COMPONENTROLETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE]; /**< name of standard component which defines component role */ -} OMX_PARAM_COMPONENTROLETYPE; - -/** End of Stream Buffer Flag: - * - * A component sets EOS when it has no more data to emit on a particular - * output port. Thus an output port shall set EOS on the last buffer it - * emits. A component's determination of when an output port should - * cease sending data is implemenation specific. - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_EOS 0x00000001 - -/** Start Time Buffer Flag: - * - * The source of a stream (e.g. a demux component) sets the STARTTIME - * flag on the buffer that contains the starting timestamp for the - * stream. The starting timestamp corresponds to the first data that - * should be displayed at startup or after a seek. - * The first timestamp of the stream is not necessarily the start time. - * For instance, in the case of a seek to a particular video frame, - * the target frame may be an interframe. Thus the first buffer of - * the stream will be the intra-frame preceding the target frame and - * the starttime will occur with the target frame (with any other - * required frames required to reconstruct the target intervening). - * - * The STARTTIME flag is directly associated with the buffer's - * timestamp ' thus its association to buffer data and its - * propagation is identical to the timestamp's. - * - * When a Sync Component client receives a buffer with the - * STARTTIME flag it shall perform a SetConfig on its sync port - * using OMX_ConfigTimeClientStartTime and passing the buffer's - * timestamp. - * - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_STARTTIME 0x00000002 - - - -/** Decode Only Buffer Flag: - * - * The source of a stream (e.g. a demux component) sets the DECODEONLY - * flag on any buffer that should shall be decoded but should not be - * displayed. This flag is used, for instance, when a source seeks to - * a target interframe that requires the decode of frames preceding the - * target to facilitate the target's reconstruction. In this case the - * source would emit the frames preceding the target downstream - * but mark them as decode only. - * - * The DECODEONLY is associated with buffer data and propagated in a - * manner identical to the buffer timestamp. - * - * A component that renders data should ignore all buffers with - * the DECODEONLY flag set. - * - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_DECODEONLY 0x00000004 - - -/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_DATACORRUPT 0x00000008 - -/* End of Frame: The buffer contains exactly one end of frame and no data - * occurs after the end of frame. This flag is an optional hint. The absence - * of this flag does not imply the absence of an end of frame within the buffer. - * @ingroup buf -*/ -#define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010 - -/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame ' - * a frame that has no dependency on any other frame information - * @ingroup buf - */ -#define OMX_BUFFERFLAG_SYNCFRAME 0x00000020 - -/* Extra data present flag: there is extra data appended to the data stream - * residing in the buffer - * @ingroup buf - */ -#define OMX_BUFFERFLAG_EXTRADATA 0x00000040 - -/** Codec Config Buffer Flag: -* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an -* output port when all bytes in the buffer form part or all of a set of -* codec specific configuration data. Examples include SPS/PPS nal units -* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for -* OMX_AUDIO_CodingAAC. Any component that for a given stream sets -* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes -* with frame data in the same buffer, and shall send all buffers -* containing codec configuration bytes before any buffers containing -* frame data that those configurations bytes describe. -* If the stream format for a particular codec has a frame specific -* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or -* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as -* normal without setting OMX_BUFFERFLAG_CODECCONFIG. - * @ingroup buf - */ -#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080 - - - -/** @ingroup buf */ -typedef struct OMX_BUFFERHEADERTYPE -{ - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U8* pBuffer; /**< Pointer to actual block of memory - that is acting as the buffer */ - OMX_U32 nAllocLen; /**< size of the buffer allocated, in bytes */ - OMX_U32 nFilledLen; /**< number of bytes currently in the - buffer */ - OMX_U32 nOffset; /**< start offset of valid data in bytes from - the start of the buffer */ - OMX_PTR pAppPrivate; /**< pointer to any data the application - wants to associate with this buffer */ - OMX_PTR pPlatformPrivate; /**< pointer to any data the platform - wants to associate with this buffer */ - OMX_PTR pInputPortPrivate; /**< pointer to any data the input port - wants to associate with this buffer */ - OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port - wants to associate with this buffer */ - OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a - mark event upon processing this buffer. */ - OMX_PTR pMarkData; /**< Application specific data associated with - the mark sent on a mark event to disambiguate - this mark from others. */ - OMX_U32 nTickCount; /**< Optional entry that the component and - application can update with a tick count - when they access the component. This - value should be in microseconds. Since - this is a value relative to an arbitrary - starting point, this value cannot be used - to determine absolute time. This is an - optional entry and not all components - will update it.*/ - OMX_TICKS nTimeStamp; /**< Timestamp corresponding to the sample - starting at the first logical sample - boundary in the buffer. Timestamps of - successive samples within the buffer may - be inferred by adding the duration of the - of the preceding buffer to the timestamp - of the preceding buffer.*/ - OMX_U32 nFlags; /**< buffer specific flags */ - OMX_U32 nOutputPortIndex; /**< The index of the output port (if any) using - this buffer */ - OMX_U32 nInputPortIndex; /**< The index of the input port (if any) using - this buffer */ -} OMX_BUFFERHEADERTYPE; - -/** The OMX_EXTRADATATYPE enumeration is used to define the - * possible extra data payload types. - * NB: this enum is binary backwards compatible with the previous - * OMX_EXTRADATA_QUANT define. This should be replaced with - * OMX_ExtraDataQuantization. - */ -typedef enum OMX_EXTRADATATYPE -{ - OMX_ExtraDataNone = 0, /**< Indicates that no more extra data sections follow */ - OMX_ExtraDataQuantization, /**< The data payload contains quantization data */ - OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_ExtraDataMax = 0x7FFFFFFF -} OMX_EXTRADATATYPE; - - -typedef struct OMX_OTHER_EXTRADATATYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_EXTRADATATYPE eType; /* Extra Data type */ - OMX_U32 nDataSize; /* Size of the supporting data to follow */ - OMX_U8 data[1]; /* Supporting data hint */ -} OMX_OTHER_EXTRADATATYPE; - -/** @ingroup comp */ -typedef struct OMX_PORT_PARAM_TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPorts; /**< The number of ports for this component */ - OMX_U32 nStartPortNumber; /** first port number for this type of port */ -} OMX_PORT_PARAM_TYPE; - -/** @ingroup comp */ -typedef enum OMX_EVENTTYPE -{ - OMX_EventCmdComplete, /**< component has sucessfully completed a command */ - OMX_EventError, /**< component has detected an error condition */ - OMX_EventMark, /**< component has detected a buffer mark */ - OMX_EventPortSettingsChanged, /**< component is reported a port settings change */ - OMX_EventBufferFlag, /**< component has detected an EOS */ - OMX_EventResourcesAcquired, /**< component has been granted resources and is - automatically starting the state change from - OMX_StateWaitForResources to OMX_StateIdle. */ - OMX_EventComponentResumed, /**< Component resumed due to reacquisition of resources */ - OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */ - OMX_EventPortFormatDetected, /**< Component has detected a supported format. */ - OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - - /** Event when tunneled decoder has rendered an output or reached EOS - * nData1 must contain the number of timestamps returned - * pEventData must point to an array of the OMX_VIDEO_RENDEREVENTTYPE structs containing the - * render-timestamps of each frame. Component may batch rendered timestamps using this event, - * but must signal the event no more than 40ms after the first frame in the batch. The frames - * must be ordered by system timestamp inside and across batches. - * - * If component is doing frame-rate conversion, it must signal the render time of each - * converted frame, and must interpolate media timestamps for in-between frames. - * - * When the component reached EOS, it must signal an EOS timestamp using the same mechanism. - * This is in addition to the timestamp of the last rendered frame, and should follow that - * frame. - */ - OMX_EventOutputRendered = 0x7F000001, - OMX_EventMax = 0x7FFFFFFF -} OMX_EVENTTYPE; - -typedef struct OMX_CALLBACKTYPE -{ - /** The EventHandler method is used to notify the application when an - event of interest occurs. Events are defined in the OMX_EVENTTYPE - enumeration. Please see that enumeration for details of what will - be returned for each type of event. Callbacks should not return - an error to the component, so if an error occurs, the application - shall handle it internally. This is a blocking call. - - The application should return from this call within 5 msec to avoid - blocking the component for an excessively long period of time. - - @param hComponent - handle of the component to access. This is the component - handle returned by the call to the GetHandle function. - @param pAppData - pointer to an application defined value that was provided in the - pAppData parameter to the OMX_GetHandle method for the component. - This application defined value is provided so that the application - can have a component specific context when receiving the callback. - @param eEvent - Event that the component wants to notify the application about. - @param nData1 - nData will be the OMX_ERRORTYPE for an error event and will be - an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event. - @param nData2 - nData2 will hold further information related to the event. Can be OMX_STATETYPE for - a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event. - Default value is 0 if not used. ) - @param pEventData - Pointer to additional event-specific data (see spec for meaning). - */ - - OMX_ERRORTYPE (*EventHandler)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - - /** The EmptyBufferDone method is used to return emptied buffers from an - input port back to the application for reuse. This is a blocking call - so the application should not attempt to refill the buffers during this - call, but should queue them and refill them in another thread. There - is no error return, so the application shall handle any errors generated - internally. - - The application should return from this call within 5 msec. - - @param hComponent - handle of the component to access. This is the component - handle returned by the call to the GetHandle function. - @param pAppData - pointer to an application defined value that was provided in the - pAppData parameter to the OMX_GetHandle method for the component. - This application defined value is provided so that the application - can have a component specific context when receiving the callback. - @param pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer indicating the buffer that was emptied. - @ingroup buf - */ - OMX_ERRORTYPE (*EmptyBufferDone)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** The FillBufferDone method is used to return filled buffers from an - output port back to the application for emptying and then reuse. - This is a blocking call so the application should not attempt to - empty the buffers during this call, but should queue the buffers - and empty them in another thread. There is no error return, so - the application shall handle any errors generated internally. The - application shall also update the buffer header to indicate the - number of bytes placed into the buffer. - - The application should return from this call within 5 msec. - - @param hComponent - handle of the component to access. This is the component - handle returned by the call to the GetHandle function. - @param pAppData - pointer to an application defined value that was provided in the - pAppData parameter to the OMX_GetHandle method for the component. - This application defined value is provided so that the application - can have a component specific context when receiving the callback. - @param pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer indicating the buffer that was filled. - @ingroup buf - */ - OMX_ERRORTYPE (*FillBufferDone)( - OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); - -} OMX_CALLBACKTYPE; - -/** The OMX_BUFFERSUPPLIERTYPE enumeration is used to dictate port supplier - preference when tunneling between two ports. - @ingroup tun buf -*/ -typedef enum OMX_BUFFERSUPPLIERTYPE -{ - OMX_BufferSupplyUnspecified = 0x0, /**< port supplying the buffers is unspecified, - or don't care */ - OMX_BufferSupplyInput, /**< input port supplies the buffers */ - OMX_BufferSupplyOutput, /**< output port supplies the buffers */ - OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_BufferSupplyMax = 0x7FFFFFFF -} OMX_BUFFERSUPPLIERTYPE; - - -/** buffer supplier parameter - * @ingroup tun - */ -typedef struct OMX_PARAM_BUFFERSUPPLIERTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_BUFFERSUPPLIERTYPE eBufferSupplier; /**< buffer supplier */ -} OMX_PARAM_BUFFERSUPPLIERTYPE; - - -/**< indicates that buffers received by an input port of a tunnel - may not modify the data in the buffers - @ingroup tun - */ -#define OMX_PORTTUNNELFLAG_READONLY 0x00000001 - - -/** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output - port to an input port as part the two ComponentTunnelRequest calls - resulting from a OMX_SetupTunnel call from the IL Client. - @ingroup tun - */ -typedef struct OMX_TUNNELSETUPTYPE -{ - OMX_U32 nTunnelFlags; /**< bit flags for tunneling */ - OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */ -} OMX_TUNNELSETUPTYPE; - -/* OMX Component headers is included to enable the core to use - macros for functions into the component for OMX release 1.0. - Developers should not access any structures or data from within - the component header directly */ -/* TO BE REMOVED - #include */ - -/** GetComponentVersion will return information about the component. - This is a blocking call. This macro will go directly from the - application to the component (via a core macro). The - component will return from this call within 5 msec. - @param [in] hComponent - handle of component to execute the command - @param [out] pComponentName - pointer to an empty string of length 128 bytes. The component - will write its name into this string. The name will be - terminated by a single zero byte. The name of a component will - be 127 bytes or less to leave room for the trailing zero byte. - An example of a valid component name is "OMX.ABC.ChannelMixer\0". - @param [out] pComponentVersion - pointer to an OMX Version structure that the component will fill - in. The component will fill in a value that indicates the - component version. NOTE: the component version is NOT the same - as the OMX Specification version (found in all structures). The - component version is defined by the vendor of the component and - its value is entirely up to the component vendor. - @param [out] pSpecVersion - pointer to an OMX Version structure that the component will fill - in. The SpecVersion is the version of the specification that the - component was built against. Please note that this value may or - may not match the structure's version. For example, if the - component was built against the 2.0 specification, but the - application (which creates the structure is built against the - 1.0 specification the versions would be different. - @param [out] pComponentUUID - pointer to the UUID of the component which will be filled in by - the component. The UUID is a unique identifier that is set at - RUN time for the component and is unique to each instantion of - the component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetComponentVersion( \ - hComponent, \ - pComponentName, \ - pComponentVersion, \ - pSpecVersion, \ - pComponentUUID) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion( \ - hComponent, \ - pComponentName, \ - pComponentVersion, \ - pSpecVersion, \ - pComponentUUID) /* Macro End */ - - -/** Send a command to the component. This call is a non-blocking call. - The component should check the parameters and then queue the command - to the component thread to be executed. The component thread shall - send the EventHandler() callback at the conclusion of the command. - This macro will go directly from the application to the component (via - a core macro). The component will return from this call within 5 msec. - - When the command is "OMX_CommandStateSet" the component will queue a - state transition to the new state idenfied in nParam. - - When the command is "OMX_CommandFlush", to flush a port's buffer queues, - the command will force the component to return all buffers NOT CURRENTLY - BEING PROCESSED to the application, in the order in which the buffers - were received. - - When the command is "OMX_CommandPortDisable" or - "OMX_CommandPortEnable", the component's port (given by the value of - nParam) will be stopped or restarted. - - When the command "OMX_CommandMarkBuffer" is used to mark a buffer, the - pCmdData will point to a OMX_MARKTYPE structure containing the component - handle of the component to examine the buffer chain for the mark. nParam1 - contains the index of the port on which the buffer mark is applied. - - Specification text for more details. - - @param [in] hComponent - handle of component to execute the command - @param [in] Cmd - Command for the component to execute - @param [in] nParam - Parameter for the command to be executed. When Cmd has the value - OMX_CommandStateSet, value is a member of OMX_STATETYPE. When Cmd has - the value OMX_CommandFlush, value of nParam indicates which port(s) - to flush. -1 is used to flush all ports a single port index will - only flush that port. When Cmd has the value "OMX_CommandPortDisable" - or "OMX_CommandPortEnable", the component's port is given by - the value of nParam. When Cmd has the value "OMX_CommandMarkBuffer" - the components pot is given by the value of nParam. - @param [in] pCmdData - Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value - "OMX_CommandMarkBuffer". - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_SendCommand( \ - hComponent, \ - Cmd, \ - nParam, \ - pCmdData) \ - ((OMX_COMPONENTTYPE*)hComponent)->SendCommand( \ - hComponent, \ - Cmd, \ - nParam, \ - pCmdData) /* Macro End */ - - -/** The OMX_GetParameter macro will get one of the current parameter - settings from the component. This macro cannot only be invoked when - the component is in the OMX_StateInvalid state. The nParamIndex - parameter is used to indicate which structure is being requested from - the component. The application shall allocate the correct structure - and shall fill in the structure size and version information before - invoking this macro. When the parameter applies to a port, the - caller shall fill in the appropriate nPortIndex value indicating the - port on which the parameter applies. If the component has not had - any settings changed, then the component should return a set of - valid DEFAULT parameters for the component. This is a blocking - call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nParamIndex - Index of the structure to be filled. This value is from the - OMX_INDEXTYPE enumeration. - @param [in,out] pComponentParameterStructure - Pointer to application allocated structure to be filled by the - component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) /* Macro End */ - - -/** The OMX_SetParameter macro will send an initialization parameter - structure to a component. Each structure shall be sent one at a time, - in a separate invocation of the macro. This macro can only be - invoked when the component is in the OMX_StateLoaded state, or the - port is disabled (when the parameter applies to a port). The - nParamIndex parameter is used to indicate which structure is being - passed to the component. The application shall allocate the - correct structure and shall fill in the structure size and version - information (as well as the actual data) before invoking this macro. - The application is free to dispose of this structure after the call - as the component is required to copy any data it shall retain. This - is a blocking call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nIndex - Index of the structure to be sent. This value is from the - OMX_INDEXTYPE enumeration. - @param [in] pComponentParameterStructure - pointer to application allocated structure to be used for - initialization by the component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_SetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->SetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) /* Macro End */ - - -/** The OMX_GetConfig macro will get one of the configuration structures - from a component. This macro can be invoked anytime after the - component has been loaded. The nParamIndex call parameter is used to - indicate which structure is being requested from the component. The - application shall allocate the correct structure and shall fill in the - structure size and version information before invoking this macro. - If the component has not had this configuration parameter sent before, - then the component should return a set of valid DEFAULT values for the - component. This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nIndex - Index of the structure to be filled. This value is from the - OMX_INDEXTYPE enumeration. - @param [in,out] pComponentConfigStructure - pointer to application allocated structure to be filled by the - component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp -*/ -#define OMX_GetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) /* Macro End */ - - -/** The OMX_SetConfig macro will send one of the configuration - structures to a component. Each structure shall be sent one at a time, - each in a separate invocation of the macro. This macro can be invoked - anytime after the component has been loaded. The application shall - allocate the correct structure and shall fill in the structure size - and version information (as well as the actual data) before invoking - this macro. The application is free to dispose of this structure after - the call as the component is required to copy any data it shall retain. - This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nConfigIndex - Index of the structure to be sent. This value is from the - OMX_INDEXTYPE enumeration above. - @param [in] pComponentConfigStructure - pointer to application allocated structure to be used for - initialization by the component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_SetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->SetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) /* Macro End */ - - -/** The OMX_GetExtensionIndex macro will invoke a component to translate - a vendor specific configuration or parameter string into an OMX - structure index. There is no requirement for the vendor to support - this command for the indexes already found in the OMX_INDEXTYPE - enumeration (this is done to save space in small components). The - component shall support all vendor supplied extension indexes not found - in the master OMX_INDEXTYPE enumeration. This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @param [in] cParameterName - OMX_STRING that shall be less than 128 characters long including - the trailing null byte. This is the string that will get - translated by the component into a configuration index. - @param [out] pIndexType - a pointer to a OMX_INDEXTYPE to receive the index value. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetExtensionIndex( \ - hComponent, \ - cParameterName, \ - pIndexType) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex( \ - hComponent, \ - cParameterName, \ - pIndexType) /* Macro End */ - - -/** The OMX_GetState macro will invoke the component to get the current - state of the component and place the state value into the location - pointed to by pState. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] pState - pointer to the location to receive the state. The value returned - is one of the OMX_STATETYPE members - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetState( \ - hComponent, \ - pState) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetState( \ - hComponent, \ - pState) /* Macro End */ - - -/** The OMX_UseBuffer macro will request that the component use - a buffer (and allocate its own buffer header) already allocated - by another component, or by the IL Client. This is a blocking - call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] ppBuffer - pointer to an OMX_BUFFERHEADERTYPE structure used to receive the - pointer to the buffer header - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ - -#define OMX_UseBuffer( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes, \ - pBuffer) - - -/** The OMX_AllocateBuffer macro will request that the component allocate - a new buffer and buffer header. The component will allocate the - buffer and the buffer header and return a pointer to the buffer - header. This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] ppBuffer - pointer to an OMX_BUFFERHEADERTYPE structure used to receive - the pointer to the buffer header - @param [in] nPortIndex - nPortIndex is used to select the port on the component the buffer will - be used with. The port can be found by using the nPortIndex - value as an index into the Port Definition array of the component. - @param [in] pAppPrivate - pAppPrivate is used to initialize the pAppPrivate member of the - buffer header structure. - @param [in] nSizeBytes - size of the buffer to allocate. Used when bAllocateNew is true. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_AllocateBuffer( \ - hComponent, \ - ppBuffer, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes) \ - ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer( \ - hComponent, \ - ppBuffer, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes) /* Macro End */ - - -/** The OMX_FreeBuffer macro will release a buffer header from the component - which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If - the component allocated the buffer (see the OMX_UseBuffer macro) then - the component shall free the buffer and buffer header. This is a - blocking call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nPortIndex - nPortIndex is used to select the port on the component the buffer will - be used with. - @param [in] pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_FreeBuffer( \ - hComponent, \ - nPortIndex, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer( \ - hComponent, \ - nPortIndex, \ - pBuffer) /* Macro End */ - - -/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an - input port of a component. The buffer will be emptied by the component - and returned to the application via the EmptyBufferDone call back. - This is a non-blocking call in that the component will record the buffer - and return immediately and then empty the buffer, later, at the proper - time. As expected, this macro may be invoked only while the component - is in the OMX_StateExecuting. If nPortIndex does not specify an input - port, the component shall return an error. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_EmptyThisBuffer( \ - hComponent, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer( \ - hComponent, \ - pBuffer) /* Macro End */ - - -/** The OMX_FillThisBuffer macro will send an empty buffer to an - output port of a component. The buffer will be filled by the component - and returned to the application via the FillBufferDone call back. - This is a non-blocking call in that the component will record the buffer - and return immediately and then fill the buffer, later, at the proper - time. As expected, this macro may be invoked only while the component - is in the OMX_ExecutingState. If nPortIndex does not specify an output - port, the component shall return an error. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_FillThisBuffer( \ - hComponent, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer( \ - hComponent, \ - pBuffer) /* Macro End */ - - - -/** The OMX_UseEGLImage macro will request that the component use - a EGLImage provided by EGL (and allocate its own buffer header) - This is a blocking call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] ppBuffer - pointer to an OMX_BUFFERHEADERTYPE structure used to receive the - pointer to the buffer header. Note that the memory location used - for this buffer is NOT visible to the IL Client. - @param [in] nPortIndex - nPortIndex is used to select the port on the component the buffer will - be used with. The port can be found by using the nPortIndex - value as an index into the Port Definition array of the component. - @param [in] pAppPrivate - pAppPrivate is used to initialize the pAppPrivate member of the - buffer header structure. - @param [in] eglImage - eglImage contains the handle of the EGLImage to use as a buffer on the - specified port. The component is expected to validate properties of - the EGLImage against the configuration of the port to ensure the component - can use the EGLImage as a buffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_UseEGLImage( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - eglImage) \ - ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - eglImage) - -/** The OMX_Init method is used to initialize the OMX core. It shall be the - first call made into OMX and it should only be executed one time without - an interviening OMX_Deinit call. - - The core should return from this call within 20 msec. - - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void); - - -/** The OMX_Deinit method is used to deinitialize the OMX core. It shall be - the last call made into OMX. In the event that the core determines that - thare are components loaded when this call is made, the core may return - with an error rather than try to unload the components. - - The core should return from this call within 20 msec. - - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void); - - -/** The OMX_ComponentNameEnum method will enumerate through all the names of - recognised valid components in the system. This function is provided - as a means to detect all the components in the system run-time. There is - no strict ordering to the enumeration order of component names, although - each name will only be enumerated once. If the OMX core supports run-time - installation of new components, it is only requried to detect newly - installed components when the first call to enumerate component names - is made (i.e. when nIndex is 0x0). - - The core should return from this call in 20 msec. - - @param [out] cComponentName - pointer to a null terminated string with the component name. The - names of the components are strings less than 127 bytes in length - plus the trailing null for a maximum size of 128 bytes. An example - of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are - assigned by the vendor, but shall start with "OMX." and then have - the Vendor designation next. - @param [in] nNameLength - number of characters in the cComponentName string. With all - component name strings restricted to less than 128 characters - (including the trailing null) it is recomended that the caller - provide a input string for the cComponentName of 128 characters. - @param [in] nIndex - number containing the enumeration index for the component. - Multiple calls to OMX_ComponentNameEnum with increasing values - of nIndex will enumerate through the component names in the - system until OMX_ErrorNoMore is returned. The value of nIndex - is 0 to (N-1), where N is the number of valid installed components - in the system. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. When the value of nIndex exceeds the number of - components in the system minus 1, OMX_ErrorNoMore will be - returned. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum( - OMX_OUT OMX_STRING cComponentName, - OMX_IN OMX_U32 nNameLength, - OMX_IN OMX_U32 nIndex); - - -/** The OMX_GetHandle method will locate the component specified by the - component name given, load that component into memory and then invoke - the component's methods to create an instance of the component. - - The core should return from this call within 20 msec. - - @param [out] pHandle - pointer to an OMX_HANDLETYPE pointer to be filled in by this method. - @param [in] cComponentName - pointer to a null terminated string with the component name. The - names of the components are strings less than 127 bytes in length - plus the trailing null for a maximum size of 128 bytes. An example - of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are - assigned by the vendor, but shall start with "OMX." and then have - the Vendor designation next. - @param [in] pAppData - pointer to an application defined value that will be returned - during callbacks so that the application can identify the source - of the callback. - @param [in] pCallBacks - pointer to a OMX_CALLBACKTYPE structure that will be passed to the - component to initialize it with. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle( - OMX_OUT OMX_HANDLETYPE* pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_CALLBACKTYPE* pCallBacks); - - -/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle - method. If the component reference count goes to zero, the component will - be unloaded from memory. - - The core should return from this call within 20 msec when the component is - in the OMX_StateLoaded state. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle( - OMX_IN OMX_HANDLETYPE hComponent); - - - -/** The OMX_SetupTunnel method will handle the necessary calls to the components - to setup the specified tunnel the two components. NOTE: This is - an actual method (not a #define macro). This method will make calls into - the component ComponentTunnelRequest method to do the actual tunnel - connection. - - The ComponentTunnelRequest method on both components will be called. - This method shall not be called unless the component is in the - OMX_StateLoaded state except when the ports used for the tunnel are - disabled. In this case, the component may be in the OMX_StateExecuting, - OMX_StatePause, or OMX_StateIdle states. - - The core should return from this call within 20 msec. - - @param [in] hOutput - Handle of the component to be accessed. Also this is the handle - of the component whose port, specified in the nPortOutput parameter - will be used the source for the tunnel. This is the component handle - returned by the call to the OMX_GetHandle function. There is a - requirement that hOutput be the source for the data when - tunelling (i.e. nPortOutput is an output port). If 0x0, the component - specified in hInput will have it's port specified in nPortInput - setup for communication with the application / IL client. - @param [in] nPortOutput - nPortOutput is used to select the source port on component to be - used in the tunnel. - @param [in] hInput - This is the component to setup the tunnel with. This is the handle - of the component whose port, specified in the nPortInput parameter - will be used the destination for the tunnel. This is the component handle - returned by the call to the OMX_GetHandle function. There is a - requirement that hInput be the destination for the data when - tunelling (i.e. nPortInut is an input port). If 0x0, the component - specified in hOutput will have it's port specified in nPortPOutput - setup for communication with the application / IL client. - @param [in] nPortInput - nPortInput is used to select the destination port on component to be - used in the tunnel. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - When OMX_ErrorNotImplemented is returned, one or both components is - a non-interop component and does not support tunneling. - - On failure, the ports of both components are setup for communication - with the application / IL Client. - @ingroup core tun - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel( - OMX_IN OMX_HANDLETYPE hOutput, - OMX_IN OMX_U32 nPortOutput, - OMX_IN OMX_HANDLETYPE hInput, - OMX_IN OMX_U32 nPortInput); - -/** @ingroup cp */ -OMX_API OMX_ERRORTYPE OMX_GetContentPipe( - OMX_OUT OMX_HANDLETYPE *hPipe, - OMX_IN OMX_STRING szURI); - -/** The OMX_GetComponentsOfRole method will return the number of components that support the given - role and (if the compNames field is non-NULL) the names of those components. The call will fail if - an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the - client should: - * first call this function with the compNames field NULL to determine the number of component names - * second call this function with the compNames field pointing to an array of names allocated - according to the number returned by the first call. - - The core should return from this call within 5 msec. - - @param [in] role - This is generic standard component name consisting only of component class - name and the type within that class (e.g. 'audio_decoder.aac'). - @param [inout] pNumComps - This is used both as input and output. - - If compNames is NULL, the input is ignored and the output specifies how many components support - the given role. - - If compNames is not NULL, on input it bounds the size of the input structure and - on output, it specifies the number of components string names listed within the compNames parameter. - @param [inout] compNames - If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts - a list of the names of all physical components that implement the specified standard component name. - Each name is NULL terminated. numComps indicates the number of names. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole ( - OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 *pNumComps, - OMX_INOUT OMX_U8 **compNames); - -/** The OMX_GetRolesOfComponent method will return the number of roles supported by the given - component and (if the roles field is non-NULL) the names of those roles. The call will fail if - an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the - client should: - * first call this function with the roles field NULL to determine the number of role names - * second call this function with the roles field pointing to an array of names allocated - according to the number returned by the first call. - - The core should return from this call within 5 msec. - - @param [in] compName - This is the name of the component being queried about. - @param [inout] pNumRoles - This is used both as input and output. - - If roles is NULL, the input is ignored and the output specifies how many roles the component supports. - - If compNames is not NULL, on input it bounds the size of the input structure and - on output, it specifies the number of roles string names listed within the roles parameter. - @param [out] roles - If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings - which accepts a list of the names of all standard components roles implemented on the - specified component name. numComps indicates the number of names. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( - OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 *pNumRoles, - OMX_OUT OMX_U8 **roles); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ - diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_IVCommon.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_IVCommon.h deleted file mode 100644 index f9b6f4b0fd279a..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_IVCommon.h +++ /dev/null @@ -1,958 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/** - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** - * @file OMX_IVCommon.h - OpenMax IL version 1.1.2 - * The structures needed by Video and Image components to exchange - * parameters and configuration data with the components. - */ -#ifndef OMX_IVCommon_h -#define OMX_IVCommon_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Each OMX header must include all required header files to allow the header - * to compile without errors. The includes below are required for this header - * file to compile successfully - */ - -#include - -/** @defgroup iv OpenMAX IL Imaging and Video Domain - * Common structures for OpenMAX IL Imaging and Video domains - * @{ - */ - - -/** - * Enumeration defining possible uncompressed image/video formats. - * - * ENUMS: - * Unused : Placeholder value when format is N/A - * Monochrome : black and white - * 8bitRGB332 : Red 7:5, Green 4:2, Blue 1:0 - * 12bitRGB444 : Red 11:8, Green 7:4, Blue 3:0 - * 16bitARGB4444 : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0 - * 16bitARGB1555 : Alpha 15, Red 14:10, Green 9:5, Blue 4:0 - * 16bitRGB565 : Red 15:11, Green 10:5, Blue 4:0 - * 16bitBGR565 : Blue 15:11, Green 10:5, Red 4:0 - * 18bitRGB666 : Red 17:12, Green 11:6, Blue 5:0 - * 18bitARGB1665 : Alpha 17, Red 16:11, Green 10:5, Blue 4:0 - * 19bitARGB1666 : Alpha 18, Red 17:12, Green 11:6, Blue 5:0 - * 24bitRGB888 : Red 24:16, Green 15:8, Blue 7:0 - * 24bitBGR888 : Blue 24:16, Green 15:8, Red 7:0 - * 24bitARGB1887 : Alpha 23, Red 22:15, Green 14:7, Blue 6:0 - * 25bitARGB1888 : Alpha 24, Red 23:16, Green 15:8, Blue 7:0 - * 32bitBGRA8888 : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0 - * 32bitARGB8888 : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0 - * YUV411Planar : U,Y are subsampled by a factor of 4 horizontally - * YUV411PackedPlanar : packed per payload in planar slices - * YUV420Planar : Three arrays Y,U,V. - * YUV420PackedPlanar : packed per payload in planar slices - * YUV420SemiPlanar : Two arrays, one is all Y, the other is U and V - * YUV422Planar : Three arrays Y,U,V. - * YUV422PackedPlanar : packed per payload in planar slices - * YUV422SemiPlanar : Two arrays, one is all Y, the other is U and V - * YCbYCr : Organized as 16bit YUYV (i.e. YCbYCr) - * YCrYCb : Organized as 16bit YVYU (i.e. YCrYCb) - * CbYCrY : Organized as 16bit UYVY (i.e. CbYCrY) - * CrYCbY : Organized as 16bit VYUY (i.e. CrYCbY) - * YUV444Interleaved : Each pixel contains equal parts YUV - * RawBayer8bit : SMIA camera output format - * RawBayer10bit : SMIA camera output format - * RawBayer8bitcompressed : SMIA camera output format - */ -typedef enum OMX_COLOR_FORMATTYPE { - OMX_COLOR_FormatUnused, - OMX_COLOR_FormatMonochrome, - OMX_COLOR_Format8bitRGB332, - OMX_COLOR_Format12bitRGB444, - OMX_COLOR_Format16bitARGB4444, - OMX_COLOR_Format16bitARGB1555, - OMX_COLOR_Format16bitRGB565, - OMX_COLOR_Format16bitBGR565, - OMX_COLOR_Format18bitRGB666, - OMX_COLOR_Format18bitARGB1665, - OMX_COLOR_Format19bitARGB1666, - OMX_COLOR_Format24bitRGB888, - OMX_COLOR_Format24bitBGR888, - OMX_COLOR_Format24bitARGB1887, - OMX_COLOR_Format25bitARGB1888, - OMX_COLOR_Format32bitBGRA8888, - OMX_COLOR_Format32bitARGB8888, - OMX_COLOR_FormatYUV411Planar, - OMX_COLOR_FormatYUV411PackedPlanar, - OMX_COLOR_FormatYUV420Planar, - OMX_COLOR_FormatYUV420PackedPlanar, - OMX_COLOR_FormatYUV420SemiPlanar, - OMX_COLOR_FormatYUV422Planar, - OMX_COLOR_FormatYUV422PackedPlanar, - OMX_COLOR_FormatYUV422SemiPlanar, - OMX_COLOR_FormatYCbYCr, - OMX_COLOR_FormatYCrYCb, - OMX_COLOR_FormatCbYCrY, - OMX_COLOR_FormatCrYCbY, - OMX_COLOR_FormatYUV444Interleaved, - OMX_COLOR_FormatRawBayer8bit, - OMX_COLOR_FormatRawBayer10bit, - OMX_COLOR_FormatRawBayer8bitcompressed, - OMX_COLOR_FormatL2, - OMX_COLOR_FormatL4, - OMX_COLOR_FormatL8, - OMX_COLOR_FormatL16, - OMX_COLOR_FormatL24, - OMX_COLOR_FormatL32, - OMX_COLOR_FormatYUV420PackedSemiPlanar, - OMX_COLOR_FormatYUV422PackedSemiPlanar, - OMX_COLOR_Format18BitBGR666, - OMX_COLOR_Format24BitARGB6666, - OMX_COLOR_Format24BitABGR6666, - OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - /** - -/** @defgroup imaging OpenMAX IL Imaging Domain - * @ingroup iv - * Structures for OpenMAX IL Imaging domain - * @{ - */ - -/** - * Enumeration used to define the possible image compression coding. - */ -typedef enum OMX_IMAGE_CODINGTYPE { - OMX_IMAGE_CodingUnused, /**< Value when format is N/A */ - OMX_IMAGE_CodingAutoDetect, /**< Auto detection of image format */ - OMX_IMAGE_CodingJPEG, /**< JPEG/JFIF image format */ - OMX_IMAGE_CodingJPEG2K, /**< JPEG 2000 image format */ - OMX_IMAGE_CodingEXIF, /**< EXIF image format */ - OMX_IMAGE_CodingTIFF, /**< TIFF image format */ - OMX_IMAGE_CodingGIF, /**< Graphics image format */ - OMX_IMAGE_CodingPNG, /**< PNG image format */ - OMX_IMAGE_CodingLZW, /**< LZW image format */ - OMX_IMAGE_CodingBMP, /**< Windows Bitmap format */ - OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_CodingMax = 0x7FFFFFFF -} OMX_IMAGE_CODINGTYPE; - - -/** - * Data structure used to define an image path. The number of image paths - * for input and output will vary by type of the image component. - * - * Input (aka Source) : Zero Inputs, one Output, - * Splitter : One Input, 2 or more Outputs, - * Processing Element : One Input, one output, - * Mixer : 2 or more inputs, one output, - * Output (aka Sink) : One Input, zero outputs. - * - * The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output - * image path. If additional vendor specific data is required, it should - * be transmitted to the component using the CustomCommand function. - * Compliant components will prepopulate this structure with optimal - * values during the OMX_GetParameter() command. - * - * STRUCT MEMBERS: - * cMIMEType : MIME type of data for the port - * pNativeRender : Platform specific reference for a display if a - * sync, otherwise this field is 0 - * nFrameWidth : Width of frame to be used on port if - * uncompressed format is used. Use 0 for - * unknown, don't care or variable - * nFrameHeight : Height of frame to be used on port if - * uncompressed format is used. Use 0 for - * unknown, don't care or variable - * nStride : Number of bytes per span of an image (i.e. - * indicates the number of bytes to get from - * span N to span N+1, where negative stride - * indicates the image is bottom up - * nSliceHeight : Height used when encoding in slices - * bFlagErrorConcealment : Turns on error concealment if it is supported by - * the OMX component - * eCompressionFormat : Compression format used in this instance of - * the component. When OMX_IMAGE_CodingUnused is - * specified, eColorFormat is valid - * eColorFormat : Decompressed format used by this component - * pNativeWindow : Platform specific reference for a window object if a - * display sink , otherwise this field is 0x0. - */ -typedef struct OMX_IMAGE_PORTDEFINITIONTYPE { - OMX_STRING cMIMEType; - OMX_NATIVE_DEVICETYPE pNativeRender; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - OMX_S32 nStride; - OMX_U32 nSliceHeight; - OMX_BOOL bFlagErrorConcealment; - OMX_IMAGE_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_NATIVE_WINDOWTYPE pNativeWindow; -} OMX_IMAGE_PORTDEFINITIONTYPE; - - -/** - * Port format parameter. This structure is used to enumerate the various - * data input/output format supported by the port. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Indicates which port to set - * nIndex : Indicates the enumeration index for the format from - * 0x0 to N-1 - * eCompressionFormat : Compression format used in this instance of the - * component. When OMX_IMAGE_CodingUnused is specified, - * eColorFormat is valid - * eColorFormat : Decompressed format used by this component - */ -typedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nIndex; - OMX_IMAGE_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; -} OMX_IMAGE_PARAM_PORTFORMATTYPE; - - -/** - * Flash control type - * - * ENUMS - * Torch : Flash forced constantly on - */ -typedef enum OMX_IMAGE_FLASHCONTROLTYPE { - OMX_IMAGE_FlashControlOn = 0, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FlashControlRedEyeReduction, - OMX_IMAGE_FlashControlFillin, - OMX_IMAGE_FlashControlTorch, - OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_FlashControlMax = 0x7FFFFFFF -} OMX_IMAGE_FLASHCONTROLTYPE; - - -/** - * Flash control configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFlashControl : Flash control type - */ -typedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_FLASHCONTROLTYPE eFlashControl; -} OMX_IMAGE_PARAM_FLASHCONTROLTYPE; - - -/** - * Focus control type - */ -typedef enum OMX_IMAGE_FOCUSCONTROLTYPE { - OMX_IMAGE_FocusControlOn = 0, - OMX_IMAGE_FocusControlOff, - OMX_IMAGE_FocusControlAuto, - OMX_IMAGE_FocusControlAutoLock, - OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_FocusControlMax = 0x7FFFFFFF -} OMX_IMAGE_FOCUSCONTROLTYPE; - - -/** - * Focus control configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFocusControl : Focus control - * nFocusSteps : Focus can take on values from 0 mm to infinity. - * Interest is only in number of steps over this range. - * nFocusStepIndex : Current focus step index - */ -typedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl; - OMX_U32 nFocusSteps; - OMX_U32 nFocusStepIndex; -} OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE; - - -/** - * Q Factor for JPEG compression, which controls the tradeoff between image - * quality and size. Q Factor provides a more simple means of controlling - * JPEG compression quality, without directly programming Quantization - * tables for chroma and luma - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nQFactor : JPEG Q factor value in the range of 1-100. A factor of 1 - * produces the smallest, worst quality images, and a factor - * of 100 produces the largest, best quality images. A - * typical default is 75 for small good quality images - */ -typedef struct OMX_IMAGE_PARAM_QFACTORTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nQFactor; -} OMX_IMAGE_PARAM_QFACTORTYPE; - -/** - * Quantization table type - */ - -typedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE { - OMX_IMAGE_QuantizationTableLuma = 0, - OMX_IMAGE_QuantizationTableChroma, - OMX_IMAGE_QuantizationTableChromaCb, - OMX_IMAGE_QuantizationTableChromaCr, - OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF -} OMX_IMAGE_QUANTIZATIONTABLETYPE; - -/** - * JPEG quantization tables are used to determine DCT compression for - * YUV data, as an alternative to specifying Q factor, providing exact - * control of compression - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eQuantizationTable : Quantization table type - * nQuantizationMatrix[64] : JPEG quantization table of coefficients stored - * in increasing columns then by rows of data (i.e. - * row 1, ... row 8). Quantization values are in - * the range 0-255 and stored in linear order - * (i.e. the component will zig-zag the - * quantization table data if required internally) - */ -typedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable; - OMX_U8 nQuantizationMatrix[64]; -} OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE; - - -/** - * Huffman table type, the same Huffman table is applied for chroma and - * luma component - */ -typedef enum OMX_IMAGE_HUFFMANTABLETYPE { - OMX_IMAGE_HuffmanTableAC = 0, - OMX_IMAGE_HuffmanTableDC, - OMX_IMAGE_HuffmanTableACLuma, - OMX_IMAGE_HuffmanTableACChroma, - OMX_IMAGE_HuffmanTableDCLuma, - OMX_IMAGE_HuffmanTableDCChroma, - OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF -} OMX_IMAGE_HUFFMANTABLETYPE; - -/** - * JPEG Huffman table - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eHuffmanTable : Huffman table type - * nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each - * possible length - * nHuffmanTable[256] : 0-255, the size used for AC and DC - * HuffmanTable are 16 and 162 - */ -typedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable; - OMX_U8 nNumberOfHuffmanCodeOfLength[16]; - OMX_U8 nHuffmanTable[256]; -}OMX_IMAGE_PARAM_HUFFMANTTABLETYPE; - -/** @} */ -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Index.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_Index.h deleted file mode 100644 index 1a2a548e88ad84..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Index.h +++ /dev/null @@ -1,274 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/* - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** @file OMX_Index.h - OpenMax IL version 1.1.2 - * The OMX_Index header file contains the definitions for both applications - * and components . - */ - - -#ifndef OMX_Index_h -#define OMX_Index_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Each OMX header must include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ -#include - -/** The OMX_INDEXTYPE enumeration is used to select a structure when either - * getting or setting parameters and/or configuration data. Each entry in - * this enumeration maps to an OMX specified structure. When the - * OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods - * are used, the second parameter will always be an entry from this enumeration - * and the third entry will be the structure shown in the comments for the entry. - * For example, if the application is initializing a cropping function, the - * OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter - * and would send a pointer to an initialized OMX_RECTTYPE structure as the - * third parameter. - * - * The enumeration entries named with the OMX_Config prefix are sent using - * the OMX_SetConfig command and the enumeration entries named with the - * OMX_PARAM_ prefix are sent using the OMX_SetParameter command. - */ -typedef enum OMX_INDEXTYPE { - - OMX_IndexComponentStartUnused = 0x01000000, - OMX_IndexParamPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ - OMX_IndexParamAudioInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamImageInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamVideoInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamOtherInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamNumAvailableStreams, /**< reference: OMX_PARAM_U32TYPE */ - OMX_IndexParamActiveStream, /**< reference: OMX_PARAM_U32TYPE */ - OMX_IndexParamSuspensionPolicy, /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */ - OMX_IndexParamComponentSuspended, /**< reference: OMX_PARAM_SUSPENSIONTYPE */ - OMX_IndexConfigCapturing, /**< reference: OMX_CONFIG_BOOLEANTYPE */ - OMX_IndexConfigCaptureMode, /**< reference: OMX_CONFIG_CAPTUREMODETYPE */ - OMX_IndexAutoPauseAfterCapture, /**< reference: OMX_CONFIG_BOOLEANTYPE */ - OMX_IndexParamContentURI, /**< reference: OMX_PARAM_CONTENTURITYPE */ - OMX_IndexParamCustomContentPipe, /**< reference: OMX_PARAM_CONTENTPIPETYPE */ - OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */ - OMX_IndexConfigMetadataItemCount, /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */ - OMX_IndexConfigContainerNodeCount, /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */ - OMX_IndexConfigMetadataItem, /**< reference: OMX_CONFIG_METADATAITEMTYPE */ - OMX_IndexConfigCounterNodeID, /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */ - OMX_IndexParamMetadataFilterType, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ - OMX_IndexParamMetadataKeyFilter, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ - OMX_IndexConfigPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ - OMX_IndexParamStandardComponentRole, /**< reference: OMX_PARAM_COMPONENTROLETYPE */ - - OMX_IndexPortStartUnused = 0x02000000, - OMX_IndexParamPortDefinition, /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */ - OMX_IndexParamCompBufferSupplier, /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */ - OMX_IndexReservedStartUnused = 0x03000000, - - /* Audio parameters and configurations */ - OMX_IndexAudioStartUnused = 0x04000000, - OMX_IndexParamAudioPortFormat, /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */ - OMX_IndexParamAudioPcm, /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */ - OMX_IndexParamAudioAac, /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */ - OMX_IndexParamAudioRa, /**< reference: OMX_AUDIO_PARAM_RATYPE */ - OMX_IndexParamAudioMp3, /**< reference: OMX_AUDIO_PARAM_MP3TYPE */ - OMX_IndexParamAudioAdpcm, /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */ - OMX_IndexParamAudioG723, /**< reference: OMX_AUDIO_PARAM_G723TYPE */ - OMX_IndexParamAudioG729, /**< reference: OMX_AUDIO_PARAM_G729TYPE */ - OMX_IndexParamAudioAmr, /**< reference: OMX_AUDIO_PARAM_AMRTYPE */ - OMX_IndexParamAudioWma, /**< reference: OMX_AUDIO_PARAM_WMATYPE */ - OMX_IndexParamAudioSbc, /**< reference: OMX_AUDIO_PARAM_SBCTYPE */ - OMX_IndexParamAudioMidi, /**< reference: OMX_AUDIO_PARAM_MIDITYPE */ - OMX_IndexParamAudioGsm_FR, /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */ - OMX_IndexParamAudioMidiLoadUserSound, /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */ - OMX_IndexParamAudioG726, /**< reference: OMX_AUDIO_PARAM_G726TYPE */ - OMX_IndexParamAudioGsm_EFR, /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */ - OMX_IndexParamAudioGsm_HR, /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */ - OMX_IndexParamAudioPdc_FR, /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */ - OMX_IndexParamAudioPdc_EFR, /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */ - OMX_IndexParamAudioPdc_HR, /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */ - OMX_IndexParamAudioTdma_FR, /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */ - OMX_IndexParamAudioTdma_EFR, /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */ - OMX_IndexParamAudioQcelp8, /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */ - OMX_IndexParamAudioQcelp13, /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */ - OMX_IndexParamAudioEvrc, /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */ - OMX_IndexParamAudioSmv, /**< reference: OMX_AUDIO_PARAM_SMVTYPE */ - OMX_IndexParamAudioVorbis, /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */ - OMX_IndexParamAudioFlac, /**< reference: OMX_AUDIO_PARAM_FLACTYPE */ - - OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */ - OMX_IndexConfigAudioMidiControl, /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */ - OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */ - OMX_IndexConfigAudioMidiStatus, /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */ - OMX_IndexConfigAudioMidiMetaEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */ - OMX_IndexConfigAudioMidiMetaEventData, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */ - OMX_IndexConfigAudioVolume, /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */ - OMX_IndexConfigAudioBalance, /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */ - OMX_IndexConfigAudioChannelMute, /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */ - OMX_IndexConfigAudioMute, /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */ - OMX_IndexConfigAudioLoudness, /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */ - OMX_IndexConfigAudioEchoCancelation, /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */ - OMX_IndexConfigAudioNoiseReduction, /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */ - OMX_IndexConfigAudioBass, /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */ - OMX_IndexConfigAudioTreble, /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */ - OMX_IndexConfigAudioStereoWidening, /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */ - OMX_IndexConfigAudioChorus, /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */ - OMX_IndexConfigAudioEqualizer, /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */ - OMX_IndexConfigAudioReverberation, /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */ - OMX_IndexConfigAudioChannelVolume, /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */ - - /* Image specific parameters and configurations */ - OMX_IndexImageStartUnused = 0x05000000, - OMX_IndexParamImagePortFormat, /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */ - OMX_IndexParamFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ - OMX_IndexConfigFocusControl, /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */ - OMX_IndexParamQFactor, /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */ - OMX_IndexParamQuantizationTable, /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */ - OMX_IndexParamHuffmanTable, /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */ - OMX_IndexConfigFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ - - /* Video specific parameters and configurations */ - OMX_IndexVideoStartUnused = 0x06000000, - OMX_IndexParamVideoPortFormat, /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */ - OMX_IndexParamVideoQuantization, /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */ - OMX_IndexParamVideoFastUpdate, /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */ - OMX_IndexParamVideoBitrate, /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */ - OMX_IndexParamVideoMotionVector, /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */ - OMX_IndexParamVideoIntraRefresh, /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */ - OMX_IndexParamVideoErrorCorrection, /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */ - OMX_IndexParamVideoVBSMC, /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */ - OMX_IndexParamVideoMpeg2, /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */ - OMX_IndexParamVideoMpeg4, /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */ - OMX_IndexParamVideoWmv, /**< reference: OMX_VIDEO_PARAM_WMVTYPE */ - OMX_IndexParamVideoRv, /**< reference: OMX_VIDEO_PARAM_RVTYPE */ - OMX_IndexParamVideoAvc, /**< reference: OMX_VIDEO_PARAM_AVCTYPE */ - OMX_IndexParamVideoH263, /**< reference: OMX_VIDEO_PARAM_H263TYPE */ - OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ - OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ - OMX_IndexConfigVideoBitrate, /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */ - OMX_IndexConfigVideoFramerate, /**< reference: OMX_CONFIG_FRAMERATETYPE */ - OMX_IndexConfigVideoIntraVOPRefresh, /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */ - OMX_IndexConfigVideoIntraMBRefresh, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ - OMX_IndexConfigVideoMBErrorReporting, /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */ - OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */ - OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ - OMX_IndexParamVideoSliceFMO, /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */ - OMX_IndexConfigVideoAVCIntraPeriod, /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */ - OMX_IndexConfigVideoNalSize, /**< reference: OMX_VIDEO_CONFIG_NALSIZE */ - - /* Image & Video common Configurations */ - OMX_IndexCommonStartUnused = 0x07000000, - OMX_IndexParamCommonDeblocking, /**< reference: OMX_PARAM_DEBLOCKINGTYPE */ - OMX_IndexParamCommonSensorMode, /**< reference: OMX_PARAM_SENSORMODETYPE */ - OMX_IndexParamCommonInterleave, /**< reference: OMX_PARAM_INTERLEAVETYPE */ - OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */ - OMX_IndexConfigCommonScale, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ - OMX_IndexConfigCommonImageFilter, /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */ - OMX_IndexConfigCommonColorEnhancement, /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */ - OMX_IndexConfigCommonColorKey, /**< reference: OMX_CONFIG_COLORKEYTYPE */ - OMX_IndexConfigCommonColorBlend, /**< reference: OMX_CONFIG_COLORBLENDTYPE */ - OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */ - OMX_IndexConfigCommonRotate, /**< reference: OMX_CONFIG_ROTATIONTYPE */ - OMX_IndexConfigCommonMirror, /**< reference: OMX_CONFIG_MIRRORTYPE */ - OMX_IndexConfigCommonOutputPosition, /**< reference: OMX_CONFIG_POINTTYPE */ - OMX_IndexConfigCommonInputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ - OMX_IndexConfigCommonOutputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ - OMX_IndexConfigCommonDigitalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ - OMX_IndexConfigCommonOpticalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/ - OMX_IndexConfigCommonWhiteBalance, /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */ - OMX_IndexConfigCommonExposure, /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */ - OMX_IndexConfigCommonContrast, /**< reference: OMX_CONFIG_CONTRASTTYPE */ - OMX_IndexConfigCommonBrightness, /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */ - OMX_IndexConfigCommonBacklight, /**< reference: OMX_CONFIG_BACKLIGHTTYPE */ - OMX_IndexConfigCommonGamma, /**< reference: OMX_CONFIG_GAMMATYPE */ - OMX_IndexConfigCommonSaturation, /**< reference: OMX_CONFIG_SATURATIONTYPE */ - OMX_IndexConfigCommonLightness, /**< reference: OMX_CONFIG_LIGHTNESSTYPE */ - OMX_IndexConfigCommonExclusionRect, /**< reference: OMX_CONFIG_RECTTYPE */ - OMX_IndexConfigCommonDithering, /**< reference: OMX_CONFIG_DITHERTYPE */ - OMX_IndexConfigCommonPlaneBlend, /**< reference: OMX_CONFIG_PLANEBLENDTYPE */ - OMX_IndexConfigCommonExposureValue, /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */ - OMX_IndexConfigCommonOutputSize, /**< reference: OMX_FRAMESIZETYPE */ - OMX_IndexParamCommonExtraQuantData, /**< reference: OMX_OTHER_EXTRADATATYPE */ - OMX_IndexConfigCommonFocusRegion, /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */ - OMX_IndexConfigCommonFocusStatus, /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */ - OMX_IndexConfigCommonTransitionEffect, /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */ - - /* Reserved Configuration range */ - OMX_IndexOtherStartUnused = 0x08000000, - OMX_IndexParamOtherPortFormat, /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */ - OMX_IndexConfigOtherPower, /**< reference: OMX_OTHER_CONFIG_POWERTYPE */ - OMX_IndexConfigOtherStats, /**< reference: OMX_OTHER_CONFIG_STATSTYPE */ - - - /* Reserved Time range */ - OMX_IndexTimeStartUnused = 0x09000000, - OMX_IndexConfigTimeScale, /**< reference: OMX_TIME_CONFIG_SCALETYPE */ - OMX_IndexConfigTimeClockState, /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */ - OMX_IndexConfigTimeActiveRefClock, /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */ - OMX_IndexConfigTimeCurrentMediaTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ - OMX_IndexConfigTimeCurrentWallTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ - OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ - OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ - OMX_IndexConfigTimeMediaTimeRequest, /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */ - OMX_IndexConfigTimeClientStartTime, /** - - -/** Khronos standard extension indices. - -This enum lists the current Khronos extension indices to OpenMAX IL. -*/ -typedef enum OMX_INDEXEXTTYPE { - - /* Component parameters and configurations */ - OMX_IndexExtComponentStartUnused = OMX_IndexKhronosExtensions + 0x00100000, - OMX_IndexConfigCallbackRequest, /**< reference: OMX_CONFIG_CALLBACKREQUESTTYPE */ - OMX_IndexConfigCommitMode, /**< reference: OMX_CONFIG_COMMITMODETYPE */ - OMX_IndexConfigCommit, /**< reference: OMX_CONFIG_COMMITTYPE */ - - /* Port parameters and configurations */ - OMX_IndexExtPortStartUnused = OMX_IndexKhronosExtensions + 0x00200000, - - /* Audio parameters and configurations */ - OMX_IndexExtAudioStartUnused = OMX_IndexKhronosExtensions + 0x00400000, - OMX_IndexParamAudioAndroidAc3, /**< reference: OMX_AUDIO_PARAM_ANDROID_AC3TYPE */ - OMX_IndexParamAudioAndroidOpus, /**< reference: OMX_AUDIO_PARAM_ANDROID_OPUSTYPE */ - OMX_IndexParamAudioAndroidAacPresentation, /**< reference: OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE */ - OMX_IndexParamAudioAndroidEac3, /**< reference: OMX_AUDIO_PARAM_ANDROID_EAC3TYPE */ - - /* Image parameters and configurations */ - OMX_IndexExtImageStartUnused = OMX_IndexKhronosExtensions + 0x00500000, - - /* Video parameters and configurations */ - OMX_IndexExtVideoStartUnused = OMX_IndexKhronosExtensions + 0x00600000, - OMX_IndexParamNalStreamFormatSupported, /**< reference: OMX_NALSTREAMFORMATTYPE */ - OMX_IndexParamNalStreamFormat, /**< reference: OMX_NALSTREAMFORMATTYPE */ - OMX_IndexParamNalStreamFormatSelect, /**< reference: OMX_NALSTREAMFORMATTYPE */ - OMX_IndexParamVideoVp8, /**< reference: OMX_VIDEO_PARAM_VP8TYPE */ - OMX_IndexConfigVideoVp8ReferenceFrame, /**< reference: OMX_VIDEO_VP8REFERENCEFRAMETYPE */ - OMX_IndexConfigVideoVp8ReferenceFrameType, /**< reference: OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE */ - OMX_IndexParamVideoAndroidVp8Encoder, /**< reference: OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE */ - OMX_IndexParamVideoHevc, /**< reference: OMX_VIDEO_PARAM_HEVCTYPE */ - OMX_IndexParamSliceSegments, /**< reference: OMX_VIDEO_SLICESEGMENTSTYPE */ - - /* Image & Video common configurations */ - OMX_IndexExtCommonStartUnused = OMX_IndexKhronosExtensions + 0x00700000, - - /* Other configurations */ - OMX_IndexExtOtherStartUnused = OMX_IndexKhronosExtensions + 0x00800000, - OMX_IndexConfigAutoFramerateConversion, /**< reference: OMX_CONFIG_BOOLEANTYPE */ - OMX_IndexConfigPriority, /**< reference: OMX_PARAM_U32TYPE */ - OMX_IndexConfigOperatingRate, /**< reference: OMX_PARAM_U32TYPE in Q16 format for video and in Hz for audio */ - OMX_IndexParamConsumerUsageBits, /**< reference: OMX_PARAM_U32TYPE */ - - /* Time configurations */ - OMX_IndexExtTimeStartUnused = OMX_IndexKhronosExtensions + 0x00900000, - - OMX_IndexExtMax = 0x7FFFFFFF -} OMX_INDEXEXTTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* OMX_IndexExt_h */ -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Other.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_Other.h deleted file mode 100644 index 6072ef62c8614b..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Other.h +++ /dev/null @@ -1,354 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/* - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** @file OMX_Other.h - OpenMax IL version 1.1.2 - * The structures needed by Other components to exchange - * parameters and configuration data with the components. - */ - -#ifndef OMX_Other_h -#define OMX_Other_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/* Each OMX header must include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ - -#include - - -/** - * Enumeration of possible data types which match to multiple domains or no - * domain at all. For types which are vendor specific, a value above - * OMX_OTHER_VENDORTSTART should be used. - */ -typedef enum OMX_OTHER_FORMATTYPE { - OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time, - time deltas, etc */ - OMX_OTHER_FormatPower, /**< Perhaps used for enabling/disabling power - management, setting clocks? */ - OMX_OTHER_FormatStats, /**< Could be things such as frame rate, frames - dropped, etc */ - OMX_OTHER_FormatBinary, /**< Arbitrary binary data */ - OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific - formats */ - - OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_OTHER_FormatMax = 0x7FFFFFFF -} OMX_OTHER_FORMATTYPE; - -/** - * Enumeration of seek modes. - */ -typedef enum OMX_TIME_SEEKMODETYPE { - OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation - * of the requested seek position over - * the actual seek position if it - * results in a faster seek. */ - OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek - * position over an approximation - * of the requested seek position even - * if it results in a slower seek. */ - OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_SeekModeMax = 0x7FFFFFFF -} OMX_TIME_SEEKMODETYPE; - -/* Structure representing the seekmode of the component */ -typedef struct OMX_TIME_CONFIG_SEEKMODETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_TIME_SEEKMODETYPE eType; /**< The seek mode */ -} OMX_TIME_CONFIG_SEEKMODETYPE; - -/** Structure representing a time stamp used with the following configs - * on the Clock Component (CC): - * - * OMX_IndexConfigTimeCurrentWallTime: query of the CC's current wall - * time - * OMX_IndexConfigTimeCurrentMediaTime: query of the CC's current media - * time - * OMX_IndexConfigTimeCurrentAudioReference and - * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference - * clock sending SC its reference time - * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends - * this structure to the Clock Component via a SetConfig on its - * client port when it receives a buffer with - * OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp - * specified by that buffer for nStartTimestamp. - * - * It's also used with the following config on components in general: - * - * OMX_IndexConfigTimePosition: IL client querying component position - * (GetConfig) or commanding a component to seek to the given location - * (SetConfig) - */ -typedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version - * information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_TICKS nTimestamp; /**< timestamp .*/ -} OMX_TIME_CONFIG_TIMESTAMPTYPE; - -/** Enumeration of possible reference clocks to the media time. */ -typedef enum OMX_TIME_UPDATETYPE { - OMX_TIME_UpdateRequestFulfillment, /**< Update is the fulfillment of a media time request. */ - OMX_TIME_UpdateScaleChanged, /**< Update was generated because the scale chagned. */ - OMX_TIME_UpdateClockStateChanged, /**< Update was generated because the clock state changed. */ - OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_UpdateMax = 0x7FFFFFFF -} OMX_TIME_UPDATETYPE; - -/** Enumeration of possible reference clocks to the media time. */ -typedef enum OMX_TIME_REFCLOCKTYPE { - OMX_TIME_RefClockNone, /**< Use no references. */ - OMX_TIME_RefClockAudio, /**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */ - OMX_TIME_RefClockVideo, /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */ - OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_RefClockMax = 0x7FFFFFFF -} OMX_TIME_REFCLOCKTYPE; - -/** Enumeration of clock states. */ -typedef enum OMX_TIME_CLOCKSTATE { - OMX_TIME_ClockStateRunning, /**< Clock running. */ - OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the - * prescribed clients emit their - * start time. */ - OMX_TIME_ClockStateStopped, /**< Clock stopped. */ - OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_ClockStateMax = 0x7FFFFFFF -} OMX_TIME_CLOCKSTATE; - -/** Structure representing a media time request to the clock component. - * - * A client component sends this structure to the Clock Component via a SetConfig - * on its client port to specify a media timestamp the Clock Component - * should emit. The Clock Component should fulfill the request by sending a - * OMX_TIME_MEDIATIMETYPE when its media clock matches the requested - * timestamp. - * - * The client may require a media time request be fulfilled slightly - * earlier than the media time specified. In this case the client specifies - * an offset which is equal to the difference between wall time corresponding - * to the requested media time and the wall time when it will be - * fulfilled. - * - * A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to - * time events according to timestamps. If a client must perform an operation O at - * a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a - * media time request at T (perhaps specifying an offset to ensure the request fulfillment - * is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE - * structure back to the client component, the client may perform operation O (perhaps having - * to wait a slight amount more time itself as specified by the return values). - */ - -typedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_PTR pClientPrivate; /**< Client private data to disabiguate this media time - * from others (e.g. the number of the frame to deliver). - * Duplicated in the media time structure that fulfills - * this request. A value of zero is reserved for time scale - * updates. */ - OMX_TICKS nMediaTimestamp; /**< Media timestamp requested.*/ - OMX_TICKS nOffset; /**< Amount of wall clock time by which this - * request should be fulfilled early */ -} OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE; - -/**< Structure sent from the clock component client either when fulfilling - * a media time request or when the time scale has changed. - * - * In the former case the Clock Component fills this structure and times its emission - * to a client component (via the client port) according to the corresponding media - * time request sent by the client. The Clock Component should time the emission to occur - * when the requested timestamp matches the Clock Component's media time but also the - * prescribed offset early. - * - * Upon scale changes the clock component clears the nClientPrivate data, sends the current - * media time and sets the nScale to the new scale via the client port. It emits a - * OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to - * alter processing to accomodate scaling. For instance a video component might skip inter-frames - * in the case of extreme fastforward. Likewise an audio component might add or remove samples - * from an audio frame to scale audio data. - * - * It is expected that some clock components may not be able to fulfill requests - * at exactly the prescribed time. This is acceptable so long as the request is - * fulfilled at least as early as described and not later. This structure provides - * fields the client may use to wait for the remaining time. - * - * The client may use either the nOffset or nWallTimeAtMedia fields to determine the - * wall time until the nMediaTimestamp actually occurs. In the latter case the - * client can get a more accurate value for offset by getting the current wall - * from the cloc component and subtracting it from nWallTimeAtMedia. - */ - -typedef struct OMX_TIME_MEDIATIMETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nClientPrivate; /**< Client private data to disabiguate this media time - * from others. Copied from the media time request. - * A value of zero is reserved for time scale updates. */ - OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */ - OMX_TICKS nMediaTimestamp; /**< Media time requested. If no media time was - * requested then this is the current media time. */ - OMX_TICKS nOffset; /**< Amount of wall clock time by which this - * request was actually fulfilled early */ - - OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp. - * A client may compare this value to current - * media time obtained from the Clock Component to determine - * the wall time until the media timestamp is really - * current. */ - OMX_S32 xScale; /**< Current media time scale in Q16 format. */ - OMX_TIME_CLOCKSTATE eState; /* Seeking Change. Added 7/12.*/ - /**< State of the media time. */ -} OMX_TIME_MEDIATIMETYPE; - -/** Structure representing the current media time scale factor. Applicable only to clock - * component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via - * the clock component client ports. Upon recieving this config the clock component changes - * the rate by which the media time increases or decreases effectively implementing trick modes. - */ -typedef struct OMX_TIME_CONFIG_SCALETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_S32 xScale; /**< This is a value in Q16 format which is used for - * scaling the media time */ -} OMX_TIME_CONFIG_SCALETYPE; - -/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPE's nWaitMask field */ -#define OMX_CLOCKPORT0 0x00000001 -#define OMX_CLOCKPORT1 0x00000002 -#define OMX_CLOCKPORT2 0x00000004 -#define OMX_CLOCKPORT3 0x00000008 -#define OMX_CLOCKPORT4 0x00000010 -#define OMX_CLOCKPORT5 0x00000020 -#define OMX_CLOCKPORT6 0x00000040 -#define OMX_CLOCKPORT7 0x00000080 - -/** Structure representing the current mode of the media clock. - * IL Client uses this config to change or query the mode of the - * media clock of the clock component. Applicable only to clock - * component. - * - * On a SetConfig if eState is OMX_TIME_ClockStateRunning media time - * starts immediately at the prescribed start time. If - * OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores - * the given nStartTime and waits for all clients specified in the - * nWaitMask to send starttimes (via - * OMX_IndexConfigTimeClientStartTime). The Clock Component then starts - * the media clock using the earliest start time supplied. */ -typedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version - * information */ - OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */ - OMX_TICKS nStartTime; /**< Start time of the media time. */ - OMX_TICKS nOffset; /**< Time to offset the media time by - * (e.g. preroll). Media time will be - * reported to be nOffset ticks earlier. - */ - OMX_U32 nWaitMask; /**< Mask of OMX_CLOCKPORT values. */ -} OMX_TIME_CONFIG_CLOCKSTATETYPE; - -/** Structure representing the reference clock currently being used to - * compute media time. IL client uses this config to change or query the - * clock component's active reference clock */ -typedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_TIME_REFCLOCKTYPE eClock; /**< Reference clock used to compute media time */ -} OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE; - -/** Descriptor for setting specifics of power type. - * Note: this structure is listed for backwards compatibility. */ -typedef struct OMX_OTHER_CONFIG_POWERTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_BOOL bEnablePM; /**< Flag to enable Power Management */ -} OMX_OTHER_CONFIG_POWERTYPE; - - -/** Descriptor for setting specifics of stats type. - * Note: this structure is listed for backwards compatibility. */ -typedef struct OMX_OTHER_CONFIG_STATSTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - /* what goes here */ -} OMX_OTHER_CONFIG_STATSTYPE; - - -/** - * The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output other - * path. - */ -typedef struct OMX_OTHER_PORTDEFINITIONTYPE { - OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ -} OMX_OTHER_PORTDEFINITIONTYPE; - -/** Port format parameter. This structure is used to enumerate - * the various data input/output format supported by the port. - */ -typedef struct OMX_OTHER_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Indicates which port to set */ - OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ - OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ -} OMX_OTHER_PARAM_PORTFORMATTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Types.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_Types.h deleted file mode 100644 index 5afaba057c7ad4..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Types.h +++ /dev/null @@ -1,387 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/* - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** OMX_Types.h - OpenMax IL version 1.1.2 - * The OMX_Types header file contains the primitive type definitions used by - * the core, the application and the component. This file may need to be - * modified to be used on systems that do not have "char" set to 8 bits, - * "short" set to 16 bits and "long" set to 32 bits. - */ - -#ifndef OMX_Types_h -#define OMX_Types_h - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** The OMX_API and OMX_APIENTRY are platform specific definitions used - * to declare OMX function prototypes. They are modified to meet the - * requirements for a particular platform */ -#ifdef __SYMBIAN32__ -# ifdef __OMX_EXPORTS -# define OMX_API __declspec(dllexport) -# else -# ifdef _WIN32 -# define OMX_API __declspec(dllexport) -# else -# define OMX_API __declspec(dllimport) -# endif -# endif -#else -# ifdef _WIN32 -# ifdef __OMX_EXPORTS -# define OMX_API __declspec(dllexport) -# else -//# define OMX_API __declspec(dllimport) -#define OMX_API -# endif -# else -# ifdef __OMX_EXPORTS -# define OMX_API -# else -# define OMX_API extern -# endif -# endif -#endif - -#ifndef OMX_APIENTRY -#define OMX_APIENTRY -#endif - -/** OMX_IN is used to identify inputs to an OMX function. This designation - will also be used in the case of a pointer that points to a parameter - that is used as an output. */ -#ifndef OMX_IN -#define OMX_IN -#endif - -/** OMX_OUT is used to identify outputs from an OMX function. This - designation will also be used in the case of a pointer that points - to a parameter that is used as an input. */ -#ifndef OMX_OUT -#define OMX_OUT -#endif - - -/** OMX_INOUT is used to identify parameters that may be either inputs or - outputs from an OMX function at the same time. This designation will - also be used in the case of a pointer that points to a parameter that - is used both as an input and an output. */ -#ifndef OMX_INOUT -#define OMX_INOUT -#endif - -/** OMX_ALL is used to as a wildcard to select all entities of the same type - * when specifying the index, or referring to a object by an index. (i.e. - * use OMX_ALL to indicate all N channels). When used as a port index - * for a config or parameter this OMX_ALL denotes that the config or - * parameter applies to the entire component not just one port. */ -#define OMX_ALL 0xFFFFFFFF - -/** In the following we define groups that help building doxygen documentation */ - -/** @defgroup core OpenMAX IL core - * Functions and structure related to the OMX IL core - */ - - /** @defgroup comp OpenMAX IL component - * Functions and structure related to the OMX IL component - */ - -/** @defgroup rpm Resource and Policy Management - * Structures for resource and policy management of components - */ - -/** @defgroup buf Buffer Management - * Buffer handling functions and structures - */ - -/** @defgroup tun Tunneling - * @ingroup core comp - * Structures and functions to manage tunnels among component ports - */ - -/** @defgroup cp Content Pipes - * @ingroup core - */ - - /** @defgroup metadata Metadata handling - * - */ - -/** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */ -typedef unsigned char OMX_U8; - -/** OMX_S8 is an 8 bit signed quantity that is byte aligned */ -typedef signed char OMX_S8; - -/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */ -typedef unsigned short OMX_U16; - -/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */ -typedef signed short OMX_S16; - -/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */ -typedef uint32_t OMX_U32; - -/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */ -typedef int32_t OMX_S32; - - -/* Users with compilers that cannot accept the "long long" designation should - define the OMX_SKIP64BIT macro. It should be noted that this may cause - some components to fail to compile if the component was written to require - 64 bit integral types. However, these components would NOT compile anyway - since the compiler does not support the way the component was written. -*/ -#ifndef OMX_SKIP64BIT -#ifdef __SYMBIAN32__ -/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned long long OMX_U64; - -/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed long long OMX_S64; - -#elif defined(WIN32) - -/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned __int64 OMX_U64; - -/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed __int64 OMX_S64; - -#else /* WIN32 */ - -/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned long long OMX_U64; - -/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed long long OMX_S64; - -#endif /* WIN32 */ -#endif - - -/** The OMX_BOOL type is intended to be used to represent a true or a false - value when passing parameters to and from the OMX core and components. The - OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary. - */ -typedef enum OMX_BOOL { - OMX_FALSE = 0, - OMX_TRUE = !OMX_FALSE, - OMX_BOOL_MAX = 0x7FFFFFFF -} OMX_BOOL; - -/* - * Temporary Android 64 bit modification - * - * #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS - * overrides all OMX pointer types to be uint32_t. - * - * After this change, OMX codecs will work in 32 bit only, so 64 bit processes - * must communicate to a remote 32 bit process for OMX to work. - */ - -#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS - -typedef uint32_t OMX_PTR; -typedef OMX_PTR OMX_STRING; -typedef OMX_PTR OMX_BYTE; - -#else /* OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS */ - -/** The OMX_PTR type is intended to be used to pass pointers between the OMX - applications and the OMX Core and components. This is a 32 bit pointer and - is aligned on a 32 bit boundary. - */ -typedef void* OMX_PTR; - -/** The OMX_STRING type is intended to be used to pass "C" type strings between - the application and the core and component. The OMX_STRING type is a 32 - bit pointer to a zero terminated string. The pointer is word aligned and - the string is byte aligned. - */ -typedef char* OMX_STRING; - -/** The OMX_BYTE type is intended to be used to pass arrays of bytes such as - buffers between the application and the component and core. The OMX_BYTE - type is a 32 bit pointer to a zero terminated string. The pointer is word - aligned and the string is byte aligned. - */ -typedef unsigned char* OMX_BYTE; - -#endif /* OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS */ - -/** OMX_UUIDTYPE is a very long unique identifier to uniquely identify - at runtime. This identifier should be generated by a component in a way - that guarantees that every instance of the identifier running on the system - is unique. */ -typedef unsigned char OMX_UUIDTYPE[128]; - -/** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or - an output port. This enumeration is common across all component types. - */ -typedef enum OMX_DIRTYPE -{ - OMX_DirInput, /**< Port is an input port */ - OMX_DirOutput, /**< Port is an output port */ - OMX_DirMax = 0x7FFFFFFF -} OMX_DIRTYPE; - -/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering - for numerical data (i.e. big endian, or little endian). - */ -typedef enum OMX_ENDIANTYPE -{ - OMX_EndianBig, /**< big endian */ - OMX_EndianLittle, /**< little endian */ - OMX_EndianMax = 0x7FFFFFFF -} OMX_ENDIANTYPE; - - -/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data - is signed or unsigned - */ -typedef enum OMX_NUMERICALDATATYPE -{ - OMX_NumericalDataSigned, /**< signed data */ - OMX_NumericalDataUnsigned, /**< unsigned data */ - OMX_NumercialDataMax = 0x7FFFFFFF -} OMX_NUMERICALDATATYPE; - - -/** Unsigned bounded value type */ -typedef struct OMX_BU32 { - OMX_U32 nValue; /**< actual value */ - OMX_U32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ - OMX_U32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ -} OMX_BU32; - - -/** Signed bounded value type */ -typedef struct OMX_BS32 { - OMX_S32 nValue; /**< actual value */ - OMX_S32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ - OMX_S32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ -} OMX_BS32; - - -/** Structure representing some time or duration in microseconds. This structure - * must be interpreted as a signed 64 bit value. The quantity is signed to accommodate - * negative deltas and preroll scenarios. The quantity is represented in microseconds - * to accomodate high resolution timestamps (e.g. DVD presentation timestamps based - * on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g. - * individual audio samples delivered at 192 kHz). The quantity is 64 bit to - * accommodate a large dynamic range (signed 32 bit values would allow only for plus - * or minus 35 minutes). - * - * Implementations with limited precision may convert the signed 64 bit value to - * a signed 32 bit value internally but risk loss of precision. - */ -#ifndef OMX_SKIP64BIT -typedef OMX_S64 OMX_TICKS; -#else -typedef struct OMX_TICKS -{ - OMX_U32 nLowPart; /** low bits of the signed 64 bit tick value */ - OMX_U32 nHighPart; /** high bits of the signed 64 bit tick value */ -} OMX_TICKS; -#endif -#define OMX_TICKS_PER_SECOND 1000000 - -/** Define the public interface for the OMX Handle. The core will not use - this value internally, but the application should only use this value. - */ -typedef OMX_PTR OMX_HANDLETYPE; - -typedef struct OMX_MARKTYPE -{ - OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will - generate a mark event upon - processing the mark. */ - OMX_PTR pMarkData; /**< Application specific data associated with - the mark sent on a mark event to disambiguate - this mark from others. */ -} OMX_MARKTYPE; - - -/** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the - * platform & operating specific object used to reference the display - * or can be used by a audio port for native audio rendering */ -typedef OMX_PTR OMX_NATIVE_DEVICETYPE; - -/** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the - * platform & operating specific object used to reference the window */ -typedef OMX_PTR OMX_NATIVE_WINDOWTYPE; - -/** The OMX_VERSIONTYPE union is used to specify the version for - a structure or component. For a component, the version is entirely - specified by the component vendor. Components doing the same function - from different vendors may or may not have the same version. For - structures, the version shall be set by the entity that allocates the - structure. For structures specified in the OMX 1.1 specification, the - value of the version shall be set to 1.1.0.0 in all cases. Access to the - OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or - by accessing one of the structure elements to, for example, check only - the Major revision. - */ -typedef union OMX_VERSIONTYPE -{ - struct - { - OMX_U8 nVersionMajor; /**< Major version accessor element */ - OMX_U8 nVersionMinor; /**< Minor version accessor element */ - OMX_U8 nRevision; /**< Revision version accessor element */ - OMX_U8 nStep; /**< Step version accessor element */ - } s; - OMX_U32 nVersion; /**< 32 bit value to make accessing the - version easily done in a single word - size copy/compare operation */ -} OMX_VERSIONTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Video.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_Video.h deleted file mode 100644 index decc410ba945a2..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_Video.h +++ /dev/null @@ -1,1081 +0,0 @@ -/* ------------------------------------------------------------------ - * Copyright (C) 1998-2009 PacketVideo - * - * 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. - * ------------------------------------------------------------------- - */ -/** - * Copyright (c) 2008 The Khronos Group 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. - * - */ - -/** - * @file OMX_Video.h - OpenMax IL version 1.1.2 - * The structures is needed by Video components to exchange parameters - * and configuration data with OMX components. - */ -#ifndef OMX_Video_h -#define OMX_Video_h - -/** @defgroup video OpenMAX IL Video Domain - * @ingroup iv - * Structures for OpenMAX IL Video domain - * @{ - */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/** - * Each OMX header must include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ - -#include - - -/** - * Enumeration used to define the possible video compression codings. - * NOTE: This essentially refers to file extensions. If the coding is - * being used to specify the ENCODE type, then additional work - * must be done to configure the exact flavor of the compression - * to be used. For decode cases where the user application can - * not differentiate between MPEG-4 and H.264 bit streams, it is - * up to the codec to handle this. - */ -typedef enum OMX_VIDEO_CODINGTYPE { - OMX_VIDEO_CodingUnused, /**< Value when coding is N/A */ - OMX_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */ - OMX_VIDEO_CodingMPEG2, /**< AKA: H.262 */ - OMX_VIDEO_CodingH263, /**< H.263 */ - OMX_VIDEO_CodingMPEG4, /**< MPEG-4 */ - OMX_VIDEO_CodingWMV, /**< all versions of Windows Media Video */ - OMX_VIDEO_CodingRV, /**< all versions of Real Video */ - OMX_VIDEO_CodingAVC, /**< H.264/AVC */ - OMX_VIDEO_CodingMJPEG, /**< Motion JPEG */ - OMX_VIDEO_CodingVP8, /**< Google VP8, formerly known as On2 VP8 */ - OMX_VIDEO_CodingVP9, /**< Google VP9 */ - OMX_VIDEO_CodingHEVC, /**< ITU H.265/HEVC */ - OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_CodingMax = 0x7FFFFFFF -} OMX_VIDEO_CODINGTYPE; - - -/** - * Data structure used to define a video path. The number of Video paths for - * input and output will vary by type of the Video component. - * - * Input (aka Source) : zero Inputs, one Output, - * Splitter : one Input, 2 or more Outputs, - * Processing Element : one Input, one output, - * Mixer : 2 or more inputs, one output, - * Output (aka Sink) : one Input, zero outputs. - * - * The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output video - * path. If additional vendor specific data is required, it should be - * transmitted to the component using the CustomCommand function. Compliant - * components will prepopulate this structure with optimal values during the - * GetDefaultInitParams command. - * - * STRUCT MEMBERS: - * cMIMEType : MIME type of data for the port - * pNativeRender : Platform specific reference for a display if a - * sync, otherwise this field is 0 - * nFrameWidth : Width of frame to be used on channel if - * uncompressed format is used. Use 0 for unknown, - * don't care or variable - * nFrameHeight : Height of frame to be used on channel if - * uncompressed format is used. Use 0 for unknown, - * don't care or variable - * nStride : Number of bytes per span of an image - * (i.e. indicates the number of bytes to get - * from span N to span N+1, where negative stride - * indicates the image is bottom up - * nSliceHeight : Height used when encoding in slices - * nBitrate : Bit rate of frame to be used on channel if - * compressed format is used. Use 0 for unknown, - * don't care or variable - * xFramerate : Frame rate to be used on channel if uncompressed - * format is used. Use 0 for unknown, don't care or - * variable. Units are Q16 frames per second. - * bFlagErrorConcealment : Turns on error concealment if it is supported by - * the OMX component - * eCompressionFormat : Compression format used in this instance of the - * component. When OMX_VIDEO_CodingUnused is - * specified, eColorFormat is used - * eColorFormat : Decompressed format used by this component - * pNativeWindow : Platform specific reference for a window object if a - * display sink , otherwise this field is 0x0. - */ -typedef struct OMX_VIDEO_PORTDEFINITIONTYPE { - OMX_STRING cMIMEType; - OMX_NATIVE_DEVICETYPE pNativeRender; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - OMX_S32 nStride; - OMX_U32 nSliceHeight; - OMX_U32 nBitrate; - OMX_U32 xFramerate; - OMX_BOOL bFlagErrorConcealment; - OMX_VIDEO_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_NATIVE_WINDOWTYPE pNativeWindow; -} OMX_VIDEO_PORTDEFINITIONTYPE; - -/** - * Port format parameter. This structure is used to enumerate the various - * data input/output format supported by the port. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Indicates which port to set - * nIndex : Indicates the enumeration index for the format from - * 0x0 to N-1 - * eCompressionFormat : Compression format used in this instance of the - * component. When OMX_VIDEO_CodingUnused is specified, - * eColorFormat is used - * eColorFormat : Decompressed format used by this component - * xFrameRate : Indicates the video frame rate in Q16 format - */ -typedef struct OMX_VIDEO_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nIndex; - OMX_VIDEO_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_U32 xFramerate; -} OMX_VIDEO_PARAM_PORTFORMATTYPE; - - -/** - * This is a structure for configuring video compression quantization - * parameter values. Codecs may support different QP values for different - * frame types. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version info - * nPortIndex : Port that this structure applies to - * nQpI : QP value to use for index frames - * nQpP : QP value to use for P frames - * nQpB : QP values to use for bidirectional frames - */ -typedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nQpI; - OMX_U32 nQpP; - OMX_U32 nQpB; -} OMX_VIDEO_PARAM_QUANTIZATIONTYPE; - - -/** - * Structure for configuration of video fast update parameters. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version info - * nPortIndex : Port that this structure applies to - * bEnableVFU : Enable/Disable video fast update - * nFirstGOB : Specifies the number of the first macroblock row - * nFirstMB : specifies the first MB relative to the specified first GOB - * nNumMBs : Specifies the number of MBs to be refreshed from nFirstGOB - * and nFirstMB - */ -typedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnableVFU; - OMX_U32 nFirstGOB; - OMX_U32 nFirstMB; - OMX_U32 nNumMBs; -} OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE; - - -/** - * Enumeration of possible bitrate control types - */ -typedef enum OMX_VIDEO_CONTROLRATETYPE { - OMX_Video_ControlRateDisable, - OMX_Video_ControlRateVariable, - OMX_Video_ControlRateConstant, - OMX_Video_ControlRateVariableSkipFrames, - OMX_Video_ControlRateConstantSkipFrames, - OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_Video_ControlRateMax = 0x7FFFFFFF -} OMX_VIDEO_CONTROLRATETYPE; - - -/** - * Structure for configuring bitrate mode of a codec. - * - * STRUCT MEMBERS: - * nSize : Size of the struct in bytes - * nVersion : OMX spec version info - * nPortIndex : Port that this struct applies to - * eControlRate : Control rate type enum - * nTargetBitrate : Target bitrate to encode with - */ -typedef struct OMX_VIDEO_PARAM_BITRATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_CONTROLRATETYPE eControlRate; - OMX_U32 nTargetBitrate; -} OMX_VIDEO_PARAM_BITRATETYPE; - - -/** - * Enumeration of possible motion vector (MV) types - */ -typedef enum OMX_VIDEO_MOTIONVECTORTYPE { - OMX_Video_MotionVectorPixel, - OMX_Video_MotionVectorHalfPel, - OMX_Video_MotionVectorQuarterPel, - OMX_Video_MotionVectorEighthPel, - OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_Video_MotionVectorMax = 0x7FFFFFFF -} OMX_VIDEO_MOTIONVECTORTYPE; - - -/** - * Structure for configuring the number of motion vectors used as well - * as their accuracy. - * - * STRUCT MEMBERS: - * nSize : Size of the struct in bytes - * nVersion : OMX spec version info - * nPortIndex : port that this structure applies to - * eAccuracy : Enumerated MV accuracy - * bUnrestrictedMVs : Allow unrestricted MVs - * bFourMV : Allow use of 4 MVs - * sXSearchRange : Search range in horizontal direction for MVs - * sYSearchRange : Search range in vertical direction for MVs - */ -typedef struct OMX_VIDEO_PARAM_MOTIONVECTORTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_MOTIONVECTORTYPE eAccuracy; - OMX_BOOL bUnrestrictedMVs; - OMX_BOOL bFourMV; - OMX_S32 sXSearchRange; - OMX_S32 sYSearchRange; -} OMX_VIDEO_PARAM_MOTIONVECTORTYPE; - - -/** - * Enumeration of possible methods to use for Intra Refresh - */ -typedef enum OMX_VIDEO_INTRAREFRESHTYPE { - OMX_VIDEO_IntraRefreshCyclic, - OMX_VIDEO_IntraRefreshAdaptive, - OMX_VIDEO_IntraRefreshBoth, - OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF -} OMX_VIDEO_INTRAREFRESHTYPE; - - -/** - * Structure for configuring intra refresh mode - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eRefreshMode : Cyclic, Adaptive, or Both - * nAirMBs : Number of intra macroblocks to refresh in a frame when - * AIR is enabled - * nAirRef : Number of times a motion marked macroblock has to be - * intra coded - * nCirMBs : Number of consecutive macroblocks to be coded as "intra" - * when CIR is enabled - */ -typedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode; - OMX_U32 nAirMBs; - OMX_U32 nAirRef; - OMX_U32 nCirMBs; -} OMX_VIDEO_PARAM_INTRAREFRESHTYPE; - - -/** - * Structure for enabling various error correction methods for video - * compression. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bEnableHEC : Enable/disable header extension codes (HEC) - * bEnableResync : Enable/disable resynchronization markers - * nResynchMarkerSpacing : Resynch markers interval (in bits) to be - * applied in the stream - * bEnableDataPartitioning : Enable/disable data partitioning - * bEnableRVLC : Enable/disable reversible variable length - * coding - */ -typedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnableHEC; - OMX_BOOL bEnableResync; - OMX_U32 nResynchMarkerSpacing; - OMX_BOOL bEnableDataPartitioning; - OMX_BOOL bEnableRVLC; -} OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE; - - -/** - * Configuration of variable block-size motion compensation (VBSMC) - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * b16x16 : Enable inter block search 16x16 - * b16x8 : Enable inter block search 16x8 - * b8x16 : Enable inter block search 8x16 - * b8x8 : Enable inter block search 8x8 - * b8x4 : Enable inter block search 8x4 - * b4x8 : Enable inter block search 4x8 - * b4x4 : Enable inter block search 4x4 - */ -typedef struct OMX_VIDEO_PARAM_VBSMCTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL b16x16; - OMX_BOOL b16x8; - OMX_BOOL b8x16; - OMX_BOOL b8x8; - OMX_BOOL b8x4; - OMX_BOOL b4x8; - OMX_BOOL b4x4; -} OMX_VIDEO_PARAM_VBSMCTYPE; - - -/** - * H.263 profile types, each profile indicates support for various - * performance bounds and different annexes. - * - * ENUMS: - * Baseline : Baseline Profile: H.263 (V1), no optional modes - * H320 Coding : H.320 Coding Efficiency Backward Compatibility - * Profile: H.263+ (V2), includes annexes I, J, L.4 - * and T - * BackwardCompatible : Backward Compatibility Profile: H.263 (V1), - * includes annex F - * ISWV2 : Interactive Streaming Wireless Profile: H.263+ - * (V2), includes annexes I, J, K and T - * ISWV3 : Interactive Streaming Wireless Profile: H.263++ - * (V3), includes profile 3 and annexes V and W.6.3.8 - * HighCompression : Conversational High Compression Profile: H.263++ - * (V3), includes profiles 1 & 2 and annexes D and U - * Internet : Conversational Internet Profile: H.263++ (V3), - * includes profile 5 and annex K - * Interlace : Conversational Interlace Profile: H.263++ (V3), - * includes profile 5 and annex W.6.3.11 - * HighLatency : High Latency Profile: H.263++ (V3), includes - * profile 6 and annexes O.1 and P.5 - */ -typedef enum OMX_VIDEO_H263PROFILETYPE { - OMX_VIDEO_H263ProfileBaseline = 0x01, - OMX_VIDEO_H263ProfileH320Coding = 0x02, - OMX_VIDEO_H263ProfileBackwardCompatible = 0x04, - OMX_VIDEO_H263ProfileISWV2 = 0x08, - OMX_VIDEO_H263ProfileISWV3 = 0x10, - OMX_VIDEO_H263ProfileHighCompression = 0x20, - OMX_VIDEO_H263ProfileInternet = 0x40, - OMX_VIDEO_H263ProfileInterlace = 0x80, - OMX_VIDEO_H263ProfileHighLatency = 0x100, - OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_H263ProfileMax = 0x7FFFFFFF -} OMX_VIDEO_H263PROFILETYPE; - - -/** - * H.263 level types, each level indicates support for various frame sizes, - * bit rates, decoder frame rates. - */ -typedef enum OMX_VIDEO_H263LEVELTYPE { - OMX_VIDEO_H263Level10 = 0x01, - OMX_VIDEO_H263Level20 = 0x02, - OMX_VIDEO_H263Level30 = 0x04, - OMX_VIDEO_H263Level40 = 0x08, - OMX_VIDEO_H263Level45 = 0x10, - OMX_VIDEO_H263Level50 = 0x20, - OMX_VIDEO_H263Level60 = 0x40, - OMX_VIDEO_H263Level70 = 0x80, - OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_H263LevelMax = 0x7FFFFFFF -} OMX_VIDEO_H263LEVELTYPE; - - -/** - * Specifies the picture type. These values should be OR'd to signal all - * pictures types which are allowed. - * - * ENUMS: - * Generic Picture Types: I, P and B - * H.263 Specific Picture Types: SI and SP - * H.264 Specific Picture Types: EI and EP - * MPEG-4 Specific Picture Types: S - */ -typedef enum OMX_VIDEO_PICTURETYPE { - OMX_VIDEO_PictureTypeI = 0x01, - OMX_VIDEO_PictureTypeP = 0x02, - OMX_VIDEO_PictureTypeB = 0x04, - OMX_VIDEO_PictureTypeSI = 0x08, - OMX_VIDEO_PictureTypeSP = 0x10, - OMX_VIDEO_PictureTypeEI = 0x11, - OMX_VIDEO_PictureTypeEP = 0x12, - OMX_VIDEO_PictureTypeS = 0x14, - OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF -} OMX_VIDEO_PICTURETYPE; - - -/** - * H.263 Params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nPFrames : Number of P frames between each I frame - * nBFrames : Number of B frames between each I frame - * eProfile : H.263 profile(s) to use - * eLevel : H.263 level(s) to use - * bPLUSPTYPEAllowed : Indicating that it is allowed to use PLUSPTYPE - * (specified in the 1998 version of H.263) to - * indicate custom picture sizes or clock - * frequencies - * nAllowedPictureTypes : Specifies the picture types allowed in the - * bitstream - * bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is - * not constrained. It is recommended to change - * the value of the RTYPE bit for each reference - * picture in error-free communication - * nPictureHeaderRepetition : Specifies the frequency of picture header - * repetition - * nGOBHeaderInterval : Specifies the interval of non-empty GOB - * headers in units of GOBs - */ -typedef struct OMX_VIDEO_PARAM_H263TYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_VIDEO_H263PROFILETYPE eProfile; - OMX_VIDEO_H263LEVELTYPE eLevel; - OMX_BOOL bPLUSPTYPEAllowed; - OMX_U32 nAllowedPictureTypes; - OMX_BOOL bForceRoundingTypeToZero; - OMX_U32 nPictureHeaderRepetition; - OMX_U32 nGOBHeaderInterval; -} OMX_VIDEO_PARAM_H263TYPE; - - -/** - * MPEG-2 profile types, each profile indicates support for various - * performance bounds and different annexes. - */ -typedef enum OMX_VIDEO_MPEG2PROFILETYPE { - OMX_VIDEO_MPEG2ProfileSimple = 0, /**< Simple Profile */ - OMX_VIDEO_MPEG2ProfileMain, /**< Main Profile */ - OMX_VIDEO_MPEG2Profile422, /**< 4:2:2 Profile */ - OMX_VIDEO_MPEG2ProfileSNR, /**< SNR Profile */ - OMX_VIDEO_MPEG2ProfileSpatial, /**< Spatial Profile */ - OMX_VIDEO_MPEG2ProfileHigh, /**< High Profile */ - OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG2PROFILETYPE; - - -/** - * MPEG-2 level types, each level indicates support for various frame - * sizes, bit rates, decoder frame rates. No need - */ -typedef enum OMX_VIDEO_MPEG2LEVELTYPE { - OMX_VIDEO_MPEG2LevelLL = 0, /**< Low Level */ - OMX_VIDEO_MPEG2LevelML, /**< Main Level */ - OMX_VIDEO_MPEG2LevelH14, /**< High 1440 */ - OMX_VIDEO_MPEG2LevelHL, /**< High Level */ - OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG2LEVELTYPE; - - -/** - * MPEG-2 params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nPFrames : Number of P frames between each I frame - * nBFrames : Number of B frames between each I frame - * eProfile : MPEG-2 profile(s) to use - * eLevel : MPEG-2 levels(s) to use - */ -typedef struct OMX_VIDEO_PARAM_MPEG2TYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_VIDEO_MPEG2PROFILETYPE eProfile; - OMX_VIDEO_MPEG2LEVELTYPE eLevel; -} OMX_VIDEO_PARAM_MPEG2TYPE; - - -/** - * MPEG-4 profile types, each profile indicates support for various - * performance bounds and different annexes. - * - * ENUMS: - * - Simple Profile, Levels 1-3 - * - Simple Scalable Profile, Levels 1-2 - * - Core Profile, Levels 1-2 - * - Main Profile, Levels 2-4 - * - N-bit Profile, Level 2 - * - Scalable Texture Profile, Level 1 - * - Simple Face Animation Profile, Levels 1-2 - * - Simple Face and Body Animation (FBA) Profile, Levels 1-2 - * - Basic Animated Texture Profile, Levels 1-2 - * - Hybrid Profile, Levels 1-2 - * - Advanced Real Time Simple Profiles, Levels 1-4 - * - Core Scalable Profile, Levels 1-3 - * - Advanced Coding Efficiency Profile, Levels 1-4 - * - Advanced Core Profile, Levels 1-2 - * - Advanced Scalable Texture, Levels 2-3 - */ -typedef enum OMX_VIDEO_MPEG4PROFILETYPE { - OMX_VIDEO_MPEG4ProfileSimple = 0x01, - OMX_VIDEO_MPEG4ProfileSimpleScalable = 0x02, - OMX_VIDEO_MPEG4ProfileCore = 0x04, - OMX_VIDEO_MPEG4ProfileMain = 0x08, - OMX_VIDEO_MPEG4ProfileNbit = 0x10, - OMX_VIDEO_MPEG4ProfileScalableTexture = 0x20, - OMX_VIDEO_MPEG4ProfileSimpleFace = 0x40, - OMX_VIDEO_MPEG4ProfileSimpleFBA = 0x80, - OMX_VIDEO_MPEG4ProfileBasicAnimated = 0x100, - OMX_VIDEO_MPEG4ProfileHybrid = 0x200, - OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400, - OMX_VIDEO_MPEG4ProfileCoreScalable = 0x800, - OMX_VIDEO_MPEG4ProfileAdvancedCoding = 0x1000, - OMX_VIDEO_MPEG4ProfileAdvancedCore = 0x2000, - OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000, - OMX_VIDEO_MPEG4ProfileAdvancedSimple = 0x8000, - OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG4ProfileMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG4PROFILETYPE; - - -/** - * MPEG-4 level types, each level indicates support for various frame - * sizes, bit rates, decoder frame rates. No need - */ -typedef enum OMX_VIDEO_MPEG4LEVELTYPE { - OMX_VIDEO_MPEG4Level0 = 0x01, /**< Level 0 */ - OMX_VIDEO_MPEG4Level0b = 0x02, /**< Level 0b */ - OMX_VIDEO_MPEG4Level1 = 0x04, /**< Level 1 */ - OMX_VIDEO_MPEG4Level2 = 0x08, /**< Level 2 */ - OMX_VIDEO_MPEG4Level3 = 0x10, /**< Level 3 */ - OMX_VIDEO_MPEG4Level4 = 0x20, /**< Level 4 */ - OMX_VIDEO_MPEG4Level4a = 0x40, /**< Level 4a */ - OMX_VIDEO_MPEG4Level5 = 0x80, /**< Level 5 */ - OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG4LEVELTYPE; - - -/** - * MPEG-4 configuration. This structure handles configuration options - * which are specific to MPEG4 algorithms - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nSliceHeaderSpacing : Number of macroblocks between slice header (H263+ - * Annex K). Put zero if not used - * bSVH : Enable Short Video Header mode - * bGov : Flag to enable GOV - * nPFrames : Number of P frames between each I frame (also called - * GOV period) - * nBFrames : Number of B frames between each I frame - * nIDCVLCThreshold : Value of intra DC VLC threshold - * bACPred : Flag to use ac prediction - * nMaxPacketSize : Maximum size of packet in bytes. - * nTimeIncRes : Used to pass VOP time increment resolution for MPEG4. - * Interpreted as described in MPEG4 standard. - * eProfile : MPEG-4 profile(s) to use. - * eLevel : MPEG-4 level(s) to use. - * nAllowedPictureTypes : Specifies the picture types allowed in the bitstream - * nHeaderExtension : Specifies the number of consecutive video packet - * headers within a VOP - * bReversibleVLC : Specifies whether reversible variable length coding - * is in use - */ -typedef struct OMX_VIDEO_PARAM_MPEG4TYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nSliceHeaderSpacing; - OMX_BOOL bSVH; - OMX_BOOL bGov; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_U32 nIDCVLCThreshold; - OMX_BOOL bACPred; - OMX_U32 nMaxPacketSize; - OMX_U32 nTimeIncRes; - OMX_VIDEO_MPEG4PROFILETYPE eProfile; - OMX_VIDEO_MPEG4LEVELTYPE eLevel; - OMX_U32 nAllowedPictureTypes; - OMX_U32 nHeaderExtension; - OMX_BOOL bReversibleVLC; -} OMX_VIDEO_PARAM_MPEG4TYPE; - - -/** - * WMV Versions - */ -typedef enum OMX_VIDEO_WMVFORMATTYPE { - OMX_VIDEO_WMVFormatUnused = 0x01, /**< Format unused or unknown */ - OMX_VIDEO_WMVFormat7 = 0x02, /**< Windows Media Video format 7 */ - OMX_VIDEO_WMVFormat8 = 0x04, /**< Windows Media Video format 8 */ - OMX_VIDEO_WMVFormat9 = 0x08, /**< Windows Media Video format 9 */ - OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_WMVFormatMax = 0x7FFFFFFF -} OMX_VIDEO_WMVFORMATTYPE; - - -/** - * WMV Params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFormat : Version of WMV stream / data - */ -typedef struct OMX_VIDEO_PARAM_WMVTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_WMVFORMATTYPE eFormat; -} OMX_VIDEO_PARAM_WMVTYPE; - - -/** - * Real Video Version - */ -typedef enum OMX_VIDEO_RVFORMATTYPE { - OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */ - OMX_VIDEO_RVFormat8, /**< Real Video format 8 */ - OMX_VIDEO_RVFormat9, /**< Real Video format 9 */ - OMX_VIDEO_RVFormatG2, /**< Real Video Format G2 */ - OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_RVFormatMax = 0x7FFFFFFF -} OMX_VIDEO_RVFORMATTYPE; - - -/** - * Real Video Params - * - * STUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFormat : Version of RV stream / data - * nBitsPerPixel : Bits per pixel coded in the frame - * nPaddedWidth : Padded width in pixel of a video frame - * nPaddedHeight : Padded Height in pixels of a video frame - * nFrameRate : Rate of video in frames per second - * nBitstreamFlags : Flags which internal information about the bitstream - * nBitstreamVersion : Bitstream version - * nMaxEncodeFrameSize: Max encoded frame size - * bEnablePostFilter : Turn on/off post filter - * bEnableTemporalInterpolation : Turn on/off temporal interpolation - * bEnableLatencyMode : When enabled, the decoder does not display a decoded - * frame until it has detected that no enhancement layer - * frames or dependent B frames will be coming. This - * detection usually occurs when a subsequent non-B - * frame is encountered - */ -typedef struct OMX_VIDEO_PARAM_RVTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_RVFORMATTYPE eFormat; - OMX_U16 nBitsPerPixel; - OMX_U16 nPaddedWidth; - OMX_U16 nPaddedHeight; - OMX_U32 nFrameRate; - OMX_U32 nBitstreamFlags; - OMX_U32 nBitstreamVersion; - OMX_U32 nMaxEncodeFrameSize; - OMX_BOOL bEnablePostFilter; - OMX_BOOL bEnableTemporalInterpolation; - OMX_BOOL bEnableLatencyMode; -} OMX_VIDEO_PARAM_RVTYPE; - - -/** - * AVC profile types, each profile indicates support for various - * performance bounds and different annexes. - */ -typedef enum OMX_VIDEO_AVCPROFILETYPE { - OMX_VIDEO_AVCProfileBaseline = 0x01, /**< Baseline profile */ - OMX_VIDEO_AVCProfileMain = 0x02, /**< Main profile */ - OMX_VIDEO_AVCProfileExtended = 0x04, /**< Extended profile */ - OMX_VIDEO_AVCProfileHigh = 0x08, /**< High profile */ - OMX_VIDEO_AVCProfileHigh10 = 0x10, /**< High 10 profile */ - OMX_VIDEO_AVCProfileHigh422 = 0x20, /**< High 4:2:2 profile */ - OMX_VIDEO_AVCProfileHigh444 = 0x40, /**< High 4:4:4 profile */ - OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_AVCProfileMax = 0x7FFFFFFF -} OMX_VIDEO_AVCPROFILETYPE; - - -/** - * AVC level types, each level indicates support for various frame sizes, - * bit rates, decoder frame rates. No need - */ -typedef enum OMX_VIDEO_AVCLEVELTYPE { - OMX_VIDEO_AVCLevel1 = 0x01, /**< Level 1 */ - OMX_VIDEO_AVCLevel1b = 0x02, /**< Level 1b */ - OMX_VIDEO_AVCLevel11 = 0x04, /**< Level 1.1 */ - OMX_VIDEO_AVCLevel12 = 0x08, /**< Level 1.2 */ - OMX_VIDEO_AVCLevel13 = 0x10, /**< Level 1.3 */ - OMX_VIDEO_AVCLevel2 = 0x20, /**< Level 2 */ - OMX_VIDEO_AVCLevel21 = 0x40, /**< Level 2.1 */ - OMX_VIDEO_AVCLevel22 = 0x80, /**< Level 2.2 */ - OMX_VIDEO_AVCLevel3 = 0x100, /**< Level 3 */ - OMX_VIDEO_AVCLevel31 = 0x200, /**< Level 3.1 */ - OMX_VIDEO_AVCLevel32 = 0x400, /**< Level 3.2 */ - OMX_VIDEO_AVCLevel4 = 0x800, /**< Level 4 */ - OMX_VIDEO_AVCLevel41 = 0x1000, /**< Level 4.1 */ - OMX_VIDEO_AVCLevel42 = 0x2000, /**< Level 4.2 */ - OMX_VIDEO_AVCLevel5 = 0x4000, /**< Level 5 */ - OMX_VIDEO_AVCLevel51 = 0x8000, /**< Level 5.1 */ - OMX_VIDEO_AVCLevel52 = 0x10000, /**< Level 5.2 */ - OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF -} OMX_VIDEO_AVCLEVELTYPE; - - -/** - * AVC loop filter modes - * - * OMX_VIDEO_AVCLoopFilterEnable : Enable - * OMX_VIDEO_AVCLoopFilterDisable : Disable - * OMX_VIDEO_AVCLoopFilterDisableSliceBoundary : Disabled on slice boundaries - */ -typedef enum OMX_VIDEO_AVCLOOPFILTERTYPE { - OMX_VIDEO_AVCLoopFilterEnable = 0, - OMX_VIDEO_AVCLoopFilterDisable, - OMX_VIDEO_AVCLoopFilterDisableSliceBoundary, - OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF -} OMX_VIDEO_AVCLOOPFILTERTYPE; - - -/** - * AVC params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nSliceHeaderSpacing : Number of macroblocks between slice header, put - * zero if not used - * nPFrames : Number of P frames between each I frame - * nBFrames : Number of B frames between each I frame - * bUseHadamard : Enable/disable Hadamard transform - * nRefFrames : Max number of reference frames to use for inter - * motion search (1-16) - * nRefIdxTrailing : Pic param set ref frame index (index into ref - * frame buffer of trailing frames list), B frame - * support - * nRefIdxForward : Pic param set ref frame index (index into ref - * frame buffer of forward frames list), B frame - * support - * bEnableUEP : Enable/disable unequal error protection. This - * is only valid of data partitioning is enabled. - * bEnableFMO : Enable/disable flexible macroblock ordering - * bEnableASO : Enable/disable arbitrary slice ordering - * bEnableRS : Enable/disable sending of redundant slices - * eProfile : AVC profile(s) to use - * eLevel : AVC level(s) to use - * nAllowedPictureTypes : Specifies the picture types allowed in the - * bitstream - * bFrameMBsOnly : specifies that every coded picture of the - * coded video sequence is a coded frame - * containing only frame macroblocks - * bMBAFF : Enable/disable switching between frame and - * field macroblocks within a picture - * bEntropyCodingCABAC : Entropy decoding method to be applied for the - * syntax elements for which two descriptors appear - * in the syntax tables - * bWeightedPPrediction : Enable/disable weighted prediction shall not - * be applied to P and SP slices - * nWeightedBipredicitonMode : Default weighted prediction is applied to B - * slices - * bconstIpred : Enable/disable intra prediction - * bDirect8x8Inference : Specifies the method used in the derivation - * process for luma motion vectors for B_Skip, - * B_Direct_16x16 and B_Direct_8x8 as specified - * in subclause 8.4.1.2 of the AVC spec - * bDirectSpatialTemporal : Flag indicating spatial or temporal direct - * mode used in B slice coding (related to - * bDirect8x8Inference) . Spatial direct mode is - * more common and should be the default. - * nCabacInitIdx : Index used to init CABAC contexts - * eLoopFilterMode : Enable/disable loop filter - */ -typedef struct OMX_VIDEO_PARAM_AVCTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nSliceHeaderSpacing; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_BOOL bUseHadamard; - OMX_U32 nRefFrames; - OMX_U32 nRefIdx10ActiveMinus1; - OMX_U32 nRefIdx11ActiveMinus1; - OMX_BOOL bEnableUEP; - OMX_BOOL bEnableFMO; - OMX_BOOL bEnableASO; - OMX_BOOL bEnableRS; - OMX_VIDEO_AVCPROFILETYPE eProfile; - OMX_VIDEO_AVCLEVELTYPE eLevel; - OMX_U32 nAllowedPictureTypes; - OMX_BOOL bFrameMBsOnly; - OMX_BOOL bMBAFF; - OMX_BOOL bEntropyCodingCABAC; - OMX_BOOL bWeightedPPrediction; - OMX_U32 nWeightedBipredicitonMode; - OMX_BOOL bconstIpred ; - OMX_BOOL bDirect8x8Inference; - OMX_BOOL bDirectSpatialTemporal; - OMX_U32 nCabacInitIdc; - OMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode; -} OMX_VIDEO_PARAM_AVCTYPE; - -typedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 eProfile; /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE, - or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ - OMX_U32 eLevel; /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE, - or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ - OMX_U32 nProfileIndex; /**< Used to query for individual profile support information, - This parameter is valid only for - OMX_IndexParamVideoProfileLevelQuerySupported index, - For all other indices this parameter is to be ignored. */ -} OMX_VIDEO_PARAM_PROFILELEVELTYPE; - -/** - * Structure for dynamically configuring bitrate mode of a codec. - * - * STRUCT MEMBERS: - * nSize : Size of the struct in bytes - * nVersion : OMX spec version info - * nPortIndex : Port that this struct applies to - * nEncodeBitrate : Target average bitrate to be generated in bps - */ -typedef struct OMX_VIDEO_CONFIG_BITRATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nEncodeBitrate; -} OMX_VIDEO_CONFIG_BITRATETYPE; - -/** - * Defines Encoder Frame Rate setting - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * xEncodeFramerate : Encoding framerate represented in Q16 format - */ -typedef struct OMX_CONFIG_FRAMERATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 xEncodeFramerate; /* Q16 format */ -} OMX_CONFIG_FRAMERATETYPE; - -typedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL IntraRefreshVOP; -} OMX_CONFIG_INTRAREFRESHVOPTYPE; - -typedef struct OMX_CONFIG_MACROBLOCKERRORMAPTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nErrMapSize; /* Size of the Error Map in bytes */ - OMX_U8 ErrMap[1]; /* Error map hint */ -} OMX_CONFIG_MACROBLOCKERRORMAPTYPE; - -typedef struct OMX_CONFIG_MBERRORREPORTINGTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnabled; -} OMX_CONFIG_MBERRORREPORTINGTYPE; - -typedef struct OMX_PARAM_MACROBLOCKSTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nMacroblocks; -} OMX_PARAM_MACROBLOCKSTYPE; - -/** - * AVC Slice Mode modes - * - * OMX_VIDEO_SLICEMODE_AVCDefault : Normal frame encoding, one slice per frame - * OMX_VIDEO_SLICEMODE_AVCMBSlice : NAL mode, number of MBs per frame - * OMX_VIDEO_SLICEMODE_AVCByteSlice : NAL mode, number of bytes per frame - */ -typedef enum OMX_VIDEO_AVCSLICEMODETYPE { - OMX_VIDEO_SLICEMODE_AVCDefault = 0, - OMX_VIDEO_SLICEMODE_AVCMBSlice, - OMX_VIDEO_SLICEMODE_AVCByteSlice, - OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF -} OMX_VIDEO_AVCSLICEMODETYPE; - -/** - * AVC FMO Slice Mode Params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nNumSliceGroups : Specifies the number of slice groups - * nSliceGroupMapType : Specifies the type of slice groups - * eSliceMode : Specifies the type of slice - */ -typedef struct OMX_VIDEO_PARAM_AVCSLICEFMO { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U8 nNumSliceGroups; - OMX_U8 nSliceGroupMapType; - OMX_VIDEO_AVCSLICEMODETYPE eSliceMode; -} OMX_VIDEO_PARAM_AVCSLICEFMO; - -/** - * AVC IDR Period Configs - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nIDRPeriod : Specifies periodicity of IDR frames - * nPFrames : Specifies internal of coding Intra frames - */ -typedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nIDRPeriod; - OMX_U32 nPFrames; -} OMX_VIDEO_CONFIG_AVCINTRAPERIOD; - -/** - * AVC NAL Size Configs - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nNaluBytes : Specifies the NAL unit size - */ -typedef struct OMX_VIDEO_CONFIG_NALSIZE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nNaluBytes; -} OMX_VIDEO_CONFIG_NALSIZE; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ - diff --git a/phonelibs/android_frameworks_native/include/media/openmax/OMX_VideoExt.h b/phonelibs/android_frameworks_native/include/media/openmax/OMX_VideoExt.h deleted file mode 100644 index 3971bc5cc366d1..00000000000000 --- a/phonelibs/android_frameworks_native/include/media/openmax/OMX_VideoExt.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2010 The Khronos Group 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. - * - */ - -/** OMX_VideoExt.h - OpenMax IL version 1.1.2 - * The OMX_VideoExt header file contains extensions to the - * definitions used by both the application and the component to - * access video items. - */ - -#ifndef OMX_VideoExt_h -#define OMX_VideoExt_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Each OMX header shall include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ -#include - -/** NALU Formats */ -typedef enum OMX_NALUFORMATSTYPE { - OMX_NaluFormatStartCodes = 1, - OMX_NaluFormatOneNaluPerBuffer = 2, - OMX_NaluFormatOneByteInterleaveLength = 4, - OMX_NaluFormatTwoByteInterleaveLength = 8, - OMX_NaluFormatFourByteInterleaveLength = 16, - OMX_NaluFormatCodingMax = 0x7FFFFFFF -} OMX_NALUFORMATSTYPE; - -/** NAL Stream Format */ -typedef struct OMX_NALSTREAMFORMATTYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_NALUFORMATSTYPE eNaluFormat; -} OMX_NALSTREAMFORMATTYPE; - -/** VP8 profiles */ -typedef enum OMX_VIDEO_VP8PROFILETYPE { - OMX_VIDEO_VP8ProfileMain = 0x01, - OMX_VIDEO_VP8ProfileUnknown = 0x6EFFFFFF, - OMX_VIDEO_VP8ProfileMax = 0x7FFFFFFF -} OMX_VIDEO_VP8PROFILETYPE; - -/** VP8 levels */ -typedef enum OMX_VIDEO_VP8LEVELTYPE { - OMX_VIDEO_VP8Level_Version0 = 0x01, - OMX_VIDEO_VP8Level_Version1 = 0x02, - OMX_VIDEO_VP8Level_Version2 = 0x04, - OMX_VIDEO_VP8Level_Version3 = 0x08, - OMX_VIDEO_VP8LevelUnknown = 0x6EFFFFFF, - OMX_VIDEO_VP8LevelMax = 0x7FFFFFFF -} OMX_VIDEO_VP8LEVELTYPE; - -/** VP8 Param */ -typedef struct OMX_VIDEO_PARAM_VP8TYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_VP8PROFILETYPE eProfile; - OMX_VIDEO_VP8LEVELTYPE eLevel; - OMX_U32 nDCTPartitions; - OMX_BOOL bErrorResilientMode; -} OMX_VIDEO_PARAM_VP8TYPE; - -/** Structure for configuring VP8 reference frames */ -typedef struct OMX_VIDEO_VP8REFERENCEFRAMETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bPreviousFrameRefresh; - OMX_BOOL bGoldenFrameRefresh; - OMX_BOOL bAlternateFrameRefresh; - OMX_BOOL bUsePreviousFrame; - OMX_BOOL bUseGoldenFrame; - OMX_BOOL bUseAlternateFrame; -} OMX_VIDEO_VP8REFERENCEFRAMETYPE; - -/** Structure for querying VP8 reference frame type */ -typedef struct OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bIsIntraFrame; - OMX_BOOL bIsGoldenOrAlternateFrame; -} OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE; - -/** Maximum number of VP8 temporal layers */ -#define OMX_VIDEO_ANDROID_MAXVP8TEMPORALLAYERS 3 - -/** VP8 temporal layer patterns */ -typedef enum OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE { - OMX_VIDEO_VPXTemporalLayerPatternNone = 0, - OMX_VIDEO_VPXTemporalLayerPatternWebRTC = 1, - OMX_VIDEO_VPXTemporalLayerPatternMax = 0x7FFFFFFF -} OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE; - -/** - * Android specific VP8 encoder params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nKeyFrameInterval : Key frame interval in frames - * eTemporalPattern : Type of temporal layer pattern - * nTemporalLayerCount : Number of temporal coding layers - * nTemporalLayerBitrateRatio : Bitrate ratio allocation between temporal - * streams in percentage - * nMinQuantizer : Minimum (best quality) quantizer - * nMaxQuantizer : Maximum (worst quality) quantizer - */ -typedef struct OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nKeyFrameInterval; - OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE eTemporalPattern; - OMX_U32 nTemporalLayerCount; - OMX_U32 nTemporalLayerBitrateRatio[OMX_VIDEO_ANDROID_MAXVP8TEMPORALLAYERS]; - OMX_U32 nMinQuantizer; - OMX_U32 nMaxQuantizer; -} OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE; - -/** HEVC Profile enum type */ -typedef enum OMX_VIDEO_HEVCPROFILETYPE { - OMX_VIDEO_HEVCProfileUnknown = 0x0, - OMX_VIDEO_HEVCProfileMain = 0x1, - OMX_VIDEO_HEVCProfileMain10 = 0x2, - OMX_VIDEO_HEVCProfileMax = 0x7FFFFFFF -} OMX_VIDEO_HEVCPROFILETYPE; - -/** HEVC Level enum type */ -typedef enum OMX_VIDEO_HEVCLEVELTYPE { - OMX_VIDEO_HEVCLevelUnknown = 0x0, - OMX_VIDEO_HEVCMainTierLevel1 = 0x1, - OMX_VIDEO_HEVCHighTierLevel1 = 0x2, - OMX_VIDEO_HEVCMainTierLevel2 = 0x4, - OMX_VIDEO_HEVCHighTierLevel2 = 0x8, - OMX_VIDEO_HEVCMainTierLevel21 = 0x10, - OMX_VIDEO_HEVCHighTierLevel21 = 0x20, - OMX_VIDEO_HEVCMainTierLevel3 = 0x40, - OMX_VIDEO_HEVCHighTierLevel3 = 0x80, - OMX_VIDEO_HEVCMainTierLevel31 = 0x100, - OMX_VIDEO_HEVCHighTierLevel31 = 0x200, - OMX_VIDEO_HEVCMainTierLevel4 = 0x400, - OMX_VIDEO_HEVCHighTierLevel4 = 0x800, - OMX_VIDEO_HEVCMainTierLevel41 = 0x1000, - OMX_VIDEO_HEVCHighTierLevel41 = 0x2000, - OMX_VIDEO_HEVCMainTierLevel5 = 0x4000, - OMX_VIDEO_HEVCHighTierLevel5 = 0x8000, - OMX_VIDEO_HEVCMainTierLevel51 = 0x10000, - OMX_VIDEO_HEVCHighTierLevel51 = 0x20000, - OMX_VIDEO_HEVCMainTierLevel52 = 0x40000, - OMX_VIDEO_HEVCHighTierLevel52 = 0x80000, - OMX_VIDEO_HEVCMainTierLevel6 = 0x100000, - OMX_VIDEO_HEVCHighTierLevel6 = 0x200000, - OMX_VIDEO_HEVCMainTierLevel61 = 0x400000, - OMX_VIDEO_HEVCHighTierLevel61 = 0x800000, - OMX_VIDEO_HEVCMainTierLevel62 = 0x1000000, - OMX_VIDEO_HEVCHighTierLevel62 = 0x2000000, - OMX_VIDEO_HEVCHighTiermax = 0x7FFFFFFF -} OMX_VIDEO_HEVCLEVELTYPE; - -/** Structure for controlling HEVC video encoding and decoding */ -typedef struct OMX_VIDEO_PARAM_HEVCTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_HEVCPROFILETYPE eProfile; - OMX_VIDEO_HEVCLEVELTYPE eLevel; -} OMX_VIDEO_PARAM_HEVCTYPE; - -/** Structure to define if dependent slice segments should be used */ -typedef struct OMX_VIDEO_SLICESEGMENTSTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bDepedentSegments; - OMX_BOOL bEnableLoopFilterAcrossSlices; -} OMX_VIDEO_SLICESEGMENTSTYPE; - -/** Structure to return timestamps of rendered output frames as well as EOS - * for tunneled components. - */ -typedef struct OMX_VIDEO_RENDEREVENTTYPE { - OMX_S64 nMediaTimeUs; // timestamp of rendered video frame - OMX_S64 nSystemTimeNs; // system monotonic time at the time frame was rendered - // Use INT64_MAX for nMediaTimeUs to signal that the EOS - // has been reached. In this case, nSystemTimeNs MUST be - // the system time when the last frame was rendered. - // This MUST be done in addition to returning (and - // following) the render information for the last frame. -} OMX_VIDEO_RENDEREVENTTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* OMX_VideoExt_h */ -/* File EOF */ diff --git a/phonelibs/android_frameworks_native/include/powermanager/IPowerManager.h b/phonelibs/android_frameworks_native/include/powermanager/IPowerManager.h deleted file mode 100644 index 91ecc5aa31e372..00000000000000 --- a/phonelibs/android_frameworks_native/include/powermanager/IPowerManager.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -#ifndef ANDROID_IPOWERMANAGER_H -#define ANDROID_IPOWERMANAGER_H - -#include -#include -#include - -namespace android { - -// ---------------------------------------------------------------------------- - -// must be kept in sync with interface defined in IPowerManager.aidl -class IPowerManager : public IInterface -{ -public: - DECLARE_META_INTERFACE(PowerManager); - - // FIXME remove the bool isOneWay parameters as they are not oneway in the .aidl - virtual status_t acquireWakeLock(int flags, const sp& lock, const String16& tag, - const String16& packageName, bool isOneWay = false) = 0; - virtual status_t acquireWakeLockWithUid(int flags, const sp& lock, const String16& tag, - const String16& packageName, int uid, bool isOneWay = false) = 0; - virtual status_t releaseWakeLock(const sp& lock, int flags, bool isOneWay = false) = 0; - virtual status_t updateWakeLockUids(const sp& lock, int len, const int *uids, - bool isOneWay = false) = 0; - // oneway in the .aidl - virtual status_t powerHint(int hintId, int data) = 0; -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IPOWERMANAGER_H diff --git a/phonelibs/android_frameworks_native/include/powermanager/PowerManager.h b/phonelibs/android_frameworks_native/include/powermanager/PowerManager.h deleted file mode 100644 index cbddc11536c4e0..00000000000000 --- a/phonelibs/android_frameworks_native/include/powermanager/PowerManager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -#ifndef ANDROID_POWERMANAGER_H -#define ANDROID_POWERMANAGER_H - -namespace android { - -// must be kept in sync with definitions in PowerManager.java -enum { - POWERMANAGER_PARTIAL_WAKE_LOCK = 1, // equals PowerManager.PARTIAL_WAKE_LOCK constant -}; - -enum { - USER_ACTIVITY_EVENT_OTHER = 0, - USER_ACTIVITY_EVENT_BUTTON = 1, - USER_ACTIVITY_EVENT_TOUCH = 2, - - USER_ACTIVITY_EVENT_LAST = USER_ACTIVITY_EVENT_TOUCH, // Last valid event code. -}; - -}; // namespace android - -#endif // ANDROID_POWERMANAGER_H diff --git a/phonelibs/android_frameworks_native/include/private/binder/Static.h b/phonelibs/android_frameworks_native/include/private/binder/Static.h deleted file mode 100644 index d1046468043166..00000000000000 --- a/phonelibs/android_frameworks_native/include/private/binder/Static.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -// All static variables go here, to control initialization and -// destruction order in the library. - -#include - -#include -#include -#include -#include -#include - -namespace android { - -// For TextStream.cpp -extern Vector gTextBuffers; - -// For ProcessState.cpp -extern Mutex gProcessMutex; -extern sp gProcess; - -// For IServiceManager.cpp -extern Mutex gDefaultServiceManagerLock; -extern sp gDefaultServiceManager; -extern sp gPermissionController; - -} // namespace android diff --git a/phonelibs/android_frameworks_native/include/private/binder/binder_module.h b/phonelibs/android_frameworks_native/include/private/binder/binder_module.h deleted file mode 100644 index a8dd64f235bbd6..00000000000000 --- a/phonelibs/android_frameworks_native/include/private/binder/binder_module.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -#ifndef _BINDER_MODULE_H_ -#define _BINDER_MODULE_H_ - -#ifdef __cplusplus -namespace android { -#endif - -/* obtain structures and constants from the kernel header */ - -#include -#include - -#ifdef __cplusplus -} // namespace android -#endif - -#endif // _BINDER_MODULE_H_ diff --git a/phonelibs/android_frameworks_native/include/private/gui/ComposerService.h b/phonelibs/android_frameworks_native/include/private/gui/ComposerService.h deleted file mode 100644 index ff2f9bf0f7371e..00000000000000 --- a/phonelibs/android_frameworks_native/include/private/gui/ComposerService.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -#ifndef ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H -#define ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H - -#include -#include - -#include -#include - - -namespace android { - -// --------------------------------------------------------------------------- - -class IMemoryHeap; -class ISurfaceComposer; - -// --------------------------------------------------------------------------- - -// This holds our connection to the composer service (i.e. SurfaceFlinger). -// If the remote side goes away, we will re-establish the connection. -// Users of this class should not retain the value from -// getComposerService() for an extended period. -// -// (It's not clear that using Singleton is useful here anymore.) -class ComposerService : public Singleton -{ - sp mComposerService; - sp mDeathObserver; - Mutex mLock; - - ComposerService(); - void connectLocked(); - void composerServiceDied(); - friend class Singleton; -public: - - // Get a connection to the Composer Service. This will block until - // a connection is established. - static sp getComposerService(); -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H diff --git a/phonelibs/android_frameworks_native/include/private/gui/LayerState.h b/phonelibs/android_frameworks_native/include/private/gui/LayerState.h deleted file mode 100644 index 9ff840991fa9cb..00000000000000 --- a/phonelibs/android_frameworks_native/include/private/gui/LayerState.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -#ifndef ANDROID_SF_LAYER_STATE_H -#define ANDROID_SF_LAYER_STATE_H - -#include -#include - -#include - -#include -#include - -namespace android { - -class Parcel; -class ISurfaceComposerClient; - -/* - * Used to communicate layer information between SurfaceFlinger and its clients. - */ -struct layer_state_t { - - - enum { - eLayerHidden = 0x01, // SURFACE_HIDDEN in SurfaceControl.java - eLayerOpaque = 0x02, // SURFACE_OPAQUE - eLayerSecure = 0x80, // SECURE - }; - - enum { - ePositionChanged = 0x00000001, - eLayerChanged = 0x00000002, - eSizeChanged = 0x00000004, - eAlphaChanged = 0x00000008, - eMatrixChanged = 0x00000010, - eTransparentRegionChanged = 0x00000020, - eFlagsChanged = 0x00000040, - eLayerStackChanged = 0x00000080, - eCropChanged = 0x00000100, - eBlurChanged = 0x00400000, - eBlurMaskSurfaceChanged = 0x00800000, - eBlurMaskSamplingChanged = 0x01000000, - eBlurMaskAlphaThresholdChanged = 0x02000000, - }; - - layer_state_t() - : what(0), - x(0), y(0), z(0), w(0), h(0), layerStack(0), blur(0), - blurMaskSampling(0), blurMaskAlphaThreshold(0), alpha(0), flags(0), mask(0), - reserved(0) - { - matrix.dsdx = matrix.dtdy = 1.0f; - matrix.dsdy = matrix.dtdx = 0.0f; - crop.makeInvalid(); - } - - status_t write(Parcel& output) const; - status_t read(const Parcel& input); - - struct matrix22_t { - float dsdx; - float dtdx; - float dsdy; - float dtdy; - }; - sp surface; - uint32_t what; - float x; - float y; - uint32_t z; - uint32_t w; - uint32_t h; - uint32_t layerStack; - float blur; - sp blurMaskSurface; - uint32_t blurMaskSampling; - float blurMaskAlphaThreshold; - float alpha; - uint8_t flags; - uint8_t mask; - uint8_t reserved; - matrix22_t matrix; - Rect crop; - // non POD must be last. see write/read - Region transparentRegion; -}; - -struct ComposerState { - sp client; - layer_state_t state; - status_t write(Parcel& output) const; - status_t read(const Parcel& input); -}; - -struct DisplayState { - - enum { - eOrientationDefault = 0, - eOrientation90 = 1, - eOrientation180 = 2, - eOrientation270 = 3, - eOrientationUnchanged = 4, - eOrientationSwapMask = 0x01 - }; - - enum { - eSurfaceChanged = 0x01, - eLayerStackChanged = 0x02, - eDisplayProjectionChanged = 0x04, - eDisplaySizeChanged = 0x08 - }; - - uint32_t what; - sp token; - sp surface; - uint32_t layerStack; - uint32_t orientation; - Rect viewport; - Rect frame; - uint32_t width, height; - status_t write(Parcel& output) const; - status_t read(const Parcel& input); -}; - -}; // namespace android - -#endif // ANDROID_SF_LAYER_STATE_H - diff --git a/phonelibs/android_frameworks_native/include/private/gui/SyncFeatures.h b/phonelibs/android_frameworks_native/include/private/gui/SyncFeatures.h deleted file mode 100644 index 79fb75bcbeb143..00000000000000 --- a/phonelibs/android_frameworks_native/include/private/gui/SyncFeatures.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * 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. - */ - -#ifndef ANDROID_GUI_SYNC_FEATURES_H -#define ANDROID_GUI_SYNC_FEATURES_H - -#include -#include - - -namespace android { -// ---------------------------------------------------------------------------- - -class SyncFeatures : public Singleton { - friend class Singleton; - bool mHasNativeFenceSync; - bool mHasFenceSync; - bool mHasWaitSync; - String8 mString; - SyncFeatures(); - -public: - bool useNativeFenceSync() const; - bool useFenceSync() const; - bool useWaitSync() const; - String8 toString() const; -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_SYNC_FEATURES_H diff --git a/phonelibs/android_frameworks_native/include/private/ui/RegionHelper.h b/phonelibs/android_frameworks_native/include/private/ui/RegionHelper.h deleted file mode 100644 index 8c190dd40b0007..00000000000000 --- a/phonelibs/android_frameworks_native/include/private/ui/RegionHelper.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * 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. - */ - -#ifndef ANDROID_UI_PRIVATE_REGION_HELPER_H -#define ANDROID_UI_PRIVATE_REGION_HELPER_H - -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -template -class region_operator -{ -public: - typedef typename RECT::value_type TYPE; - static const TYPE max_value = 0x7FFFFFF; - - /* - * Common boolean operations: - * value is computed as 0b101 op 0b110 - * other boolean operation are possible, simply compute - * their corresponding value with the above formulae and use - * it when instantiating a region_operator. - */ - static const uint32_t LHS = 0x5; // 0b101 - static const uint32_t RHS = 0x6; // 0b110 - enum { - op_nand = LHS & ~RHS, - op_and = LHS & RHS, - op_or = LHS | RHS, - op_xor = LHS ^ RHS - }; - - struct region { - RECT const* rects; - size_t count; - TYPE dx; - TYPE dy; - inline region(const region& rhs) - : rects(rhs.rects), count(rhs.count), dx(rhs.dx), dy(rhs.dy) { } - inline region(RECT const* r, size_t c) - : rects(r), count(c), dx(), dy() { } - inline region(RECT const* r, size_t c, TYPE dx, TYPE dy) - : rects(r), count(c), dx(dx), dy(dy) { } - }; - - class region_rasterizer { - friend class region_operator; - virtual void operator()(const RECT& rect) = 0; - public: - virtual ~region_rasterizer() { }; - }; - - inline region_operator(int op, const region& lhs, const region& rhs) - : op_mask(op), spanner(lhs, rhs) - { - } - - void operator()(region_rasterizer& rasterizer) { - RECT current; - do { - SpannerInner spannerInner(spanner.lhs, spanner.rhs); - int inside = spanner.next(current.top, current.bottom); - spannerInner.prepare(inside); - do { - TYPE left, right; - int inside = spannerInner.next(current.left, current.right); - if ((op_mask >> inside) & 1) { - if (current.left < current.right && - current.top < current.bottom) { - rasterizer(current); - } - } - } while(!spannerInner.isDone()); - } while(!spanner.isDone()); - } - -private: - uint32_t op_mask; - - class SpannerBase - { - public: - SpannerBase() - : lhs_head(max_value), lhs_tail(max_value), - rhs_head(max_value), rhs_tail(max_value) { - } - - enum { - lhs_before_rhs = 0, - lhs_after_rhs = 1, - lhs_coincide_rhs = 2 - }; - - protected: - TYPE lhs_head; - TYPE lhs_tail; - TYPE rhs_head; - TYPE rhs_tail; - - inline int next(TYPE& head, TYPE& tail, - bool& more_lhs, bool& more_rhs) - { - int inside; - more_lhs = false; - more_rhs = false; - if (lhs_head < rhs_head) { - inside = lhs_before_rhs; - head = lhs_head; - if (lhs_tail <= rhs_head) { - tail = lhs_tail; - more_lhs = true; - } else { - lhs_head = rhs_head; - tail = rhs_head; - } - } else if (rhs_head < lhs_head) { - inside = lhs_after_rhs; - head = rhs_head; - if (rhs_tail <= lhs_head) { - tail = rhs_tail; - more_rhs = true; - } else { - rhs_head = lhs_head; - tail = lhs_head; - } - } else { - inside = lhs_coincide_rhs; - head = lhs_head; - if (lhs_tail <= rhs_tail) { - tail = rhs_head = lhs_tail; - more_lhs = true; - } - if (rhs_tail <= lhs_tail) { - tail = lhs_head = rhs_tail; - more_rhs = true; - } - } - return inside; - } - }; - - class Spanner : protected SpannerBase - { - friend class region_operator; - region lhs; - region rhs; - - public: - inline Spanner(const region& lhs, const region& rhs) - : lhs(lhs), rhs(rhs) - { - if (lhs.count) { - SpannerBase::lhs_head = lhs.rects->top + lhs.dy; - SpannerBase::lhs_tail = lhs.rects->bottom + lhs.dy; - } - if (rhs.count) { - SpannerBase::rhs_head = rhs.rects->top + rhs.dy; - SpannerBase::rhs_tail = rhs.rects->bottom + rhs.dy; - } - } - - inline bool isDone() const { - return !rhs.count && !lhs.count; - } - - inline int next(TYPE& top, TYPE& bottom) - { - bool more_lhs = false; - bool more_rhs = false; - int inside = SpannerBase::next(top, bottom, more_lhs, more_rhs); - if (more_lhs) { - advance(lhs, SpannerBase::lhs_head, SpannerBase::lhs_tail); - } - if (more_rhs) { - advance(rhs, SpannerBase::rhs_head, SpannerBase::rhs_tail); - } - return inside; - } - - private: - static inline - void advance(region& reg, TYPE& aTop, TYPE& aBottom) { - // got to next span - size_t count = reg.count; - RECT const * rects = reg.rects; - RECT const * const end = rects + count; - const int top = rects->top; - while (rects != end && rects->top == top) { - rects++; - count--; - } - if (rects != end) { - aTop = rects->top + reg.dy; - aBottom = rects->bottom + reg.dy; - } else { - aTop = max_value; - aBottom = max_value; - } - reg.rects = rects; - reg.count = count; - } - }; - - class SpannerInner : protected SpannerBase - { - region lhs; - region rhs; - - public: - inline SpannerInner(const region& lhs, const region& rhs) - : lhs(lhs), rhs(rhs) - { - } - - inline void prepare(int inside) { - if (inside == SpannerBase::lhs_before_rhs) { - if (lhs.count) { - SpannerBase::lhs_head = lhs.rects->left + lhs.dx; - SpannerBase::lhs_tail = lhs.rects->right + lhs.dx; - } - SpannerBase::rhs_head = max_value; - SpannerBase::rhs_tail = max_value; - } else if (inside == SpannerBase::lhs_after_rhs) { - SpannerBase::lhs_head = max_value; - SpannerBase::lhs_tail = max_value; - if (rhs.count) { - SpannerBase::rhs_head = rhs.rects->left + rhs.dx; - SpannerBase::rhs_tail = rhs.rects->right + rhs.dx; - } - } else { - if (lhs.count) { - SpannerBase::lhs_head = lhs.rects->left + lhs.dx; - SpannerBase::lhs_tail = lhs.rects->right + lhs.dx; - } - if (rhs.count) { - SpannerBase::rhs_head = rhs.rects->left + rhs.dx; - SpannerBase::rhs_tail = rhs.rects->right + rhs.dx; - } - } - } - - inline bool isDone() const { - return SpannerBase::lhs_head == max_value && - SpannerBase::rhs_head == max_value; - } - - inline int next(TYPE& left, TYPE& right) - { - bool more_lhs = false; - bool more_rhs = false; - int inside = SpannerBase::next(left, right, more_lhs, more_rhs); - if (more_lhs) { - advance(lhs, SpannerBase::lhs_head, SpannerBase::lhs_tail); - } - if (more_rhs) { - advance(rhs, SpannerBase::rhs_head, SpannerBase::rhs_tail); - } - return inside; - } - - private: - static inline - void advance(region& reg, TYPE& left, TYPE& right) { - if (reg.rects && reg.count) { - const int cur_span_top = reg.rects->top; - reg.rects++; - reg.count--; - if (!reg.count || reg.rects->top != cur_span_top) { - left = max_value; - right = max_value; - } else { - left = reg.rects->left + reg.dx; - right = reg.rects->right + reg.dx; - } - } - } - }; - - Spanner spanner; -}; - -// ---------------------------------------------------------------------------- -}; - -#endif /* ANDROID_UI_PRIVATE_REGION_HELPER_H */ 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/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 516adf37346d2f..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/nanovg/fontstash.h b/phonelibs/nanovg/fontstash.h deleted file mode 100644 index 35dfb0f6525ea8..00000000000000 --- a/phonelibs/nanovg/fontstash.h +++ /dev/null @@ -1,1718 +0,0 @@ -// -// Copyright (c) 2009-2013 Mikko Mononen memon@inside.org -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. 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. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// - -#ifndef FONS_H -#define FONS_H - -#define FONS_INVALID -1 - -enum FONSflags { - FONS_ZERO_TOPLEFT = 1, - FONS_ZERO_BOTTOMLEFT = 2, -}; - -enum FONSalign { - // Horizontal align - FONS_ALIGN_LEFT = 1<<0, // Default - FONS_ALIGN_CENTER = 1<<1, - FONS_ALIGN_RIGHT = 1<<2, - // Vertical align - FONS_ALIGN_TOP = 1<<3, - FONS_ALIGN_MIDDLE = 1<<4, - FONS_ALIGN_BOTTOM = 1<<5, - FONS_ALIGN_BASELINE = 1<<6, // Default -}; - -enum FONSerrorCode { - // Font atlas is full. - FONS_ATLAS_FULL = 1, - // Scratch memory used to render glyphs is full, requested size reported in 'val', you may need to bump up FONS_SCRATCH_BUF_SIZE. - FONS_SCRATCH_FULL = 2, - // Calls to fonsPushState has created too large stack, if you need deep state stack bump up FONS_MAX_STATES. - FONS_STATES_OVERFLOW = 3, - // Trying to pop too many states fonsPopState(). - FONS_STATES_UNDERFLOW = 4, -}; - -struct FONSparams { - int width, height; - unsigned char flags; - void* userPtr; - int (*renderCreate)(void* uptr, int width, int height); - int (*renderResize)(void* uptr, int width, int height); - void (*renderUpdate)(void* uptr, int* rect, const unsigned char* data); - void (*renderDraw)(void* uptr, const float* verts, const float* tcoords, const unsigned int* colors, int nverts); - void (*renderDelete)(void* uptr); -}; -typedef struct FONSparams FONSparams; - -struct FONSquad -{ - float x0,y0,s0,t0; - float x1,y1,s1,t1; -}; -typedef struct FONSquad FONSquad; - -struct FONStextIter { - float x, y, nextx, nexty, scale, spacing; - unsigned int codepoint; - short isize, iblur; - struct FONSfont* font; - int prevGlyphIndex; - const char* str; - const char* next; - const char* end; - unsigned int utf8state; -}; -typedef struct FONStextIter FONStextIter; - -typedef struct FONScontext FONScontext; - -// Constructor and destructor. -FONScontext* fonsCreateInternal(FONSparams* params); -void fonsDeleteInternal(FONScontext* s); - -void fonsSetErrorCallback(FONScontext* s, void (*callback)(void* uptr, int error, int val), void* uptr); -// Returns current atlas size. -void fonsGetAtlasSize(FONScontext* s, int* width, int* height); -// Expands the atlas size. -int fonsExpandAtlas(FONScontext* s, int width, int height); -// Resets the whole stash. -int fonsResetAtlas(FONScontext* stash, int width, int height); - -// Add fonts -int fonsAddFont(FONScontext* s, const char* name, const char* path); -int fonsAddFontMem(FONScontext* s, const char* name, unsigned char* data, int ndata, int freeData); -int fonsGetFontByName(FONScontext* s, const char* name); - -// State handling -void fonsPushState(FONScontext* s); -void fonsPopState(FONScontext* s); -void fonsClearState(FONScontext* s); - -// State setting -void fonsSetSize(FONScontext* s, float size); -void fonsSetColor(FONScontext* s, unsigned int color); -void fonsSetSpacing(FONScontext* s, float spacing); -void fonsSetBlur(FONScontext* s, float blur); -void fonsSetAlign(FONScontext* s, int align); -void fonsSetFont(FONScontext* s, int font); - -// Draw text -float fonsDrawText(FONScontext* s, float x, float y, const char* string, const char* end); - -// Measure text -float fonsTextBounds(FONScontext* s, float x, float y, const char* string, const char* end, float* bounds); -void fonsLineBounds(FONScontext* s, float y, float* miny, float* maxy); -void fonsVertMetrics(FONScontext* s, float* ascender, float* descender, float* lineh); - -// Text iterator -int fonsTextIterInit(FONScontext* stash, FONStextIter* iter, float x, float y, const char* str, const char* end); -int fonsTextIterNext(FONScontext* stash, FONStextIter* iter, struct FONSquad* quad); - -// Pull texture changes -const unsigned char* fonsGetTextureData(FONScontext* stash, int* width, int* height); -int fonsValidateTexture(FONScontext* s, int* dirty); - -// Draws the stash texture for debugging -void fonsDrawDebug(FONScontext* s, float x, float y); - -#endif // FONTSTASH_H - - -#ifdef FONTSTASH_IMPLEMENTATION - -#define FONS_NOTUSED(v) (void)sizeof(v) - -#ifdef FONS_USE_FREETYPE - -#include -#include FT_FREETYPE_H -#include FT_ADVANCES_H -#include - -struct FONSttFontImpl { - FT_Face font; -}; -typedef struct FONSttFontImpl FONSttFontImpl; - -static FT_Library ftLibrary; - -int fons__tt_init(FONScontext *context) -{ - FT_Error ftError; - FONS_NOTUSED(context); - ftError = FT_Init_FreeType(&ftLibrary); - return ftError == 0; -} - -int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize) -{ - FT_Error ftError; - FONS_NOTUSED(context); - - //font->font.userdata = stash; - ftError = FT_New_Memory_Face(ftLibrary, (const FT_Byte*)data, dataSize, 0, &font->font); - return ftError == 0; -} - -void fons__tt_getFontVMetrics(FONSttFontImpl *font, int *ascent, int *descent, int *lineGap) -{ - *ascent = font->font->ascender; - *descent = font->font->descender; - *lineGap = font->font->height - (*ascent - *descent); -} - -float fons__tt_getPixelHeightScale(FONSttFontImpl *font, float size) -{ - return size / (font->font->ascender - font->font->descender); -} - -int fons__tt_getGlyphIndex(FONSttFontImpl *font, int codepoint) -{ - return FT_Get_Char_Index(font->font, codepoint); -} - -int fons__tt_buildGlyphBitmap(FONSttFontImpl *font, int glyph, float size, float scale, - int *advance, int *lsb, int *x0, int *y0, int *x1, int *y1) -{ - FT_Error ftError; - FT_GlyphSlot ftGlyph; - FT_Fixed advFixed; - FONS_NOTUSED(scale); - - ftError = FT_Set_Pixel_Sizes(font->font, 0, (FT_UInt)(size * (float)font->font->units_per_EM / (float)(font->font->ascender - font->font->descender))); - if (ftError) return 0; - ftError = FT_Load_Glyph(font->font, glyph, FT_LOAD_RENDER); - if (ftError) return 0; - ftError = FT_Get_Advance(font->font, glyph, FT_LOAD_NO_SCALE, &advFixed); - if (ftError) return 0; - ftGlyph = font->font->glyph; - *advance = (int)advFixed; - *lsb = (int)ftGlyph->metrics.horiBearingX; - *x0 = ftGlyph->bitmap_left; - *x1 = *x0 + ftGlyph->bitmap.width; - *y0 = -ftGlyph->bitmap_top; - *y1 = *y0 + ftGlyph->bitmap.rows; - return 1; -} - -void fons__tt_renderGlyphBitmap(FONSttFontImpl *font, unsigned char *output, int outWidth, int outHeight, int outStride, - float scaleX, float scaleY, int glyph) -{ - FT_GlyphSlot ftGlyph = font->font->glyph; - int ftGlyphOffset = 0; - int x, y; - FONS_NOTUSED(outWidth); - FONS_NOTUSED(outHeight); - FONS_NOTUSED(scaleX); - FONS_NOTUSED(scaleY); - FONS_NOTUSED(glyph); // glyph has already been loaded by fons__tt_buildGlyphBitmap - - for ( y = 0; y < ftGlyph->bitmap.rows; y++ ) { - for ( x = 0; x < ftGlyph->bitmap.width; x++ ) { - output[(y * outStride) + x] = ftGlyph->bitmap.buffer[ftGlyphOffset++]; - } - } -} - -int fons__tt_getGlyphKernAdvance(FONSttFontImpl *font, int glyph1, int glyph2) -{ - FT_Vector ftKerning; - FT_Get_Kerning(font->font, glyph1, glyph2, FT_KERNING_DEFAULT, &ftKerning); - return (int)((ftKerning.x + 32) >> 6); // Round up and convert to integer -} - -#else - -#define STB_TRUETYPE_IMPLEMENTATION -static void* fons__tmpalloc(size_t size, void* up); -static void fons__tmpfree(void* ptr, void* up); -#define STBTT_malloc(x,u) fons__tmpalloc(x,u) -#define STBTT_free(x,u) fons__tmpfree(x,u) -#include "stb_truetype.h" - -struct FONSttFontImpl { - stbtt_fontinfo font; -}; -typedef struct FONSttFontImpl FONSttFontImpl; - -int fons__tt_init(FONScontext *context) -{ - FONS_NOTUSED(context); - return 1; -} - -int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize) -{ - int stbError; - FONS_NOTUSED(dataSize); - - font->font.userdata = context; - stbError = stbtt_InitFont(&font->font, data, 0); - return stbError; -} - -void fons__tt_getFontVMetrics(FONSttFontImpl *font, int *ascent, int *descent, int *lineGap) -{ - stbtt_GetFontVMetrics(&font->font, ascent, descent, lineGap); -} - -float fons__tt_getPixelHeightScale(FONSttFontImpl *font, float size) -{ - return stbtt_ScaleForPixelHeight(&font->font, size); -} - -int fons__tt_getGlyphIndex(FONSttFontImpl *font, int codepoint) -{ - return stbtt_FindGlyphIndex(&font->font, codepoint); -} - -int fons__tt_buildGlyphBitmap(FONSttFontImpl *font, int glyph, float size, float scale, - int *advance, int *lsb, int *x0, int *y0, int *x1, int *y1) -{ - FONS_NOTUSED(size); - stbtt_GetGlyphHMetrics(&font->font, glyph, advance, lsb); - stbtt_GetGlyphBitmapBox(&font->font, glyph, scale, scale, x0, y0, x1, y1); - return 1; -} - -void fons__tt_renderGlyphBitmap(FONSttFontImpl *font, unsigned char *output, int outWidth, int outHeight, int outStride, - float scaleX, float scaleY, int glyph) -{ - stbtt_MakeGlyphBitmap(&font->font, output, outWidth, outHeight, outStride, scaleX, scaleY, glyph); -} - -int fons__tt_getGlyphKernAdvance(FONSttFontImpl *font, int glyph1, int glyph2) -{ - return stbtt_GetGlyphKernAdvance(&font->font, glyph1, glyph2); -} - -#endif - -#ifndef FONS_SCRATCH_BUF_SIZE -# define FONS_SCRATCH_BUF_SIZE 64000 -#endif -#ifndef FONS_HASH_LUT_SIZE -# define FONS_HASH_LUT_SIZE 256 -#endif -#ifndef FONS_INIT_FONTS -# define FONS_INIT_FONTS 4 -#endif -#ifndef FONS_INIT_GLYPHS -# define FONS_INIT_GLYPHS 256 -#endif -#ifndef FONS_INIT_ATLAS_NODES -# define FONS_INIT_ATLAS_NODES 256 -#endif -#ifndef FONS_VERTEX_COUNT -# define FONS_VERTEX_COUNT 1024 -#endif -#ifndef FONS_MAX_STATES -# define FONS_MAX_STATES 20 -#endif -#ifndef FONS_MAX_FALLBACKS -# define FONS_MAX_FALLBACKS 20 -#endif - -static unsigned int fons__hashint(unsigned int a) -{ - a += ~(a<<15); - a ^= (a>>10); - a += (a<<3); - a ^= (a>>6); - a += ~(a<<11); - a ^= (a>>16); - return a; -} - -static int fons__mini(int a, int b) -{ - return a < b ? a : b; -} - -static int fons__maxi(int a, int b) -{ - return a > b ? a : b; -} - -struct FONSglyph -{ - unsigned int codepoint; - int index; - int next; - short size, blur; - short x0,y0,x1,y1; - short xadv,xoff,yoff; -}; -typedef struct FONSglyph FONSglyph; - -struct FONSfont -{ - FONSttFontImpl font; - char name[64]; - unsigned char* data; - int dataSize; - unsigned char freeData; - float ascender; - float descender; - float lineh; - FONSglyph* glyphs; - int cglyphs; - int nglyphs; - int lut[FONS_HASH_LUT_SIZE]; - int fallbacks[FONS_MAX_FALLBACKS]; - int nfallbacks; -}; -typedef struct FONSfont FONSfont; - -struct FONSstate -{ - int font; - int align; - float size; - unsigned int color; - float blur; - float spacing; -}; -typedef struct FONSstate FONSstate; - -struct FONSatlasNode { - short x, y, width; -}; -typedef struct FONSatlasNode FONSatlasNode; - -struct FONSatlas -{ - int width, height; - FONSatlasNode* nodes; - int nnodes; - int cnodes; -}; -typedef struct FONSatlas FONSatlas; - -struct FONScontext -{ - FONSparams params; - float itw,ith; - unsigned char* texData; - int dirtyRect[4]; - FONSfont** fonts; - FONSatlas* atlas; - int cfonts; - int nfonts; - float verts[FONS_VERTEX_COUNT*2]; - float tcoords[FONS_VERTEX_COUNT*2]; - unsigned int colors[FONS_VERTEX_COUNT]; - int nverts; - unsigned char* scratch; - int nscratch; - FONSstate states[FONS_MAX_STATES]; - int nstates; - void (*handleError)(void* uptr, int error, int val); - void* errorUptr; -}; - -#ifdef STB_TRUETYPE_IMPLEMENTATION - -static void* fons__tmpalloc(size_t size, void* up) -{ - unsigned char* ptr; - FONScontext* stash = (FONScontext*)up; - - // 16-byte align the returned pointer - size = (size + 0xf) & ~0xf; - - if (stash->nscratch+(int)size > FONS_SCRATCH_BUF_SIZE) { - if (stash->handleError) - stash->handleError(stash->errorUptr, FONS_SCRATCH_FULL, stash->nscratch+(int)size); - return NULL; - } - ptr = stash->scratch + stash->nscratch; - stash->nscratch += (int)size; - return ptr; -} - -static void fons__tmpfree(void* ptr, void* up) -{ - (void)ptr; - (void)up; - // empty -} - -#endif // STB_TRUETYPE_IMPLEMENTATION - -// Copyright (c) 2008-2010 Bjoern Hoehrmann -// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. - -#define FONS_UTF8_ACCEPT 0 -#define FONS_UTF8_REJECT 12 - -static unsigned int fons__decutf8(unsigned int* state, unsigned int* codep, unsigned int byte) -{ - static const unsigned char utf8d[] = { - // The first part of the table maps bytes to character classes that - // to reduce the size of the transition table and create bitmasks. - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, - - // The second part is a transition table that maps a combination - // of a state of the automaton and a character class to a state. - 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12, - 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12, - 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12, - 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12, - 12,36,12,12,12,12,12,12,12,12,12,12, - }; - - unsigned int type = utf8d[byte]; - - *codep = (*state != FONS_UTF8_ACCEPT) ? - (byte & 0x3fu) | (*codep << 6) : - (0xff >> type) & (byte); - - *state = utf8d[256 + *state + type]; - return *state; -} - -// Atlas based on Skyline Bin Packer by Jukka Jylänki - -static void fons__deleteAtlas(FONSatlas* atlas) -{ - if (atlas == NULL) return; - if (atlas->nodes != NULL) free(atlas->nodes); - free(atlas); -} - -static FONSatlas* fons__allocAtlas(int w, int h, int nnodes) -{ - FONSatlas* atlas = NULL; - - // Allocate memory for the font stash. - atlas = (FONSatlas*)malloc(sizeof(FONSatlas)); - if (atlas == NULL) goto error; - memset(atlas, 0, sizeof(FONSatlas)); - - atlas->width = w; - atlas->height = h; - - // Allocate space for skyline nodes - atlas->nodes = (FONSatlasNode*)malloc(sizeof(FONSatlasNode) * nnodes); - if (atlas->nodes == NULL) goto error; - memset(atlas->nodes, 0, sizeof(FONSatlasNode) * nnodes); - atlas->nnodes = 0; - atlas->cnodes = nnodes; - - // Init root node. - atlas->nodes[0].x = 0; - atlas->nodes[0].y = 0; - atlas->nodes[0].width = (short)w; - atlas->nnodes++; - - return atlas; - -error: - if (atlas) fons__deleteAtlas(atlas); - return NULL; -} - -static int fons__atlasInsertNode(FONSatlas* atlas, int idx, int x, int y, int w) -{ - int i; - // Insert node - if (atlas->nnodes+1 > atlas->cnodes) { - atlas->cnodes = atlas->cnodes == 0 ? 8 : atlas->cnodes * 2; - atlas->nodes = (FONSatlasNode*)realloc(atlas->nodes, sizeof(FONSatlasNode) * atlas->cnodes); - if (atlas->nodes == NULL) - return 0; - } - for (i = atlas->nnodes; i > idx; i--) - atlas->nodes[i] = atlas->nodes[i-1]; - atlas->nodes[idx].x = (short)x; - atlas->nodes[idx].y = (short)y; - atlas->nodes[idx].width = (short)w; - atlas->nnodes++; - - return 1; -} - -static void fons__atlasRemoveNode(FONSatlas* atlas, int idx) -{ - int i; - if (atlas->nnodes == 0) return; - for (i = idx; i < atlas->nnodes-1; i++) - atlas->nodes[i] = atlas->nodes[i+1]; - atlas->nnodes--; -} - -static void fons__atlasExpand(FONSatlas* atlas, int w, int h) -{ - // Insert node for empty space - if (w > atlas->width) - fons__atlasInsertNode(atlas, atlas->nnodes, atlas->width, 0, w - atlas->width); - atlas->width = w; - atlas->height = h; -} - -static void fons__atlasReset(FONSatlas* atlas, int w, int h) -{ - atlas->width = w; - atlas->height = h; - atlas->nnodes = 0; - - // Init root node. - atlas->nodes[0].x = 0; - atlas->nodes[0].y = 0; - atlas->nodes[0].width = (short)w; - atlas->nnodes++; -} - -static int fons__atlasAddSkylineLevel(FONSatlas* atlas, int idx, int x, int y, int w, int h) -{ - int i; - - // Insert new node - if (fons__atlasInsertNode(atlas, idx, x, y+h, w) == 0) - return 0; - - // Delete skyline segments that fall under the shadow of the new segment. - for (i = idx+1; i < atlas->nnodes; i++) { - if (atlas->nodes[i].x < atlas->nodes[i-1].x + atlas->nodes[i-1].width) { - int shrink = atlas->nodes[i-1].x + atlas->nodes[i-1].width - atlas->nodes[i].x; - atlas->nodes[i].x += (short)shrink; - atlas->nodes[i].width -= (short)shrink; - if (atlas->nodes[i].width <= 0) { - fons__atlasRemoveNode(atlas, i); - i--; - } else { - break; - } - } else { - break; - } - } - - // Merge same height skyline segments that are next to each other. - for (i = 0; i < atlas->nnodes-1; i++) { - if (atlas->nodes[i].y == atlas->nodes[i+1].y) { - atlas->nodes[i].width += atlas->nodes[i+1].width; - fons__atlasRemoveNode(atlas, i+1); - i--; - } - } - - return 1; -} - -static int fons__atlasRectFits(FONSatlas* atlas, int i, int w, int h) -{ - // Checks if there is enough space at the location of skyline span 'i', - // and return the max height of all skyline spans under that at that location, - // (think tetris block being dropped at that position). Or -1 if no space found. - int x = atlas->nodes[i].x; - int y = atlas->nodes[i].y; - int spaceLeft; - if (x + w > atlas->width) - return -1; - spaceLeft = w; - while (spaceLeft > 0) { - if (i == atlas->nnodes) return -1; - y = fons__maxi(y, atlas->nodes[i].y); - if (y + h > atlas->height) return -1; - spaceLeft -= atlas->nodes[i].width; - ++i; - } - return y; -} - -static int fons__atlasAddRect(FONSatlas* atlas, int rw, int rh, int* rx, int* ry) -{ - int besth = atlas->height, bestw = atlas->width, besti = -1; - int bestx = -1, besty = -1, i; - - // Bottom left fit heuristic. - for (i = 0; i < atlas->nnodes; i++) { - int y = fons__atlasRectFits(atlas, i, rw, rh); - if (y != -1) { - if (y + rh < besth || (y + rh == besth && atlas->nodes[i].width < bestw)) { - besti = i; - bestw = atlas->nodes[i].width; - besth = y + rh; - bestx = atlas->nodes[i].x; - besty = y; - } - } - } - - if (besti == -1) - return 0; - - // Perform the actual packing. - if (fons__atlasAddSkylineLevel(atlas, besti, bestx, besty, rw, rh) == 0) - return 0; - - *rx = bestx; - *ry = besty; - - return 1; -} - -static void fons__addWhiteRect(FONScontext* stash, int w, int h) -{ - int x, y, gx, gy; - unsigned char* dst; - if (fons__atlasAddRect(stash->atlas, w, h, &gx, &gy) == 0) - return; - - // Rasterize - dst = &stash->texData[gx + gy * stash->params.width]; - for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) - dst[x] = 0xff; - dst += stash->params.width; - } - - stash->dirtyRect[0] = fons__mini(stash->dirtyRect[0], gx); - stash->dirtyRect[1] = fons__mini(stash->dirtyRect[1], gy); - stash->dirtyRect[2] = fons__maxi(stash->dirtyRect[2], gx+w); - stash->dirtyRect[3] = fons__maxi(stash->dirtyRect[3], gy+h); -} - -FONScontext* fonsCreateInternal(FONSparams* params) -{ - FONScontext* stash = NULL; - - // Allocate memory for the font stash. - stash = (FONScontext*)malloc(sizeof(FONScontext)); - if (stash == NULL) goto error; - memset(stash, 0, sizeof(FONScontext)); - - stash->params = *params; - - // Allocate scratch buffer. - stash->scratch = (unsigned char*)malloc(FONS_SCRATCH_BUF_SIZE); - if (stash->scratch == NULL) goto error; - - // Initialize implementation library - if (!fons__tt_init(stash)) goto error; - - if (stash->params.renderCreate != NULL) { - if (stash->params.renderCreate(stash->params.userPtr, stash->params.width, stash->params.height) == 0) - goto error; - } - - stash->atlas = fons__allocAtlas(stash->params.width, stash->params.height, FONS_INIT_ATLAS_NODES); - if (stash->atlas == NULL) goto error; - - // Allocate space for fonts. - stash->fonts = (FONSfont**)malloc(sizeof(FONSfont*) * FONS_INIT_FONTS); - if (stash->fonts == NULL) goto error; - memset(stash->fonts, 0, sizeof(FONSfont*) * FONS_INIT_FONTS); - stash->cfonts = FONS_INIT_FONTS; - stash->nfonts = 0; - - // Create texture for the cache. - stash->itw = 1.0f/stash->params.width; - stash->ith = 1.0f/stash->params.height; - stash->texData = (unsigned char*)malloc(stash->params.width * stash->params.height); - if (stash->texData == NULL) goto error; - memset(stash->texData, 0, stash->params.width * stash->params.height); - - stash->dirtyRect[0] = stash->params.width; - stash->dirtyRect[1] = stash->params.height; - stash->dirtyRect[2] = 0; - stash->dirtyRect[3] = 0; - - // Add white rect at 0,0 for debug drawing. - fons__addWhiteRect(stash, 2,2); - - fonsPushState(stash); - fonsClearState(stash); - - return stash; - -error: - fonsDeleteInternal(stash); - return NULL; -} - -static FONSstate* fons__getState(FONScontext* stash) -{ - return &stash->states[stash->nstates-1]; -} - -int fonsAddFallbackFont(FONScontext* stash, int base, int fallback) -{ - FONSfont* baseFont = stash->fonts[base]; - if (baseFont->nfallbacks < FONS_MAX_FALLBACKS) { - baseFont->fallbacks[baseFont->nfallbacks++] = fallback; - return 1; - } - return 0; -} - -void fonsSetSize(FONScontext* stash, float size) -{ - fons__getState(stash)->size = size; -} - -void fonsSetColor(FONScontext* stash, unsigned int color) -{ - fons__getState(stash)->color = color; -} - -void fonsSetSpacing(FONScontext* stash, float spacing) -{ - fons__getState(stash)->spacing = spacing; -} - -void fonsSetBlur(FONScontext* stash, float blur) -{ - fons__getState(stash)->blur = blur; -} - -void fonsSetAlign(FONScontext* stash, int align) -{ - fons__getState(stash)->align = align; -} - -void fonsSetFont(FONScontext* stash, int font) -{ - fons__getState(stash)->font = font; -} - -void fonsPushState(FONScontext* stash) -{ - if (stash->nstates >= FONS_MAX_STATES) { - if (stash->handleError) - stash->handleError(stash->errorUptr, FONS_STATES_OVERFLOW, 0); - return; - } - if (stash->nstates > 0) - memcpy(&stash->states[stash->nstates], &stash->states[stash->nstates-1], sizeof(FONSstate)); - stash->nstates++; -} - -void fonsPopState(FONScontext* stash) -{ - if (stash->nstates <= 1) { - if (stash->handleError) - stash->handleError(stash->errorUptr, FONS_STATES_UNDERFLOW, 0); - return; - } - stash->nstates--; -} - -void fonsClearState(FONScontext* stash) -{ - FONSstate* state = fons__getState(stash); - state->size = 12.0f; - state->color = 0xffffffff; - state->font = 0; - state->blur = 0; - state->spacing = 0; - state->align = FONS_ALIGN_LEFT | FONS_ALIGN_BASELINE; -} - -static void fons__freeFont(FONSfont* font) -{ - if (font == NULL) return; - if (font->glyphs) free(font->glyphs); - if (font->freeData && font->data) free(font->data); - free(font); -} - -static int fons__allocFont(FONScontext* stash) -{ - FONSfont* font = NULL; - if (stash->nfonts+1 > stash->cfonts) { - stash->cfonts = stash->cfonts == 0 ? 8 : stash->cfonts * 2; - stash->fonts = (FONSfont**)realloc(stash->fonts, sizeof(FONSfont*) * stash->cfonts); - if (stash->fonts == NULL) - return -1; - } - font = (FONSfont*)malloc(sizeof(FONSfont)); - if (font == NULL) goto error; - memset(font, 0, sizeof(FONSfont)); - - font->glyphs = (FONSglyph*)malloc(sizeof(FONSglyph) * FONS_INIT_GLYPHS); - if (font->glyphs == NULL) goto error; - font->cglyphs = FONS_INIT_GLYPHS; - font->nglyphs = 0; - - stash->fonts[stash->nfonts++] = font; - return stash->nfonts-1; - -error: - fons__freeFont(font); - - return FONS_INVALID; -} - -int fonsAddFont(FONScontext* stash, const char* name, const char* path) -{ - FILE* fp = 0; - int dataSize = 0; - unsigned char* data = NULL; - - // Read in the font data. - fp = fopen(path, "rb"); - if (fp == NULL) goto error; - fseek(fp,0,SEEK_END); - dataSize = (int)ftell(fp); - fseek(fp,0,SEEK_SET); - data = (unsigned char*)malloc(dataSize); - if (data == NULL) goto error; - fread(data, 1, dataSize, fp); - fclose(fp); - fp = 0; - - return fonsAddFontMem(stash, name, data, dataSize, 1); - -error: - if (data) free(data); - if (fp) fclose(fp); - return FONS_INVALID; -} - -int fonsAddFontMem(FONScontext* stash, const char* name, unsigned char* data, int dataSize, int freeData) -{ - int i, ascent, descent, fh, lineGap; - FONSfont* font; - - int idx = fons__allocFont(stash); - if (idx == FONS_INVALID) - return FONS_INVALID; - - font = stash->fonts[idx]; - - strncpy(font->name, name, sizeof(font->name)); - font->name[sizeof(font->name)-1] = '\0'; - - // Init hash lookup. - for (i = 0; i < FONS_HASH_LUT_SIZE; ++i) - font->lut[i] = -1; - - // Read in the font data. - font->dataSize = dataSize; - font->data = data; - font->freeData = (unsigned char)freeData; - - // Init font - stash->nscratch = 0; - if (!fons__tt_loadFont(stash, &font->font, data, dataSize)) goto error; - - // Store normalized line height. The real line height is got - // by multiplying the lineh by font size. - fons__tt_getFontVMetrics( &font->font, &ascent, &descent, &lineGap); - fh = ascent - descent; - font->ascender = (float)ascent / (float)fh; - font->descender = (float)descent / (float)fh; - font->lineh = (float)(fh + lineGap) / (float)fh; - - return idx; - -error: - fons__freeFont(font); - stash->nfonts--; - return FONS_INVALID; -} - -int fonsGetFontByName(FONScontext* s, const char* name) -{ - int i; - for (i = 0; i < s->nfonts; i++) { - if (strcmp(s->fonts[i]->name, name) == 0) - return i; - } - return FONS_INVALID; -} - - -static FONSglyph* fons__allocGlyph(FONSfont* font) -{ - if (font->nglyphs+1 > font->cglyphs) { - font->cglyphs = font->cglyphs == 0 ? 8 : font->cglyphs * 2; - font->glyphs = (FONSglyph*)realloc(font->glyphs, sizeof(FONSglyph) * font->cglyphs); - if (font->glyphs == NULL) return NULL; - } - font->nglyphs++; - return &font->glyphs[font->nglyphs-1]; -} - - -// Based on Exponential blur, Jani Huhtanen, 2006 - -#define APREC 16 -#define ZPREC 7 - -static void fons__blurCols(unsigned char* dst, int w, int h, int dstStride, int alpha) -{ - int x, y; - for (y = 0; y < h; y++) { - int z = 0; // force zero border - for (x = 1; x < w; x++) { - z += (alpha * (((int)(dst[x]) << ZPREC) - z)) >> APREC; - dst[x] = (unsigned char)(z >> ZPREC); - } - dst[w-1] = 0; // force zero border - z = 0; - for (x = w-2; x >= 0; x--) { - z += (alpha * (((int)(dst[x]) << ZPREC) - z)) >> APREC; - dst[x] = (unsigned char)(z >> ZPREC); - } - dst[0] = 0; // force zero border - dst += dstStride; - } -} - -static void fons__blurRows(unsigned char* dst, int w, int h, int dstStride, int alpha) -{ - int x, y; - for (x = 0; x < w; x++) { - int z = 0; // force zero border - for (y = dstStride; y < h*dstStride; y += dstStride) { - z += (alpha * (((int)(dst[y]) << ZPREC) - z)) >> APREC; - dst[y] = (unsigned char)(z >> ZPREC); - } - dst[(h-1)*dstStride] = 0; // force zero border - z = 0; - for (y = (h-2)*dstStride; y >= 0; y -= dstStride) { - z += (alpha * (((int)(dst[y]) << ZPREC) - z)) >> APREC; - dst[y] = (unsigned char)(z >> ZPREC); - } - dst[0] = 0; // force zero border - dst++; - } -} - - -static void fons__blur(FONScontext* stash, unsigned char* dst, int w, int h, int dstStride, int blur) -{ - int alpha; - float sigma; - (void)stash; - - if (blur < 1) - return; - // Calculate the alpha such that 90% of the kernel is within the radius. (Kernel extends to infinity) - sigma = (float)blur * 0.57735f; // 1 / sqrt(3) - alpha = (int)((1< 20) iblur = 20; - pad = iblur+2; - - // Reset allocator. - stash->nscratch = 0; - - // Find code point and size. - h = fons__hashint(codepoint) & (FONS_HASH_LUT_SIZE-1); - i = font->lut[h]; - while (i != -1) { - if (font->glyphs[i].codepoint == codepoint && font->glyphs[i].size == isize && font->glyphs[i].blur == iblur) - return &font->glyphs[i]; - i = font->glyphs[i].next; - } - - // Could not find glyph, create it. - scale = fons__tt_getPixelHeightScale(&font->font, size); - g = fons__tt_getGlyphIndex(&font->font, codepoint); - // Try to find the glyph in fallback fonts. - if (g == 0) { - for (i = 0; i < font->nfallbacks; ++i) { - FONSglyph* fallbackGlyph = fons__getGlyph(stash, stash->fonts[font->fallbacks[i]], codepoint, isize, iblur); - if (fallbackGlyph != NULL && fallbackGlyph->index != 0) { - return fallbackGlyph; - } - } - } - fons__tt_buildGlyphBitmap(&font->font, g, size, scale, &advance, &lsb, &x0, &y0, &x1, &y1); - gw = x1-x0 + pad*2; - gh = y1-y0 + pad*2; - - // Find free spot for the rect in the atlas - added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy); - if (added == 0 && stash->handleError != NULL) { - // Atlas is full, let the user to resize the atlas (or not), and try again. - stash->handleError(stash->errorUptr, FONS_ATLAS_FULL, 0); - added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy); - } - if (added == 0) return NULL; - - // Init glyph. - glyph = fons__allocGlyph(font); - glyph->codepoint = codepoint; - glyph->size = isize; - glyph->blur = iblur; - glyph->index = g; - glyph->x0 = (short)gx; - glyph->y0 = (short)gy; - glyph->x1 = (short)(glyph->x0+gw); - glyph->y1 = (short)(glyph->y0+gh); - glyph->xadv = (short)(scale * advance * 10.0f); - glyph->xoff = (short)(x0 - pad); - glyph->yoff = (short)(y0 - pad); - glyph->next = 0; - - // Insert char to hash lookup. - glyph->next = font->lut[h]; - font->lut[h] = font->nglyphs-1; - - // Rasterize - dst = &stash->texData[(glyph->x0+pad) + (glyph->y0+pad) * stash->params.width]; - fons__tt_renderGlyphBitmap(&font->font, dst, gw-pad*2,gh-pad*2, stash->params.width, scale,scale, g); - - // Make sure there is one pixel empty border. - dst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width]; - for (y = 0; y < gh; y++) { - dst[y*stash->params.width] = 0; - dst[gw-1 + y*stash->params.width] = 0; - } - for (x = 0; x < gw; x++) { - dst[x] = 0; - dst[x + (gh-1)*stash->params.width] = 0; - } - - // Debug code to color the glyph background -/* unsigned char* fdst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width]; - for (y = 0; y < gh; y++) { - for (x = 0; x < gw; x++) { - int a = (int)fdst[x+y*stash->params.width] + 20; - if (a > 255) a = 255; - fdst[x+y*stash->params.width] = a; - } - }*/ - - // Blur - if (iblur > 0) { - stash->nscratch = 0; - bdst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width]; - fons__blur(stash, bdst, gw,gh, stash->params.width, iblur); - } - - stash->dirtyRect[0] = fons__mini(stash->dirtyRect[0], glyph->x0); - stash->dirtyRect[1] = fons__mini(stash->dirtyRect[1], glyph->y0); - stash->dirtyRect[2] = fons__maxi(stash->dirtyRect[2], glyph->x1); - stash->dirtyRect[3] = fons__maxi(stash->dirtyRect[3], glyph->y1); - - return glyph; -} - -static void fons__getQuad(FONScontext* stash, FONSfont* font, - int prevGlyphIndex, FONSglyph* glyph, - float scale, float spacing, float* x, float* y, FONSquad* q) -{ - float rx,ry,xoff,yoff,x0,y0,x1,y1; - - if (prevGlyphIndex != -1) { - float adv = fons__tt_getGlyphKernAdvance(&font->font, prevGlyphIndex, glyph->index) * scale; - *x += (int)(adv + spacing + 0.5f); - } - - // Each glyph has 2px border to allow good interpolation, - // one pixel to prevent leaking, and one to allow good interpolation for rendering. - // Inset the texture region by one pixel for correct interpolation. - xoff = (short)(glyph->xoff+1); - yoff = (short)(glyph->yoff+1); - x0 = (float)(glyph->x0+1); - y0 = (float)(glyph->y0+1); - x1 = (float)(glyph->x1-1); - y1 = (float)(glyph->y1-1); - - if (stash->params.flags & FONS_ZERO_TOPLEFT) { - rx = (float)(int)(*x + xoff); - ry = (float)(int)(*y + yoff); - - q->x0 = rx; - q->y0 = ry; - q->x1 = rx + x1 - x0; - q->y1 = ry + y1 - y0; - - q->s0 = x0 * stash->itw; - q->t0 = y0 * stash->ith; - q->s1 = x1 * stash->itw; - q->t1 = y1 * stash->ith; - } else { - rx = (float)(int)(*x + xoff); - ry = (float)(int)(*y - yoff); - - q->x0 = rx; - q->y0 = ry; - q->x1 = rx + x1 - x0; - q->y1 = ry - y1 + y0; - - q->s0 = x0 * stash->itw; - q->t0 = y0 * stash->ith; - q->s1 = x1 * stash->itw; - q->t1 = y1 * stash->ith; - } - - *x += (int)(glyph->xadv / 10.0f + 0.5f); -} - -static void fons__flush(FONScontext* stash) -{ - // Flush texture - if (stash->dirtyRect[0] < stash->dirtyRect[2] && stash->dirtyRect[1] < stash->dirtyRect[3]) { - if (stash->params.renderUpdate != NULL) - stash->params.renderUpdate(stash->params.userPtr, stash->dirtyRect, stash->texData); - // Reset dirty rect - stash->dirtyRect[0] = stash->params.width; - stash->dirtyRect[1] = stash->params.height; - stash->dirtyRect[2] = 0; - stash->dirtyRect[3] = 0; - } - - // Flush triangles - if (stash->nverts > 0) { - if (stash->params.renderDraw != NULL) - stash->params.renderDraw(stash->params.userPtr, stash->verts, stash->tcoords, stash->colors, stash->nverts); - stash->nverts = 0; - } -} - -static __inline void fons__vertex(FONScontext* stash, float x, float y, float s, float t, unsigned int c) -{ - stash->verts[stash->nverts*2+0] = x; - stash->verts[stash->nverts*2+1] = y; - stash->tcoords[stash->nverts*2+0] = s; - stash->tcoords[stash->nverts*2+1] = t; - stash->colors[stash->nverts] = c; - stash->nverts++; -} - -static float fons__getVertAlign(FONScontext* stash, FONSfont* font, int align, short isize) -{ - if (stash->params.flags & FONS_ZERO_TOPLEFT) { - if (align & FONS_ALIGN_TOP) { - return font->ascender * (float)isize/10.0f; - } else if (align & FONS_ALIGN_MIDDLE) { - return (font->ascender + font->descender) / 2.0f * (float)isize/10.0f; - } else if (align & FONS_ALIGN_BASELINE) { - return 0.0f; - } else if (align & FONS_ALIGN_BOTTOM) { - return font->descender * (float)isize/10.0f; - } - } else { - if (align & FONS_ALIGN_TOP) { - return -font->ascender * (float)isize/10.0f; - } else if (align & FONS_ALIGN_MIDDLE) { - return -(font->ascender + font->descender) / 2.0f * (float)isize/10.0f; - } else if (align & FONS_ALIGN_BASELINE) { - return 0.0f; - } else if (align & FONS_ALIGN_BOTTOM) { - return -font->descender * (float)isize/10.0f; - } - } - return 0.0; -} - -float fonsDrawText(FONScontext* stash, - float x, float y, - const char* str, const char* end) -{ - FONSstate* state = fons__getState(stash); - unsigned int codepoint; - unsigned int utf8state = 0; - FONSglyph* glyph = NULL; - FONSquad q; - int prevGlyphIndex = -1; - short isize = (short)(state->size*10.0f); - short iblur = (short)state->blur; - float scale; - FONSfont* font; - float width; - - if (stash == NULL) return x; - if (state->font < 0 || state->font >= stash->nfonts) return x; - font = stash->fonts[state->font]; - if (font->data == NULL) return x; - - scale = fons__tt_getPixelHeightScale(&font->font, (float)isize/10.0f); - - if (end == NULL) - end = str + strlen(str); - - // Align horizontally - if (state->align & FONS_ALIGN_LEFT) { - // empty - } else if (state->align & FONS_ALIGN_RIGHT) { - width = fonsTextBounds(stash, x,y, str, end, NULL); - x -= width; - } else if (state->align & FONS_ALIGN_CENTER) { - width = fonsTextBounds(stash, x,y, str, end, NULL); - x -= width * 0.5f; - } - // Align vertically. - y += fons__getVertAlign(stash, font, state->align, isize); - - for (; str != end; ++str) { - if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str)) - continue; - glyph = fons__getGlyph(stash, font, codepoint, isize, iblur); - if (glyph != NULL) { - fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q); - - if (stash->nverts+6 > FONS_VERTEX_COUNT) - fons__flush(stash); - - fons__vertex(stash, q.x0, q.y0, q.s0, q.t0, state->color); - fons__vertex(stash, q.x1, q.y1, q.s1, q.t1, state->color); - fons__vertex(stash, q.x1, q.y0, q.s1, q.t0, state->color); - - fons__vertex(stash, q.x0, q.y0, q.s0, q.t0, state->color); - fons__vertex(stash, q.x0, q.y1, q.s0, q.t1, state->color); - fons__vertex(stash, q.x1, q.y1, q.s1, q.t1, state->color); - } - prevGlyphIndex = glyph != NULL ? glyph->index : -1; - } - fons__flush(stash); - - return x; -} - -int fonsTextIterInit(FONScontext* stash, FONStextIter* iter, - float x, float y, const char* str, const char* end) -{ - FONSstate* state = fons__getState(stash); - float width; - - memset(iter, 0, sizeof(*iter)); - - if (stash == NULL) return 0; - if (state->font < 0 || state->font >= stash->nfonts) return 0; - iter->font = stash->fonts[state->font]; - if (iter->font->data == NULL) return 0; - - iter->isize = (short)(state->size*10.0f); - iter->iblur = (short)state->blur; - iter->scale = fons__tt_getPixelHeightScale(&iter->font->font, (float)iter->isize/10.0f); - - // Align horizontally - if (state->align & FONS_ALIGN_LEFT) { - // empty - } else if (state->align & FONS_ALIGN_RIGHT) { - width = fonsTextBounds(stash, x,y, str, end, NULL); - x -= width; - } else if (state->align & FONS_ALIGN_CENTER) { - width = fonsTextBounds(stash, x,y, str, end, NULL); - x -= width * 0.5f; - } - // Align vertically. - y += fons__getVertAlign(stash, iter->font, state->align, iter->isize); - - if (end == NULL) - end = str + strlen(str); - - iter->x = iter->nextx = x; - iter->y = iter->nexty = y; - iter->spacing = state->spacing; - iter->str = str; - iter->next = str; - iter->end = end; - iter->codepoint = 0; - iter->prevGlyphIndex = -1; - - return 1; -} - -int fonsTextIterNext(FONScontext* stash, FONStextIter* iter, FONSquad* quad) -{ - FONSglyph* glyph = NULL; - const char* str = iter->next; - iter->str = iter->next; - - if (str == iter->end) - return 0; - - for (; str != iter->end; str++) { - if (fons__decutf8(&iter->utf8state, &iter->codepoint, *(const unsigned char*)str)) - continue; - str++; - // Get glyph and quad - iter->x = iter->nextx; - iter->y = iter->nexty; - glyph = fons__getGlyph(stash, iter->font, iter->codepoint, iter->isize, iter->iblur); - if (glyph != NULL) - fons__getQuad(stash, iter->font, iter->prevGlyphIndex, glyph, iter->scale, iter->spacing, &iter->nextx, &iter->nexty, quad); - iter->prevGlyphIndex = glyph != NULL ? glyph->index : -1; - break; - } - iter->next = str; - - return 1; -} - -void fonsDrawDebug(FONScontext* stash, float x, float y) -{ - int i; - int w = stash->params.width; - int h = stash->params.height; - float u = w == 0 ? 0 : (1.0f / w); - float v = h == 0 ? 0 : (1.0f / h); - - if (stash->nverts+6+6 > FONS_VERTEX_COUNT) - fons__flush(stash); - - // Draw background - fons__vertex(stash, x+0, y+0, u, v, 0x0fffffff); - fons__vertex(stash, x+w, y+h, u, v, 0x0fffffff); - fons__vertex(stash, x+w, y+0, u, v, 0x0fffffff); - - fons__vertex(stash, x+0, y+0, u, v, 0x0fffffff); - fons__vertex(stash, x+0, y+h, u, v, 0x0fffffff); - fons__vertex(stash, x+w, y+h, u, v, 0x0fffffff); - - // Draw texture - fons__vertex(stash, x+0, y+0, 0, 0, 0xffffffff); - fons__vertex(stash, x+w, y+h, 1, 1, 0xffffffff); - fons__vertex(stash, x+w, y+0, 1, 0, 0xffffffff); - - fons__vertex(stash, x+0, y+0, 0, 0, 0xffffffff); - fons__vertex(stash, x+0, y+h, 0, 1, 0xffffffff); - fons__vertex(stash, x+w, y+h, 1, 1, 0xffffffff); - - // Drawbug draw atlas - for (i = 0; i < stash->atlas->nnodes; i++) { - FONSatlasNode* n = &stash->atlas->nodes[i]; - - if (stash->nverts+6 > FONS_VERTEX_COUNT) - fons__flush(stash); - - fons__vertex(stash, x+n->x+0, y+n->y+0, u, v, 0xc00000ff); - fons__vertex(stash, x+n->x+n->width, y+n->y+1, u, v, 0xc00000ff); - fons__vertex(stash, x+n->x+n->width, y+n->y+0, u, v, 0xc00000ff); - - fons__vertex(stash, x+n->x+0, y+n->y+0, u, v, 0xc00000ff); - fons__vertex(stash, x+n->x+0, y+n->y+1, u, v, 0xc00000ff); - fons__vertex(stash, x+n->x+n->width, y+n->y+1, u, v, 0xc00000ff); - } - - fons__flush(stash); -} - -float fonsTextBounds(FONScontext* stash, - float x, float y, - const char* str, const char* end, - float* bounds) -{ - FONSstate* state = fons__getState(stash); - unsigned int codepoint; - unsigned int utf8state = 0; - FONSquad q; - FONSglyph* glyph = NULL; - int prevGlyphIndex = -1; - short isize = (short)(state->size*10.0f); - short iblur = (short)state->blur; - float scale; - FONSfont* font; - float startx, advance; - float minx, miny, maxx, maxy; - - if (stash == NULL) return 0; - if (state->font < 0 || state->font >= stash->nfonts) return 0; - font = stash->fonts[state->font]; - if (font->data == NULL) return 0; - - scale = fons__tt_getPixelHeightScale(&font->font, (float)isize/10.0f); - - // Align vertically. - y += fons__getVertAlign(stash, font, state->align, isize); - - minx = maxx = x; - miny = maxy = y; - startx = x; - - if (end == NULL) - end = str + strlen(str); - - for (; str != end; ++str) { - if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str)) - continue; - glyph = fons__getGlyph(stash, font, codepoint, isize, iblur); - if (glyph != NULL) { - fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q); - if (q.x0 < minx) minx = q.x0; - if (q.x1 > maxx) maxx = q.x1; - if (stash->params.flags & FONS_ZERO_TOPLEFT) { - if (q.y0 < miny) miny = q.y0; - if (q.y1 > maxy) maxy = q.y1; - } else { - if (q.y1 < miny) miny = q.y1; - if (q.y0 > maxy) maxy = q.y0; - } - } - prevGlyphIndex = glyph != NULL ? glyph->index : -1; - } - - advance = x - startx; - - // Align horizontally - if (state->align & FONS_ALIGN_LEFT) { - // empty - } else if (state->align & FONS_ALIGN_RIGHT) { - minx -= advance; - maxx -= advance; - } else if (state->align & FONS_ALIGN_CENTER) { - minx -= advance * 0.5f; - maxx -= advance * 0.5f; - } - - if (bounds) { - bounds[0] = minx; - bounds[1] = miny; - bounds[2] = maxx; - bounds[3] = maxy; - } - - return advance; -} - -void fonsVertMetrics(FONScontext* stash, - float* ascender, float* descender, float* lineh) -{ - FONSfont* font; - FONSstate* state = fons__getState(stash); - short isize; - - if (stash == NULL) return; - if (state->font < 0 || state->font >= stash->nfonts) return; - font = stash->fonts[state->font]; - isize = (short)(state->size*10.0f); - if (font->data == NULL) return; - - if (ascender) - *ascender = font->ascender*isize/10.0f; - if (descender) - *descender = font->descender*isize/10.0f; - if (lineh) - *lineh = font->lineh*isize/10.0f; -} - -void fonsLineBounds(FONScontext* stash, float y, float* miny, float* maxy) -{ - FONSfont* font; - FONSstate* state = fons__getState(stash); - short isize; - - if (stash == NULL) return; - if (state->font < 0 || state->font >= stash->nfonts) return; - font = stash->fonts[state->font]; - isize = (short)(state->size*10.0f); - if (font->data == NULL) return; - - y += fons__getVertAlign(stash, font, state->align, isize); - - if (stash->params.flags & FONS_ZERO_TOPLEFT) { - *miny = y - font->ascender * (float)isize/10.0f; - *maxy = *miny + font->lineh*isize/10.0f; - } else { - *maxy = y + font->descender * (float)isize/10.0f; - *miny = *maxy - font->lineh*isize/10.0f; - } -} - -const unsigned char* fonsGetTextureData(FONScontext* stash, int* width, int* height) -{ - if (width != NULL) - *width = stash->params.width; - if (height != NULL) - *height = stash->params.height; - return stash->texData; -} - -int fonsValidateTexture(FONScontext* stash, int* dirty) -{ - if (stash->dirtyRect[0] < stash->dirtyRect[2] && stash->dirtyRect[1] < stash->dirtyRect[3]) { - dirty[0] = stash->dirtyRect[0]; - dirty[1] = stash->dirtyRect[1]; - dirty[2] = stash->dirtyRect[2]; - dirty[3] = stash->dirtyRect[3]; - // Reset dirty rect - stash->dirtyRect[0] = stash->params.width; - stash->dirtyRect[1] = stash->params.height; - stash->dirtyRect[2] = 0; - stash->dirtyRect[3] = 0; - return 1; - } - return 0; -} - -void fonsDeleteInternal(FONScontext* stash) -{ - int i; - if (stash == NULL) return; - - if (stash->params.renderDelete) - stash->params.renderDelete(stash->params.userPtr); - - for (i = 0; i < stash->nfonts; ++i) - fons__freeFont(stash->fonts[i]); - - if (stash->atlas) fons__deleteAtlas(stash->atlas); - if (stash->fonts) free(stash->fonts); - if (stash->texData) free(stash->texData); - if (stash->scratch) free(stash->scratch); - free(stash); -} - -void fonsSetErrorCallback(FONScontext* stash, void (*callback)(void* uptr, int error, int val), void* uptr) -{ - if (stash == NULL) return; - stash->handleError = callback; - stash->errorUptr = uptr; -} - -void fonsGetAtlasSize(FONScontext* stash, int* width, int* height) -{ - if (stash == NULL) return; - *width = stash->params.width; - *height = stash->params.height; -} - -int fonsExpandAtlas(FONScontext* stash, int width, int height) -{ - int i, maxy = 0; - unsigned char* data = NULL; - if (stash == NULL) return 0; - - width = fons__maxi(width, stash->params.width); - height = fons__maxi(height, stash->params.height); - - if (width == stash->params.width && height == stash->params.height) - return 1; - - // Flush pending glyphs. - fons__flush(stash); - - // Create new texture - if (stash->params.renderResize != NULL) { - if (stash->params.renderResize(stash->params.userPtr, width, height) == 0) - return 0; - } - // Copy old texture data over. - data = (unsigned char*)malloc(width * height); - if (data == NULL) - return 0; - for (i = 0; i < stash->params.height; i++) { - unsigned char* dst = &data[i*width]; - unsigned char* src = &stash->texData[i*stash->params.width]; - memcpy(dst, src, stash->params.width); - if (width > stash->params.width) - memset(dst+stash->params.width, 0, width - stash->params.width); - } - if (height > stash->params.height) - memset(&data[stash->params.height * width], 0, (height - stash->params.height) * width); - - free(stash->texData); - stash->texData = data; - - // Increase atlas size - fons__atlasExpand(stash->atlas, width, height); - - // Add existing data as dirty. - for (i = 0; i < stash->atlas->nnodes; i++) - maxy = fons__maxi(maxy, stash->atlas->nodes[i].y); - stash->dirtyRect[0] = 0; - stash->dirtyRect[1] = 0; - stash->dirtyRect[2] = stash->params.width; - stash->dirtyRect[3] = maxy; - - stash->params.width = width; - stash->params.height = height; - stash->itw = 1.0f/stash->params.width; - stash->ith = 1.0f/stash->params.height; - - return 1; -} - -int fonsResetAtlas(FONScontext* stash, int width, int height) -{ - int i, j; - if (stash == NULL) return 0; - - // Flush pending glyphs. - fons__flush(stash); - - // Create new texture - if (stash->params.renderResize != NULL) { - if (stash->params.renderResize(stash->params.userPtr, width, height) == 0) - return 0; - } - - // Reset atlas - fons__atlasReset(stash->atlas, width, height); - - // Clear texture data. - stash->texData = (unsigned char*)realloc(stash->texData, width * height); - if (stash->texData == NULL) return 0; - memset(stash->texData, 0, width * height); - - // Reset dirty rect - stash->dirtyRect[0] = width; - stash->dirtyRect[1] = height; - stash->dirtyRect[2] = 0; - stash->dirtyRect[3] = 0; - - // Reset cached glyphs - for (i = 0; i < stash->nfonts; i++) { - FONSfont* font = stash->fonts[i]; - font->nglyphs = 0; - for (j = 0; j < FONS_HASH_LUT_SIZE; j++) - font->lut[j] = -1; - } - - stash->params.width = width; - stash->params.height = height; - stash->itw = 1.0f/stash->params.width; - stash->ith = 1.0f/stash->params.height; - - // Add white rect at 0,0 for debug drawing. - fons__addWhiteRect(stash, 2,2); - - return 1; -} - - -#endif diff --git a/phonelibs/nanovg/nanovg.c b/phonelibs/nanovg/nanovg.c deleted file mode 100644 index 51f972ca5b36d9..00000000000000 --- a/phonelibs/nanovg/nanovg.c +++ /dev/null @@ -1,2870 +0,0 @@ -// -// Copyright (c) 2013 Mikko Mononen memon@inside.org -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. 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. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// - -#include -#include -#include -#include - -#include "nanovg.h" -#define FONTSTASH_IMPLEMENTATION -#include "fontstash.h" -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" - -#ifdef _MSC_VER -#pragma warning(disable: 4100) // unreferenced formal parameter -#pragma warning(disable: 4127) // conditional expression is constant -#pragma warning(disable: 4204) // nonstandard extension used : non-constant aggregate initializer -#pragma warning(disable: 4706) // assignment within conditional expression -#endif - -#define NVG_INIT_FONTIMAGE_SIZE 512 -#define NVG_MAX_FONTIMAGE_SIZE 2048 -#define NVG_MAX_FONTIMAGES 4 - -#define NVG_INIT_COMMANDS_SIZE 256 -#define NVG_INIT_POINTS_SIZE 128 -#define NVG_INIT_PATHS_SIZE 16 -#define NVG_INIT_VERTS_SIZE 256 -#define NVG_MAX_STATES 32 - -#define NVG_KAPPA90 0.5522847493f // Length proportional to radius of a cubic bezier handle for 90deg arcs. - -#define NVG_COUNTOF(arr) (sizeof(arr) / sizeof(0[arr])) - - -enum NVGcommands { - NVG_MOVETO = 0, - NVG_LINETO = 1, - NVG_BEZIERTO = 2, - NVG_CLOSE = 3, - NVG_WINDING = 4, -}; - -enum NVGpointFlags -{ - NVG_PT_CORNER = 0x01, - NVG_PT_LEFT = 0x02, - NVG_PT_BEVEL = 0x04, - NVG_PR_INNERBEVEL = 0x08, -}; - -struct NVGstate { - NVGcompositeOperationState compositeOperation; - NVGpaint fill; - NVGpaint stroke; - float strokeWidth; - float miterLimit; - int lineJoin; - int lineCap; - float alpha; - float xform[6]; - NVGscissor scissor; - float fontSize; - float letterSpacing; - float lineHeight; - float fontBlur; - int textAlign; - int fontId; -}; -typedef struct NVGstate NVGstate; - -struct NVGpoint { - float x,y; - float dx, dy; - float len; - float dmx, dmy; - unsigned char flags; -}; -typedef struct NVGpoint NVGpoint; - -struct NVGpathCache { - NVGpoint* points; - int npoints; - int cpoints; - NVGpath* paths; - int npaths; - int cpaths; - NVGvertex* verts; - int nverts; - int cverts; - float bounds[4]; -}; -typedef struct NVGpathCache NVGpathCache; - -struct NVGcontext { - NVGparams params; - float* commands; - int ccommands; - int ncommands; - float commandx, commandy; - NVGstate states[NVG_MAX_STATES]; - int nstates; - NVGpathCache* cache; - float tessTol; - float distTol; - float fringeWidth; - float devicePxRatio; - struct FONScontext* fs; - int fontImages[NVG_MAX_FONTIMAGES]; - int fontImageIdx; - int drawCallCount; - int fillTriCount; - int strokeTriCount; - int textTriCount; -}; - -static float nvg__sqrtf(float a) { return sqrtf(a); } -static float nvg__modf(float a, float b) { return fmodf(a, b); } -static float nvg__sinf(float a) { return sinf(a); } -static float nvg__cosf(float a) { return cosf(a); } -static float nvg__tanf(float a) { return tanf(a); } -static float nvg__atan2f(float a,float b) { return atan2f(a, b); } -static float nvg__acosf(float a) { return acosf(a); } - -static int nvg__mini(int a, int b) { return a < b ? a : b; } -static int nvg__maxi(int a, int b) { return a > b ? a : b; } -static int nvg__clampi(int a, int mn, int mx) { return a < mn ? mn : (a > mx ? mx : a); } -static float nvg__minf(float a, float b) { return a < b ? a : b; } -static float nvg__maxf(float a, float b) { return a > b ? a : b; } -static float nvg__absf(float a) { return a >= 0.0f ? a : -a; } -static float nvg__signf(float a) { return a >= 0.0f ? 1.0f : -1.0f; } -static float nvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); } -static float nvg__cross(float dx0, float dy0, float dx1, float dy1) { return dx1*dy0 - dx0*dy1; } - -static float nvg__normalize(float *x, float* y) -{ - float d = nvg__sqrtf((*x)*(*x) + (*y)*(*y)); - if (d > 1e-6f) { - float id = 1.0f / d; - *x *= id; - *y *= id; - } - return d; -} - - -static void nvg__deletePathCache(NVGpathCache* c) -{ - if (c == NULL) return; - if (c->points != NULL) free(c->points); - if (c->paths != NULL) free(c->paths); - if (c->verts != NULL) free(c->verts); - free(c); -} - -static NVGpathCache* nvg__allocPathCache(void) -{ - NVGpathCache* c = (NVGpathCache*)malloc(sizeof(NVGpathCache)); - if (c == NULL) goto error; - memset(c, 0, sizeof(NVGpathCache)); - - c->points = (NVGpoint*)malloc(sizeof(NVGpoint)*NVG_INIT_POINTS_SIZE); - if (!c->points) goto error; - c->npoints = 0; - c->cpoints = NVG_INIT_POINTS_SIZE; - - c->paths = (NVGpath*)malloc(sizeof(NVGpath)*NVG_INIT_PATHS_SIZE); - if (!c->paths) goto error; - c->npaths = 0; - c->cpaths = NVG_INIT_PATHS_SIZE; - - c->verts = (NVGvertex*)malloc(sizeof(NVGvertex)*NVG_INIT_VERTS_SIZE); - if (!c->verts) goto error; - c->nverts = 0; - c->cverts = NVG_INIT_VERTS_SIZE; - - return c; -error: - nvg__deletePathCache(c); - return NULL; -} - -static void nvg__setDevicePixelRatio(NVGcontext* ctx, float ratio) -{ - ctx->tessTol = 0.25f / ratio; - ctx->distTol = 0.01f / ratio; - ctx->fringeWidth = 1.0f / ratio; - ctx->devicePxRatio = ratio; -} - -static NVGcompositeOperationState nvg__compositeOperationState(int op) -{ - int sfactor, dfactor; - - if (op == NVG_SOURCE_OVER) - { - sfactor = NVG_ONE; - dfactor = NVG_ONE_MINUS_SRC_ALPHA; - } - else if (op == NVG_SOURCE_IN) - { - sfactor = NVG_DST_ALPHA; - dfactor = NVG_ZERO; - } - else if (op == NVG_SOURCE_OUT) - { - sfactor = NVG_ONE_MINUS_DST_ALPHA; - dfactor = NVG_ZERO; - } - else if (op == NVG_ATOP) - { - sfactor = NVG_DST_ALPHA; - dfactor = NVG_ONE_MINUS_SRC_ALPHA; - } - else if (op == NVG_DESTINATION_OVER) - { - sfactor = NVG_ONE_MINUS_DST_ALPHA; - dfactor = NVG_ONE; - } - else if (op == NVG_DESTINATION_IN) - { - sfactor = NVG_ZERO; - dfactor = NVG_SRC_ALPHA; - } - else if (op == NVG_DESTINATION_OUT) - { - sfactor = NVG_ZERO; - dfactor = NVG_ONE_MINUS_SRC_ALPHA; - } - else if (op == NVG_DESTINATION_ATOP) - { - sfactor = NVG_ONE_MINUS_DST_ALPHA; - dfactor = NVG_SRC_ALPHA; - } - else if (op == NVG_LIGHTER) - { - sfactor = NVG_ONE; - dfactor = NVG_ONE; - } - else if (op == NVG_COPY) - { - sfactor = NVG_ONE; - dfactor = NVG_ZERO; - } - else if (op == NVG_XOR) - { - sfactor = NVG_ONE_MINUS_DST_ALPHA; - dfactor = NVG_ONE_MINUS_SRC_ALPHA; - } - - NVGcompositeOperationState state; - state.srcRGB = sfactor; - state.dstRGB = dfactor; - state.srcAlpha = sfactor; - state.dstAlpha = dfactor; - return state; -} - -static NVGstate* nvg__getState(NVGcontext* ctx) -{ - return &ctx->states[ctx->nstates-1]; -} - -NVGcontext* nvgCreateInternal(NVGparams* params) -{ - FONSparams fontParams; - NVGcontext* ctx = (NVGcontext*)malloc(sizeof(NVGcontext)); - int i; - if (ctx == NULL) goto error; - memset(ctx, 0, sizeof(NVGcontext)); - - ctx->params = *params; - for (i = 0; i < NVG_MAX_FONTIMAGES; i++) - ctx->fontImages[i] = 0; - - ctx->commands = (float*)malloc(sizeof(float)*NVG_INIT_COMMANDS_SIZE); - if (!ctx->commands) goto error; - ctx->ncommands = 0; - ctx->ccommands = NVG_INIT_COMMANDS_SIZE; - - ctx->cache = nvg__allocPathCache(); - if (ctx->cache == NULL) goto error; - - nvgSave(ctx); - nvgReset(ctx); - - nvg__setDevicePixelRatio(ctx, 1.0f); - - if (ctx->params.renderCreate(ctx->params.userPtr) == 0) goto error; - - // Init font rendering - memset(&fontParams, 0, sizeof(fontParams)); - fontParams.width = NVG_INIT_FONTIMAGE_SIZE; - fontParams.height = NVG_INIT_FONTIMAGE_SIZE; - fontParams.flags = FONS_ZERO_TOPLEFT; - fontParams.renderCreate = NULL; - fontParams.renderUpdate = NULL; - fontParams.renderDraw = NULL; - fontParams.renderDelete = NULL; - fontParams.userPtr = NULL; - ctx->fs = fonsCreateInternal(&fontParams); - if (ctx->fs == NULL) goto error; - - // Create font texture - ctx->fontImages[0] = ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_ALPHA, fontParams.width, fontParams.height, 0, NULL); - if (ctx->fontImages[0] == 0) goto error; - ctx->fontImageIdx = 0; - - return ctx; - -error: - nvgDeleteInternal(ctx); - return 0; -} - -NVGparams* nvgInternalParams(NVGcontext* ctx) -{ - return &ctx->params; -} - -void nvgDeleteInternal(NVGcontext* ctx) -{ - int i; - if (ctx == NULL) return; - if (ctx->commands != NULL) free(ctx->commands); - if (ctx->cache != NULL) nvg__deletePathCache(ctx->cache); - - if (ctx->fs) - fonsDeleteInternal(ctx->fs); - - for (i = 0; i < NVG_MAX_FONTIMAGES; i++) { - if (ctx->fontImages[i] != 0) { - nvgDeleteImage(ctx, ctx->fontImages[i]); - ctx->fontImages[i] = 0; - } - } - - if (ctx->params.renderDelete != NULL) - ctx->params.renderDelete(ctx->params.userPtr); - - free(ctx); -} - -void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio) -{ -/* printf("Tris: draws:%d fill:%d stroke:%d text:%d TOT:%d\n", - ctx->drawCallCount, ctx->fillTriCount, ctx->strokeTriCount, ctx->textTriCount, - ctx->fillTriCount+ctx->strokeTriCount+ctx->textTriCount);*/ - - ctx->nstates = 0; - nvgSave(ctx); - nvgReset(ctx); - - nvg__setDevicePixelRatio(ctx, devicePixelRatio); - - ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight, devicePixelRatio); - - ctx->drawCallCount = 0; - ctx->fillTriCount = 0; - ctx->strokeTriCount = 0; - ctx->textTriCount = 0; -} - -void nvgCancelFrame(NVGcontext* ctx) -{ - ctx->params.renderCancel(ctx->params.userPtr); -} - -void nvgEndFrame(NVGcontext* ctx) -{ - NVGstate* state = nvg__getState(ctx); - ctx->params.renderFlush(ctx->params.userPtr, state->compositeOperation); - if (ctx->fontImageIdx != 0) { - int fontImage = ctx->fontImages[ctx->fontImageIdx]; - int i, j, iw, ih; - // delete images that smaller than current one - if (fontImage == 0) - return; - nvgImageSize(ctx, fontImage, &iw, &ih); - for (i = j = 0; i < ctx->fontImageIdx; i++) { - if (ctx->fontImages[i] != 0) { - int nw, nh; - nvgImageSize(ctx, ctx->fontImages[i], &nw, &nh); - if (nw < iw || nh < ih) - nvgDeleteImage(ctx, ctx->fontImages[i]); - else - ctx->fontImages[j++] = ctx->fontImages[i]; - } - } - // make current font image to first - ctx->fontImages[j++] = ctx->fontImages[0]; - ctx->fontImages[0] = fontImage; - ctx->fontImageIdx = 0; - // clear all images after j - for (i = j; i < NVG_MAX_FONTIMAGES; i++) - ctx->fontImages[i] = 0; - } -} - -NVGcolor nvgRGB(unsigned char r, unsigned char g, unsigned char b) -{ - return nvgRGBA(r,g,b,255); -} - -NVGcolor nvgRGBf(float r, float g, float b) -{ - return nvgRGBAf(r,g,b,1.0f); -} - -NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) -{ - NVGcolor color; - // Use longer initialization to suppress warning. - color.r = r / 255.0f; - color.g = g / 255.0f; - color.b = b / 255.0f; - color.a = a / 255.0f; - return color; -} - -NVGcolor nvgRGBAf(float r, float g, float b, float a) -{ - NVGcolor color; - // Use longer initialization to suppress warning. - color.r = r; - color.g = g; - color.b = b; - color.a = a; - return color; -} - -NVGcolor nvgTransRGBA(NVGcolor c, unsigned char a) -{ - c.a = a / 255.0f; - return c; -} - -NVGcolor nvgTransRGBAf(NVGcolor c, float a) -{ - c.a = a; - return c; -} - -NVGcolor nvgLerpRGBA(NVGcolor c0, NVGcolor c1, float u) -{ - int i; - float oneminu; - NVGcolor cint = {0}; - - u = nvg__clampf(u, 0.0f, 1.0f); - oneminu = 1.0f - u; - for( i = 0; i <4; i++ ) - { - cint.rgba[i] = c0.rgba[i] * oneminu + c1.rgba[i] * u; - } - - return cint; -} - -NVGcolor nvgHSL(float h, float s, float l) -{ - return nvgHSLA(h,s,l,255); -} - -static float nvg__hue(float h, float m1, float m2) -{ - if (h < 0) h += 1; - if (h > 1) h -= 1; - if (h < 1.0f/6.0f) - return m1 + (m2 - m1) * h * 6.0f; - else if (h < 3.0f/6.0f) - return m2; - else if (h < 4.0f/6.0f) - return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f; - return m1; -} - -NVGcolor nvgHSLA(float h, float s, float l, unsigned char a) -{ - float m1, m2; - NVGcolor col; - h = nvg__modf(h, 1.0f); - if (h < 0.0f) h += 1.0f; - s = nvg__clampf(s, 0.0f, 1.0f); - l = nvg__clampf(l, 0.0f, 1.0f); - m2 = l <= 0.5f ? (l * (1 + s)) : (l + s - l * s); - m1 = 2 * l - m2; - col.r = nvg__clampf(nvg__hue(h + 1.0f/3.0f, m1, m2), 0.0f, 1.0f); - col.g = nvg__clampf(nvg__hue(h, m1, m2), 0.0f, 1.0f); - col.b = nvg__clampf(nvg__hue(h - 1.0f/3.0f, m1, m2), 0.0f, 1.0f); - col.a = a/255.0f; - return col; -} - -void nvgTransformIdentity(float* t) -{ - t[0] = 1.0f; t[1] = 0.0f; - t[2] = 0.0f; t[3] = 1.0f; - t[4] = 0.0f; t[5] = 0.0f; -} - -void nvgTransformTranslate(float* t, float tx, float ty) -{ - t[0] = 1.0f; t[1] = 0.0f; - t[2] = 0.0f; t[3] = 1.0f; - t[4] = tx; t[5] = ty; -} - -void nvgTransformScale(float* t, float sx, float sy) -{ - t[0] = sx; t[1] = 0.0f; - t[2] = 0.0f; t[3] = sy; - t[4] = 0.0f; t[5] = 0.0f; -} - -void nvgTransformRotate(float* t, float a) -{ - float cs = nvg__cosf(a), sn = nvg__sinf(a); - t[0] = cs; t[1] = sn; - t[2] = -sn; t[3] = cs; - t[4] = 0.0f; t[5] = 0.0f; -} - -void nvgTransformSkewX(float* t, float a) -{ - t[0] = 1.0f; t[1] = 0.0f; - t[2] = nvg__tanf(a); t[3] = 1.0f; - t[4] = 0.0f; t[5] = 0.0f; -} - -void nvgTransformSkewY(float* t, float a) -{ - t[0] = 1.0f; t[1] = nvg__tanf(a); - t[2] = 0.0f; t[3] = 1.0f; - t[4] = 0.0f; t[5] = 0.0f; -} - -void nvgTransformMultiply(float* t, const float* s) -{ - float t0 = t[0] * s[0] + t[1] * s[2]; - float t2 = t[2] * s[0] + t[3] * s[2]; - float t4 = t[4] * s[0] + t[5] * s[2] + s[4]; - t[1] = t[0] * s[1] + t[1] * s[3]; - t[3] = t[2] * s[1] + t[3] * s[3]; - t[5] = t[4] * s[1] + t[5] * s[3] + s[5]; - t[0] = t0; - t[2] = t2; - t[4] = t4; -} - -void nvgTransformPremultiply(float* t, const float* s) -{ - float s2[6]; - memcpy(s2, s, sizeof(float)*6); - nvgTransformMultiply(s2, t); - memcpy(t, s2, sizeof(float)*6); -} - -int nvgTransformInverse(float* inv, const float* t) -{ - double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1]; - if (det > -1e-6 && det < 1e-6) { - nvgTransformIdentity(inv); - return 0; - } - invdet = 1.0 / det; - inv[0] = (float)(t[3] * invdet); - inv[2] = (float)(-t[2] * invdet); - inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet); - inv[1] = (float)(-t[1] * invdet); - inv[3] = (float)(t[0] * invdet); - inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet); - return 1; -} - -void nvgTransformPoint(float* dx, float* dy, const float* t, float sx, float sy) -{ - *dx = sx*t[0] + sy*t[2] + t[4]; - *dy = sx*t[1] + sy*t[3] + t[5]; -} - -float nvgDegToRad(float deg) -{ - return deg / 180.0f * NVG_PI; -} - -float nvgRadToDeg(float rad) -{ - return rad / NVG_PI * 180.0f; -} - -static void nvg__setPaintColor(NVGpaint* p, NVGcolor color) -{ - memset(p, 0, sizeof(*p)); - nvgTransformIdentity(p->xform); - p->radius = 0.0f; - p->feather = 1.0f; - p->innerColor = color; - p->outerColor = color; -} - - -// State handling -void nvgSave(NVGcontext* ctx) -{ - if (ctx->nstates >= NVG_MAX_STATES) - return; - if (ctx->nstates > 0) - memcpy(&ctx->states[ctx->nstates], &ctx->states[ctx->nstates-1], sizeof(NVGstate)); - ctx->nstates++; -} - -void nvgRestore(NVGcontext* ctx) -{ - if (ctx->nstates <= 1) - return; - ctx->nstates--; -} - -void nvgReset(NVGcontext* ctx) -{ - NVGstate* state = nvg__getState(ctx); - memset(state, 0, sizeof(*state)); - - nvg__setPaintColor(&state->fill, nvgRGBA(255,255,255,255)); - nvg__setPaintColor(&state->stroke, nvgRGBA(0,0,0,255)); - state->compositeOperation = nvg__compositeOperationState(NVG_SOURCE_OVER); - state->strokeWidth = 1.0f; - state->miterLimit = 10.0f; - state->lineCap = NVG_BUTT; - state->lineJoin = NVG_MITER; - state->alpha = 1.0f; - nvgTransformIdentity(state->xform); - - state->scissor.extent[0] = -1.0f; - state->scissor.extent[1] = -1.0f; - - state->fontSize = 16.0f; - state->letterSpacing = 0.0f; - state->lineHeight = 1.0f; - state->fontBlur = 0.0f; - state->textAlign = NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE; - state->fontId = 0; -} - -// State setting -void nvgStrokeWidth(NVGcontext* ctx, float width) -{ - NVGstate* state = nvg__getState(ctx); - state->strokeWidth = width; -} - -void nvgMiterLimit(NVGcontext* ctx, float limit) -{ - NVGstate* state = nvg__getState(ctx); - state->miterLimit = limit; -} - -void nvgLineCap(NVGcontext* ctx, int cap) -{ - NVGstate* state = nvg__getState(ctx); - state->lineCap = cap; -} - -void nvgLineJoin(NVGcontext* ctx, int join) -{ - NVGstate* state = nvg__getState(ctx); - state->lineJoin = join; -} - -void nvgGlobalAlpha(NVGcontext* ctx, float alpha) -{ - NVGstate* state = nvg__getState(ctx); - state->alpha = alpha; -} - -void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e, float f) -{ - NVGstate* state = nvg__getState(ctx); - float t[6] = { a, b, c, d, e, f }; - nvgTransformPremultiply(state->xform, t); -} - -void nvgResetTransform(NVGcontext* ctx) -{ - NVGstate* state = nvg__getState(ctx); - nvgTransformIdentity(state->xform); -} - -void nvgTranslate(NVGcontext* ctx, float x, float y) -{ - NVGstate* state = nvg__getState(ctx); - float t[6]; - nvgTransformTranslate(t, x,y); - nvgTransformPremultiply(state->xform, t); -} - -void nvgRotate(NVGcontext* ctx, float angle) -{ - NVGstate* state = nvg__getState(ctx); - float t[6]; - nvgTransformRotate(t, angle); - nvgTransformPremultiply(state->xform, t); -} - -void nvgSkewX(NVGcontext* ctx, float angle) -{ - NVGstate* state = nvg__getState(ctx); - float t[6]; - nvgTransformSkewX(t, angle); - nvgTransformPremultiply(state->xform, t); -} - -void nvgSkewY(NVGcontext* ctx, float angle) -{ - NVGstate* state = nvg__getState(ctx); - float t[6]; - nvgTransformSkewY(t, angle); - nvgTransformPremultiply(state->xform, t); -} - -void nvgScale(NVGcontext* ctx, float x, float y) -{ - NVGstate* state = nvg__getState(ctx); - float t[6]; - nvgTransformScale(t, x,y); - nvgTransformPremultiply(state->xform, t); -} - -void nvgCurrentTransform(NVGcontext* ctx, float* xform) -{ - NVGstate* state = nvg__getState(ctx); - if (xform == NULL) return; - memcpy(xform, state->xform, sizeof(float)*6); -} - -void nvgStrokeColor(NVGcontext* ctx, NVGcolor color) -{ - NVGstate* state = nvg__getState(ctx); - nvg__setPaintColor(&state->stroke, color); -} - -void nvgStrokePaint(NVGcontext* ctx, NVGpaint paint) -{ - NVGstate* state = nvg__getState(ctx); - state->stroke = paint; - nvgTransformMultiply(state->stroke.xform, state->xform); -} - -void nvgFillColor(NVGcontext* ctx, NVGcolor color) -{ - NVGstate* state = nvg__getState(ctx); - nvg__setPaintColor(&state->fill, color); -} - -void nvgFillPaint(NVGcontext* ctx, NVGpaint paint) -{ - NVGstate* state = nvg__getState(ctx); - state->fill = paint; - nvgTransformMultiply(state->fill.xform, state->xform); -} - -int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags) -{ - int w, h, n, image; - unsigned char* img; - stbi_set_unpremultiply_on_load(1); - stbi_convert_iphone_png_to_rgb(1); - img = stbi_load(filename, &w, &h, &n, 4); - if (img == NULL) { -// printf("Failed to load %s - %s\n", filename, stbi_failure_reason()); - return 0; - } - image = nvgCreateImageRGBA(ctx, w, h, imageFlags, img); - stbi_image_free(img); - return image; -} - -int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata) -{ - int w, h, n, image; - unsigned char* img = stbi_load_from_memory(data, ndata, &w, &h, &n, 4); - if (img == NULL) { -// printf("Failed to load %s - %s\n", filename, stbi_failure_reason()); - return 0; - } - image = nvgCreateImageRGBA(ctx, w, h, imageFlags, img); - stbi_image_free(img); - return image; -} - -int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data) -{ - return ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_RGBA, w, h, imageFlags, data); -} - -void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data) -{ - int w, h; - ctx->params.renderGetTextureSize(ctx->params.userPtr, image, &w, &h); - ctx->params.renderUpdateTexture(ctx->params.userPtr, image, 0,0, w,h, data); -} - -void nvgImageSize(NVGcontext* ctx, int image, int* w, int* h) -{ - ctx->params.renderGetTextureSize(ctx->params.userPtr, image, w, h); -} - -void nvgDeleteImage(NVGcontext* ctx, int image) -{ - ctx->params.renderDeleteTexture(ctx->params.userPtr, image); -} - -NVGpaint nvgLinearGradient(NVGcontext* ctx, - float sx, float sy, float ex, float ey, - NVGcolor icol, NVGcolor ocol) -{ - NVGpaint p; - float dx, dy, d; - const float large = 1e5; - NVG_NOTUSED(ctx); - memset(&p, 0, sizeof(p)); - - // Calculate transform aligned to the line - dx = ex - sx; - dy = ey - sy; - d = sqrtf(dx*dx + dy*dy); - if (d > 0.0001f) { - dx /= d; - dy /= d; - } else { - dx = 0; - dy = 1; - } - - p.xform[0] = dy; p.xform[1] = -dx; - p.xform[2] = dx; p.xform[3] = dy; - p.xform[4] = sx - dx*large; p.xform[5] = sy - dy*large; - - p.extent[0] = large; - p.extent[1] = large + d*0.5f; - - p.radius = 0.0f; - - p.feather = nvg__maxf(1.0f, d); - - p.innerColor = icol; - p.outerColor = ocol; - - return p; -} - -NVGpaint nvgRadialGradient(NVGcontext* ctx, - float cx, float cy, float inr, float outr, - NVGcolor icol, NVGcolor ocol) -{ - NVGpaint p; - float r = (inr+outr)*0.5f; - float f = (outr-inr); - NVG_NOTUSED(ctx); - memset(&p, 0, sizeof(p)); - - nvgTransformIdentity(p.xform); - p.xform[4] = cx; - p.xform[5] = cy; - - p.extent[0] = r; - p.extent[1] = r; - - p.radius = r; - - p.feather = nvg__maxf(1.0f, f); - - p.innerColor = icol; - p.outerColor = ocol; - - return p; -} - -NVGpaint nvgBoxGradient(NVGcontext* ctx, - float x, float y, float w, float h, float r, float f, - NVGcolor icol, NVGcolor ocol) -{ - NVGpaint p; - NVG_NOTUSED(ctx); - memset(&p, 0, sizeof(p)); - - nvgTransformIdentity(p.xform); - p.xform[4] = x+w*0.5f; - p.xform[5] = y+h*0.5f; - - p.extent[0] = w*0.5f; - p.extent[1] = h*0.5f; - - p.radius = r; - - p.feather = nvg__maxf(1.0f, f); - - p.innerColor = icol; - p.outerColor = ocol; - - return p; -} - - -NVGpaint nvgImagePattern(NVGcontext* ctx, - float cx, float cy, float w, float h, float angle, - int image, float alpha) -{ - NVGpaint p; - NVG_NOTUSED(ctx); - memset(&p, 0, sizeof(p)); - - nvgTransformRotate(p.xform, angle); - p.xform[4] = cx; - p.xform[5] = cy; - - p.extent[0] = w; - p.extent[1] = h; - - p.image = image; - - p.innerColor = p.outerColor = nvgRGBAf(1,1,1,alpha); - - return p; -} - -// Scissoring -void nvgScissor(NVGcontext* ctx, float x, float y, float w, float h) -{ - NVGstate* state = nvg__getState(ctx); - - w = nvg__maxf(0.0f, w); - h = nvg__maxf(0.0f, h); - - nvgTransformIdentity(state->scissor.xform); - state->scissor.xform[4] = x+w*0.5f; - state->scissor.xform[5] = y+h*0.5f; - nvgTransformMultiply(state->scissor.xform, state->xform); - - state->scissor.extent[0] = w*0.5f; - state->scissor.extent[1] = h*0.5f; -} - -static void nvg__isectRects(float* dst, - float ax, float ay, float aw, float ah, - float bx, float by, float bw, float bh) -{ - float minx = nvg__maxf(ax, bx); - float miny = nvg__maxf(ay, by); - float maxx = nvg__minf(ax+aw, bx+bw); - float maxy = nvg__minf(ay+ah, by+bh); - dst[0] = minx; - dst[1] = miny; - dst[2] = nvg__maxf(0.0f, maxx - minx); - dst[3] = nvg__maxf(0.0f, maxy - miny); -} - -void nvgIntersectScissor(NVGcontext* ctx, float x, float y, float w, float h) -{ - NVGstate* state = nvg__getState(ctx); - float pxform[6], invxorm[6]; - float rect[4]; - float ex, ey, tex, tey; - - // If no previous scissor has been set, set the scissor as current scissor. - if (state->scissor.extent[0] < 0) { - nvgScissor(ctx, x, y, w, h); - return; - } - - // Transform the current scissor rect into current transform space. - // If there is difference in rotation, this will be approximation. - memcpy(pxform, state->scissor.xform, sizeof(float)*6); - ex = state->scissor.extent[0]; - ey = state->scissor.extent[1]; - nvgTransformInverse(invxorm, state->xform); - nvgTransformMultiply(pxform, invxorm); - tex = ex*nvg__absf(pxform[0]) + ey*nvg__absf(pxform[2]); - tey = ex*nvg__absf(pxform[1]) + ey*nvg__absf(pxform[3]); - - // Intersect rects. - nvg__isectRects(rect, pxform[4]-tex,pxform[5]-tey,tex*2,tey*2, x,y,w,h); - - nvgScissor(ctx, rect[0], rect[1], rect[2], rect[3]); -} - -void nvgResetScissor(NVGcontext* ctx) -{ - NVGstate* state = nvg__getState(ctx); - memset(state->scissor.xform, 0, sizeof(state->scissor.xform)); - state->scissor.extent[0] = -1.0f; - state->scissor.extent[1] = -1.0f; -} - -// Global composite operation. -void nvgGlobalCompositeOperation(NVGcontext* ctx, int op) -{ - NVGstate* state = nvg__getState(ctx); - state->compositeOperation = nvg__compositeOperationState(op); -} - -void nvgGlobalCompositeBlendFunc(NVGcontext* ctx, int sfactor, int dfactor) -{ - nvgGlobalCompositeBlendFuncSeparate(ctx, sfactor, dfactor, sfactor, dfactor); -} - -void nvgGlobalCompositeBlendFuncSeparate(NVGcontext* ctx, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) -{ - NVGcompositeOperationState op; - op.srcRGB = srcRGB; - op.dstRGB = dstRGB; - op.srcAlpha = srcAlpha; - op.dstAlpha = dstAlpha; - - NVGstate* state = nvg__getState(ctx); - state->compositeOperation = op; -} - -static int nvg__ptEquals(float x1, float y1, float x2, float y2, float tol) -{ - float dx = x2 - x1; - float dy = y2 - y1; - return dx*dx + dy*dy < tol*tol; -} - -static float nvg__distPtSeg(float x, float y, float px, float py, float qx, float qy) -{ - float pqx, pqy, dx, dy, d, t; - pqx = qx-px; - pqy = qy-py; - dx = x-px; - dy = y-py; - d = pqx*pqx + pqy*pqy; - t = pqx*dx + pqy*dy; - if (d > 0) t /= d; - if (t < 0) t = 0; - else if (t > 1) t = 1; - dx = px + t*pqx - x; - dy = py + t*pqy - y; - return dx*dx + dy*dy; -} - -static void nvg__appendCommands(NVGcontext* ctx, float* vals, int nvals) -{ - NVGstate* state = nvg__getState(ctx); - int i; - - if (ctx->ncommands+nvals > ctx->ccommands) { - float* commands; - int ccommands = ctx->ncommands+nvals + ctx->ccommands/2; - commands = (float*)realloc(ctx->commands, sizeof(float)*ccommands); - if (commands == NULL) return; - ctx->commands = commands; - ctx->ccommands = ccommands; - } - - if ((int)vals[0] != NVG_CLOSE && (int)vals[0] != NVG_WINDING) { - ctx->commandx = vals[nvals-2]; - ctx->commandy = vals[nvals-1]; - } - - // transform commands - i = 0; - while (i < nvals) { - int cmd = (int)vals[i]; - switch (cmd) { - case NVG_MOVETO: - nvgTransformPoint(&vals[i+1],&vals[i+2], state->xform, vals[i+1],vals[i+2]); - i += 3; - break; - case NVG_LINETO: - nvgTransformPoint(&vals[i+1],&vals[i+2], state->xform, vals[i+1],vals[i+2]); - i += 3; - break; - case NVG_BEZIERTO: - nvgTransformPoint(&vals[i+1],&vals[i+2], state->xform, vals[i+1],vals[i+2]); - nvgTransformPoint(&vals[i+3],&vals[i+4], state->xform, vals[i+3],vals[i+4]); - nvgTransformPoint(&vals[i+5],&vals[i+6], state->xform, vals[i+5],vals[i+6]); - i += 7; - break; - case NVG_CLOSE: - i++; - break; - case NVG_WINDING: - i += 2; - break; - default: - i++; - } - } - - memcpy(&ctx->commands[ctx->ncommands], vals, nvals*sizeof(float)); - - ctx->ncommands += nvals; -} - - -static void nvg__clearPathCache(NVGcontext* ctx) -{ - ctx->cache->npoints = 0; - ctx->cache->npaths = 0; -} - -static NVGpath* nvg__lastPath(NVGcontext* ctx) -{ - if (ctx->cache->npaths > 0) - return &ctx->cache->paths[ctx->cache->npaths-1]; - return NULL; -} - -static void nvg__addPath(NVGcontext* ctx) -{ - NVGpath* path; - if (ctx->cache->npaths+1 > ctx->cache->cpaths) { - NVGpath* paths; - int cpaths = ctx->cache->npaths+1 + ctx->cache->cpaths/2; - paths = (NVGpath*)realloc(ctx->cache->paths, sizeof(NVGpath)*cpaths); - if (paths == NULL) return; - ctx->cache->paths = paths; - ctx->cache->cpaths = cpaths; - } - path = &ctx->cache->paths[ctx->cache->npaths]; - memset(path, 0, sizeof(*path)); - path->first = ctx->cache->npoints; - path->winding = NVG_CCW; - - ctx->cache->npaths++; -} - -static NVGpoint* nvg__lastPoint(NVGcontext* ctx) -{ - if (ctx->cache->npoints > 0) - return &ctx->cache->points[ctx->cache->npoints-1]; - return NULL; -} - -static void nvg__addPoint(NVGcontext* ctx, float x, float y, int flags) -{ - NVGpath* path = nvg__lastPath(ctx); - NVGpoint* pt; - if (path == NULL) return; - - if (path->count > 0 && ctx->cache->npoints > 0) { - pt = nvg__lastPoint(ctx); - if (nvg__ptEquals(pt->x,pt->y, x,y, ctx->distTol)) { - pt->flags |= flags; - return; - } - } - - if (ctx->cache->npoints+1 > ctx->cache->cpoints) { - NVGpoint* points; - int cpoints = ctx->cache->npoints+1 + ctx->cache->cpoints/2; - points = (NVGpoint*)realloc(ctx->cache->points, sizeof(NVGpoint)*cpoints); - if (points == NULL) return; - ctx->cache->points = points; - ctx->cache->cpoints = cpoints; - } - - pt = &ctx->cache->points[ctx->cache->npoints]; - memset(pt, 0, sizeof(*pt)); - pt->x = x; - pt->y = y; - pt->flags = (unsigned char)flags; - - ctx->cache->npoints++; - path->count++; -} - -static void nvg__closePath(NVGcontext* ctx) -{ - NVGpath* path = nvg__lastPath(ctx); - if (path == NULL) return; - path->closed = 1; -} - -static void nvg__pathWinding(NVGcontext* ctx, int winding) -{ - NVGpath* path = nvg__lastPath(ctx); - if (path == NULL) return; - path->winding = winding; -} - -static float nvg__getAverageScale(float *t) -{ - float sx = sqrtf(t[0]*t[0] + t[2]*t[2]); - float sy = sqrtf(t[1]*t[1] + t[3]*t[3]); - return (sx + sy) * 0.5f; -} - -static NVGvertex* nvg__allocTempVerts(NVGcontext* ctx, int nverts) -{ - if (nverts > ctx->cache->cverts) { - NVGvertex* verts; - int cverts = (nverts + 0xff) & ~0xff; // Round up to prevent allocations when things change just slightly. - verts = (NVGvertex*)realloc(ctx->cache->verts, sizeof(NVGvertex)*cverts); - if (verts == NULL) return NULL; - ctx->cache->verts = verts; - ctx->cache->cverts = cverts; - } - - return ctx->cache->verts; -} - -static float nvg__triarea2(float ax, float ay, float bx, float by, float cx, float cy) -{ - float abx = bx - ax; - float aby = by - ay; - float acx = cx - ax; - float acy = cy - ay; - return acx*aby - abx*acy; -} - -static float nvg__polyArea(NVGpoint* pts, int npts) -{ - int i; - float area = 0; - for (i = 2; i < npts; i++) { - NVGpoint* a = &pts[0]; - NVGpoint* b = &pts[i-1]; - NVGpoint* c = &pts[i]; - area += nvg__triarea2(a->x,a->y, b->x,b->y, c->x,c->y); - } - return area * 0.5f; -} - -static void nvg__polyReverse(NVGpoint* pts, int npts) -{ - NVGpoint tmp; - int i = 0, j = npts-1; - while (i < j) { - tmp = pts[i]; - pts[i] = pts[j]; - pts[j] = tmp; - i++; - j--; - } -} - - -static void nvg__vset(NVGvertex* vtx, float x, float y, float u, float v) -{ - vtx->x = x; - vtx->y = y; - vtx->u = u; - vtx->v = v; -} - -static void nvg__tesselateBezier(NVGcontext* ctx, - float x1, float y1, float x2, float y2, - float x3, float y3, float x4, float y4, - int level, int type) -{ - float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234; - float dx,dy,d2,d3; - - if (level > 10) return; - - x12 = (x1+x2)*0.5f; - y12 = (y1+y2)*0.5f; - x23 = (x2+x3)*0.5f; - y23 = (y2+y3)*0.5f; - x34 = (x3+x4)*0.5f; - y34 = (y3+y4)*0.5f; - x123 = (x12+x23)*0.5f; - y123 = (y12+y23)*0.5f; - - dx = x4 - x1; - dy = y4 - y1; - d2 = nvg__absf(((x2 - x4) * dy - (y2 - y4) * dx)); - d3 = nvg__absf(((x3 - x4) * dy - (y3 - y4) * dx)); - - if ((d2 + d3)*(d2 + d3) < ctx->tessTol * (dx*dx + dy*dy)) { - nvg__addPoint(ctx, x4, y4, type); - return; - } - -/* if (nvg__absf(x1+x3-x2-x2) + nvg__absf(y1+y3-y2-y2) + nvg__absf(x2+x4-x3-x3) + nvg__absf(y2+y4-y3-y3) < ctx->tessTol) { - nvg__addPoint(ctx, x4, y4, type); - return; - }*/ - - x234 = (x23+x34)*0.5f; - y234 = (y23+y34)*0.5f; - x1234 = (x123+x234)*0.5f; - y1234 = (y123+y234)*0.5f; - - nvg__tesselateBezier(ctx, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0); - nvg__tesselateBezier(ctx, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type); -} - -static void nvg__flattenPaths(NVGcontext* ctx) -{ - NVGpathCache* cache = ctx->cache; -// NVGstate* state = nvg__getState(ctx); - NVGpoint* last; - NVGpoint* p0; - NVGpoint* p1; - NVGpoint* pts; - NVGpath* path; - int i, j; - float* cp1; - float* cp2; - float* p; - float area; - - if (cache->npaths > 0) - return; - - // Flatten - i = 0; - while (i < ctx->ncommands) { - int cmd = (int)ctx->commands[i]; - switch (cmd) { - case NVG_MOVETO: - nvg__addPath(ctx); - p = &ctx->commands[i+1]; - nvg__addPoint(ctx, p[0], p[1], NVG_PT_CORNER); - i += 3; - break; - case NVG_LINETO: - p = &ctx->commands[i+1]; - nvg__addPoint(ctx, p[0], p[1], NVG_PT_CORNER); - i += 3; - break; - case NVG_BEZIERTO: - last = nvg__lastPoint(ctx); - if (last != NULL) { - cp1 = &ctx->commands[i+1]; - cp2 = &ctx->commands[i+3]; - p = &ctx->commands[i+5]; - nvg__tesselateBezier(ctx, last->x,last->y, cp1[0],cp1[1], cp2[0],cp2[1], p[0],p[1], 0, NVG_PT_CORNER); - } - i += 7; - break; - case NVG_CLOSE: - nvg__closePath(ctx); - i++; - break; - case NVG_WINDING: - nvg__pathWinding(ctx, (int)ctx->commands[i+1]); - i += 2; - break; - default: - i++; - } - } - - cache->bounds[0] = cache->bounds[1] = 1e6f; - cache->bounds[2] = cache->bounds[3] = -1e6f; - - // Calculate the direction and length of line segments. - for (j = 0; j < cache->npaths; j++) { - path = &cache->paths[j]; - pts = &cache->points[path->first]; - - // If the first and last points are the same, remove the last, mark as closed path. - p0 = &pts[path->count-1]; - p1 = &pts[0]; - if (nvg__ptEquals(p0->x,p0->y, p1->x,p1->y, ctx->distTol)) { - path->count--; - p0 = &pts[path->count-1]; - path->closed = 1; - } - - // Enforce winding. - if (path->count > 2) { - area = nvg__polyArea(pts, path->count); - if (path->winding == NVG_CCW && area < 0.0f) - nvg__polyReverse(pts, path->count); - if (path->winding == NVG_CW && area > 0.0f) - nvg__polyReverse(pts, path->count); - } - - for(i = 0; i < path->count; i++) { - // Calculate segment direction and length - p0->dx = p1->x - p0->x; - p0->dy = p1->y - p0->y; - p0->len = nvg__normalize(&p0->dx, &p0->dy); - // Update bounds - cache->bounds[0] = nvg__minf(cache->bounds[0], p0->x); - cache->bounds[1] = nvg__minf(cache->bounds[1], p0->y); - cache->bounds[2] = nvg__maxf(cache->bounds[2], p0->x); - cache->bounds[3] = nvg__maxf(cache->bounds[3], p0->y); - // Advance - p0 = p1++; - } - } -} - -static int nvg__curveDivs(float r, float arc, float tol) -{ - float da = acosf(r / (r + tol)) * 2.0f; - return nvg__maxi(2, (int)ceilf(arc / da)); -} - -static void nvg__chooseBevel(int bevel, NVGpoint* p0, NVGpoint* p1, float w, - float* x0, float* y0, float* x1, float* y1) -{ - if (bevel) { - *x0 = p1->x + p0->dy * w; - *y0 = p1->y - p0->dx * w; - *x1 = p1->x + p1->dy * w; - *y1 = p1->y - p1->dx * w; - } else { - *x0 = p1->x + p1->dmx * w; - *y0 = p1->y + p1->dmy * w; - *x1 = p1->x + p1->dmx * w; - *y1 = p1->y + p1->dmy * w; - } -} - -static NVGvertex* nvg__roundJoin(NVGvertex* dst, NVGpoint* p0, NVGpoint* p1, - float lw, float rw, float lu, float ru, int ncap, float fringe) -{ - int i, n; - float dlx0 = p0->dy; - float dly0 = -p0->dx; - float dlx1 = p1->dy; - float dly1 = -p1->dx; - NVG_NOTUSED(fringe); - - if (p1->flags & NVG_PT_LEFT) { - float lx0,ly0,lx1,ly1,a0,a1; - nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, lw, &lx0,&ly0, &lx1,&ly1); - a0 = atan2f(-dly0, -dlx0); - a1 = atan2f(-dly1, -dlx1); - if (a1 > a0) a1 -= NVG_PI*2; - - nvg__vset(dst, lx0, ly0, lu,1); dst++; - nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; - - n = nvg__clampi((int)ceilf(((a0 - a1) / NVG_PI) * ncap), 2, ncap); - for (i = 0; i < n; i++) { - float u = i/(float)(n-1); - float a = a0 + u*(a1-a0); - float rx = p1->x + cosf(a) * rw; - float ry = p1->y + sinf(a) * rw; - nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; - nvg__vset(dst, rx, ry, ru,1); dst++; - } - - nvg__vset(dst, lx1, ly1, lu,1); dst++; - nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; - - } else { - float rx0,ry0,rx1,ry1,a0,a1; - nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, -rw, &rx0,&ry0, &rx1,&ry1); - a0 = atan2f(dly0, dlx0); - a1 = atan2f(dly1, dlx1); - if (a1 < a0) a1 += NVG_PI*2; - - nvg__vset(dst, p1->x + dlx0*rw, p1->y + dly0*rw, lu,1); dst++; - nvg__vset(dst, rx0, ry0, ru,1); dst++; - - n = nvg__clampi((int)ceilf(((a1 - a0) / NVG_PI) * ncap), 2, ncap); - for (i = 0; i < n; i++) { - float u = i/(float)(n-1); - float a = a0 + u*(a1-a0); - float lx = p1->x + cosf(a) * lw; - float ly = p1->y + sinf(a) * lw; - nvg__vset(dst, lx, ly, lu,1); dst++; - nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; - } - - nvg__vset(dst, p1->x + dlx1*rw, p1->y + dly1*rw, lu,1); dst++; - nvg__vset(dst, rx1, ry1, ru,1); dst++; - - } - return dst; -} - -static NVGvertex* nvg__bevelJoin(NVGvertex* dst, NVGpoint* p0, NVGpoint* p1, - float lw, float rw, float lu, float ru, float fringe) -{ - float rx0,ry0,rx1,ry1; - float lx0,ly0,lx1,ly1; - float dlx0 = p0->dy; - float dly0 = -p0->dx; - float dlx1 = p1->dy; - float dly1 = -p1->dx; - NVG_NOTUSED(fringe); - - if (p1->flags & NVG_PT_LEFT) { - nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, lw, &lx0,&ly0, &lx1,&ly1); - - nvg__vset(dst, lx0, ly0, lu,1); dst++; - nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; - - if (p1->flags & NVG_PT_BEVEL) { - nvg__vset(dst, lx0, ly0, lu,1); dst++; - nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; - - nvg__vset(dst, lx1, ly1, lu,1); dst++; - nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; - } else { - rx0 = p1->x - p1->dmx * rw; - ry0 = p1->y - p1->dmy * rw; - - nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; - nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; - - nvg__vset(dst, rx0, ry0, ru,1); dst++; - nvg__vset(dst, rx0, ry0, ru,1); dst++; - - nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; - nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; - } - - nvg__vset(dst, lx1, ly1, lu,1); dst++; - nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; - - } else { - nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, -rw, &rx0,&ry0, &rx1,&ry1); - - nvg__vset(dst, p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); dst++; - nvg__vset(dst, rx0, ry0, ru,1); dst++; - - if (p1->flags & NVG_PT_BEVEL) { - nvg__vset(dst, p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); dst++; - nvg__vset(dst, rx0, ry0, ru,1); dst++; - - nvg__vset(dst, p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); dst++; - nvg__vset(dst, rx1, ry1, ru,1); dst++; - } else { - lx0 = p1->x + p1->dmx * lw; - ly0 = p1->y + p1->dmy * lw; - - nvg__vset(dst, p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); dst++; - nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; - - nvg__vset(dst, lx0, ly0, lu,1); dst++; - nvg__vset(dst, lx0, ly0, lu,1); dst++; - - nvg__vset(dst, p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); dst++; - nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; - } - - nvg__vset(dst, p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); dst++; - nvg__vset(dst, rx1, ry1, ru,1); dst++; - } - - return dst; -} - -static NVGvertex* nvg__buttCapStart(NVGvertex* dst, NVGpoint* p, - float dx, float dy, float w, float d, float aa) -{ - float px = p->x - dx*d; - float py = p->y - dy*d; - float dlx = dy; - float dly = -dx; - nvg__vset(dst, px + dlx*w - dx*aa, py + dly*w - dy*aa, 0,0); dst++; - nvg__vset(dst, px - dlx*w - dx*aa, py - dly*w - dy*aa, 1,0); dst++; - nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; - nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; - return dst; -} - -static NVGvertex* nvg__buttCapEnd(NVGvertex* dst, NVGpoint* p, - float dx, float dy, float w, float d, float aa) -{ - float px = p->x + dx*d; - float py = p->y + dy*d; - float dlx = dy; - float dly = -dx; - nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; - nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; - nvg__vset(dst, px + dlx*w + dx*aa, py + dly*w + dy*aa, 0,0); dst++; - nvg__vset(dst, px - dlx*w + dx*aa, py - dly*w + dy*aa, 1,0); dst++; - return dst; -} - - -static NVGvertex* nvg__roundCapStart(NVGvertex* dst, NVGpoint* p, - float dx, float dy, float w, int ncap, float aa) -{ - int i; - float px = p->x; - float py = p->y; - float dlx = dy; - float dly = -dx; - NVG_NOTUSED(aa); - for (i = 0; i < ncap; i++) { - float a = i/(float)(ncap-1)*NVG_PI; - float ax = cosf(a) * w, ay = sinf(a) * w; - nvg__vset(dst, px - dlx*ax - dx*ay, py - dly*ax - dy*ay, 0,1); dst++; - nvg__vset(dst, px, py, 0.5f,1); dst++; - } - nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; - nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; - return dst; -} - -static NVGvertex* nvg__roundCapEnd(NVGvertex* dst, NVGpoint* p, - float dx, float dy, float w, int ncap, float aa) -{ - int i; - float px = p->x; - float py = p->y; - float dlx = dy; - float dly = -dx; - NVG_NOTUSED(aa); - nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; - nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; - for (i = 0; i < ncap; i++) { - float a = i/(float)(ncap-1)*NVG_PI; - float ax = cosf(a) * w, ay = sinf(a) * w; - nvg__vset(dst, px, py, 0.5f,1); dst++; - nvg__vset(dst, px - dlx*ax + dx*ay, py - dly*ax + dy*ay, 0,1); dst++; - } - return dst; -} - - -static void nvg__calculateJoins(NVGcontext* ctx, float w, int lineJoin, float miterLimit) -{ - NVGpathCache* cache = ctx->cache; - int i, j; - float iw = 0.0f; - - if (w > 0.0f) iw = 1.0f / w; - - // Calculate which joins needs extra vertices to append, and gather vertex count. - for (i = 0; i < cache->npaths; i++) { - NVGpath* path = &cache->paths[i]; - NVGpoint* pts = &cache->points[path->first]; - NVGpoint* p0 = &pts[path->count-1]; - NVGpoint* p1 = &pts[0]; - int nleft = 0; - - path->nbevel = 0; - - for (j = 0; j < path->count; j++) { - float dlx0, dly0, dlx1, dly1, dmr2, cross, limit; - dlx0 = p0->dy; - dly0 = -p0->dx; - dlx1 = p1->dy; - dly1 = -p1->dx; - // Calculate extrusions - p1->dmx = (dlx0 + dlx1) * 0.5f; - p1->dmy = (dly0 + dly1) * 0.5f; - dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy; - if (dmr2 > 0.000001f) { - float scale = 1.0f / dmr2; - if (scale > 600.0f) { - scale = 600.0f; - } - p1->dmx *= scale; - p1->dmy *= scale; - } - - // Clear flags, but keep the corner. - p1->flags = (p1->flags & NVG_PT_CORNER) ? NVG_PT_CORNER : 0; - - // Keep track of left turns. - cross = p1->dx * p0->dy - p0->dx * p1->dy; - if (cross > 0.0f) { - nleft++; - p1->flags |= NVG_PT_LEFT; - } - - // Calculate if we should use bevel or miter for inner join. - limit = nvg__maxf(1.01f, nvg__minf(p0->len, p1->len) * iw); - if ((dmr2 * limit*limit) < 1.0f) - p1->flags |= NVG_PR_INNERBEVEL; - - // Check to see if the corner needs to be beveled. - if (p1->flags & NVG_PT_CORNER) { - if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NVG_BEVEL || lineJoin == NVG_ROUND) { - p1->flags |= NVG_PT_BEVEL; - } - } - - if ((p1->flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) - path->nbevel++; - - p0 = p1++; - } - - path->convex = (nleft == path->count) ? 1 : 0; - } -} - - -static int nvg__expandStroke(NVGcontext* ctx, float w, int lineCap, int lineJoin, float miterLimit) -{ - NVGpathCache* cache = ctx->cache; - NVGvertex* verts; - NVGvertex* dst; - int cverts, i, j; - float aa = ctx->fringeWidth; - int ncap = nvg__curveDivs(w, NVG_PI, ctx->tessTol); // Calculate divisions per half circle. - - nvg__calculateJoins(ctx, w, lineJoin, miterLimit); - - // Calculate max vertex usage. - cverts = 0; - for (i = 0; i < cache->npaths; i++) { - NVGpath* path = &cache->paths[i]; - int loop = (path->closed == 0) ? 0 : 1; - if (lineJoin == NVG_ROUND) - cverts += (path->count + path->nbevel*(ncap+2) + 1) * 2; // plus one for loop - else - cverts += (path->count + path->nbevel*5 + 1) * 2; // plus one for loop - if (loop == 0) { - // space for caps - if (lineCap == NVG_ROUND) { - cverts += (ncap*2 + 2)*2; - } else { - cverts += (3+3)*2; - } - } - } - - verts = nvg__allocTempVerts(ctx, cverts); - if (verts == NULL) return 0; - - for (i = 0; i < cache->npaths; i++) { - NVGpath* path = &cache->paths[i]; - NVGpoint* pts = &cache->points[path->first]; - NVGpoint* p0; - NVGpoint* p1; - int s, e, loop; - float dx, dy; - - path->fill = 0; - path->nfill = 0; - - // Calculate fringe or stroke - loop = (path->closed == 0) ? 0 : 1; - dst = verts; - path->stroke = dst; - - if (loop) { - // Looping - p0 = &pts[path->count-1]; - p1 = &pts[0]; - s = 0; - e = path->count; - } else { - // Add cap - p0 = &pts[0]; - p1 = &pts[1]; - s = 1; - e = path->count-1; - } - - if (loop == 0) { - // Add cap - dx = p1->x - p0->x; - dy = p1->y - p0->y; - nvg__normalize(&dx, &dy); - if (lineCap == NVG_BUTT) - dst = nvg__buttCapStart(dst, p0, dx, dy, w, -aa*0.5f, aa); - else if (lineCap == NVG_BUTT || lineCap == NVG_SQUARE) - dst = nvg__buttCapStart(dst, p0, dx, dy, w, w-aa, aa); - else if (lineCap == NVG_ROUND) - dst = nvg__roundCapStart(dst, p0, dx, dy, w, ncap, aa); - } - - for (j = s; j < e; ++j) { - if ((p1->flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) { - if (lineJoin == NVG_ROUND) { - dst = nvg__roundJoin(dst, p0, p1, w, w, 0, 1, ncap, aa); - } else { - dst = nvg__bevelJoin(dst, p0, p1, w, w, 0, 1, aa); - } - } else { - nvg__vset(dst, p1->x + (p1->dmx * w), p1->y + (p1->dmy * w), 0,1); dst++; - nvg__vset(dst, p1->x - (p1->dmx * w), p1->y - (p1->dmy * w), 1,1); dst++; - } - p0 = p1++; - } - - if (loop) { - // Loop it - nvg__vset(dst, verts[0].x, verts[0].y, 0,1); dst++; - nvg__vset(dst, verts[1].x, verts[1].y, 1,1); dst++; - } else { - // Add cap - dx = p1->x - p0->x; - dy = p1->y - p0->y; - nvg__normalize(&dx, &dy); - if (lineCap == NVG_BUTT) - dst = nvg__buttCapEnd(dst, p1, dx, dy, w, -aa*0.5f, aa); - else if (lineCap == NVG_BUTT || lineCap == NVG_SQUARE) - dst = nvg__buttCapEnd(dst, p1, dx, dy, w, w-aa, aa); - else if (lineCap == NVG_ROUND) - dst = nvg__roundCapEnd(dst, p1, dx, dy, w, ncap, aa); - } - - path->nstroke = (int)(dst - verts); - - verts = dst; - } - - return 1; -} - -static int nvg__expandFill(NVGcontext* ctx, float w, int lineJoin, float miterLimit) -{ - NVGpathCache* cache = ctx->cache; - NVGvertex* verts; - NVGvertex* dst; - int cverts, convex, i, j; - float aa = ctx->fringeWidth; - int fringe = w > 0.0f; - - nvg__calculateJoins(ctx, w, lineJoin, miterLimit); - - // Calculate max vertex usage. - cverts = 0; - for (i = 0; i < cache->npaths; i++) { - NVGpath* path = &cache->paths[i]; - cverts += path->count + path->nbevel + 1; - if (fringe) - cverts += (path->count + path->nbevel*5 + 1) * 2; // plus one for loop - } - - verts = nvg__allocTempVerts(ctx, cverts); - if (verts == NULL) return 0; - - convex = cache->npaths == 1 && cache->paths[0].convex; - - for (i = 0; i < cache->npaths; i++) { - NVGpath* path = &cache->paths[i]; - NVGpoint* pts = &cache->points[path->first]; - NVGpoint* p0; - NVGpoint* p1; - float rw, lw, woff; - float ru, lu; - - // Calculate shape vertices. - woff = 0.5f*aa; - dst = verts; - path->fill = dst; - - if (fringe) { - // Looping - p0 = &pts[path->count-1]; - p1 = &pts[0]; - for (j = 0; j < path->count; ++j) { - if (p1->flags & NVG_PT_BEVEL) { - float dlx0 = p0->dy; - float dly0 = -p0->dx; - float dlx1 = p1->dy; - float dly1 = -p1->dx; - if (p1->flags & NVG_PT_LEFT) { - float lx = p1->x + p1->dmx * woff; - float ly = p1->y + p1->dmy * woff; - nvg__vset(dst, lx, ly, 0.5f,1); dst++; - } else { - float lx0 = p1->x + dlx0 * woff; - float ly0 = p1->y + dly0 * woff; - float lx1 = p1->x + dlx1 * woff; - float ly1 = p1->y + dly1 * woff; - nvg__vset(dst, lx0, ly0, 0.5f,1); dst++; - nvg__vset(dst, lx1, ly1, 0.5f,1); dst++; - } - } else { - nvg__vset(dst, p1->x + (p1->dmx * woff), p1->y + (p1->dmy * woff), 0.5f,1); dst++; - } - p0 = p1++; - } - } else { - for (j = 0; j < path->count; ++j) { - nvg__vset(dst, pts[j].x, pts[j].y, 0.5f,1); - dst++; - } - } - - path->nfill = (int)(dst - verts); - verts = dst; - - // Calculate fringe - if (fringe) { - lw = w + woff; - rw = w - woff; - lu = 0; - ru = 1; - dst = verts; - path->stroke = dst; - - // Create only half a fringe for convex shapes so that - // the shape can be rendered without stenciling. - if (convex) { - lw = woff; // This should generate the same vertex as fill inset above. - lu = 0.5f; // Set outline fade at middle. - } - - // Looping - p0 = &pts[path->count-1]; - p1 = &pts[0]; - - for (j = 0; j < path->count; ++j) { - if ((p1->flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) { - dst = nvg__bevelJoin(dst, p0, p1, lw, rw, lu, ru, ctx->fringeWidth); - } else { - nvg__vset(dst, p1->x + (p1->dmx * lw), p1->y + (p1->dmy * lw), lu,1); dst++; - nvg__vset(dst, p1->x - (p1->dmx * rw), p1->y - (p1->dmy * rw), ru,1); dst++; - } - p0 = p1++; - } - - // Loop it - nvg__vset(dst, verts[0].x, verts[0].y, lu,1); dst++; - nvg__vset(dst, verts[1].x, verts[1].y, ru,1); dst++; - - path->nstroke = (int)(dst - verts); - verts = dst; - } else { - path->stroke = NULL; - path->nstroke = 0; - } - } - - return 1; -} - - -// Draw -void nvgBeginPath(NVGcontext* ctx) -{ - ctx->ncommands = 0; - nvg__clearPathCache(ctx); -} - -void nvgMoveTo(NVGcontext* ctx, float x, float y) -{ - float vals[] = { NVG_MOVETO, x, y }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgLineTo(NVGcontext* ctx, float x, float y) -{ - float vals[] = { NVG_LINETO, x, y }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgBezierTo(NVGcontext* ctx, float c1x, float c1y, float c2x, float c2y, float x, float y) -{ - float vals[] = { NVG_BEZIERTO, c1x, c1y, c2x, c2y, x, y }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgQuadTo(NVGcontext* ctx, float cx, float cy, float x, float y) -{ - float x0 = ctx->commandx; - float y0 = ctx->commandy; - float vals[] = { NVG_BEZIERTO, - x0 + 2.0f/3.0f*(cx - x0), y0 + 2.0f/3.0f*(cy - y0), - x + 2.0f/3.0f*(cx - x), y + 2.0f/3.0f*(cy - y), - x, y }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgArcTo(NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius) -{ - float x0 = ctx->commandx; - float y0 = ctx->commandy; - float dx0,dy0, dx1,dy1, a, d, cx,cy, a0,a1; - int dir; - - if (ctx->ncommands == 0) { - return; - } - - // Handle degenerate cases. - if (nvg__ptEquals(x0,y0, x1,y1, ctx->distTol) || - nvg__ptEquals(x1,y1, x2,y2, ctx->distTol) || - nvg__distPtSeg(x1,y1, x0,y0, x2,y2) < ctx->distTol*ctx->distTol || - radius < ctx->distTol) { - nvgLineTo(ctx, x1,y1); - return; - } - - // Calculate tangential circle to lines (x0,y0)-(x1,y1) and (x1,y1)-(x2,y2). - dx0 = x0-x1; - dy0 = y0-y1; - dx1 = x2-x1; - dy1 = y2-y1; - nvg__normalize(&dx0,&dy0); - nvg__normalize(&dx1,&dy1); - a = nvg__acosf(dx0*dx1 + dy0*dy1); - d = radius / nvg__tanf(a/2.0f); - -// printf("a=%f° d=%f\n", a/NVG_PI*180.0f, d); - - if (d > 10000.0f) { - nvgLineTo(ctx, x1,y1); - return; - } - - if (nvg__cross(dx0,dy0, dx1,dy1) > 0.0f) { - cx = x1 + dx0*d + dy0*radius; - cy = y1 + dy0*d + -dx0*radius; - a0 = nvg__atan2f(dx0, -dy0); - a1 = nvg__atan2f(-dx1, dy1); - dir = NVG_CW; -// printf("CW c=(%f, %f) a0=%f° a1=%f°\n", cx, cy, a0/NVG_PI*180.0f, a1/NVG_PI*180.0f); - } else { - cx = x1 + dx0*d + -dy0*radius; - cy = y1 + dy0*d + dx0*radius; - a0 = nvg__atan2f(-dx0, dy0); - a1 = nvg__atan2f(dx1, -dy1); - dir = NVG_CCW; -// printf("CCW c=(%f, %f) a0=%f° a1=%f°\n", cx, cy, a0/NVG_PI*180.0f, a1/NVG_PI*180.0f); - } - - nvgArc(ctx, cx, cy, radius, a0, a1, dir); -} - -void nvgClosePath(NVGcontext* ctx) -{ - float vals[] = { NVG_CLOSE }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgPathWinding(NVGcontext* ctx, int dir) -{ - float vals[] = { NVG_WINDING, (float)dir }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgArc(NVGcontext* ctx, float cx, float cy, float r, float a0, float a1, int dir) -{ - float a = 0, da = 0, hda = 0, kappa = 0; - float dx = 0, dy = 0, x = 0, y = 0, tanx = 0, tany = 0; - float px = 0, py = 0, ptanx = 0, ptany = 0; - float vals[3 + 5*7 + 100]; - int i, ndivs, nvals; - int move = ctx->ncommands > 0 ? NVG_LINETO : NVG_MOVETO; - - // Clamp angles - da = a1 - a0; - if (dir == NVG_CW) { - if (nvg__absf(da) >= NVG_PI*2) { - da = NVG_PI*2; - } else { - while (da < 0.0f) da += NVG_PI*2; - } - } else { - if (nvg__absf(da) >= NVG_PI*2) { - da = -NVG_PI*2; - } else { - while (da > 0.0f) da -= NVG_PI*2; - } - } - - // Split arc into max 90 degree segments. - ndivs = nvg__maxi(1, nvg__mini((int)(nvg__absf(da) / (NVG_PI*0.5f) + 0.5f), 5)); - hda = (da / (float)ndivs) / 2.0f; - kappa = nvg__absf(4.0f / 3.0f * (1.0f - nvg__cosf(hda)) / nvg__sinf(hda)); - - if (dir == NVG_CCW) - kappa = -kappa; - - nvals = 0; - for (i = 0; i <= ndivs; i++) { - a = a0 + da * (i/(float)ndivs); - dx = nvg__cosf(a); - dy = nvg__sinf(a); - x = cx + dx*r; - y = cy + dy*r; - tanx = -dy*r*kappa; - tany = dx*r*kappa; - - if (i == 0) { - vals[nvals++] = (float)move; - vals[nvals++] = x; - vals[nvals++] = y; - } else { - vals[nvals++] = NVG_BEZIERTO; - vals[nvals++] = px+ptanx; - vals[nvals++] = py+ptany; - vals[nvals++] = x-tanx; - vals[nvals++] = y-tany; - vals[nvals++] = x; - vals[nvals++] = y; - } - px = x; - py = y; - ptanx = tanx; - ptany = tany; - } - - nvg__appendCommands(ctx, vals, nvals); -} - -void nvgRect(NVGcontext* ctx, float x, float y, float w, float h) -{ - float vals[] = { - NVG_MOVETO, x,y, - NVG_LINETO, x,y+h, - NVG_LINETO, x+w,y+h, - NVG_LINETO, x+w,y, - NVG_CLOSE - }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgRoundedRect(NVGcontext* ctx, float x, float y, float w, float h, float r) -{ - nvgRoundedRectVarying(ctx, x, y, w, h, r, r, r, r); -} - -void nvgRoundedRectVarying(NVGcontext* ctx, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft) -{ - if(radTopLeft < 0.1f && radTopRight < 0.1f && radBottomRight < 0.1f && radBottomLeft < 0.1f) { - nvgRect(ctx, x, y, w, h); - return; - } else { - float halfw = nvg__absf(w)*0.5f; - float halfh = nvg__absf(h)*0.5f; - float rxBL = nvg__minf(radBottomLeft, halfw) * nvg__signf(w), ryBL = nvg__minf(radBottomLeft, halfh) * nvg__signf(h); - float rxBR = nvg__minf(radBottomRight, halfw) * nvg__signf(w), ryBR = nvg__minf(radBottomRight, halfh) * nvg__signf(h); - float rxTR = nvg__minf(radTopRight, halfw) * nvg__signf(w), ryTR = nvg__minf(radTopRight, halfh) * nvg__signf(h); - float rxTL = nvg__minf(radTopLeft, halfw) * nvg__signf(w), ryTL = nvg__minf(radTopLeft, halfh) * nvg__signf(h); - float vals[] = { - NVG_MOVETO, x, y + ryTL, - NVG_LINETO, x, y + h - ryBL, - NVG_BEZIERTO, x, y + h - ryBL*(1 - NVG_KAPPA90), x + rxBL*(1 - NVG_KAPPA90), y + h, x + rxBL, y + h, - NVG_LINETO, x + w - rxBR, y + h, - NVG_BEZIERTO, x + w - rxBR*(1 - NVG_KAPPA90), y + h, x + w, y + h - ryBR*(1 - NVG_KAPPA90), x + w, y + h - ryBR, - NVG_LINETO, x + w, y + ryTR, - NVG_BEZIERTO, x + w, y + ryTR*(1 - NVG_KAPPA90), x + w - rxTR*(1 - NVG_KAPPA90), y, x + w - rxTR, y, - NVG_LINETO, x + rxTL, y, - NVG_BEZIERTO, x + rxTL*(1 - NVG_KAPPA90), y, x, y + ryTL*(1 - NVG_KAPPA90), x, y + ryTL, - NVG_CLOSE - }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); - } -} - -void nvgEllipse(NVGcontext* ctx, float cx, float cy, float rx, float ry) -{ - float vals[] = { - NVG_MOVETO, cx-rx, cy, - NVG_BEZIERTO, cx-rx, cy+ry*NVG_KAPPA90, cx-rx*NVG_KAPPA90, cy+ry, cx, cy+ry, - NVG_BEZIERTO, cx+rx*NVG_KAPPA90, cy+ry, cx+rx, cy+ry*NVG_KAPPA90, cx+rx, cy, - NVG_BEZIERTO, cx+rx, cy-ry*NVG_KAPPA90, cx+rx*NVG_KAPPA90, cy-ry, cx, cy-ry, - NVG_BEZIERTO, cx-rx*NVG_KAPPA90, cy-ry, cx-rx, cy-ry*NVG_KAPPA90, cx-rx, cy, - NVG_CLOSE - }; - nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); -} - -void nvgCircle(NVGcontext* ctx, float cx, float cy, float r) -{ - nvgEllipse(ctx, cx,cy, r,r); -} - -void nvgDebugDumpPathCache(NVGcontext* ctx) -{ - const NVGpath* path; - int i, j; - - printf("Dumping %d cached paths\n", ctx->cache->npaths); - for (i = 0; i < ctx->cache->npaths; i++) { - path = &ctx->cache->paths[i]; - printf(" - Path %d\n", i); - if (path->nfill) { - printf(" - fill: %d\n", path->nfill); - for (j = 0; j < path->nfill; j++) - printf("%f\t%f\n", path->fill[j].x, path->fill[j].y); - } - if (path->nstroke) { - printf(" - stroke: %d\n", path->nstroke); - for (j = 0; j < path->nstroke; j++) - printf("%f\t%f\n", path->stroke[j].x, path->stroke[j].y); - } - } -} - -void nvgFill(NVGcontext* ctx) -{ - NVGstate* state = nvg__getState(ctx); - const NVGpath* path; - NVGpaint fillPaint = state->fill; - int i; - - nvg__flattenPaths(ctx); - if (ctx->params.edgeAntiAlias) - nvg__expandFill(ctx, ctx->fringeWidth, NVG_MITER, 2.4f); - else - nvg__expandFill(ctx, 0.0f, NVG_MITER, 2.4f); - - // Apply global alpha - fillPaint.innerColor.a *= state->alpha; - fillPaint.outerColor.a *= state->alpha; - - ctx->params.renderFill(ctx->params.userPtr, &fillPaint, &state->scissor, ctx->fringeWidth, - ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths); - - // Count triangles - for (i = 0; i < ctx->cache->npaths; i++) { - path = &ctx->cache->paths[i]; - ctx->fillTriCount += path->nfill-2; - ctx->fillTriCount += path->nstroke-2; - ctx->drawCallCount += 2; - } -} - -void nvgStroke(NVGcontext* ctx) -{ - NVGstate* state = nvg__getState(ctx); - float scale = nvg__getAverageScale(state->xform); - float strokeWidth = nvg__clampf(state->strokeWidth * scale, 0.0f, 200.0f); - NVGpaint strokePaint = state->stroke; - const NVGpath* path; - int i; - - if (strokeWidth < ctx->fringeWidth) { - // If the stroke width is less than pixel size, use alpha to emulate coverage. - // Since coverage is area, scale by alpha*alpha. - float alpha = nvg__clampf(strokeWidth / ctx->fringeWidth, 0.0f, 1.0f); - strokePaint.innerColor.a *= alpha*alpha; - strokePaint.outerColor.a *= alpha*alpha; - strokeWidth = ctx->fringeWidth; - } - - // Apply global alpha - strokePaint.innerColor.a *= state->alpha; - strokePaint.outerColor.a *= state->alpha; - - nvg__flattenPaths(ctx); - - if (ctx->params.edgeAntiAlias) - nvg__expandStroke(ctx, strokeWidth*0.5f + ctx->fringeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit); - else - nvg__expandStroke(ctx, strokeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit); - - ctx->params.renderStroke(ctx->params.userPtr, &strokePaint, &state->scissor, ctx->fringeWidth, - strokeWidth, ctx->cache->paths, ctx->cache->npaths); - - // Count triangles - for (i = 0; i < ctx->cache->npaths; i++) { - path = &ctx->cache->paths[i]; - ctx->strokeTriCount += path->nstroke-2; - ctx->drawCallCount++; - } -} - -// Add fonts -int nvgCreateFont(NVGcontext* ctx, const char* name, const char* path) -{ - return fonsAddFont(ctx->fs, name, path); -} - -int nvgCreateFontMem(NVGcontext* ctx, const char* name, unsigned char* data, int ndata, int freeData) -{ - return fonsAddFontMem(ctx->fs, name, data, ndata, freeData); -} - -int nvgFindFont(NVGcontext* ctx, const char* name) -{ - if (name == NULL) return -1; - return fonsGetFontByName(ctx->fs, name); -} - - -int nvgAddFallbackFontId(NVGcontext* ctx, int baseFont, int fallbackFont) -{ - if(baseFont == -1 || fallbackFont == -1) return 0; - return fonsAddFallbackFont(ctx->fs, baseFont, fallbackFont); -} - -int nvgAddFallbackFont(NVGcontext* ctx, const char* baseFont, const char* fallbackFont) -{ - return nvgAddFallbackFontId(ctx, nvgFindFont(ctx, baseFont), nvgFindFont(ctx, fallbackFont)); -} - -// State setting -void nvgFontSize(NVGcontext* ctx, float size) -{ - NVGstate* state = nvg__getState(ctx); - state->fontSize = size; -} - -void nvgFontBlur(NVGcontext* ctx, float blur) -{ - NVGstate* state = nvg__getState(ctx); - state->fontBlur = blur; -} - -void nvgTextLetterSpacing(NVGcontext* ctx, float spacing) -{ - NVGstate* state = nvg__getState(ctx); - state->letterSpacing = spacing; -} - -void nvgTextLineHeight(NVGcontext* ctx, float lineHeight) -{ - NVGstate* state = nvg__getState(ctx); - state->lineHeight = lineHeight; -} - -void nvgTextAlign(NVGcontext* ctx, int align) -{ - NVGstate* state = nvg__getState(ctx); - state->textAlign = align; -} - -void nvgFontFaceId(NVGcontext* ctx, int font) -{ - NVGstate* state = nvg__getState(ctx); - state->fontId = font; -} - -void nvgFontFace(NVGcontext* ctx, const char* font) -{ - NVGstate* state = nvg__getState(ctx); - state->fontId = fonsGetFontByName(ctx->fs, font); -} - -static float nvg__quantize(float a, float d) -{ - return ((int)(a / d + 0.5f)) * d; -} - -static float nvg__getFontScale(NVGstate* state) -{ - return nvg__minf(nvg__quantize(nvg__getAverageScale(state->xform), 0.01f), 4.0f); -} - -static void nvg__flushTextTexture(NVGcontext* ctx) -{ - int dirty[4]; - - if (fonsValidateTexture(ctx->fs, dirty)) { - int fontImage = ctx->fontImages[ctx->fontImageIdx]; - // Update texture - if (fontImage != 0) { - int iw, ih; - const unsigned char* data = fonsGetTextureData(ctx->fs, &iw, &ih); - int x = dirty[0]; - int y = dirty[1]; - int w = dirty[2] - dirty[0]; - int h = dirty[3] - dirty[1]; - ctx->params.renderUpdateTexture(ctx->params.userPtr, fontImage, x,y, w,h, data); - } - } -} - -static int nvg__allocTextAtlas(NVGcontext* ctx) -{ - int iw, ih; - nvg__flushTextTexture(ctx); - if (ctx->fontImageIdx >= NVG_MAX_FONTIMAGES-1) - return 0; - // if next fontImage already have a texture - if (ctx->fontImages[ctx->fontImageIdx+1] != 0) - nvgImageSize(ctx, ctx->fontImages[ctx->fontImageIdx+1], &iw, &ih); - else { // calculate the new font image size and create it. - nvgImageSize(ctx, ctx->fontImages[ctx->fontImageIdx], &iw, &ih); - if (iw > ih) - ih *= 2; - else - iw *= 2; - if (iw > NVG_MAX_FONTIMAGE_SIZE || ih > NVG_MAX_FONTIMAGE_SIZE) - iw = ih = NVG_MAX_FONTIMAGE_SIZE; - ctx->fontImages[ctx->fontImageIdx+1] = ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_ALPHA, iw, ih, 0, NULL); - } - ++ctx->fontImageIdx; - fonsResetAtlas(ctx->fs, iw, ih); - return 1; -} - -static void nvg__renderText(NVGcontext* ctx, NVGvertex* verts, int nverts) -{ - NVGstate* state = nvg__getState(ctx); - NVGpaint paint = state->fill; - - // Render triangles. - paint.image = ctx->fontImages[ctx->fontImageIdx]; - - // Apply global alpha - paint.innerColor.a *= state->alpha; - paint.outerColor.a *= state->alpha; - - ctx->params.renderTriangles(ctx->params.userPtr, &paint, &state->scissor, verts, nverts); - - ctx->drawCallCount++; - ctx->textTriCount += nverts/3; -} - -float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char* end) -{ - NVGstate* state = nvg__getState(ctx); - FONStextIter iter, prevIter; - FONSquad q; - NVGvertex* verts; - float scale = nvg__getFontScale(state) * ctx->devicePxRatio; - float invscale = 1.0f / scale; - int cverts = 0; - int nverts = 0; - - if (end == NULL) - end = string + strlen(string); - - if (state->fontId == FONS_INVALID) return x; - - fonsSetSize(ctx->fs, state->fontSize*scale); - fonsSetSpacing(ctx->fs, state->letterSpacing*scale); - fonsSetBlur(ctx->fs, state->fontBlur*scale); - fonsSetAlign(ctx->fs, state->textAlign); - fonsSetFont(ctx->fs, state->fontId); - - cverts = nvg__maxi(2, (int)(end - string)) * 6; // conservative estimate. - verts = nvg__allocTempVerts(ctx, cverts); - if (verts == NULL) return x; - - fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end); - prevIter = iter; - while (fonsTextIterNext(ctx->fs, &iter, &q)) { - float c[4*2]; - if (iter.prevGlyphIndex == -1) { // can not retrieve glyph? - if (!nvg__allocTextAtlas(ctx)) - break; // no memory :( - if (nverts != 0) { - nvg__renderText(ctx, verts, nverts); - nverts = 0; - } - iter = prevIter; - fonsTextIterNext(ctx->fs, &iter, &q); // try again - if (iter.prevGlyphIndex == -1) // still can not find glyph? - break; - } - prevIter = iter; - // Transform corners. - nvgTransformPoint(&c[0],&c[1], state->xform, q.x0*invscale, q.y0*invscale); - nvgTransformPoint(&c[2],&c[3], state->xform, q.x1*invscale, q.y0*invscale); - nvgTransformPoint(&c[4],&c[5], state->xform, q.x1*invscale, q.y1*invscale); - nvgTransformPoint(&c[6],&c[7], state->xform, q.x0*invscale, q.y1*invscale); - // Create triangles - if (nverts+6 <= cverts) { - nvg__vset(&verts[nverts], c[0], c[1], q.s0, q.t0); nverts++; - nvg__vset(&verts[nverts], c[4], c[5], q.s1, q.t1); nverts++; - nvg__vset(&verts[nverts], c[2], c[3], q.s1, q.t0); nverts++; - nvg__vset(&verts[nverts], c[0], c[1], q.s0, q.t0); nverts++; - nvg__vset(&verts[nverts], c[6], c[7], q.s0, q.t1); nverts++; - nvg__vset(&verts[nverts], c[4], c[5], q.s1, q.t1); nverts++; - } - } - - // TODO: add back-end bit to do this just once per frame. - nvg__flushTextTexture(ctx); - - nvg__renderText(ctx, verts, nverts); - - return iter.x; -} - -void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end) -{ - NVGstate* state = nvg__getState(ctx); - NVGtextRow rows[2]; - int nrows = 0, i; - int oldAlign = state->textAlign; - int haling = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT); - int valign = state->textAlign & (NVG_ALIGN_TOP | NVG_ALIGN_MIDDLE | NVG_ALIGN_BOTTOM | NVG_ALIGN_BASELINE); - float lineh = 0; - - if (state->fontId == FONS_INVALID) return; - - nvgTextMetrics(ctx, NULL, NULL, &lineh); - - state->textAlign = NVG_ALIGN_LEFT | valign; - - while ((nrows = nvgTextBreakLines(ctx, string, end, breakRowWidth, rows, 2))) { - for (i = 0; i < nrows; i++) { - NVGtextRow* row = &rows[i]; - if (haling & NVG_ALIGN_LEFT) - nvgText(ctx, x, y, row->start, row->end); - else if (haling & NVG_ALIGN_CENTER) - nvgText(ctx, x + breakRowWidth*0.5f - row->width*0.5f, y, row->start, row->end); - else if (haling & NVG_ALIGN_RIGHT) - nvgText(ctx, x + breakRowWidth - row->width, y, row->start, row->end); - y += lineh * state->lineHeight; - } - string = rows[nrows-1].next; - } - - state->textAlign = oldAlign; -} - -int nvgTextGlyphPositions(NVGcontext* ctx, float x, float y, const char* string, const char* end, NVGglyphPosition* positions, int maxPositions) -{ - NVGstate* state = nvg__getState(ctx); - float scale = nvg__getFontScale(state) * ctx->devicePxRatio; - float invscale = 1.0f / scale; - FONStextIter iter, prevIter; - FONSquad q; - int npos = 0; - - if (state->fontId == FONS_INVALID) return 0; - - if (end == NULL) - end = string + strlen(string); - - if (string == end) - return 0; - - fonsSetSize(ctx->fs, state->fontSize*scale); - fonsSetSpacing(ctx->fs, state->letterSpacing*scale); - fonsSetBlur(ctx->fs, state->fontBlur*scale); - fonsSetAlign(ctx->fs, state->textAlign); - fonsSetFont(ctx->fs, state->fontId); - - fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end); - prevIter = iter; - while (fonsTextIterNext(ctx->fs, &iter, &q)) { - if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph? - iter = prevIter; - fonsTextIterNext(ctx->fs, &iter, &q); // try again - } - prevIter = iter; - positions[npos].str = iter.str; - positions[npos].x = iter.x * invscale; - positions[npos].minx = nvg__minf(iter.x, q.x0) * invscale; - positions[npos].maxx = nvg__maxf(iter.nextx, q.x1) * invscale; - npos++; - if (npos >= maxPositions) - break; - } - - return npos; -} - -enum NVGcodepointType { - NVG_SPACE, - NVG_NEWLINE, - NVG_CHAR, -}; - -int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, float breakRowWidth, NVGtextRow* rows, int maxRows) -{ - NVGstate* state = nvg__getState(ctx); - float scale = nvg__getFontScale(state) * ctx->devicePxRatio; - float invscale = 1.0f / scale; - FONStextIter iter, prevIter; - FONSquad q; - int nrows = 0; - float rowStartX = 0; - float rowWidth = 0; - float rowMinX = 0; - float rowMaxX = 0; - const char* rowStart = NULL; - const char* rowEnd = NULL; - const char* wordStart = NULL; - float wordStartX = 0; - float wordMinX = 0; - const char* breakEnd = NULL; - float breakWidth = 0; - float breakMaxX = 0; - int type = NVG_SPACE, ptype = NVG_SPACE; - unsigned int pcodepoint = 0; - - if (maxRows == 0) return 0; - if (state->fontId == FONS_INVALID) return 0; - - if (end == NULL) - end = string + strlen(string); - - if (string == end) return 0; - - fonsSetSize(ctx->fs, state->fontSize*scale); - fonsSetSpacing(ctx->fs, state->letterSpacing*scale); - fonsSetBlur(ctx->fs, state->fontBlur*scale); - fonsSetAlign(ctx->fs, state->textAlign); - fonsSetFont(ctx->fs, state->fontId); - - breakRowWidth *= scale; - - fonsTextIterInit(ctx->fs, &iter, 0, 0, string, end); - prevIter = iter; - while (fonsTextIterNext(ctx->fs, &iter, &q)) { - if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph? - iter = prevIter; - fonsTextIterNext(ctx->fs, &iter, &q); // try again - } - prevIter = iter; - switch (iter.codepoint) { - case 9: // \t - case 11: // \v - case 12: // \f - case 32: // space - case 0x00a0: // NBSP - type = NVG_SPACE; - break; - case 10: // \n - type = pcodepoint == 13 ? NVG_SPACE : NVG_NEWLINE; - break; - case 13: // \r - type = pcodepoint == 10 ? NVG_SPACE : NVG_NEWLINE; - break; - case 0x0085: // NEL - type = NVG_NEWLINE; - break; - default: - type = NVG_CHAR; - break; - } - - if (type == NVG_NEWLINE) { - // Always handle new lines. - rows[nrows].start = rowStart != NULL ? rowStart : iter.str; - rows[nrows].end = rowEnd != NULL ? rowEnd : iter.str; - rows[nrows].width = rowWidth * invscale; - rows[nrows].minx = rowMinX * invscale; - rows[nrows].maxx = rowMaxX * invscale; - rows[nrows].next = iter.next; - nrows++; - if (nrows >= maxRows) - return nrows; - // Set null break point - breakEnd = rowStart; - breakWidth = 0.0; - breakMaxX = 0.0; - // Indicate to skip the white space at the beginning of the row. - rowStart = NULL; - rowEnd = NULL; - rowWidth = 0; - rowMinX = rowMaxX = 0; - } else { - if (rowStart == NULL) { - // Skip white space until the beginning of the line - if (type == NVG_CHAR) { - // The current char is the row so far - rowStartX = iter.x; - rowStart = iter.str; - rowEnd = iter.next; - rowWidth = iter.nextx - rowStartX; // q.x1 - rowStartX; - rowMinX = q.x0 - rowStartX; - rowMaxX = q.x1 - rowStartX; - wordStart = iter.str; - wordStartX = iter.x; - wordMinX = q.x0 - rowStartX; - // Set null break point - breakEnd = rowStart; - breakWidth = 0.0; - breakMaxX = 0.0; - } - } else { - float nextWidth = iter.nextx - rowStartX; - - // track last non-white space character - if (type == NVG_CHAR) { - rowEnd = iter.next; - rowWidth = iter.nextx - rowStartX; - rowMaxX = q.x1 - rowStartX; - } - // track last end of a word - if (ptype == NVG_CHAR && type == NVG_SPACE) { - breakEnd = iter.str; - breakWidth = rowWidth; - breakMaxX = rowMaxX; - } - // track last beginning of a word - if (ptype == NVG_SPACE && type == NVG_CHAR) { - wordStart = iter.str; - wordStartX = iter.x; - wordMinX = q.x0 - rowStartX; - } - - // Break to new line when a character is beyond break width. - if (type == NVG_CHAR && nextWidth > breakRowWidth) { - // The run length is too long, need to break to new line. - if (breakEnd == rowStart) { - // The current word is longer than the row length, just break it from here. - rows[nrows].start = rowStart; - rows[nrows].end = iter.str; - rows[nrows].width = rowWidth * invscale; - rows[nrows].minx = rowMinX * invscale; - rows[nrows].maxx = rowMaxX * invscale; - rows[nrows].next = iter.str; - nrows++; - if (nrows >= maxRows) - return nrows; - rowStartX = iter.x; - rowStart = iter.str; - rowEnd = iter.next; - rowWidth = iter.nextx - rowStartX; - rowMinX = q.x0 - rowStartX; - rowMaxX = q.x1 - rowStartX; - wordStart = iter.str; - wordStartX = iter.x; - wordMinX = q.x0 - rowStartX; - } else { - // Break the line from the end of the last word, and start new line from the beginning of the new. - rows[nrows].start = rowStart; - rows[nrows].end = breakEnd; - rows[nrows].width = breakWidth * invscale; - rows[nrows].minx = rowMinX * invscale; - rows[nrows].maxx = breakMaxX * invscale; - rows[nrows].next = wordStart; - nrows++; - if (nrows >= maxRows) - return nrows; - rowStartX = wordStartX; - rowStart = wordStart; - rowEnd = iter.next; - rowWidth = iter.nextx - rowStartX; - rowMinX = wordMinX; - rowMaxX = q.x1 - rowStartX; - // No change to the word start - } - // Set null break point - breakEnd = rowStart; - breakWidth = 0.0; - breakMaxX = 0.0; - } - } - } - - pcodepoint = iter.codepoint; - ptype = type; - } - - // Break the line from the end of the last word, and start new line from the beginning of the new. - if (rowStart != NULL) { - rows[nrows].start = rowStart; - rows[nrows].end = rowEnd; - rows[nrows].width = rowWidth * invscale; - rows[nrows].minx = rowMinX * invscale; - rows[nrows].maxx = rowMaxX * invscale; - rows[nrows].next = end; - nrows++; - } - - return nrows; -} - -float nvgTextBounds(NVGcontext* ctx, float x, float y, const char* string, const char* end, float* bounds) -{ - NVGstate* state = nvg__getState(ctx); - float scale = nvg__getFontScale(state) * ctx->devicePxRatio; - float invscale = 1.0f / scale; - float width; - - if (state->fontId == FONS_INVALID) return 0; - - fonsSetSize(ctx->fs, state->fontSize*scale); - fonsSetSpacing(ctx->fs, state->letterSpacing*scale); - fonsSetBlur(ctx->fs, state->fontBlur*scale); - fonsSetAlign(ctx->fs, state->textAlign); - fonsSetFont(ctx->fs, state->fontId); - - width = fonsTextBounds(ctx->fs, x*scale, y*scale, string, end, bounds); - if (bounds != NULL) { - // Use line bounds for height. - fonsLineBounds(ctx->fs, y*scale, &bounds[1], &bounds[3]); - bounds[0] *= invscale; - bounds[1] *= invscale; - bounds[2] *= invscale; - bounds[3] *= invscale; - } - return width * invscale; -} - -void nvgTextBoxBounds(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end, float* bounds) -{ - NVGstate* state = nvg__getState(ctx); - NVGtextRow rows[2]; - float scale = nvg__getFontScale(state) * ctx->devicePxRatio; - float invscale = 1.0f / scale; - int nrows = 0, i; - int oldAlign = state->textAlign; - int haling = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT); - int valign = state->textAlign & (NVG_ALIGN_TOP | NVG_ALIGN_MIDDLE | NVG_ALIGN_BOTTOM | NVG_ALIGN_BASELINE); - float lineh = 0, rminy = 0, rmaxy = 0; - float minx, miny, maxx, maxy; - - if (state->fontId == FONS_INVALID) { - if (bounds != NULL) - bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0f; - return; - } - - nvgTextMetrics(ctx, NULL, NULL, &lineh); - - state->textAlign = NVG_ALIGN_LEFT | valign; - - minx = maxx = x; - miny = maxy = y; - - fonsSetSize(ctx->fs, state->fontSize*scale); - fonsSetSpacing(ctx->fs, state->letterSpacing*scale); - fonsSetBlur(ctx->fs, state->fontBlur*scale); - fonsSetAlign(ctx->fs, state->textAlign); - fonsSetFont(ctx->fs, state->fontId); - fonsLineBounds(ctx->fs, 0, &rminy, &rmaxy); - rminy *= invscale; - rmaxy *= invscale; - - while ((nrows = nvgTextBreakLines(ctx, string, end, breakRowWidth, rows, 2))) { - for (i = 0; i < nrows; i++) { - NVGtextRow* row = &rows[i]; - float rminx, rmaxx, dx = 0; - // Horizontal bounds - if (haling & NVG_ALIGN_LEFT) - dx = 0; - else if (haling & NVG_ALIGN_CENTER) - dx = breakRowWidth*0.5f - row->width*0.5f; - else if (haling & NVG_ALIGN_RIGHT) - dx = breakRowWidth - row->width; - rminx = x + row->minx + dx; - rmaxx = x + row->maxx + dx; - minx = nvg__minf(minx, rminx); - maxx = nvg__maxf(maxx, rmaxx); - // Vertical bounds. - miny = nvg__minf(miny, y + rminy); - maxy = nvg__maxf(maxy, y + rmaxy); - - y += lineh * state->lineHeight; - } - string = rows[nrows-1].next; - } - - state->textAlign = oldAlign; - - if (bounds != NULL) { - bounds[0] = minx; - bounds[1] = miny; - bounds[2] = maxx; - bounds[3] = maxy; - } -} - -void nvgTextMetrics(NVGcontext* ctx, float* ascender, float* descender, float* lineh) -{ - NVGstate* state = nvg__getState(ctx); - float scale = nvg__getFontScale(state) * ctx->devicePxRatio; - float invscale = 1.0f / scale; - - if (state->fontId == FONS_INVALID) return; - - fonsSetSize(ctx->fs, state->fontSize*scale); - fonsSetSpacing(ctx->fs, state->letterSpacing*scale); - fonsSetBlur(ctx->fs, state->fontBlur*scale); - fonsSetAlign(ctx->fs, state->textAlign); - fonsSetFont(ctx->fs, state->fontId); - - fonsVertMetrics(ctx->fs, ascender, descender, lineh); - if (ascender != NULL) - *ascender *= invscale; - if (descender != NULL) - *descender *= invscale; - if (lineh != NULL) - *lineh *= invscale; -} -// vim: ft=c nu noet ts=4 diff --git a/phonelibs/nanovg/nanovg.h b/phonelibs/nanovg/nanovg.h deleted file mode 100644 index bb0d3417a286ce..00000000000000 --- a/phonelibs/nanovg/nanovg.h +++ /dev/null @@ -1,681 +0,0 @@ -// -// Copyright (c) 2013 Mikko Mononen memon@inside.org -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. 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. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// - -#ifndef NANOVG_H -#define NANOVG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define NVG_PI 3.14159265358979323846264338327f - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union -#endif - -typedef struct NVGcontext NVGcontext; - -struct NVGcolor { - union { - float rgba[4]; - struct { - float r,g,b,a; - }; - }; -}; -typedef struct NVGcolor NVGcolor; - -struct NVGpaint { - float xform[6]; - float extent[2]; - float radius; - float feather; - NVGcolor innerColor; - NVGcolor outerColor; - int image; -}; -typedef struct NVGpaint NVGpaint; - -enum NVGwinding { - NVG_CCW = 1, // Winding for solid shapes - NVG_CW = 2, // Winding for holes -}; - -enum NVGsolidity { - NVG_SOLID = 1, // CCW - NVG_HOLE = 2, // CW -}; - -enum NVGlineCap { - NVG_BUTT, - NVG_ROUND, - NVG_SQUARE, - NVG_BEVEL, - NVG_MITER, -}; - -enum NVGalign { - // Horizontal align - NVG_ALIGN_LEFT = 1<<0, // Default, align text horizontally to left. - NVG_ALIGN_CENTER = 1<<1, // Align text horizontally to center. - NVG_ALIGN_RIGHT = 1<<2, // Align text horizontally to right. - // Vertical align - NVG_ALIGN_TOP = 1<<3, // Align text vertically to top. - NVG_ALIGN_MIDDLE = 1<<4, // Align text vertically to middle. - NVG_ALIGN_BOTTOM = 1<<5, // Align text vertically to bottom. - NVG_ALIGN_BASELINE = 1<<6, // Default, align text vertically to baseline. -}; - -enum NVGblendFactor { - NVG_ZERO = 1<<0, - NVG_ONE = 1<<1, - NVG_SRC_COLOR = 1<<2, - NVG_ONE_MINUS_SRC_COLOR = 1<<3, - NVG_DST_COLOR = 1<<4, - NVG_ONE_MINUS_DST_COLOR = 1<<5, - NVG_SRC_ALPHA = 1<<6, - NVG_ONE_MINUS_SRC_ALPHA = 1<<7, - NVG_DST_ALPHA = 1<<8, - NVG_ONE_MINUS_DST_ALPHA = 1<<9, - NVG_SRC_ALPHA_SATURATE = 1<<10, -}; - -enum NVGcompositeOperation { - NVG_SOURCE_OVER, - NVG_SOURCE_IN, - NVG_SOURCE_OUT, - NVG_ATOP, - NVG_DESTINATION_OVER, - NVG_DESTINATION_IN, - NVG_DESTINATION_OUT, - NVG_DESTINATION_ATOP, - NVG_LIGHTER, - NVG_COPY, - NVG_XOR, -}; - -struct NVGcompositeOperationState { - int srcRGB; - int dstRGB; - int srcAlpha; - int dstAlpha; -}; -typedef struct NVGcompositeOperationState NVGcompositeOperationState; - -struct NVGglyphPosition { - const char* str; // Position of the glyph in the input string. - float x; // The x-coordinate of the logical glyph position. - float minx, maxx; // The bounds of the glyph shape. -}; -typedef struct NVGglyphPosition NVGglyphPosition; - -struct NVGtextRow { - const char* start; // Pointer to the input text where the row starts. - const char* end; // Pointer to the input text where the row ends (one past the last character). - const char* next; // Pointer to the beginning of the next row. - float width; // Logical width of the row. - float minx, maxx; // Actual bounds of the row. Logical with and bounds can differ because of kerning and some parts over extending. -}; -typedef struct NVGtextRow NVGtextRow; - -enum NVGimageFlags { - NVG_IMAGE_GENERATE_MIPMAPS = 1<<0, // Generate mipmaps during creation of the image. - NVG_IMAGE_REPEATX = 1<<1, // Repeat image in X direction. - NVG_IMAGE_REPEATY = 1<<2, // Repeat image in Y direction. - NVG_IMAGE_FLIPY = 1<<3, // Flips (inverses) image in Y direction when rendered. - NVG_IMAGE_PREMULTIPLIED = 1<<4, // Image data has premultiplied alpha. -}; - -// Begin drawing a new frame -// Calls to nanovg drawing API should be wrapped in nvgBeginFrame() & nvgEndFrame() -// nvgBeginFrame() defines the size of the window to render to in relation currently -// set viewport (i.e. glViewport on GL backends). Device pixel ration allows to -// control the rendering on Hi-DPI devices. -// For example, GLFW returns two dimension for an opened window: window size and -// frame buffer size. In that case you would set windowWidth/Height to the window size -// devicePixelRatio to: frameBufferWidth / windowWidth. -void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio); - -// Cancels drawing the current frame. -void nvgCancelFrame(NVGcontext* ctx); - -// Ends drawing flushing remaining render state. -void nvgEndFrame(NVGcontext* ctx); - -// -// Composite operation -// -// The composite operations in NanoVG are modeled after HTML Canvas API, and -// the blend func is based on OpenGL (see corresponding manuals for more info). -// The colors in the blending state have premultiplied alpha. - -// Sets the composite operation. The op parameter should be one of NVGcompositeOperation. -void nvgGlobalCompositeOperation(NVGcontext* ctx, int op); - -// Sets the composite operation with custom pixel arithmetic. The parameters should be one of NVGblendFactor. -void nvgGlobalCompositeBlendFunc(NVGcontext* ctx, int sfactor, int dfactor); - -// Sets the composite operation with custom pixel arithmetic for RGB and alpha components separately. The parameters should be one of NVGblendFactor. -void nvgGlobalCompositeBlendFuncSeparate(NVGcontext* ctx, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha); - -// -// Color utils -// -// Colors in NanoVG are stored as unsigned ints in ABGR format. - -// Returns a color value from red, green, blue values. Alpha will be set to 255 (1.0f). -NVGcolor nvgRGB(unsigned char r, unsigned char g, unsigned char b); - -// Returns a color value from red, green, blue values. Alpha will be set to 1.0f. -NVGcolor nvgRGBf(float r, float g, float b); - - -// Returns a color value from red, green, blue and alpha values. -NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); - -// Returns a color value from red, green, blue and alpha values. -NVGcolor nvgRGBAf(float r, float g, float b, float a); - - -// Linearly interpolates from color c0 to c1, and returns resulting color value. -NVGcolor nvgLerpRGBA(NVGcolor c0, NVGcolor c1, float u); - -// Sets transparency of a color value. -NVGcolor nvgTransRGBA(NVGcolor c0, unsigned char a); - -// Sets transparency of a color value. -NVGcolor nvgTransRGBAf(NVGcolor c0, float a); - -// Returns color value specified by hue, saturation and lightness. -// HSL values are all in range [0..1], alpha will be set to 255. -NVGcolor nvgHSL(float h, float s, float l); - -// Returns color value specified by hue, saturation and lightness and alpha. -// HSL values are all in range [0..1], alpha in range [0..255] -NVGcolor nvgHSLA(float h, float s, float l, unsigned char a); - -// -// State Handling -// -// NanoVG contains state which represents how paths will be rendered. -// The state contains transform, fill and stroke styles, text and font styles, -// and scissor clipping. - -// Pushes and saves the current render state into a state stack. -// A matching nvgRestore() must be used to restore the state. -void nvgSave(NVGcontext* ctx); - -// Pops and restores current render state. -void nvgRestore(NVGcontext* ctx); - -// Resets current render state to default values. Does not affect the render state stack. -void nvgReset(NVGcontext* ctx); - -// -// Render styles -// -// Fill and stroke render style can be either a solid color or a paint which is a gradient or a pattern. -// Solid color is simply defined as a color value, different kinds of paints can be created -// using nvgLinearGradient(), nvgBoxGradient(), nvgRadialGradient() and nvgImagePattern(). -// -// Current render style can be saved and restored using nvgSave() and nvgRestore(). - -// Sets current stroke style to a solid color. -void nvgStrokeColor(NVGcontext* ctx, NVGcolor color); - -// Sets current stroke style to a paint, which can be a one of the gradients or a pattern. -void nvgStrokePaint(NVGcontext* ctx, NVGpaint paint); - -// Sets current fill style to a solid color. -void nvgFillColor(NVGcontext* ctx, NVGcolor color); - -// Sets current fill style to a paint, which can be a one of the gradients or a pattern. -void nvgFillPaint(NVGcontext* ctx, NVGpaint paint); - -// Sets the miter limit of the stroke style. -// Miter limit controls when a sharp corner is beveled. -void nvgMiterLimit(NVGcontext* ctx, float limit); - -// Sets the stroke width of the stroke style. -void nvgStrokeWidth(NVGcontext* ctx, float size); - -// Sets how the end of the line (cap) is drawn, -// Can be one of: NVG_BUTT (default), NVG_ROUND, NVG_SQUARE. -void nvgLineCap(NVGcontext* ctx, int cap); - -// Sets how sharp path corners are drawn. -// Can be one of NVG_MITER (default), NVG_ROUND, NVG_BEVEL. -void nvgLineJoin(NVGcontext* ctx, int join); - -// Sets the transparency applied to all rendered shapes. -// Already transparent paths will get proportionally more transparent as well. -void nvgGlobalAlpha(NVGcontext* ctx, float alpha); - -// -// Transforms -// -// The paths, gradients, patterns and scissor region are transformed by an transformation -// matrix at the time when they are passed to the API. -// The current transformation matrix is a affine matrix: -// [sx kx tx] -// [ky sy ty] -// [ 0 0 1] -// Where: sx,sy define scaling, kx,ky skewing, and tx,ty translation. -// The last row is assumed to be 0,0,1 and is not stored. -// -// Apart from nvgResetTransform(), each transformation function first creates -// specific transformation matrix and pre-multiplies the current transformation by it. -// -// Current coordinate system (transformation) can be saved and restored using nvgSave() and nvgRestore(). - -// Resets current transform to a identity matrix. -void nvgResetTransform(NVGcontext* ctx); - -// Premultiplies current coordinate system by specified matrix. -// The parameters are interpreted as matrix as follows: -// [a c e] -// [b d f] -// [0 0 1] -void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e, float f); - -// Translates current coordinate system. -void nvgTranslate(NVGcontext* ctx, float x, float y); - -// Rotates current coordinate system. Angle is specified in radians. -void nvgRotate(NVGcontext* ctx, float angle); - -// Skews the current coordinate system along X axis. Angle is specified in radians. -void nvgSkewX(NVGcontext* ctx, float angle); - -// Skews the current coordinate system along Y axis. Angle is specified in radians. -void nvgSkewY(NVGcontext* ctx, float angle); - -// Scales the current coordinate system. -void nvgScale(NVGcontext* ctx, float x, float y); - -// Stores the top part (a-f) of the current transformation matrix in to the specified buffer. -// [a c e] -// [b d f] -// [0 0 1] -// There should be space for 6 floats in the return buffer for the values a-f. -void nvgCurrentTransform(NVGcontext* ctx, float* xform); - - -// The following functions can be used to make calculations on 2x3 transformation matrices. -// A 2x3 matrix is represented as float[6]. - -// Sets the transform to identity matrix. -void nvgTransformIdentity(float* dst); - -// Sets the transform to translation matrix matrix. -void nvgTransformTranslate(float* dst, float tx, float ty); - -// Sets the transform to scale matrix. -void nvgTransformScale(float* dst, float sx, float sy); - -// Sets the transform to rotate matrix. Angle is specified in radians. -void nvgTransformRotate(float* dst, float a); - -// Sets the transform to skew-x matrix. Angle is specified in radians. -void nvgTransformSkewX(float* dst, float a); - -// Sets the transform to skew-y matrix. Angle is specified in radians. -void nvgTransformSkewY(float* dst, float a); - -// Sets the transform to the result of multiplication of two transforms, of A = A*B. -void nvgTransformMultiply(float* dst, const float* src); - -// Sets the transform to the result of multiplication of two transforms, of A = B*A. -void nvgTransformPremultiply(float* dst, const float* src); - -// Sets the destination to inverse of specified transform. -// Returns 1 if the inverse could be calculated, else 0. -int nvgTransformInverse(float* dst, const float* src); - -// Transform a point by given transform. -void nvgTransformPoint(float* dstx, float* dsty, const float* xform, float srcx, float srcy); - -// Converts degrees to radians and vice versa. -float nvgDegToRad(float deg); -float nvgRadToDeg(float rad); - -// -// Images -// -// NanoVG allows you to load jpg, png, psd, tga, pic and gif files to be used for rendering. -// In addition you can upload your own image. The image loading is provided by stb_image. -// The parameter imageFlags is combination of flags defined in NVGimageFlags. - -// Creates image by loading it from the disk from specified file name. -// Returns handle to the image. -int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags); - -// Creates image by loading it from the specified chunk of memory. -// Returns handle to the image. -int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata); - -// Creates image from specified image data. -// Returns handle to the image. -int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data); - -// Updates image data specified by image handle. -void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data); - -// Returns the dimensions of a created image. -void nvgImageSize(NVGcontext* ctx, int image, int* w, int* h); - -// Deletes created image. -void nvgDeleteImage(NVGcontext* ctx, int image); - -// -// Paints -// -// NanoVG supports four types of paints: linear gradient, box gradient, radial gradient and image pattern. -// These can be used as paints for strokes and fills. - -// Creates and returns a linear gradient. Parameters (sx,sy)-(ex,ey) specify the start and end coordinates -// of the linear gradient, icol specifies the start color and ocol the end color. -// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). -NVGpaint nvgLinearGradient(NVGcontext* ctx, float sx, float sy, float ex, float ey, - NVGcolor icol, NVGcolor ocol); - -// Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering -// drop shadows or highlights for boxes. Parameters (x,y) define the top-left corner of the rectangle, -// (w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry -// the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient. -// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). -NVGpaint nvgBoxGradient(NVGcontext* ctx, float x, float y, float w, float h, - float r, float f, NVGcolor icol, NVGcolor ocol); - -// Creates and returns a radial gradient. Parameters (cx,cy) specify the center, inr and outr specify -// the inner and outer radius of the gradient, icol specifies the start color and ocol the end color. -// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). -NVGpaint nvgRadialGradient(NVGcontext* ctx, float cx, float cy, float inr, float outr, - NVGcolor icol, NVGcolor ocol); - -// Creates and returns an image patter. Parameters (ox,oy) specify the left-top location of the image pattern, -// (ex,ey) the size of one image, angle rotation around the top-left corner, image is handle to the image to render. -// The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). -NVGpaint nvgImagePattern(NVGcontext* ctx, float ox, float oy, float ex, float ey, - float angle, int image, float alpha); - -// -// Scissoring -// -// Scissoring allows you to clip the rendering into a rectangle. This is useful for various -// user interface cases like rendering a text edit or a timeline. - -// Sets the current scissor rectangle. -// The scissor rectangle is transformed by the current transform. -void nvgScissor(NVGcontext* ctx, float x, float y, float w, float h); - -// Intersects current scissor rectangle with the specified rectangle. -// The scissor rectangle is transformed by the current transform. -// Note: in case the rotation of previous scissor rect differs from -// the current one, the intersection will be done between the specified -// rectangle and the previous scissor rectangle transformed in the current -// transform space. The resulting shape is always rectangle. -void nvgIntersectScissor(NVGcontext* ctx, float x, float y, float w, float h); - -// Reset and disables scissoring. -void nvgResetScissor(NVGcontext* ctx); - -// -// Paths -// -// Drawing a new shape starts with nvgBeginPath(), it clears all the currently defined paths. -// Then you define one or more paths and sub-paths which describe the shape. The are functions -// to draw common shapes like rectangles and circles, and lower level step-by-step functions, -// which allow to define a path curve by curve. -// -// NanoVG uses even-odd fill rule to draw the shapes. Solid shapes should have counter clockwise -// winding and holes should have counter clockwise order. To specify winding of a path you can -// call nvgPathWinding(). This is useful especially for the common shapes, which are drawn CCW. -// -// Finally you can fill the path using current fill style by calling nvgFill(), and stroke it -// with current stroke style by calling nvgStroke(). -// -// The curve segments and sub-paths are transformed by the current transform. - -// Clears the current path and sub-paths. -void nvgBeginPath(NVGcontext* ctx); - -// Starts new sub-path with specified point as first point. -void nvgMoveTo(NVGcontext* ctx, float x, float y); - -// Adds line segment from the last point in the path to the specified point. -void nvgLineTo(NVGcontext* ctx, float x, float y); - -// Adds cubic bezier segment from last point in the path via two control points to the specified point. -void nvgBezierTo(NVGcontext* ctx, float c1x, float c1y, float c2x, float c2y, float x, float y); - -// Adds quadratic bezier segment from last point in the path via a control point to the specified point. -void nvgQuadTo(NVGcontext* ctx, float cx, float cy, float x, float y); - -// Adds an arc segment at the corner defined by the last path point, and two specified points. -void nvgArcTo(NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius); - -// Closes current sub-path with a line segment. -void nvgClosePath(NVGcontext* ctx); - -// Sets the current sub-path winding, see NVGwinding and NVGsolidity. -void nvgPathWinding(NVGcontext* ctx, int dir); - -// Creates new circle arc shaped sub-path. The arc center is at cx,cy, the arc radius is r, -// and the arc is drawn from angle a0 to a1, and swept in direction dir (NVG_CCW, or NVG_CW). -// Angles are specified in radians. -void nvgArc(NVGcontext* ctx, float cx, float cy, float r, float a0, float a1, int dir); - -// Creates new rectangle shaped sub-path. -void nvgRect(NVGcontext* ctx, float x, float y, float w, float h); - -// Creates new rounded rectangle shaped sub-path. -void nvgRoundedRect(NVGcontext* ctx, float x, float y, float w, float h, float r); - -// Creates new rounded rectangle shaped sub-path with varying radii for each corner. -void nvgRoundedRectVarying(NVGcontext* ctx, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft); - -// Creates new ellipse shaped sub-path. -void nvgEllipse(NVGcontext* ctx, float cx, float cy, float rx, float ry); - -// Creates new circle shaped sub-path. -void nvgCircle(NVGcontext* ctx, float cx, float cy, float r); - -// Fills the current path with current fill style. -void nvgFill(NVGcontext* ctx); - -// Fills the current path with current stroke style. -void nvgStroke(NVGcontext* ctx); - - -// -// Text -// -// NanoVG allows you to load .ttf files and use the font to render text. -// -// The appearance of the text can be defined by setting the current text style -// and by specifying the fill color. Common text and font settings such as -// font size, letter spacing and text align are supported. Font blur allows you -// to create simple text effects such as drop shadows. -// -// At render time the font face can be set based on the font handles or name. -// -// Font measure functions return values in local space, the calculations are -// carried in the same resolution as the final rendering. This is done because -// the text glyph positions are snapped to the nearest pixels sharp rendering. -// -// The local space means that values are not rotated or scale as per the current -// transformation. For example if you set font size to 12, which would mean that -// line height is 16, then regardless of the current scaling and rotation, the -// returned line height is always 16. Some measures may vary because of the scaling -// since aforementioned pixel snapping. -// -// While this may sound a little odd, the setup allows you to always render the -// same way regardless of scaling. I.e. following works regardless of scaling: -// -// const char* txt = "Text me up."; -// nvgTextBounds(vg, x,y, txt, NULL, bounds); -// nvgBeginPath(vg); -// nvgRoundedRect(vg, bounds[0],bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]); -// nvgFill(vg); -// -// Note: currently only solid color fill is supported for text. - -// Creates font by loading it from the disk from specified file name. -// Returns handle to the font. -int nvgCreateFont(NVGcontext* ctx, const char* name, const char* filename); - -// Creates font by loading it from the specified memory chunk. -// Returns handle to the font. -int nvgCreateFontMem(NVGcontext* ctx, const char* name, unsigned char* data, int ndata, int freeData); - -// Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found. -int nvgFindFont(NVGcontext* ctx, const char* name); - -// Adds a fallback font by handle. -int nvgAddFallbackFontId(NVGcontext* ctx, int baseFont, int fallbackFont); - -// Adds a fallback font by name. -int nvgAddFallbackFont(NVGcontext* ctx, const char* baseFont, const char* fallbackFont); - -// Sets the font size of current text style. -void nvgFontSize(NVGcontext* ctx, float size); - -// Sets the blur of current text style. -void nvgFontBlur(NVGcontext* ctx, float blur); - -// Sets the letter spacing of current text style. -void nvgTextLetterSpacing(NVGcontext* ctx, float spacing); - -// Sets the proportional line height of current text style. The line height is specified as multiple of font size. -void nvgTextLineHeight(NVGcontext* ctx, float lineHeight); - -// Sets the text align of current text style, see NVGalign for options. -void nvgTextAlign(NVGcontext* ctx, int align); - -// Sets the font face based on specified id of current text style. -void nvgFontFaceId(NVGcontext* ctx, int font); - -// Sets the font face based on specified name of current text style. -void nvgFontFace(NVGcontext* ctx, const char* font); - -// Draws text string at specified location. If end is specified only the sub-string up to the end is drawn. -float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char* end); - -// Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn. -// White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. -// Words longer than the max width are slit at nearest character (i.e. no hyphenation). -void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end); - -// Measures the specified text string. Parameter bounds should be a pointer to float[4], -// if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax] -// Returns the horizontal advance of the measured text (i.e. where the next character should drawn). -// Measured values are returned in local coordinate space. -float nvgTextBounds(NVGcontext* ctx, float x, float y, const char* string, const char* end, float* bounds); - -// Measures the specified multi-text string. Parameter bounds should be a pointer to float[4], -// if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax] -// Measured values are returned in local coordinate space. -void nvgTextBoxBounds(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end, float* bounds); - -// Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used. -// Measured values are returned in local coordinate space. -int nvgTextGlyphPositions(NVGcontext* ctx, float x, float y, const char* string, const char* end, NVGglyphPosition* positions, int maxPositions); - -// Returns the vertical metrics based on the current text style. -// Measured values are returned in local coordinate space. -void nvgTextMetrics(NVGcontext* ctx, float* ascender, float* descender, float* lineh); - -// Breaks the specified text into lines. If end is specified only the sub-string will be used. -// White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. -// Words longer than the max width are slit at nearest character (i.e. no hyphenation). -int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, float breakRowWidth, NVGtextRow* rows, int maxRows); - -// -// Internal Render API -// -enum NVGtexture { - NVG_TEXTURE_ALPHA = 0x01, - NVG_TEXTURE_RGBA = 0x02, -}; - -struct NVGscissor { - float xform[6]; - float extent[2]; -}; -typedef struct NVGscissor NVGscissor; - -struct NVGvertex { - float x,y,u,v; -}; -typedef struct NVGvertex NVGvertex; - -struct NVGpath { - int first; - int count; - unsigned char closed; - int nbevel; - NVGvertex* fill; - int nfill; - NVGvertex* stroke; - int nstroke; - int winding; - int convex; -}; -typedef struct NVGpath NVGpath; - -struct NVGparams { - void* userPtr; - int edgeAntiAlias; - int (*renderCreate)(void* uptr); - int (*renderCreateTexture)(void* uptr, int type, int w, int h, int imageFlags, const unsigned char* data); - int (*renderDeleteTexture)(void* uptr, int image); - int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data); - int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h); - void (*renderViewport)(void* uptr, int width, int height, float devicePixelRatio); - void (*renderCancel)(void* uptr); - void (*renderFlush)(void* uptr, NVGcompositeOperationState compositeOperation); - void (*renderFill)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths); - void (*renderStroke)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, float strokeWidth, const NVGpath* paths, int npaths); - void (*renderTriangles)(void* uptr, NVGpaint* paint, NVGscissor* scissor, const NVGvertex* verts, int nverts); - void (*renderDelete)(void* uptr); -}; -typedef struct NVGparams NVGparams; - -// Constructor and destructor, called by the render back-end. -NVGcontext* nvgCreateInternal(NVGparams* params); -void nvgDeleteInternal(NVGcontext* ctx); - -NVGparams* nvgInternalParams(NVGcontext* ctx); - -// Debug function to dump cached path data. -void nvgDebugDumpPathCache(NVGcontext* ctx); - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#define NVG_NOTUSED(v) for (;;) { (void)(1 ? (void)0 : ( (void)(v) ) ); break; } - -#ifdef __cplusplus -} -#endif - -#endif // NANOVG_H diff --git a/phonelibs/nanovg/nanovg_gl.h b/phonelibs/nanovg/nanovg_gl.h deleted file mode 100644 index c050067321993d..00000000000000 --- a/phonelibs/nanovg/nanovg_gl.h +++ /dev/null @@ -1,1592 +0,0 @@ -// -// Copyright (c) 2009-2013 Mikko Mononen memon@inside.org -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. 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. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// -#ifndef NANOVG_GL_H -#define NANOVG_GL_H - -#ifdef __cplusplus -extern "C" { -#endif - -// Create flags - -enum NVGcreateFlags { - // Flag indicating if geometry based anti-aliasing is used (may not be needed when using MSAA). - NVG_ANTIALIAS = 1<<0, - // Flag indicating if strokes should be drawn using stencil buffer. The rendering will be a little - // slower, but path overlaps (i.e. self-intersecting or sharp turns) will be drawn just once. - NVG_STENCIL_STROKES = 1<<1, - // Flag indicating that additional debug checks are done. - NVG_DEBUG = 1<<2, -}; - -#if defined NANOVG_GL2_IMPLEMENTATION -# define NANOVG_GL2 1 -# define NANOVG_GL_IMPLEMENTATION 1 -#elif defined NANOVG_GL3_IMPLEMENTATION -# define NANOVG_GL3 1 -# define NANOVG_GL_IMPLEMENTATION 1 -# define NANOVG_GL_USE_UNIFORMBUFFER 1 -#elif defined NANOVG_GLES2_IMPLEMENTATION -# define NANOVG_GLES2 1 -# define NANOVG_GL_IMPLEMENTATION 1 -#elif defined NANOVG_GLES3_IMPLEMENTATION -# define NANOVG_GLES3 1 -# define NANOVG_GL_IMPLEMENTATION 1 -#endif - -#define NANOVG_GL_USE_STATE_FILTER (1) - -// Creates NanoVG contexts for different OpenGL (ES) versions. -// Flags should be combination of the create flags above. - -#if defined NANOVG_GL2 - -NVGcontext* nvgCreateGL2(int flags); -void nvgDeleteGL2(NVGcontext* ctx); - -int nvglCreateImageFromHandleGL2(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); -GLuint nvglImageHandleGL2(NVGcontext* ctx, int image); - -#endif - -#if defined NANOVG_GL3 - -NVGcontext* nvgCreateGL3(int flags); -void nvgDeleteGL3(NVGcontext* ctx); - -int nvglCreateImageFromHandleGL3(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); -GLuint nvglImageHandleGL3(NVGcontext* ctx, int image); - -#endif - -#if defined NANOVG_GLES2 - -NVGcontext* nvgCreateGLES2(int flags); -void nvgDeleteGLES2(NVGcontext* ctx); - -int nvglCreateImageFromHandleGLES2(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); -GLuint nvglImageHandleGLES2(NVGcontext* ctx, int image); - -#endif - -#if defined NANOVG_GLES3 - -NVGcontext* nvgCreateGLES3(int flags); -void nvgDeleteGLES3(NVGcontext* ctx); - -int nvglCreateImageFromHandleGLES3(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); -GLuint nvglImageHandleGLES3(NVGcontext* ctx, int image); - -#endif - -// These are additional flags on top of NVGimageFlags. -enum NVGimageFlagsGL { - NVG_IMAGE_NODELETE = 1<<16, // Do not delete GL texture handle. -}; - -#ifdef __cplusplus -} -#endif - -#endif /* NANOVG_GL_H */ - -#ifdef NANOVG_GL_IMPLEMENTATION - -#include -#include -#include -#include -#include "nanovg.h" - -enum GLNVGuniformLoc { - GLNVG_LOC_VIEWSIZE, - GLNVG_LOC_TEX, - GLNVG_LOC_FRAG, - GLNVG_MAX_LOCS -}; - -enum GLNVGshaderType { - NSVG_SHADER_FILLGRAD, - NSVG_SHADER_FILLIMG, - NSVG_SHADER_SIMPLE, - NSVG_SHADER_IMG -}; - -#if NANOVG_GL_USE_UNIFORMBUFFER -enum GLNVGuniformBindings { - GLNVG_FRAG_BINDING = 0, -}; -#endif - -struct GLNVGshader { - GLuint prog; - GLuint frag; - GLuint vert; - GLint loc[GLNVG_MAX_LOCS]; -}; -typedef struct GLNVGshader GLNVGshader; - -struct GLNVGtexture { - int id; - GLuint tex; - int width, height; - int type; - int flags; -}; -typedef struct GLNVGtexture GLNVGtexture; - -enum GLNVGcallType { - GLNVG_NONE = 0, - GLNVG_FILL, - GLNVG_CONVEXFILL, - GLNVG_STROKE, - GLNVG_TRIANGLES, -}; - -struct GLNVGcall { - int type; - int image; - int pathOffset; - int pathCount; - int triangleOffset; - int triangleCount; - int uniformOffset; -}; -typedef struct GLNVGcall GLNVGcall; - -struct GLNVGpath { - int fillOffset; - int fillCount; - int strokeOffset; - int strokeCount; -}; -typedef struct GLNVGpath GLNVGpath; - -struct GLNVGfragUniforms { - #if NANOVG_GL_USE_UNIFORMBUFFER - float scissorMat[12]; // matrices are actually 3 vec4s - float paintMat[12]; - struct NVGcolor innerCol; - struct NVGcolor outerCol; - float scissorExt[2]; - float scissorScale[2]; - float extent[2]; - float radius; - float feather; - float strokeMult; - float strokeThr; - int texType; - int type; - #else - // note: after modifying layout or size of uniform array, - // don't forget to also update the fragment shader source! - #define NANOVG_GL_UNIFORMARRAY_SIZE 11 - union { - struct { - float scissorMat[12]; // matrices are actually 3 vec4s - float paintMat[12]; - struct NVGcolor innerCol; - struct NVGcolor outerCol; - float scissorExt[2]; - float scissorScale[2]; - float extent[2]; - float radius; - float feather; - float strokeMult; - float strokeThr; - float texType; - float type; - }; - float uniformArray[NANOVG_GL_UNIFORMARRAY_SIZE][4]; - }; - #endif -}; -typedef struct GLNVGfragUniforms GLNVGfragUniforms; - -struct GLNVGcontext { - GLNVGshader shader; - GLNVGtexture* textures; - float view[2]; - int ntextures; - int ctextures; - int textureId; - GLuint vertBuf; -#if defined NANOVG_GL3 - GLuint vertArr; -#endif -#if NANOVG_GL_USE_UNIFORMBUFFER - GLuint fragBuf; -#endif - int fragSize; - int flags; - - // Per frame buffers - GLNVGcall* calls; - int ccalls; - int ncalls; - GLNVGpath* paths; - int cpaths; - int npaths; - struct NVGvertex* verts; - int cverts; - int nverts; - unsigned char* uniforms; - int cuniforms; - int nuniforms; - - // cached state - #if NANOVG_GL_USE_STATE_FILTER - GLuint boundTexture; - GLuint stencilMask; - GLenum stencilFunc; - GLint stencilFuncRef; - GLuint stencilFuncMask; - #endif -}; -typedef struct GLNVGcontext GLNVGcontext; - -static int glnvg__maxi(int a, int b) { return a > b ? a : b; } - -#ifdef NANOVG_GLES2 -static unsigned int glnvg__nearestPow2(unsigned int num) -{ - unsigned n = num > 0 ? num - 1 : 0; - n |= n >> 1; - n |= n >> 2; - n |= n >> 4; - n |= n >> 8; - n |= n >> 16; - n++; - return n; -} -#endif - -static void glnvg__bindTexture(GLNVGcontext* gl, GLuint tex) -{ -#if NANOVG_GL_USE_STATE_FILTER - if (gl->boundTexture != tex) { - gl->boundTexture = tex; - glBindTexture(GL_TEXTURE_2D, tex); - } -#else - glBindTexture(GL_TEXTURE_2D, tex); -#endif -} - -static void glnvg__stencilMask(GLNVGcontext* gl, GLuint mask) -{ -#if NANOVG_GL_USE_STATE_FILTER - if (gl->stencilMask != mask) { - gl->stencilMask = mask; - glStencilMask(mask); - } -#else - glStencilMask(mask); -#endif -} - -static void glnvg__stencilFunc(GLNVGcontext* gl, GLenum func, GLint ref, GLuint mask) -{ -#if NANOVG_GL_USE_STATE_FILTER - if ((gl->stencilFunc != func) || - (gl->stencilFuncRef != ref) || - (gl->stencilFuncMask != mask)) { - - gl->stencilFunc = func; - gl->stencilFuncRef = ref; - gl->stencilFuncMask = mask; - glStencilFunc(func, ref, mask); - } -#else - glStencilFunc(func, ref, mask); -#endif -} - -static GLNVGtexture* glnvg__allocTexture(GLNVGcontext* gl) -{ - GLNVGtexture* tex = NULL; - int i; - - for (i = 0; i < gl->ntextures; i++) { - if (gl->textures[i].id == 0) { - tex = &gl->textures[i]; - break; - } - } - if (tex == NULL) { - if (gl->ntextures+1 > gl->ctextures) { - GLNVGtexture* textures; - int ctextures = glnvg__maxi(gl->ntextures+1, 4) + gl->ctextures/2; // 1.5x Overallocate - textures = (GLNVGtexture*)realloc(gl->textures, sizeof(GLNVGtexture)*ctextures); - if (textures == NULL) return NULL; - gl->textures = textures; - gl->ctextures = ctextures; - } - tex = &gl->textures[gl->ntextures++]; - } - - memset(tex, 0, sizeof(*tex)); - tex->id = ++gl->textureId; - - return tex; -} - -static GLNVGtexture* glnvg__findTexture(GLNVGcontext* gl, int id) -{ - int i; - for (i = 0; i < gl->ntextures; i++) - if (gl->textures[i].id == id) - return &gl->textures[i]; - return NULL; -} - -static int glnvg__deleteTexture(GLNVGcontext* gl, int id) -{ - int i; - for (i = 0; i < gl->ntextures; i++) { - if (gl->textures[i].id == id) { - if (gl->textures[i].tex != 0 && (gl->textures[i].flags & NVG_IMAGE_NODELETE) == 0) - glDeleteTextures(1, &gl->textures[i].tex); - memset(&gl->textures[i], 0, sizeof(gl->textures[i])); - return 1; - } - } - return 0; -} - -static void glnvg__dumpShaderError(GLuint shader, const char* name, const char* type) -{ - GLchar str[512+1]; - GLsizei len = 0; - glGetShaderInfoLog(shader, 512, &len, str); - if (len > 512) len = 512; - str[len] = '\0'; - printf("Shader %s/%s error:\n%s\n", name, type, str); -} - -static void glnvg__dumpProgramError(GLuint prog, const char* name) -{ - GLchar str[512+1]; - GLsizei len = 0; - glGetProgramInfoLog(prog, 512, &len, str); - if (len > 512) len = 512; - str[len] = '\0'; - printf("Program %s error:\n%s\n", name, str); -} - -static void glnvg__checkError(GLNVGcontext* gl, const char* str) -{ - GLenum err; - if ((gl->flags & NVG_DEBUG) == 0) return; - err = glGetError(); - if (err != GL_NO_ERROR) { - printf("Error %08x after %s\n", err, str); - return; - } -} - -static int glnvg__createShader(GLNVGshader* shader, const char* name, const char* header, const char* opts, const char* vshader, const char* fshader) -{ - GLint status; - GLuint prog, vert, frag; - const char* str[3]; - str[0] = header; - str[1] = opts != NULL ? opts : ""; - - memset(shader, 0, sizeof(*shader)); - - prog = glCreateProgram(); - vert = glCreateShader(GL_VERTEX_SHADER); - frag = glCreateShader(GL_FRAGMENT_SHADER); - str[2] = vshader; - glShaderSource(vert, 3, str, 0); - str[2] = fshader; - glShaderSource(frag, 3, str, 0); - - glCompileShader(vert); - glGetShaderiv(vert, GL_COMPILE_STATUS, &status); - if (status != GL_TRUE) { - glnvg__dumpShaderError(vert, name, "vert"); - return 0; - } - - glCompileShader(frag); - glGetShaderiv(frag, GL_COMPILE_STATUS, &status); - if (status != GL_TRUE) { - glnvg__dumpShaderError(frag, name, "frag"); - return 0; - } - - glAttachShader(prog, vert); - glAttachShader(prog, frag); - - glBindAttribLocation(prog, 0, "vertex"); - glBindAttribLocation(prog, 1, "tcoord"); - - glLinkProgram(prog); - glGetProgramiv(prog, GL_LINK_STATUS, &status); - if (status != GL_TRUE) { - glnvg__dumpProgramError(prog, name); - return 0; - } - - shader->prog = prog; - shader->vert = vert; - shader->frag = frag; - - return 1; -} - -static void glnvg__deleteShader(GLNVGshader* shader) -{ - if (shader->prog != 0) - glDeleteProgram(shader->prog); - if (shader->vert != 0) - glDeleteShader(shader->vert); - if (shader->frag != 0) - glDeleteShader(shader->frag); -} - -static void glnvg__getUniforms(GLNVGshader* shader) -{ - shader->loc[GLNVG_LOC_VIEWSIZE] = glGetUniformLocation(shader->prog, "viewSize"); - shader->loc[GLNVG_LOC_TEX] = glGetUniformLocation(shader->prog, "tex"); - -#if NANOVG_GL_USE_UNIFORMBUFFER - shader->loc[GLNVG_LOC_FRAG] = glGetUniformBlockIndex(shader->prog, "frag"); -#else - shader->loc[GLNVG_LOC_FRAG] = glGetUniformLocation(shader->prog, "frag"); -#endif -} - -static int glnvg__renderCreate(void* uptr) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - int align = 4; - - // TODO: mediump float may not be enough for GLES2 in iOS. - // see the following discussion: https://github.com/memononen/nanovg/issues/46 - static const char* shaderHeader = -#if defined NANOVG_GL2 - "#define NANOVG_GL2 1\n" -#elif defined NANOVG_GL3 - "#version 150 core\n" - "#define NANOVG_GL3 1\n" -#elif defined NANOVG_GLES2 - "#version 100\n" - "#define NANOVG_GL2 1\n" -#elif defined NANOVG_GLES3 - "#version 300 es\n" - "#define NANOVG_GL3 1\n" -#endif - -#if NANOVG_GL_USE_UNIFORMBUFFER - "#define USE_UNIFORMBUFFER 1\n" -#else - "#define UNIFORMARRAY_SIZE 11\n" -#endif - "\n"; - - static const char* fillVertShader = - "#ifdef NANOVG_GL3\n" - " uniform vec2 viewSize;\n" - " in vec2 vertex;\n" - " in vec2 tcoord;\n" - " out vec2 ftcoord;\n" - " out vec2 fpos;\n" - "#else\n" - " uniform vec2 viewSize;\n" - " attribute vec2 vertex;\n" - " attribute vec2 tcoord;\n" - " varying vec2 ftcoord;\n" - " varying vec2 fpos;\n" - "#endif\n" - "void main(void) {\n" - " ftcoord = tcoord;\n" - " fpos = vertex;\n" - " gl_Position = vec4(2.0*vertex.x/viewSize.x - 1.0, 1.0 - 2.0*vertex.y/viewSize.y, 0, 1);\n" - "}\n"; - - static const char* fillFragShader = - "#ifdef GL_ES\n" - "#if defined(GL_FRAGMENT_PRECISION_HIGH) || defined(NANOVG_GL3)\n" - " precision highp float;\n" - "#else\n" - " precision mediump float;\n" - "#endif\n" - "#endif\n" - "#ifdef NANOVG_GL3\n" - "#ifdef USE_UNIFORMBUFFER\n" - " layout(std140) uniform frag {\n" - " mat3 scissorMat;\n" - " mat3 paintMat;\n" - " vec4 innerCol;\n" - " vec4 outerCol;\n" - " vec2 scissorExt;\n" - " vec2 scissorScale;\n" - " vec2 extent;\n" - " float radius;\n" - " float feather;\n" - " float strokeMult;\n" - " float strokeThr;\n" - " int texType;\n" - " int type;\n" - " };\n" - "#else\n" // NANOVG_GL3 && !USE_UNIFORMBUFFER - " uniform vec4 frag[UNIFORMARRAY_SIZE];\n" - "#endif\n" - " uniform sampler2D tex;\n" - " in vec2 ftcoord;\n" - " in vec2 fpos;\n" - " out vec4 outColor;\n" - "#else\n" // !NANOVG_GL3 - " uniform vec4 frag[UNIFORMARRAY_SIZE];\n" - " uniform sampler2D tex;\n" - " varying vec2 ftcoord;\n" - " varying vec2 fpos;\n" - "#endif\n" - "#ifndef USE_UNIFORMBUFFER\n" - " #define scissorMat mat3(frag[0].xyz, frag[1].xyz, frag[2].xyz)\n" - " #define paintMat mat3(frag[3].xyz, frag[4].xyz, frag[5].xyz)\n" - " #define innerCol frag[6]\n" - " #define outerCol frag[7]\n" - " #define scissorExt frag[8].xy\n" - " #define scissorScale frag[8].zw\n" - " #define extent frag[9].xy\n" - " #define radius frag[9].z\n" - " #define feather frag[9].w\n" - " #define strokeMult frag[10].x\n" - " #define strokeThr frag[10].y\n" - " #define texType int(frag[10].z)\n" - " #define type int(frag[10].w)\n" - "#endif\n" - "\n" - "float sdroundrect(vec2 pt, vec2 ext, float rad) {\n" - " vec2 ext2 = ext - vec2(rad,rad);\n" - " vec2 d = abs(pt) - ext2;\n" - " return min(max(d.x,d.y),0.0) + length(max(d,0.0)) - rad;\n" - "}\n" - "\n" - "// Scissoring\n" - "float scissorMask(vec2 p) {\n" - " vec2 sc = (abs((scissorMat * vec3(p,1.0)).xy) - scissorExt);\n" - " sc = vec2(0.5,0.5) - sc * scissorScale;\n" - " return clamp(sc.x,0.0,1.0) * clamp(sc.y,0.0,1.0);\n" - "}\n" - "#ifdef EDGE_AA\n" - "// Stroke - from [0..1] to clipped pyramid, where the slope is 1px.\n" - "float strokeMask() {\n" - " return min(1.0, (1.0-abs(ftcoord.x*2.0-1.0))*strokeMult) * min(1.0, ftcoord.y);\n" - "}\n" - "#endif\n" - "\n" - "void main(void) {\n" - " vec4 result;\n" - " float scissor = scissorMask(fpos);\n" - "#ifdef EDGE_AA\n" - " float strokeAlpha = strokeMask();\n" - "#else\n" - " float strokeAlpha = 1.0;\n" - "#endif\n" - " if (type == 0) { // Gradient\n" - " // Calculate gradient color using box gradient\n" - " vec2 pt = (paintMat * vec3(fpos,1.0)).xy;\n" - " float d = clamp((sdroundrect(pt, extent, radius) + feather*0.5) / feather, 0.0, 1.0);\n" - " vec4 color = mix(innerCol,outerCol,d);\n" - " // Combine alpha\n" - " color *= strokeAlpha * scissor;\n" - " result = color;\n" - " } else if (type == 1) { // Image\n" - " // Calculate color fron texture\n" - " vec2 pt = (paintMat * vec3(fpos,1.0)).xy / extent;\n" - "#ifdef NANOVG_GL3\n" - " vec4 color = texture(tex, pt);\n" - "#else\n" - " vec4 color = texture2D(tex, pt);\n" - "#endif\n" - " if (texType == 1) color = vec4(color.xyz*color.w,color.w);" - " if (texType == 2) color = vec4(color.x);" - " // Apply color tint and alpha.\n" - " color *= innerCol;\n" - " // Combine alpha\n" - " color *= strokeAlpha * scissor;\n" - " result = color;\n" - " } else if (type == 2) { // Stencil fill\n" - " result = vec4(1,1,1,1);\n" - " } else if (type == 3) { // Textured tris\n" - "#ifdef NANOVG_GL3\n" - " vec4 color = texture(tex, ftcoord);\n" - "#else\n" - " vec4 color = texture2D(tex, ftcoord);\n" - "#endif\n" - " if (texType == 1) color = vec4(color.xyz*color.w,color.w);" - " if (texType == 2) color = vec4(color.x);" - " color *= scissor;\n" - " result = color * innerCol;\n" - " }\n" - "#ifdef EDGE_AA\n" - " if (strokeAlpha < strokeThr) discard;\n" - "#endif\n" - "#ifdef NANOVG_GL3\n" - " outColor = result;\n" - "#else\n" - " gl_FragColor = result;\n" - "#endif\n" - "}\n"; - - glnvg__checkError(gl, "init"); - - if (gl->flags & NVG_ANTIALIAS) { - if (glnvg__createShader(&gl->shader, "shader", shaderHeader, "#define EDGE_AA 1\n", fillVertShader, fillFragShader) == 0) - return 0; - } else { - if (glnvg__createShader(&gl->shader, "shader", shaderHeader, NULL, fillVertShader, fillFragShader) == 0) - return 0; - } - - glnvg__checkError(gl, "uniform locations"); - glnvg__getUniforms(&gl->shader); - - // Create dynamic vertex array -#if defined NANOVG_GL3 - glGenVertexArrays(1, &gl->vertArr); -#endif - glGenBuffers(1, &gl->vertBuf); - -#if NANOVG_GL_USE_UNIFORMBUFFER - // Create UBOs - glUniformBlockBinding(gl->shader.prog, gl->shader.loc[GLNVG_LOC_FRAG], GLNVG_FRAG_BINDING); - glGenBuffers(1, &gl->fragBuf); - glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &align); -#endif - gl->fragSize = sizeof(GLNVGfragUniforms) + align - sizeof(GLNVGfragUniforms) % align; - - glnvg__checkError(gl, "create done"); - - glFinish(); - - return 1; -} - -static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, int imageFlags, const unsigned char* data) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - GLNVGtexture* tex = glnvg__allocTexture(gl); - - if (tex == NULL) return 0; - -#ifdef NANOVG_GLES2 - // Check for non-power of 2. - if (glnvg__nearestPow2(w) != (unsigned int)w || glnvg__nearestPow2(h) != (unsigned int)h) { - // No repeat - if ((imageFlags & NVG_IMAGE_REPEATX) != 0 || (imageFlags & NVG_IMAGE_REPEATY) != 0) { - printf("Repeat X/Y is not supported for non power-of-two textures (%d x %d)\n", w, h); - imageFlags &= ~(NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); - } - // No mips. - if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { - printf("Mip-maps is not support for non power-of-two textures (%d x %d)\n", w, h); - imageFlags &= ~NVG_IMAGE_GENERATE_MIPMAPS; - } - } -#endif - - glGenTextures(1, &tex->tex); - tex->width = w; - tex->height = h; - tex->type = type; - tex->flags = imageFlags; - glnvg__bindTexture(gl, tex->tex); - - glPixelStorei(GL_UNPACK_ALIGNMENT,1); -#ifndef NANOVG_GLES2 - glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->width); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); -#endif - -#if defined (NANOVG_GL2) - // GL 1.4 and later has support for generating mipmaps using a tex parameter. - if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - } -#endif - - if (type == NVG_TEXTURE_RGBA) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); - else -#if defined(NANOVG_GLES2) - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); -#elif defined(NANOVG_GLES3) - glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data); -#else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data); -#endif - - if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - if (imageFlags & NVG_IMAGE_REPEATX) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - else - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - - if (imageFlags & NVG_IMAGE_REPEATY) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - else - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); -#ifndef NANOVG_GLES2 - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); -#endif - - // The new way to build mipmaps on GLES and GL3 -#if !defined(NANOVG_GL2) - if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { - glGenerateMipmap(GL_TEXTURE_2D); - } -#endif - - glnvg__checkError(gl, "create tex"); - glnvg__bindTexture(gl, 0); - - return tex->id; -} - - -static int glnvg__renderDeleteTexture(void* uptr, int image) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - return glnvg__deleteTexture(gl, image); -} - -static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - GLNVGtexture* tex = glnvg__findTexture(gl, image); - - if (tex == NULL) return 0; - glnvg__bindTexture(gl, tex->tex); - - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - -#ifndef NANOVG_GLES2 - glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->width); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); - glPixelStorei(GL_UNPACK_SKIP_ROWS, y); -#else - // No support for all of skip, need to update a whole row at a time. - if (tex->type == NVG_TEXTURE_RGBA) - data += y*tex->width*4; - else - data += y*tex->width; - x = 0; - w = tex->width; -#endif - - if (tex->type == NVG_TEXTURE_RGBA) - glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RGBA, GL_UNSIGNED_BYTE, data); - else -#ifdef NANOVG_GLES2 - glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); -#else - glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RED, GL_UNSIGNED_BYTE, data); -#endif - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); -#ifndef NANOVG_GLES2 - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); -#endif - - glnvg__bindTexture(gl, 0); - - return 1; -} - -static int glnvg__renderGetTextureSize(void* uptr, int image, int* w, int* h) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - GLNVGtexture* tex = glnvg__findTexture(gl, image); - if (tex == NULL) return 0; - *w = tex->width; - *h = tex->height; - return 1; -} - -static void glnvg__xformToMat3x4(float* m3, float* t) -{ - m3[0] = t[0]; - m3[1] = t[1]; - m3[2] = 0.0f; - m3[3] = 0.0f; - m3[4] = t[2]; - m3[5] = t[3]; - m3[6] = 0.0f; - m3[7] = 0.0f; - m3[8] = t[4]; - m3[9] = t[5]; - m3[10] = 1.0f; - m3[11] = 0.0f; -} - -static NVGcolor glnvg__premulColor(NVGcolor c) -{ - c.r *= c.a; - c.g *= c.a; - c.b *= c.a; - return c; -} - -static int glnvg__convertPaint(GLNVGcontext* gl, GLNVGfragUniforms* frag, NVGpaint* paint, - NVGscissor* scissor, float width, float fringe, float strokeThr) -{ - GLNVGtexture* tex = NULL; - float invxform[6]; - - memset(frag, 0, sizeof(*frag)); - - frag->innerCol = glnvg__premulColor(paint->innerColor); - frag->outerCol = glnvg__premulColor(paint->outerColor); - - if (scissor->extent[0] < -0.5f || scissor->extent[1] < -0.5f) { - memset(frag->scissorMat, 0, sizeof(frag->scissorMat)); - frag->scissorExt[0] = 1.0f; - frag->scissorExt[1] = 1.0f; - frag->scissorScale[0] = 1.0f; - frag->scissorScale[1] = 1.0f; - } else { - nvgTransformInverse(invxform, scissor->xform); - glnvg__xformToMat3x4(frag->scissorMat, invxform); - frag->scissorExt[0] = scissor->extent[0]; - frag->scissorExt[1] = scissor->extent[1]; - frag->scissorScale[0] = sqrtf(scissor->xform[0]*scissor->xform[0] + scissor->xform[2]*scissor->xform[2]) / fringe; - frag->scissorScale[1] = sqrtf(scissor->xform[1]*scissor->xform[1] + scissor->xform[3]*scissor->xform[3]) / fringe; - } - - memcpy(frag->extent, paint->extent, sizeof(frag->extent)); - frag->strokeMult = (width*0.5f + fringe*0.5f) / fringe; - frag->strokeThr = strokeThr; - - if (paint->image != 0) { - tex = glnvg__findTexture(gl, paint->image); - if (tex == NULL) return 0; - if ((tex->flags & NVG_IMAGE_FLIPY) != 0) { - float m1[6], m2[6]; - nvgTransformTranslate(m1, 0.0f, frag->extent[1] * 0.5f); - nvgTransformMultiply(m1, paint->xform); - nvgTransformScale(m2, 1.0f, -1.0f); - nvgTransformMultiply(m2, m1); - nvgTransformTranslate(m1, 0.0f, -frag->extent[1] * 0.5f); - nvgTransformMultiply(m1, m2); - nvgTransformInverse(invxform, m1); - } else { - nvgTransformInverse(invxform, paint->xform); - } - frag->type = NSVG_SHADER_FILLIMG; - - if (tex->type == NVG_TEXTURE_RGBA) - frag->texType = (tex->flags & NVG_IMAGE_PREMULTIPLIED) ? 0 : 1; - else - frag->texType = 2; -// printf("frag->texType = %d\n", frag->texType); - } else { - frag->type = NSVG_SHADER_FILLGRAD; - frag->radius = paint->radius; - frag->feather = paint->feather; - nvgTransformInverse(invxform, paint->xform); - } - - glnvg__xformToMat3x4(frag->paintMat, invxform); - - return 1; -} - -static GLNVGfragUniforms* nvg__fragUniformPtr(GLNVGcontext* gl, int i); - -static void glnvg__setUniforms(GLNVGcontext* gl, int uniformOffset, int image) -{ -#if NANOVG_GL_USE_UNIFORMBUFFER - glBindBufferRange(GL_UNIFORM_BUFFER, GLNVG_FRAG_BINDING, gl->fragBuf, uniformOffset, sizeof(GLNVGfragUniforms)); -#else - GLNVGfragUniforms* frag = nvg__fragUniformPtr(gl, uniformOffset); - glUniform4fv(gl->shader.loc[GLNVG_LOC_FRAG], NANOVG_GL_UNIFORMARRAY_SIZE, &(frag->uniformArray[0][0])); -#endif - - if (image != 0) { - GLNVGtexture* tex = glnvg__findTexture(gl, image); - glnvg__bindTexture(gl, tex != NULL ? tex->tex : 0); - glnvg__checkError(gl, "tex paint tex"); - } else { - glnvg__bindTexture(gl, 0); - } -} - -static void glnvg__renderViewport(void* uptr, int width, int height, float devicePixelRatio) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - gl->view[0] = (float)width; - gl->view[1] = (float)height; -} - -static void glnvg__fill(GLNVGcontext* gl, GLNVGcall* call) -{ - GLNVGpath* paths = &gl->paths[call->pathOffset]; - int i, npaths = call->pathCount; - - // Draw shapes - glEnable(GL_STENCIL_TEST); - glnvg__stencilMask(gl, 0xff); - glnvg__stencilFunc(gl, GL_ALWAYS, 0, 0xff); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - - // set bindpoint for solid loc - glnvg__setUniforms(gl, call->uniformOffset, 0); - glnvg__checkError(gl, "fill simple"); - - glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR_WRAP); - glStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR_WRAP); - glDisable(GL_CULL_FACE); - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_FAN, paths[i].fillOffset, paths[i].fillCount); - glEnable(GL_CULL_FACE); - - // Draw anti-aliased pixels - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - - glnvg__setUniforms(gl, call->uniformOffset + gl->fragSize, call->image); - glnvg__checkError(gl, "fill fill"); - - if (gl->flags & NVG_ANTIALIAS) { - glnvg__stencilFunc(gl, GL_EQUAL, 0x00, 0xff); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - // Draw fringes - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); - } - - // Draw fill - glnvg__stencilFunc(gl, GL_NOTEQUAL, 0x0, 0xff); - glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); - glDrawArrays(GL_TRIANGLES, call->triangleOffset, call->triangleCount); - - glDisable(GL_STENCIL_TEST); -} - -static void glnvg__convexFill(GLNVGcontext* gl, GLNVGcall* call) -{ - GLNVGpath* paths = &gl->paths[call->pathOffset]; - int i, npaths = call->pathCount; - - glnvg__setUniforms(gl, call->uniformOffset, call->image); - glnvg__checkError(gl, "convex fill"); - - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_FAN, paths[i].fillOffset, paths[i].fillCount); - if (gl->flags & NVG_ANTIALIAS) { - // Draw fringes - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); - } -} - -static void glnvg__stroke(GLNVGcontext* gl, GLNVGcall* call) -{ - GLNVGpath* paths = &gl->paths[call->pathOffset]; - int npaths = call->pathCount, i; - - if (gl->flags & NVG_STENCIL_STROKES) { - - glEnable(GL_STENCIL_TEST); - glnvg__stencilMask(gl, 0xff); - - // Fill the stroke base without overlap - glnvg__stencilFunc(gl, GL_EQUAL, 0x0, 0xff); - glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); - glnvg__setUniforms(gl, call->uniformOffset + gl->fragSize, call->image); - glnvg__checkError(gl, "stroke fill 0"); - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); - - // Draw anti-aliased pixels. - glnvg__setUniforms(gl, call->uniformOffset, call->image); - glnvg__stencilFunc(gl, GL_EQUAL, 0x00, 0xff); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); - - // Clear stencil buffer. - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - glnvg__stencilFunc(gl, GL_ALWAYS, 0x0, 0xff); - glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); - glnvg__checkError(gl, "stroke fill 1"); - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - - glDisable(GL_STENCIL_TEST); - -// glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset + gl->fragSize), paint, scissor, strokeWidth, fringe, 1.0f - 0.5f/255.0f); - - } else { - glnvg__setUniforms(gl, call->uniformOffset, call->image); - glnvg__checkError(gl, "stroke fill"); - // Draw Strokes - for (i = 0; i < npaths; i++) - glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); - } -} - -static void glnvg__triangles(GLNVGcontext* gl, GLNVGcall* call) -{ - glnvg__setUniforms(gl, call->uniformOffset, call->image); - glnvg__checkError(gl, "triangles fill"); - - glDrawArrays(GL_TRIANGLES, call->triangleOffset, call->triangleCount); -} - -static void glnvg__renderCancel(void* uptr) { - GLNVGcontext* gl = (GLNVGcontext*)uptr; - gl->nverts = 0; - gl->npaths = 0; - gl->ncalls = 0; - gl->nuniforms = 0; -} - -static GLenum glnvg_convertBlendFuncFactor(int factor) -{ - if (factor == NVG_ZERO) - return GL_ZERO; - if (factor == NVG_ONE) - return GL_ONE; - if (factor == NVG_SRC_COLOR) - return GL_SRC_COLOR; - if (factor == NVG_ONE_MINUS_SRC_COLOR) - return GL_ONE_MINUS_SRC_COLOR; - if (factor == NVG_DST_COLOR) - return GL_DST_COLOR; - if (factor == NVG_ONE_MINUS_DST_COLOR) - return GL_ONE_MINUS_DST_COLOR; - if (factor == NVG_SRC_ALPHA) - return GL_SRC_ALPHA; - if (factor == NVG_ONE_MINUS_SRC_ALPHA) - return GL_ONE_MINUS_SRC_ALPHA; - if (factor == NVG_DST_ALPHA) - return GL_DST_ALPHA; - if (factor == NVG_ONE_MINUS_DST_ALPHA) - return GL_ONE_MINUS_DST_ALPHA; - if (factor == NVG_SRC_ALPHA_SATURATE) - return GL_SRC_ALPHA_SATURATE; - return GL_INVALID_ENUM; -} - -static void glnvg__blendCompositeOperation(NVGcompositeOperationState op) -{ - GLenum srcRGB = glnvg_convertBlendFuncFactor(op.srcRGB); - GLenum dstRGB = glnvg_convertBlendFuncFactor(op.dstRGB); - GLenum srcAlpha = glnvg_convertBlendFuncFactor(op.srcAlpha); - GLenum dstAlpha = glnvg_convertBlendFuncFactor(op.dstAlpha); - if (srcRGB == GL_INVALID_ENUM || dstRGB == GL_INVALID_ENUM || srcAlpha == GL_INVALID_ENUM || dstAlpha == GL_INVALID_ENUM) - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - else - glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); -} - -static void glnvg__renderFlush(void* uptr, NVGcompositeOperationState compositeOperation) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - int i; - - if (gl->ncalls > 0) { - - // Setup require GL state. - glUseProgram(gl->shader.prog); - - glnvg__blendCompositeOperation(compositeOperation); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - glFrontFace(GL_CCW); - glEnable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glStencilMask(0xffffffff); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - glStencilFunc(GL_ALWAYS, 0, 0xffffffff); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, 0); - #if NANOVG_GL_USE_STATE_FILTER - gl->boundTexture = 0; - gl->stencilMask = 0xffffffff; - gl->stencilFunc = GL_ALWAYS; - gl->stencilFuncRef = 0; - gl->stencilFuncMask = 0xffffffff; - #endif - -#if NANOVG_GL_USE_UNIFORMBUFFER - // Upload ubo for frag shaders - glBindBuffer(GL_UNIFORM_BUFFER, gl->fragBuf); - glBufferData(GL_UNIFORM_BUFFER, gl->nuniforms * gl->fragSize, gl->uniforms, GL_STREAM_DRAW); -#endif - - // Upload vertex data -#if defined NANOVG_GL3 - glBindVertexArray(gl->vertArr); -#endif - glBindBuffer(GL_ARRAY_BUFFER, gl->vertBuf); - glBufferData(GL_ARRAY_BUFFER, gl->nverts * sizeof(NVGvertex), gl->verts, GL_STREAM_DRAW); - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(NVGvertex), (const GLvoid*)(size_t)0); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(NVGvertex), (const GLvoid*)(0 + 2*sizeof(float))); - - // Set view and texture just once per frame. - glUniform1i(gl->shader.loc[GLNVG_LOC_TEX], 0); - glUniform2fv(gl->shader.loc[GLNVG_LOC_VIEWSIZE], 1, gl->view); - -#if NANOVG_GL_USE_UNIFORMBUFFER - glBindBuffer(GL_UNIFORM_BUFFER, gl->fragBuf); -#endif - - for (i = 0; i < gl->ncalls; i++) { - GLNVGcall* call = &gl->calls[i]; - if (call->type == GLNVG_FILL) - glnvg__fill(gl, call); - else if (call->type == GLNVG_CONVEXFILL) - glnvg__convexFill(gl, call); - else if (call->type == GLNVG_STROKE) - glnvg__stroke(gl, call); - else if (call->type == GLNVG_TRIANGLES) - glnvg__triangles(gl, call); - } - - glDisableVertexAttribArray(0); - glDisableVertexAttribArray(1); -#if defined NANOVG_GL3 - glBindVertexArray(0); -#endif - glDisable(GL_CULL_FACE); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glUseProgram(0); - glnvg__bindTexture(gl, 0); - } - - // Reset calls - gl->nverts = 0; - gl->npaths = 0; - gl->ncalls = 0; - gl->nuniforms = 0; -} - -static int glnvg__maxVertCount(const NVGpath* paths, int npaths) -{ - int i, count = 0; - for (i = 0; i < npaths; i++) { - count += paths[i].nfill; - count += paths[i].nstroke; - } - return count; -} - -static GLNVGcall* glnvg__allocCall(GLNVGcontext* gl) -{ - GLNVGcall* ret = NULL; - if (gl->ncalls+1 > gl->ccalls) { - GLNVGcall* calls; - int ccalls = glnvg__maxi(gl->ncalls+1, 128) + gl->ccalls/2; // 1.5x Overallocate - calls = (GLNVGcall*)realloc(gl->calls, sizeof(GLNVGcall) * ccalls); - if (calls == NULL) return NULL; - gl->calls = calls; - gl->ccalls = ccalls; - } - ret = &gl->calls[gl->ncalls++]; - memset(ret, 0, sizeof(GLNVGcall)); - return ret; -} - -static int glnvg__allocPaths(GLNVGcontext* gl, int n) -{ - int ret = 0; - if (gl->npaths+n > gl->cpaths) { - GLNVGpath* paths; - int cpaths = glnvg__maxi(gl->npaths + n, 128) + gl->cpaths/2; // 1.5x Overallocate - paths = (GLNVGpath*)realloc(gl->paths, sizeof(GLNVGpath) * cpaths); - if (paths == NULL) return -1; - gl->paths = paths; - gl->cpaths = cpaths; - } - ret = gl->npaths; - gl->npaths += n; - return ret; -} - -static int glnvg__allocVerts(GLNVGcontext* gl, int n) -{ - int ret = 0; - if (gl->nverts+n > gl->cverts) { - NVGvertex* verts; - int cverts = glnvg__maxi(gl->nverts + n, 4096) + gl->cverts/2; // 1.5x Overallocate - verts = (NVGvertex*)realloc(gl->verts, sizeof(NVGvertex) * cverts); - if (verts == NULL) return -1; - gl->verts = verts; - gl->cverts = cverts; - } - ret = gl->nverts; - gl->nverts += n; - return ret; -} - -static int glnvg__allocFragUniforms(GLNVGcontext* gl, int n) -{ - int ret = 0, structSize = gl->fragSize; - if (gl->nuniforms+n > gl->cuniforms) { - unsigned char* uniforms; - int cuniforms = glnvg__maxi(gl->nuniforms+n, 128) + gl->cuniforms/2; // 1.5x Overallocate - uniforms = (unsigned char*)realloc(gl->uniforms, structSize * cuniforms); - if (uniforms == NULL) return -1; - gl->uniforms = uniforms; - gl->cuniforms = cuniforms; - } - ret = gl->nuniforms * structSize; - gl->nuniforms += n; - return ret; -} - -static GLNVGfragUniforms* nvg__fragUniformPtr(GLNVGcontext* gl, int i) -{ - return (GLNVGfragUniforms*)&gl->uniforms[i]; -} - -static void glnvg__vset(NVGvertex* vtx, float x, float y, float u, float v) -{ - vtx->x = x; - vtx->y = y; - vtx->u = u; - vtx->v = v; -} - -static void glnvg__renderFill(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, - const float* bounds, const NVGpath* paths, int npaths) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - GLNVGcall* call = glnvg__allocCall(gl); - NVGvertex* quad; - GLNVGfragUniforms* frag; - int i, maxverts, offset; - - if (call == NULL) return; - - call->type = GLNVG_FILL; - call->pathOffset = glnvg__allocPaths(gl, npaths); - if (call->pathOffset == -1) goto error; - call->pathCount = npaths; - call->image = paint->image; - - if (npaths == 1 && paths[0].convex) - call->type = GLNVG_CONVEXFILL; - - // Allocate vertices for all the paths. - maxverts = glnvg__maxVertCount(paths, npaths) + 6; - offset = glnvg__allocVerts(gl, maxverts); - if (offset == -1) goto error; - - for (i = 0; i < npaths; i++) { - GLNVGpath* copy = &gl->paths[call->pathOffset + i]; - const NVGpath* path = &paths[i]; - memset(copy, 0, sizeof(GLNVGpath)); - if (path->nfill > 0) { - copy->fillOffset = offset; - copy->fillCount = path->nfill; - memcpy(&gl->verts[offset], path->fill, sizeof(NVGvertex) * path->nfill); - offset += path->nfill; - } - if (path->nstroke > 0) { - copy->strokeOffset = offset; - copy->strokeCount = path->nstroke; - memcpy(&gl->verts[offset], path->stroke, sizeof(NVGvertex) * path->nstroke); - offset += path->nstroke; - } - } - - // Quad - call->triangleOffset = offset; - call->triangleCount = 6; - quad = &gl->verts[call->triangleOffset]; - glnvg__vset(&quad[0], bounds[0], bounds[3], 0.5f, 1.0f); - glnvg__vset(&quad[1], bounds[2], bounds[3], 0.5f, 1.0f); - glnvg__vset(&quad[2], bounds[2], bounds[1], 0.5f, 1.0f); - - glnvg__vset(&quad[3], bounds[0], bounds[3], 0.5f, 1.0f); - glnvg__vset(&quad[4], bounds[2], bounds[1], 0.5f, 1.0f); - glnvg__vset(&quad[5], bounds[0], bounds[1], 0.5f, 1.0f); - - // Setup uniforms for draw calls - if (call->type == GLNVG_FILL) { - call->uniformOffset = glnvg__allocFragUniforms(gl, 2); - if (call->uniformOffset == -1) goto error; - // Simple shader for stencil - frag = nvg__fragUniformPtr(gl, call->uniformOffset); - memset(frag, 0, sizeof(*frag)); - frag->strokeThr = -1.0f; - frag->type = NSVG_SHADER_SIMPLE; - // Fill shader - glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset + gl->fragSize), paint, scissor, fringe, fringe, -1.0f); - } else { - call->uniformOffset = glnvg__allocFragUniforms(gl, 1); - if (call->uniformOffset == -1) goto error; - // Fill shader - glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset), paint, scissor, fringe, fringe, -1.0f); - } - - return; - -error: - // We get here if call alloc was ok, but something else is not. - // Roll back the last call to prevent drawing it. - if (gl->ncalls > 0) gl->ncalls--; -} - -static void glnvg__renderStroke(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, - float strokeWidth, const NVGpath* paths, int npaths) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - GLNVGcall* call = glnvg__allocCall(gl); - int i, maxverts, offset; - - if (call == NULL) return; - - call->type = GLNVG_STROKE; - call->pathOffset = glnvg__allocPaths(gl, npaths); - if (call->pathOffset == -1) goto error; - call->pathCount = npaths; - call->image = paint->image; - - // Allocate vertices for all the paths. - maxverts = glnvg__maxVertCount(paths, npaths); - offset = glnvg__allocVerts(gl, maxverts); - if (offset == -1) goto error; - - for (i = 0; i < npaths; i++) { - GLNVGpath* copy = &gl->paths[call->pathOffset + i]; - const NVGpath* path = &paths[i]; - memset(copy, 0, sizeof(GLNVGpath)); - if (path->nstroke) { - copy->strokeOffset = offset; - copy->strokeCount = path->nstroke; - memcpy(&gl->verts[offset], path->stroke, sizeof(NVGvertex) * path->nstroke); - offset += path->nstroke; - } - } - - if (gl->flags & NVG_STENCIL_STROKES) { - // Fill shader - call->uniformOffset = glnvg__allocFragUniforms(gl, 2); - if (call->uniformOffset == -1) goto error; - - glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset), paint, scissor, strokeWidth, fringe, -1.0f); - glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset + gl->fragSize), paint, scissor, strokeWidth, fringe, 1.0f - 0.5f/255.0f); - - } else { - // Fill shader - call->uniformOffset = glnvg__allocFragUniforms(gl, 1); - if (call->uniformOffset == -1) goto error; - glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset), paint, scissor, strokeWidth, fringe, -1.0f); - } - - return; - -error: - // We get here if call alloc was ok, but something else is not. - // Roll back the last call to prevent drawing it. - if (gl->ncalls > 0) gl->ncalls--; -} - -static void glnvg__renderTriangles(void* uptr, NVGpaint* paint, NVGscissor* scissor, - const NVGvertex* verts, int nverts) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - GLNVGcall* call = glnvg__allocCall(gl); - GLNVGfragUniforms* frag; - - if (call == NULL) return; - - call->type = GLNVG_TRIANGLES; - call->image = paint->image; - - // Allocate vertices for all the paths. - call->triangleOffset = glnvg__allocVerts(gl, nverts); - if (call->triangleOffset == -1) goto error; - call->triangleCount = nverts; - - memcpy(&gl->verts[call->triangleOffset], verts, sizeof(NVGvertex) * nverts); - - // Fill shader - call->uniformOffset = glnvg__allocFragUniforms(gl, 1); - if (call->uniformOffset == -1) goto error; - frag = nvg__fragUniformPtr(gl, call->uniformOffset); - glnvg__convertPaint(gl, frag, paint, scissor, 1.0f, 1.0f, -1.0f); - frag->type = NSVG_SHADER_IMG; - - return; - -error: - // We get here if call alloc was ok, but something else is not. - // Roll back the last call to prevent drawing it. - if (gl->ncalls > 0) gl->ncalls--; -} - -static void glnvg__renderDelete(void* uptr) -{ - GLNVGcontext* gl = (GLNVGcontext*)uptr; - int i; - if (gl == NULL) return; - - glnvg__deleteShader(&gl->shader); - -#if NANOVG_GL3 -#if NANOVG_GL_USE_UNIFORMBUFFER - if (gl->fragBuf != 0) - glDeleteBuffers(1, &gl->fragBuf); -#endif - if (gl->vertArr != 0) - glDeleteVertexArrays(1, &gl->vertArr); -#endif - if (gl->vertBuf != 0) - glDeleteBuffers(1, &gl->vertBuf); - - for (i = 0; i < gl->ntextures; i++) { - if (gl->textures[i].tex != 0 && (gl->textures[i].flags & NVG_IMAGE_NODELETE) == 0) - glDeleteTextures(1, &gl->textures[i].tex); - } - free(gl->textures); - - free(gl->paths); - free(gl->verts); - free(gl->uniforms); - free(gl->calls); - - free(gl); -} - - -#if defined NANOVG_GL2 -NVGcontext* nvgCreateGL2(int flags) -#elif defined NANOVG_GL3 -NVGcontext* nvgCreateGL3(int flags) -#elif defined NANOVG_GLES2 -NVGcontext* nvgCreateGLES2(int flags) -#elif defined NANOVG_GLES3 -NVGcontext* nvgCreateGLES3(int flags) -#endif -{ - NVGparams params; - NVGcontext* ctx = NULL; - GLNVGcontext* gl = (GLNVGcontext*)malloc(sizeof(GLNVGcontext)); - if (gl == NULL) goto error; - memset(gl, 0, sizeof(GLNVGcontext)); - - memset(¶ms, 0, sizeof(params)); - params.renderCreate = glnvg__renderCreate; - params.renderCreateTexture = glnvg__renderCreateTexture; - params.renderDeleteTexture = glnvg__renderDeleteTexture; - params.renderUpdateTexture = glnvg__renderUpdateTexture; - params.renderGetTextureSize = glnvg__renderGetTextureSize; - params.renderViewport = glnvg__renderViewport; - params.renderCancel = glnvg__renderCancel; - params.renderFlush = glnvg__renderFlush; - params.renderFill = glnvg__renderFill; - params.renderStroke = glnvg__renderStroke; - params.renderTriangles = glnvg__renderTriangles; - params.renderDelete = glnvg__renderDelete; - params.userPtr = gl; - params.edgeAntiAlias = flags & NVG_ANTIALIAS ? 1 : 0; - - gl->flags = flags; - - ctx = nvgCreateInternal(¶ms); - if (ctx == NULL) goto error; - - return ctx; - -error: - // 'gl' is freed by nvgDeleteInternal. - if (ctx != NULL) nvgDeleteInternal(ctx); - return NULL; -} - -#if defined NANOVG_GL2 -void nvgDeleteGL2(NVGcontext* ctx) -#elif defined NANOVG_GL3 -void nvgDeleteGL3(NVGcontext* ctx) -#elif defined NANOVG_GLES2 -void nvgDeleteGLES2(NVGcontext* ctx) -#elif defined NANOVG_GLES3 -void nvgDeleteGLES3(NVGcontext* ctx) -#endif -{ - nvgDeleteInternal(ctx); -} - -#if defined NANOVG_GL2 -int nvglCreateImageFromHandleGL2(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) -#elif defined NANOVG_GL3 -int nvglCreateImageFromHandleGL3(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) -#elif defined NANOVG_GLES2 -int nvglCreateImageFromHandleGLES2(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) -#elif defined NANOVG_GLES3 -int nvglCreateImageFromHandleGLES3(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) -#endif -{ - GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(ctx)->userPtr; - GLNVGtexture* tex = glnvg__allocTexture(gl); - - if (tex == NULL) return 0; - - tex->type = NVG_TEXTURE_RGBA; - tex->tex = textureId; - tex->flags = imageFlags; - tex->width = w; - tex->height = h; - - return tex->id; -} - -#if defined NANOVG_GL2 -GLuint nvglImageHandleGL2(NVGcontext* ctx, int image) -#elif defined NANOVG_GL3 -GLuint nvglImageHandleGL3(NVGcontext* ctx, int image) -#elif defined NANOVG_GLES2 -GLuint nvglImageHandleGLES2(NVGcontext* ctx, int image) -#elif defined NANOVG_GLES3 -GLuint nvglImageHandleGLES3(NVGcontext* ctx, int image) -#endif -{ - GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(ctx)->userPtr; - GLNVGtexture* tex = glnvg__findTexture(gl, image); - return tex->tex; -} - -#endif /* NANOVG_GL_IMPLEMENTATION */ diff --git a/phonelibs/nanovg/nanovg_gl_utils.h b/phonelibs/nanovg/nanovg_gl_utils.h deleted file mode 100644 index 1323e90c64cf90..00000000000000 --- a/phonelibs/nanovg/nanovg_gl_utils.h +++ /dev/null @@ -1,143 +0,0 @@ -// -// Copyright (c) 2009-2013 Mikko Mononen memon@inside.org -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. 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. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// -#ifndef NANOVG_GL_UTILS_H -#define NANOVG_GL_UTILS_H - -struct NVGLUframebuffer { - NVGcontext* ctx; - GLuint fbo; - GLuint rbo; - GLuint texture; - int image; -}; -typedef struct NVGLUframebuffer NVGLUframebuffer; - -// Helper function to create GL frame buffer to render to. -void nvgluBindFramebuffer(NVGLUframebuffer* fb); -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags); -void nvgluDeleteFramebuffer(NVGLUframebuffer* fb); - -#endif // NANOVG_GL_UTILS_H - -#ifdef NANOVG_GL_IMPLEMENTATION - -#if defined(NANOVG_GL3) || defined(NANOVG_GLES2) || defined(NANOVG_GLES3) -// FBO is core in OpenGL 3>. -# define NANOVG_FBO_VALID 1 -#elif defined(NANOVG_GL2) -// On OS X including glext defines FBO on GL2 too. -# ifdef __APPLE__ -# include -# define NANOVG_FBO_VALID 1 -# endif -#endif - -static GLint defaultFBO = -1; - -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags) -{ -#ifdef NANOVG_FBO_VALID - GLint defaultFBO; - GLint defaultRBO; - NVGLUframebuffer* fb = NULL; - - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); - glGetIntegerv(GL_RENDERBUFFER_BINDING, &defaultRBO); - - fb = (NVGLUframebuffer*)malloc(sizeof(NVGLUframebuffer)); - if (fb == NULL) goto error; - memset(fb, 0, sizeof(NVGLUframebuffer)); - - fb->image = nvgCreateImageRGBA(ctx, w, h, imageFlags | NVG_IMAGE_FLIPY | NVG_IMAGE_PREMULTIPLIED, NULL); - -#if defined NANOVG_GL2 - fb->texture = nvglImageHandleGL2(ctx, fb->image); -#elif defined NANOVG_GL3 - fb->texture = nvglImageHandleGL3(ctx, fb->image); -#elif defined NANOVG_GLES2 - fb->texture = nvglImageHandleGLES2(ctx, fb->image); -#elif defined NANOVG_GLES3 - fb->texture = nvglImageHandleGLES3(ctx, fb->image); -#endif - - fb->ctx = ctx; - - // frame buffer object - glGenFramebuffers(1, &fb->fbo); - glBindFramebuffer(GL_FRAMEBUFFER, fb->fbo); - - // render buffer object - glGenRenderbuffers(1, &fb->rbo); - glBindRenderbuffer(GL_RENDERBUFFER, fb->rbo); - glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, w, h); - - // combine all - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->texture, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fb->rbo); - - if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) goto error; - - glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO); - return fb; -error: - glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO); - nvgluDeleteFramebuffer(fb); - return NULL; -#else - NVG_NOTUSED(ctx); - NVG_NOTUSED(w); - NVG_NOTUSED(h); - NVG_NOTUSED(imageFlags); - return NULL; -#endif -} - -void nvgluBindFramebuffer(NVGLUframebuffer* fb) -{ -#ifdef NANOVG_FBO_VALID - if (defaultFBO == -1) glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); - glBindFramebuffer(GL_FRAMEBUFFER, fb != NULL ? fb->fbo : defaultFBO); -#else - NVG_NOTUSED(fb); -#endif -} - -void nvgluDeleteFramebuffer(NVGLUframebuffer* fb) -{ -#ifdef NANOVG_FBO_VALID - if (fb == NULL) return; - if (fb->fbo != 0) - glDeleteFramebuffers(1, &fb->fbo); - if (fb->rbo != 0) - glDeleteRenderbuffers(1, &fb->rbo); - if (fb->image >= 0) - nvgDeleteImage(fb->ctx, fb->image); - fb->ctx = NULL; - fb->fbo = 0; - fb->rbo = 0; - fb->texture = 0; - fb->image = -1; - free(fb); -#else - NVG_NOTUSED(fb); -#endif -} - -#endif // NANOVG_GL_IMPLEMENTATION diff --git a/phonelibs/nanovg/stb_image.h b/phonelibs/nanovg/stb_image.h deleted file mode 100644 index e06f7a1d73b1e3..00000000000000 --- a/phonelibs/nanovg/stb_image.h +++ /dev/null @@ -1,6614 +0,0 @@ -/* stb_image - v2.10 - public domain image loader - http://nothings.org/stb_image.h - no warranty implied; use at your own risk - - Do this: - #define STB_IMAGE_IMPLEMENTATION - before you include this file in *one* C or C++ file to create the implementation. - - // i.e. it should look like this: - #include ... - #include ... - #include ... - #define STB_IMAGE_IMPLEMENTATION - #include "stb_image.h" - - You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. - And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free - - - QUICK NOTES: - Primarily of interest to game developers and other people who can - avoid problematic images and only need the trivial interface - - JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) - PNG 1/2/4/8-bit-per-channel (16 bpc not supported) - - TGA (not sure what subset, if a subset) - BMP non-1bpp, non-RLE - PSD (composited view only, no extra channels, 8/16 bit-per-channel) - - GIF (*comp always reports as 4-channel) - HDR (radiance rgbE format) - PIC (Softimage PIC) - PNM (PPM and PGM binary only) - - Animated GIF still needs a proper API, but here's one way to do it: - http://gist.github.com/urraka/685d9a6340b26b830d49 - - - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - - decode from arbitrary I/O callbacks - - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) - - Full documentation under "DOCUMENTATION" below. - - - Revision 2.00 release notes: - - - Progressive JPEG is now supported. - - - PPM and PGM binary formats are now supported, thanks to Ken Miller. - - - x86 platforms now make use of SSE2 SIMD instructions for - JPEG decoding, and ARM platforms can use NEON SIMD if requested. - This work was done by Fabian "ryg" Giesen. SSE2 is used by - default, but NEON must be enabled explicitly; see docs. - - With other JPEG optimizations included in this version, we see - 2x speedup on a JPEG on an x86 machine, and a 1.5x speedup - on a JPEG on an ARM machine, relative to previous versions of this - library. The same results will not obtain for all JPGs and for all - x86/ARM machines. (Note that progressive JPEGs are significantly - slower to decode than regular JPEGs.) This doesn't mean that this - is the fastest JPEG decoder in the land; rather, it brings it - closer to parity with standard libraries. If you want the fastest - decode, look elsewhere. (See "Philosophy" section of docs below.) - - See final bullet items below for more info on SIMD. - - - Added STBI_MALLOC, STBI_REALLOC, and STBI_FREE macros for replacing - the memory allocator. Unlike other STBI libraries, these macros don't - support a context parameter, so if you need to pass a context in to - the allocator, you'll have to store it in a global or a thread-local - variable. - - - Split existing STBI_NO_HDR flag into two flags, STBI_NO_HDR and - STBI_NO_LINEAR. - STBI_NO_HDR: suppress implementation of .hdr reader format - STBI_NO_LINEAR: suppress high-dynamic-range light-linear float API - - - You can suppress implementation of any of the decoders to reduce - your code footprint by #defining one or more of the following - symbols before creating the implementation. - - STBI_NO_JPEG - STBI_NO_PNG - STBI_NO_BMP - STBI_NO_PSD - STBI_NO_TGA - STBI_NO_GIF - STBI_NO_HDR - STBI_NO_PIC - STBI_NO_PNM (.ppm and .pgm) - - - You can request *only* certain decoders and suppress all other ones - (this will be more forward-compatible, as addition of new decoders - doesn't require you to disable them explicitly): - - STBI_ONLY_JPEG - STBI_ONLY_PNG - STBI_ONLY_BMP - STBI_ONLY_PSD - STBI_ONLY_TGA - STBI_ONLY_GIF - STBI_ONLY_HDR - STBI_ONLY_PIC - STBI_ONLY_PNM (.ppm and .pgm) - - Note that you can define multiples of these, and you will get all - of them ("only x" and "only y" is interpreted to mean "only x&y"). - - - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still - want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB - - - Compilation of all SIMD code can be suppressed with - #define STBI_NO_SIMD - It should not be necessary to disable SIMD unless you have issues - compiling (e.g. using an x86 compiler which doesn't support SSE - intrinsics or that doesn't support the method used to detect - SSE2 support at run-time), and even those can be reported as - bugs so I can refine the built-in compile-time checking to be - smarter. - - - The old STBI_SIMD system which allowed installing a user-defined - IDCT etc. has been removed. If you need this, don't upgrade. My - assumption is that almost nobody was doing this, and those who - were will find the built-in SIMD more satisfactory anyway. - - - RGB values computed for JPEG images are slightly different from - previous versions of stb_image. (This is due to using less - integer precision in SIMD.) The C code has been adjusted so - that the same RGB values will be computed regardless of whether - SIMD support is available, so your app should always produce - consistent results. But these results are slightly different from - previous versions. (Specifically, about 3% of available YCbCr values - will compute different RGB results from pre-1.49 versions by +-1; - most of the deviating values are one smaller in the G channel.) - - - If you must produce consistent results with previous versions of - stb_image, #define STBI_JPEG_OLD and you will get the same results - you used to; however, you will not get the SIMD speedups for - the YCbCr-to-RGB conversion step (although you should still see - significant JPEG speedup from the other changes). - - Please note that STBI_JPEG_OLD is a temporary feature; it will be - removed in future versions of the library. It is only intended for - near-term back-compatibility use. - - - Latest revision history: - 2.10 (2016-01-22) avoid warning introduced in 2.09 - 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED - 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA - 2.07 (2015-09-13) partial animated GIF support - limited 16-bit PSD support - minor bugs, code cleanup, and compiler warnings - 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value - 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning - 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit - 2.03 (2015-04-12) additional corruption checking - stbi_set_flip_vertically_on_load - fix NEON support; fix mingw support - 2.02 (2015-01-19) fix incorrect assert, fix warning - 2.01 (2015-01-17) fix various warnings - 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG - 2.00 (2014-12-25) optimize JPEG, including x86 SSE2 & ARM NEON SIMD - progressive JPEG - PGM/PPM support - STBI_MALLOC,STBI_REALLOC,STBI_FREE - STBI_NO_*, STBI_ONLY_* - GIF bugfix - 1.48 (2014-12-14) fix incorrectly-named assert() - 1.47 (2014-12-14) 1/2/4-bit PNG support (both grayscale and paletted) - optimize PNG - fix bug in interlaced PNG with user-specified channel count - - See end of file for full revision history. - - - ============================ Contributors ========================= - - Image formats Extensions, features - Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) - Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) - Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) - Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) - Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) - Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) - Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) - urraka@github (animated gif) Junggon Kim (PNM comments) - Daniel Gibson (16-bit TGA) - - Optimizations & bugfixes - Fabian "ryg" Giesen - Arseny Kapoulkine - - Bug & warning fixes - Marc LeBlanc David Woo Guillaume George Martins Mozeiko - Christpher Lloyd Martin Golini Jerry Jansson Joseph Thomson - Dave Moore Roy Eltham Hayaki Saito Phil Jordan - Won Chun Luke Graham Johan Duparc Nathan Reed - the Horde3D community Thomas Ruf Ronny Chevalier Nick Verigakis - Janez Zemva John Bartholomew Michal Cichon svdijk@github - Jonathan Blow Ken Hamada Tero Hanninen Baldur Karlsson - Laurent Gomila Cort Stratton Sergio Gonzalez romigrou@github - Aruelien Pocheville Thibault Reuille Cass Everitt - Ryamond Barbiero Paul Du Bois Engin Manap - Blazej Dariusz Roszkowski - Michaelangel007@github - - -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. - -*/ - -#ifndef STBI_INCLUDE_STB_IMAGE_H -#define STBI_INCLUDE_STB_IMAGE_H - -// DOCUMENTATION -// -// Limitations: -// - no 16-bit-per-channel PNG -// - no 12-bit-per-channel JPEG -// - no JPEGs with arithmetic coding -// - no 1-bit BMP -// - GIF always returns *comp=4 -// -// Basic usage (see HDR discussion below for HDR usage): -// int x,y,n; -// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); -// // ... process data if not NULL ... -// // ... x = width, y = height, n = # 8-bit components per pixel ... -// // ... replace '0' with '1'..'4' to force that many components per pixel -// // ... but 'n' will always be the number that it would have been if you said 0 -// stbi_image_free(data) -// -// Standard parameters: -// int *x -- outputs image width in pixels -// int *y -- outputs image height in pixels -// int *comp -- outputs # of image components in image file -// int req_comp -- if non-zero, # of image components requested in result -// -// The return value from an image loader is an 'unsigned char *' which points -// to the pixel data, or NULL on an allocation failure or if the image is -// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, -// with each pixel consisting of N interleaved 8-bit components; the first -// pixel pointed to is top-left-most in the image. There is no padding between -// image scanlines or between pixels, regardless of format. The number of -// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise. -// If req_comp is non-zero, *comp has the number of components that _would_ -// have been output otherwise. E.g. if you set req_comp to 4, you will always -// get RGBA output, but you can check *comp to see if it's trivially opaque -// because e.g. there were only 3 channels in the source image. -// -// An output image with N components has the following components interleaved -// in this order in each pixel: -// -// N=#comp components -// 1 grey -// 2 grey, alpha -// 3 red, green, blue -// 4 red, green, blue, alpha -// -// If image loading fails for any reason, the return value will be NULL, -// and *x, *y, *comp will be unchanged. The function stbi_failure_reason() -// can be queried for an extremely brief, end-user unfriendly explanation -// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid -// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly -// more user-friendly ones. -// -// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. -// -// =========================================================================== -// -// Philosophy -// -// stb libraries are designed with the following priorities: -// -// 1. easy to use -// 2. easy to maintain -// 3. good performance -// -// Sometimes I let "good performance" creep up in priority over "easy to maintain", -// and for best performance I may provide less-easy-to-use APIs that give higher -// performance, in addition to the easy to use ones. Nevertheless, it's important -// to keep in mind that from the standpoint of you, a client of this library, -// all you care about is #1 and #3, and stb libraries do not emphasize #3 above all. -// -// Some secondary priorities arise directly from the first two, some of which -// make more explicit reasons why performance can't be emphasized. -// -// - Portable ("ease of use") -// - Small footprint ("easy to maintain") -// - No dependencies ("ease of use") -// -// =========================================================================== -// -// I/O callbacks -// -// I/O callbacks allow you to read from arbitrary sources, like packaged -// files or some other source. Data read from callbacks are processed -// through a small internal buffer (currently 128 bytes) to try to reduce -// overhead. -// -// The three functions you must define are "read" (reads some bytes of data), -// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). -// -// =========================================================================== -// -// SIMD support -// -// The JPEG decoder will try to automatically use SIMD kernels on x86 when -// supported by the compiler. For ARM Neon support, you must explicitly -// request it. -// -// (The old do-it-yourself SIMD API is no longer supported in the current -// code.) -// -// On x86, SSE2 will automatically be used when available based on a run-time -// test; if not, the generic C versions are used as a fall-back. On ARM targets, -// the typical path is to have separate builds for NEON and non-NEON devices -// (at least this is true for iOS and Android). Therefore, the NEON support is -// toggled by a build flag: define STBI_NEON to get NEON loops. -// -// The output of the JPEG decoder is slightly different from versions where -// SIMD support was introduced (that is, for versions before 1.49). The -// difference is only +-1 in the 8-bit RGB channels, and only on a small -// fraction of pixels. You can force the pre-1.49 behavior by defining -// STBI_JPEG_OLD, but this will disable some of the SIMD decoding path -// and hence cost some performance. -// -// If for some reason you do not want to use any of SIMD code, or if -// you have issues compiling it, you can disable it entirely by -// defining STBI_NO_SIMD. -// -// =========================================================================== -// -// HDR image support (disable by defining STBI_NO_HDR) -// -// stb_image now supports loading HDR images in general, and currently -// the Radiance .HDR file format, although the support is provided -// generically. You can still load any file through the existing interface; -// if you attempt to load an HDR file, it will be automatically remapped to -// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; -// both of these constants can be reconfigured through this interface: -// -// stbi_hdr_to_ldr_gamma(2.2f); -// stbi_hdr_to_ldr_scale(1.0f); -// -// (note, do not use _inverse_ constants; stbi_image will invert them -// appropriately). -// -// Additionally, there is a new, parallel interface for loading files as -// (linear) floats to preserve the full dynamic range: -// -// float *data = stbi_loadf(filename, &x, &y, &n, 0); -// -// If you load LDR images through this interface, those images will -// be promoted to floating point values, run through the inverse of -// constants corresponding to the above: -// -// stbi_ldr_to_hdr_scale(1.0f); -// stbi_ldr_to_hdr_gamma(2.2f); -// -// Finally, given a filename (or an open file or memory block--see header -// file for details) containing image data, you can query for the "most -// appropriate" interface to use (that is, whether the image is HDR or -// not), using: -// -// stbi_is_hdr(char *filename); -// -// =========================================================================== -// -// iPhone PNG support: -// -// By default we convert iphone-formatted PNGs back to RGB, even though -// they are internally encoded differently. You can disable this conversion -// by by calling stbi_convert_iphone_png_to_rgb(0), in which case -// you will always just get the native iphone "format" through (which -// is BGR stored in RGB). -// -// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per -// pixel to remove any premultiplied alpha *only* if the image file explicitly -// says there's premultiplied data (currently only happens in iPhone images, -// and only if iPhone convert-to-rgb processing is on). -// - - -#ifndef STBI_NO_STDIO -#include -#endif // STBI_NO_STDIO - -#define STBI_VERSION 1 - -enum -{ - STBI_default = 0, // only used for req_comp - - STBI_grey = 1, - STBI_grey_alpha = 2, - STBI_rgb = 3, - STBI_rgb_alpha = 4 -}; - -typedef unsigned char stbi_uc; - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef STB_IMAGE_STATIC -#define STBIDEF static -#else -#define STBIDEF extern -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// PRIMARY API - works on images of any type -// - -// -// load image by filename, open file, or memory buffer -// - -typedef struct -{ - int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read - void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative - int (*eof) (void *user); // returns nonzero if we are at end of file/data -} stbi_io_callbacks; - -STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp); -STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *comp, int req_comp); -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *comp, int req_comp); - -#ifndef STBI_NO_STDIO -STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -// for stbi_load_from_file, file pointer is left pointing immediately after image -#endif - -#ifndef STBI_NO_LINEAR - STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp); - STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); - STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp); - - #ifndef STBI_NO_STDIO - STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); - #endif -#endif - -#ifndef STBI_NO_HDR - STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); - STBIDEF void stbi_hdr_to_ldr_scale(float scale); -#endif // STBI_NO_HDR - -#ifndef STBI_NO_LINEAR - STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); - STBIDEF void stbi_ldr_to_hdr_scale(float scale); -#endif // STBI_NO_LINEAR - -// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); -#ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename); -STBIDEF int stbi_is_hdr_from_file(FILE *f); -#endif // STBI_NO_STDIO - - -// get a VERY brief reason for failure -// NOT THREADSAFE -STBIDEF const char *stbi_failure_reason (void); - -// free the loaded image -- this is just free() -STBIDEF void stbi_image_free (void *retval_from_stbi_load); - -// get image dimensions & components without fully decoding -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); - -#endif - - - -// for image formats that explicitly notate that they have premultiplied alpha, -// we just return the colors as stored in the file. set this flag to force -// unpremultiplication. results are undefined if the unpremultiply overflow. -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); - -// indicate whether we should process iphone images back to canonical format, -// or just pass them through "as-is" -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); - -// flip the image vertically, so the first pixel in the output array is the bottom left -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); - -// ZLIB client - used by PNG, available for other purposes - -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); -STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - - -#ifdef __cplusplus -} -#endif - -// -// -//// end header file ///////////////////////////////////////////////////// -#endif // STBI_INCLUDE_STB_IMAGE_H - -#ifdef STB_IMAGE_IMPLEMENTATION - -#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ - || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ - || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ - || defined(STBI_ONLY_ZLIB) - #ifndef STBI_ONLY_JPEG - #define STBI_NO_JPEG - #endif - #ifndef STBI_ONLY_PNG - #define STBI_NO_PNG - #endif - #ifndef STBI_ONLY_BMP - #define STBI_NO_BMP - #endif - #ifndef STBI_ONLY_PSD - #define STBI_NO_PSD - #endif - #ifndef STBI_ONLY_TGA - #define STBI_NO_TGA - #endif - #ifndef STBI_ONLY_GIF - #define STBI_NO_GIF - #endif - #ifndef STBI_ONLY_HDR - #define STBI_NO_HDR - #endif - #ifndef STBI_ONLY_PIC - #define STBI_NO_PIC - #endif - #ifndef STBI_ONLY_PNM - #define STBI_NO_PNM - #endif -#endif - -#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) -#define STBI_NO_ZLIB -#endif - - -#include -#include // ptrdiff_t on osx -#include -#include - -#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -#include // ldexp -#endif - -#ifndef STBI_NO_STDIO -#include -#endif - -#ifndef STBI_ASSERT -#include -#define STBI_ASSERT(x) assert(x) -#endif - - -#ifndef _MSC_VER - #ifdef __cplusplus - #define stbi_inline inline - #else - #define stbi_inline - #endif -#else - #define stbi_inline __forceinline -#endif - - -#ifdef _MSC_VER -typedef unsigned short stbi__uint16; -typedef signed short stbi__int16; -typedef unsigned int stbi__uint32; -typedef signed int stbi__int32; -#else -#include -typedef uint16_t stbi__uint16; -typedef int16_t stbi__int16; -typedef uint32_t stbi__uint32; -typedef int32_t stbi__int32; -#endif - -// should produce compiler error if size is wrong -typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; - -#ifdef _MSC_VER -#define STBI_NOTUSED(v) (void)(v) -#else -#define STBI_NOTUSED(v) (void)sizeof(v) -#endif - -#ifdef _MSC_VER -#define STBI_HAS_LROTL -#endif - -#ifdef STBI_HAS_LROTL - #define stbi_lrot(x,y) _lrotl(x,y) -#else - #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) -#endif - -#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) -// ok -#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) -// ok -#else -#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." -#endif - -#ifndef STBI_MALLOC -#define STBI_MALLOC(sz) malloc(sz) -#define STBI_REALLOC(p,newsz) realloc(p,newsz) -#define STBI_FREE(p) free(p) -#endif - -#ifndef STBI_REALLOC_SIZED -#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) -#endif - -// x86/x64 detection -#if defined(__x86_64__) || defined(_M_X64) -#define STBI__X64_TARGET -#elif defined(__i386) || defined(_M_IX86) -#define STBI__X86_TARGET -#endif - -#if defined(__GNUC__) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) -// NOTE: not clear do we actually need this for the 64-bit path? -// gcc doesn't support sse2 intrinsics unless you compile with -msse2, -// (but compiling with -msse2 allows the compiler to use SSE2 everywhere; -// this is just broken and gcc are jerks for not fixing it properly -// http://www.virtualdub.org/blog/pivot/entry.php?id=363 ) -#define STBI_NO_SIMD -#endif - -#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) -// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET -// -// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the -// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. -// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not -// simultaneously enabling "-mstackrealign". -// -// See https://github.com/nothings/stb/issues/81 for more information. -// -// So default to no SSE2 on 32-bit MinGW. If you've read this far and added -// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. -#define STBI_NO_SIMD -#endif - -#if !defined(STBI_NO_SIMD) && defined(STBI__X86_TARGET) -#define STBI_SSE2 -#include - -#ifdef _MSC_VER - -#if _MSC_VER >= 1400 // not VC6 -#include // __cpuid -static int stbi__cpuid3(void) -{ - int info[4]; - __cpuid(info,1); - return info[3]; -} -#else -static int stbi__cpuid3(void) -{ - int res; - __asm { - mov eax,1 - cpuid - mov res,edx - } - return res; -} -#endif - -#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name - -static int stbi__sse2_available() -{ - int info3 = stbi__cpuid3(); - return ((info3 >> 26) & 1) != 0; -} -#else // assume GCC-style if not VC++ -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) - -static int stbi__sse2_available() -{ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later - // GCC 4.8+ has a nice way to do this - return __builtin_cpu_supports("sse2"); -#else - // portable way to do this, preferably without using GCC inline ASM? - // just bail for now. - return 0; -#endif -} -#endif -#endif - -// ARM NEON -#if defined(STBI_NO_SIMD) && defined(STBI_NEON) -#undef STBI_NEON -#endif - -#ifdef STBI_NEON -#include -// assume GCC or Clang on ARM targets -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) -#endif - -#ifndef STBI_SIMD_ALIGN -#define STBI_SIMD_ALIGN(type, name) type name -#endif - -/////////////////////////////////////////////// -// -// stbi__context struct and start_xxx functions - -// stbi__context structure is our basic context used by all images, so it -// contains all the IO context, plus some basic image information -typedef struct -{ - stbi__uint32 img_x, img_y; - int img_n, img_out_n; - - stbi_io_callbacks io; - void *io_user_data; - - int read_from_callbacks; - int buflen; - stbi_uc buffer_start[128]; - - stbi_uc *img_buffer, *img_buffer_end; - stbi_uc *img_buffer_original, *img_buffer_original_end; -} stbi__context; - - -static void stbi__refill_buffer(stbi__context *s); - -// initialize a memory-decode context -static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) -{ - s->io.read = NULL; - s->read_from_callbacks = 0; - s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; - s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; -} - -// initialize a callback-based context -static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) -{ - s->io = *c; - s->io_user_data = user; - s->buflen = sizeof(s->buffer_start); - s->read_from_callbacks = 1; - s->img_buffer_original = s->buffer_start; - stbi__refill_buffer(s); - s->img_buffer_original_end = s->img_buffer_end; -} - -#ifndef STBI_NO_STDIO - -static int stbi__stdio_read(void *user, char *data, int size) -{ - return (int) fread(data,1,size,(FILE*) user); -} - -static void stbi__stdio_skip(void *user, int n) -{ - fseek((FILE*) user, n, SEEK_CUR); -} - -static int stbi__stdio_eof(void *user) -{ - return feof((FILE*) user); -} - -static stbi_io_callbacks stbi__stdio_callbacks = -{ - stbi__stdio_read, - stbi__stdio_skip, - stbi__stdio_eof, -}; - -static void stbi__start_file(stbi__context *s, FILE *f) -{ - stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); -} - -//static void stop_file(stbi__context *s) { } - -#endif // !STBI_NO_STDIO - -static void stbi__rewind(stbi__context *s) -{ - // conceptually rewind SHOULD rewind to the beginning of the stream, - // but we just rewind to the beginning of the initial buffer, because - // we only use it after doing 'test', which only ever looks at at most 92 bytes - s->img_buffer = s->img_buffer_original; - s->img_buffer_end = s->img_buffer_original_end; -} - -#ifndef STBI_NO_JPEG -static int stbi__jpeg_test(stbi__context *s); -static stbi_uc *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PNG -static int stbi__png_test(stbi__context *s); -static stbi_uc *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_BMP -static int stbi__bmp_test(stbi__context *s); -static stbi_uc *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_TGA -static int stbi__tga_test(stbi__context *s); -static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s); -static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_HDR -static int stbi__hdr_test(stbi__context *s); -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PIC -static int stbi__pic_test(stbi__context *s); -static stbi_uc *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_GIF -static int stbi__gif_test(stbi__context *s); -static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PNM -static int stbi__pnm_test(stbi__context *s); -static stbi_uc *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -// this is not threadsafe -static const char *stbi__g_failure_reason; - -STBIDEF const char *stbi_failure_reason(void) -{ - return stbi__g_failure_reason; -} - -static int stbi__err(const char *str) -{ - stbi__g_failure_reason = str; - return 0; -} - -static void *stbi__malloc(size_t size) -{ - return STBI_MALLOC(size); -} - -// stbi__err - error -// stbi__errpf - error returning pointer to float -// stbi__errpuc - error returning pointer to unsigned char - -#ifdef STBI_NO_FAILURE_STRINGS - #define stbi__err(x,y) 0 -#elif defined(STBI_FAILURE_USERMSG) - #define stbi__err(x,y) stbi__err(y) -#else - #define stbi__err(x,y) stbi__err(x) -#endif - -#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) -#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) - -STBIDEF void stbi_image_free(void *retval_from_stbi_load) -{ - STBI_FREE(retval_from_stbi_load); -} - -#ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); -#endif - -#ifndef STBI_NO_HDR -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); -#endif - -static int stbi__vertically_flip_on_load = 0; - -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) -{ - stbi__vertically_flip_on_load = flag_true_if_should_flip; -} - -static unsigned char *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - #ifndef STBI_NO_JPEG - if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_PNG - if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_BMP - if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_GIF - if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_PSD - if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_PIC - if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp); - #endif - #ifndef STBI_NO_PNM - if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp); - #endif - - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - float *hdr = stbi__hdr_load(s, x,y,comp,req_comp); - return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - - #ifndef STBI_NO_TGA - // test tga last because it's a crappy test! - if (stbi__tga_test(s)) - return stbi__tga_load(s,x,y,comp,req_comp); - #endif - - return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); -} - -static unsigned char *stbi__load_flip(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *result = stbi__load_main(s, x, y, comp, req_comp); - - if (stbi__vertically_flip_on_load && result != NULL) { - int w = *x, h = *y; - int depth = req_comp ? req_comp : *comp; - int row,col,z; - stbi_uc temp; - - // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once - for (row = 0; row < (h>>1); row++) { - for (col = 0; col < w; col++) { - for (z = 0; z < depth; z++) { - temp = result[(row * w + col) * depth + z]; - result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; - result[((h - row - 1) * w + col) * depth + z] = temp; - } - } - } - } - - return result; -} - -#ifndef STBI_NO_HDR -static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) -{ - if (stbi__vertically_flip_on_load && result != NULL) { - int w = *x, h = *y; - int depth = req_comp ? req_comp : *comp; - int row,col,z; - float temp; - - // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once - for (row = 0; row < (h>>1); row++) { - for (col = 0; col < w; col++) { - for (z = 0; z < depth; z++) { - temp = result[(row * w + col) * depth + z]; - result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; - result[((h - row - 1) * w + col) * depth + z] = temp; - } - } - } - } -} -#endif - -#ifndef STBI_NO_STDIO - -static FILE *stbi__fopen(char const *filename, char const *mode) -{ - FILE *f; -#if defined(_MSC_VER) && _MSC_VER >= 1400 - if (0 != fopen_s(&f, filename, mode)) - f=0; -#else - f = fopen(filename, mode); -#endif - return f; -} - - -STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - unsigned char *result; - if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *result; - stbi__context s; - stbi__start_file(&s,f); - result = stbi__load_flip(&s,x,y,comp,req_comp); - if (result) { - // need to 'unget' all the characters in the IO buffer - fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); - } - return result; -} -#endif //!STBI_NO_STDIO - -STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_flip(&s,x,y,comp,req_comp); -} - -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__load_flip(&s,x,y,comp,req_comp); -} - -#ifndef STBI_NO_LINEAR -static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp); - if (hdr_data) - stbi__float_postprocess(hdr_data,x,y,comp,req_comp); - return hdr_data; - } - #endif - data = stbi__load_flip(s, x, y, comp, req_comp); - if (data) - return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); -} - -STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} - -STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} - -#ifndef STBI_NO_STDIO -STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - float *result; - FILE *f = stbi__fopen(filename, "rb"); - if (!f) return stbi__errpf("can't fopen", "Unable to open file"); - result = stbi_loadf_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_file(&s,f); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} -#endif // !STBI_NO_STDIO - -#endif // !STBI_NO_LINEAR - -// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is -// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always -// reports false! - -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(buffer); - STBI_NOTUSED(len); - return 0; - #endif -} - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result=0; - if (f) { - result = stbi_is_hdr_from_file(f); - fclose(f); - } - return result; -} - -STBIDEF int stbi_is_hdr_from_file(FILE *f) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_file(&s,f); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(f); - return 0; - #endif -} -#endif // !STBI_NO_STDIO - -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(clbk); - STBI_NOTUSED(user); - return 0; - #endif -} - -#ifndef STBI_NO_LINEAR -static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; - -STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } -STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } -#endif - -static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; - -STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } -STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } - - -////////////////////////////////////////////////////////////////////////////// -// -// Common code used by all image loaders -// - -enum -{ - STBI__SCAN_load=0, - STBI__SCAN_type, - STBI__SCAN_header -}; - -static void stbi__refill_buffer(stbi__context *s) -{ - int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); - if (n == 0) { - // at end of file, treat same as if from memory, but need to handle case - // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file - s->read_from_callbacks = 0; - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start+1; - *s->img_buffer = 0; - } else { - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start + n; - } -} - -stbi_inline static stbi_uc stbi__get8(stbi__context *s) -{ - if (s->img_buffer < s->img_buffer_end) - return *s->img_buffer++; - if (s->read_from_callbacks) { - stbi__refill_buffer(s); - return *s->img_buffer++; - } - return 0; -} - -stbi_inline static int stbi__at_eof(stbi__context *s) -{ - if (s->io.read) { - if (!(s->io.eof)(s->io_user_data)) return 0; - // if feof() is true, check if buffer = end - // special case: we've only got the special 0 character at the end - if (s->read_from_callbacks == 0) return 1; - } - - return s->img_buffer >= s->img_buffer_end; -} - -static void stbi__skip(stbi__context *s, int n) -{ - if (n < 0) { - s->img_buffer = s->img_buffer_end; - return; - } - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - s->img_buffer = s->img_buffer_end; - (s->io.skip)(s->io_user_data, n - blen); - return; - } - } - s->img_buffer += n; -} - -static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) -{ - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - int res, count; - - memcpy(buffer, s->img_buffer, blen); - - count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); - res = (count == (n-blen)); - s->img_buffer = s->img_buffer_end; - return res; - } - } - - if (s->img_buffer+n <= s->img_buffer_end) { - memcpy(buffer, s->img_buffer, n); - s->img_buffer += n; - return 1; - } else - return 0; -} - -static int stbi__get16be(stbi__context *s) -{ - int z = stbi__get8(s); - return (z << 8) + stbi__get8(s); -} - -static stbi__uint32 stbi__get32be(stbi__context *s) -{ - stbi__uint32 z = stbi__get16be(s); - return (z << 16) + stbi__get16be(s); -} - -#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) -// nothing -#else -static int stbi__get16le(stbi__context *s) -{ - int z = stbi__get8(s); - return z + (stbi__get8(s) << 8); -} -#endif - -#ifndef STBI_NO_BMP -static stbi__uint32 stbi__get32le(stbi__context *s) -{ - stbi__uint32 z = stbi__get16le(s); - return z + (stbi__get16le(s) << 16); -} -#endif - -#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings - - -////////////////////////////////////////////////////////////////////////////// -// -// generic converter from built-in img_n to req_comp -// individual types do this automatically as much as possible (e.g. jpeg -// does all cases internally since it needs to colorspace convert anyway, -// and it never has alpha, so very few cases ). png can automatically -// interleave an alpha=255 channel, but falls back to this for other cases -// -// assume data buffer is malloced, so malloc a new one and free that one -// only failure mode is malloc failing - -static stbi_uc stbi__compute_y(int r, int g, int b) -{ - return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); -} - -static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) -{ - int i,j; - unsigned char *good; - - if (req_comp == img_n) return data; - STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - - good = (unsigned char *) stbi__malloc(req_comp * x * y); - if (good == NULL) { - STBI_FREE(data); - return stbi__errpuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - unsigned char *src = data + j * x * img_n ; - unsigned char *dest = good + j * x * req_comp; - - #define COMBO(a,b) ((a)*8+(b)) - #define CASE(a,b) case COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (COMBO(img_n, req_comp)) { - CASE(1,2) dest[0]=src[0], dest[1]=255; break; - CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; - CASE(2,1) dest[0]=src[0]; break; - CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; - CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; - CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; - CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; break; - CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; - CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; - CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; - default: STBI_ASSERT(0); - } - #undef CASE - } - - STBI_FREE(data); - return good; -} - -#ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) -{ - int i,k,n; - float *output = (float *) stbi__malloc(x * y * comp * sizeof(float)); - if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); - } - if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; - } - STBI_FREE(data); - return output; -} -#endif - -#ifndef STBI_NO_HDR -#define stbi__float2int(x) ((int) (x)) -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) -{ - int i,k,n; - stbi_uc *output = (stbi_uc *) stbi__malloc(x * y * comp); - if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - if (k < comp) { - float z = data[i*comp+k] * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - } - STBI_FREE(data); - return output; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// "baseline" JPEG/JFIF decoder -// -// simple implementation -// - doesn't support delayed output of y-dimension -// - simple interface (only one output format: 8-bit interleaved RGB) -// - doesn't try to recover corrupt jpegs -// - doesn't allow partial loading, loading multiple at once -// - still fast on x86 (copying globals into locals doesn't help x86) -// - allocates lots of intermediate memory (full size of all components) -// - non-interleaved case requires this anyway -// - allows good upsampling (see next) -// high-quality -// - upsampled channels are bilinearly interpolated, even across blocks -// - quality integer IDCT derived from IJG's 'slow' -// performance -// - fast huffman; reasonable integer IDCT -// - some SIMD kernels for common paths on targets with SSE2/NEON -// - uses a lot of intermediate memory, could cache poorly - -#ifndef STBI_NO_JPEG - -// huffman decoding acceleration -#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache - -typedef struct -{ - stbi_uc fast[1 << FAST_BITS]; - // weirdly, repacking this into AoS is a 10% speed loss, instead of a win - stbi__uint16 code[256]; - stbi_uc values[256]; - stbi_uc size[257]; - unsigned int maxcode[18]; - int delta[17]; // old 'firstsymbol' - old 'firstcode' -} stbi__huffman; - -typedef struct -{ - stbi__context *s; - stbi__huffman huff_dc[4]; - stbi__huffman huff_ac[4]; - stbi_uc dequant[4][64]; - stbi__int16 fast_ac[4][1 << FAST_BITS]; - -// sizes for components, interleaved MCUs - int img_h_max, img_v_max; - int img_mcu_x, img_mcu_y; - int img_mcu_w, img_mcu_h; - -// definition of jpeg image component - struct - { - int id; - int h,v; - int tq; - int hd,ha; - int dc_pred; - - int x,y,w2,h2; - stbi_uc *data; - void *raw_data, *raw_coeff; - stbi_uc *linebuf; - short *coeff; // progressive only - int coeff_w, coeff_h; // number of 8x8 coefficient blocks - } img_comp[4]; - - stbi__uint32 code_buffer; // jpeg entropy-coded buffer - int code_bits; // number of valid bits - unsigned char marker; // marker seen while filling entropy buffer - int nomore; // flag if we saw a marker so must stop - - int progressive; - int spec_start; - int spec_end; - int succ_high; - int succ_low; - int eob_run; - - int scan_n, order[4]; - int restart_interval, todo; - -// kernels - void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); - void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); - stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); -} stbi__jpeg; - -static int stbi__build_huffman(stbi__huffman *h, int *count) -{ - int i,j,k=0,code; - // build size list for each symbol (from JPEG spec) - for (i=0; i < 16; ++i) - for (j=0; j < count[i]; ++j) - h->size[k++] = (stbi_uc) (i+1); - h->size[k] = 0; - - // compute actual symbols (from jpeg spec) - code = 0; - k = 0; - for(j=1; j <= 16; ++j) { - // compute delta to add to code to compute symbol id - h->delta[j] = k - code; - if (h->size[k] == j) { - while (h->size[k] == j) - h->code[k++] = (stbi__uint16) (code++); - if (code-1 >= (1 << j)) return stbi__err("bad code lengths","Corrupt JPEG"); - } - // compute largest code + 1 for this size, preshifted as needed later - h->maxcode[j] = code << (16-j); - code <<= 1; - } - h->maxcode[j] = 0xffffffff; - - // build non-spec acceleration table; 255 is flag for not-accelerated - memset(h->fast, 255, 1 << FAST_BITS); - for (i=0; i < k; ++i) { - int s = h->size[i]; - if (s <= FAST_BITS) { - int c = h->code[i] << (FAST_BITS-s); - int m = 1 << (FAST_BITS-s); - for (j=0; j < m; ++j) { - h->fast[c+j] = (stbi_uc) i; - } - } - } - return 1; -} - -// build a table that decodes both magnitude and value of small ACs in -// one go. -static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) -{ - int i; - for (i=0; i < (1 << FAST_BITS); ++i) { - stbi_uc fast = h->fast[i]; - fast_ac[i] = 0; - if (fast < 255) { - int rs = h->values[fast]; - int run = (rs >> 4) & 15; - int magbits = rs & 15; - int len = h->size[fast]; - - if (magbits && len + magbits <= FAST_BITS) { - // magnitude code followed by receive_extend code - int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); - int m = 1 << (magbits - 1); - if (k < m) k += (-1 << magbits) + 1; - // if the result is small enough, we can fit it in fast_ac table - if (k >= -128 && k <= 127) - fast_ac[i] = (stbi__int16) ((k << 8) + (run << 4) + (len + magbits)); - } - } - } -} - -static void stbi__grow_buffer_unsafe(stbi__jpeg *j) -{ - do { - int b = j->nomore ? 0 : stbi__get8(j->s); - if (b == 0xff) { - int c = stbi__get8(j->s); - if (c != 0) { - j->marker = (unsigned char) c; - j->nomore = 1; - return; - } - } - j->code_buffer |= b << (24 - j->code_bits); - j->code_bits += 8; - } while (j->code_bits <= 24); -} - -// (1 << n) - 1 -static stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; - -// decode a jpeg huffman value from the bitstream -stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) -{ - unsigned int temp; - int c,k; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - - // look at the top FAST_BITS and determine what symbol ID it is, - // if the code is <= FAST_BITS - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - k = h->fast[c]; - if (k < 255) { - int s = h->size[k]; - if (s > j->code_bits) - return -1; - j->code_buffer <<= s; - j->code_bits -= s; - return h->values[k]; - } - - // naive test is to shift the code_buffer down so k bits are - // valid, then test against maxcode. To speed this up, we've - // preshifted maxcode left so that it has (16-k) 0s at the - // end; in other words, regardless of the number of bits, it - // wants to be compared against something shifted to have 16; - // that way we don't need to shift inside the loop. - temp = j->code_buffer >> 16; - for (k=FAST_BITS+1 ; ; ++k) - if (temp < h->maxcode[k]) - break; - if (k == 17) { - // error! code not found - j->code_bits -= 16; - return -1; - } - - if (k > j->code_bits) - return -1; - - // convert the huffman code to the symbol id - c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; - STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); - - // convert the id to a symbol - j->code_bits -= k; - j->code_buffer <<= k; - return h->values[c]; -} - -// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); - - sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB - k = stbi_lrot(j->code_buffer, n); - STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k + (stbi__jbias[n] & ~sgn); -} - -// get some unsigned bits -stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) -{ - unsigned int k; - if (j->code_bits < n) stbi__grow_buffer_unsafe(j); - k = stbi_lrot(j->code_buffer, n); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k; -} - -stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) -{ - unsigned int k; - if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); - k = j->code_buffer; - j->code_buffer <<= 1; - --j->code_bits; - return k & 0x80000000; -} - -// given a value that's at position X in the zigzag stream, -// where does it appear in the 8x8 matrix coded as row-major? -static stbi_uc stbi__jpeg_dezigzag[64+15] = -{ - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - // let corrupt input sample past end - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63 -}; - -// decode one 64-entry block-- -static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi_uc *dequant) -{ - int diff,dc,k; - int t; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - t = stbi__jpeg_huff_decode(j, hdc); - if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - - // 0 all the ac values now so we can do it 32-bits at a time - memset(data,0,64*sizeof(data[0])); - - diff = t ? stbi__extend_receive(j, t) : 0; - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) (dc * dequant[0]); - - // decode AC components, see JPEG spec - k = 1; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - j->code_buffer <<= s; - j->code_bits -= s; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) * dequant[zig]); - } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (rs != 0xf0) break; // end block - k += 16; - } else { - k += r; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); - } - } - } while (k < 64); - return 1; -} - -static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) -{ - int diff,dc; - int t; - if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - - if (j->succ_high == 0) { - // first scan for DC coefficient, must be first - memset(data,0,64*sizeof(data[0])); // 0 all the ac values now - t = stbi__jpeg_huff_decode(j, hdc); - diff = t ? stbi__extend_receive(j, t) : 0; - - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) (dc << j->succ_low); - } else { - // refinement scan for DC coefficient - if (stbi__jpeg_get_bit(j)) - data[0] += (short) (1 << j->succ_low); - } - return 1; -} - -// @OPTIMIZE: store non-zigzagged during the decode passes, -// and only de-zigzag when dequantizing -static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) -{ - int k; - if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - - if (j->succ_high == 0) { - int shift = j->succ_low; - - if (j->eob_run) { - --j->eob_run; - return 1; - } - - k = j->spec_start; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - j->code_buffer <<= s; - j->code_bits -= s; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) << shift); - } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r); - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - --j->eob_run; - break; - } - k += 16; - } else { - k += r; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) << shift); - } - } - } while (k <= j->spec_end); - } else { - // refinement scan for these AC coefficients - - short bit = (short) (1 << j->succ_low); - - if (j->eob_run) { - --j->eob_run; - for (k = j->spec_start; k <= j->spec_end; ++k) { - short *p = &data[stbi__jpeg_dezigzag[k]]; - if (*p != 0) - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } - } else { - k = j->spec_start; - do { - int r,s; - int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r) - 1; - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - r = 64; // force end of block - } else { - // r=15 s=0 should write 16 0s, so we just do - // a run of 15 0s and then write s (which is 0), - // so we don't have to do anything special here - } - } else { - if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); - // sign bit - if (stbi__jpeg_get_bit(j)) - s = bit; - else - s = -bit; - } - - // advance by r - while (k <= j->spec_end) { - short *p = &data[stbi__jpeg_dezigzag[k++]]; - if (*p != 0) { - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } else { - if (r == 0) { - *p = (short) s; - break; - } - --r; - } - } - } while (k <= j->spec_end); - } - } - return 1; -} - -// take a -128..127 value and stbi__clamp it and convert to 0..255 -stbi_inline static stbi_uc stbi__clamp(int x) -{ - // trick to use a single test to catch both cases - if ((unsigned int) x > 255) { - if (x < 0) return 0; - if (x > 255) return 255; - } - return (stbi_uc) x; -} - -#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) -#define stbi__fsh(x) ((x) << 12) - -// derived from jidctint -- DCT_ISLOW -#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ - int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ - p2 = s2; \ - p3 = s6; \ - p1 = (p2+p3) * stbi__f2f(0.5411961f); \ - t2 = p1 + p3*stbi__f2f(-1.847759065f); \ - t3 = p1 + p2*stbi__f2f( 0.765366865f); \ - p2 = s0; \ - p3 = s4; \ - t0 = stbi__fsh(p2+p3); \ - t1 = stbi__fsh(p2-p3); \ - x0 = t0+t3; \ - x3 = t0-t3; \ - x1 = t1+t2; \ - x2 = t1-t2; \ - t0 = s7; \ - t1 = s5; \ - t2 = s3; \ - t3 = s1; \ - p3 = t0+t2; \ - p4 = t1+t3; \ - p1 = t0+t3; \ - p2 = t1+t2; \ - p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ - t0 = t0*stbi__f2f( 0.298631336f); \ - t1 = t1*stbi__f2f( 2.053119869f); \ - t2 = t2*stbi__f2f( 3.072711026f); \ - t3 = t3*stbi__f2f( 1.501321110f); \ - p1 = p5 + p1*stbi__f2f(-0.899976223f); \ - p2 = p5 + p2*stbi__f2f(-2.562915447f); \ - p3 = p3*stbi__f2f(-1.961570560f); \ - p4 = p4*stbi__f2f(-0.390180644f); \ - t3 += p1+p4; \ - t2 += p2+p3; \ - t1 += p2+p4; \ - t0 += p1+p3; - -static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) -{ - int i,val[64],*v=val; - stbi_uc *o; - short *d = data; - - // columns - for (i=0; i < 8; ++i,++d, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing - if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 - && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds - int dcterm = d[0] << 2; - v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; - } else { - STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision - x0 += 512; x1 += 512; x2 += 512; x3 += 512; - v[ 0] = (x0+t3) >> 10; - v[56] = (x0-t3) >> 10; - v[ 8] = (x1+t2) >> 10; - v[48] = (x1-t2) >> 10; - v[16] = (x2+t1) >> 10; - v[40] = (x2-t1) >> 10; - v[24] = (x3+t0) >> 10; - v[32] = (x3-t0) >> 10; - } - } - - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out - STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - // so we want to round that, which means adding 0.5 * 1<<17, - // aka 65536. Also, we'll end up with -128 to 127 that we want - // to encode as 0..255 by adding 128, so we'll add that before the shift - x0 += 65536 + (128<<17); - x1 += 65536 + (128<<17); - x2 += 65536 + (128<<17); - x3 += 65536 + (128<<17); - // tried computing the shifts into temps, or'ing the temps to see - // if any were out of range, but that was slower - o[0] = stbi__clamp((x0+t3) >> 17); - o[7] = stbi__clamp((x0-t3) >> 17); - o[1] = stbi__clamp((x1+t2) >> 17); - o[6] = stbi__clamp((x1-t2) >> 17); - o[2] = stbi__clamp((x2+t1) >> 17); - o[5] = stbi__clamp((x2-t1) >> 17); - o[3] = stbi__clamp((x3+t0) >> 17); - o[4] = stbi__clamp((x3-t0) >> 17); - } -} - -#ifdef STBI_SSE2 -// sse2 integer IDCT. not the fastest possible implementation but it -// produces bit-identical results to the generic C version so it's -// fully "transparent". -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - // This is constructed to match our regular (generic) integer IDCT exactly. - __m128i row0, row1, row2, row3, row4, row5, row6, row7; - __m128i tmp; - - // dot product constant: even elems=x, odd elems=y - #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) - - // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) - // out(1) = c1[even]*x + c1[odd]*y - #define dct_rot(out0,out1, x,y,c0,c1) \ - __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ - __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ - __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ - __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ - __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ - __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) - - // out = in << 12 (in 16-bit, out 32-bit) - #define dct_widen(out, in) \ - __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ - __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) - - // wide add - #define dct_wadd(out, a, b) \ - __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_add_epi32(a##_h, b##_h) - - // wide sub - #define dct_wsub(out, a, b) \ - __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) - - // butterfly a/b, add bias, then shift by "s" and pack - #define dct_bfly32o(out0, out1, a,b,bias,s) \ - { \ - __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ - __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ - dct_wadd(sum, abiased, b); \ - dct_wsub(dif, abiased, b); \ - out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ - out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ - } - - // 8-bit interleave step (for transposes) - #define dct_interleave8(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi8(a, b); \ - b = _mm_unpackhi_epi8(tmp, b) - - // 16-bit interleave step (for transposes) - #define dct_interleave16(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi16(a, b); \ - b = _mm_unpackhi_epi16(tmp, b) - - #define dct_pass(bias,shift) \ - { \ - /* even part */ \ - dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ - __m128i sum04 = _mm_add_epi16(row0, row4); \ - __m128i dif04 = _mm_sub_epi16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ - dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ - __m128i sum17 = _mm_add_epi16(row1, row7); \ - __m128i sum35 = _mm_add_epi16(row3, row5); \ - dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ - dct_wadd(x4, y0o, y4o); \ - dct_wadd(x5, y1o, y5o); \ - dct_wadd(x6, y2o, y5o); \ - dct_wadd(x7, y3o, y4o); \ - dct_bfly32o(row0,row7, x0,x7,bias,shift); \ - dct_bfly32o(row1,row6, x1,x6,bias,shift); \ - dct_bfly32o(row2,row5, x2,x5,bias,shift); \ - dct_bfly32o(row3,row4, x3,x4,bias,shift); \ - } - - __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); - __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); - __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); - __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); - __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); - __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); - __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); - __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); - - // rounding biases in column/row passes, see stbi__idct_block for explanation. - __m128i bias_0 = _mm_set1_epi32(512); - __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); - - // load - row0 = _mm_load_si128((const __m128i *) (data + 0*8)); - row1 = _mm_load_si128((const __m128i *) (data + 1*8)); - row2 = _mm_load_si128((const __m128i *) (data + 2*8)); - row3 = _mm_load_si128((const __m128i *) (data + 3*8)); - row4 = _mm_load_si128((const __m128i *) (data + 4*8)); - row5 = _mm_load_si128((const __m128i *) (data + 5*8)); - row6 = _mm_load_si128((const __m128i *) (data + 6*8)); - row7 = _mm_load_si128((const __m128i *) (data + 7*8)); - - // column pass - dct_pass(bias_0, 10); - - { - // 16bit 8x8 transpose pass 1 - dct_interleave16(row0, row4); - dct_interleave16(row1, row5); - dct_interleave16(row2, row6); - dct_interleave16(row3, row7); - - // transpose pass 2 - dct_interleave16(row0, row2); - dct_interleave16(row1, row3); - dct_interleave16(row4, row6); - dct_interleave16(row5, row7); - - // transpose pass 3 - dct_interleave16(row0, row1); - dct_interleave16(row2, row3); - dct_interleave16(row4, row5); - dct_interleave16(row6, row7); - } - - // row pass - dct_pass(bias_1, 17); - - { - // pack - __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 - __m128i p1 = _mm_packus_epi16(row2, row3); - __m128i p2 = _mm_packus_epi16(row4, row5); - __m128i p3 = _mm_packus_epi16(row6, row7); - - // 8bit 8x8 transpose pass 1 - dct_interleave8(p0, p2); // a0e0a1e1... - dct_interleave8(p1, p3); // c0g0c1g1... - - // transpose pass 2 - dct_interleave8(p0, p1); // a0c0e0g0... - dct_interleave8(p2, p3); // b0d0f0h0... - - // transpose pass 3 - dct_interleave8(p0, p2); // a0b0c0d0... - dct_interleave8(p1, p3); // a4b4c4d4... - - // store - _mm_storel_epi64((__m128i *) out, p0); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p2); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p1); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p3); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); - } - -#undef dct_const -#undef dct_rot -#undef dct_widen -#undef dct_wadd -#undef dct_wsub -#undef dct_bfly32o -#undef dct_interleave8 -#undef dct_interleave16 -#undef dct_pass -} - -#endif // STBI_SSE2 - -#ifdef STBI_NEON - -// NEON integer IDCT. should produce bit-identical -// results to the generic C version. -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; - - int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); - int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); - int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); - int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); - int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); - int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); - int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); - int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); - int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); - int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); - int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); - int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); - -#define dct_long_mul(out, inq, coeff) \ - int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) - -#define dct_long_mac(out, acc, inq, coeff) \ - int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) - -#define dct_widen(out, inq) \ - int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ - int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) - -// wide add -#define dct_wadd(out, a, b) \ - int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vaddq_s32(a##_h, b##_h) - -// wide sub -#define dct_wsub(out, a, b) \ - int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vsubq_s32(a##_h, b##_h) - -// butterfly a/b, then shift using "shiftop" by "s" and pack -#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ - { \ - dct_wadd(sum, a, b); \ - dct_wsub(dif, a, b); \ - out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ - out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ - } - -#define dct_pass(shiftop, shift) \ - { \ - /* even part */ \ - int16x8_t sum26 = vaddq_s16(row2, row6); \ - dct_long_mul(p1e, sum26, rot0_0); \ - dct_long_mac(t2e, p1e, row6, rot0_1); \ - dct_long_mac(t3e, p1e, row2, rot0_2); \ - int16x8_t sum04 = vaddq_s16(row0, row4); \ - int16x8_t dif04 = vsubq_s16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - int16x8_t sum15 = vaddq_s16(row1, row5); \ - int16x8_t sum17 = vaddq_s16(row1, row7); \ - int16x8_t sum35 = vaddq_s16(row3, row5); \ - int16x8_t sum37 = vaddq_s16(row3, row7); \ - int16x8_t sumodd = vaddq_s16(sum17, sum35); \ - dct_long_mul(p5o, sumodd, rot1_0); \ - dct_long_mac(p1o, p5o, sum17, rot1_1); \ - dct_long_mac(p2o, p5o, sum35, rot1_2); \ - dct_long_mul(p3o, sum37, rot2_0); \ - dct_long_mul(p4o, sum15, rot2_1); \ - dct_wadd(sump13o, p1o, p3o); \ - dct_wadd(sump24o, p2o, p4o); \ - dct_wadd(sump23o, p2o, p3o); \ - dct_wadd(sump14o, p1o, p4o); \ - dct_long_mac(x4, sump13o, row7, rot3_0); \ - dct_long_mac(x5, sump24o, row5, rot3_1); \ - dct_long_mac(x6, sump23o, row3, rot3_2); \ - dct_long_mac(x7, sump14o, row1, rot3_3); \ - dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ - dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ - dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ - dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ - } - - // load - row0 = vld1q_s16(data + 0*8); - row1 = vld1q_s16(data + 1*8); - row2 = vld1q_s16(data + 2*8); - row3 = vld1q_s16(data + 3*8); - row4 = vld1q_s16(data + 4*8); - row5 = vld1q_s16(data + 5*8); - row6 = vld1q_s16(data + 6*8); - row7 = vld1q_s16(data + 7*8); - - // add DC bias - row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); - - // column pass - dct_pass(vrshrn_n_s32, 10); - - // 16bit 8x8 transpose - { -// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. -// whether compilers actually get this is another story, sadly. -#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } -#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } - - // pass 1 - dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 - dct_trn16(row2, row3); - dct_trn16(row4, row5); - dct_trn16(row6, row7); - - // pass 2 - dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 - dct_trn32(row1, row3); - dct_trn32(row4, row6); - dct_trn32(row5, row7); - - // pass 3 - dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 - dct_trn64(row1, row5); - dct_trn64(row2, row6); - dct_trn64(row3, row7); - -#undef dct_trn16 -#undef dct_trn32 -#undef dct_trn64 - } - - // row pass - // vrshrn_n_s32 only supports shifts up to 16, we need - // 17. so do a non-rounding shift of 16 first then follow - // up with a rounding shift by 1. - dct_pass(vshrn_n_s32, 16); - - { - // pack and round - uint8x8_t p0 = vqrshrun_n_s16(row0, 1); - uint8x8_t p1 = vqrshrun_n_s16(row1, 1); - uint8x8_t p2 = vqrshrun_n_s16(row2, 1); - uint8x8_t p3 = vqrshrun_n_s16(row3, 1); - uint8x8_t p4 = vqrshrun_n_s16(row4, 1); - uint8x8_t p5 = vqrshrun_n_s16(row5, 1); - uint8x8_t p6 = vqrshrun_n_s16(row6, 1); - uint8x8_t p7 = vqrshrun_n_s16(row7, 1); - - // again, these can translate into one instruction, but often don't. -#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } -#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } - - // sadly can't use interleaved stores here since we only write - // 8 bytes to each scan line! - - // 8x8 8-bit transpose pass 1 - dct_trn8_8(p0, p1); - dct_trn8_8(p2, p3); - dct_trn8_8(p4, p5); - dct_trn8_8(p6, p7); - - // pass 2 - dct_trn8_16(p0, p2); - dct_trn8_16(p1, p3); - dct_trn8_16(p4, p6); - dct_trn8_16(p5, p7); - - // pass 3 - dct_trn8_32(p0, p4); - dct_trn8_32(p1, p5); - dct_trn8_32(p2, p6); - dct_trn8_32(p3, p7); - - // store - vst1_u8(out, p0); out += out_stride; - vst1_u8(out, p1); out += out_stride; - vst1_u8(out, p2); out += out_stride; - vst1_u8(out, p3); out += out_stride; - vst1_u8(out, p4); out += out_stride; - vst1_u8(out, p5); out += out_stride; - vst1_u8(out, p6); out += out_stride; - vst1_u8(out, p7); - -#undef dct_trn8_8 -#undef dct_trn8_16 -#undef dct_trn8_32 - } - -#undef dct_long_mul -#undef dct_long_mac -#undef dct_widen -#undef dct_wadd -#undef dct_wsub -#undef dct_bfly32o -#undef dct_pass -} - -#endif // STBI_NEON - -#define STBI__MARKER_none 0xff -// if there's a pending marker from the entropy stream, return that -// otherwise, fetch from the stream and get a marker. if there's no -// marker, return 0xff, which is never a valid marker value -static stbi_uc stbi__get_marker(stbi__jpeg *j) -{ - stbi_uc x; - if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } - x = stbi__get8(j->s); - if (x != 0xff) return STBI__MARKER_none; - while (x == 0xff) - x = stbi__get8(j->s); - return x; -} - -// in each scan, we'll have scan_n components, and the order -// of the components is specified by order[] -#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) - -// after a restart interval, stbi__jpeg_reset the entropy decoder and -// the dc prediction -static void stbi__jpeg_reset(stbi__jpeg *j) -{ - j->code_bits = 0; - j->code_buffer = 0; - j->nomore = 0; - j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; - j->marker = STBI__MARKER_none; - j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; - j->eob_run = 0; - // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, - // since we don't even allow 1<<30 pixels -} - -static int stbi__parse_entropy_coded_data(stbi__jpeg *z) -{ - stbi__jpeg_reset(z); - if (!z->progressive) { - if (z->scan_n == 1) { - int i,j; - STBI_SIMD_ALIGN(short, data[64]); - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - STBI_SIMD_ALIGN(short, data[64]); - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x)*8; - int y2 = (j*z->img_comp[n].v + y)*8; - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } - } else { - if (z->scan_n == 1) { - int i,j; - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - if (z->spec_start == 0) { - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } else { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) - return 0; - } - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x); - int y2 = (j*z->img_comp[n].v + y); - short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } - } -} - -static void stbi__jpeg_dequantize(short *data, stbi_uc *dequant) -{ - int i; - for (i=0; i < 64; ++i) - data[i] *= dequant[i]; -} - -static void stbi__jpeg_finish(stbi__jpeg *z) -{ - if (z->progressive) { - // dequantize and idct the data - int i,j,n; - for (n=0; n < z->s->img_n; ++n) { - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - } - } - } - } -} - -static int stbi__process_marker(stbi__jpeg *z, int m) -{ - int L; - switch (m) { - case STBI__MARKER_none: // no marker found - return stbi__err("expected marker","Corrupt JPEG"); - - case 0xDD: // DRI - specify restart interval - if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); - z->restart_interval = stbi__get16be(z->s); - return 1; - - case 0xDB: // DQT - define quantization table - L = stbi__get16be(z->s)-2; - while (L > 0) { - int q = stbi__get8(z->s); - int p = q >> 4; - int t = q & 15,i; - if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG"); - if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); - for (i=0; i < 64; ++i) - z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s); - L -= 65; - } - return L==0; - - case 0xC4: // DHT - define huffman table - L = stbi__get16be(z->s)-2; - while (L > 0) { - stbi_uc *v; - int sizes[16],i,n=0; - int q = stbi__get8(z->s); - int tc = q >> 4; - int th = q & 15; - if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); - for (i=0; i < 16; ++i) { - sizes[i] = stbi__get8(z->s); - n += sizes[i]; - } - L -= 17; - if (tc == 0) { - if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; - v = z->huff_dc[th].values; - } else { - if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; - v = z->huff_ac[th].values; - } - for (i=0; i < n; ++i) - v[i] = stbi__get8(z->s); - if (tc != 0) - stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); - L -= n; - } - return L==0; - } - // check for comment block or APP blocks - if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { - stbi__skip(z->s, stbi__get16be(z->s)-2); - return 1; - } - return 0; -} - -// after we see SOS -static int stbi__process_scan_header(stbi__jpeg *z) -{ - int i; - int Ls = stbi__get16be(z->s); - z->scan_n = stbi__get8(z->s); - if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); - if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); - for (i=0; i < z->scan_n; ++i) { - int id = stbi__get8(z->s), which; - int q = stbi__get8(z->s); - for (which = 0; which < z->s->img_n; ++which) - if (z->img_comp[which].id == id) - break; - if (which == z->s->img_n) return 0; // no match - z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); - z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); - z->order[i] = which; - } - - { - int aa; - z->spec_start = stbi__get8(z->s); - z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 - aa = stbi__get8(z->s); - z->succ_high = (aa >> 4); - z->succ_low = (aa & 15); - if (z->progressive) { - if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) - return stbi__err("bad SOS", "Corrupt JPEG"); - } else { - if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); - if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); - z->spec_end = 63; - } - } - - return 1; -} - -static int stbi__process_frame_header(stbi__jpeg *z, int scan) -{ - stbi__context *s = z->s; - int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG - p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline - s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG - s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires - c = stbi__get8(s); - if (c != 3 && c != 1) return stbi__err("bad component count","Corrupt JPEG"); // JFIF requires - s->img_n = c; - for (i=0; i < c; ++i) { - z->img_comp[i].data = NULL; - z->img_comp[i].linebuf = NULL; - } - - if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); - - for (i=0; i < s->img_n; ++i) { - z->img_comp[i].id = stbi__get8(s); - if (z->img_comp[i].id != i+1) // JFIF requires - if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! - return stbi__err("bad component ID","Corrupt JPEG"); - q = stbi__get8(s); - z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); - z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); - z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); - } - - if (scan != STBI__SCAN_load) return 1; - - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); - - for (i=0; i < s->img_n; ++i) { - if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; - if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; - } - - // compute interleaved mcu info - z->img_h_max = h_max; - z->img_v_max = v_max; - z->img_mcu_w = h_max * 8; - z->img_mcu_h = v_max * 8; - z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; - z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; - - for (i=0; i < s->img_n; ++i) { - // number of effective pixels (e.g. for non-interleaved MCU) - z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; - z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; - // to simplify generation, we'll allocate enough memory to decode - // the bogus oversized data from using interleaved MCUs and their - // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't - // discard the extra data until colorspace conversion - z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; - z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; - z->img_comp[i].raw_data = stbi__malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15); - - if (z->img_comp[i].raw_data == NULL) { - for(--i; i >= 0; --i) { - STBI_FREE(z->img_comp[i].raw_data); - z->img_comp[i].raw_data = NULL; - } - return stbi__err("outofmem", "Out of memory"); - } - // align blocks for idct using mmx/sse - z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); - z->img_comp[i].linebuf = NULL; - if (z->progressive) { - z->img_comp[i].coeff_w = (z->img_comp[i].w2 + 7) >> 3; - z->img_comp[i].coeff_h = (z->img_comp[i].h2 + 7) >> 3; - z->img_comp[i].raw_coeff = STBI_MALLOC(z->img_comp[i].coeff_w * z->img_comp[i].coeff_h * 64 * sizeof(short) + 15); - z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); - } else { - z->img_comp[i].coeff = 0; - z->img_comp[i].raw_coeff = 0; - } - } - - return 1; -} - -// use comparisons since in some cases we handle more than one case (e.g. SOF) -#define stbi__DNL(x) ((x) == 0xdc) -#define stbi__SOI(x) ((x) == 0xd8) -#define stbi__EOI(x) ((x) == 0xd9) -#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) -#define stbi__SOS(x) ((x) == 0xda) - -#define stbi__SOF_progressive(x) ((x) == 0xc2) - -static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) -{ - int m; - z->marker = STBI__MARKER_none; // initialize cached marker to empty - m = stbi__get_marker(z); - if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); - if (scan == STBI__SCAN_type) return 1; - m = stbi__get_marker(z); - while (!stbi__SOF(m)) { - if (!stbi__process_marker(z,m)) return 0; - m = stbi__get_marker(z); - while (m == STBI__MARKER_none) { - // some files have extra padding after their blocks, so ok, we'll scan - if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); - m = stbi__get_marker(z); - } - } - z->progressive = stbi__SOF_progressive(m); - if (!stbi__process_frame_header(z, scan)) return 0; - return 1; -} - -// decode image to YCbCr format -static int stbi__decode_jpeg_image(stbi__jpeg *j) -{ - int m; - for (m = 0; m < 4; m++) { - j->img_comp[m].raw_data = NULL; - j->img_comp[m].raw_coeff = NULL; - } - j->restart_interval = 0; - if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; - m = stbi__get_marker(j); - while (!stbi__EOI(m)) { - if (stbi__SOS(m)) { - if (!stbi__process_scan_header(j)) return 0; - if (!stbi__parse_entropy_coded_data(j)) return 0; - if (j->marker == STBI__MARKER_none ) { - // handle 0s at the end of image data from IP Kamera 9060 - while (!stbi__at_eof(j->s)) { - int x = stbi__get8(j->s); - if (x == 255) { - j->marker = stbi__get8(j->s); - break; - } else if (x != 0) { - return stbi__err("junk before marker", "Corrupt JPEG"); - } - } - // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 - } - } else { - if (!stbi__process_marker(j, m)) return 0; - } - m = stbi__get_marker(j); - } - if (j->progressive) - stbi__jpeg_finish(j); - return 1; -} - -// static jfif-centered resampling (across block boundaries) - -typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, - int w, int hs); - -#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) - -static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - STBI_NOTUSED(out); - STBI_NOTUSED(in_far); - STBI_NOTUSED(w); - STBI_NOTUSED(hs); - return in_near; -} - -static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples vertically for every one in input - int i; - STBI_NOTUSED(hs); - for (i=0; i < w; ++i) - out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); - return out; -} - -static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples horizontally for every one in input - int i; - stbi_uc *input = in_near; - - if (w == 1) { - // if only one sample, can't do any interpolation - out[0] = out[1] = input[0]; - return out; - } - - out[0] = input[0]; - out[1] = stbi__div4(input[0]*3 + input[1] + 2); - for (i=1; i < w-1; ++i) { - int n = 3*input[i]+2; - out[i*2+0] = stbi__div4(n+input[i-1]); - out[i*2+1] = stbi__div4(n+input[i+1]); - } - out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); - out[i*2+1] = input[w-1]; - - STBI_NOTUSED(in_far); - STBI_NOTUSED(hs); - - return out; -} - -#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) - -static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i,t0,t1; - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - out[0] = stbi__div4(t1+2); - for (i=1; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); - - STBI_NOTUSED(hs); - - return out; -} - -#if defined(STBI_SSE2) || defined(STBI_NEON) -static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i=0,t0,t1; - - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - // process groups of 8 pixels for as long as we can. - // note we can't handle the last pixel in a row in this loop - // because we need to handle the filter boundary conditions. - for (; i < ((w-1) & ~7); i += 8) { -#if defined(STBI_SSE2) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - __m128i zero = _mm_setzero_si128(); - __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); - __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); - __m128i farw = _mm_unpacklo_epi8(farb, zero); - __m128i nearw = _mm_unpacklo_epi8(nearb, zero); - __m128i diff = _mm_sub_epi16(farw, nearw); - __m128i nears = _mm_slli_epi16(nearw, 2); - __m128i curr = _mm_add_epi16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - __m128i prv0 = _mm_slli_si128(curr, 2); - __m128i nxt0 = _mm_srli_si128(curr, 2); - __m128i prev = _mm_insert_epi16(prv0, t1, 0); - __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - __m128i bias = _mm_set1_epi16(8); - __m128i curs = _mm_slli_epi16(curr, 2); - __m128i prvd = _mm_sub_epi16(prev, curr); - __m128i nxtd = _mm_sub_epi16(next, curr); - __m128i curb = _mm_add_epi16(curs, bias); - __m128i even = _mm_add_epi16(prvd, curb); - __m128i odd = _mm_add_epi16(nxtd, curb); - - // interleave even and odd pixels, then undo scaling. - __m128i int0 = _mm_unpacklo_epi16(even, odd); - __m128i int1 = _mm_unpackhi_epi16(even, odd); - __m128i de0 = _mm_srli_epi16(int0, 4); - __m128i de1 = _mm_srli_epi16(int1, 4); - - // pack and write output - __m128i outv = _mm_packus_epi16(de0, de1); - _mm_storeu_si128((__m128i *) (out + i*2), outv); -#elif defined(STBI_NEON) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - uint8x8_t farb = vld1_u8(in_far + i); - uint8x8_t nearb = vld1_u8(in_near + i); - int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); - int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); - int16x8_t curr = vaddq_s16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - int16x8_t prv0 = vextq_s16(curr, curr, 7); - int16x8_t nxt0 = vextq_s16(curr, curr, 1); - int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); - int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - int16x8_t curs = vshlq_n_s16(curr, 2); - int16x8_t prvd = vsubq_s16(prev, curr); - int16x8_t nxtd = vsubq_s16(next, curr); - int16x8_t even = vaddq_s16(curs, prvd); - int16x8_t odd = vaddq_s16(curs, nxtd); - - // undo scaling and round, then store with even/odd phases interleaved - uint8x8x2_t o; - o.val[0] = vqrshrun_n_s16(even, 4); - o.val[1] = vqrshrun_n_s16(odd, 4); - vst2_u8(out + i*2, o); -#endif - - // "previous" value for next iter - t1 = 3*in_near[i+7] + in_far[i+7]; - } - - t0 = t1; - t1 = 3*in_near[i] + in_far[i]; - out[i*2] = stbi__div16(3*t1 + t0 + 8); - - for (++i; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); - - STBI_NOTUSED(hs); - - return out; -} -#endif - -static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // resample with nearest-neighbor - int i,j; - STBI_NOTUSED(in_far); - for (i=0; i < w; ++i) - for (j=0; j < hs; ++j) - out[i*hs+j] = in_near[i]; - return out; -} - -#ifdef STBI_JPEG_OLD -// this is the same YCbCr-to-RGB calculation that stb_image has used -// historically before the algorithm changes in 1.49 -#define float2fixed(x) ((int) ((x) * 65536 + 0.5)) -static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 16) + 32768; // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr*float2fixed(1.40200f); - g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); - b = y_fixed + cb*float2fixed(1.77200f); - r >>= 16; - g >>= 16; - b >>= 16; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } -} -#else -// this is a reduced-precision calculation of YCbCr-to-RGB introduced -// to make sure the code produces the same results in both SIMD and scalar -#define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) -static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* float2fixed(1.40200f); - g = y_fixed + (cr*-float2fixed(0.71414f)) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } -} -#endif - -#if defined(STBI_SSE2) || defined(STBI_NEON) -static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) -{ - int i = 0; - -#ifdef STBI_SSE2 - // step == 3 is pretty ugly on the final interleave, and i'm not convinced - // it's useful in practice (you wouldn't use it for textures, for example). - // so just accelerate step == 4 case. - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - __m128i signflip = _mm_set1_epi8(-0x80); - __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); - __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); - __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); - __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); - __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); - __m128i xw = _mm_set1_epi16(255); // alpha channel - - for (; i+7 < count; i += 8) { - // load - __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); - __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); - __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); - __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 - __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 - - // unpack to short (and left-shift cr, cb by 8) - __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); - __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); - __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); - - // color transform - __m128i yws = _mm_srli_epi16(yw, 4); - __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); - __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); - __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); - __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); - __m128i rws = _mm_add_epi16(cr0, yws); - __m128i gwt = _mm_add_epi16(cb0, yws); - __m128i bws = _mm_add_epi16(yws, cb1); - __m128i gws = _mm_add_epi16(gwt, cr1); - - // descale - __m128i rw = _mm_srai_epi16(rws, 4); - __m128i bw = _mm_srai_epi16(bws, 4); - __m128i gw = _mm_srai_epi16(gws, 4); - - // back to byte, set up for transpose - __m128i brb = _mm_packus_epi16(rw, bw); - __m128i gxb = _mm_packus_epi16(gw, xw); - - // transpose to interleave channels - __m128i t0 = _mm_unpacklo_epi8(brb, gxb); - __m128i t1 = _mm_unpackhi_epi8(brb, gxb); - __m128i o0 = _mm_unpacklo_epi16(t0, t1); - __m128i o1 = _mm_unpackhi_epi16(t0, t1); - - // store - _mm_storeu_si128((__m128i *) (out + 0), o0); - _mm_storeu_si128((__m128i *) (out + 16), o1); - out += 32; - } - } -#endif - -#ifdef STBI_NEON - // in this version, step=3 support would be easy to add. but is there demand? - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - uint8x8_t signflip = vdup_n_u8(0x80); - int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); - int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); - int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); - int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); - - for (; i+7 < count; i += 8) { - // load - uint8x8_t y_bytes = vld1_u8(y + i); - uint8x8_t cr_bytes = vld1_u8(pcr + i); - uint8x8_t cb_bytes = vld1_u8(pcb + i); - int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); - int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); - - // expand to s16 - int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); - int16x8_t crw = vshll_n_s8(cr_biased, 7); - int16x8_t cbw = vshll_n_s8(cb_biased, 7); - - // color transform - int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); - int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); - int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); - int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); - int16x8_t rws = vaddq_s16(yws, cr0); - int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); - int16x8_t bws = vaddq_s16(yws, cb1); - - // undo scaling, round, convert to byte - uint8x8x4_t o; - o.val[0] = vqrshrun_n_s16(rws, 4); - o.val[1] = vqrshrun_n_s16(gws, 4); - o.val[2] = vqrshrun_n_s16(bws, 4); - o.val[3] = vdup_n_u8(255); - - // store, interleaving r/g/b/a - vst4_u8(out, o); - out += 8*4; - } - } -#endif - - for (; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* float2fixed(1.40200f); - g = y_fixed + cr*-float2fixed(0.71414f) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } -} -#endif - -// set up the kernels -static void stbi__setup_jpeg(stbi__jpeg *j) -{ - j->idct_block_kernel = stbi__idct_block; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; - -#ifdef STBI_SSE2 - if (stbi__sse2_available()) { - j->idct_block_kernel = stbi__idct_simd; - #ifndef STBI_JPEG_OLD - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - #endif - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; - } -#endif - -#ifdef STBI_NEON - j->idct_block_kernel = stbi__idct_simd; - #ifndef STBI_JPEG_OLD - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - #endif - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; -#endif -} - -// clean up the temporary component buffers -static void stbi__cleanup_jpeg(stbi__jpeg *j) -{ - int i; - for (i=0; i < j->s->img_n; ++i) { - if (j->img_comp[i].raw_data) { - STBI_FREE(j->img_comp[i].raw_data); - j->img_comp[i].raw_data = NULL; - j->img_comp[i].data = NULL; - } - if (j->img_comp[i].raw_coeff) { - STBI_FREE(j->img_comp[i].raw_coeff); - j->img_comp[i].raw_coeff = 0; - j->img_comp[i].coeff = 0; - } - if (j->img_comp[i].linebuf) { - STBI_FREE(j->img_comp[i].linebuf); - j->img_comp[i].linebuf = NULL; - } - } -} - -typedef struct -{ - resample_row_func resample; - stbi_uc *line0,*line1; - int hs,vs; // expansion factor in each axis - int w_lores; // horizontal pixels pre-expansion - int ystep; // how far through vertical expansion we are - int ypos; // which pre-expansion row we're on -} stbi__resample; - -static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) -{ - int n, decode_n; - z->s->img_n = 0; // make stbi__cleanup_jpeg safe - - // validate req_comp - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - - // load a jpeg image from whichever source, but leave in YCbCr format - if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } - - // determine actual number of components to generate - n = req_comp ? req_comp : z->s->img_n; - - if (z->s->img_n == 3 && n < 3) - decode_n = 1; - else - decode_n = z->s->img_n; - - // resample and color-convert - { - int k; - unsigned int i,j; - stbi_uc *output; - stbi_uc *coutput[4]; - - stbi__resample res_comp[4]; - - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - - // allocate line buffer big enough for upsampling off the edges - // with upsample factor of 4 - z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); - if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - r->hs = z->img_h_max / z->img_comp[k].h; - r->vs = z->img_v_max / z->img_comp[k].v; - r->ystep = r->vs >> 1; - r->w_lores = (z->s->img_x + r->hs-1) / r->hs; - r->ypos = 0; - r->line0 = r->line1 = z->img_comp[k].data; - - if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; - else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; - else r->resample = stbi__resample_row_generic; - } - - // can't error after this so, this is safe - output = (stbi_uc *) stbi__malloc(n * z->s->img_x * z->s->img_y + 1); - if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - // now go ahead and resample - for (j=0; j < z->s->img_y; ++j) { - stbi_uc *out = output + n * z->s->img_x * j; - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - int y_bot = r->ystep >= (r->vs >> 1); - coutput[k] = r->resample(z->img_comp[k].linebuf, - y_bot ? r->line1 : r->line0, - y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); - if (++r->ystep >= r->vs) { - r->ystep = 0; - r->line0 = r->line1; - if (++r->ypos < z->img_comp[k].y) - r->line1 += z->img_comp[k].w2; - } - } - if (n >= 3) { - stbi_uc *y = coutput[0]; - if (z->s->img_n == 3) { - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } else - for (i=0; i < z->s->img_x; ++i) { - out[0] = out[1] = out[2] = y[i]; - out[3] = 255; // not used if n==3 - out += n; - } - } else { - stbi_uc *y = coutput[0]; - if (n == 1) - for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; - else - for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; - } - } - stbi__cleanup_jpeg(z); - *out_x = z->s->img_x; - *out_y = z->s->img_y; - if (comp) *comp = z->s->img_n; // report original components, not output - return output; - } -} - -static unsigned char *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__jpeg j; - j.s = s; - stbi__setup_jpeg(&j); - return load_jpeg_image(&j, x,y,comp,req_comp); -} - -static int stbi__jpeg_test(stbi__context *s) -{ - int r; - stbi__jpeg j; - j.s = s; - stbi__setup_jpeg(&j); - r = stbi__decode_jpeg_header(&j, STBI__SCAN_type); - stbi__rewind(s); - return r; -} - -static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) -{ - if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { - stbi__rewind( j->s ); - return 0; - } - if (x) *x = j->s->img_x; - if (y) *y = j->s->img_y; - if (comp) *comp = j->s->img_n; - return 1; -} - -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__jpeg j; - j.s = s; - return stbi__jpeg_info_raw(&j, x, y, comp); -} -#endif - -// public domain zlib decode v0.2 Sean Barrett 2006-11-18 -// simple implementation -// - all input must be provided in an upfront buffer -// - all output is written to a single output buffer (can malloc/realloc) -// performance -// - fast huffman - -#ifndef STBI_NO_ZLIB - -// fast-way is faster to check than jpeg huffman, but slow way is slower -#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables -#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) - -// zlib-style huffman encoding -// (jpegs packs from left, zlib from right, so can't share code) -typedef struct -{ - stbi__uint16 fast[1 << STBI__ZFAST_BITS]; - stbi__uint16 firstcode[16]; - int maxcode[17]; - stbi__uint16 firstsymbol[16]; - stbi_uc size[288]; - stbi__uint16 value[288]; -} stbi__zhuffman; - -stbi_inline static int stbi__bitreverse16(int n) -{ - n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); - n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); - n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); - n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); - return n; -} - -stbi_inline static int stbi__bit_reverse(int v, int bits) -{ - STBI_ASSERT(bits <= 16); - // to bit reverse n bits, reverse 16 and shift - // e.g. 11 bits, bit reverse and shift away 5 - return stbi__bitreverse16(v) >> (16-bits); -} - -static int stbi__zbuild_huffman(stbi__zhuffman *z, stbi_uc *sizelist, int num) -{ - int i,k=0; - int code, next_code[16], sizes[17]; - - // DEFLATE spec for generating codes - memset(sizes, 0, sizeof(sizes)); - memset(z->fast, 0, sizeof(z->fast)); - for (i=0; i < num; ++i) - ++sizes[sizelist[i]]; - sizes[0] = 0; - for (i=1; i < 16; ++i) - if (sizes[i] > (1 << i)) - return stbi__err("bad sizes", "Corrupt PNG"); - code = 0; - for (i=1; i < 16; ++i) { - next_code[i] = code; - z->firstcode[i] = (stbi__uint16) code; - z->firstsymbol[i] = (stbi__uint16) k; - code = (code + sizes[i]); - if (sizes[i]) - if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); - z->maxcode[i] = code << (16-i); // preshift for inner loop - code <<= 1; - k += sizes[i]; - } - z->maxcode[16] = 0x10000; // sentinel - for (i=0; i < num; ++i) { - int s = sizelist[i]; - if (s) { - int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; - stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); - z->size [c] = (stbi_uc ) s; - z->value[c] = (stbi__uint16) i; - if (s <= STBI__ZFAST_BITS) { - int j = stbi__bit_reverse(next_code[s],s); - while (j < (1 << STBI__ZFAST_BITS)) { - z->fast[j] = fastv; - j += (1 << s); - } - } - ++next_code[s]; - } - } - return 1; -} - -// zlib-from-memory implementation for PNG reading -// because PNG allows splitting the zlib stream arbitrarily, -// and it's annoying structurally to have PNG call ZLIB call PNG, -// we require PNG read all the IDATs and combine them into a single -// memory buffer - -typedef struct -{ - stbi_uc *zbuffer, *zbuffer_end; - int num_bits; - stbi__uint32 code_buffer; - - char *zout; - char *zout_start; - char *zout_end; - int z_expandable; - - stbi__zhuffman z_length, z_distance; -} stbi__zbuf; - -stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) -{ - if (z->zbuffer >= z->zbuffer_end) return 0; - return *z->zbuffer++; -} - -static void stbi__fill_bits(stbi__zbuf *z) -{ - do { - STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); - z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; - z->num_bits += 8; - } while (z->num_bits <= 24); -} - -stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) -{ - unsigned int k; - if (z->num_bits < n) stbi__fill_bits(z); - k = z->code_buffer & ((1 << n) - 1); - z->code_buffer >>= n; - z->num_bits -= n; - return k; -} - -static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s,k; - // not resolved by fast table, so compute it the slow way - // use jpeg approach, which requires MSbits at top - k = stbi__bit_reverse(a->code_buffer, 16); - for (s=STBI__ZFAST_BITS+1; ; ++s) - if (k < z->maxcode[s]) - break; - if (s == 16) return -1; // invalid code! - // code size is s, so: - b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; - STBI_ASSERT(z->size[b] == s); - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; -} - -stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s; - if (a->num_bits < 16) stbi__fill_bits(a); - b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; - if (b) { - s = b >> 9; - a->code_buffer >>= s; - a->num_bits -= s; - return b & 511; - } - return stbi__zhuffman_decode_slowpath(a, z); -} - -static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes -{ - char *q; - int cur, limit, old_limit; - z->zout = zout; - if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); - cur = (int) (z->zout - z->zout_start); - limit = old_limit = (int) (z->zout_end - z->zout_start); - while (cur + n > limit) - limit *= 2; - q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); - STBI_NOTUSED(old_limit); - if (q == NULL) return stbi__err("outofmem", "Out of memory"); - z->zout_start = q; - z->zout = q + cur; - z->zout_end = q + limit; - return 1; -} - -static int stbi__zlength_base[31] = { - 3,4,5,6,7,8,9,10,11,13, - 15,17,19,23,27,31,35,43,51,59, - 67,83,99,115,131,163,195,227,258,0,0 }; - -static int stbi__zlength_extra[31]= -{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; - -static int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, -257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; - -static int stbi__zdist_extra[32] = -{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -static int stbi__parse_huffman_block(stbi__zbuf *a) -{ - char *zout = a->zout; - for(;;) { - int z = stbi__zhuffman_decode(a, &a->z_length); - if (z < 256) { - if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes - if (zout >= a->zout_end) { - if (!stbi__zexpand(a, zout, 1)) return 0; - zout = a->zout; - } - *zout++ = (char) z; - } else { - stbi_uc *p; - int len,dist; - if (z == 256) { - a->zout = zout; - return 1; - } - z -= 257; - len = stbi__zlength_base[z]; - if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); - z = stbi__zhuffman_decode(a, &a->z_distance); - if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); - dist = stbi__zdist_base[z]; - if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); - if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); - if (zout + len > a->zout_end) { - if (!stbi__zexpand(a, zout, len)) return 0; - zout = a->zout; - } - p = (stbi_uc *) (zout - dist); - if (dist == 1) { // run of one byte; common in images. - stbi_uc v = *p; - if (len) { do *zout++ = v; while (--len); } - } else { - if (len) { do *zout++ = *p++; while (--len); } - } - } - } -} - -static int stbi__compute_huffman_codes(stbi__zbuf *a) -{ - static stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; - stbi__zhuffman z_codelength; - stbi_uc lencodes[286+32+137];//padding for maximum single op - stbi_uc codelength_sizes[19]; - int i,n; - - int hlit = stbi__zreceive(a,5) + 257; - int hdist = stbi__zreceive(a,5) + 1; - int hclen = stbi__zreceive(a,4) + 4; - - memset(codelength_sizes, 0, sizeof(codelength_sizes)); - for (i=0; i < hclen; ++i) { - int s = stbi__zreceive(a,3); - codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; - } - if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; - - n = 0; - while (n < hlit + hdist) { - int c = stbi__zhuffman_decode(a, &z_codelength); - if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); - if (c < 16) - lencodes[n++] = (stbi_uc) c; - else if (c == 16) { - c = stbi__zreceive(a,2)+3; - memset(lencodes+n, lencodes[n-1], c); - n += c; - } else if (c == 17) { - c = stbi__zreceive(a,3)+3; - memset(lencodes+n, 0, c); - n += c; - } else { - STBI_ASSERT(c == 18); - c = stbi__zreceive(a,7)+11; - memset(lencodes+n, 0, c); - n += c; - } - } - if (n != hlit+hdist) return stbi__err("bad codelengths","Corrupt PNG"); - if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; - return 1; -} - -static int stbi__parse_uncomperssed_block(stbi__zbuf *a) -{ - stbi_uc header[4]; - int len,nlen,k; - if (a->num_bits & 7) - stbi__zreceive(a, a->num_bits & 7); // discard - // drain the bit-packed data into header - k = 0; - while (a->num_bits > 0) { - header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check - a->code_buffer >>= 8; - a->num_bits -= 8; - } - STBI_ASSERT(a->num_bits == 0); - // now fill header the normal way - while (k < 4) - header[k++] = stbi__zget8(a); - len = header[1] * 256 + header[0]; - nlen = header[3] * 256 + header[2]; - if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); - if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); - if (a->zout + len > a->zout_end) - if (!stbi__zexpand(a, a->zout, len)) return 0; - memcpy(a->zout, a->zbuffer, len); - a->zbuffer += len; - a->zout += len; - return 1; -} - -static int stbi__parse_zlib_header(stbi__zbuf *a) -{ - int cmf = stbi__zget8(a); - int cm = cmf & 15; - /* int cinfo = cmf >> 4; */ - int flg = stbi__zget8(a); - if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec - if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png - if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png - // window = 1 << (8 + cinfo)... but who cares, we fully buffer output - return 1; -} - -// @TODO: should statically initialize these for optimal thread safety -static stbi_uc stbi__zdefault_length[288], stbi__zdefault_distance[32]; -static void stbi__init_zdefaults(void) -{ - int i; // use <= to match clearly with spec - for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; - for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; - for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; - for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; - - for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; -} - -static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) -{ - int final, type; - if (parse_header) - if (!stbi__parse_zlib_header(a)) return 0; - a->num_bits = 0; - a->code_buffer = 0; - do { - final = stbi__zreceive(a,1); - type = stbi__zreceive(a,2); - if (type == 0) { - if (!stbi__parse_uncomperssed_block(a)) return 0; - } else if (type == 3) { - return 0; - } else { - if (type == 1) { - // use fixed code lengths - if (!stbi__zdefault_distance[31]) stbi__init_zdefaults(); - if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; - } else { - if (!stbi__compute_huffman_codes(a)) return 0; - } - if (!stbi__parse_huffman_block(a)) return 0; - } - } while (!final); - return 1; -} - -static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) -{ - a->zout_start = obuf; - a->zout = obuf; - a->zout_end = obuf + olen; - a->z_expandable = exp; - - return stbi__parse_zlib(a, parse_header); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) -{ - return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(16384); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer+len; - if (stbi__do_zlib(&a, p, 16384, 1, 0)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) - return (int) (a.zout - a.zout_start); - else - return -1; -} -#endif - -// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 -// simple implementation -// - only 8-bit samples -// - no CRC checking -// - allocates lots of intermediate memory -// - avoids problem of streaming data between subsystems -// - avoids explicit window management -// performance -// - uses stb_zlib, a PD zlib implementation with fast huffman decoding - -#ifndef STBI_NO_PNG -typedef struct -{ - stbi__uint32 length; - stbi__uint32 type; -} stbi__pngchunk; - -static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) -{ - stbi__pngchunk c; - c.length = stbi__get32be(s); - c.type = stbi__get32be(s); - return c; -} - -static int stbi__check_png_header(stbi__context *s) -{ - static stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; - int i; - for (i=0; i < 8; ++i) - if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); - return 1; -} - -typedef struct -{ - stbi__context *s; - stbi_uc *idata, *expanded, *out; -} stbi__png; - - -enum { - STBI__F_none=0, - STBI__F_sub=1, - STBI__F_up=2, - STBI__F_avg=3, - STBI__F_paeth=4, - // synthetic filters used for first scanline to avoid needing a dummy row of 0s - STBI__F_avg_first, - STBI__F_paeth_first -}; - -static stbi_uc first_row_filter[5] = -{ - STBI__F_none, - STBI__F_sub, - STBI__F_none, - STBI__F_avg_first, - STBI__F_paeth_first -}; - -static int stbi__paeth(int a, int b, int c) -{ - int p = a + b - c; - int pa = abs(p-a); - int pb = abs(p-b); - int pc = abs(p-c); - if (pa <= pb && pa <= pc) return a; - if (pb <= pc) return b; - return c; -} - -static stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; - -// create the png data from post-deflated data -static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) -{ - stbi__context *s = a->s; - stbi__uint32 i,j,stride = x*out_n; - stbi__uint32 img_len, img_width_bytes; - int k; - int img_n = s->img_n; // copy it into a local for later - - STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); - a->out = (stbi_uc *) stbi__malloc(x * y * out_n); // extra bytes to write off the end into - if (!a->out) return stbi__err("outofmem", "Out of memory"); - - img_width_bytes = (((img_n * x * depth) + 7) >> 3); - img_len = (img_width_bytes + 1) * y; - if (s->img_x == x && s->img_y == y) { - if (raw_len != img_len) return stbi__err("not enough pixels","Corrupt PNG"); - } else { // interlaced: - if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); - } - - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *prior = cur - stride; - int filter = *raw++; - int filter_bytes = img_n; - int width = x; - if (filter > 4) - return stbi__err("invalid filter","Corrupt PNG"); - - if (depth < 8) { - STBI_ASSERT(img_width_bytes <= x); - cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place - filter_bytes = 1; - width = img_width_bytes; - } - - // if first row, use special filter that doesn't sample previous row - if (j == 0) filter = first_row_filter[filter]; - - // handle first byte explicitly - for (k=0; k < filter_bytes; ++k) { - switch (filter) { - case STBI__F_none : cur[k] = raw[k]; break; - case STBI__F_sub : cur[k] = raw[k]; break; - case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; - case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; - case STBI__F_avg_first : cur[k] = raw[k]; break; - case STBI__F_paeth_first: cur[k] = raw[k]; break; - } - } - - if (depth == 8) { - if (img_n != out_n) - cur[img_n] = 255; // first pixel - raw += img_n; - cur += out_n; - prior += out_n; - } else { - raw += 1; - cur += 1; - prior += 1; - } - - // this is a little gross, so that we don't switch per-pixel or per-component - if (depth < 8 || img_n == out_n) { - int nk = (width - 1)*img_n; - #define CASE(f) \ - case f: \ - for (k=0; k < nk; ++k) - switch (filter) { - // "none" filter turns into a memcpy here; make that explicit. - case STBI__F_none: memcpy(cur, raw, nk); break; - CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); break; - CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); break; - CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); break; - CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); break; - CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); break; - } - #undef CASE - raw += nk; - } else { - STBI_ASSERT(img_n+1 == out_n); - #define CASE(f) \ - case f: \ - for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ - for (k=0; k < img_n; ++k) - switch (filter) { - CASE(STBI__F_none) cur[k] = raw[k]; break; - CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-out_n]); break; - CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-out_n])>>1)); break; - CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; - CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-out_n] >> 1)); break; - CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],0,0)); break; - } - #undef CASE - } - } - - // we make a separate pass to expand bits to pixels; for performance, - // this could run two scanlines behind the above code, so it won't - // intefere with filtering but will still be in the cache. - if (depth < 8) { - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; - // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit - // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop - stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range - - // note that the final byte might overshoot and write more data than desired. - // we can allocate enough data that this never writes out of memory, but it - // could also overwrite the next scanline. can it overwrite non-empty data - // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. - // so we need to explicitly clamp the final ones - - if (depth == 4) { - for (k=x*img_n; k >= 2; k-=2, ++in) { - *cur++ = scale * ((*in >> 4) ); - *cur++ = scale * ((*in ) & 0x0f); - } - if (k > 0) *cur++ = scale * ((*in >> 4) ); - } else if (depth == 2) { - for (k=x*img_n; k >= 4; k-=4, ++in) { - *cur++ = scale * ((*in >> 6) ); - *cur++ = scale * ((*in >> 4) & 0x03); - *cur++ = scale * ((*in >> 2) & 0x03); - *cur++ = scale * ((*in ) & 0x03); - } - if (k > 0) *cur++ = scale * ((*in >> 6) ); - if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); - if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); - } else if (depth == 1) { - for (k=x*img_n; k >= 8; k-=8, ++in) { - *cur++ = scale * ((*in >> 7) ); - *cur++ = scale * ((*in >> 6) & 0x01); - *cur++ = scale * ((*in >> 5) & 0x01); - *cur++ = scale * ((*in >> 4) & 0x01); - *cur++ = scale * ((*in >> 3) & 0x01); - *cur++ = scale * ((*in >> 2) & 0x01); - *cur++ = scale * ((*in >> 1) & 0x01); - *cur++ = scale * ((*in ) & 0x01); - } - if (k > 0) *cur++ = scale * ((*in >> 7) ); - if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); - if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); - if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); - if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); - if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); - if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); - } - if (img_n != out_n) { - int q; - // insert alpha = 255 - cur = a->out + stride*j; - if (img_n == 1) { - for (q=x-1; q >= 0; --q) { - cur[q*2+1] = 255; - cur[q*2+0] = cur[q]; - } - } else { - STBI_ASSERT(img_n == 3); - for (q=x-1; q >= 0; --q) { - cur[q*4+3] = 255; - cur[q*4+2] = cur[q*3+2]; - cur[q*4+1] = cur[q*3+1]; - cur[q*4+0] = cur[q*3+0]; - } - } - } - } - } - - return 1; -} - -static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) -{ - stbi_uc *final; - int p; - if (!interlaced) - return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); - - // de-interlacing - final = (stbi_uc *) stbi__malloc(a->s->img_x * a->s->img_y * out_n); - for (p=0; p < 7; ++p) { - int xorig[] = { 0,4,0,2,0,1,0 }; - int yorig[] = { 0,0,4,0,2,0,1 }; - int xspc[] = { 8,8,4,4,2,2,1 }; - int yspc[] = { 8,8,8,4,4,2,2 }; - int i,j,x,y; - // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 - x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; - y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; - if (x && y) { - stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; - if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { - STBI_FREE(final); - return 0; - } - for (j=0; j < y; ++j) { - for (i=0; i < x; ++i) { - int out_y = j*yspc[p]+yorig[p]; - int out_x = i*xspc[p]+xorig[p]; - memcpy(final + out_y*a->s->img_x*out_n + out_x*out_n, - a->out + (j*x+i)*out_n, out_n); - } - } - STBI_FREE(a->out); - image_data += img_len; - image_data_len -= img_len; - } - } - a->out = final; - - return 1; -} - -static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - // compute color-based transparency, assuming we've - // already got 255 as the alpha value in the output - STBI_ASSERT(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i=0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 255); - p += 2; - } - } else { - for (i=0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; -} - -static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) -{ - stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; - stbi_uc *p, *temp_out, *orig = a->out; - - p = (stbi_uc *) stbi__malloc(pixel_count * pal_img_n); - if (p == NULL) return stbi__err("outofmem", "Out of memory"); - - // between here and free(out) below, exitting would leak - temp_out = p; - - if (pal_img_n == 3) { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p += 3; - } - } else { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p[3] = palette[n+3]; - p += 4; - } - } - STBI_FREE(a->out); - a->out = temp_out; - - STBI_NOTUSED(len); - - return 1; -} - -static int stbi__unpremultiply_on_load = 0; -static int stbi__de_iphone_flag = 0; - -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) -{ - stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; -} - -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) -{ - stbi__de_iphone_flag = flag_true_if_should_convert; -} - -static void stbi__de_iphone(stbi__png *z) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - if (s->img_out_n == 3) { // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 3; - } - } else { - STBI_ASSERT(s->img_out_n == 4); - if (stbi__unpremultiply_on_load) { - // convert bgr to rgb and unpremultiply - for (i=0; i < pixel_count; ++i) { - stbi_uc a = p[3]; - stbi_uc t = p[0]; - if (a) { - p[0] = p[2] * 255 / a; - p[1] = p[1] * 255 / a; - p[2] = t * 255 / a; - } else { - p[0] = p[2]; - p[2] = t; - } - p += 4; - } - } else { - // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 4; - } - } - } -} - -#define STBI__PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) - -static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) -{ - stbi_uc palette[1024], pal_img_n=0; - stbi_uc has_trans=0, tc[3]; - stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; - int first=1,k,interlace=0, color=0, depth=0, is_iphone=0; - stbi__context *s = z->s; - - z->expanded = NULL; - z->idata = NULL; - z->out = NULL; - - if (!stbi__check_png_header(s)) return 0; - - if (scan == STBI__SCAN_type) return 1; - - for (;;) { - stbi__pngchunk c = stbi__get_chunk_header(s); - switch (c.type) { - case STBI__PNG_TYPE('C','g','B','I'): - is_iphone = 1; - stbi__skip(s, c.length); - break; - case STBI__PNG_TYPE('I','H','D','R'): { - int comp,filter; - if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); - first = 0; - if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); - s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); - s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); - depth = stbi__get8(s); if (depth != 1 && depth != 2 && depth != 4 && depth != 8) return stbi__err("1/2/4/8-bit only","PNG not supported: 1/2/4/8-bit only"); - color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); - if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); - comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); - filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); - interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); - if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); - if (!pal_img_n) { - s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); - if (scan == STBI__SCAN_header) return 1; - } else { - // if paletted, then pal_n is our final components, and - // img_n is # components to decompress/filter. - s->img_n = 1; - if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); - // if SCAN_header, have to scan to see if we have a tRNS - } - break; - } - - case STBI__PNG_TYPE('P','L','T','E'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); - pal_len = c.length / 3; - if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); - for (i=0; i < pal_len; ++i) { - palette[i*4+0] = stbi__get8(s); - palette[i*4+1] = stbi__get8(s); - palette[i*4+2] = stbi__get8(s); - palette[i*4+3] = 255; - } - break; - } - - case STBI__PNG_TYPE('t','R','N','S'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); - if (pal_img_n) { - if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } - if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); - if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); - pal_img_n = 4; - for (i=0; i < c.length; ++i) - palette[i*4+3] = stbi__get8(s); - } else { - if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); - if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); - has_trans = 1; - for (k=0; k < s->img_n; ++k) - tc[k] = (stbi_uc) (stbi__get16be(s) & 255) * stbi__depth_scale_table[depth]; // non 8-bit images will be larger - } - break; - } - - case STBI__PNG_TYPE('I','D','A','T'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); - if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } - if ((int)(ioff + c.length) < (int)ioff) return 0; - if (ioff + c.length > idata_limit) { - stbi__uint32 idata_limit_old = idata_limit; - stbi_uc *p; - if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; - while (ioff + c.length > idata_limit) - idata_limit *= 2; - STBI_NOTUSED(idata_limit_old); - p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); - z->idata = p; - } - if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); - ioff += c.length; - break; - } - - case STBI__PNG_TYPE('I','E','N','D'): { - stbi__uint32 raw_len, bpl; - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (scan != STBI__SCAN_load) return 1; - if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); - // initial guess for decoded data size to avoid unnecessary reallocs - bpl = (s->img_x * depth + 7) / 8; // bytes per line, per component - raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; - z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); - if (z->expanded == NULL) return 0; // zlib should set error - STBI_FREE(z->idata); z->idata = NULL; - if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) - s->img_out_n = s->img_n+1; - else - s->img_out_n = s->img_n; - if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, depth, color, interlace)) return 0; - if (has_trans) - if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; - if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) - stbi__de_iphone(z); - if (pal_img_n) { - // pal_img_n == 3 or 4 - s->img_n = pal_img_n; // record the actual colors we had - s->img_out_n = pal_img_n; - if (req_comp >= 3) s->img_out_n = req_comp; - if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) - return 0; - } - STBI_FREE(z->expanded); z->expanded = NULL; - return 1; - } - - default: - // if critical, fail - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if ((c.type & (1 << 29)) == 0) { - #ifndef STBI_NO_FAILURE_STRINGS - // not threadsafe - static char invalid_chunk[] = "XXXX PNG chunk not known"; - invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); - invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); - invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); - invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); - #endif - return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); - } - stbi__skip(s, c.length); - break; - } - // end of PNG chunk, read and skip CRC - stbi__get32be(s); - } -} - -static unsigned char *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp) -{ - unsigned char *result=NULL; - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { - result = p->out; - p->out = NULL; - if (req_comp && req_comp != p->s->img_out_n) { - result = stbi__convert_format(result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); - p->s->img_out_n = req_comp; - if (result == NULL) return result; - } - *x = p->s->img_x; - *y = p->s->img_y; - if (n) *n = p->s->img_out_n; - } - STBI_FREE(p->out); p->out = NULL; - STBI_FREE(p->expanded); p->expanded = NULL; - STBI_FREE(p->idata); p->idata = NULL; - - return result; -} - -static unsigned char *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__png p; - p.s = s; - return stbi__do_png(&p, x,y,comp,req_comp); -} - -static int stbi__png_test(stbi__context *s) -{ - int r; - r = stbi__check_png_header(s); - stbi__rewind(s); - return r; -} - -static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) -{ - if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { - stbi__rewind( p->s ); - return 0; - } - if (x) *x = p->s->img_x; - if (y) *y = p->s->img_y; - if (comp) *comp = p->s->img_n; - return 1; -} - -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__png p; - p.s = s; - return stbi__png_info_raw(&p, x, y, comp); -} -#endif - -// Microsoft/Windows BMP image - -#ifndef STBI_NO_BMP -static int stbi__bmp_test_raw(stbi__context *s) -{ - int r; - int sz; - if (stbi__get8(s) != 'B') return 0; - if (stbi__get8(s) != 'M') return 0; - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - stbi__get32le(s); // discard data offset - sz = stbi__get32le(s); - r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); - return r; -} - -static int stbi__bmp_test(stbi__context *s) -{ - int r = stbi__bmp_test_raw(s); - stbi__rewind(s); - return r; -} - - -// returns 0..31 for the highest set bit -static int stbi__high_bit(unsigned int z) -{ - int n=0; - if (z == 0) return -1; - if (z >= 0x10000) n += 16, z >>= 16; - if (z >= 0x00100) n += 8, z >>= 8; - if (z >= 0x00010) n += 4, z >>= 4; - if (z >= 0x00004) n += 2, z >>= 2; - if (z >= 0x00002) n += 1, z >>= 1; - return n; -} - -static int stbi__bitcount(unsigned int a) -{ - a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 - a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 - a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits - a = (a + (a >> 8)); // max 16 per 8 bits - a = (a + (a >> 16)); // max 32 per 8 bits - return a & 0xff; -} - -static int stbi__shiftsigned(int v, int shift, int bits) -{ - int result; - int z=0; - - if (shift < 0) v <<= -shift; - else v >>= shift; - result = v; - - z = bits; - while (z < 8) { - result += v >> z; - z += bits; - } - return result; -} - -typedef struct -{ - int bpp, offset, hsz; - unsigned int mr,mg,mb,ma, all_a; -} stbi__bmp_data; - -static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) -{ - int hsz; - if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - info->offset = stbi__get32le(s); - info->hsz = hsz = stbi__get32le(s); - - if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); - if (hsz == 12) { - s->img_x = stbi__get16le(s); - s->img_y = stbi__get16le(s); - } else { - s->img_x = stbi__get32le(s); - s->img_y = stbi__get32le(s); - } - if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); - info->bpp = stbi__get16le(s); - if (info->bpp == 1) return stbi__errpuc("monochrome", "BMP type not supported: 1-bit"); - if (hsz != 12) { - int compress = stbi__get32le(s); - if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); - stbi__get32le(s); // discard sizeof - stbi__get32le(s); // discard hres - stbi__get32le(s); // discard vres - stbi__get32le(s); // discard colorsused - stbi__get32le(s); // discard max important - if (hsz == 40 || hsz == 56) { - if (hsz == 56) { - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - } - if (info->bpp == 16 || info->bpp == 32) { - info->mr = info->mg = info->mb = 0; - if (compress == 0) { - if (info->bpp == 32) { - info->mr = 0xffu << 16; - info->mg = 0xffu << 8; - info->mb = 0xffu << 0; - info->ma = 0xffu << 24; - info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 - } else { - info->mr = 31u << 10; - info->mg = 31u << 5; - info->mb = 31u << 0; - } - } else if (compress == 3) { - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - // not documented, but generated by photoshop and handled by mspaint - if (info->mr == info->mg && info->mg == info->mb) { - // ?!?!? - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else { - int i; - if (hsz != 108 && hsz != 124) - return stbi__errpuc("bad BMP", "bad BMP"); - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - info->ma = stbi__get32le(s); - stbi__get32le(s); // discard color space - for (i=0; i < 12; ++i) - stbi__get32le(s); // discard color space parameters - if (hsz == 124) { - stbi__get32le(s); // discard rendering intent - stbi__get32le(s); // discard offset of profile data - stbi__get32le(s); // discard size of profile data - stbi__get32le(s); // discard reserved - } - } - } - return (void *) 1; -} - - -static stbi_uc *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *out; - unsigned int mr=0,mg=0,mb=0,ma=0, all_a; - stbi_uc pal[256][4]; - int psize=0,i,j,width; - int flip_vertically, pad, target; - stbi__bmp_data info; - - info.all_a = 255; - if (stbi__bmp_parse_header(s, &info) == NULL) - return NULL; // error code already set - - flip_vertically = ((int) s->img_y) > 0; - s->img_y = abs((int) s->img_y); - - mr = info.mr; - mg = info.mg; - mb = info.mb; - ma = info.ma; - all_a = info.all_a; - - if (info.hsz == 12) { - if (info.bpp < 24) - psize = (info.offset - 14 - 24) / 3; - } else { - if (info.bpp < 16) - psize = (info.offset - 14 - info.hsz) >> 2; - } - - s->img_n = ma ? 4 : 3; - if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 - target = req_comp; - else - target = s->img_n; // if they want monochrome, we'll post-convert - - out = (stbi_uc *) stbi__malloc(target * s->img_x * s->img_y); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - if (info.bpp < 16) { - int z=0; - if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } - for (i=0; i < psize; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - if (info.hsz != 12) stbi__get8(s); - pal[i][3] = 255; - } - stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); - if (info.bpp == 4) width = (s->img_x + 1) >> 1; - else if (info.bpp == 8) width = s->img_x; - else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } - pad = (-width)&3; - for (j=0; j < (int) s->img_y; ++j) { - for (i=0; i < (int) s->img_x; i += 2) { - int v=stbi__get8(s),v2=0; - if (info.bpp == 4) { - v2 = v & 15; - v >>= 4; - } - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - v = (info.bpp == 8) ? stbi__get8(s) : v2; - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - } - stbi__skip(s, pad); - } - } else { - int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; - int z = 0; - int easy=0; - stbi__skip(s, info.offset - 14 - info.hsz); - if (info.bpp == 24) width = 3 * s->img_x; - else if (info.bpp == 16) width = 2*s->img_x; - else /* bpp = 32 and pad = 0 */ width=0; - pad = (-width) & 3; - if (info.bpp == 24) { - easy = 1; - } else if (info.bpp == 32) { - if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) - easy = 2; - } - if (!easy) { - if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } - // right shift amt to put high bit in position #7 - rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); - gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); - bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); - ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); - } - for (j=0; j < (int) s->img_y; ++j) { - if (easy) { - for (i=0; i < (int) s->img_x; ++i) { - unsigned char a; - out[z+2] = stbi__get8(s); - out[z+1] = stbi__get8(s); - out[z+0] = stbi__get8(s); - z += 3; - a = (easy == 2 ? stbi__get8(s) : 255); - all_a |= a; - if (target == 4) out[z++] = a; - } - } else { - int bpp = info.bpp; - for (i=0; i < (int) s->img_x; ++i) { - stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); - int a; - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); - a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); - all_a |= a; - if (target == 4) out[z++] = STBI__BYTECAST(a); - } - } - stbi__skip(s, pad); - } - } - - // if alpha channel is all 0s, replace with all 255s - if (target == 4 && all_a == 0) - for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) - out[i] = 255; - - if (flip_vertically) { - stbi_uc t; - for (j=0; j < (int) s->img_y>>1; ++j) { - stbi_uc *p1 = out + j *s->img_x*target; - stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; - for (i=0; i < (int) s->img_x*target; ++i) { - t = p1[i], p1[i] = p2[i], p2[i] = t; - } - } - } - - if (req_comp && req_comp != target) { - out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = s->img_n; - return out; -} -#endif - -// Targa Truevision - TGA -// by Jonathan Dummer -#ifndef STBI_NO_TGA -// returns STBI_rgb or whatever, 0 on error -static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) -{ - // only RGB or RGBA (incl. 16bit) or grey allowed - if(is_rgb16) *is_rgb16 = 0; - switch(bits_per_pixel) { - case 8: return STBI_grey; - case 16: if(is_grey) return STBI_grey_alpha; - // else: fall-through - case 15: if(is_rgb16) *is_rgb16 = 1; - return STBI_rgb; - case 24: // fall-through - case 32: return bits_per_pixel/8; - default: return 0; - } -} - -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) -{ - int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; - int sz, tga_colormap_type; - stbi__get8(s); // discard Offset - tga_colormap_type = stbi__get8(s); // colormap type - if( tga_colormap_type > 1 ) { - stbi__rewind(s); - return 0; // only RGB or indexed allowed - } - tga_image_type = stbi__get8(s); // image type - if ( tga_colormap_type == 1 ) { // colormapped (paletted) image - if (tga_image_type != 1 && tga_image_type != 9) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip image x and y origin - tga_colormap_bpp = sz; - } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE - if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { - stbi__rewind(s); - return 0; // only RGB or grey allowed, +/- RLE - } - stbi__skip(s,9); // skip colormap specification and image x/y origin - tga_colormap_bpp = 0; - } - tga_w = stbi__get16le(s); - if( tga_w < 1 ) { - stbi__rewind(s); - return 0; // test width - } - tga_h = stbi__get16le(s); - if( tga_h < 1 ) { - stbi__rewind(s); - return 0; // test height - } - tga_bits_per_pixel = stbi__get8(s); // bits per pixel - stbi__get8(s); // ignore alpha bits - if (tga_colormap_bpp != 0) { - if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { - // when using a colormap, tga_bits_per_pixel is the size of the indexes - // I don't think anything but 8 or 16bit indexes makes sense - stbi__rewind(s); - return 0; - } - tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); - } else { - tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); - } - if(!tga_comp) { - stbi__rewind(s); - return 0; - } - if (x) *x = tga_w; - if (y) *y = tga_h; - if (comp) *comp = tga_comp; - return 1; // seems to have passed everything -} - -static int stbi__tga_test(stbi__context *s) -{ - int res = 0; - int sz, tga_color_type; - stbi__get8(s); // discard Offset - tga_color_type = stbi__get8(s); // color type - if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed - sz = stbi__get8(s); // image type - if ( tga_color_type == 1 ) { // colormapped (paletted) image - if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - stbi__skip(s,4); // skip image x and y origin - } else { // "normal" image w/o colormap - if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE - stbi__skip(s,9); // skip colormap specification and image x/y origin - } - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height - sz = stbi__get8(s); // bits per pixel - if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - - res = 1; // if we got this far, everything's good and we can return 1 instead of 0 - -errorEnd: - stbi__rewind(s); - return res; -} - -// read 16bit value and convert to 24bit RGB -void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) -{ - stbi__uint16 px = stbi__get16le(s); - stbi__uint16 fiveBitMask = 31; - // we have 3 channels with 5bits each - int r = (px >> 10) & fiveBitMask; - int g = (px >> 5) & fiveBitMask; - int b = px & fiveBitMask; - // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later - out[0] = (r * 255)/31; - out[1] = (g * 255)/31; - out[2] = (b * 255)/31; - - // some people claim that the most significant bit might be used for alpha - // (possibly if an alpha-bit is set in the "image descriptor byte") - // but that only made 16bit test images completely translucent.. - // so let's treat all 15 and 16bit TGAs as RGB with no alpha. -} - -static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - // read in the TGA header stuff - int tga_offset = stbi__get8(s); - int tga_indexed = stbi__get8(s); - int tga_image_type = stbi__get8(s); - int tga_is_RLE = 0; - int tga_palette_start = stbi__get16le(s); - int tga_palette_len = stbi__get16le(s); - int tga_palette_bits = stbi__get8(s); - int tga_x_origin = stbi__get16le(s); - int tga_y_origin = stbi__get16le(s); - int tga_width = stbi__get16le(s); - int tga_height = stbi__get16le(s); - int tga_bits_per_pixel = stbi__get8(s); - int tga_comp, tga_rgb16=0; - int tga_inverted = stbi__get8(s); - // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) - // image data - unsigned char *tga_data; - unsigned char *tga_palette = NULL; - int i, j; - unsigned char raw_data[4]; - int RLE_count = 0; - int RLE_repeating = 0; - int read_next_pixel = 1; - - // do a tiny bit of precessing - if ( tga_image_type >= 8 ) - { - tga_image_type -= 8; - tga_is_RLE = 1; - } - tga_inverted = 1 - ((tga_inverted >> 5) & 1); - - // If I'm paletted, then I'll use the number of bits from the palette - if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); - else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); - - if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency - return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); - - // tga info - *x = tga_width; - *y = tga_height; - if (comp) *comp = tga_comp; - - tga_data = (unsigned char*)stbi__malloc( (size_t)tga_width * tga_height * tga_comp ); - if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); - - // skip to the data's starting position (offset usually = 0) - stbi__skip(s, tga_offset ); - - if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { - for (i=0; i < tga_height; ++i) { - int row = tga_inverted ? tga_height -i - 1 : i; - stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; - stbi__getn(s, tga_row, tga_width * tga_comp); - } - } else { - // do I need to load a palette? - if ( tga_indexed) - { - // any data to skip? (offset usually = 0) - stbi__skip(s, tga_palette_start ); - // load the palette - tga_palette = (unsigned char*)stbi__malloc( tga_palette_len * tga_comp ); - if (!tga_palette) { - STBI_FREE(tga_data); - return stbi__errpuc("outofmem", "Out of memory"); - } - if (tga_rgb16) { - stbi_uc *pal_entry = tga_palette; - STBI_ASSERT(tga_comp == STBI_rgb); - for (i=0; i < tga_palette_len; ++i) { - stbi__tga_read_rgb16(s, pal_entry); - pal_entry += tga_comp; - } - } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { - STBI_FREE(tga_data); - STBI_FREE(tga_palette); - return stbi__errpuc("bad palette", "Corrupt TGA"); - } - } - // load the data - for (i=0; i < tga_width * tga_height; ++i) - { - // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? - if ( tga_is_RLE ) - { - if ( RLE_count == 0 ) - { - // yep, get the next byte as a RLE command - int RLE_cmd = stbi__get8(s); - RLE_count = 1 + (RLE_cmd & 127); - RLE_repeating = RLE_cmd >> 7; - read_next_pixel = 1; - } else if ( !RLE_repeating ) - { - read_next_pixel = 1; - } - } else - { - read_next_pixel = 1; - } - // OK, if I need to read a pixel, do it now - if ( read_next_pixel ) - { - // load however much data we did have - if ( tga_indexed ) - { - // read in index, then perform the lookup - int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); - if ( pal_idx >= tga_palette_len ) { - // invalid index - pal_idx = 0; - } - pal_idx *= tga_comp; - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = tga_palette[pal_idx+j]; - } - } else if(tga_rgb16) { - STBI_ASSERT(tga_comp == STBI_rgb); - stbi__tga_read_rgb16(s, raw_data); - } else { - // read in the data raw - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = stbi__get8(s); - } - } - // clear the reading flag for the next pixel - read_next_pixel = 0; - } // end of reading a pixel - - // copy data - for (j = 0; j < tga_comp; ++j) - tga_data[i*tga_comp+j] = raw_data[j]; - - // in case we're in RLE mode, keep counting down - --RLE_count; - } - // do I need to invert the image? - if ( tga_inverted ) - { - for (j = 0; j*2 < tga_height; ++j) - { - int index1 = j * tga_width * tga_comp; - int index2 = (tga_height - 1 - j) * tga_width * tga_comp; - for (i = tga_width * tga_comp; i > 0; --i) - { - unsigned char temp = tga_data[index1]; - tga_data[index1] = tga_data[index2]; - tga_data[index2] = temp; - ++index1; - ++index2; - } - } - } - // clear my palette, if I had one - if ( tga_palette != NULL ) - { - STBI_FREE( tga_palette ); - } - } - - // swap RGB - if the source data was RGB16, it already is in the right order - if (tga_comp >= 3 && !tga_rgb16) - { - unsigned char* tga_pixel = tga_data; - for (i=0; i < tga_width * tga_height; ++i) - { - unsigned char temp = tga_pixel[0]; - tga_pixel[0] = tga_pixel[2]; - tga_pixel[2] = temp; - tga_pixel += tga_comp; - } - } - - // convert to target component count - if (req_comp && req_comp != tga_comp) - tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); - - // the things I do to get rid of an error message, and yet keep - // Microsoft's C compilers happy... [8^( - tga_palette_start = tga_palette_len = tga_palette_bits = - tga_x_origin = tga_y_origin = 0; - // OK, done - return tga_data; -} -#endif - -// ************************************************************************************************* -// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB - -#ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s) -{ - int r = (stbi__get32be(s) == 0x38425053); - stbi__rewind(s); - return r; -} - -static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - int pixelCount; - int channelCount, compression; - int channel, i, count, len; - int bitdepth; - int w,h; - stbi_uc *out; - - // Check identifier - if (stbi__get32be(s) != 0x38425053) // "8BPS" - return stbi__errpuc("not PSD", "Corrupt PSD image"); - - // Check file type version. - if (stbi__get16be(s) != 1) - return stbi__errpuc("wrong version", "Unsupported version of PSD image"); - - // Skip 6 reserved bytes. - stbi__skip(s, 6 ); - - // Read the number of channels (R, G, B, A, etc). - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) - return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); - - // Read the rows and columns of the image. - h = stbi__get32be(s); - w = stbi__get32be(s); - - // Make sure the depth is 8 bits. - bitdepth = stbi__get16be(s); - if (bitdepth != 8 && bitdepth != 16) - return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); - - // Make sure the color mode is RGB. - // Valid options are: - // 0: Bitmap - // 1: Grayscale - // 2: Indexed color - // 3: RGB color - // 4: CMYK color - // 7: Multichannel - // 8: Duotone - // 9: Lab color - if (stbi__get16be(s) != 3) - return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); - - // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) - stbi__skip(s,stbi__get32be(s) ); - - // Skip the image resources. (resolution, pen tool paths, etc) - stbi__skip(s, stbi__get32be(s) ); - - // Skip the reserved data. - stbi__skip(s, stbi__get32be(s) ); - - // Find out if the data is compressed. - // Known values: - // 0: no compression - // 1: RLE compressed - compression = stbi__get16be(s); - if (compression > 1) - return stbi__errpuc("bad compression", "PSD has an unknown compression format"); - - // Create the destination image. - out = (stbi_uc *) stbi__malloc(4 * w*h); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - pixelCount = w*h; - - // Initialize the data to zero. - //memset( out, 0, pixelCount * 4 ); - - // Finally, the image data. - if (compression) { - // RLE as used by .PSD and .TIFF - // Loop until you get the number of unpacked bytes you are expecting: - // Read the next source byte into n. - // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. - // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. - // Else if n is 128, noop. - // Endloop - - // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, - // which we're going to just skip. - stbi__skip(s, h * channelCount * 2 ); - - // Read the RLE data by channel. - for (channel = 0; channel < 4; channel++) { - stbi_uc *p; - - p = out+channel; - if (channel >= channelCount) { - // Fill this channel with default data. - for (i = 0; i < pixelCount; i++, p += 4) - *p = (channel == 3 ? 255 : 0); - } else { - // Read the RLE data. - count = 0; - while (count < pixelCount) { - len = stbi__get8(s); - if (len == 128) { - // No-op. - } else if (len < 128) { - // Copy next len+1 bytes literally. - len++; - count += len; - while (len) { - *p = stbi__get8(s); - p += 4; - len--; - } - } else if (len > 128) { - stbi_uc val; - // Next -len+1 bytes in the dest are replicated from next source byte. - // (Interpret len as a negative 8-bit int.) - len ^= 0x0FF; - len += 2; - val = stbi__get8(s); - count += len; - while (len) { - *p = val; - p += 4; - len--; - } - } - } - } - } - - } else { - // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) - // where each channel consists of an 8-bit value for each pixel in the image. - - // Read the data by channel. - for (channel = 0; channel < 4; channel++) { - stbi_uc *p; - - p = out + channel; - if (channel >= channelCount) { - // Fill this channel with default data. - stbi_uc val = channel == 3 ? 255 : 0; - for (i = 0; i < pixelCount; i++, p += 4) - *p = val; - } else { - // Read the data. - if (bitdepth == 16) { - for (i = 0; i < pixelCount; i++, p += 4) - *p = (stbi_uc) (stbi__get16be(s) >> 8); - } else { - for (i = 0; i < pixelCount; i++, p += 4) - *p = stbi__get8(s); - } - } - } - } - - if (req_comp && req_comp != 4) { - out = stbi__convert_format(out, 4, req_comp, w, h); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - - if (comp) *comp = 4; - *y = h; - *x = w; - - return out; -} -#endif - -// ************************************************************************************************* -// Softimage PIC loader -// by Tom Seddon -// -// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format -// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ - -#ifndef STBI_NO_PIC -static int stbi__pic_is4(stbi__context *s,const char *str) -{ - int i; - for (i=0; i<4; ++i) - if (stbi__get8(s) != (stbi_uc)str[i]) - return 0; - - return 1; -} - -static int stbi__pic_test_core(stbi__context *s) -{ - int i; - - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) - return 0; - - for(i=0;i<84;++i) - stbi__get8(s); - - if (!stbi__pic_is4(s,"PICT")) - return 0; - - return 1; -} - -typedef struct -{ - stbi_uc size,type,channel; -} stbi__pic_packet; - -static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) -{ - int mask=0x80, i; - - for (i=0; i<4; ++i, mask>>=1) { - if (channel & mask) { - if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); - dest[i]=stbi__get8(s); - } - } - - return dest; -} - -static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) -{ - int mask=0x80,i; - - for (i=0;i<4; ++i, mask>>=1) - if (channel&mask) - dest[i]=src[i]; -} - -static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) -{ - int act_comp=0,num_packets=0,y,chained; - stbi__pic_packet packets[10]; - - // this will (should...) cater for even some bizarre stuff like having data - // for the same channel in multiple packets. - do { - stbi__pic_packet *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return stbi__errpuc("bad format","too many packets"); - - packet = &packets[num_packets++]; - - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); - - act_comp |= packet->channel; - - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); - if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); - } while (chained); - - *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? - - for(y=0; ytype) { - default: - return stbi__errpuc("bad format","packet has bad compression type"); - - case 0: {//uncompressed - int x; - - for(x=0;xchannel,dest)) - return 0; - break; - } - - case 1://Pure RLE - { - int left=width, i; - - while (left>0) { - stbi_uc count,value[4]; - - count=stbi__get8(s); - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); - - if (count > left) - count = (stbi_uc) left; - - if (!stbi__readval(s,packet->channel,value)) return 0; - - for(i=0; ichannel,dest,value); - left -= count; - } - } - break; - - case 2: {//Mixed RLE - int left=width; - while (left>0) { - int count = stbi__get8(s), i; - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); - - if (count >= 128) { // Repeated - stbi_uc value[4]; - - if (count==128) - count = stbi__get16be(s); - else - count -= 127; - if (count > left) - return stbi__errpuc("bad file","scanline overrun"); - - if (!stbi__readval(s,packet->channel,value)) - return 0; - - for(i=0;ichannel,dest,value); - } else { // Raw - ++count; - if (count>left) return stbi__errpuc("bad file","scanline overrun"); - - for(i=0;ichannel,dest)) - return 0; - } - left-=count; - } - break; - } - } - } - } - - return result; -} - -static stbi_uc *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp) -{ - stbi_uc *result; - int i, x,y; - - for (i=0; i<92; ++i) - stbi__get8(s); - - x = stbi__get16be(s); - y = stbi__get16be(s); - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); - if ((1 << 28) / x < y) return stbi__errpuc("too large", "Image too large to decode"); - - stbi__get32be(s); //skip `ratio' - stbi__get16be(s); //skip `fields' - stbi__get16be(s); //skip `pad' - - // intermediate buffer is RGBA - result = (stbi_uc *) stbi__malloc(x*y*4); - memset(result, 0xff, x*y*4); - - if (!stbi__pic_load_core(s,x,y,comp, result)) { - STBI_FREE(result); - result=0; - } - *px = x; - *py = y; - if (req_comp == 0) req_comp = *comp; - result=stbi__convert_format(result,4,req_comp,x,y); - - return result; -} - -static int stbi__pic_test(stbi__context *s) -{ - int r = stbi__pic_test_core(s); - stbi__rewind(s); - return r; -} -#endif - -// ************************************************************************************************* -// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb - -#ifndef STBI_NO_GIF -typedef struct -{ - stbi__int16 prefix; - stbi_uc first; - stbi_uc suffix; -} stbi__gif_lzw; - -typedef struct -{ - int w,h; - stbi_uc *out, *old_out; // output buffer (always 4 components) - int flags, bgindex, ratio, transparent, eflags, delay; - stbi_uc pal[256][4]; - stbi_uc lpal[256][4]; - stbi__gif_lzw codes[4096]; - stbi_uc *color_table; - int parse, step; - int lflags; - int start_x, start_y; - int max_x, max_y; - int cur_x, cur_y; - int line_size; -} stbi__gif; - -static int stbi__gif_test_raw(stbi__context *s) -{ - int sz; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; - sz = stbi__get8(s); - if (sz != '9' && sz != '7') return 0; - if (stbi__get8(s) != 'a') return 0; - return 1; -} - -static int stbi__gif_test(stbi__context *s) -{ - int r = stbi__gif_test_raw(s); - stbi__rewind(s); - return r; -} - -static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) -{ - int i; - for (i=0; i < num_entries; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - pal[i][3] = transp == i ? 0 : 255; - } -} - -static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) -{ - stbi_uc version; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') - return stbi__err("not GIF", "Corrupt GIF"); - - version = stbi__get8(s); - if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); - if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); - - stbi__g_failure_reason = ""; - g->w = stbi__get16le(s); - g->h = stbi__get16le(s); - g->flags = stbi__get8(s); - g->bgindex = stbi__get8(s); - g->ratio = stbi__get8(s); - g->transparent = -1; - - if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments - - if (is_info) return 1; - - if (g->flags & 0x80) - stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); - - return 1; -} - -static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__gif g; - if (!stbi__gif_header(s, &g, comp, 1)) { - stbi__rewind( s ); - return 0; - } - if (x) *x = g.w; - if (y) *y = g.h; - return 1; -} - -static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) -{ - stbi_uc *p, *c; - - // recurse to decode the prefixes, since the linked-list is backwards, - // and working backwards through an interleaved image would be nasty - if (g->codes[code].prefix >= 0) - stbi__out_gif_code(g, g->codes[code].prefix); - - if (g->cur_y >= g->max_y) return; - - p = &g->out[g->cur_x + g->cur_y]; - c = &g->color_table[g->codes[code].suffix * 4]; - - if (c[3] >= 128) { - p[0] = c[2]; - p[1] = c[1]; - p[2] = c[0]; - p[3] = c[3]; - } - g->cur_x += 4; - - if (g->cur_x >= g->max_x) { - g->cur_x = g->start_x; - g->cur_y += g->step; - - while (g->cur_y >= g->max_y && g->parse > 0) { - g->step = (1 << g->parse) * g->line_size; - g->cur_y = g->start_y + (g->step >> 1); - --g->parse; - } - } -} - -static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) -{ - stbi_uc lzw_cs; - stbi__int32 len, init_code; - stbi__uint32 first; - stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; - stbi__gif_lzw *p; - - lzw_cs = stbi__get8(s); - if (lzw_cs > 12) return NULL; - clear = 1 << lzw_cs; - first = 1; - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - bits = 0; - valid_bits = 0; - for (init_code = 0; init_code < clear; init_code++) { - g->codes[init_code].prefix = -1; - g->codes[init_code].first = (stbi_uc) init_code; - g->codes[init_code].suffix = (stbi_uc) init_code; - } - - // support no starting clear code - avail = clear+2; - oldcode = -1; - - len = 0; - for(;;) { - if (valid_bits < codesize) { - if (len == 0) { - len = stbi__get8(s); // start new block - if (len == 0) - return g->out; - } - --len; - bits |= (stbi__int32) stbi__get8(s) << valid_bits; - valid_bits += 8; - } else { - stbi__int32 code = bits & codemask; - bits >>= codesize; - valid_bits -= codesize; - // @OPTIMIZE: is there some way we can accelerate the non-clear path? - if (code == clear) { // clear code - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - avail = clear + 2; - oldcode = -1; - first = 0; - } else if (code == clear + 1) { // end of stream code - stbi__skip(s, len); - while ((len = stbi__get8(s)) > 0) - stbi__skip(s,len); - return g->out; - } else if (code <= avail) { - if (first) return stbi__errpuc("no clear code", "Corrupt GIF"); - - if (oldcode >= 0) { - p = &g->codes[avail++]; - if (avail > 4096) return stbi__errpuc("too many codes", "Corrupt GIF"); - p->prefix = (stbi__int16) oldcode; - p->first = g->codes[oldcode].first; - p->suffix = (code == avail) ? p->first : g->codes[code].first; - } else if (code == avail) - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - - stbi__out_gif_code(g, (stbi__uint16) code); - - if ((avail & codemask) == 0 && avail <= 0x0FFF) { - codesize++; - codemask = (1 << codesize) - 1; - } - - oldcode = code; - } else { - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - } - } - } -} - -static void stbi__fill_gif_background(stbi__gif *g, int x0, int y0, int x1, int y1) -{ - int x, y; - stbi_uc *c = g->pal[g->bgindex]; - for (y = y0; y < y1; y += 4 * g->w) { - for (x = x0; x < x1; x += 4) { - stbi_uc *p = &g->out[y + x]; - p[0] = c[2]; - p[1] = c[1]; - p[2] = c[0]; - p[3] = 0; - } - } -} - -// this function is designed to support animated gifs, although stb_image doesn't support it -static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp) -{ - int i; - stbi_uc *prev_out = 0; - - if (g->out == 0 && !stbi__gif_header(s, g, comp,0)) - return 0; // stbi__g_failure_reason set by stbi__gif_header - - prev_out = g->out; - g->out = (stbi_uc *) stbi__malloc(4 * g->w * g->h); - if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory"); - - switch ((g->eflags & 0x1C) >> 2) { - case 0: // unspecified (also always used on 1st frame) - stbi__fill_gif_background(g, 0, 0, 4 * g->w, 4 * g->w * g->h); - break; - case 1: // do not dispose - if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); - g->old_out = prev_out; - break; - case 2: // dispose to background - if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); - stbi__fill_gif_background(g, g->start_x, g->start_y, g->max_x, g->max_y); - break; - case 3: // dispose to previous - if (g->old_out) { - for (i = g->start_y; i < g->max_y; i += 4 * g->w) - memcpy(&g->out[i + g->start_x], &g->old_out[i + g->start_x], g->max_x - g->start_x); - } - break; - } - - for (;;) { - switch (stbi__get8(s)) { - case 0x2C: /* Image Descriptor */ - { - int prev_trans = -1; - stbi__int32 x, y, w, h; - stbi_uc *o; - - x = stbi__get16le(s); - y = stbi__get16le(s); - w = stbi__get16le(s); - h = stbi__get16le(s); - if (((x + w) > (g->w)) || ((y + h) > (g->h))) - return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); - - g->line_size = g->w * 4; - g->start_x = x * 4; - g->start_y = y * g->line_size; - g->max_x = g->start_x + w * 4; - g->max_y = g->start_y + h * g->line_size; - g->cur_x = g->start_x; - g->cur_y = g->start_y; - - g->lflags = stbi__get8(s); - - if (g->lflags & 0x40) { - g->step = 8 * g->line_size; // first interlaced spacing - g->parse = 3; - } else { - g->step = g->line_size; - g->parse = 0; - } - - if (g->lflags & 0x80) { - stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); - g->color_table = (stbi_uc *) g->lpal; - } else if (g->flags & 0x80) { - if (g->transparent >= 0 && (g->eflags & 0x01)) { - prev_trans = g->pal[g->transparent][3]; - g->pal[g->transparent][3] = 0; - } - g->color_table = (stbi_uc *) g->pal; - } else - return stbi__errpuc("missing color table", "Corrupt GIF"); - - o = stbi__process_gif_raster(s, g); - if (o == NULL) return NULL; - - if (prev_trans != -1) - g->pal[g->transparent][3] = (stbi_uc) prev_trans; - - return o; - } - - case 0x21: // Comment Extension. - { - int len; - if (stbi__get8(s) == 0xF9) { // Graphic Control Extension. - len = stbi__get8(s); - if (len == 4) { - g->eflags = stbi__get8(s); - g->delay = stbi__get16le(s); - g->transparent = stbi__get8(s); - } else { - stbi__skip(s, len); - break; - } - } - while ((len = stbi__get8(s)) != 0) - stbi__skip(s, len); - break; - } - - case 0x3B: // gif stream termination code - return (stbi_uc *) s; // using '1' causes warning on some compilers - - default: - return stbi__errpuc("unknown code", "Corrupt GIF"); - } - } - - STBI_NOTUSED(req_comp); -} - -static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *u = 0; - stbi__gif g; - memset(&g, 0, sizeof(g)); - - u = stbi__gif_load_next(s, &g, comp, req_comp); - if (u == (stbi_uc *) s) u = 0; // end of animated gif marker - if (u) { - *x = g.w; - *y = g.h; - if (req_comp && req_comp != 4) - u = stbi__convert_format(u, 4, req_comp, g.w, g.h); - } - else if (g.out) - STBI_FREE(g.out); - - return u; -} - -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) -{ - return stbi__gif_info_raw(s,x,y,comp); -} -#endif - -// ************************************************************************************************* -// Radiance RGBE HDR loader -// originally by Nicolas Schulz -#ifndef STBI_NO_HDR -static int stbi__hdr_test_core(stbi__context *s) -{ - const char *signature = "#?RADIANCE\n"; - int i; - for (i=0; signature[i]; ++i) - if (stbi__get8(s) != signature[i]) - return 0; - return 1; -} - -static int stbi__hdr_test(stbi__context* s) -{ - int r = stbi__hdr_test_core(s); - stbi__rewind(s); - return r; -} - -#define STBI__HDR_BUFLEN 1024 -static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) -{ - int len=0; - char c = '\0'; - - c = (char) stbi__get8(z); - - while (!stbi__at_eof(z) && c != '\n') { - buffer[len++] = c; - if (len == STBI__HDR_BUFLEN-1) { - // flush to end of line - while (!stbi__at_eof(z) && stbi__get8(z) != '\n') - ; - break; - } - c = (char) stbi__get8(z); - } - - buffer[len] = 0; - return buffer; -} - -static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) -{ - if ( input[3] != 0 ) { - float f1; - // Exponent - f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); - if (req_comp <= 2) - output[0] = (input[0] + input[1] + input[2]) * f1 / 3; - else { - output[0] = input[0] * f1; - output[1] = input[1] * f1; - output[2] = input[2] * f1; - } - if (req_comp == 2) output[1] = 1; - if (req_comp == 4) output[3] = 1; - } else { - switch (req_comp) { - case 4: output[3] = 1; /* fallthrough */ - case 3: output[0] = output[1] = output[2] = 0; - break; - case 2: output[1] = 1; /* fallthrough */ - case 1: output[0] = 0; - break; - } - } -} - -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - int width, height; - stbi_uc *scanline; - float *hdr_data; - int len; - unsigned char count, value; - int i, j, k, c1,c2, z; - - - // Check identifier - if (strcmp(stbi__hdr_gettoken(s,buffer), "#?RADIANCE") != 0) - return stbi__errpf("not HDR", "Corrupt HDR image"); - - // Parse header - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); - - // Parse width and height - // can't use sscanf() if we're not using stdio! - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - height = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - width = (int) strtol(token, NULL, 10); - - *x = width; - *y = height; - - if (comp) *comp = 3; - if (req_comp == 0) req_comp = 3; - - // Read data - hdr_data = (float *) stbi__malloc(height * width * req_comp * sizeof(float)); - - // Load image data - // image data is stored as some number of sca - if ( width < 8 || width >= 32768) { - // Read flat data - for (j=0; j < height; ++j) { - for (i=0; i < width; ++i) { - stbi_uc rgbe[4]; - main_decode_loop: - stbi__getn(s, rgbe, 4); - stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); - } - } - } else { - // Read RLE-encoded data - scanline = NULL; - - for (j = 0; j < height; ++j) { - c1 = stbi__get8(s); - c2 = stbi__get8(s); - len = stbi__get8(s); - if (c1 != 2 || c2 != 2 || (len & 0x80)) { - // not run-length encoded, so we have to actually use THIS data as a decoded - // pixel (note this can't be a valid pixel--one of RGB must be >= 128) - stbi_uc rgbe[4]; - rgbe[0] = (stbi_uc) c1; - rgbe[1] = (stbi_uc) c2; - rgbe[2] = (stbi_uc) len; - rgbe[3] = (stbi_uc) stbi__get8(s); - stbi__hdr_convert(hdr_data, rgbe, req_comp); - i = 1; - j = 0; - STBI_FREE(scanline); - goto main_decode_loop; // yes, this makes no sense - } - len <<= 8; - len |= stbi__get8(s); - if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } - if (scanline == NULL) scanline = (stbi_uc *) stbi__malloc(width * 4); - - for (k = 0; k < 4; ++k) { - i = 0; - while (i < width) { - count = stbi__get8(s); - if (count > 128) { - // Run - value = stbi__get8(s); - count -= 128; - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = value; - } else { - // Dump - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = stbi__get8(s); - } - } - } - for (i=0; i < width; ++i) - stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); - } - STBI_FREE(scanline); - } - - return hdr_data; -} - -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - - if (stbi__hdr_test(s) == 0) { - stbi__rewind( s ); - return 0; - } - - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) { - stbi__rewind( s ); - return 0; - } - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *y = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *x = (int) strtol(token, NULL, 10); - *comp = 3; - return 1; -} -#endif // STBI_NO_HDR - -#ifndef STBI_NO_BMP -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) -{ - void *p; - stbi__bmp_data info; - - info.all_a = 255; - p = stbi__bmp_parse_header(s, &info); - stbi__rewind( s ); - if (p == NULL) - return 0; - *x = s->img_x; - *y = s->img_y; - *comp = info.ma ? 4 : 3; - return 1; -} -#endif - -#ifndef STBI_NO_PSD -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) -{ - int channelCount; - if (stbi__get32be(s) != 0x38425053) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 1) { - stbi__rewind( s ); - return 0; - } - stbi__skip(s, 6); - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) { - stbi__rewind( s ); - return 0; - } - *y = stbi__get32be(s); - *x = stbi__get32be(s); - if (stbi__get16be(s) != 8) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 3) { - stbi__rewind( s ); - return 0; - } - *comp = 4; - return 1; -} -#endif - -#ifndef STBI_NO_PIC -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) -{ - int act_comp=0,num_packets=0,chained; - stbi__pic_packet packets[10]; - - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { - stbi__rewind(s); - return 0; - } - - stbi__skip(s, 88); - - *x = stbi__get16be(s); - *y = stbi__get16be(s); - if (stbi__at_eof(s)) { - stbi__rewind( s); - return 0; - } - if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { - stbi__rewind( s ); - return 0; - } - - stbi__skip(s, 8); - - do { - stbi__pic_packet *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return 0; - - packet = &packets[num_packets++]; - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); - act_comp |= packet->channel; - - if (stbi__at_eof(s)) { - stbi__rewind( s ); - return 0; - } - if (packet->size != 8) { - stbi__rewind( s ); - return 0; - } - } while (chained); - - *comp = (act_comp & 0x10 ? 4 : 3); - - return 1; -} -#endif - -// ************************************************************************************************* -// Portable Gray Map and Portable Pixel Map loader -// by Ken Miller -// -// PGM: http://netpbm.sourceforge.net/doc/pgm.html -// PPM: http://netpbm.sourceforge.net/doc/ppm.html -// -// Known limitations: -// Does not support comments in the header section -// Does not support ASCII image data (formats P2 and P3) -// Does not support 16-bit-per-channel - -#ifndef STBI_NO_PNM - -static int stbi__pnm_test(stbi__context *s) -{ - char p, t; - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind( s ); - return 0; - } - return 1; -} - -static stbi_uc *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *out; - if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) - return 0; - *x = s->img_x; - *y = s->img_y; - *comp = s->img_n; - - out = (stbi_uc *) stbi__malloc(s->img_n * s->img_x * s->img_y); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - stbi__getn(s, out, s->img_n * s->img_x * s->img_y); - - if (req_comp && req_comp != s->img_n) { - out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - return out; -} - -static int stbi__pnm_isspace(char c) -{ - return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; -} - -static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) -{ - for (;;) { - while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) - *c = (char) stbi__get8(s); - - if (stbi__at_eof(s) || *c != '#') - break; - - while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) - *c = (char) stbi__get8(s); - } -} - -static int stbi__pnm_isdigit(char c) -{ - return c >= '0' && c <= '9'; -} - -static int stbi__pnm_getinteger(stbi__context *s, char *c) -{ - int value = 0; - - while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { - value = value*10 + (*c - '0'); - *c = (char) stbi__get8(s); - } - - return value; -} - -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) -{ - int maxv; - char c, p, t; - - stbi__rewind( s ); - - // Get identifier - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind( s ); - return 0; - } - - *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm - - c = (char) stbi__get8(s); - stbi__pnm_skip_whitespace(s, &c); - - *x = stbi__pnm_getinteger(s, &c); // read width - stbi__pnm_skip_whitespace(s, &c); - - *y = stbi__pnm_getinteger(s, &c); // read height - stbi__pnm_skip_whitespace(s, &c); - - maxv = stbi__pnm_getinteger(s, &c); // read max value - - if (maxv > 255) - return stbi__err("max value > 255", "PPM image not 8-bit"); - else - return 1; -} -#endif - -static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) -{ - #ifndef STBI_NO_JPEG - if (stbi__jpeg_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PNG - if (stbi__png_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_GIF - if (stbi__gif_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_BMP - if (stbi__bmp_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PSD - if (stbi__psd_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PIC - if (stbi__pic_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PNM - if (stbi__pnm_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_HDR - if (stbi__hdr_info(s, x, y, comp)) return 1; - #endif - - // test tga last because it's a crappy test! - #ifndef STBI_NO_TGA - if (stbi__tga_info(s, x, y, comp)) - return 1; - #endif - return stbi__err("unknown image type", "Image not of any known type, or corrupt"); -} - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result; - if (!f) return stbi__err("can't fopen", "Unable to open file"); - result = stbi_info_from_file(f, x, y, comp); - fclose(f); - return result; -} - -STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - int r; - stbi__context s; - long pos = ftell(f); - stbi__start_file(&s, f); - r = stbi__info_main(&s,x,y,comp); - fseek(f,pos,SEEK_SET); - return r; -} -#endif // !STBI_NO_STDIO - -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__info_main(&s,x,y,comp); -} - -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); - return stbi__info_main(&s,x,y,comp); -} - -#endif // STB_IMAGE_IMPLEMENTATION - -/* - revision history: - 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED - 2.09 (2016-01-16) allow comments in PNM files - 16-bit-per-pixel TGA (not bit-per-component) - info() for TGA could break due to .hdr handling - info() for BMP to shares code instead of sloppy parse - can use STBI_REALLOC_SIZED if allocator doesn't support realloc - code cleanup - 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA - 2.07 (2015-09-13) fix compiler warnings - partial animated GIF support - limited 16-bpc PSD support - #ifdef unused functions - bug with < 92 byte PIC,PNM,HDR,TGA - 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value - 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning - 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit - 2.03 (2015-04-12) extra corruption checking (mmozeiko) - stbi_set_flip_vertically_on_load (nguillemot) - fix NEON support; fix mingw support - 2.02 (2015-01-19) fix incorrect assert, fix warning - 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 - 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG - 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) - progressive JPEG (stb) - PGM/PPM support (Ken Miller) - STBI_MALLOC,STBI_REALLOC,STBI_FREE - GIF bugfix -- seemingly never worked - STBI_NO_*, STBI_ONLY_* - 1.48 (2014-12-14) fix incorrectly-named assert() - 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) - optimize PNG (ryg) - fix bug in interlaced PNG with user-specified channel count (stb) - 1.46 (2014-08-26) - fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG - 1.45 (2014-08-16) - fix MSVC-ARM internal compiler error by wrapping malloc - 1.44 (2014-08-07) - various warning fixes from Ronny Chevalier - 1.43 (2014-07-15) - fix MSVC-only compiler problem in code changed in 1.42 - 1.42 (2014-07-09) - don't define _CRT_SECURE_NO_WARNINGS (affects user code) - fixes to stbi__cleanup_jpeg path - added STBI_ASSERT to avoid requiring assert.h - 1.41 (2014-06-25) - fix search&replace from 1.36 that messed up comments/error messages - 1.40 (2014-06-22) - fix gcc struct-initialization warning - 1.39 (2014-06-15) - fix to TGA optimization when req_comp != number of components in TGA; - fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) - add support for BMP version 5 (more ignored fields) - 1.38 (2014-06-06) - suppress MSVC warnings on integer casts truncating values - fix accidental rename of 'skip' field of I/O - 1.37 (2014-06-04) - remove duplicate typedef - 1.36 (2014-06-03) - convert to header file single-file library - if de-iphone isn't set, load iphone images color-swapped instead of returning NULL - 1.35 (2014-05-27) - various warnings - fix broken STBI_SIMD path - fix bug where stbi_load_from_file no longer left file pointer in correct place - fix broken non-easy path for 32-bit BMP (possibly never used) - TGA optimization by Arseny Kapoulkine - 1.34 (unknown) - use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case - 1.33 (2011-07-14) - make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements - 1.32 (2011-07-13) - support for "info" function for all supported filetypes (SpartanJ) - 1.31 (2011-06-20) - a few more leak fixes, bug in PNG handling (SpartanJ) - 1.30 (2011-06-11) - added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) - removed deprecated format-specific test/load functions - removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway - error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) - fix inefficiency in decoding 32-bit BMP (David Woo) - 1.29 (2010-08-16) - various warning fixes from Aurelien Pocheville - 1.28 (2010-08-01) - fix bug in GIF palette transparency (SpartanJ) - 1.27 (2010-08-01) - cast-to-stbi_uc to fix warnings - 1.26 (2010-07-24) - fix bug in file buffering for PNG reported by SpartanJ - 1.25 (2010-07-17) - refix trans_data warning (Won Chun) - 1.24 (2010-07-12) - perf improvements reading from files on platforms with lock-heavy fgetc() - minor perf improvements for jpeg - deprecated type-specific functions so we'll get feedback if they're needed - attempt to fix trans_data warning (Won Chun) - 1.23 fixed bug in iPhone support - 1.22 (2010-07-10) - removed image *writing* support - stbi_info support from Jetro Lauha - GIF support from Jean-Marc Lienher - iPhone PNG-extensions from James Brown - warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) - 1.21 fix use of 'stbi_uc' in header (reported by jon blow) - 1.20 added support for Softimage PIC, by Tom Seddon - 1.19 bug in interlaced PNG corruption check (found by ryg) - 1.18 (2008-08-02) - fix a threading bug (local mutable static) - 1.17 support interlaced PNG - 1.16 major bugfix - stbi__convert_format converted one too many pixels - 1.15 initialize some fields for thread safety - 1.14 fix threadsafe conversion bug - header-file-only version (#define STBI_HEADER_FILE_ONLY before including) - 1.13 threadsafe - 1.12 const qualifiers in the API - 1.11 Support installable IDCT, colorspace conversion routines - 1.10 Fixes for 64-bit (don't use "unsigned long") - optimized upsampling by Fabian "ryg" Giesen - 1.09 Fix format-conversion for PSD code (bad global variables!) - 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz - 1.07 attempt to fix C++ warning/errors again - 1.06 attempt to fix C++ warning/errors again - 1.05 fix TGA loading to return correct *comp and use good luminance calc - 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free - 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR - 1.02 support for (subset of) HDR files, float interface for preferred access to them - 1.01 fix bug: possible bug in handling right-side up bmps... not sure - fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all - 1.00 interface to zlib that skips zlib header - 0.99 correct handling of alpha in palette - 0.98 TGA loader by lonesock; dynamically add loaders (untested) - 0.97 jpeg errors on too large a file; also catch another malloc failure - 0.96 fix detection of invalid v value - particleman@mollyrocket forum - 0.95 during header scan, seek to markers in case of padding - 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same - 0.93 handle jpegtran output; verbose errors - 0.92 read 4,8,16,24,32-bit BMP files of several formats - 0.91 output 24-bit Windows 3.0 BMP files - 0.90 fix a few more warnings; bump version number to approach 1.0 - 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd - 0.60 fix compiling as c++ - 0.59 fix warnings: merge Dave Moore's -Wall fixes - 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian - 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available - 0.56 fix bug: zlib uncompressed mode len vs. nlen - 0.55 fix bug: restart_interval not initialized to 0 - 0.54 allow NULL for 'int *comp' - 0.53 fix bug in png 3->4; speedup png decoding - 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments - 0.51 obey req_comp requests, 1-component jpegs return as 1-component, - on 'test' only check type, not whether we support this variant - 0.50 (2006-11-19) - first released version -*/ diff --git a/phonelibs/nanovg/stb_truetype.h b/phonelibs/nanovg/stb_truetype.h deleted file mode 100644 index bfb1841f6989ce..00000000000000 --- a/phonelibs/nanovg/stb_truetype.h +++ /dev/null @@ -1,3249 +0,0 @@ -// stb_truetype.h - v1.09 - public domain -// authored from 2009-2015 by Sean Barrett / RAD Game Tools -// -// This library processes TrueType files: -// parse files -// extract glyph metrics -// extract glyph shapes -// render glyphs to one-channel bitmaps with antialiasing (box filter) -// -// Todo: -// non-MS cmaps -// crashproof on bad data -// hinting? (no longer patented) -// cleartype-style AA? -// optimize: use simple memory allocator for intermediates -// optimize: build edge-list directly from curves -// optimize: rasterize directly from curves? -// -// ADDITIONAL CONTRIBUTORS -// -// 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 -// -// Misc other: -// Ryan Gordon -// -// VERSION HISTORY -// -// 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; -// variant PackFontRanges to pack and render in separate phases; -// 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. -// -// USAGE -// -// Include this file in whatever places neeed 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 -// implementation into that C/C++ file. -// -// To make the implementation private to the file that generates the implementation, -// #define STBTT_STATIC -// -// Simple 3D API (don't ship this, but it's fine for tools and quick start) -// stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture -// stbtt_GetBakedQuad() -- compute quad to draw for a given char -// -// 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_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 -// -// Render a unicode codepoint to a bitmap -// stbtt_GetCodepointBitmap() -- allocates and returns a bitmap -// stbtt_MakeCodepointBitmap() -- renders into bitmap you provide -// stbtt_GetCodepointBitmapBox() -- how big the bitmap must be -// -// Character advance/positioning -// stbtt_GetCodepointHMetrics() -// stbtt_GetFontVMetrics() -// stbtt_GetCodepointKernAdvance() -// -// Starting with version 1.06, the rasterizer was replaced with a new, -// faster and generally-more-precise rasterizer. The new rasterizer more -// accurately measures pixel coverage for anti-aliasing, except in the case -// where multiple shapes overlap, in which case it overestimates the AA pixel -// coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If -// this turns out to be a problem, you can re-enable the old rasterizer with -// #define STBTT_RASTERIZER_VERSION 1 -// which will incur about a 15% speed hit. -// -// ADDITIONAL DOCUMENTATION -// -// Immediately after this block comment are a series of sample programs. -// -// After the sample programs is the "header file" section. This section -// includes documentation for each API function. -// -// Some important concepts to understand to use this library: -// -// Codepoint -// Characters are defined by unicode codepoints, e.g. 65 is -// uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is -// the hiragana for "ma". -// -// Glyph -// A visual character shape (every codepoint is rendered as -// some glyph) -// -// Glyph index -// A font-specific integer ID representing a glyph -// -// Baseline -// Glyph shapes are defined relative to a baseline, which is the -// bottom of uppercase characters. Characters extend both above -// and below the baseline. -// -// Current Point -// As you draw text to the screen, you keep track of a "current point" -// which is the origin of each character. The current point's vertical -// position is the baseline. Even "baked fonts" use this model. -// -// Vertical Font Metrics -// The vertical qualities of the font, used to vertically position -// and space the characters. See docs for stbtt_GetFontVMetrics. -// -// Font Size in Pixels or Points -// The preferred interface for specifying font sizes in stb_truetype -// is to specify how tall the font's vertical extent should be in pixels. -// If that sounds good enough, skip the next paragraph. -// -// Most font APIs instead use "points", which are a common typographic -// 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 -// 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 -// be 1.333 pixels. Additionally, the TrueType font data provides -// an explicit scale factor to scale a given font's glyphs to points, -// but the author has observed that this scale factor is often wrong -// for non-commercial fonts, thus making fonts scaled in points -// according to the TrueType spec incoherently sized in practice. -// -// ADVANCED USAGE -// -// Quality: -// -// - Use the functions with Subpixel at the end to allow your characters -// to have subpixel positioning. Since the font is anti-aliased, not -// hinted, this is very import for quality. (This is not possible with -// baked fonts.) -// -// - Kerning is now supported, and if you're supporting subpixel rendering -// then kerning is worth using to give your text a polished look. -// -// Performance: -// -// - Convert Unicode codepoints to glyph indexes and operate on the glyphs; -// if you don't do this, stb_truetype is forced to do the conversion on -// every call. -// -// - There are a lot of memory allocations. We should modify it to take -// a temp buffer and allocate from the temp buffer (without freeing), -// should help performance a lot. -// -// NOTES -// -// The system uses the raw data found in the .ttf file without changing it -// and without building auxiliary data structures. This is a bit inefficient -// on little-endian systems (the data is big-endian), but assuming you're -// caching the bitmaps or glyph shapes this shouldn't be a big deal. -// -// It appears to be very hard to programmatically determine what font a -// given file is in a general way. I provide an API for this, but I don't -// recommend it. -// -// -// SOURCE STATISTICS (based on v0.6c, 2050 LOC) -// -// Documentation & header file 520 LOC \___ 660 LOC documentation -// Sample code 140 LOC / -// Truetype parsing 620 LOC ---- 620 LOC TrueType -// Software rasterization 240 LOC \ . -// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation -// Bitmap management 100 LOC / -// Baked bitmap interface 70 LOC / -// Font name matching & access 150 LOC ---- 150 -// C runtime library abstraction 60 LOC ---- 60 -// -// -// PERFORMANCE MEASUREMENTS FOR 1.06: -// -// 32-bit 64-bit -// Previous release: 8.83 s 7.68 s -// Pool allocations: 7.72 s 6.34 s -// Inline sort : 6.54 s 5.65 s -// New rasterizer : 5.63 s 5.00 s - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -//// -//// SAMPLE PROGRAMS -//// -// -// Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless -// -#if 0 -#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation -#include "stb_truetype.h" - -unsigned char ttf_buffer[1<<20]; -unsigned char temp_bitmap[512*512]; - -stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs -GLuint ftex; - -void my_stbtt_initfont(void) -{ - fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb")); - stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits! - // can free ttf_buffer at this point - glGenTextures(1, &ftex); - glBindTexture(GL_TEXTURE_2D, ftex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap); - // can free temp_bitmap at this point - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -} - -void my_stbtt_print(float x, float y, char *text) -{ - // assume orthographic projection with units = screen pixels, origin at top left - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, ftex); - glBegin(GL_QUADS); - while (*text) { - if (*text >= 32 && *text < 128) { - stbtt_aligned_quad q; - stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 - glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); - glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); - glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); - glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); - } - ++text; - } - glEnd(); -} -#endif -// -// -////////////////////////////////////////////////////////////////////////////// -// -// Complete program (this compiles): get a single bitmap, print as ASCII art -// -#if 0 -#include -#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation -#include "stb_truetype.h" - -char ttf_buffer[1<<25]; - -int main(int argc, char **argv) -{ - stbtt_fontinfo font; - unsigned char *bitmap; - int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); - - fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); - - stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); - bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); - - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) - putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); - putchar('\n'); - } - return 0; -} -#endif -// -// Output: -// -// .ii. -// @@@@@@. -// V@Mio@@o -// :i. V@V -// :oM@@M -// :@@@MM@M -// @@o o@M -// :@@. M@M -// @@@o@@@@ -// :M@@V:@@. -// -////////////////////////////////////////////////////////////////////////////// -// -// Complete program: print "Hello World!" banner, with bugs -// -#if 0 -char buffer[24<<20]; -unsigned char screen[20][79]; - -int main(int arg, char **argv) -{ - stbtt_fontinfo font; - int i,j,ascent,baseline,ch=0; - float scale, xpos=2; // leave a little padding in case the character extends left - char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness - - fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); - stbtt_InitFont(&font, buffer, 0); - - scale = stbtt_ScaleForPixelHeight(&font, 15); - stbtt_GetFontVMetrics(&font, &ascent,0,0); - baseline = (int) (ascent*scale); - - while (text[ch]) { - int advance,lsb,x0,y0,x1,y1; - float x_shift = xpos - (float) floor(xpos); - stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); - stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); - stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); - // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong - // because this API is really for baking character bitmaps into textures. if you want to render - // a sequence of characters, you really need to render each bitmap to a temp buffer, then - // "alpha blend" that into the working buffer - xpos += (advance * scale); - if (text[ch+1]) - xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); - ++ch; - } - - for (j=0; j < 20; ++j) { - for (i=0; i < 78; ++i) - putchar(" .:ioVM@"[screen[j][i]>>5]); - putchar('\n'); - } - - return 0; -} -#endif - - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -//// -//// INTEGRATION WITH YOUR CODEBASE -//// -//// The following sections allow you to supply alternate definitions -//// of C library functions used by stb_truetype. - -#ifdef STB_TRUETYPE_IMPLEMENTATION - // #define your own (u)stbtt_int8/16/32 before including to override this - #ifndef stbtt_uint8 - typedef unsigned char stbtt_uint8; - typedef signed char stbtt_int8; - typedef unsigned short stbtt_uint16; - typedef signed short stbtt_int16; - typedef unsigned int stbtt_uint32; - typedef signed int stbtt_int32; - #endif - - typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; - typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; - - // #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h - #ifndef STBTT_ifloor - #include - #define STBTT_ifloor(x) ((int) floor(x)) - #define STBTT_iceil(x) ((int) ceil(x)) - #endif - - #ifndef STBTT_sqrt - #include - #define STBTT_sqrt(x) sqrt(x) - #endif - - // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h - #ifndef STBTT_malloc - #include - #define STBTT_malloc(x,u) ((void)(u),malloc(x)) - #define STBTT_free(x,u) ((void)(u),free(x)) - #endif - - #ifndef STBTT_assert - #include - #define STBTT_assert(x) assert(x) - #endif - - #ifndef STBTT_strlen - #include - #define STBTT_strlen(x) strlen(x) - #endif - - #ifndef STBTT_memcpy - #include - #define STBTT_memcpy memcpy - #define STBTT_memset memset - #endif -#endif - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -//// -//// INTERFACE -//// -//// - -#ifndef __STB_INCLUDE_STB_TRUETYPE_H__ -#define __STB_INCLUDE_STB_TRUETYPE_H__ - -#ifdef STBTT_STATIC -#define STBTT_DEF static -#else -#define STBTT_DEF extern -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// TEXTURE BAKING API -// -// If you use this API, you only have to call two functions ever. -// - -typedef struct -{ - unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap - float xoff,yoff,xadvance; -} stbtt_bakedchar; - -STBTT_DEF int stbtt_BakeFontBitmap(const 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 - stbtt_bakedchar *chardata); // you allocate this, it's num_chars long -// if return is positive, the first unused row of the bitmap -// if return is negative, returns the negative of the number of characters that fit -// if return is 0, no characters fit and no rows were used -// This uses a very crappy packing. - -typedef struct -{ - float x0,y0,s0,t0; // top-left - 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 - 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 opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier -// Call GetBakedQuad with char_index = 'character - first_char', and it -// creates the quad you need to draw and advances the current position. -// -// The coordinate system used assumes y increases downwards. -// -// Characters will extend both above and below the current position; -// see discussion of "BASELINE" above. -// -// It's inefficient; you might want to c&p it and optimize it. - - - -////////////////////////////////////////////////////////////////////////////// -// -// NEW TEXTURE BAKING API -// -// This provides options for packing multiple fonts into one atlas, not -// perfectly but better than nothing. - -typedef struct -{ - unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap - float xoff,yoff,xadvance; - float xoff2,yoff2; -} stbtt_packedchar; - -typedef struct stbtt_pack_context stbtt_pack_context; -typedef struct stbtt_fontinfo stbtt_fontinfo; -#ifndef STB_RECT_PACK_VERSION -typedef struct stbrp_rect stbrp_rect; -#endif - -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 -// 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 -// bilinear filtering). -// -// Returns 0 on failure, 1 on success. - -STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); -// Cleans up the packing context and frees all memory. - -#define STBTT_POINT_SIZE(x) (-(x)) - -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, 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 -// bitmaps for characters with unicode values starting at first_unicode_char_in_range -// and increasing. Data for how to render them is stored in chardata_for_range; -// pass these to stbtt_GetPackedQuad to get back renderable quads. -// -// font_size is the full height of the character from ascender to descender, -// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed -// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() -// and pass that result as 'font_size': -// ..., 20 , ... // font max minus min y is 20 pixels tall -// ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall - -typedef struct -{ - float font_size; - int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint - int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints - int num_chars; - stbtt_packedchar *chardata_for_range; // output - 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); -// 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 -// times within a single PackBegin/PackEnd. - -STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); -// Oversampling a font increases the quality by allowing higher-quality subpixel -// positioning, and is especially valuable at smaller text sizes. -// -// This function sets the amount of oversampling for all following calls to -// stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given -// pack context. The default (no oversampling) is achieved by h_oversample=1 -// and v_oversample=1. The total number of pixels required is -// h_oversample*v_oversample larger than the default; for example, 2x2 -// oversampling requires 4x the storage of 1x1. For best results, render -// oversampled textures with bilinear filtering. Look at the readme in -// stb/tests/oversample for information about oversampled fonts -// -// 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 - 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 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); -// 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 -// 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 -// better packing than calling PackFontRanges multiple times -// (or it may not). - -// this is an opaque structure that you shouldn't mess with which holds -// all the context needed from PackBegin to PackEnd. -struct stbtt_pack_context { - void *user_allocator_context; - void *pack_info; - int width; - int height; - int stride_in_bytes; - int padding; - unsigned int h_oversample, v_oversample; - unsigned char *pixels; - void *nodes; -}; - -////////////////////////////////////////////////////////////////////////////// -// -// FONT LOADING -// -// - -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. - - -// The following structure is defined publically 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 -{ - void * userdata; - unsigned char * data; // pointer to .ttf file - int fontstart; // offset of start of font - - 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 index_map; // a cmap mapping for our chosen character encoding - int indexToLocFormat; // format needed to map from glyph index to glyph -} stbtt_fontinfo; - -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 -// the necessary cached info for the rest of the system. You must allocate -// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't -// need to do anything special to free it, because the contents are pure -// value data with no additional data structures. Returns 0 on failure. - - -////////////////////////////////////////////////////////////////////////////// -// -// CHARACTER TO GLYPH-INDEX CONVERSIOn - -STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); -// If you're going to perform multiple operations on the same character -// 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. - - -////////////////////////////////////////////////////////////////////////////// -// -// CHARACTER PROPERTIES -// - -STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); -// computes a scale factor to produce a font whose "height" is 'pixels' tall. -// Height is measured as the distance from the highest ascender to the lowest -// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics -// and computing: -// scale = pixels / (ascent - descent) -// so if you prefer to measure height by the ascent only, use a similar calculation. - -STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); -// computes a scale factor to produce a font whose EM size is mapped to -// 'pixels' tall. This is probably what traditional APIs compute, but -// I'm not positive. - -STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); -// ascent is the coordinate above the baseline the font extends; descent -// is the coordinate below the baseline the font extends (i.e. it is typically negative) -// lineGap is the spacing between one row's descent and the next row's ascent... -// so you should advance the vertical position by "*ascent - *descent + *lineGap" -// these are expressed in unscaled coordinates, so you must multiply by -// the scale factor for a given size - -STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); -// the bounding box around all possible characters - -STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); -// leftSideBearing is the offset from the current horizontal position to the left edge of the character -// advanceWidth is the offset from the current horizontal position to the next horizontal position -// these are expressed in unscaled coordinates - -STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); -// an additional amount to add to the 'advance' value between ch1 and ch2 - -STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); -// Gets the bounding box of the visible part of the glyph, in unscaled coordinates - -STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); -STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); -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 - - -////////////////////////////////////////////////////////////////////////////// -// -// GLYPH SHAPES (you probably don't need these, but they have to go before -// the bitmaps for C declaration-order reasons) -// - -#ifndef STBTT_vmove // you can predefine these to use different values (but why?) - enum { - STBTT_vmove=1, - STBTT_vline, - STBTT_vcurve - }; -#endif - -#ifndef stbtt_vertex // you can predefine this to use different values - // (we share this with other code at RAD) - #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; - unsigned char type,padding; - } stbtt_vertex; -#endif - -STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); -// returns non-zero if nothing is drawn for this glyph - -STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); -STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); -// 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 -// 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 -// draws a quadratic bezier from previous endpoint to -// its x,y, using cx,cy as the bezier control point. - -STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); -// frees the data allocated above - -////////////////////////////////////////////////////////////////////////////// -// -// BITMAP RENDERING -// - -STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); -// frees the bitmap allocated below - -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); -// allocates a large-enough single-channel 8bpp bitmap and renders the -// specified character/glyph at the specified scale into it, with -// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). -// *width & *height are filled out with the width & height of the bitmap, -// which is stored left-to-right, top-to-bottom. -// -// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap - -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); -// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel -// shift for the character - -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); -// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap -// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap -// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the -// width and height and positioning info for it first. - -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); -// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel -// shift for the character - -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 -// the bitmap top left is (leftSideBearing*scale,iy0). -// (Note that the bitmap uses y-increases-down, but the shape uses -// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) - -STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); -// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel -// shift for the character - -// the following functions are equivalent to the above functions, but operate -// on glyph indices instead of Unicode codepoints (for efficiency) -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); -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_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); - - -// @TODO: don't expose this structure -typedef struct -{ - int w,h,stride; - unsigned char *pixels; -} stbtt__bitmap; - -// rasterize a shape with quadratic beziers into a bitmap -STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into - float flatness_in_pixels, // allowable error of curve in pixels - stbtt_vertex *vertices, // array of vertices defining shape - int num_verts, // number of vertices in above array - float scale_x, float scale_y, // scale applied to input vertices - float shift_x, float shift_y, // translation applied to input vertices - int x_off, int y_off, // another translation applied to input - int invert, // if non-zero, vertically flip shape - void *userdata); // context for to STBTT_MALLOC - -////////////////////////////////////////////////////////////////////////////// -// -// Finding the right font... -// -// You should really just solve this offline, keep your own tables -// of what font is what, and don't try to get it out of the .ttf file. -// That's because getting it out of the .ttf file is really hard, because -// the names in the file can appear in many possible encodings, in many -// possible languages, and e.g. if you need a case-insensitive comparison, -// the details of that depend on the encoding & language in a complex way -// (actually underspecified in truetype, but also gigantic). -// -// But you can use the provided functions in two possible ways: -// stbtt_FindMatchingFont() will use *case-sensitive* comparisons on -// unicode-encoded names to try to find the font you want; -// you can run this before calling stbtt_InitFont() -// -// stbtt_GetFontNameString() lets you get any of the various strings -// from the file yourself and do your own comparisons on them. -// You have to have called stbtt_InitFont() first. - - -STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); -// returns the offset (not index) of the font that matches, or -1 if none -// if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". -// if you use any other flag, use a font name like "Arial"; this checks -// the 'macStyle' header field; i don't know if fonts set this consistently -#define STBTT_MACSTYLE_DONTCARE 0 -#define STBTT_MACSTYLE_BOLD 1 -#define STBTT_MACSTYLE_ITALIC 2 -#define STBTT_MACSTYLE_UNDERSCORE 4 -#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 - -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); -// returns 1/0 whether the first string interpreted as utf8 is identical to -// the second string interpreted as big-endian utf16... useful for strings from next func - -STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); -// returns the string (which may be big-endian double byte, e.g. for unicode) -// and puts the length in bytes in *length. -// -// some of the values for the IDs are below; for more see the truetype spec: -// http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html -// http://www.microsoft.com/typography/otspec/name.htm - -enum { // platformID - STBTT_PLATFORM_ID_UNICODE =0, - STBTT_PLATFORM_ID_MAC =1, - STBTT_PLATFORM_ID_ISO =2, - STBTT_PLATFORM_ID_MICROSOFT =3 -}; - -enum { // encodingID for STBTT_PLATFORM_ID_UNICODE - STBTT_UNICODE_EID_UNICODE_1_0 =0, - STBTT_UNICODE_EID_UNICODE_1_1 =1, - STBTT_UNICODE_EID_ISO_10646 =2, - STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, - STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 -}; - -enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT - STBTT_MS_EID_SYMBOL =0, - STBTT_MS_EID_UNICODE_BMP =1, - STBTT_MS_EID_SHIFTJIS =2, - STBTT_MS_EID_UNICODE_FULL =10 -}; - -enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes - STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, - STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, - STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, - STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 -}; - -enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... - // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs - STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, - STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, - STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, - STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, - STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, - STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D -}; - -enum { // languageID for STBTT_PLATFORM_ID_MAC - STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, - STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, - STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, - STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , - STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , - STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, - STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 -}; - -#ifdef __cplusplus -} -#endif - -#endif // __STB_INCLUDE_STB_TRUETYPE_H__ - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -//// -//// IMPLEMENTATION -//// -//// - -#ifdef STB_TRUETYPE_IMPLEMENTATION - -#ifndef STBTT_MAX_OVERSAMPLE -#define STBTT_MAX_OVERSAMPLE 8 -#endif - -#if STBTT_MAX_OVERSAMPLE > 255 -#error "STBTT_MAX_OVERSAMPLE cannot be > 255" -#endif - -typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; - -#ifndef STBTT_RASTERIZER_VERSION -#define STBTT_RASTERIZER_VERSION 2 -#endif - -////////////////////////////////////////////////////////////////////////// -// -// accessors to parse data from file -// - -// on platforms that don't allow misaligned reads, if we want to allow -// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE - -#define ttBYTE(p) (* (stbtt_uint8 *) (p)) -#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 - -#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) -{ - // 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 - return 0; -} - -// @OPTIMIZE: binary search -static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) -{ - stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); - stbtt_uint32 tabledir = fontstart + 12; - stbtt_int32 i; - for (i=0; i < num_tables; ++i) { - stbtt_uint32 loc = tabledir + 16*i; - if (stbtt_tag(data+loc+0, tag)) - return ttULONG(data+loc+8); - } - return 0; -} - -STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index) -{ - // if it's just a font, there's only one valid index - if (stbtt__isfont(font_collection)) - return index == 0 ? 0 : -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) { - stbtt_int32 n = ttLONG(font_collection+8); - if (index >= n) - return -1; - return ttULONG(font_collection+12+index*4); - } - } - return -1; -} - -STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart) -{ - stbtt_uint8 *data = (stbtt_uint8 *) data2; - stbtt_uint32 cmap, t; - stbtt_int32 i,numTables; - - info->data = data; - info->fontstart = fontstart; - - cmap = stbtt__find_table(data, fontstart, "cmap"); // required - info->loca = stbtt__find_table(data, fontstart, "loca"); // required - info->head = stbtt__find_table(data, fontstart, "head"); // required - info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required - 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) - return 0; - - t = stbtt__find_table(data, fontstart, "maxp"); - if (t) - info->numGlyphs = ttUSHORT(data+t+4); - else - info->numGlyphs = 0xffff; - - // find a cmap encoding table we understand *now* to avoid searching - // later. (todo: could make this installable) - // the same regardless of glyph. - numTables = ttUSHORT(data + cmap + 2); - info->index_map = 0; - for (i=0; i < numTables; ++i) { - stbtt_uint32 encoding_record = cmap + 4 + 8 * i; - // find an encoding we understand: - switch(ttUSHORT(data+encoding_record)) { - case STBTT_PLATFORM_ID_MICROSOFT: - switch (ttUSHORT(data+encoding_record+2)) { - case STBTT_MS_EID_UNICODE_BMP: - case STBTT_MS_EID_UNICODE_FULL: - // MS/Unicode - info->index_map = cmap + ttULONG(data+encoding_record+4); - break; - } - break; - case STBTT_PLATFORM_ID_UNICODE: - // Mac/iOS has these - // all the encodingIDs are unicode, so we don't bother to check it - info->index_map = cmap + ttULONG(data+encoding_record+4); - break; - } - } - if (info->index_map == 0) - return 0; - - info->indexToLocFormat = ttUSHORT(data+info->head + 50); - return 1; -} - -STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) -{ - stbtt_uint8 *data = info->data; - stbtt_uint32 index_map = info->index_map; - - stbtt_uint16 format = ttUSHORT(data + index_map + 0); - if (format == 0) { // apple byte encoding - stbtt_int32 bytes = ttUSHORT(data + index_map + 2); - if (unicode_codepoint < bytes-6) - return ttBYTE(data + index_map + 6 + unicode_codepoint); - return 0; - } else if (format == 6) { - stbtt_uint32 first = ttUSHORT(data + index_map + 6); - stbtt_uint32 count = ttUSHORT(data + index_map + 8); - if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) - return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); - return 0; - } else if (format == 2) { - STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean - return 0; - } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges - stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; - stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; - stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); - stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; - - // do a binary search of the segments - stbtt_uint32 endCount = index_map + 14; - stbtt_uint32 search = endCount; - - if (unicode_codepoint > 0xffff) - return 0; - - // they lie from endCount .. endCount + segCount - // but searchRange is the nearest power of two, so... - if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) - search += rangeShift*2; - - // now decrement to bias correctly to find smallest - search -= 2; - while (entrySelector) { - stbtt_uint16 end; - searchRange >>= 1; - end = ttUSHORT(data + search + searchRange*2); - if (unicode_codepoint > end) - search += searchRange*2; - --entrySelector; - } - search += 2; - - { - stbtt_uint16 offset, start; - stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); - - STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); - start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); - if (unicode_codepoint < start) - return 0; - - offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); - if (offset == 0) - return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); - - return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); - } - } else if (format == 12 || format == 13) { - stbtt_uint32 ngroups = ttULONG(data+index_map+12); - stbtt_int32 low,high; - low = 0; high = (stbtt_int32)ngroups; - // Binary search the right group. - while (low < high) { - stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high - stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); - stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); - if ((stbtt_uint32) unicode_codepoint < start_char) - high = mid; - else if ((stbtt_uint32) unicode_codepoint > end_char) - low = mid+1; - else { - stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); - if (format == 12) - return start_glyph + unicode_codepoint-start_char; - else // format == 13 - return start_glyph; - } - } - return 0; // not found - } - // @TODO - STBTT_assert(0); - return 0; -} - -STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) -{ - return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); -} - -static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) -{ - v->type = type; - v->x = (stbtt_int16) x; - v->y = (stbtt_int16) y; - v->cx = (stbtt_int16) cx; - v->cy = (stbtt_int16) cy; -} - -static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) -{ - int g1,g2; - - if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range - if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format - - if (info->indexToLocFormat == 0) { - g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; - g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; - } else { - g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); - g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); - } - - return g1==g2 ? -1 : g1; // if length is 0, return -1 -} - -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 (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; -} - -STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) -{ - return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); -} - -STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) -{ - stbtt_int16 numberOfContours; - int g = stbtt__GetGlyfOffset(info, glyph_index); - if (g < 0) return 1; - numberOfContours = ttSHORT(info->data + g); - return numberOfContours == 0; -} - -static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, - stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) -{ - if (start_off) { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); - } else { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); - else - stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); - } - return num_vertices; -} - -STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) -{ - stbtt_int16 numberOfContours; - stbtt_uint8 *endPtsOfContours; - stbtt_uint8 *data = info->data; - stbtt_vertex *vertices=0; - int num_vertices=0; - int g = stbtt__GetGlyfOffset(info, glyph_index); - - *pvertices = NULL; - - if (g < 0) return 0; - - numberOfContours = ttSHORT(data + g); - - if (numberOfContours > 0) { - stbtt_uint8 flags=0,flagcount; - stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; - stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; - stbtt_uint8 *points; - endPtsOfContours = (data + g + 10); - ins = ttUSHORT(data + g + 10 + numberOfContours * 2); - points = data + g + 10 + numberOfContours * 2 + 2 + ins; - - n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); - - m = n + 2*numberOfContours; // a loose bound on how many vertices we might need - vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); - if (vertices == 0) - return 0; - - next_move = 0; - flagcount=0; - - // in first pass, we load uninterpreted data into the allocated array - // above, shifted to the end of the array so we won't overwrite it when - // we create our final data starting from the front - - off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated - - // first load flags - - for (i=0; i < n; ++i) { - if (flagcount == 0) { - flags = *points++; - if (flags & 8) - flagcount = *points++; - } else - --flagcount; - vertices[off+i].type = flags; - } - - // now load x coordinates - x=0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - if (flags & 2) { - stbtt_int16 dx = *points++; - x += (flags & 16) ? dx : -dx; // ??? - } else { - if (!(flags & 16)) { - x = x + (stbtt_int16) (points[0]*256 + points[1]); - points += 2; - } - } - vertices[off+i].x = (stbtt_int16) x; - } - - // now load y coordinates - y=0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - if (flags & 4) { - stbtt_int16 dy = *points++; - y += (flags & 32) ? dy : -dy; // ??? - } else { - if (!(flags & 32)) { - y = y + (stbtt_int16) (points[0]*256 + points[1]); - points += 2; - } - } - vertices[off+i].y = (stbtt_int16) y; - } - - // now convert them to our format - num_vertices=0; - sx = sy = cx = cy = scx = scy = 0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - x = (stbtt_int16) vertices[off+i].x; - y = (stbtt_int16) vertices[off+i].y; - - if (next_move == i) { - 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 - 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 - // where we can start, and we need to save some state for when we wraparound. - scx = x; - scy = y; - if (!(vertices[off+i+1].type & 1)) { - // next point is also a curve point, so interpolate an on-point curve - sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; - sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; - } else { - // otherwise just use the next point as our start point - sx = (stbtt_int32) vertices[off+i+1].x; - sy = (stbtt_int32) vertices[off+i+1].y; - ++i; // we're using point i+1 as the starting point, so skip it - } - } else { - sx = x; - sy = y; - } - stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); - was_off = 0; - next_move = 1 + ttUSHORT(endPtsOfContours+j*2); - ++j; - } else { - if (!(flags & 1)) { // if it's a curve - if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); - cx = x; - cy = y; - was_off = 1; - } else { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); - else - stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); - was_off = 0; - } - } - } - num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); - } else if (numberOfContours == -1) { - // Compound shapes. - int more = 1; - stbtt_uint8 *comp = data + g + 10; - num_vertices = 0; - vertices = 0; - while (more) { - stbtt_uint16 flags, gidx; - 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; - - if (flags & 2) { // XY values - if (flags & 1) { // shorts - mtx[4] = ttSHORT(comp); comp+=2; - mtx[5] = ttSHORT(comp); comp+=2; - } else { - mtx[4] = ttCHAR(comp); comp+=1; - mtx[5] = ttCHAR(comp); comp+=1; - } - } - else { - // @TODO handle matching point - STBTT_assert(0); - } - if (flags & (1<<3)) { // WE_HAVE_A_SCALE - mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = mtx[2] = 0; - } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE - mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = mtx[2] = 0; - mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO - mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; - 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]); - - // Get indexed glyph. - comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); - if (comp_num_verts > 0) { - // Transform vertices. - for (i = 0; i < comp_num_verts; ++i) { - stbtt_vertex* v = &comp_verts[i]; - stbtt_vertex_type x,y; - x=v->x; y=v->y; - v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); - v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); - x=v->cx; y=v->cy; - v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); - v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); - } - // Append vertices. - tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); - if (!tmp) { - if (vertices) STBTT_free(vertices, info->userdata); - if (comp_verts) STBTT_free(comp_verts, info->userdata); - return 0; - } - if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); - STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); - if (vertices) STBTT_free(vertices, info->userdata); - vertices = tmp; - STBTT_free(comp_verts, info->userdata); - num_vertices += comp_num_verts; - } - // More components ? - more = flags & (1<<5); - } - } else if (numberOfContours < 0) { - // @TODO other compound variations? - STBTT_assert(0); - } else { - // numberOfCounters == 0, do nothing - } - - *pvertices = vertices; - return num_vertices; -} - -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); - if (glyph_index < numOfLongHorMetrics) { - if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); - if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); - } else { - if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); - if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); - } -} - -STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) -{ - stbtt_uint8 *data = info->data + info->kern; - stbtt_uint32 needle, straw; - int l, r, m; - - // 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; - - l = 0; - r = ttUSHORT(data+10) - 1; - needle = glyph1 << 16 | glyph2; - while (l <= r) { - m = (l + r) >> 1; - straw = ttULONG(data+18+(m*6)); // note: unaligned read - if (needle < straw) - r = m - 1; - else if (needle > straw) - l = m + 1; - else - return ttSHORT(data+22+(m*6)); - } - return 0; -} - -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 - return 0; - return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); -} - -STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) -{ - stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); -} - -STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) -{ - if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); - if (descent) *descent = ttSHORT(info->data+info->hhea + 6); - if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); -} - -STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) -{ - *x0 = ttSHORT(info->data + info->head + 36); - *y0 = ttSHORT(info->data + info->head + 38); - *x1 = ttSHORT(info->data + info->head + 40); - *y1 = ttSHORT(info->data + info->head + 42); -} - -STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) -{ - int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); - return (float) height / fheight; -} - -STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) -{ - int unitsPerEm = ttUSHORT(info->data + info->head + 18); - return pixels / unitsPerEm; -} - -STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) -{ - STBTT_free(v, info->userdata); -} - -////////////////////////////////////////////////////////////////////////////// -// -// antialiasing software rasterizer -// - -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) -{ - int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning - if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { - // e.g. space character - if (ix0) *ix0 = 0; - if (iy0) *iy0 = 0; - if (ix1) *ix1 = 0; - if (iy1) *iy1 = 0; - } else { - // move to integral bboxes (treating pixels as little squares, what pixels get touched)? - if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); - if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); - if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); - if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); - } -} - -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_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); -} - -STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) -{ - stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); -} - -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) -{ - stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); -} - -////////////////////////////////////////////////////////////////////////////// -// -// Rasterizer - -typedef struct stbtt__hheap_chunk -{ - struct stbtt__hheap_chunk *next; -} stbtt__hheap_chunk; - -typedef struct stbtt__hheap -{ - struct stbtt__hheap_chunk *head; - void *first_free; - int num_remaining_in_head_chunk; -} stbtt__hheap; - -static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) -{ - if (hh->first_free) { - void *p = hh->first_free; - hh->first_free = * (void **) p; - return p; - } else { - if (hh->num_remaining_in_head_chunk == 0) { - int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); - stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); - if (c == NULL) - return NULL; - c->next = hh->head; - hh->head = c; - hh->num_remaining_in_head_chunk = count; - } - --hh->num_remaining_in_head_chunk; - return (char *) (hh->head) + size * hh->num_remaining_in_head_chunk; - } -} - -static void stbtt__hheap_free(stbtt__hheap *hh, void *p) -{ - *(void **) p = hh->first_free; - hh->first_free = p; -} - -static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) -{ - stbtt__hheap_chunk *c = hh->head; - while (c) { - stbtt__hheap_chunk *n = c->next; - STBTT_free(c, userdata); - c = n; - } -} - -typedef struct stbtt__edge { - float x0,y0, x1,y1; - int invert; -} stbtt__edge; - - -typedef struct stbtt__active_edge -{ - struct stbtt__active_edge *next; - #if STBTT_RASTERIZER_VERSION==1 - int x,dx; - float ey; - int direction; - #elif STBTT_RASTERIZER_VERSION==2 - float fx,fdx,fdy; - float direction; - float sy; - float ey; - #else - #error "Unrecognized value of STBTT_RASTERIZER_VERSION" - #endif -} stbtt__active_edge; - -#if STBTT_RASTERIZER_VERSION == 1 -#define STBTT_FIXSHIFT 10 -#define STBTT_FIX (1 << STBTT_FIXSHIFT) -#define STBTT_FIXMASK (STBTT_FIX-1) - -static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) -{ - stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); - 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); - else - z->dx = STBTT_ifloor(STBTT_FIX * dxdy); - - z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount - z->x -= off_x * STBTT_FIX; - - z->ey = e->y1; - z->next = 0; - z->direction = e->invert ? 1 : -1; - return z; -} -#elif STBTT_RASTERIZER_VERSION == 2 -static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) -{ - stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); - float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); - STBTT_assert(z != NULL); - //STBTT_assert(e->y0 <= start_point); - if (!z) return z; - z->fdx = dxdy; - z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; - z->fx = e->x0 + dxdy * (start_point - e->y0); - z->fx -= off_x; - z->direction = e->invert ? 1.0f : -1.0f; - z->sy = e->y0; - z->ey = e->y1; - z->next = 0; - return z; -} -#else -#error "Unrecognized value of STBTT_RASTERIZER_VERSION" -#endif - -#if STBTT_RASTERIZER_VERSION == 1 -// note: this routine clips fills that extend off the edges... ideally this -// wouldn't happen, but it could happen if the truetype glyph bounding boxes -// are wrong, or if the user supplies a too-small bitmap -static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) -{ - // non-zero winding fill - int x0=0, w=0; - - while (e) { - if (w == 0) { - // if we're currently at zero, we need to record the edge start point - x0 = e->x; w += e->direction; - } else { - int x1 = e->x; w += e->direction; - // if we went to zero, we need to draw - if (w == 0) { - int i = x0 >> STBTT_FIXSHIFT; - int j = x1 >> STBTT_FIXSHIFT; - - if (i < len && j >= 0) { - if (i == j) { - // x0,x1 are the same pixel, so compute combined coverage - scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); - } else { - if (i >= 0) // add antialiasing for x0 - scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); - else - i = -1; // clip - - if (j < len) // add antialiasing for x1 - scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); - else - j = len; // clip - - for (++i; i < j; ++i) // fill pixels between x0 and x1 - scanline[i] = scanline[i] + (stbtt_uint8) max_weight; - } - } - } - } - - e = e->next; - } -} - -static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) -{ - stbtt__hheap hh = { 0, 0, 0 }; - stbtt__active_edge *active = NULL; - int y,j=0; - int max_weight = (255 / vsubsample); // weight per vertical scanline - int s; // vertical subsample index - unsigned char scanline_data[512], *scanline; - - if (result->w > 512) - scanline = (unsigned char *) STBTT_malloc(result->w, userdata); - else - scanline = scanline_data; - - y = off_y * vsubsample; - e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; - - while (j < result->h) { - STBTT_memset(scanline, 0, result->w); - for (s=0; s < vsubsample; ++s) { - // find center of pixel for this scanline - float scan_y = y + 0.5f; - stbtt__active_edge **step = &active; - - // update all active edges; - // remove all active edges that terminate before the center of this scanline - while (*step) { - stbtt__active_edge * z = *step; - if (z->ey <= scan_y) { - *step = z->next; // delete from list - STBTT_assert(z->direction); - z->direction = 0; - stbtt__hheap_free(&hh, z); - } else { - z->x += z->dx; // advance to position for current scanline - step = &((*step)->next); // advance through list - } - } - - // resort the list if needed - for(;;) { - int changed=0; - step = &active; - while (*step && (*step)->next) { - if ((*step)->x > (*step)->next->x) { - stbtt__active_edge *t = *step; - stbtt__active_edge *q = t->next; - - t->next = q->next; - q->next = t; - *step = q; - changed = 1; - } - step = &(*step)->next; - } - if (!changed) break; - } - - // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline - while (e->y0 <= scan_y) { - if (e->y1 > scan_y) { - stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); - if (z != NULL) { - // find insertion point - if (active == NULL) - active = z; - else if (z->x < active->x) { - // insert at front - z->next = active; - active = z; - } else { - // find thing to insert AFTER - stbtt__active_edge *p = active; - while (p->next && p->next->x < z->x) - p = p->next; - // at this point, p->next->x is NOT < z->x - z->next = p->next; - p->next = z; - } - } - } - ++e; - } - - // now process all active edges in XOR fashion - if (active) - stbtt__fill_active_edges(scanline, result->w, active, max_weight); - - ++y; - } - STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); - ++j; - } - - stbtt__hheap_cleanup(&hh, userdata); - - if (scanline != scanline_data) - STBTT_free(scanline, userdata); -} - -#elif STBTT_RASTERIZER_VERSION == 2 - -// the edge passed in here does not cross the vertical line at x or the vertical line at x+1 -// (i.e. it has already been clipped to those) -static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) -{ - if (y0 == y1) return; - STBTT_assert(y0 < y1); - STBTT_assert(e->sy <= e->ey); - if (y0 > e->ey) return; - if (y1 < e->sy) return; - if (y0 < e->sy) { - x0 += (x1-x0) * (e->sy - y0) / (y1-y0); - y0 = e->sy; - } - if (y1 > e->ey) { - x1 += (x1-x0) * (e->ey - y1) / (y1-y0); - y1 = e->ey; - } - - if (x0 == x) - STBTT_assert(x1 <= x+1); - else if (x0 == x+1) - STBTT_assert(x1 >= x); - else if (x0 <= x) - STBTT_assert(x1 <= x); - else if (x0 >= x+1) - STBTT_assert(x1 >= x+1); - else - STBTT_assert(x1 >= x && x1 <= x+1); - - if (x0 <= x && x1 <= x) - scanline[x] += e->direction * (y1-y0); - else if (x0 >= x+1 && x1 >= x+1) - ; - else { - STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); - scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position - } -} - -static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) -{ - float y_bottom = y_top+1; - - while (e) { - // brute force every pixel - - // compute intersection points with top & bottom - STBTT_assert(e->ey >= y_top); - - if (e->fdx == 0) { - float x0 = e->fx; - if (x0 < len) { - if (x0 >= 0) { - stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); - stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); - } else { - stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); - } - } - } else { - float x0 = e->fx; - float dx = e->fdx; - float xb = x0 + dx; - float x_top, x_bottom; - float sy0,sy1; - float dy = e->fdy; - STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); - - // compute endpoints of line segment clipped to this scanline (if the - // line segment starts on this scanline. x0 is the intersection of the - // line with y_top, but that may be off the line segment. - if (e->sy > y_top) { - x_top = x0 + dx * (e->sy - y_top); - sy0 = e->sy; - } else { - x_top = x0; - sy0 = y_top; - } - if (e->ey < y_bottom) { - x_bottom = x0 + dx * (e->ey - y_top); - sy1 = e->ey; - } else { - x_bottom = xb; - sy1 = y_bottom; - } - - if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { - // from here on, we don't have to range check x values - - if ((int) x_top == (int) x_bottom) { - float height; - // simple case, only spans one pixel - int x = (int) x_top; - height = sy1 - sy0; - STBTT_assert(x >= 0 && x < len); - scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; - scanline_fill[x] += e->direction * height; // everything right of this pixel is filled - } else { - int x,x1,x2; - float y_crossing, step, sign, area; - // covers 2+ pixels - if (x_top > x_bottom) { - // flip scanline vertically; signed area is the same - float t; - sy0 = y_bottom - (sy0 - y_top); - sy1 = y_bottom - (sy1 - y_top); - t = sy0, sy0 = sy1, sy1 = t; - t = x_bottom, x_bottom = x_top, x_top = t; - dx = -dx; - dy = -dy; - t = x0, x0 = xb, xb = t; - } - - x1 = (int) x_top; - x2 = (int) x_bottom; - // compute intersection with y axis at x1+1 - y_crossing = (x1+1 - x0) * dy + y_top; - - sign = e->direction; - // area of the rectangle covered from y0..y_crossing - area = sign * (y_crossing-sy0); - // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) - scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); - - step = sign * dy; - for (x = x1+1; x < x2; ++x) { - scanline[x] += area + step/2; - area += step; - } - y_crossing += dy * (x2 - (x1+1)); - - STBTT_assert(fabs(area) <= 1.01f); - - scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); - - scanline_fill[x2] += sign * (sy1-sy0); - } - } else { - // if edge goes outside of box we're drawing, we require - // clipping logic. since this does not match the intended use - // of this library, we use a different, very slow brute - // force implementation - int x; - for (x=0; x < len; ++x) { - // cases: - // - // there can be up to two intersections with the pixel. any intersection - // with left or right edges can be handled by splitting into two (or three) - // regions. intersections with top & bottom do not necessitate case-wise logic. - // - // the old way of doing this found the intersections with the left & right edges, - // then used some simple logic to produce up to three segments in sorted order - // from top-to-bottom. however, this had a problem: if an x edge was epsilon - // across the x border, then the corresponding y position might not be distinct - // 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 - 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; - - if (x0 < x1 && x3 > x2) { // three segments descending down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else if (x3 < x1 && x0 > x2) { // three segments descending down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else { // one segment - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); - } - } - } - } - e = e->next; - } -} - -// directly AA rasterize edges w/o supersampling -static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) -{ - stbtt__hheap hh = { 0, 0, 0 }; - stbtt__active_edge *active = NULL; - int y,j=0, i; - float scanline_data[129], *scanline, *scanline2; - - if (result->w > 64) - scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); - else - scanline = scanline_data; - - scanline2 = scanline + result->w; - - y = off_y; - e[n].y0 = (float) (off_y + result->h) + 1; - - while (j < result->h) { - // find center of pixel for this scanline - float scan_y_top = y + 0.0f; - float scan_y_bottom = y + 1.0f; - stbtt__active_edge **step = &active; - - STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); - STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); - - // update all active edges; - // remove all active edges that terminate before the top of this scanline - while (*step) { - stbtt__active_edge * z = *step; - if (z->ey <= scan_y_top) { - *step = z->next; // delete from list - STBTT_assert(z->direction); - z->direction = 0; - stbtt__hheap_free(&hh, z); - } else { - step = &((*step)->next); // advance through list - } - } - - // insert all edges that start before the bottom of this scanline - while (e->y0 <= scan_y_bottom) { - 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); - // insert at front - z->next = active; - active = z; - } - } - ++e; - } - - // now process all active edges - if (active) - stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); - - { - float sum = 0; - for (i=0; i < result->w; ++i) { - float k; - int m; - sum += scanline2[i]; - k = scanline[i] + sum; - k = (float) fabs(k)*255 + 0.5f; - m = (int) k; - if (m > 255) m = 255; - result->pixels[j*result->stride + i] = (unsigned char) m; - } - } - // advance all the edges - step = &active; - while (*step) { - stbtt__active_edge *z = *step; - z->fx += z->fdx; // advance to position for current scanline - step = &((*step)->next); // advance through list - } - - ++y; - ++j; - } - - stbtt__hheap_cleanup(&hh, userdata); - - if (scanline != scanline_data) - STBTT_free(scanline, userdata); -} -#else -#error "Unrecognized value of STBTT_RASTERIZER_VERSION" -#endif - -#define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) - -static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) -{ - int i,j; - for (i=1; i < n; ++i) { - stbtt__edge t = p[i], *a = &t; - j = i; - while (j > 0) { - stbtt__edge *b = &p[j-1]; - int c = STBTT__COMPARE(a,b); - if (!c) break; - p[j] = p[j-1]; - --j; - } - if (i != j) - p[j] = t; - } -} - -static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) -{ - /* threshhold for transitioning to insertion sort */ - while (n > 12) { - stbtt__edge t; - int c01,c12,c,m,i,j; - - /* compute median of three */ - m = n >> 1; - c01 = STBTT__COMPARE(&p[0],&p[m]); - c12 = STBTT__COMPARE(&p[m],&p[n-1]); - /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ - if (c01 != c12) { - /* otherwise, we'll need to swap something else to middle */ - int z; - c = STBTT__COMPARE(&p[0],&p[n-1]); - /* 0>mid && midn => n; 0 0 */ - /* 0n: 0>n => 0; 0 n */ - z = (c == c12) ? 0 : n-1; - t = p[z]; - p[z] = p[m]; - p[m] = t; - } - /* now p[m] is the median-of-three */ - /* swap it to the beginning so it won't move around */ - t = p[0]; - p[0] = p[m]; - p[m] = t; - - /* partition loop */ - i=1; - j=n-1; - for(;;) { - /* handling of equality is crucial here */ - /* for sentinels & efficiency with duplicates */ - for (;;++i) { - if (!STBTT__COMPARE(&p[i], &p[0])) break; - } - for (;;--j) { - if (!STBTT__COMPARE(&p[0], &p[j])) break; - } - /* make sure we haven't crossed */ - if (i >= j) break; - t = p[i]; - p[i] = p[j]; - p[j] = t; - - ++i; - --j; - } - /* recurse on smaller side, iterate on larger */ - if (j < (n-i)) { - stbtt__sort_edges_quicksort(p,j); - p = p+i; - n = n-i; - } else { - stbtt__sort_edges_quicksort(p+i, n-i); - n = j; - } - } -} - -static void stbtt__sort_edges(stbtt__edge *p, int n) -{ - stbtt__sort_edges_quicksort(p, n); - stbtt__sort_edges_ins_sort(p, n); -} - -typedef struct -{ - float x,y; -} stbtt__point; - -static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) -{ - float y_scale_inv = invert ? -scale_y : scale_y; - stbtt__edge *e; - int n,i,j,k,m; -#if STBTT_RASTERIZER_VERSION == 1 - int vsubsample = result->h < 8 ? 15 : 5; -#elif STBTT_RASTERIZER_VERSION == 2 - int vsubsample = 1; -#else - #error "Unrecognized value of STBTT_RASTERIZER_VERSION" -#endif - // vsubsample should divide 255 evenly; otherwise we won't reach full opacity - - // now we have to blow out the windings into explicit edge lists - n = 0; - for (i=0; i < windings; ++i) - n += wcount[i]; - - e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel - if (e == 0) return; - n = 0; - - m=0; - for (i=0; i < windings; ++i) { - stbtt__point *p = pts + m; - m += wcount[i]; - j = wcount[i]-1; - for (k=0; k < wcount[i]; j=k++) { - int a=k,b=j; - // skip the edge if horizontal - if (p[j].y == p[k].y) - continue; - // add edge from j to k to the list - e[n].invert = 0; - if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { - e[n].invert = 1; - a=j,b=k; - } - e[n].x0 = p[a].x * scale_x + shift_x; - e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; - e[n].x1 = p[b].x * scale_x + shift_x; - e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; - ++n; - } - } - - // now sort the edges by their highest point (should snap to integer, and then by x) - //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); - stbtt__sort_edges(e, n); - - // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule - stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); - - STBTT_free(e, userdata); -} - -static void stbtt__add_point(stbtt__point *points, int n, float x, float y) -{ - if (!points) return; // during first pass, it's unallocated - points[n].x = x; - points[n].y = y; -} - -// tesselate until threshhold 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 - float mx = (x0 + 2*x1 + x2)/4; - float my = (y0 + 2*y1 + y2)/4; - // versus directly drawn line - float dx = (x0+x2)/2 - mx; - float dy = (y0+y2)/2 - my; - if (n > 16) // 65536 segments on one curve better be enough! - return 1; - if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA - stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); - stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); - } else { - stbtt__add_point(points, *num_points,x2,y2); - *num_points = *num_points+1; - } - return 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) -{ - stbtt__point *points=0; - int num_points=0; - - float objspace_flatness_squared = objspace_flatness * objspace_flatness; - int i,n=0,start=0, pass; - - // count how many "moves" there are to get the contour count - for (i=0; i < num_verts; ++i) - if (vertices[i].type == STBTT_vmove) - ++n; - - *num_contours = n; - if (n == 0) return 0; - - *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); - - if (*contour_lengths == 0) { - *num_contours = 0; - return 0; - } - - // make two passes through the points so we don't need to realloc - for (pass=0; pass < 2; ++pass) { - float x=0,y=0; - if (pass == 1) { - points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); - if (points == NULL) goto error; - } - num_points = 0; - n= -1; - for (i=0; i < num_verts; ++i) { - switch (vertices[i].type) { - case STBTT_vmove: - // start the next contour - if (n >= 0) - (*contour_lengths)[n] = num_points - start; - ++n; - start = num_points; - - x = vertices[i].x, y = vertices[i].y; - stbtt__add_point(points, num_points++, x,y); - break; - case STBTT_vline: - x = vertices[i].x, y = vertices[i].y; - stbtt__add_point(points, num_points++, x, y); - break; - case STBTT_vcurve: - stbtt__tesselate_curve(points, &num_points, x,y, - vertices[i].cx, vertices[i].cy, - 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; - } - - return points; -error: - STBTT_free(points, userdata); - STBTT_free(*contour_lengths, userdata); - *contour_lengths = 0; - *num_contours = 0; - return NULL; -} - -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; - 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); - STBTT_free(winding_lengths, userdata); - STBTT_free(windings, userdata); - } -} - -STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) -{ - STBTT_free(bitmap, userdata); -} - -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) -{ - int ix0,iy0,ix1,iy1; - stbtt__bitmap gbm; - 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; - scale_y = scale_x; - } - - stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); - - // now we get the size - gbm.w = (ix1 - ix0); - gbm.h = (iy1 - iy0); - gbm.pixels = NULL; // in case we error - - if (width ) *width = gbm.w; - 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) { - gbm.stride = gbm.w; - - stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); - } - } - 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) -{ - return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); -} - -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) -{ - int ix0,iy0; - stbtt_vertex *vertices; - int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); - stbtt__bitmap gbm; - - stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); - gbm.pixels = output; - gbm.w = out_w; - gbm.h = out_h; - gbm.stride = out_stride; - - if (gbm.w && gbm.h) - stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); - - STBTT_free(vertices, info->userdata); -} - -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_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); -} - -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_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) -{ - stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); -} - -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) -{ - stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); -} - -////////////////////////////////////////////////////////////////////////////// -// -// bitmap baking -// -// 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) - 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 - stbtt_bakedchar *chardata) -{ - float scale; - int x,y,bottom_y, i; - stbtt_fontinfo f; - f.userdata = NULL; - if (!stbtt_InitFont(&f, data, offset)) - return -1; - STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels - x=y=1; - bottom_y = 1; - - scale = stbtt_ScaleForPixelHeight(&f, pixel_height); - - for (i=0; i < num_chars; ++i) { - int advance, lsb, x0,y0,x1,y1,gw,gh; - int g = stbtt_FindGlyphIndex(&f, first_char + i); - stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); - stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); - gw = x1-x0; - gh = y1-y0; - if (x + gw + 1 >= pw) - y = bottom_y, x = 1; // advance to next row - if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row - return -i; - STBTT_assert(x+gw < pw); - STBTT_assert(y+gh < ph); - stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); - chardata[i].x0 = (stbtt_int16) x; - chardata[i].y0 = (stbtt_int16) y; - chardata[i].x1 = (stbtt_int16) (x + gw); - chardata[i].y1 = (stbtt_int16) (y + gh); - chardata[i].xadvance = scale * advance; - chardata[i].xoff = (float) x0; - chardata[i].yoff = (float) y0; - x = x + gw + 1; - if (y+gh+1 > bottom_y) - bottom_y = y+gh+1; - } - 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) -{ - float d3d_bias = opengl_fillrule ? 0 : -0.5f; - float ipw = 1.0f / pw, iph = 1.0f / ph; - 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); - - q->x0 = round_x + d3d_bias; - q->y0 = round_y + d3d_bias; - q->x1 = round_x + b->x1 - b->x0 + d3d_bias; - q->y1 = round_y + b->y1 - b->y0 + d3d_bias; - - q->s0 = b->x0 * ipw; - q->t0 = b->y0 * iph; - q->s1 = b->x1 * ipw; - q->t1 = b->y1 * iph; - - *xpos += b->xadvance; -} - -////////////////////////////////////////////////////////////////////////////// -// -// rectangle packing replacement routines if you don't have stb_rect_pack.h -// - -#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; - -//////////////////////////////////////////////////////////////////////////////////// -// // -// // -// COMPILER WARNING ?!?!? // -// // -// // -// if you get a compile warning due to these symbols being defined more than // -// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // -// // -//////////////////////////////////////////////////////////////////////////////////// - -typedef struct -{ - int width,height; - int x,y,bottom_y; -} stbrp_context; - -typedef struct -{ - unsigned char x; -} stbrp_node; - -struct stbrp_rect -{ - stbrp_coord x,y; - int id,w,h,was_packed; -}; - -static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) -{ - con->width = pw; - con->height = ph; - con->x = 0; - con->y = 0; - con->bottom_y = 0; - STBTT__NOTUSED(nodes); - STBTT__NOTUSED(num_nodes); -} - -static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) -{ - int i; - for (i=0; i < num_rects; ++i) { - if (con->x + rects[i].w > con->width) { - con->x = 0; - con->y = con->bottom_y; - } - if (con->y + rects[i].h > con->height) - break; - rects[i].x = con->x; - rects[i].y = con->y; - rects[i].was_packed = 1; - con->x += rects[i].w; - if (con->y + rects[i].h > con->bottom_y) - con->bottom_y = con->y + rects[i].h; - } - for ( ; i < num_rects; ++i) - rects[i].was_packed = 0; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// bitmap baking -// -// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If -// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. - -STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) -{ - stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); - int num_nodes = pw - padding; - stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); - - if (context == NULL || nodes == NULL) { - if (context != NULL) STBTT_free(context, alloc_context); - if (nodes != NULL) STBTT_free(nodes , alloc_context); - return 0; - } - - spc->user_allocator_context = alloc_context; - spc->width = pw; - spc->height = ph; - spc->pixels = pixels; - spc->pack_info = context; - spc->nodes = nodes; - spc->padding = padding; - spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; - spc->h_oversample = 1; - spc->v_oversample = 1; - - stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); - - if (pixels) - STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels - - return 1; -} - -STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) -{ - STBTT_free(spc->nodes , spc->user_allocator_context); - STBTT_free(spc->pack_info, spc->user_allocator_context); -} - -STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) -{ - STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); - STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); - if (h_oversample <= STBTT_MAX_OVERSAMPLE) - spc->h_oversample = h_oversample; - if (v_oversample <= STBTT_MAX_OVERSAMPLE) - spc->v_oversample = v_oversample; -} - -#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) -{ - unsigned char buffer[STBTT_MAX_OVERSAMPLE]; - int safe_w = w - kernel_width; - int j; - STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze - for (j=0; j < h; ++j) { - int i; - unsigned int total; - STBTT_memset(buffer, 0, kernel_width); - - total = 0; - - // make kernel_width a constant in common cases so compiler can optimize out the divide - switch (kernel_width) { - case 2: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 2); - } - break; - case 3: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 3); - } - break; - case 4: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 4); - } - break; - case 5: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 5); - } - break; - default: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / kernel_width); - } - break; - } - - for (; i < w; ++i) { - STBTT_assert(pixels[i] == 0); - total -= buffer[i & STBTT__OVER_MASK]; - pixels[i] = (unsigned char) (total / kernel_width); - } - - pixels += stride_in_bytes; - } -} - -static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) -{ - unsigned char buffer[STBTT_MAX_OVERSAMPLE]; - int safe_h = h - kernel_width; - int j; - STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze - for (j=0; j < w; ++j) { - int i; - unsigned int total; - STBTT_memset(buffer, 0, kernel_width); - - total = 0; - - // make kernel_width a constant in common cases so compiler can optimize out the divide - switch (kernel_width) { - case 2: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 2); - } - break; - case 3: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 3); - } - break; - case 4: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 4); - } - break; - case 5: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 5); - } - break; - default: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); - } - break; - } - - for (; i < h; ++i) { - STBTT_assert(pixels[i*stride_in_bytes] == 0); - total -= buffer[i & STBTT__OVER_MASK]; - pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); - } - - pixels += 1; - } -} - -static float stbtt__oversample_shift(int oversample) -{ - if (!oversample) - return 0.0f; - - // The prefilter is a box filter of width "oversample", - // which shifts phase by (oversample - 1)/2 pixels in - // oversampled space. We want to shift in the opposite - // direction to counter this. - return (float)-(oversample - 1) / (2.0f * (float)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) -{ - int i,j,k; - - k=0; - for (i=0; i < num_ranges; ++i) { - float fh = ranges[i].font_size; - float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); - ranges[i].h_oversample = (unsigned char) spc->h_oversample; - ranges[i].v_oversample = (unsigned char) spc->v_oversample; - for (j=0; j < ranges[i].num_chars; ++j) { - 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); - ++k; - } - } - - return k; -} - -// 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) -{ - int i,j,k, return_value = 1; - - // save current values - int old_h_over = spc->h_oversample; - int old_v_over = spc->v_oversample; - - k = 0; - for (i=0; i < num_ranges; ++i) { - float fh = ranges[i].font_size; - float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); - float recip_h,recip_v,sub_x,sub_y; - spc->h_oversample = ranges[i].h_oversample; - spc->v_oversample = ranges[i].v_oversample; - recip_h = 1.0f / spc->h_oversample; - recip_v = 1.0f / spc->v_oversample; - sub_x = stbtt__oversample_shift(spc->h_oversample); - 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) { - 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]; - int glyph = stbtt_FindGlyphIndex(info, codepoint); - stbrp_coord pad = (stbrp_coord) spc->padding; - - // pad on left and top - r->x += pad; - r->y += pad; - r->w -= pad; - r->h -= pad; - stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); - stbtt_GetGlyphBitmapBox(info, glyph, - scale * spc->h_oversample, - scale * spc->v_oversample, - &x0,&y0,&x1,&y1); - stbtt_MakeGlyphBitmapSubpixel(info, - spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w - spc->h_oversample+1, - r->h - spc->v_oversample+1, - spc->stride_in_bytes, - scale * spc->h_oversample, - scale * spc->v_oversample, - 0,0, - glyph); - - if (spc->h_oversample > 1) - stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w, r->h, spc->stride_in_bytes, - spc->h_oversample); - - if (spc->v_oversample > 1) - stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w, r->h, spc->stride_in_bytes, - spc->v_oversample); - - bc->x0 = (stbtt_int16) r->x; - bc->y0 = (stbtt_int16) r->y; - bc->x1 = (stbtt_int16) (r->x + r->w); - bc->y1 = (stbtt_int16) (r->y + r->h); - bc->xadvance = scale * advance; - bc->xoff = (float) x0 * recip_h + sub_x; - 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; - } else { - return_value = 0; // if any fail, report failure - } - - ++k; - } - } - - // restore original values - spc->h_oversample = old_h_over; - spc->v_oversample = old_v_over; - - return return_value; -} - -STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) -{ - 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_fontinfo info; - int i,j,n, return_value = 1; - //stbrp_context *context = (stbrp_context *) spc->pack_info; - stbrp_rect *rects; - - // flag all characters as NOT packed - for (i=0; i < num_ranges; ++i) - for (j=0; j < ranges[i].num_chars; ++j) - ranges[i].chardata_for_range[j].x0 = - ranges[i].chardata_for_range[j].y0 = - ranges[i].chardata_for_range[j].x1 = - ranges[i].chardata_for_range[j].y1 = 0; - - 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; - - info.userdata = spc->user_allocator_context; - stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); - - 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, - int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) -{ - stbtt_pack_range range; - range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; - range.array_of_unicode_codepoints = NULL; - range.num_chars = num_chars_in_range; - range.chardata_for_range = chardata_for_range; - range.font_size = font_size; - 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) -{ - float ipw = 1.0f / pw, iph = 1.0f / ph; - stbtt_packedchar *b = chardata + char_index; - - if (align_to_integer) { - float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); - float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); - q->x0 = x; - q->y0 = y; - q->x1 = x + b->xoff2 - b->xoff; - q->y1 = y + b->yoff2 - b->yoff; - } else { - q->x0 = *xpos + b->xoff; - q->y0 = *ypos + b->yoff; - q->x1 = *xpos + b->xoff2; - q->y1 = *ypos + b->yoff2; - } - - q->s0 = b->x0 * ipw; - q->t0 = b->y0 * iph; - q->s1 = b->x1 * ipw; - q->t1 = b->y1 * iph; - - *xpos += b->xadvance; -} - - -////////////////////////////////////////////////////////////////////////////// -// -// font name matching -- recommended not to use this -// - -// 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) -{ - stbtt_int32 i=0; - - // convert utf16 to utf8 and compare the results while converting - while (len2) { - stbtt_uint16 ch = s2[0]*256 + s2[1]; - if (ch < 0x80) { - if (i >= len1) return -1; - if (s1[i++] != ch) return -1; - } else if (ch < 0x800) { - if (i+1 >= len1) return -1; - if (s1[i++] != 0xc0 + (ch >> 6)) return -1; - if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; - } else if (ch >= 0xd800 && ch < 0xdc00) { - stbtt_uint32 c; - stbtt_uint16 ch2 = s2[2]*256 + s2[3]; - if (i+3 >= len1) return -1; - c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; - if (s1[i++] != 0xf0 + (c >> 18)) return -1; - if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; - s2 += 2; // plus another 2 below - len2 -= 2; - } else if (ch >= 0xdc00 && ch < 0xe000) { - return -1; - } else { - if (i+2 >= len1) return -1; - if (s1[i++] != 0xe0 + (ch >> 12)) return -1; - if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; - } - s2 += 2; - len2 -= 2; - } - return i; -} - -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) -{ - return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2); -} - -// returns results in whatever encoding you request... but note that 2-byte encodings -// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare -STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) -{ - stbtt_int32 i,count,stringOffset; - stbtt_uint8 *fc = font->data; - stbtt_uint32 offset = font->fontstart; - stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); - if (!nm) return NULL; - - count = ttUSHORT(fc+nm+2); - stringOffset = nm + ttUSHORT(fc+nm+4); - for (i=0; i < count; ++i) { - stbtt_uint32 loc = nm + 6 + 12 * i; - if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) - && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { - *length = ttUSHORT(fc+loc+8); - return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); - } - } - return NULL; -} - -static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) -{ - stbtt_int32 i; - stbtt_int32 count = ttUSHORT(fc+nm+2); - stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); - - for (i=0; i < count; ++i) { - stbtt_uint32 loc = nm + 6 + 12 * i; - stbtt_int32 id = ttUSHORT(fc+loc+6); - if (id == target_id) { - // find the encoding - stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); - - // is this a Unicode encoding? - if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { - stbtt_int32 slen = ttUSHORT(fc+loc+8); - stbtt_int32 off = ttUSHORT(fc+loc+10); - - // check if there's a prefix match - stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); - if (matchlen >= 0) { - // check for target_id+1 immediately following, with same encoding & language - if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { - slen = ttUSHORT(fc+loc+12+8); - off = ttUSHORT(fc+loc+12+10); - if (slen == 0) { - if (matchlen == nlen) - return 1; - } else if (matchlen < nlen && name[matchlen] == ' ') { - ++matchlen; - if (stbtt_CompareUTF8toUTF16_bigendian((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) - return 1; - } - } else { - // if nothing immediately following - if (matchlen == nlen) - return 1; - } - } - } - - // @TODO handle other encodings - } - } - return 0; -} - -static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) -{ - stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); - stbtt_uint32 nm,hd; - if (!stbtt__isfont(fc+offset)) return 0; - - // check italics/bold/underline flags in macStyle... - if (flags) { - hd = stbtt__find_table(fc, offset, "head"); - if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; - } - - nm = stbtt__find_table(fc, offset, "name"); - if (!nm) return 0; - - if (flags) { - // if we checked the macStyle flags, then just check the family and ignore the subfamily - if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; - } else { - if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; - } - - return 0; -} - -STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags) -{ - stbtt_int32 i; - for (i=0;;++i) { - stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); - if (off < 0) return off; - if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) - return off; - } -} - -#endif // STB_TRUETYPE_IMPLEMENTATION - - -// FULL VERSION HISTORY -// -// 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; -// allow PackFontRanges to pack and render in separate phases; -// 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 -// 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ -// 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match -// non-oversampled; STBTT_POINT_SIZE for packed case only -// 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling -// 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) -// 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID -// 0.8b (2014-07-07) fix a warning -// 0.8 (2014-05-25) fix a few more warnings -// 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back -// 0.6c (2012-07-24) improve documentation -// 0.6b (2012-07-20) fix a few more warnings -// 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, -// stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty -// 0.5 (2011-12-09) bugfixes: -// subpixel glyph renderer computed wrong bounding box -// first vertex of shape can be off-curve (FreeSans) -// 0.4b (2011-12-03) fixed an error in the font baking example -// 0.4 (2011-12-01) kerning, subpixel rendering (tor) -// bugfixes for: -// codepoint-to-glyph conversion using table fmt=12 -// codepoint-to-glyph conversion using table fmt=4 -// stbtt_GetBakedQuad with non-square texture (Zer) -// updated Hello World! sample to use kerning and subpixel -// fixed some warnings -// 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) -// userdata, malloc-from-userdata, non-zero fill (stb) -// 0.2 (2009-03-11) Fix unsigned/signed char warnings -// 0.1 (2009-03-09) First public release -// 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/qpoases/EXAMPLES/example1.cpp b/phonelibs/qpoases/EXAMPLES/example1.cpp deleted file mode 100644 index 92b47fc93798d2..00000000000000 --- a/phonelibs/qpoases/EXAMPLES/example1.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 EXAMPLES/example1.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Very simple example for testing qpOASES (using QProblem class). - */ - - -#include - - -/** Example for qpOASES main function using the QProblem class. */ -int main( ) -{ - /* Setup data of first QP. */ - real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; - real_t A[1*2] = { 1.0, 1.0 }; - real_t g[2] = { 1.5, 1.0 }; - real_t lb[2] = { 0.5, -2.0 }; - real_t ub[2] = { 5.0, 2.0 }; - real_t lbA[1] = { -1.0 }; - real_t ubA[1] = { 2.0 }; - - /* Setup data of second QP. */ - real_t g_new[2] = { 1.0, 1.5 }; - real_t lb_new[2] = { 0.0, -1.0 }; - real_t ub_new[2] = { 5.0, -0.5 }; - real_t lbA_new[1] = { -2.0 }; - real_t ubA_new[1] = { 1.0 }; - - - /* Setting up QProblem object. */ - QProblem example( 2,1 ); - - /* Solve first QP. */ - int nWSR = 10; - example.init( H,g,A,lb,ub,lbA,ubA, nWSR,0 ); - - /* Solve second QP. */ - nWSR = 10; - example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR,0 ); - - return 0; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/EXAMPLES/example1b.cpp b/phonelibs/qpoases/EXAMPLES/example1b.cpp deleted file mode 100644 index 331f19d8da0cbc..00000000000000 --- a/phonelibs/qpoases/EXAMPLES/example1b.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 EXAMPLES/example1b.cpp - * \author Hans Joachim Ferreau - * \version 1.3 - * \date 2007-2008 - * - * Very simple example for testing qpOASES using the QProblemB class. - */ - - -#include - - -/** Example for qpOASES main function using the QProblemB class. */ -int main( ) -{ - /* Setup data of first QP. */ - real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; - real_t g[2] = { 1.5, 1.0 }; - real_t lb[2] = { 0.5, -2.0 }; - real_t ub[2] = { 5.0, 2.0 }; - - /* Setup data of second QP. */ - real_t g_new[2] = { 1.0, 1.5 }; - real_t lb_new[2] = { 0.0, -1.0 }; - real_t ub_new[2] = { 5.0, -0.5 }; - - - /* Setting up QProblemB object. */ - QProblemB example( 2 ); - - /* Solve first QP. */ - int nWSR = 10; - example.init( H,g,lb,ub, nWSR,0 ); - - /* Solve second QP. */ - nWSR = 10; - example.hotstart( g_new,lb_new,ub_new, nWSR,0 ); - - return 0; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/Bounds.hpp b/phonelibs/qpoases/INCLUDE/Bounds.hpp deleted file mode 100644 index 1fbd28ab38d342..00000000000000 --- a/phonelibs/qpoases/INCLUDE/Bounds.hpp +++ /dev/null @@ -1,189 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8293fa514c6a9c..00000000000000 --- a/phonelibs/qpoases/INCLUDE/Constants.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0b78747e29afeb..00000000000000 --- a/phonelibs/qpoases/INCLUDE/Constraints.hpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9b5c064a0bd7a4..00000000000000 --- a/phonelibs/qpoases/INCLUDE/CyclingManager.hpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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/EXTRAS/SolutionAnalysis.hpp b/phonelibs/qpoases/INCLUDE/EXTRAS/SolutionAnalysis.hpp deleted file mode 100644 index 056bb26f02d09d..00000000000000 --- a/phonelibs/qpoases/INCLUDE/EXTRAS/SolutionAnalysis.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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/EXTRAS/SolutionAnalysis.hpp - * \author Milan Vukov, Boris Houska, Hans Joachim Ferreau - * \version 1.3embedded - * \date 2012 - * - * Solution analysis class, based on a class in the standard version of the qpOASES - */ - - -// - -#ifndef QPOASES_SOLUTIONANALYSIS_HPP -#define QPOASES_SOLUTIONANALYSIS_HPP - -#include - -/** Enables the computation of variance as is in the standard version of qpOASES */ -#define QPOASES_USE_OLD_VERSION 0 - -#if QPOASES_USE_OLD_VERSION -#define KKT_DIM (2 * NVMAX + NCMAX) -#endif - -class SolutionAnalysis -{ -public: - - /** Default constructor. */ - SolutionAnalysis( ); - - /** Copy constructor (deep copy). */ - SolutionAnalysis( const SolutionAnalysis& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~SolutionAnalysis( ); - - /** Copy asingment operator (deep copy). */ - SolutionAnalysis& operator=( const SolutionAnalysis& rhs /**< Rhs object. */ - ); - - /** A routine for computation of inverse of the Hessian matrix. */ - returnValue getHessianInverse( - QProblem* qp, /** QP */ - real_t* hessianInverse /** Inverse of the Hessian matrix*/ - ); - - /** A routine for computation of inverse of the Hessian matrix. */ - returnValue getHessianInverse( QProblemB* qp, /** QP */ - real_t* hessianInverse /** Inverse of the Hessian matrix*/ - ); - -#if QPOASES_USE_OLD_VERSION - returnValue getVarianceCovariance( - QProblem* qp, - real_t* g_b_bA_VAR, - real_t* Primal_Dual_VAR - ); -#endif - -private: - - real_t delta_g_cov[ NVMAX ]; /** A covariance-vector of g */ - real_t delta_lb_cov[ NVMAX ]; /** A covariance-vector of lb */ - real_t delta_ub_cov[ NVMAX ]; /** A covariance-vector of ub */ - real_t delta_lbA_cov[ NCMAX_ALLOC ]; /** A covariance-vector of lbA */ - real_t delta_ubA_cov[ NCMAX_ALLOC ]; /** A covariance-vector of ubA */ - -#if QPOASES_USE_OLD_VERSION - real_t K[KKT_DIM * KKT_DIM]; /** A matrix to store an intermediate result */ -#endif - - int FR_idx[ NVMAX ]; /** Index array for free variables */ - int FX_idx[ NVMAX ]; /** Index array for fixed variables */ - int AC_idx[ NCMAX_ALLOC ]; /** Index array for active constraints */ - - real_t delta_xFR[ NVMAX ]; /** QP reaction, primal, w.r.t. free */ - real_t delta_xFX[ NVMAX ]; /** QP reaction, primal, w.r.t. fixed */ - real_t delta_yAC[ NVMAX ]; /** QP reaction, dual, w.r.t. active */ - real_t delta_yFX[ NVMAX ]; /** QP reaction, dual, w.r.t. fixed*/ -}; - -#endif // QPOASES_SOLUTIONANALYSIS_HPP diff --git a/phonelibs/qpoases/INCLUDE/Indexlist.hpp b/phonelibs/qpoases/INCLUDE/Indexlist.hpp deleted file mode 100644 index 18e3494e3f656c..00000000000000 --- a/phonelibs/qpoases/INCLUDE/Indexlist.hpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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 deleted file mode 100644 index f0b0c79a473b85..00000000000000 --- a/phonelibs/qpoases/INCLUDE/MessageHandling.hpp +++ /dev/null @@ -1,415 +0,0 @@ -/* - * 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 deleted file mode 100644 index 68fc1af9c53a79..00000000000000 --- a/phonelibs/qpoases/INCLUDE/QProblem.hpp +++ /dev/null @@ -1,666 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8b3acb82bddab4..00000000000000 --- a/phonelibs/qpoases/INCLUDE/QProblemB.hpp +++ /dev/null @@ -1,628 +0,0 @@ -/* - * 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 deleted file mode 100644 index a014843ceabb24..00000000000000 --- a/phonelibs/qpoases/INCLUDE/SubjectTo.hpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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 deleted file mode 100644 index 330f187c1e3d47..00000000000000 --- a/phonelibs/qpoases/INCLUDE/Types.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 deleted file mode 100644 index 16546a991b1945..00000000000000 --- a/phonelibs/qpoases/INCLUDE/Utils.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5faba9d48ce750..00000000000000 --- a/phonelibs/qpoases/LICENSE.txt +++ /dev/null @@ -1,504 +0,0 @@ - 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 deleted file mode 100644 index 37175d9192bdbe..00000000000000 --- a/phonelibs/qpoases/README.txt +++ /dev/null @@ -1,92 +0,0 @@ -## -## 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/SRC/Bounds.cpp b/phonelibs/qpoases/SRC/Bounds.cpp deleted file mode 100644 index 236ab2f62d284b..00000000000000 --- a/phonelibs/qpoases/SRC/Bounds.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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 deleted file mode 100644 index d0e7dbbf0904f7..00000000000000 --- a/phonelibs/qpoases/SRC/Bounds.ipp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 deleted file mode 100644 index 81fc6ce8679d23..00000000000000 --- a/phonelibs/qpoases/SRC/Constraints.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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 deleted file mode 100644 index 67add20434a1e4..00000000000000 --- a/phonelibs/qpoases/SRC/Constraints.ipp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7bbccdac228460..00000000000000 --- a/phonelibs/qpoases/SRC/CyclingManager.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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 - -/* - * S o l u t i o n A n a l y s i s - */ -SolutionAnalysis::SolutionAnalysis( ) -{ - -} - -/* - * S o l u t i o n A n a l y s i s - */ -SolutionAnalysis::SolutionAnalysis( const SolutionAnalysis& rhs ) -{ - -} - -/* - * ~ S o l u t i o n A n a l y s i s - */ -SolutionAnalysis::~SolutionAnalysis( ) -{ - -} - -/* - * o p e r a t o r = - */ -SolutionAnalysis& SolutionAnalysis::operator=( const SolutionAnalysis& rhs ) -{ - if ( this != &rhs ) - { - - } - - return *this; -} - -/* - * g e t H e s s i a n I n v e r s e - */ -returnValue SolutionAnalysis::getHessianInverse( QProblem* qp, real_t* hessianInverse ) -{ - returnValue returnvalue; /* the return value */ - BooleanType Delta_bC_isZero = BT_FALSE; /* (just use FALSE here) */ - BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ - - register int run1, run2, run3; - - register int nFR, nFX; - - /* Ask for the number of free and fixed variables, assumes that active set - * is constant for the covariance evaluation */ - nFR = qp->getNFR( ); - nFX = qp->getNFX( ); - - /* Ask for the corresponding index arrays: */ - if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* Initialization: */ - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_g_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_lb_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_ub_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NCMAX; run1++ ) - delta_lbA_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NCMAX; run1++ ) - delta_ubA_cov[ run1 ] = 0.0; - - /* The following loop solves the following: - * - * KKT * x = - * [delta_g_cov', delta_lbA_cov', delta_ubA_cov', delta_lb_cov', delta_ub_cov]' - * - * for the first NVMAX (negative) elementary vectors in order to get - * transposed inverse of the Hessian. Assuming that the Hessian is - * symmetric, the function will return transposed inverse, instead of the - * true inverse. - * - * Note, that we use negative elementary vectors due because internal - * implementation of the function hotstart_determineStepDirection requires - * so. - * - * */ - - for( run3 = 0; run3 < NVMAX; run3++ ) - { - /* Line wise loading of the corresponding (negative) elementary vector: */ - delta_g_cov[ run3 ] = -1.0; - - /* Evaluation of the step: */ - returnvalue = qp->hotstart_determineStepDirection( - FR_idx, FX_idx, AC_idx, - delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, - Delta_bC_isZero, Delta_bB_isZero, - delta_xFX, delta_xFR, delta_yAC, delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* Line wise storage of the QP reaction: */ - for( run1 = 0; run1 < nFR; run1++ ) - { - run2 = FR_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFR[ run1 ]; - } - - for( run1 = 0; run1 < nFX; run1++ ) - { - run2 = FX_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFX[ run1 ]; - } - - /* Prepare for the next iteration */ - delta_g_cov[ run3 ] = 0.0; - } - - // TODO: Perform the transpose of the inverse of the Hessian matrix - - return SUCCESSFUL_RETURN; -} - -/* - * g e t H e s s i a n I n v e r s e - */ -returnValue SolutionAnalysis::getHessianInverse( QProblemB* qp, real_t* hessianInverse ) -{ - returnValue returnvalue; /* the return value */ - BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ - - register int run1, run2, run3; - - register int nFR, nFX; - - /* Ask for the number of free and fixed variables, assumes that active set - * is constant for the covariance evaluation */ - nFR = qp->getNFR( ); - nFX = qp->getNFX( ); - - /* Ask for the corresponding index arrays: */ - if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* Initialization: */ - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_g_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_lb_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_ub_cov[ run1 ] = 0.0; - - /* The following loop solves the following: - * - * KKT * x = - * [delta_g_cov', delta_lb_cov', delta_ub_cov']' - * - * for the first NVMAX (negative) elementary vectors in order to get - * transposed inverse of the Hessian. Assuming that the Hessian is - * symmetric, the function will return transposed inverse, instead of the - * true inverse. - * - * Note, that we use negative elementary vectors due because internal - * implementation of the function hotstart_determineStepDirection requires - * so. - * - * */ - - for( run3 = 0; run3 < NVMAX; run3++ ) - { - /* Line wise loading of the corresponding (negative) elementary vector: */ - delta_g_cov[ run3 ] = -1.0; - - /* Evaluation of the step: */ - returnvalue = qp->hotstart_determineStepDirection( - FR_idx, FX_idx, - delta_g_cov, delta_lb_cov, delta_ub_cov, - Delta_bB_isZero, - delta_xFX, delta_xFR, delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* Line wise storage of the QP reaction: */ - for( run1 = 0; run1 < nFR; run1++ ) - { - run2 = FR_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFR[ run1 ]; - } - - for( run1 = 0; run1 < nFX; run1++ ) - { - run2 = FX_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFX[ run1 ]; - } - - /* Prepare for the next iteration */ - delta_g_cov[ run3 ] = 0.0; - } - - // TODO: Perform the transpose of the inverse of the Hessian matrix - - return SUCCESSFUL_RETURN; -} - -/* - * g e t V a r i a n c e C o v a r i a n c e - */ - -#if QPOASES_USE_OLD_VERSION - -returnValue SolutionAnalysis::getVarianceCovariance( QProblem* qp, real_t* g_b_bA_VAR, real_t* Primal_Dual_VAR ) -{ - int run1, run2, run3; /* simple run variables (for loops). */ - - returnValue returnvalue; /* the return value */ - BooleanType Delta_bC_isZero = BT_FALSE; /* (just use FALSE here) */ - BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ - - /* ASK FOR THE NUMBER OF FREE AND FIXED VARIABLES: - * (ASSUMES THAT ACTIVE SET IS CONSTANT FOR THE - * VARIANCE-COVARIANCE EVALUATION) - * ----------------------------------------------- */ - int nFR, nFX, nAC; - - nFR = qp->getNFR( ); - nFX = qp->getNFX( ); - nAC = qp->getNAC( ); - - if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* SOME INITIALIZATIONS: - * --------------------- */ - for( run1 = 0; run1 < KKT_DIM * KKT_DIM; run1++ ) - { - K [run1] = 0.0; - Primal_Dual_VAR[run1] = 0.0; - } - - /* ================================================================= */ - - /* FIRST MATRIX MULTIPLICATION (OBTAINS THE INTERMEDIATE RESULT - * K := [ ("ACTIVE" KKT-MATRIX OF THE QP)^(-1) * g_b_bA_VAR ]^T ) - * THE EVALUATION OF THE INVERSE OF THE KKT-MATRIX OF THE QP - * WITH RESPECT TO THE CURRENT ACTIVE SET - * USES THE EXISTING CHOLESKY AND TQ-DECOMPOSITIONS. FOR DETAILS - * cf. THE (protected) FUNCTION determineStepDirection. */ - - for( run3 = 0; run3 < KKT_DIM; run3++ ) - { - - for( run1 = 0; run1 < NVMAX; run1++ ) - { - delta_g_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+run1]; - delta_lb_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+NVMAX+run1]; /* LINE-WISE LOADING OF THE INPUT */ - delta_ub_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+NVMAX+run1]; /* VARIANCE-COVARIANCE */ - } - for( run1 = 0; run1 < NCMAX; run1++ ) - { - delta_lbA_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+2*NVMAX+run1]; - delta_ubA_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+2*NVMAX+run1]; - } - - /* EVALUATION OF THE STEP: - * ------------------------------------------------------------------------------ */ - - returnvalue = qp->hotstart_determineStepDirection( - FR_idx, FX_idx, AC_idx, - delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, - Delta_bC_isZero, Delta_bB_isZero, delta_xFX,delta_xFR, - delta_yAC,delta_yFX ); - - /* ------------------------------------------------------------------------------ */ - - /* STOP THE ALGORITHM IN THE CASE OF NO SUCCESFUL RETURN: - * ------------------------------------------------------ */ - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* LINE WISE */ - /* STORAGE OF THE QP-REACTION */ - /* (uses the index list) */ - - for( run1=0; run1hotstart_determineStepDirection( - FR_idx, FX_idx, AC_idx, - delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, - Delta_bC_isZero, Delta_bB_isZero, delta_xFX,delta_xFR, - delta_yAC,delta_yFX ); - - /* ------------------------------------------------------------------------------ */ - - /* STOP THE ALGORITHM IN THE CASE OF NO SUCCESFUL RETURN: - * ------------------------------------------------------ */ - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* ROW-WISE STORAGE */ - /* OF THE RESULT. */ - - for( run1=0; run1 - - -/***************************************************************************** - * 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 - */ diff --git a/phonelibs/qpoases/SRC/MessageHandling.cpp b/phonelibs/qpoases/SRC/MessageHandling.cpp deleted file mode 100644 index 6e68cd8552449e..00000000000000 --- a/phonelibs/qpoases/SRC/MessageHandling.cpp +++ /dev/null @@ -1,529 +0,0 @@ -/* - * 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 deleted file mode 100644 index ad9624b3d69a62..00000000000000 --- a/phonelibs/qpoases/SRC/MessageHandling.ipp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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 deleted file mode 100644 index 68a6a79e534f65..00000000000000 --- a/phonelibs/qpoases/SRC/QProblem.cpp +++ /dev/null @@ -1,3867 +0,0 @@ -/* - * 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 deleted file mode 100644 index cec58e291ddeab..00000000000000 --- a/phonelibs/qpoases/SRC/QProblem.ipp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * 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 deleted file mode 100644 index f84daabc025d3f..00000000000000 --- a/phonelibs/qpoases/SRC/QProblemB.cpp +++ /dev/null @@ -1,2151 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0c1c8b231147b5..00000000000000 --- a/phonelibs/qpoases/SRC/QProblemB.ipp +++ /dev/null @@ -1,425 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5dbf707c9d1f21..00000000000000 --- a/phonelibs/qpoases/SRC/SubjectTo.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7cd6dc69fe9bd7..00000000000000 --- a/phonelibs/qpoases/SRC/SubjectTo.ipp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7a3d0a5226203b..00000000000000 --- a/phonelibs/qpoases/SRC/Utils.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include - -#include "DlSystem/ZdlExportDefine.hpp" -#include "DlSystem/String.hpp" - -namespace zdl { -namespace DlContainer { - -/** @addtogroup c_plus_plus_apis C++ -@{ */ - -class IDlContainer; -class dlc_error; - -/** - * The structure of a record in a DL container. - */ -struct ZDL_EXPORT DlcRecord -{ - /// Name of the record. - std::string name; - /// Byte blob holding the data for the record. - std::vector data; - - DlcRecord(); - DlcRecord( DlcRecord&& other ) - : name(std::move(other.name)) - , data(std::move(other.data)) - {} - - DlcRecord(const DlcRecord&) = delete; -}; - -// The maximum length of any record name. -extern const uint32_t RECORD_NAME_MAX_SIZE; -// The maximum size of the record payload (bytes). -extern const uint32_t RECORD_DATA_MAX_SIZE; -// The maximum number of records in an archive at one time. -extern const uint32_t ARCHIVE_MAX_RECORDS; - -/** - * Represents a container for a neural network model which can - * be used to load the model into the SNPE runtime. - */ -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 - open(const std::string &filename) noexcept; - - /** - * 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 - 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 - * file. - * - * @return A pointer to the initialized container - */ - ZDL_EXPORT 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 - * file. - * - * @param[in] size Size of the byte buffer. - * - * @return A pointer to the initialized container - */ - ZDL_EXPORT static std::unique_ptr - open(const uint8_t* buffer, const size_t size) noexcept; - - -/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ - - /** - * Get the record catalog for a container. - * - * @param[out] catalog Buffer that will hold the record names on - * return. - */ - virtual void getCatalog(std::set &catalog) const = 0; - - /** - * Get the record catalog for a container. - * - * @param[out] catalog Buffer that will hold the record names on - * return. - */ - virtual void getCatalog(std::set &catalog) const = 0; - - /** - * 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 - * will own the data in the record and is - * responsible for freeing it if needed. - */ - virtual void getRecord(const std::string &name, DlcRecord &record) const = 0; - - /** - * 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 - * will own the data in the record and is - * responsible for freeing it if needed. - */ - virtual void getRecord(const zdl::DlSystem::String &name, DlcRecord &record) const = 0; - - virtual ~IDlContainer() {} -}; - -} // ns DlContainer -} // ns zdl - - -#endif diff --git a/phonelibs/snpe/include/DlSystem/DlEnums.hpp b/phonelibs/snpe/include/DlSystem/DlEnums.hpp deleted file mode 100644 index fde252ca7f6742..00000000000000 --- a/phonelibs/snpe/include/DlSystem/DlEnums.hpp +++ /dev/null @@ -1,146 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2014-2018 Qualcomm Technologies, Inc. -// All Rights Reserved. -// Confidential and Proprietary - Qualcomm Technologies, Inc. -// -//============================================================================== - -#ifndef _DL_ENUMS_HPP_ -#define _DL_ENUMS_HPP_ - -#include "DlSystem/ZdlExportDefine.hpp" - - -namespace zdl { -namespace DlSystem -{ -/** @addtogroup c_plus_plus_apis C++ -@{ */ - -/** - * Enumeration of supported target runtimes. - */ -enum class Runtime_t -{ - /// Run the processing on Snapdragon CPU. - /// Data: float 32bit - /// Math: float 32bit - CPU_FLOAT32 = 0, - - /// Run the processing on the Adreno GPU. - /// Data: float 16bit - /// Math: float 32bit - GPU_FLOAT32_16_HYBRID = 1, - - /// Run the processing on the Hexagon DSP. - /// Data: 8bit fixed point Tensorflow style format - /// Math: 8bit fixed point Tensorflow style format - DSP_FIXED8_TF = 2, - - /// Run the processing on the Adreno GPU. - /// Data: float 16bit - /// Math: float 16bit - GPU_FLOAT16 = 3, - - /// Default legacy enum to retain backward compatibility. - /// CPU = CPU_FLOAT32 - CPU = CPU_FLOAT32, - - /// Default legacy enum to retain backward compatibility. - /// GPU = GPU_FLOAT32_16_HYBRID - GPU = GPU_FLOAT32_16_HYBRID, - - /// Default legacy enum to retain backward compatibility. - /// DSP = DSP_FIXED8_TF - DSP = DSP_FIXED8_TF -}; - -/** - * Enumeration of various performance profiles that can be requested. - */ -enum class PerformanceProfile_t -{ - /// Run in a standard mode. - /// This mode will be deprecated in the future and replaced with BALANCED. - DEFAULT = 0, - /// Run in a balanced mode. - BALANCED = 0, - - /// Run in high performance mode - HIGH_PERFORMANCE, - - /// Run in a power sensitive mode, at the expense of performance. - POWER_SAVER, - - /// Use system settings. SNPE makes no calls to any performance related APIs. - SYSTEM_SETTINGS, - - /// Run in sustained high performance mode - SUSTAINED_HIGH_PERFORMANCE - -}; - -/** - * Enumeration of various execution priority hints. - */ -enum class ExecutionPriorityHint_t -{ - /// Normal priority - NORMAL = 0, - - /// Higher than normal priority - HIGH, - - /// Lower priority - LOW - -}; - -/** @} */ /* end_addtogroup c_plus_plus_apis C++*/ - -/** - * Enumeration that lists the supported image encoding formats. - */ -enum class ImageEncoding_t -{ - /// For unknown image type. Also used as a default value for ImageEncoding_t. - UNKNOWN = 0, - - /// 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, - - /// 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, - - /// 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, - - /// The GRAYSCALE format is for 8-bit grayscale. - GRAYSCALE, - - /// 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, - - /// 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 -}; - -}} // namespaces end - - -#endif diff --git a/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp b/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp deleted file mode 100644 index 70f6b33cbba1a9..00000000000000 --- a/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp +++ /dev/null @@ -1,289 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2017-2018 Qualcomm Technologies, Inc. -// All Rights Reserved. -// Confidential and Proprietary - Qualcomm Technologies, Inc. -// -//============================================================================== - -#ifndef _IUSER_BUFFER_HPP -#define _IUSER_BUFFER_HPP - -#include "TensorShape.hpp" -#include "ZdlExportDefine.hpp" - -namespace zdl { -namespace DlSystem { - -/** @addtogroup c_plus_plus_apis C++ -@{ */ - - -/** - * @brief . - * - * A base class buffer encoding type - */ -class ZDL_EXPORT UserBufferEncoding { -public: - - /** - * @brief . - * - * An enum class of all supported element types in a IUserBuffer - */ - enum class ElementType_t - { - /// Unknown element type. - UNKNOWN = 0, - - /// Each element is presented by float. - FLOAT = 1, - - /// Each element is presented by an unsigned int. - UNSIGNED8BIT = 2, - - /// Each element is presented by an 8-bit quantized value. - TF8 = 10 - }; - - /** - * @brief Retrieves the size of the element, in bytes. - * - * @return Size of the element, in bytes. - */ - virtual size_t getElementSize() const noexcept = 0; - - /** - * @brief Retrieves the element type - * - * @return Element type - */ - ElementType_t getElementType() const noexcept {return m_ElementType;}; - - virtual ~UserBufferEncoding() {} - -protected: - UserBufferEncoding(ElementType_t elementType) : m_ElementType(elementType) {}; -private: - const ElementType_t m_ElementType; -}; - -/** - * @brief . - * - * A base class buffer source type - * - * @note User buffer from CPU support all kinds of runtimes; - * User buffer from GLBUFFER support only GPU runtime. - */ -class ZDL_EXPORT UserBufferSource { -public: - enum class SourceType_t - { - /// Unknown buffer source type. - UNKNOWN = 0, - - /// The network inputs are from CPU buffer. - CPU = 1, - - /// The network inputs are from OpenGL buffer. - GLBUFFER = 2 - }; - - /** - * @brief Retrieves the source type - * - * @return Source type - */ - SourceType_t getSourceType() const noexcept {return m_SourceType;}; - -protected: - UserBufferSource(SourceType_t sourceType): m_SourceType(sourceType) {}; -private: - const SourceType_t m_SourceType; -}; - -/** - * @brief . - * - * An source type where input data is delivered from OpenGL buffer - */ -class ZDL_EXPORT UserBufferSourceGLBuffer : public UserBufferSource{ -public: - UserBufferSourceGLBuffer() : UserBufferSource(SourceType_t::GLBUFFER) {}; -}; - -/** - * @brief . - * - * An encoding type where each element is represented by an unsigned int - */ -class ZDL_EXPORT UserBufferEncodingUnsigned8Bit : public UserBufferEncoding { -public: - UserBufferEncodingUnsigned8Bit() : UserBufferEncoding(ElementType_t::UNSIGNED8BIT) {}; - size_t getElementSize() const noexcept override; - -protected: - UserBufferEncodingUnsigned8Bit(ElementType_t elementType) : UserBufferEncoding(elementType) {}; - -}; - -/** - * @brief . - * - * An encoding type where each element is represented by a float - */ -class ZDL_EXPORT UserBufferEncodingFloat : public UserBufferEncoding { -public: - UserBufferEncodingFloat() : UserBufferEncoding(ElementType_t::FLOAT) {}; - size_t getElementSize() const noexcept override; - -}; - -/** - * @brief . - * - * 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; - UserBufferEncodingTf8(unsigned char stepFor0, float stepSize) : - UserBufferEncodingUnsigned8Bit(ElementType_t::TF8), - m_StepExactly0(stepFor0), - m_QuantizedStepSize(stepSize) {}; - - /** - * @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; - } - -private: - unsigned char m_StepExactly0; - - float m_QuantizedStepSize; -}; - -/** - * @brief UserBuffer contains a pointer and info on how to walk it and interpret its content. - */ -class ZDL_EXPORT IUserBuffer { -public: - virtual ~IUserBuffer() = default; - - /** - * @brief Retrieves the total number of bytes between elements in each dimension if - * the buffer were to be interpreted as a multi-dimensional array. - * - * @return Number of bytes between elements in each dimension. - * e.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would - * return strides of [24, 8, 4]. - */ - virtual const TensorShape& getStrides() const = 0; - - /** - * @brief Retrieves the size of the buffer, in bytes. - * - * @return Size of the underlying buffer, in bytes. - */ - virtual size_t getSize() const = 0; - - /** - * @brief Changes the underlying memory that backs the UserBuffer. - * - * This can be used to avoid creating multiple UserBuffer objects - * when the only thing that differs is the memory location. - * - * @param[in] buffer Pointer to the memory location - * - * @return Whether the set succeeds. - */ - virtual bool setBufferAddress(void *buffer) noexcept = 0; - - /** - * @brief Gets a const reference to the data encoding object of - * the underlying buffer - * - * This is necessary when the UserBuffer is filled by SNPE with - * data types such as TF8, where the caller needs to know the quantization - * parameters in order to interpret the data properly - * - * @return A read-only encoding object - */ - virtual const UserBufferEncoding& getEncoding() const noexcept = 0; - - /** - * @brief Gets a reference to the data encoding object of - * the underlying buffer - * - * This is necessary when the UserBuffer is re-used, and the encoding - * parameters can change. For example, each input can be quantized with - * different step sizes. - * - * @return Data encoding meta-data - */ - virtual UserBufferEncoding& getEncoding() noexcept = 0; - -}; - -/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ - -} -} - -#endif diff --git a/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp b/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp deleted file mode 100644 index dd0704dd8c996d..00000000000000 --- a/phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp +++ /dev/null @@ -1,16 +0,0 @@ -//============================================================================= -// -// Copyright (c) 2015 Qualcomm Technologies, Inc. -// All Rights Reserved. -// Confidential and Proprietary - Qualcomm Technologies, Inc. -// -//============================================================================= - -#ifndef _ZDL_EXPORT_DEFINE_HPP_ -#define _ZDL_EXPORT_DEFINE_HPP_ - -#ifndef ZDL_EXPORT -#define ZDL_EXPORT __attribute__((visibility("default"))) -#endif - -#endif diff --git a/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp b/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp deleted file mode 100644 index 13e80e8c1a703d..00000000000000 --- a/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp +++ /dev/null @@ -1,210 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2017 Qualcomm Technologies, Inc. -// All Rights Reserved. -// Confidential and Proprietary - Qualcomm Technologies, Inc. -// -//============================================================================== - -#ifndef _SNPE_BUILDER_HPP_ -#define _SNPE_BUILDER_HPP_ - -#include "SNPE/SNPE.hpp" -#include "DlSystem/DlEnums.hpp" -#include "DlSystem/UDLFunc.hpp" -#include "DlSystem/DlOptional.hpp" -#include "DlSystem/TensorShapeMap.hpp" -#include "DlSystem/PlatformConfig.hpp" - -namespace zdl { - namespace DlContainer - { - class IDlContainer; - } -} - -struct SNPEBuilderImpl; - - -namespace zdl { namespace SNPE { -/** @addtogroup c_plus_plus_apis C++ -@{ */ - -/** - * The builder class for creating SNPE objects. - * Not meant to be extended. - */ -class ZDL_EXPORT SNPEBuilder final -{ -private: - std::unique_ptr<::SNPEBuilderImpl> m_Impl; -public: - - /** - * @brief Constructor of NeuralNetwork Builder with a supplied model. - * - * @param[in] container A container holding the model. - * - * @return A new instance of a SNPEBuilder object - * that can be used to configure and build - * an instance of SNPE. - * - */ - explicit SNPEBuilder( - zdl::DlContainer::IDlContainer* container); - ~SNPEBuilder(); - - /** - * @brief Sets the runtime processor. - * - * @param[in] targetRuntimeProcessor The target runtime. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setRuntimeProcessor( - zdl::DlSystem::Runtime_t targetRuntimeProcessor); - - /** - * @brief Requests a performance profile. - * - * @param[in] targetRuntimeProfile The target performance profile. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setPerformanceProfile( - zdl::DlSystem::PerformanceProfile_t performanceProfile); - - /** - * @brief Sets a preference for execution priority. - * - * This allows the caller to give coarse hint to SNPE runtime - * about the priority of the network. SNPE runtime is free to use - * this information to co-ordinate between different workloads - * that may or may not extend beyond SNPE. - * - * @param[in] ExecutionPriorityHint_t The target performance profile. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setExecutionPriorityHint( - zdl::DlSystem::ExecutionPriorityHint_t priority); - - /** - * @brief Sets the layers that will generate output. - * - * @param[in] outputLayerNames List of layer names to - * output. An empty list will - * result in only the final - * layer of the model being - * the output layer. The list - * will be copied. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setOutputLayers( - const zdl::DlSystem::StringList& outputLayerNames); - - /** - * @brief Passes in a User-defined layer. - * - * @param udlBundle Bundle of udl factory function and a cookie - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setUdlBundle( - zdl::DlSystem::UDLBundle udlBundle); - - /** - * @brief Sets whether this neural network will perform inference with - * input from user-supplied buffers, and write output to user-supplied - * buffers. Default behaviour is to use tensors created by - * ITensorFactory. - * - * @param[in] bufferMode Whether to use user-supplied buffer or not. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setUseUserSuppliedBuffers( - bool bufferMode); - - /** - * @brief Sets the debug mode of the runtime. - * - * @param[in] debugMode This enables debug mode for the runtime. It - * does two things. For an empty - * outputLayerNames list, all layers will be - * output. It might also disable some internal - * runtime optimizations (e.g., some networks - * might be optimized by combining layers, - * etc.). - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setDebugMode( - bool debugMode); - - /** - * @brief Sets the mode of CPU fallback functionality. - * - * @param[in] mode This flag enables/disables the functionality - * of CPU fallback. When the CPU fallback - * functionality is enabled, layers in model that - * violates runtime constraints will run on CPU - * while the rest of non-violating layers will - * run on the chosen runtime processor. In - * disabled mode, models with layers violating - * runtime constraints will NOT run on the chosen - * runtime processor and will result in runtime - * exception. By default, the functionality is - * enabled. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setCPUFallbackMode( - bool mode); - - - /** - * @brief Sets network's input dimensions to enable resizing of - * the spatial dimensions of each layer for fully convolutional networks, - * and the batch dimension for all networks. - * - * @param[in] tensorShapeMap The map of input names and their new dimensions. - * The new dimensions overwrite the input dimensions - * embedded in the model and then resize each layer - * of the model. If the model contains - * layers whose dimensions cannot be resized e.g FullyConnected, - * exception will be thrown when SNPE instance is actually built. - * In general the batch dimension is always resizable. - * After resizing of layers' dimensions in model based - * on new input dimensions, the new model is revalidated - * against all runtime constraints, whose failures may - * result in cpu fallback situation. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setInputDimensions(const zdl::DlSystem::TensorShapeMap& inputDimensionsMap); - - /** - * @brief Returns an instance of SNPE based on the current parameters. - * - * @return A new instance of a SNPE object that can be used - * to execute models or null if any errors occur. - */ - std::unique_ptr build() noexcept; - - /** - * @brief Sets the platform configuration. - * - * @param[in] platformConfig The platform configuration. - * - * @return The current instance of SNPEBuilder. - */ - SNPEBuilder& setPlatformConfig(const zdl::DlSystem::PlatformConfig& platformConfig); - -}; -/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ - -}} - -#endif diff --git a/phonelibs/snpe/include/SNPE/SNPEFactory.hpp b/phonelibs/snpe/include/SNPE/SNPEFactory.hpp deleted file mode 100644 index bb9921afe10591..00000000000000 --- a/phonelibs/snpe/include/SNPE/SNPEFactory.hpp +++ /dev/null @@ -1,104 +0,0 @@ -//============================================================================== -// -// Copyright (c) 2015-2016 Qualcomm Technologies, Inc. -// All Rights Reserved. -// Confidential and Proprietary - Qualcomm Technologies, Inc. -// -//============================================================================== - -#ifndef _SNPE_FACTORY_HPP_ -#define _SNPE_FACTORY_HPP_ - -#include "SNPE/SNPE.hpp" -#include "DlSystem/DlEnums.hpp" -#include "DlSystem/UDLFunc.hpp" -#include "DlSystem/ZdlExportDefine.hpp" -#include "DlSystem/DlOptional.hpp" - -namespace zdl { - namespace DlSystem - { - class ITensorFactory; - class IUserBufferFactory; - } - namespace DlContainer - { - class IDlContainer; - } -} - - - -namespace zdl { namespace SNPE { -/** @addtogroup c_plus_plus_apis C++ -@{ */ - -/** - * The factory class for creating SNPE objects. - * - */ -class ZDL_EXPORT SNPEFactory -{ -public: - - /** - * 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, - * otherwise. - */ - static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime); - - /** - * Gets a reference to the tensor factory. - * - * @return A reference to the tensor factory. - */ - static zdl::DlSystem::ITensorFactory& getTensorFactory(); - - /** - * Gets a reference to the UserBuffer factory. - * - * @return A reference to the UserBuffer factory. - */ - static zdl::DlSystem::IUserBufferFactory& getUserBufferFactory(); - - /** - * Gets the version of the SNPE library. - * - * @return Version of the SNPE library. - * - */ - static zdl::DlSystem::Version_t getLibraryVersion(); - - /** - * Set the SNPE storage location for all SNPE instances in this - * process. Note that this may only be called once, and if so - * must be called before creating any SNPE instances. - * - * @param[in] storagePath Absolute path to a directory which SNPE may - * use for caching and other storage purposes. - * - * @return True if the supplied path was succesfully set as - * the SNPE storage location, false otherwise. - */ - static bool setSNPEStorageLocation(const char* storagePath); - - /** - * Indicates whether the OpenGL and OpenCL interoperability is supported - * on GPU platform. - * - * @return True if the OpenGL and OpenCl interop is supported; false, - * otherwise. - */ - static bool isGLCLInteropSupported(); -}; - -/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ -}} - - -#endif 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/acados_template/__init__.py b/pyextra/acados_template/__init__.py new file mode 100644 index 00000000000000..f33b75bb7ba35b --- /dev/null +++ b/pyextra/acados_template/__init__.py @@ -0,0 +1,43 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +from .acados_model import * +from .generate_c_code_explicit_ode import * +from .generate_c_code_implicit_ode import * +from .generate_c_code_constraint import * +from .generate_c_code_nls_cost import * +from .acados_ocp import * +from .acados_sim import * +from .acados_ocp_solver import * +from .acados_sim_solver import * +from .utils import * diff --git a/pyextra/acados_template/acados_layout.json b/pyextra/acados_template/acados_layout.json new file mode 100644 index 00000000000000..16fd452337e3eb --- /dev/null +++ b/pyextra/acados_template/acados_layout.json @@ -0,0 +1,778 @@ +{ + "code_export_directory": [ + "str" + ], + "acados_include_path": [ + "str" + ], + "model": { + "name" : [ + "str" + ], + "dyn_ext_fun_type" : [ + "str" + ], + "dyn_source_discrete" : [ + "str" + ], + "dyn_disc_fun_jac_hess" : [ + "str" + ], + "dyn_disc_fun_jac" : [ + "str" + ], + "dyn_disc_fun" : [ + "str" + ] + }, + "parameter_values": [ + "ndarray", + [ + "np" + ] + ], + "acados_lib_path": [ + "str" + ], + "problem_class": [ + "str" + ], + "constraints": { + "constr_type": [ + "str" + ], + "constr_type_e": [ + "str" + ], + "lbx": [ + "ndarray", + [ + "nbx" + ] + ], + "lbu": [ + "ndarray", + [ + "nbu" + ] + ], + "ubx": [ + "ndarray", + [ + "nbx" + ] + ], + "ubu": [ + "ndarray", + [ + "nbu" + ] + ], + "idxbx": [ + "ndarray", + [ + "nbx" + ] + ], + "idxbu": [ + "ndarray", + [ + "nbu" + ] + ], + "lbx_e": [ + "ndarray", + [ + "nbx_e" + ] + ], + "ubx_e": [ + "ndarray", + [ + "nbx_e" + ] + ], + "idxbx_e": [ + "ndarray", + [ + "nbx_e" + ] + ], + "lbx_0": [ + "ndarray", + [ + "nbx_0" + ] + ], + "ubx_0": [ + "ndarray", + [ + "nbx_0" + ] + ], + "idxbx_0": [ + "ndarray", + [ + "nbx_0" + ] + ], + "idxbxe_0": [ + "ndarray", + [ + "nbxe_0" + ] + ], + "lg": [ + "ndarray", + [ + "ng" + ] + ], + "ug": [ + "ndarray", + [ + "ng" + ] + ], + "D": [ + "ndarray", + [ + "ng", + "nu" + ] + ], + "C": [ + "ndarray", + [ + "ng", + "nx" + ] + ], + "C_e": [ + "ndarray", + [ + "ng_e", + "nx" + ] + ], + "lg_e": [ + "ndarray", + [ + "ng_e" + ] + ], + "ug_e": [ + "ndarray", + [ + "ng_e" + ] + ], + "lh": [ + "ndarray", + [ + "nh" + ] + ], + "uh": [ + "ndarray", + [ + "nh" + ] + ], + "lh_e": [ + "ndarray", + [ + "nh_e" + ] + ], + "uh_e": [ + "ndarray", + [ + "nh_e" + ] + ], + "lphi": [ + "ndarray", + [ + "nphi" + ] + ], + "uphi": [ + "ndarray", + [ + "nphi" + ] + ], + "lphi_e": [ + "ndarray", + [ + "nphi_e" + ] + ], + "uphi_e": [ + "ndarray", + [ + "nphi_e" + ] + ], + "lsbx": [ + "ndarray", + [ + "nsbx" + ] + ], + "usbx": [ + "ndarray", + [ + "nsbx" + ] + ], + "lsbu": [ + "ndarray", + [ + "nsbu" + ] + ], + "usbu": [ + "ndarray", + [ + "nsbu" + ] + ], + "idxsbx": [ + "ndarray", + [ + "nsbx" + ] + ], + "idxsbu": [ + "ndarray", + [ + "nsbu" + ] + ], + "lsbx_e": [ + "ndarray", + [ + "nsbx_e" + ] + ], + "usbx_e": [ + "ndarray", + [ + "nsbx_e" + ] + ], + "idxsbx_e": [ + "ndarray", + [ + "nsbx_e" + ] + ], + "lsg": [ + "ndarray", + [ + "nsg" + ] + ], + "usg": [ + "ndarray", + [ + "nsg" + ] + ], + "idxsg": [ + "ndarray", + [ + "nsg" + ] + ], + "lsg_e": [ + "ndarray", + [ + "nsg_e" + ] + ], + "usg_e": [ + "ndarray", + [ + "nsg_e" + ] + ], + "idxsg_e": [ + "ndarray", + [ + "nsg_e" + ] + ], + "lsh": [ + "ndarray", + [ + "nsh" + ] + ], + "ush": [ + "ndarray", + [ + "nsh" + ] + ], + "idxsh": [ + "ndarray", + [ + "nsh" + ] + ], + "lsh_e": [ + "ndarray", + [ + "nsh_e" + ] + ], + "ush_e": [ + "ndarray", + [ + "nsh_e" + ] + ], + "idxsh_e": [ + "ndarray", + [ + "nsh_e" + ] + ], + "lsphi": [ + "ndarray", + [ + "nsphi" + ] + ], + "usphi": [ + "ndarray", + [ + "nsphi" + ] + ], + "idxsphi": [ + "ndarray", + [ + "nsphi" + ] + ], + "lsphi_e": [ + "ndarray", + [ + "nsphi_e" + ] + ], + "usphi_e": [ + "ndarray", + [ + "nsphi_e" + ] + ], + "idxsphi_e": [ + "ndarray", + [ + "nsphi_e" + ] + ] + }, + "cost": { + "cost_type_0": [ + "str" + ], + "cost_type": [ + "str" + ], + "cost_type_e": [ + "str" + ], + "cost_ext_fun_type_0": [ + "str" + ], + "cost_ext_fun_type": [ + "str" + ], + "cost_ext_fun_type_e": [ + "str" + ], + "Vu_0": [ + "ndarray", + [ + "ny_0", + "nu" + ] + ], + "Vu": [ + "ndarray", + [ + "ny", + "nu" + ] + ], + "Vx_0": [ + "ndarray", + [ + "ny_0", + "nx" + ] + ], + "Vx": [ + "ndarray", + [ + "ny", + "nx" + ] + ], + "Vx_e": [ + "ndarray", + [ + "ny_e", + "nx" + ] + ], + "Vz_0": [ + "ndarray", + [ + "ny_0", + "nz" + ] + ], + "Vz": [ + "ndarray", + [ + "ny", + "nz" + ] + ], + "W_0": [ + "ndarray", + [ + "ny_0", + "ny_0" + ] + ], + "W": [ + "ndarray", + [ + "ny", + "ny" + ] + ], + "Zl": [ + "ndarray", + [ + "ns" + ] + ], + "Zu": [ + "ndarray", + [ + "ns" + ] + ], + "zl": [ + "ndarray", + [ + "ns" + ] + ], + "zu": [ + "ndarray", + [ + "ns" + ] + ], + "W_e": [ + "ndarray", + [ + "ny_e", + "ny_e" + ] + ], + "yref_0": [ + "ndarray", + [ + "ny_0" + ] + ], + "yref": [ + "ndarray", + [ + "ny" + ] + ], + "yref_e": [ + "ndarray", + [ + "ny_e" + ] + ], + "Zl_e": [ + "ndarray", + [ + "ns_e" + ] + ], + "Zu_e": [ + "ndarray", + [ + "ns_e" + ] + ], + "zl_e": [ + "ndarray", + [ + "ns_e" + ] + ], + "zu_e": [ + "ndarray", + [ + "ns_e" + ] + ] + }, + "dims": { + "N": [ + "int" + ], + "nbu": [ + "int" + ], + "nbx": [ + "int" + ], + "nsbu": [ + "int" + ], + "nsbx": [ + "int" + ], + "nsbx_e": [ + "int" + ], + "nbx_0": [ + "int" + ], + "nbx_e": [ + "int" + ], + "nbxe_0": [ + "int" + ], + "nsg": [ + "int" + ], + "nsg_e": [ + "int" + ], + "nsh": [ + "int" + ], + "nsh_e": [ + "int" + ], + "nsphi": [ + "int" + ], + "nsphi_e": [ + "int" + ], + "ns": [ + "int" + ], + "ns_e": [ + "int" + ], + "ng": [ + "int" + ], + "ng_e": [ + "int" + ], + "np": [ + "int" + ], + "nr": [ + "int" + ], + "nr_e": [ + "int" + ], + "nh": [ + "int" + ], + "nh_e": [ + "int" + ], + "nphi": [ + "int" + ], + "nphi_e": [ + "int" + ], + "nu": [ + "int" + ], + "nx": [ + "int" + ], + "ny": [ + "int" + ], + "ny_0": [ + "int" + ], + "ny_e": [ + "int" + ], + "nz": [ + "int" + ], + "gnsf_nx1": [ + "int" + ], + "gnsf_nz1": [ + "int" + ], + "gnsf_nuhat": [ + "int" + ], + "gnsf_ny": [ + "int" + ], + "gnsf_nout": [ + "int" + ] + }, + "solver_options": { + "time_steps": [ + "ndarray", + [ + "N" + ] + ], + "hessian_approx": [ + "str" + ], + "regularize_method": [ + "str" + ], + "integrator_type": [ + "str" + ], + "nlp_solver_type": [ + "str" + ], + "collocation_type": [ + "str" + ], + "globalization": [ + "str" + ], + "nlp_solver_step_length": [ + "float" + ], + "levenberg_marquardt": [ + "float" + ], + "qp_solver": [ + "str" + ], + "tf": [ + "float" + ], + "Tsim": [ + "float" + ], + "alpha_min": [ + "float" + ], + "alpha_reduction": [ + "float" + ], + "sim_method_num_stages": [ + "ndarray", + [ + "N" + ] + ], + "sim_method_num_steps": [ + "ndarray", + [ + "N" + ] + ], + "sim_method_newton_iter": [ + "int" + ], + "sim_method_jac_reuse": [ + "ndarray", + [ + "N" + ] + ], + "qp_solver_cond_N": [ + "int" + ], + "qp_solver_warm_start": [ + "int" + ], + "qp_solver_tol_stat": [ + "float" + ], + "qp_solver_tol_eq": [ + "float" + ], + "qp_solver_tol_ineq": [ + "float" + ], + "qp_solver_tol_comp": [ + "float" + ], + "qp_solver_iter_max": [ + "int" + ], + "nlp_solver_tol_stat": [ + "float" + ], + "nlp_solver_tol_eq": [ + "float" + ], + "nlp_solver_tol_ineq": [ + "float" + ], + "nlp_solver_tol_comp": [ + "float" + ], + "nlp_solver_max_iter": [ + "int" + ], + "print_level": [ + "int" + ], + "initialize_t_slacks": [ + "int" + ], + "exact_hess_cost": [ + "int" + ], + "exact_hess_constr": [ + "int" + ], + "exact_hess_dyn": [ + "int" + ], + "ext_cost_num_hess": [ + "int" + ], + "model_external_shared_lib_dir": [ + "str" + ], + "model_external_shared_lib_name": [ + "str" + ] + } +} diff --git a/pyextra/acados_template/acados_model.py b/pyextra/acados_template/acados_model.py new file mode 100644 index 00000000000000..4871a2c0d57985 --- /dev/null +++ b/pyextra/acados_template/acados_model.py @@ -0,0 +1,160 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + + +class AcadosModel(): + """ + Class containing all the information to code generate the external CasADi functions + that are needed when creating an acados ocp solver or acados integrator. + Thus, this class contains: + + a) the :py:attr:`name` of the model, + b) all CasADi variables/expressions needed in the CasADi function generation process. + """ + def __init__(self): + ## common for OCP and Integrator + self.name = None + """ + The model name is used for code generation. Type: string. Default: :code:`None` + """ + self.x = None #: CasADi variable describing the state of the system; Default: :code:`None` + self.xdot = None #: CasADi variable describing the derivative of the state wrt time; Default: :code:`None` + self.u = None #: CasADi variable describing the input of the system; Default: :code:`None` + self.z = [] #: CasADi variable describing the algebraic variables of the DAE; Default: :code:`empty` + self.p = [] #: CasADi variable describing parameters of the DAE; Default: :code:`empty` + # dynamics + self.f_impl_expr = None + """ + CasADi expression for the implicit dynamics :math:`f_\\text{impl}(\dot{x}, x, u, z, p) = 0`. + Used if :py:attr:`acados_template.acados_ocp.AcadosOcpOptions.integrator_type` == 'IRK'. + Default: :code:`None` + """ + self.f_expl_expr = None + """ + CasADi expression for the explicit dynamics :math:`\dot{x} = f_\\text{expl}(x, u, p)`. + Used if :py:attr:`acados_template.acados_ocp.AcadosOcpOptions.integrator_type` == 'ERK'. + Default: :code:`None` + """ + self.disc_dyn_expr = None + """ + CasADi expression for the discrete dynamics :math:`x_{+} = f_\\text{disc}(x, u, p)`. + Used if :py:attr:`acados_template.acados_ocp.AcadosOcpOptions.integrator_type` == 'DISCRETE'. + Default: :code:`None` + """ + + self.dyn_ext_fun_type = 'casadi' #: type of external functions for dynamics module; 'casadi' or 'generic'; Default: 'casadi' + self.dyn_source_discrete = None #: name of source file for discrete dyanamics; Default: :code:`None` + self.dyn_disc_fun_jac_hess = None #: name of function discrete dyanamics + jacobian and hessian; Default: :code:`None` + self.dyn_disc_fun_jac = None #: name of function discrete dyanamics + jacobian; Default: :code:`None` + self.dyn_disc_fun = None #: name of function discrete dyanamics; Default: :code:`None` + + ## for OCP + # constraints + self.con_h_expr = None #: CasADi expression for the constraint :math:`h`; Default: :code:`None` + self.con_phi_expr = None #: CasADi expression for the constraint phi; Default: :code:`None` + self.con_r_expr = None #: CasADi expression for the constraint phi(r); Default: :code:`None` + self.con_r_in_phi = None + # terminal + self.con_h_expr_e = None #: CasADi expression for the terminal constraint :math:`h^e`; Default: :code:`None` + self.con_r_expr_e = None #: CasADi expression for the terminal constraint; Default: :code:`None` + self.con_phi_expr_e = None #: CasADi expression for the terminal constraint; Default: :code:`None` + self.con_r_in_phi_e = None + # cost + self.cost_y_expr = None #: CasADi expression for nonlinear least squares; Default: :code:`None` + self.cost_y_expr_e = None #: CasADi expression for nonlinear least squares, terminal; Default: :code:`None` + self.cost_y_expr_0 = None #: CasADi expression for nonlinear least squares, initial; Default: :code:`None` + self.cost_expr_ext_cost = None #: CasADi expression for external cost; Default: :code:`None` + self.cost_expr_ext_cost_e = None #: CasADi expression for external cost, terminal; Default: :code:`None` + self.cost_expr_ext_cost_0 = None #: CasADi expression for external cost, initial; Default: :code:`None` + self.cost_expr_ext_cost_custom_hess = None #: CasADi expression for custom hessian (only for external cost); Default: :code:`None` + self.cost_expr_ext_cost_custom_hess_e = None #: CasADi expression for custom hessian (only for external cost), terminal; Default: :code:`None` + self.cost_expr_ext_cost_custom_hess_0 = None #: CasADi expression for custom hessian (only for external cost), initial; Default: :code:`None` + + +def acados_model_strip_casadi_symbolics(model): + out = model + if 'f_impl_expr' in out.keys(): + del out['f_impl_expr'] + if 'f_expl_expr' in out.keys(): + del out['f_expl_expr'] + if 'disc_dyn_expr' in out.keys(): + del out['disc_dyn_expr'] + if 'x' in out.keys(): + del out['x'] + if 'xdot' in out.keys(): + del out['xdot'] + if 'u' in out.keys(): + del out['u'] + if 'z' in out.keys(): + del out['z'] + if 'p' in out.keys(): + del out['p'] + # constraints + if 'con_phi_expr' in out.keys(): + del out['con_phi_expr'] + if 'con_h_expr' in out.keys(): + del out['con_h_expr'] + if 'con_r_expr' in out.keys(): + del out['con_r_expr'] + if 'con_r_in_phi' in out.keys(): + del out['con_r_in_phi'] + # terminal + if 'con_phi_expr_e' in out.keys(): + del out['con_phi_expr_e'] + if 'con_h_expr_e' in out.keys(): + del out['con_h_expr_e'] + if 'con_r_expr_e' in out.keys(): + del out['con_r_expr_e'] + if 'con_r_in_phi_e' in out.keys(): + del out['con_r_in_phi_e'] + # cost + if 'cost_y_expr' in out.keys(): + del out['cost_y_expr'] + if 'cost_y_expr_e' in out.keys(): + del out['cost_y_expr_e'] + if 'cost_y_expr_0' in out.keys(): + del out['cost_y_expr_0'] + if 'cost_expr_ext_cost' in out.keys(): + del out['cost_expr_ext_cost'] + if 'cost_expr_ext_cost_e' in out.keys(): + del out['cost_expr_ext_cost_e'] + if 'cost_expr_ext_cost_0' in out.keys(): + del out['cost_expr_ext_cost_0'] + if 'cost_expr_ext_cost_custom_hess' in out.keys(): + del out['cost_expr_ext_cost_custom_hess'] + if 'cost_expr_ext_cost_custom_hess_e' in out.keys(): + del out['cost_expr_ext_cost_custom_hess_e'] + if 'cost_expr_ext_cost_custom_hess_0' in out.keys(): + del out['cost_expr_ext_cost_custom_hess_0'] + + return out diff --git a/pyextra/acados_template/acados_ocp.py b/pyextra/acados_template/acados_ocp.py new file mode 100644 index 00000000000000..198ab033dca64c --- /dev/null +++ b/pyextra/acados_template/acados_ocp.py @@ -0,0 +1,2842 @@ +# -*- coding: future_fstrings -*- +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import numpy as np +import os +from .acados_model import AcadosModel +from .utils import get_acados_path, J_to_idx, J_to_idx_slack + +class AcadosOcpDims: + """ + Class containing the dimensions of the optimal control problem. + """ + def __init__(self): + self.__nx = None + self.__nu = None + self.__nz = 0 + self.__np = 0 + self.__ny = 0 + self.__ny_e = 0 + self.__ny_0 = 0 + self.__nr = 0 + self.__nr_e = 0 + self.__nh = 0 + self.__nh_e = 0 + self.__nphi = 0 + self.__nphi_e = 0 + self.__nbx = 0 + self.__nbx_0 = 0 + self.__nbx_e = 0 + self.__nbu = 0 + self.__nsbx = 0 + self.__nsbx_e = 0 + self.__nsbu = 0 + self.__nsh = 0 + self.__nsh_e = 0 + self.__nsphi = 0 + self.__nsphi_e = 0 + self.__ns = 0 + self.__ns_e = 0 + self.__ng = 0 + self.__ng_e = 0 + self.__nsg = 0 + self.__nsg_e = 0 + self.__nbxe_0 = None + self.__N = None + + + @property + def nx(self): + """:math:`n_x` - number of states. + Type: int; default: None""" + return self.__nx + + @property + def nz(self): + """:math:`n_z` - number of algebraic variables. + Type: int; default: 0""" + return self.__nz + + @property + def nu(self): + """:math:`n_u` - number of inputs. + Type: int; default: None""" + return self.__nu + + @property + def np(self): + """:math:`n_p` - number of parameters. + Type: int; default: 0""" + return self.__np + + @property + def ny(self): + """:math:`n_y` - number of residuals in Lagrange term. + Type: int; default: 0""" + return self.__ny + + @property + def ny_0(self): + """:math:`n_{y}^0` - number of residuals in Mayer term. + Type: int; default: 0""" + return self.__ny_0 + + @property + def ny_e(self): + """:math:`n_{y}^e` - number of residuals in Mayer term. + Type: int; default: 0""" + return self.__ny_e + + @property + def nr(self): + """:math:`n_{\pi}` - dimension of the image of the inner nonlinear function in positive definite constraints. + Type: int; default: 0""" + return self.__nr + + @property + def nr_e(self): + """:math:`n_{\pi}^e` - dimension of the image of the inner nonlinear function in positive definite constraints. + Type: int; default: 0""" + return self.__nr_e + + @property + def nh(self): + """:math:`n_h` - number of nonlinear constraints. + Type: int; default: 0""" + return self.__nh + + @property + def nh_e(self): + """:math:`n_{h}^e` - number of nonlinear constraints at terminal shooting node N. + Type: int; default: 0""" + return self.__nh_e + + @property + def nphi(self): + """:math:`n_{\phi}` - number of convex-over-nonlinear constraints. + Type: int; default: 0""" + return self.__nphi + + @property + def nphi_e(self): + """:math:`n_{\phi}^e` - number of convex-over-nonlinear constraints at terminal shooting node N. + Type: int; default: 0""" + return self.__nphi_e + + @property + def nbx(self): + """:math:`n_{b_x}` - number of state bounds. + Type: int; default: 0""" + return self.__nbx + + @property + def nbxe_0(self): + """:math:`n_{be_{x0}}` - number of state bounds at initial shooting node that are equalities. + Type: int; default: None""" + return self.__nbxe_0 + + @property + def nbx_0(self): + """:math:`n_{b_{x0}}` - number of state bounds for initial state. + Type: int; default: 0""" + return self.__nbx_0 + + @property + def nbx_e(self): + """:math:`n_{b_x}` - number of state bounds at terminal shooting node N. + Type: int; default: 0""" + return self.__nbx_e + + @property + def nbu(self): + """:math:`n_{b_u}` - number of input bounds. + Type: int; default: 0""" + return self.__nbu + + @property + def nsbx(self): + """:math:`n_{{sb}_x}` - number of soft state bounds. + Type: int; default: 0""" + return self.__nsbx + + @property + def nsbx_e(self): + """:math:`n_{{sb}^e_{x}}` - number of soft state bounds at terminal shooting node N. + Type: int; default: 0""" + return self.__nsbx_e + + @property + def nsbu(self): + """:math:`n_{{sb}_u}` - number of soft input bounds. + Type: int; default: 0""" + return self.__nsbu + + @property + def nsg(self): + """:math:`n_{{sg}}` - number of soft general linear constraints. + Type: int; default: 0""" + return self.__nsg + + @property + def nsg_e(self): + """:math:`n_{{sg}^e}` - number of soft general linear constraints at terminal shooting node N. + Type: int; default: 0""" + return self.__nsg_e + + @property + def nsh(self): + """:math:`n_{{sh}}` - number of soft nonlinear constraints. + Type: int; default: 0""" + return self.__nsh + + @property + def nsh_e(self): + """:math:`n_{{sh}}^e` - number of soft nonlinear constraints at terminal shooting node N. + Type: int; default: 0""" + return self.__nsh_e + + @property + def nsphi(self): + """:math:`n_{{s\phi}}` - number of soft convex-over-nonlinear constraints. + Type: int; default: 0""" + return self.__nsphi + + @property + def nsphi_e(self): + """:math:`n_{{s\phi}^e}` - number of soft convex-over-nonlinear constraints at terminal shooting node N. + Type: int; default: 0""" + return self.__nsphi_e + + @property + def ns(self): + """:math:`n_{s}` - total number of slacks. + Type: int; default: 0""" + return self.__ns + + @property + def ns_e(self): + """:math:`n_{s}^e` - total number of slacks at terminal shooting node N. + Type: int; default: 0""" + return self.__ns_e + + @property + def ng(self): + """:math:`n_{g}` - number of general polytopic constraints. + Type: int; default: 0""" + return self.__ng + + @property + def ng_e(self): + """:math:`n_{g}^e` - number of general polytopic constraints at terminal shooting node N. + Type: int; default: 0""" + return self.__ng_e + + @property + def N(self): + """:math:`N` - prediction horizon. + Type: int; default: None""" + return self.__N + + @nx.setter + def nx(self, nx): + if type(nx) == int and nx > 0: + self.__nx = nx + else: + raise Exception('Invalid nx value, expected positive integer. Exiting.') + + @nz.setter + def nz(self, nz): + if type(nz) == int and nz > -1: + self.__nz = nz + else: + raise Exception('Invalid nz value, expected nonnegative integer. Exiting.') + + @nu.setter + def nu(self, nu): + if type(nu) == int and nu > -1: + self.__nu = nu + else: + raise Exception('Invalid nu value, expected nonnegative integer. Exiting.') + + @np.setter + def np(self, np): + if type(np) == int and np > -1: + self.__np = np + else: + raise Exception('Invalid np value, expected nonnegative integer. Exiting.') + + @ny_0.setter + def ny_0(self, ny_0): + if isinstance(ny_0, int) and ny_0 > -1: + self.__ny_0 = ny_0 + else: + raise Exception('Invalid ny_0 value, expected nonnegative integer. Exiting.') + + @ny.setter + def ny(self, ny): + if isinstance(ny, int) and ny > -1: + self.__ny = ny + else: + raise Exception('Invalid ny value, expected nonnegative integer. Exiting.') + + @ny_e.setter + def ny_e(self, ny_e): + if type(ny_e) == int and ny_e > -1: + self.__ny_e = ny_e + else: + raise Exception('Invalid ny_e value, expected nonnegative integer. Exiting.') + + @nr.setter + def nr(self, nr): + if type(nr) == int and nr > -1: + self.__nr = nr + else: + raise Exception('Invalid nr value, expected nonnegative integer. Exiting.') + + @nr_e.setter + def nr_e(self, nr_e): + if type(nr_e) == int and nr_e > -1: + self.__nr_e = nr_e + else: + raise Exception('Invalid nr_e value, expected nonnegative integer. Exiting.') + + @nh.setter + def nh(self, nh): + if type(nh) == int and nh > -1: + self.__nh = nh + else: + raise Exception('Invalid nh value, expected nonnegative integer. Exiting.') + + @nh_e.setter + def nh_e(self, nh_e): + if type(nh_e) == int and nh_e > -1: + self.__nh_e = nh_e + else: + raise Exception('Invalid nh_e value, expected nonnegative integer. Exiting.') + + @nphi.setter + def nphi(self, nphi): + if type(nphi) == int and nphi > -1: + self.__nphi = nphi + else: + raise Exception('Invalid nphi value, expected nonnegative integer. Exiting.') + + @nphi_e.setter + def nphi_e(self, nphi_e): + if type(nphi_e) == int and nphi_e > -1: + self.__nphi_e = nphi_e + else: + raise Exception('Invalid nphi_e value, expected nonnegative integer. Exiting.') + + @nbx.setter + def nbx(self, nbx): + if isinstance(nbx, int) and nbx > -1: + self.__nbx = nbx + else: + raise Exception('Invalid nbx value, expected nonnegative integer. Exiting.') + + @nbxe_0.setter + def nbxe_0(self, nbxe_0): + if isinstance(nbxe_0, int) and nbxe_0 > -1: + self.__nbxe_0 = nbxe_0 + else: + raise Exception('Invalid nbxe_0 value, expected nonnegative integer. Exiting.') + + @nbx_0.setter + def nbx_0(self, nbx_0): + if type(nbx_0) == int and nbx_0 > -1: + self.__nbx_0 = nbx_0 + else: + raise Exception('Invalid nbx_0 value, expected nonnegative integer. Exiting.') + + @nbx_e.setter + def nbx_e(self, nbx_e): + if type(nbx_e) == int and nbx_e > -1: + self.__nbx_e = nbx_e + else: + raise Exception('Invalid nbx_e value, expected nonnegative integer. Exiting.') + + @nbu.setter + def nbu(self, nbu): + if type(nbu) == int and nbu > -1: + self.__nbu = nbu + else: + raise Exception('Invalid nbu value, expected nonnegative integer. Exiting.') + + @nsbx.setter + def nsbx(self, nsbx): + if type(nsbx) == int and nsbx > -1: + self.__nsbx = nsbx + else: + raise Exception('Invalid nsbx value, expected nonnegative integer. Exiting.') + + @nsbx_e.setter + def nsbx_e(self, nsbx_e): + if type(nsbx_e) == int and nsbx_e > -1: + self.__nsbx_e = nsbx_e + else: + raise Exception('Invalid nsbx_e value, expected nonnegative integer. Exiting.') + + @nsbu.setter + def nsbu(self, nsbu): + if type(nsbu) == int and nsbu > -1: + self.__nsbu = nsbu + else: + raise Exception('Invalid nsbu value, expected nonnegative integer. Exiting.') + + @nsg.setter + def nsg(self, nsg): + if isinstance(nsg, int) and nsg > -1: + self.__nsg = nsg + else: + raise Exception('Invalid nsg value, expected nonnegative integer. Exiting.') + + @nsg_e.setter + def nsg_e(self, nsg_e): + if isinstance(nsg_e, int) and nsg_e > -1: + self.__nsg_e = nsg_e + else: + raise Exception('Invalid nsg_e value, expected nonnegative integer. Exiting.') + + @nsh.setter + def nsh(self, nsh): + if isinstance(nsh, int) and nsh > -1: + self.__nsh = nsh + else: + raise Exception('Invalid nsh value, expected nonnegative integer. Exiting.') + + @nsh_e.setter + def nsh_e(self, nsh_e): + if isinstance(nsh_e, int) and nsh_e > -1: + self.__nsh_e = nsh_e + else: + raise Exception('Invalid nsh_e value, expected nonnegative integer. Exiting.') + + @nsphi.setter + def nsphi(self, nsphi): + if isinstance(nsphi, int) and nsphi > -1: + self.__nsphi = nsphi + else: + raise Exception('Invalid nsphi value, expected nonnegative integer. Exiting.') + + @nsphi_e.setter + def nsphi_e(self, nsphi_e): + if isinstance(nsphi_e, int) and nsphi_e > -1: + self.__nsphi_e = nsphi_e + else: + raise Exception('Invalid nsphi_e value, expected nonnegative integer. Exiting.') + + @ns.setter + def ns(self, ns): + if isinstance(ns, int) and ns > -1: + self.__ns = ns + else: + raise Exception('Invalid ns value, expected nonnegative integer. Exiting.') + + @ns_e.setter + def ns_e(self, ns_e): + if isinstance(ns_e, int) and ns_e > -1: + self.__ns_e = ns_e + else: + raise Exception('Invalid ns_e value, expected nonnegative integer. Exiting.') + + @ng.setter + def ng(self, ng): + if isinstance(ng, int) and ng > -1: + self.__ng = ng + else: + raise Exception('Invalid ng value, expected nonnegative integer. Exiting.') + + @ng_e.setter + def ng_e(self, ng_e): + if isinstance(ng_e, int) and ng_e > -1: + self.__ng_e = ng_e + else: + raise Exception('Invalid ng_e value, expected nonnegative integer. Exiting.') + + @N.setter + def N(self, N): + if isinstance(N, int) and N > 0: + self.__N = N + else: + raise Exception('Invalid N value, expected positive integer. Exiting.') + + def set(self, attr, value): + setattr(self, attr, value) + + +class AcadosOcpCost: + """ + Class containing the numerical data of the cost: + + In case of LINEAR_LS: + stage cost is + :math:`l(x,u,z) = || V_x \, x + V_u \, u + V_z \, z - y_\\text{ref}||^2_W`, + terminal cost is + :math:`m(x) = || V^e_x \, x - y_\\text{ref}^e||^2_{W^e}` + + In case of NONLINEAR_LS: + stage cost is + :math:`l(x,u,z) = || y(x,u,z) - y_\\text{ref}||^2_W`, + terminal cost is + :math:`m(x) = || y^e(x) - y_\\text{ref}^e||^2_{W^e}` + """ + def __init__(self): + # initial stage + self.__cost_type_0 = None + self.__W_0 = None + self.__Vx_0 = None + self.__Vu_0 = None + self.__Vz_0 = None + self.__yref_0 = None + self.__cost_ext_fun_type_0 = 'casadi' + # Lagrange term + self.__cost_type = 'LINEAR_LS' # cost type + self.__W = np.zeros((0,0)) + self.__Vx = np.zeros((0,0)) + self.__Vu = np.zeros((0,0)) + self.__Vz = np.zeros((0,0)) + self.__yref = np.array([]) + self.__Zl = np.array([]) + self.__Zu = np.array([]) + self.__zl = np.array([]) + self.__zu = np.array([]) + self.__cost_ext_fun_type = 'casadi' + # Mayer term + self.__cost_type_e = 'LINEAR_LS' + self.__W_e = np.zeros((0,0)) + self.__Vx_e = np.zeros((0,0)) + self.__yref_e = np.array([]) + self.__Zl_e = np.array([]) + self.__Zu_e = np.array([]) + self.__zl_e = np.array([]) + self.__zu_e = np.array([]) + self.__cost_ext_fun_type_e = 'casadi' + + # initial stage + @property + def cost_type_0(self): + """Cost type at initial shooting node (0) + -- string in {EXTERNAL, LINEAR_LS, NONLINEAR_LS} or :code:`None`. + Default: :code:`None`. + + .. note:: Cost at initial stage is the same as for intermediate shooting nodes if not set differently explicitly. + + .. note:: If :py:attr:`cost_type_0` is set to :code:`None` values in :py:attr:`W_0`, :py:attr:`Vx_0`, :py:attr:`Vu_0`, :py:attr:`Vz_0` and :py:attr:`yref_0` are ignored (set to :code:`None`). + """ + return self.__cost_type_0 + + @property + def W_0(self): + """:math:`W_0` - weight matrix at initial shooting node (0). + Default: :code:`None`. + """ + return self.__W_0 + + @property + def Vx_0(self): + """:math:`V_x^0` - x matrix coefficient at initial shooting node (0). + Default: :code:`None`. + """ + return self.__Vx_0 + + @property + def Vu_0(self): + """:math:`V_u^0` - u matrix coefficient at initial shooting node (0). + Default: :code:`None`. + """ + return self.__Vu_0 + + @property + def Vz_0(self): + """:math:`V_z^0` - z matrix coefficient at initial shooting node (0). + Default: :code:`None`. + """ + return self.__Vz_0 + + @property + def yref_0(self): + """:math:`y_\\text{ref}^0` - reference at initial shooting node (0). + Default: :code:`None`. + """ + return self.__yref_0 + + @property + def cost_ext_fun_type_0(self): + """Type of external function for cost at initial shooting node (0) + -- string in {casadi, generic} or :code:`None` + Default: :code:'casadi'. + + .. note:: Cost at initial stage is the same as for intermediate shooting nodes if not set differently explicitly. + """ + return self.__cost_ext_fun_type_0 + + @yref_0.setter + def yref_0(self, yref_0): + if isinstance(yref_0, np.ndarray): + self.__yref_0 = yref_0 + else: + raise Exception('Invalid yref_0 value, expected numpy array. Exiting.') + + @W_0.setter + def W_0(self, W_0): + if isinstance(W_0, np.ndarray) and len(W_0.shape) == 2: + self.__W_0 = W_0 + else: + raise Exception('Invalid cost W_0 value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @Vx_0.setter + def Vx_0(self, Vx_0): + if isinstance(Vx_0, np.ndarray) and len(Vx_0.shape) == 2: + self.__Vx_0 = Vx_0 + else: + raise Exception('Invalid cost Vx_0 value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @Vu_0.setter + def Vu_0(self, Vu_0): + if isinstance(Vu_0, np.ndarray) and len(Vu_0.shape) == 2: + self.__Vu_0 = Vu_0 + else: + raise Exception('Invalid cost Vu_0 value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @Vz_0.setter + def Vz_0(self, Vz_0): + if isinstance(Vz_0, np.ndarray) and len(Vz_0.shape) == 2: + self.__Vz_0 = Vz_0 + else: + raise Exception('Invalid cost Vz_0 value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @cost_ext_fun_type_0.setter + def cost_ext_fun_type_0(self, cost_ext_fun_type_0): + if cost_ext_fun_type_0 in ['casadi', 'generic']: + self.__cost_ext_fun_type_0 = cost_ext_fun_type_0 + else: + raise Exception('Invalid cost_ext_fun_type_0 value, expected numpy array. Exiting.') + + # Lagrange term + @property + def cost_type(self): + """ + Cost type at intermediate shooting nodes (1 to N-1) + -- string in {EXTERNAL, LINEAR_LS, NONLINEAR_LS}. + Default: 'LINEAR_LS'. + """ + return self.__cost_type + + @property + def W(self): + """:math:`W` - weight matrix at intermediate shooting nodes (1 to N-1). + Default: :code:`np.zeros((0,0))`. + """ + return self.__W + + @property + def Vx(self): + """:math:`V_x` - x matrix coefficient at intermediate shooting nodes (1 to N-1). + Default: :code:`np.zeros((0,0))`. + """ + return self.__Vx + + @property + def Vu(self): + """:math:`V_u` - u matrix coefficient at intermediate shooting nodes (1 to N-1). + Default: :code:`np.zeros((0,0))`. + """ + return self.__Vu + + @property + def Vz(self): + """:math:`V_z` - z matrix coefficient at intermediate shooting nodes (1 to N-1). + Default: :code:`np.zeros((0,0))`. + """ + return self.__Vz + + @property + def yref(self): + """:math:`y_\\text{ref}` - reference at intermediate shooting nodes (1 to N-1). + Default: :code:`np.array([])`. + """ + return self.__yref + + @property + def Zl(self): + """:math:`Z_l` - diagonal of Hessian wrt lower slack at intermediate shooting nodes (1 to N-1). + Default: :code:`np.array([])`. + """ + return self.__Zl + + @property + def Zu(self): + """:math:`Z_u` - diagonal of Hessian wrt upper slack at intermediate shooting nodes (1 to N-1). + Default: :code:`np.array([])`. + """ + return self.__Zu + + @property + def zl(self): + """:math:`z_l` - gradient wrt lower slack at intermediate shooting nodes (1 to N-1). + Default: :code:`np.array([])`. + """ + return self.__zl + + @property + def zu(self): + """:math:`z_u` - gradient wrt upper slack at intermediate shooting nodes (1 to N-1). + Default: :code:`np.array([])`. + """ + return self.__zu + + @property + def cost_ext_fun_type(self): + """Type of external function for cost at intermediate shooting nodes (1 to N-1). + -- string in {casadi, generic} + Default: :code:'casadi'. + """ + return self.__cost_ext_fun_type + + @cost_type.setter + def cost_type(self, cost_type): + cost_types = ('LINEAR_LS', 'NONLINEAR_LS', 'EXTERNAL') + if cost_type in cost_types: + self.__cost_type = cost_type + else: + raise Exception('Invalid cost_type value. Exiting.') + + @cost_type_0.setter + def cost_type_0(self, cost_type_0): + cost_types = ('LINEAR_LS', 'NONLINEAR_LS', 'EXTERNAL') + if cost_type_0 in cost_types: + self.__cost_type_0 = cost_type_0 + else: + raise Exception('Invalid cost_type_0 value. Exiting.') + + @W.setter + def W(self, W): + if isinstance(W, np.ndarray) and len(W.shape) == 2: + self.__W = W + else: + raise Exception('Invalid cost W value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + + @Vx.setter + def Vx(self, Vx): + if isinstance(Vx, np.ndarray) and len(Vx.shape) == 2: + self.__Vx = Vx + else: + raise Exception('Invalid cost Vx value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @Vu.setter + def Vu(self, Vu): + if isinstance(Vu, np.ndarray) and len(Vu.shape) == 2: + self.__Vu = Vu + else: + raise Exception('Invalid cost Vu value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @Vz.setter + def Vz(self, Vz): + if isinstance(Vz, np.ndarray) and len(Vz.shape) == 2: + self.__Vz = Vz + else: + raise Exception('Invalid cost Vz value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @yref.setter + def yref(self, yref): + if isinstance(yref, np.ndarray): + self.__yref = yref + else: + raise Exception('Invalid yref value, expected numpy array. Exiting.') + + @Zl.setter + def Zl(self, Zl): + if isinstance(Zl, np.ndarray): + self.__Zl = Zl + else: + raise Exception('Invalid Zl value, expected numpy array. Exiting.') + + @Zu.setter + def Zu(self, Zu): + if isinstance(Zu, np.ndarray): + self.__Zu = Zu + else: + raise Exception('Invalid Zu value, expected numpy array. Exiting.') + + @zl.setter + def zl(self, zl): + if isinstance(zl, np.ndarray): + self.__zl = zl + else: + raise Exception('Invalid zl value, expected numpy array. Exiting.') + + @zu.setter + def zu(self, zu): + if isinstance(zu, np.ndarray): + self.__zu = zu + else: + raise Exception('Invalid zu value, expected numpy array. Exiting.') + + @cost_ext_fun_type.setter + def cost_ext_fun_type(self, cost_ext_fun_type): + if cost_ext_fun_type in ['casadi', 'generic']: + self.__cost_ext_fun_type = cost_ext_fun_type + else: + raise Exception('Invalid cost_ext_fun_type value, expected numpy array. Exiting.') + + # Mayer term + @property + def cost_type_e(self): + """ + Cost type at terminal shooting node (N) + -- string in {EXTERNAL, LINEAR_LS, NONLINEAR_LS}. + Default: 'LINEAR_LS'. + """ + return self.__cost_type_e + + @property + def W_e(self): + """:math:`W_e` - weight matrix at terminal shooting node (N). + Default: :code:`np.zeros((0,0))`. + """ + return self.__W_e + + @property + def Vx_e(self): + """:math:`V_x^e` - x matrix coefficient for cost at terminal shooting node (N). + Default: :code:`np.zeros((0,0))`. + """ + return self.__Vx_e + + @property + def yref_e(self): + """:math:`y_\\text{ref}^e` - cost reference at terminal shooting node (N). + Default: :code:`np.array([])`. + """ + return self.__yref_e + + @property + def Zl_e(self): + """:math:`Z_l^e` - diagonal of Hessian wrt lower slack at terminal shooting node (N). + Default: :code:`np.array([])`. + """ + return self.__Zl_e + + @property + def Zu_e(self): + """:math:`Z_u^e` - diagonal of Hessian wrt upper slack at terminal shooting node (N). + Default: :code:`np.array([])`. + """ + return self.__Zu_e + + @property + def zl_e(self): + """:math:`z_l^e` - gradient wrt lower slack at terminal shooting node (N). + Default: :code:`np.array([])`. + """ + return self.__zl_e + + @property + def zu_e(self): + """:math:`z_u^e` - gradient wrt upper slack at terminal shooting node (N). + Default: :code:`np.array([])`. + """ + return self.__zu_e + + @property + def cost_ext_fun_type_e(self): + """Type of external function for cost at intermediate shooting nodes (1 to N-1). + -- string in {casadi, generic} + Default: :code:'casadi'. + """ + return self.__cost_ext_fun_type_e + + @cost_type_e.setter + def cost_type_e(self, cost_type_e): + cost_types = ('LINEAR_LS', 'NONLINEAR_LS', 'EXTERNAL') + + if cost_type_e in cost_types: + self.__cost_type_e = cost_type_e + else: + raise Exception('Invalid cost_type_e value. Exiting.') + + @W_e.setter + def W_e(self, W_e): + if isinstance(W_e, np.ndarray) and len(W_e.shape) == 2: + self.__W_e = W_e + else: + raise Exception('Invalid cost W_e value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @Vx_e.setter + def Vx_e(self, Vx_e): + if isinstance(Vx_e, np.ndarray) and len(Vx_e.shape) == 2: + self.__Vx_e = Vx_e + else: + raise Exception('Invalid cost Vx_e value. ' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @yref_e.setter + def yref_e(self, yref_e): + if isinstance(yref_e, np.ndarray): + self.__yref_e = yref_e + else: + raise Exception('Invalid yref_e value, expected numpy array. Exiting.') + + @Zl_e.setter + def Zl_e(self, Zl_e): + if isinstance(Zl_e, np.ndarray): + self.__Zl_e = Zl_e + else: + raise Exception('Invalid Zl_e value, expected numpy array. Exiting.') + + @Zu_e.setter + def Zu_e(self, Zu_e): + if isinstance(Zu_e, np.ndarray): + self.__Zu_e = Zu_e + else: + raise Exception('Invalid Zu_e value, expected numpy array. Exiting.') + + @zl_e.setter + def zl_e(self, zl_e): + if isinstance(zl_e, np.ndarray): + self.__zl_e = zl_e + else: + raise Exception('Invalid zl_e value, expected numpy array. Exiting.') + + @zu_e.setter + def zu_e(self, zu_e): + if isinstance(zu_e, np.ndarray): + self.__zu_e = zu_e + else: + raise Exception('Invalid zu_e value, expected numpy array. Exiting.') + + @cost_ext_fun_type_e.setter + def cost_ext_fun_type_e(self, cost_ext_fun_type_e): + if cost_ext_fun_type_e in ['casadi', 'generic']: + self.__cost_ext_fun_type_e = cost_ext_fun_type_e + else: + raise Exception('Invalid cost_ext_fun_type_e value, expected numpy array. Exiting.') + + def set(self, attr, value): + setattr(self, attr, value) + + +def print_J_to_idx_note(): + print("NOTE: J* matrix is converted to zero based vector idx* vector, which is returned here.") + + +class AcadosOcpConstraints: + """ + class containing the description of the constraints + """ + def __init__(self): + self.__constr_type = 'BGH' + self.__constr_type_e = 'BGH' + # initial x + self.__lbx_0 = np.array([]) + self.__ubx_0 = np.array([]) + self.__idxbx_0 = np.array([]) + self.__idxbxe_0 = np.array([]) + # state bounds + self.__lbx = np.array([]) + self.__ubx = np.array([]) + self.__idxbx = np.array([]) + # bounds on x at shooting node N + self.__lbx_e = np.array([]) + self.__ubx_e = np.array([]) + self.__idxbx_e = np.array([]) + # bounds on u + self.__lbu = np.array([]) + self.__ubu = np.array([]) + self.__idxbu = np.array([]) + # polytopic constraints + self.__lg = np.array([]) + self.__ug = np.array([]) + self.__D = np.zeros((0,0)) + self.__C = np.zeros((0,0)) + # polytopic constraints at shooting node N + self.__C_e = np.zeros((0,0)) + self.__lg_e = np.array([]) + self.__ug_e = np.array([]) + # nonlinear constraints + self.__lh = np.array([]) + self.__uh = np.array([]) + # nonlinear constraints at shooting node N + self.__uh_e = np.array([]) + self.__lh_e = np.array([]) + # convex-over-nonlinear constraints + self.__lphi = np.array([]) + self.__uphi = np.array([]) + # nonlinear constraints at shooting node N + self.__uphi_e = np.array([]) + self.__lphi_e = np.array([]) + # SLACK BOUNDS + # soft bounds on x + self.__lsbx = np.array([]) + self.__usbx = np.array([]) + self.__idxsbx = np.array([]) + # soft bounds on u + self.__lsbu = np.array([]) + self.__usbu = np.array([]) + self.__idxsbu = np.array([]) + # soft bounds on x at shooting node N + self.__lsbx_e = np.array([]) + self.__usbx_e = np.array([]) + self.__idxsbx_e= np.array([]) + # soft bounds on general linear constraints + self.__lsg = np.array([]) + self.__usg = np.array([]) + self.__idxsg = np.array([]) + # soft bounds on nonlinear constraints + self.__lsh = np.array([]) + self.__ush = np.array([]) + self.__idxsh = np.array([]) + # soft bounds on nonlinear constraints + self.__lsphi = np.array([]) + self.__usphi = np.array([]) + self.__idxsphi = np.array([]) + # soft bounds on general linear constraints at shooting node N + self.__lsg_e = np.array([]) + self.__usg_e = np.array([]) + self.__idxsg_e = np.array([]) + # soft bounds on nonlinear constraints at shooting node N + self.__lsh_e = np.array([]) + self.__ush_e = np.array([]) + self.__idxsh_e = np.array([]) + # soft bounds on nonlinear constraints at shooting node N + self.__lsphi_e = np.array([]) + self.__usphi_e = np.array([]) + self.__idxsphi_e = np.array([]) + + + # types + @property + def constr_type(self): + """Constraints type for shooting nodes (0 to N-1). string in {BGH, BGP}. + Default: BGH; BGP is for convex over nonlinear.""" + return self.__constr_type + + @property + def constr_type_e(self): + """Constraints type for terminal shooting node N. string in {BGH, BGP}. + Default: BGH; BGP is for convex over nonlinear.""" + return self.__constr_type_e + + # initial bounds on x + @property + def lbx_0(self): + """:math:`\\underline{x_0}` - lower bounds on x at initial stage 0. + Type: :code:`np.ndarray`; default: :code:`np.array([])`.""" + return self.__lbx_0 + + @property + def ubx_0(self): + """:math:`\\bar{x_0}` - upper bounds on x at initial stage 0. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__ubx_0 + + @property + def Jbx_0(self): + """:math:`J_{bx,0}` - matrix coefficient for bounds on x at initial stage 0. + Translated internally to :py:attr:`idxbx_0`""" + print_J_to_idx_note() + return self.__idxbx_0 + + @property + def idxbx_0(self): + """Indices of bounds on x at initial stage 0 + -- can be set automatically via x0. + Can be set by using :py:attr:`Jbx_0`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxbx_0 + + @property + def idxbxe_0(self): + """Indices of bounds on x0 that are equalities -- can be set automatically via :py:attr:`x0`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxbxe_0 + + # bounds on x + @property + def lbx(self): + """:math:`\\underline{x}` - lower bounds on x at intermediate shooting nodes (1 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__lbx + + @property + def ubx(self): + """:math:`\\bar{x}` - upper bounds on x at intermediate shooting nodes (1 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__ubx + + @property + def idxbx(self): + """indices of bounds on x (defines :math:`J_{bx}`) at intermediate shooting nodes (1 to N-1). + Can be set by using :py:attr:`Jbx`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxbx + + @property + def Jbx(self): + """:math:`J_{bx}` - matrix coefficient for bounds on x + at intermediate shooting nodes (1 to N-1). + Translated internally into :py:attr:`idxbx`.""" + print_J_to_idx_note() + return self.__idxbx + + # bounds on x at shooting node N + @property + def lbx_e(self): + """:math:`\\underline{x}^e` - lower bounds on x at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__lbx_e + + @property + def ubx_e(self): + """:math:`\\bar{x}^e` - upper bounds on x at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__ubx_e + + @property + def idxbx_e(self): + """Indices for bounds on x at terminal shooting node N (defines :math:`J_{bx}^e`). + Can be set by using :py:attr:`Jbx_e`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxbx_e + + @property + def Jbx_e(self): + """:math:`J_{bx}^e` matrix coefficient for bounds on x at terminal shooting node N. + Translated internally into :py:attr:`idxbx_e`.""" + print_J_to_idx_note() + return self.__idxbx_e + + # bounds on u + @property + def lbu(self): + """:math:`\\underline{u}` - lower bounds on u at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])` + """ + return self.__lbu + + @property + def ubu(self): + """:math:`\\bar{u}` - upper bounds on u at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])` + """ + return self.__ubu + + @property + def idxbu(self): + """Indices of bounds on u (defines :math:`J_{bu}`) at shooting nodes (0 to N-1). + Can be set by using :py:attr:`Jbu`. + Type: :code:`np.ndarray`; default: :code:`np.array([])` + """ + return self.__idxbu + + @property + def Jbu(self): + """:math:`J_{bu}` - matrix coefficient for bounds on u at shooting nodes (0 to N-1). + Translated internally to :py:attr:`idxbu`. + """ + print_J_to_idx_note() + return self.__idxbu + + # polytopic constraints + @property + def C(self): + """:math:`C` - C matrix in :math:`\\underline{g} \\leq D \, u + C \, x \\leq \\bar{g}` + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array((0,0))`. + """ + return self.__C + + @property + def D(self): + """:math:`D` - D matrix in :math:`\\underline{g} \\leq D \, u + C \, x \\leq \\bar{g}` + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array((0,0))` + """ + return self.__D + + @property + def lg(self): + """:math:`\\underline{g}` - lower bound for general polytopic inequalities + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])` + """ + return self.__lg + + @property + def ug(self): + """:math:`\\bar{g}` - upper bound for general polytopic inequalities + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__ug + + # polytopic constraints at shooting node N + @property + def C_e(self): + """:math:`C^e` - C matrix at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array((0,0))`. + """ + return self.__C_e + + @property + def lg_e(self): + """:math:`\\underline{g}^e` - lower bound on general polytopic inequalities + at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__lg_e + + @property + def ug_e(self): + """:math:`\\bar{g}^e` - upper bound on general polytopic inequalities + at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__ug_e + + + # nonlinear constraints + @property + def lh(self): + """:math:`\\underline{h}` - lower bound for nonlinear inequalities + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__lh + + @property + def uh(self): + """:math:`\\bar{h}` - upper bound for nonlinear inequalities + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__uh + + # nonlinear constraints at shooting node N + @property + def lh_e(self): + """:math:`\\underline{h}^e` - lower bound on nonlinear inequalities + at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__lh_e + + @property + def uh_e(self): + """:math:`\\bar{h}^e` - upper bound on nonlinear inequalities + at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__uh_e + + # convex-over-nonlinear constraints + @property + def lphi(self): + """:math:`\\underline{\phi}` - lower bound for convex-over-nonlinear inequalities + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__lphi + + @property + def uphi(self): + """:math:`\\bar{\phi}` - upper bound for convex-over-nonlinear inequalities + at shooting nodes (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__uphi + + # convex-over-nonlinear constraints at shooting node N + @property + def lphi_e(self): + """:math:`\\underline{\phi}^e` - lower bound on convex-over-nonlinear inequalities + at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__lphi_e + + @property + def uphi_e(self): + """:math:`\\bar{\phi}^e` - upper bound on convex-over-nonlinear inequalities + at terminal shooting node N. + Type: :code:`np.ndarray`; default: :code:`np.array([])`. + """ + return self.__uphi_e + + + # SLACK bounds + # soft bounds on x + @property + def lsbx(self): + """Lower bounds on slacks corresponding to soft lower bounds on x + at stages (1 to N-1); + not required - zeros by default""" + return self.__lsbx + + @property + def usbx(self): + """Lower bounds on slacks corresponding to soft upper bounds on x + at stages (1 to N-1); + not required - zeros by default""" + return self.__usbx + + @property + def idxsbx(self): + """Indices of soft bounds on x within the indices of bounds on x + at stages (1 to N-1). + Can be set by using :py:attr:`Jsbx`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxsbx + + @property + def Jsbx(self): + """:math:`J_{sbx}` - matrix coefficient for soft bounds on x + at stages (1 to N-1); + Translated internally into :py:attr:`idxsbx`.""" + print_J_to_idx_note() + return self.__idxsbx + + # soft bounds on u + @property + def lsbu(self): + """Lower bounds on slacks corresponding to soft lower bounds on u + at stages (0 to N-1). + Not required - zeros by default.""" + return self.__lsbu + + @property + def usbu(self): + """Lower bounds on slacks corresponding to soft upper bounds on u + at stages (0 to N-1); + not required - zeros by default""" + return self.__usbu + + @property + def idxsbu(self): + """Indices of soft bounds on u within the indices of bounds on u + at stages (0 to N-1). + Can be set by using :py:attr:`Jsbu`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxsbu + + @property + def Jsbu(self): + """:math:`J_{sbu}` - matrix coefficient for soft bounds on u + at stages (0 to N-1); + internally translated into :py:attr:`idxsbu`""" + print_J_to_idx_note() + return self.__idxsbu + + # soft bounds on x at shooting node N + @property + def lsbx_e(self): + """Lower bounds on slacks corresponding to soft lower bounds on x at shooting node N. + Not required - zeros by default""" + return self.__lsbx_e + + @property + def usbx_e(self): + """Lower bounds on slacks corresponding to soft upper bounds on x at shooting node N. + Not required - zeros by default""" + return self.__usbx_e + + @property + def idxsbx_e(self): + """Indices of soft bounds on x at shooting node N, within the indices of bounds on x at terminal shooting node N. + Can be set by using :py:attr:`Jsbx_e`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxsbx_e + + @property + def Jsbx_e(self): + """:math:`J_{sbx}^e` - matrix coefficient for soft bounds on x at terminal shooting node N. + Translated internally to :py:attr:`idxsbx_e`""" + print_J_to_idx_note() + return self.__idxsbx_e + + # soft general linear constraints + @property + def lsg(self): + """Lower bounds on slacks corresponding to soft lower bounds for general linear constraints + at stages (0 to N-1). + Type: :code:`np.ndarray`; default: :code:`np.array([])` + """ + return self.__lsg + + @property + def usg(self): + """Lower bounds on slacks corresponding to soft upper bounds for general linear constraints. + Not required - zeros by default""" + return self.__usg + + @property + def idxsg(self): + """Indices of soft general linear constraints within the indices of general linear constraints. + Can be set by using :py:attr:`Jsg`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxsg + + @property + def Jsg(self): + """:math:`J_{sg}` - matrix coefficient for soft bounds on general linear constraints. + Translated internally to :py:attr:`idxsg`""" + print_J_to_idx_note() + return self.__idxsg + + # soft nonlinear constraints + @property + def lsh(self): + """Lower bounds on slacks corresponding to soft lower bounds for nonlinear constraints. + Not required - zeros by default""" + return self.__lsh + + @property + def ush(self): + """Lower bounds on slacks corresponding to soft upper bounds for nonlinear constraints. + Not required - zeros by default""" + return self.__ush + + @property + def idxsh(self): + """Indices of soft nonlinear constraints within the indices of nonlinear constraints. + Can be set by using :py:attr:`Jbx`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxsh + + @property + def Jsh(self): + """:math:`J_{sh}` - matrix coefficient for soft bounds on nonlinear constraints. + Translated internally to :py:attr:`idxsh`""" + print_J_to_idx_note() + return self.__idxsh + + # soft bounds on convex-over-nonlinear constraints + @property + def lsphi(self): + """Lower bounds on slacks corresponding to soft lower bounds for convex-over-nonlinear constraints. + Not required - zeros by default""" + return self.__lsphi + + @property + def usphi(self): + """Lower bounds on slacks corresponding to soft upper bounds for convex-over-nonlinear constraints. + Not required - zeros by default""" + return self.__usphi + + @property + def idxsphi(self): + """Indices of soft convex-over-nonlinear constraints within the indices of nonlinear constraints. + Can be set by using :py:attr:`Jsphi`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxsphi + + @property + def Jsphi(self): + """:math:`J_{s, \phi}` - matrix coefficient for soft bounds on convex-over-nonlinear constraints. + Translated internally into :py:attr:`idxsphi`.""" + print_J_to_idx_note() + return self.__idxsphi + + + # soft bounds on general linear constraints at shooting node N + @property + def lsg_e(self): + """Lower bounds on slacks corresponding to soft lower bounds for general linear constraints at shooting node N. + Not required - zeros by default""" + return self.__lsg_e + + @property + def usg_e(self): + """Lower bounds on slacks corresponding to soft upper bounds for general linear constraints at shooting node N. + Not required - zeros by default""" + return self.__usg_e + + @property + def idxsg_e(self): + """Indices of soft general linear constraints at shooting node N within the indices of general linear constraints at shooting node N. + Can be set by using :py:attr:`Jsg_e`.""" + return self.__idxsg_e + + @property + def Jsg_e(self): + """:math:`J_{s,h}^e` - matrix coefficient for soft bounds on general linear constraints at terminal shooting node N. + Translated internally to :py:attr:`idxsg_e`""" + print_J_to_idx_note() + return self.__idxsg_e + + + # soft bounds on nonlinear constraints at shooting node N + @property + def lsh_e(self): + """Lower bounds on slacks corresponding to soft lower bounds for nonlinear constraints at terminal shooting node N. + Not required - zeros by default""" + return self.__lsh_e + + @property + def ush_e(self): + """Lower bounds on slacks corresponding to soft upper bounds for nonlinear constraints at terminal shooting node N. + Not required - zeros by default""" + return self.__ush_e + + @property + def idxsh_e(self): + """Indices of soft nonlinear constraints at shooting node N within the indices of nonlinear constraints at terminal shooting node N. + Can be set by using :py:attr:`Jsh_e`.""" + return self.__idxsh_e + + @property + def Jsh_e(self): + """:math:`J_{s,h}^e` - matrix coefficient for soft bounds on nonlinear constraints at terminal shooting node N; fills :py:attr:`idxsh_e`""" + print_J_to_idx_note() + return self.__idxsh_e + + # soft bounds on convex-over-nonlinear constraints at shooting node N + @property + def lsphi_e(self): + """Lower bounds on slacks corresponding to soft lower bounds for convex-over-nonlinear constraints at terminal shooting node N. + Not required - zeros by default""" + return self.__lsphi_e + + @property + def usphi_e(self): + """Lower bounds on slacks corresponding to soft upper bounds for convex-over-nonlinear constraints at terminal shooting node N. + Not required - zeros by default""" + return self.__usphi_e + + @property + def idxsphi_e(self): + """Indices of soft nonlinear constraints at shooting node N within the indices of nonlinear constraints at terminal shooting node N. + Can be set by using :py:attr:`Jsphi_e`. + Type: :code:`np.ndarray`; default: :code:`np.array([])`""" + return self.__idxsphi_e + + @property + def Jsphi_e(self): + """:math:`J_{sh}^e` - matrix coefficient for soft bounds on convex-over-nonlinear constraints at shooting node N. + Translated internally to :py:attr:`idxsphi_e`""" + print_J_to_idx_note() + return self.__idxsphi_e + + @property + def x0(self): + """:math:`x_0 \\in \mathbb{R}^{n_x}` - initial state -- + Translated internally to :py:attr:`idxbx_0`, :py:attr:`lbx_0`, :py:attr:`ubx_0`, :py:attr:`idxbxe_0` """ + print("x0 is converted to lbx_0, ubx_0, idxbx_0") + print("idxbx_0: ", self.__idxbx_0) + print("lbx_0: ", self.__lbx_0) + print("ubx_0: ", self.__ubx_0) + print("idxbxe_0: ", self.__idxbxe_0) + return None + + # SETTERS + @constr_type.setter + def constr_type(self, constr_type): + constr_types = ('BGH', 'BGP') + if constr_type in constr_types: + self.__constr_type = constr_type + else: + raise Exception('Invalid constr_type value. Possible values are:\n\n' \ + + ',\n'.join(constr_types) + '.\n\nYou have: ' + constr_type + '.\n\nExiting.') + + @constr_type_e.setter + def constr_type_e(self, constr_type_e): + constr_types = ('BGH', 'BGP') + if constr_type_e in constr_types: + self.__constr_type_e = constr_type_e + else: + raise Exception('Invalid constr_type_e value. Possible values are:\n\n' \ + + ',\n'.join(constr_types) + '.\n\nYou have: ' + constr_type_e + '.\n\nExiting.') + + # initial x + @lbx_0.setter + def lbx_0(self, lbx_0): + if type(lbx_0) == np.ndarray: + self.__lbx_0 = lbx_0 + else: + raise Exception('Invalid lbx_0 value. Exiting.') + + @ubx_0.setter + def ubx_0(self, ubx_0): + if type(ubx_0) == np.ndarray: + self.__ubx_0 = ubx_0 + else: + raise Exception('Invalid ubx_0 value. Exiting.') + + @idxbx_0.setter + def idxbx_0(self, idxbx_0): + if isinstance(idxbx_0, np.ndarray): + self.__idxbx_0 = idxbx_0 + else: + raise Exception('Invalid idxbx_0 value. Exiting.') + + @Jbx_0.setter + def Jbx_0(self, Jbx_0): + if type(Jbx_0) == np.ndarray: + self.__idxbx_0 = J_to_idx(Jbx_0) + else: + raise Exception('Invalid Jbx_0 value. Exiting.') + + @idxbxe_0.setter + def idxbxe_0(self, idxbxe_0): + if isinstance(idxbxe_0, np.ndarray): + self.__idxbxe_0 = idxbxe_0 + else: + raise Exception('Invalid idxbxe_0 value. Exiting.') + + + @x0.setter + def x0(self, x0): + if isinstance(x0, np.ndarray): + self.__lbx_0 = x0 + self.__ubx_0 = x0 + self.__idxbx_0 = np.arange(x0.size) + self.__idxbxe_0 = np.arange(x0.size) + else: + raise Exception('Invalid x0 value. Exiting.') + + # bounds on x + @lbx.setter + def lbx(self, lbx): + if type(lbx) == np.ndarray: + self.__lbx = lbx + else: + raise Exception('Invalid lbx value. Exiting.') + + @ubx.setter + def ubx(self, ubx): + if type(ubx) == np.ndarray: + self.__ubx = ubx + else: + raise Exception('Invalid ubx value. Exiting.') + + @idxbx.setter + def idxbx(self, idxbx): + if type(idxbx) == np.ndarray: + self.__idxbx = idxbx + else: + raise Exception('Invalid idxbx value. Exiting.') + + @Jbx.setter + def Jbx(self, Jbx): + if type(Jbx) == np.ndarray: + self.__idxbx = J_to_idx(Jbx) + else: + raise Exception('Invalid Jbx value. Exiting.') + + # bounds on u + @lbu.setter + def lbu(self, lbu): + if type(lbu) == np.ndarray: + self.__lbu = lbu + else: + raise Exception('Invalid lbu value. Exiting.') + + @ubu.setter + def ubu(self, ubu): + if type(ubu) == np.ndarray: + self.__ubu = ubu + else: + raise Exception('Invalid ubu value. Exiting.') + + @idxbu.setter + def idxbu(self, idxbu): + if type(idxbu) == np.ndarray: + self.__idxbu = idxbu + else: + raise Exception('Invalid idxbu value. Exiting.') + + @Jbu.setter + def Jbu(self, Jbu): + if type(Jbu) == np.ndarray: + self.__idxbu = J_to_idx(Jbu) + else: + raise Exception('Invalid Jbu value. Exiting.') + + # bounds on x at shooting node N + @lbx_e.setter + def lbx_e(self, lbx_e): + if type(lbx_e) == np.ndarray: + self.__lbx_e = lbx_e + else: + raise Exception('Invalid lbx_e value. Exiting.') + + @ubx_e.setter + def ubx_e(self, ubx_e): + if type(ubx_e) == np.ndarray: + self.__ubx_e = ubx_e + else: + raise Exception('Invalid ubx_e value. Exiting.') + + @idxbx_e.setter + def idxbx_e(self, idxbx_e): + if type(idxbx_e) == np.ndarray: + self.__idxbx_e = idxbx_e + else: + raise Exception('Invalid idxbx_e value. Exiting.') + + @Jbx_e.setter + def Jbx_e(self, Jbx_e): + if type(Jbx_e) == np.ndarray: + self.__idxbx_e = J_to_idx(Jbx_e) + else: + raise Exception('Invalid Jbx_e value. Exiting.') + + # polytopic constraints + @D.setter + def D(self, D): + if isinstance(D, np.ndarray) and len(D.shape) == 2: + self.__D = D + else: + raise Exception('Invalid constraint D value.' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @C.setter + def C(self, C): + if isinstance(C, np.ndarray) and len(C.shape) == 2: + self.__C = C + else: + raise Exception('Invalid constraint C value.' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @lg.setter + def lg(self, lg): + if type(lg) == np.ndarray: + self.__lg = lg + else: + raise Exception('Invalid lg value. Exiting.') + + @ug.setter + def ug(self, ug): + if type(ug) == np.ndarray: + self.__ug = ug + else: + raise Exception('Invalid ug value. Exiting.') + + # polytopic constraints at shooting node N + @C_e.setter + def C_e(self, C_e): + if isinstance(C_e, np.ndarray) and len(C_e.shape) == 2: + self.__C_e = C_e + else: + raise Exception('Invalid constraint C_e value.' \ + + 'Should be 2 dimensional numpy array. Exiting.') + + @lg_e.setter + def lg_e(self, lg_e): + if type(lg_e) == np.ndarray: + self.__lg_e = lg_e + else: + raise Exception('Invalid lg_e value. Exiting.') + + @ug_e.setter + def ug_e(self, ug_e): + if type(ug_e) == np.ndarray: + self.__ug_e = ug_e + else: + raise Exception('Invalid ug_e value. Exiting.') + + # nonlinear constraints + @lh.setter + def lh(self, lh): + if type(lh) == np.ndarray: + self.__lh = lh + else: + raise Exception('Invalid lh value. Exiting.') + + @uh.setter + def uh(self, uh): + if type(uh) == np.ndarray: + self.__uh = uh + else: + raise Exception('Invalid uh value. Exiting.') + + # convex-over-nonlinear constraints + @lphi.setter + def lphi(self, lphi): + if type(lphi) == np.ndarray: + self.__lphi = lphi + else: + raise Exception('Invalid lphi value. Exiting.') + + @uphi.setter + def uphi(self, uphi): + if type(uphi) == np.ndarray: + self.__uphi = uphi + else: + raise Exception('Invalid uphi value. Exiting.') + + # nonlinear constraints at shooting node N + @lh_e.setter + def lh_e(self, lh_e): + if type(lh_e) == np.ndarray: + self.__lh_e = lh_e + else: + raise Exception('Invalid lh_e value. Exiting.') + + @uh_e.setter + def uh_e(self, uh_e): + if type(uh_e) == np.ndarray: + self.__uh_e = uh_e + else: + raise Exception('Invalid uh_e value. Exiting.') + + # convex-over-nonlinear constraints at shooting node N + @lphi_e.setter + def lphi_e(self, lphi_e): + if type(lphi_e) == np.ndarray: + self.__lphi_e = lphi_e + else: + raise Exception('Invalid lphi_e value. Exiting.') + + @uphi_e.setter + def uphi_e(self, uphi_e): + if type(uphi_e) == np.ndarray: + self.__uphi_e = uphi_e + else: + raise Exception('Invalid uphi_e value. Exiting.') + + # SLACK bounds + # soft bounds on x + @lsbx.setter + def lsbx(self, lsbx): + if type(lsbx) == np.ndarray: + self.__lsbx = lsbx + else: + raise Exception('Invalid lsbx value. Exiting.') + + @usbx.setter + def usbx(self, usbx): + if type(usbx) == np.ndarray: + self.__usbx = usbx + else: + raise Exception('Invalid usbx value. Exiting.') + + @idxsbx.setter + def idxsbx(self, idxsbx): + if type(idxsbx) == np.ndarray: + self.__idxsbx = idxsbx + else: + raise Exception('Invalid idxsbx value. Exiting.') + + @Jsbx.setter + def Jsbx(self, Jsbx): + if isinstance(Jsbx, np.ndarray): + self.__idxsbx = J_to_idx_slack(Jsbx) + else: + raise Exception('Invalid Jsbx value, expected numpy array. Exiting.') + + # soft bounds on u + @lsbu.setter + def lsbu(self, lsbu): + if type(lsbu) == np.ndarray: + self.__lsbu = lsbu + else: + raise Exception('Invalid lsbu value. Exiting.') + + @usbu.setter + def usbu(self, usbu): + if type(usbu) == np.ndarray: + self.__usbu = usbu + else: + raise Exception('Invalid usbu value. Exiting.') + + @idxsbu.setter + def idxsbu(self, idxsbu): + if type(idxsbu) == np.ndarray: + self.__idxsbu = idxsbu + else: + raise Exception('Invalid idxsbu value. Exiting.') + + @Jsbu.setter + def Jsbu(self, Jsbu): + if type(Jsbu) == np.ndarray: + self.__idxsbu = J_to_idx_slack(Jsbu) + else: + raise Exception('Invalid Jsbu value. Exiting.') + + # soft bounds on x at shooting node N + @lsbx_e.setter + def lsbx_e(self, lsbx_e): + if type(lsbx_e) == np.ndarray: + self.__lsbx_e = lsbx_e + else: + raise Exception('Invalid lsbx_e value. Exiting.') + + @usbx_e.setter + def usbx_e(self, usbx_e): + if type(usbx_e) == np.ndarray: + self.__usbx_e = usbx_e + else: + raise Exception('Invalid usbx_e value. Exiting.') + + @idxsbx_e.setter + def idxsbx_e(self, idxsbx_e): + if type(idxsbx_e) == np.ndarray: + self.__idxsbx_e = idxsbx_e + else: + raise Exception('Invalid idxsbx_e value. Exiting.') + + @Jsbx_e.setter + def Jsbx_e(self, Jsbx_e): + if type(Jsbx_e) == np.ndarray: + self.__idxsbx_e = J_to_idx_slack(Jsbx_e) + else: + raise Exception('Invalid Jsbx_e value. Exiting.') + + + # soft bounds on general linear constraints + @lsg.setter + def lsg(self, lsg): + if isinstance(lsg, np.ndarray): + self.__lsg = lsg + else: + raise Exception('Invalid lsg value. Exiting.') + + @usg.setter + def usg(self, usg): + if isinstance(usg, np.ndarray): + self.__usg = usg + else: + raise Exception('Invalid usg value. Exiting.') + + @idxsg.setter + def idxsg(self, idxsg): + if isinstance(idxsg, np.ndarray): + self.__idxsg = idxsg + else: + raise Exception('Invalid idxsg value. Exiting.') + + @Jsg.setter + def Jsg(self, Jsg): + if isinstance(Jsg, np.ndarray): + self.__idxsg = J_to_idx_slack(Jsg) + else: + raise Exception('Invalid Jsg value, expected numpy array. Exiting.') + + + # soft bounds on nonlinear constraints + @lsh.setter + def lsh(self, lsh): + if type(lsh) == np.ndarray: + self.__lsh = lsh + else: + raise Exception('Invalid lsh value. Exiting.') + + @ush.setter + def ush(self, ush): + if type(ush) == np.ndarray: + self.__ush = ush + else: + raise Exception('Invalid ush value. Exiting.') + + @idxsh.setter + def idxsh(self, idxsh): + if type(idxsh) == np.ndarray: + self.__idxsh = idxsh + else: + raise Exception('Invalid idxsh value. Exiting.') + + + @Jsh.setter + def Jsh(self, Jsh): + if isinstance(Jsh, np.ndarray): + self.__idxsh = J_to_idx_slack(Jsh) + else: + raise Exception('Invalid Jsh value, expected numpy array. Exiting.') + + # soft bounds on convex-over-nonlinear constraints + @lsphi.setter + def lsphi(self, lsphi): + if type(lsphi) == np.ndarray: + self.__lsphi = lsphi + else: + raise Exception('Invalid lsphi value. Exiting.') + + @usphi.setter + def usphi(self, usphi): + if type(usphi) == np.ndarray: + self.__usphi = usphi + else: + raise Exception('Invalid usphi value. Exiting.') + + @idxsphi.setter + def idxsphi(self, idxsphi): + if type(idxsphi) == np.ndarray: + self.__idxsphi = idxsphi + else: + raise Exception('Invalid idxsphi value. Exiting.') + + @Jsphi.setter + def Jsphi(self, Jsphi): + if isinstance(Jsphi, np.ndarray): + self.__idxsphi = J_to_idx_slack(Jsphi) + else: + raise Exception('Invalid Jsphi value, expected numpy array. Exiting.') + + # soft bounds on general linear constraints at shooting node N + @lsg_e.setter + def lsg_e(self, lsg_e): + if isinstance(lsg_e, np.ndarray): + self.__lsg_e = lsg_e + else: + raise Exception('Invalid lsg_e value. Exiting.') + + @usg_e.setter + def usg_e(self, usg_e): + if isinstance(usg_e, np.ndarray): + self.__usg_e = usg_e + else: + raise Exception('Invalid usg_e value. Exiting.') + + @idxsg_e.setter + def idxsg_e(self, idxsg_e): + if isinstance(idxsg_e, np.ndarray): + self.__idxsg_e = idxsg_e + else: + raise Exception('Invalid idxsg_e value. Exiting.') + + @Jsg_e.setter + def Jsg_e(self, Jsg_e): + if isinstance(Jsg_e, np.ndarray): + self.__idxsg_e = J_to_idx_slack(Jsg_e) + else: + raise Exception('Invalid Jsg_e value, expected numpy array. Exiting.') + + # soft bounds on nonlinear constraints at shooting node N + @lsh_e.setter + def lsh_e(self, lsh_e): + if isinstance(lsh_e, np.ndarray): + self.__lsh_e = lsh_e + else: + raise Exception('Invalid lsh_e value. Exiting.') + + @ush_e.setter + def ush_e(self, ush_e): + if isinstance(ush_e, np.ndarray): + self.__ush_e = ush_e + else: + raise Exception('Invalid ush_e value. Exiting.') + + @idxsh_e.setter + def idxsh_e(self, idxsh_e): + if isinstance(idxsh_e, np.ndarray): + self.__idxsh_e = idxsh_e + else: + raise Exception('Invalid idxsh_e value. Exiting.') + + @Jsh_e.setter + def Jsh_e(self, Jsh_e): + if isinstance(Jsh_e, np.ndarray): + self.__idxsh_e = J_to_idx_slack(Jsh_e) + else: + raise Exception('Invalid Jsh_e value, expected numpy array. Exiting.') + + + # soft bounds on convex-over-nonlinear constraints at shooting node N + @lsphi_e.setter + def lsphi_e(self, lsphi_e): + if isinstance(lsphi_e, np.ndarray): + self.__lsphi_e = lsphi_e + else: + raise Exception('Invalid lsphi_e value. Exiting.') + + @usphi_e.setter + def usphi_e(self, usphi_e): + if isinstance(usphi_e, np.ndarray): + self.__usphi_e = usphi_e + else: + raise Exception('Invalid usphi_e value. Exiting.') + + @idxsphi_e.setter + def idxsphi_e(self, idxsphi_e): + if isinstance(idxsphi_e, np.ndarray): + self.__idxsphi_e = idxsphi_e + else: + raise Exception('Invalid idxsphi_e value. Exiting.') + + @Jsphi_e.setter + def Jsphi_e(self, Jsphi_e): + if isinstance(Jsphi_e, np.ndarray): + self.__idxsphi_e = J_to_idx_slack(Jsphi_e) + else: + raise Exception('Invalid Jsphi_e value. Exiting.') + + def set(self, attr, value): + setattr(self, attr, value) + + +class AcadosOcpOptions: + """ + class containing the description of the solver options + """ + def __init__(self): + self.__qp_solver = 'PARTIAL_CONDENSING_HPIPM' # qp solver to be used in the NLP solver + self.__hessian_approx = 'GAUSS_NEWTON' # hessian approximation + self.__integrator_type = 'ERK' # integrator type + self.__tf = None # prediction horizon + self.__nlp_solver_type = 'SQP_RTI' # NLP solver + self.__globalization = 'FIXED_STEP' + self.__nlp_solver_step_length = 1.0 # fixed Newton step length + self.__levenberg_marquardt = 0.0 + self.__collocation_type = 'GAUSS_LEGENDRE' + self.__sim_method_num_stages = 4 # number of stages in the integrator + self.__sim_method_num_steps = 1 # number of steps in the integrator + self.__sim_method_newton_iter = 3 # number of Newton iterations in simulation method + self.__sim_method_jac_reuse = 0 + self.__qp_solver_tol_stat = None # QP solver stationarity tolerance + self.__qp_solver_tol_eq = None # QP solver equality tolerance + self.__qp_solver_tol_ineq = None # QP solver inequality + self.__qp_solver_tol_comp = None # QP solver complementarity + self.__qp_solver_iter_max = 50 # QP solver max iter + self.__qp_solver_cond_N = None # QP solver: new horizon after partial condensing + self.__qp_solver_warm_start = 0 + self.__nlp_solver_tol_stat = 1e-6 # NLP solver stationarity tolerance + self.__nlp_solver_tol_eq = 1e-6 # NLP solver equality tolerance + self.__nlp_solver_tol_ineq = 1e-6 # NLP solver inequality + self.__nlp_solver_tol_comp = 1e-6 # NLP solver complementarity + self.__nlp_solver_max_iter = 100 # NLP solver maximum number of iterations + self.__Tsim = None # automatically calculated as tf/N + self.__print_level = 0 # print level + self.__initialize_t_slacks = 0 # possible values: 0, 1 + self.__model_external_shared_lib_dir = None # path to the the .so lib + self.__model_external_shared_lib_name = None # name of the the .so lib + self.__regularize_method = None + self.__time_steps = None + self.__shooting_nodes = None + self.__exact_hess_cost = 1 + self.__exact_hess_dyn = 1 + self.__exact_hess_constr = 1 + self.__ext_cost_num_hess = 0 + self.__alpha_min = 0.05 + self.__alpha_reduction = 0.7 + + + @property + def qp_solver(self): + """QP solver to be used in the NLP solver. + String in ('PARTIAL_CONDENSING_HPIPM', 'FULL_CONDENSING_QPOASES', 'FULL_CONDENSING_HPIPM', 'PARTIAL_CONDENSING_QPDUNES', 'PARTIAL_CONDENSING_OSQP'). + Default: 'PARTIAL_CONDENSING_HPIPM'. + """ + return self.__qp_solver + + @property + def hessian_approx(self): + """Hessian approximation. + String in ('GAUSS_NEWTON', 'EXACT'). + Default: 'GAUSS_NEWTON'. + """ + return self.__hessian_approx + + @property + def integrator_type(self): + """ + Integrator type. + String in ('ERK', 'IRK', 'GNSF', 'DISCRETE', 'LIFTED_IRK'). + Default: 'ERK'. + """ + return self.__integrator_type + + @property + def nlp_solver_type(self): + """NLP solver. + String in ('SQP', 'SQP_RTI'). + Default: 'SQP_RTI'. + """ + return self.__nlp_solver_type + + @property + def globalization(self): + """Globalization type. + String in ('FIXED_STEP', 'MERIT_BACKTRACKING'). + Default: 'FIXED_STEP'. + + .. note:: preliminary implementation. + """ + return self.__globalization + + @property + def collocation_type(self): + """Collocation type: relevant for implicit integrators + -- string in {GAUSS_RADAU_IIA, GAUSS_LEGENDRE}. + + Default: GAUSS_LEGENDRE + """ + return self.__collocation_type + + @property + def regularize_method(self): + """Regularization method for the Hessian. + String in ('NO_REGULARIZE', 'MIRROR', 'PROJECT', 'PROJECT_REDUC_HESS', 'CONVEXIFY') or :code:`None`. + + Default: :code:`None`. + """ + return self.__regularize_method + + @property + def nlp_solver_step_length(self): + """ + Fixed Newton step length. + Type: float > 0. + Default: 1.0. + """ + return self.__nlp_solver_step_length + + @property + def levenberg_marquardt(self): + """ + Factor for LM regularization. + Type: float >= 0 + Default: 0.0. + """ + return self.__levenberg_marquardt + + @property + def sim_method_num_stages(self): + """ + Number of stages in the integrator. + Type: int > 0 or ndarray of ints > 0 of shape (N,). + Default: 4 + """ + return self.__sim_method_num_stages + + @property + def sim_method_num_steps(self): + """ + Number of steps in the integrator. + Type: int > 0 or ndarray of ints > 0 of shape (N,). + Default: 1 + """ + return self.__sim_method_num_steps + + @property + def sim_method_newton_iter(self): + """ + Number of Newton iterations in simulation method. + Type: int > 0 + Default: 3 + """ + return self.__sim_method_newton_iter + + @property + def sim_method_jac_reuse(self): + """ + Integer determining if jacobians are reused within integrator or ndarray of ints > 0 of shape (N,). + 0: False (no reuse); 1: True (reuse) + Default: 0 + """ + return self.__sim_method_jac_reuse + + @property + def qp_solver_tol_stat(self): + """ + QP solver stationarity tolerance. + Default: :code:`None` + """ + return self.__qp_solver_tol_stat + + @property + def qp_solver_tol_eq(self): + """ + QP solver equality tolerance. + Default: :code:`None` + """ + return self.__qp_solver_tol_eq + + @property + def qp_solver_tol_ineq(self): + """ + QP solver inequality. + Default: :code:`None` + """ + return self.__qp_solver_tol_ineq + + @property + def qp_solver_tol_comp(self): + """ + QP solver complementarity. + Default: :code:`None` + """ + return self.__qp_solver_tol_comp + + @property + def qp_solver_cond_N(self): + """QP solver: New horizon after partial condensing. + Set to N by default -> no condensing.""" + return self.__qp_solver_cond_N + + @property + def qp_solver_warm_start(self): + """QP solver: Warm starting. + 0: no warm start; 1: warm start; 2: hot start.""" + return self.__qp_solver_warm_start + + @property + def qp_solver_iter_max(self): + """ + QP solver: maximum number of iterations. + Type: int > 0 + Default: 50 + """ + return self.__qp_solver_iter_max + + @property + def tol(self): + """ + NLP solver tolerance. Sets or gets the max of :py:attr:`nlp_solver_tol_eq`, + :py:attr:`nlp_solver_tol_ineq`, :py:attr:`nlp_solver_tol_comp` + and :py:attr:`nlp_solver_tol_stat`. + """ + return max([self.__nlp_solver_tol_eq, self.__nlp_solver_tol_ineq,\ + self.__nlp_solver_tol_comp, self.__nlp_solver_tol_stat]) + + @property + def qp_tol(self): + """ + QP solver tolerance. + Sets all of the following at once or gets the max of + :py:attr:`qp_solver_tol_eq`, :py:attr:`qp_solver_tol_ineq`, + :py:attr:`qp_solver_tol_comp` and + :py:attr:`qp_solver_tol_stat`. + """ + return max([self.__qp_solver_tol_eq, self.__qp_solver_tol_ineq,\ + self.__qp_solver_tol_comp, self.__qp_solver_tol_stat]) + + @property + def nlp_solver_tol_stat(self): + """ + NLP solver stationarity tolerance. + Type: float > 0 + Default: 1e-6 + """ + return self.__nlp_solver_tol_stat + + @property + def nlp_solver_tol_eq(self): + """NLP solver equality tolerance""" + return self.__nlp_solver_tol_eq + + @property + def alpha_min(self): + """Minimal step size for globalization MERIT_BACKTRACKING, default: 0.05.""" + return self.__alpha_min + + @property + def alpha_reduction(self): + """Step size reduction factor for globalization MERIT_BACKTRACKING, default: 0.7.""" + return self.__alpha_reduction + + @property + def nlp_solver_tol_ineq(self): + """NLP solver inequality tolerance""" + return self.__nlp_solver_tol_ineq + + @property + def nlp_solver_tol_comp(self): + """NLP solver complementarity tolerance""" + return self.__nlp_solver_tol_comp + + @property + def nlp_solver_max_iter(self): + """ + NLP solver maximum number of iterations. + Type: int > 0 + Default: 100 + """ + return self.__nlp_solver_max_iter + + @property + def time_steps(self): + """ + Vector with time steps between the shooting nodes. Set automatically to uniform discretization if :py:attr:`N` and :py:attr:`tf` are provided. + Default: :code:`None` + """ + return self.__time_steps + + @property + def shooting_nodes(self): + """ + Vector with the shooting nodes, time_steps will be computed from it automatically. + Default: :code:`None` + """ + return self.__shooting_nodes + + @property + def tf(self): + """ + Prediction horizon + Type: float > 0 + Default: :code:`None` + """ + return self.__tf + + @property + def Tsim(self): + """ + Time horizon for one integrator step. Automatically calculated as :py:attr:`tf`/:py:attr:`N`. + Default: :code:`None` + """ + return self.__Tsim + + @property + def print_level(self): + """ + Verbosity of printing. + Type: int >= 0 + Default: 0 + """ + return self.__print_level + + @property + def model_external_shared_lib_dir(self): + """Path to the .so lib""" + return self.__model_external_shared_lib_dir + + @property + def model_external_shared_lib_name(self): + """Name of the .so lib""" + return self.__model_external_shared_lib_name + + @property + def exact_hess_constr(self): + """ + Used in case of hessian_approx == 'EXACT'.\n + Can be used to turn off exact hessian contributions from the constraints module. + """ + return self.__exact_hess_constr + + @property + def exact_hess_cost(self): + """ + Used in case of hessian_approx == 'EXACT'.\n + Can be used to turn off exact hessian contributions from the cost module. + """ + return self.__exact_hess_cost + + @property + def exact_hess_dyn(self): + """ + Used in case of hessian_approx == 'EXACT'.\n + Can be used to turn off exact hessian contributions from the dynamics module. + """ + return self.__exact_hess_dyn + + @property + def ext_cost_num_hess(self): + """ + Determines if custom hessian approximation for cost contribution is used (> 0).\n + Or if hessian contribution is evaluated exactly using CasADi external function (=0 - default). + """ + return self.__ext_cost_num_hess + + @qp_solver.setter + def qp_solver(self, qp_solver): + qp_solvers = ('PARTIAL_CONDENSING_HPIPM', \ + 'FULL_CONDENSING_QPOASES', 'FULL_CONDENSING_HPIPM', \ + 'PARTIAL_CONDENSING_QPDUNES', 'PARTIAL_CONDENSING_OSQP') + if qp_solver in qp_solvers: + self.__qp_solver = qp_solver + else: + raise Exception('Invalid qp_solver value. Possible values are:\n\n' \ + + ',\n'.join(qp_solvers) + '.\n\nYou have: ' + qp_solver + '.\n\nExiting.') + + @regularize_method.setter + def regularize_method(self, regularize_method): + regularize_methods = ('NO_REGULARIZE', 'MIRROR', 'PROJECT', \ + 'PROJECT_REDUC_HESS', 'CONVEXIFY') + if regularize_method in regularize_methods: + self.__regularize_method = regularize_method + else: + raise Exception('Invalid regularize_method value. Possible values are:\n\n' \ + + ',\n'.join(regularize_methods) + '.\n\nYou have: ' + regularize_method + '.\n\nExiting.') + + @collocation_type.setter + def collocation_type(self, collocation_type): + collocation_types = ('GAUSS_RADAU_IIA', 'GAUSS_LEGENDRE') + if collocation_type in collocation_types: + self.__collocation_type = collocation_type + else: + raise Exception('Invalid collocation_type value. Possible values are:\n\n' \ + + ',\n'.join(collocation_types) + '.\n\nYou have: ' + collocation_type + '.\n\nExiting.') + + @hessian_approx.setter + def hessian_approx(self, hessian_approx): + hessian_approxs = ('GAUSS_NEWTON', 'EXACT') + if hessian_approx in hessian_approxs: + self.__hessian_approx = hessian_approx + else: + raise Exception('Invalid hessian_approx value. Possible values are:\n\n' \ + + ',\n'.join(hessian_approxs) + '.\n\nYou have: ' + hessian_approx + '.\n\nExiting.') + + @integrator_type.setter + def integrator_type(self, integrator_type): + integrator_types = ('ERK', 'IRK', 'GNSF', 'DISCRETE', 'LIFTED_IRK') + if integrator_type in integrator_types: + self.__integrator_type = integrator_type + else: + raise Exception('Invalid integrator_type value. Possible values are:\n\n' \ + + ',\n'.join(integrator_types) + '.\n\nYou have: ' + integrator_type + '.\n\nExiting.') + + @tf.setter + def tf(self, tf): + self.__tf = tf + + @time_steps.setter + def time_steps(self, time_steps): + self.__time_steps = time_steps + + @shooting_nodes.setter + def shooting_nodes(self, shooting_nodes): + self.__shooting_nodes = shooting_nodes + + + @Tsim.setter + def Tsim(self, Tsim): + self.__Tsim = Tsim + + @globalization.setter + def globalization(self, globalization): + self.__globalization = globalization + + @alpha_min.setter + def alpha_min(self, alpha_min): + self.__alpha_min = alpha_min + + @alpha_reduction.setter + def alpha_reduction(self, alpha_reduction): + self.__alpha_reduction = alpha_reduction + + @sim_method_num_stages.setter + def sim_method_num_stages(self, sim_method_num_stages): + + # if type(sim_method_num_stages) == int: + # self.__sim_method_num_stages = sim_method_num_stages + # else: + # raise Exception('Invalid sim_method_num_stages value. sim_method_num_stages must be an integer. Exiting.') + + self.__sim_method_num_stages = sim_method_num_stages + + @sim_method_num_steps.setter + def sim_method_num_steps(self, sim_method_num_steps): + + # if type(sim_method_num_steps) == int: + # self.__sim_method_num_steps = sim_method_num_steps + # else: + # raise Exception('Invalid sim_method_num_steps value. sim_method_num_steps must be an integer. Exiting.') + self.__sim_method_num_steps = sim_method_num_steps + + + @sim_method_newton_iter.setter + def sim_method_newton_iter(self, sim_method_newton_iter): + + if type(sim_method_newton_iter) == int: + self.__sim_method_newton_iter = sim_method_newton_iter + else: + raise Exception('Invalid sim_method_newton_iter value. sim_method_newton_iter must be an integer. Exiting.') + + @sim_method_jac_reuse.setter + def sim_method_jac_reuse(self, sim_method_jac_reuse): + # if sim_method_jac_reuse in (True, False): + self.__sim_method_jac_reuse = sim_method_jac_reuse + # else: + # raise Exception('Invalid sim_method_jac_reuse value. sim_method_jac_reuse must be a Boolean.') + + @nlp_solver_type.setter + def nlp_solver_type(self, nlp_solver_type): + nlp_solver_types = ('SQP', 'SQP_RTI') + if nlp_solver_type in nlp_solver_types: + self.__nlp_solver_type = nlp_solver_type + else: + raise Exception('Invalid nlp_solver_type value. Possible values are:\n\n' \ + + ',\n'.join(nlp_solver_types) + '.\n\nYou have: ' + nlp_solver_type + '.\n\nExiting.') + + @nlp_solver_step_length.setter + def nlp_solver_step_length(self, nlp_solver_step_length): + if type(nlp_solver_step_length) == float and nlp_solver_step_length > 0: + self.__nlp_solver_step_length = nlp_solver_step_length + else: + raise Exception('Invalid nlp_solver_step_length value. nlp_solver_step_length must be a positive float. Exiting') + + @levenberg_marquardt.setter + def levenberg_marquardt(self, levenberg_marquardt): + if isinstance(levenberg_marquardt, float) and levenberg_marquardt >= 0: + self.__levenberg_marquardt = levenberg_marquardt + else: + raise Exception('Invalid levenberg_marquardt value. levenberg_marquardt must be a positive float. Exiting') + + @qp_solver_iter_max.setter + def qp_solver_iter_max(self, qp_solver_iter_max): + if isinstance(qp_solver_iter_max, int) and qp_solver_iter_max > 0: + self.__qp_solver_iter_max = qp_solver_iter_max + else: + raise Exception('Invalid qp_solver_iter_max value. qp_solver_iter_max must be a positive int. Exiting') + + @qp_solver_cond_N.setter + def qp_solver_cond_N(self, qp_solver_cond_N): + if isinstance(qp_solver_cond_N, int) and qp_solver_cond_N > 0: + self.__qp_solver_cond_N = qp_solver_cond_N + else: + raise Exception('Invalid qp_solver_cond_N value. qp_solver_cond_N must be a positive int. Exiting') + + @qp_solver_warm_start.setter + def qp_solver_warm_start(self, qp_solver_warm_start): + if qp_solver_warm_start in [0, 1, 2]: + self.__qp_solver_warm_start = qp_solver_warm_start + else: + raise Exception('Invalid qp_solver_warm_start value. qp_solver_warm_start must be 0 or 1 or 2. Exiting') + + @qp_tol.setter + def qp_tol(self, qp_tol): + if isinstance(qp_tol, float) and qp_tol > 0: + self.__qp_solver_tol_eq = qp_tol + self.__qp_solver_tol_ineq = qp_tol + self.__qp_solver_tol_stat = qp_tol + self.__qp_solver_tol_comp = qp_tol + else: + raise Exception('Invalid qp_tol value. qp_tol must be a positive float. Exiting') + + @qp_solver_tol_stat.setter + def qp_solver_tol_stat(self, qp_solver_tol_stat): + if isinstance(qp_solver_tol_stat, float) and qp_solver_tol_stat > 0: + self.__qp_solver_tol_stat = qp_solver_tol_stat + else: + raise Exception('Invalid qp_solver_tol_stat value. qp_solver_tol_stat must be a positive float. Exiting') + + @qp_solver_tol_eq.setter + def qp_solver_tol_eq(self, qp_solver_tol_eq): + if isinstance(qp_solver_tol_eq, float) and qp_solver_tol_eq > 0: + self.__qp_solver_tol_eq = qp_solver_tol_eq + else: + raise Exception('Invalid qp_solver_tol_eq value. qp_solver_tol_eq must be a positive float. Exiting') + + @qp_solver_tol_ineq.setter + def qp_solver_tol_ineq(self, qp_solver_tol_ineq): + if isinstance(qp_solver_tol_ineq, float) and qp_solver_tol_ineq > 0: + self.__qp_solver_tol_ineq = qp_solver_tol_ineq + else: + raise Exception('Invalid qp_solver_tol_ineq value. qp_solver_tol_ineq must be a positive float. Exiting') + + @qp_solver_tol_comp.setter + def qp_solver_tol_comp(self, qp_solver_tol_comp): + if isinstance(qp_solver_tol_comp, float) and qp_solver_tol_comp > 0: + self.__qp_solver_tol_comp = qp_solver_tol_comp + else: + raise Exception('Invalid qp_solver_tol_comp value. qp_solver_tol_comp must be a positive float. Exiting') + + @tol.setter + def tol(self, tol): + if isinstance(tol, float) and tol > 0: + self.__nlp_solver_tol_eq = tol + self.__nlp_solver_tol_ineq = tol + self.__nlp_solver_tol_stat = tol + self.__nlp_solver_tol_comp = tol + else: + raise Exception('Invalid tol value. tol must be a positive float. Exiting') + + @nlp_solver_tol_stat.setter + def nlp_solver_tol_stat(self, nlp_solver_tol_stat): + if isinstance(nlp_solver_tol_stat, float) and nlp_solver_tol_stat > 0: + self.__nlp_solver_tol_stat = nlp_solver_tol_stat + else: + raise Exception('Invalid nlp_solver_tol_stat value. nlp_solver_tol_stat must be a positive float. Exiting') + + @nlp_solver_tol_eq.setter + def nlp_solver_tol_eq(self, nlp_solver_tol_eq): + if isinstance(nlp_solver_tol_eq, float) and nlp_solver_tol_eq > 0: + self.__nlp_solver_tol_eq = nlp_solver_tol_eq + else: + raise Exception('Invalid nlp_solver_tol_eq value. nlp_solver_tol_eq must be a positive float. Exiting') + + @nlp_solver_tol_ineq.setter + def nlp_solver_tol_ineq(self, nlp_solver_tol_ineq): + if isinstance(nlp_solver_tol_ineq, float) and nlp_solver_tol_ineq > 0: + self.__nlp_solver_tol_ineq = nlp_solver_tol_ineq + else: + raise Exception('Invalid nlp_solver_tol_ineq value. nlp_solver_tol_ineq must be a positive float. Exiting') + + @nlp_solver_tol_comp.setter + def nlp_solver_tol_comp(self, nlp_solver_tol_comp): + if isinstance(nlp_solver_tol_comp, float) and nlp_solver_tol_comp > 0: + self.__nlp_solver_tol_comp = nlp_solver_tol_comp + else: + raise Exception('Invalid nlp_solver_tol_comp value. nlp_solver_tol_comp must be a positive float. Exiting') + + @nlp_solver_max_iter.setter + def nlp_solver_max_iter(self, nlp_solver_max_iter): + + if type(nlp_solver_max_iter) == int and nlp_solver_max_iter > 0: + self.__nlp_solver_max_iter = nlp_solver_max_iter + else: + raise Exception('Invalid nlp_solver_max_iter value. nlp_solver_max_iter must be a positive int. Exiting') + + @print_level.setter + def print_level(self, print_level): + if type(print_level) == int and print_level >= 0: + self.__print_level = print_level + else: + raise Exception('Invalid print_level value. print_level takes one of the values >=0. Exiting') + + @model_external_shared_lib_dir.setter + def model_external_shared_lib_dir(self, model_external_shared_lib_dir): + if type(model_external_shared_lib_dir) == str : + self.__model_external_shared_lib_dir = model_external_shared_lib_dir + else: + raise Exception('Invalid model_external_shared_lib_dir value. Str expected.' \ + + '.\n\nYou have: ' + type(model_external_shared_lib_dir) + '.\n\nExiting.') + + @model_external_shared_lib_name.setter + def model_external_shared_lib_name(self, model_external_shared_lib_name): + if type(model_external_shared_lib_name) == str : + if model_external_shared_lib_name[-3:] == '.so' : + raise Exception('Invalid model_external_shared_lib_name value. Remove the .so extension.' \ + + '.\n\nYou have: ' + type(model_external_shared_lib_name) + '.\n\nExiting.') + else : + self.__model_external_shared_lib_name = model_external_shared_lib_name + else: + raise Exception('Invalid model_external_shared_lib_name value. Str expected.' \ + + '.\n\nYou have: ' + type(model_external_shared_lib_name) + '.\n\nExiting.') + + @exact_hess_constr.setter + def exact_hess_constr(self, exact_hess_constr): + if exact_hess_constr in [0, 1]: + self.__exact_hess_constr = exact_hess_constr + else: + raise Exception('Invalid exact_hess_constr value. exact_hess_constr takes one of the values 0, 1. Exiting') + + @exact_hess_cost.setter + def exact_hess_cost(self, exact_hess_cost): + if exact_hess_cost in [0, 1]: + self.__exact_hess_cost = exact_hess_cost + else: + raise Exception('Invalid exact_hess_cost value. exact_hess_cost takes one of the values 0, 1. Exiting') + + @exact_hess_dyn.setter + def exact_hess_dyn(self, exact_hess_dyn): + if exact_hess_dyn in [0, 1]: + self.__exact_hess_dyn = exact_hess_dyn + else: + raise Exception('Invalid exact_hess_dyn value. exact_hess_dyn takes one of the values 0, 1. Exiting') + + @ext_cost_num_hess.setter + def ext_cost_num_hess(self, ext_cost_num_hess): + if ext_cost_num_hess in [0, 1]: + self.__ext_cost_num_hess = ext_cost_num_hess + else: + raise Exception('Invalid ext_cost_num_hess value. ext_cost_num_hess takes one of the values 0, 1. Exiting') + + def set(self, attr, value): + setattr(self, attr, value) + + +class AcadosOcp: + """ + Class containing the full description of the optimal control problem. + This object can be used to create an :py:class:`acados_template.acados_ocp_solver.AcadosOcpSolver`. + + The class has the following properties that can be modified to formulate a specific OCP, see below: + + - :py:attr:`dims` of type :py:class:`acados_template.acados_ocp.AcadosOcpDims` + - :py:attr:`model` of type :py:class:`acados_template.acados_model.AcadosModel` + - :py:attr:`cost` of type :py:class:`acados_template.acados_ocp.AcadosOcpCost` + - :py:attr:`constraints` of type :py:class:`acados_template.acados_ocp.AcadosOcpConstraints` + - :py:attr:`solver_options` of type :py:class:`acados_template.acados_ocp.AcadosOcpOptions` + + - :py:attr:`acados_include_path` (set automatically) + - :py:attr:`acados_lib_path` (set automatically) + - :py:attr:`parameter_values` - used to initialize the parameters (can be changed) + """ + def __init__(self, acados_path=''): + """ + Keyword arguments: + acados_path -- path of your acados installation + """ + if acados_path == '': + acados_path = get_acados_path() + + self.dims = AcadosOcpDims() + """Dimension definitions, type :py:class:`acados_template.acados_ocp.AcadosOcpDims`""" + self.model = AcadosModel() + """Model definitions, type :py:class:`acados_template.acados_model.AcadosModel`""" + self.cost = AcadosOcpCost() + """Cost definitions, type :py:class:`acados_template.acados_ocp.AcadosOcpCost`""" + self.constraints = AcadosOcpConstraints() + """Constraints definitions, type :py:class:`acados_template.acados_ocp.AcadosOcpConstraints`""" + self.solver_options = AcadosOcpOptions() + """Solver Options, type :py:class:`acados_template.acados_ocp.AcadosOcpOptions`""" + + self.acados_include_path = f'{acados_path}/include' + """Path to acados include directory, type: string""" + self.acados_lib_path = f'{acados_path}/lib' + """Path to where acados library is located, type: string""" + + self.__parameter_values = np.array([]) + self.__problem_class = 'OCP' + + self.code_export_directory = 'c_generated_code' + """Path to where code will be exported. Default: `c_generated_code`.""" + + @property + def parameter_values(self): + """:math:`p` - initial values for parameter - can be updated stagewise""" + return self.__parameter_values + + @parameter_values.setter + def parameter_values(self, parameter_values): + if isinstance(parameter_values, np.ndarray): + self.__parameter_values = parameter_values + else: + raise Exception('Invalid parameter_values value. ' + + f'Expected numpy array, got {type(parameter_values)}.') + + def set(self, attr, value): + # tokenize string + tokens = attr.split('_', 1) + if len(tokens) > 1: + setter_to_call = getattr(getattr(self, tokens[0]), 'set') + else: + setter_to_call = getattr(self, 'set') + + setter_to_call(tokens[1], value) + + return diff --git a/pyextra/acados_template/acados_ocp_solver.py b/pyextra/acados_template/acados_ocp_solver.py new file mode 100644 index 00000000000000..b34b8fa84a096b --- /dev/null +++ b/pyextra/acados_template/acados_ocp_solver.py @@ -0,0 +1,1562 @@ +# -*- coding: future_fstrings -*- +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import sys +import os +import json +import numpy as np +from datetime import datetime +import ctypes +from ctypes import POINTER, cast, CDLL, c_void_p, c_char_p, c_double, c_int, c_int64, byref + +from copy import deepcopy + +from .generate_c_code_explicit_ode import generate_c_code_explicit_ode +from .generate_c_code_implicit_ode import generate_c_code_implicit_ode +from .generate_c_code_gnsf import generate_c_code_gnsf +from .generate_c_code_discrete_dynamics import generate_c_code_discrete_dynamics +from .generate_c_code_constraint import generate_c_code_constraint +from .generate_c_code_nls_cost import generate_c_code_nls_cost +from .generate_c_code_external_cost import generate_c_code_external_cost +from .acados_ocp import AcadosOcp +from .acados_model import acados_model_strip_casadi_symbolics +from .utils import is_column, is_empty, casadi_length, render_template, acados_class2dict,\ + format_class_dict, ocp_check_against_layout, np_array_to_list, make_model_consistent,\ + set_up_imported_gnsf_model, get_acados_path, get_ocp_nlp_layout, get_python_interface_path + + +def make_ocp_dims_consistent(acados_ocp): + dims = acados_ocp.dims + cost = acados_ocp.cost + constraints = acados_ocp.constraints + model = acados_ocp.model + opts = acados_ocp.solver_options + + # nx + if is_column(model.x): + dims.nx = casadi_length(model.x) + else: + raise Exception('model.x should be column vector!') + + # nu + if is_empty(model.u): + dims.nu = 0 + else: + dims.nu = casadi_length(model.u) + + # nz + if is_empty(model.z): + dims.nz = 0 + else: + dims.nz = casadi_length(model.z) + + # np + if is_empty(model.p): + dims.np = 0 + else: + dims.np = casadi_length(model.p) + if acados_ocp.parameter_values.shape[0] != dims.np: + raise Exception('inconsistent dimension np, regarding model.p and parameter_values.' + \ + f'\nGot np = {dims.np}, acados_ocp.parameter_values.shape = {acados_ocp.parameter_values.shape[0]}\n') + + # cost + # initial stage - if not set, copy fields from path constraints + if cost.cost_type_0 is None: + cost.cost_type_0 = cost.cost_type + cost.W_0 = cost.W + cost.Vx_0 = cost.Vx + cost.Vu_0 = cost.Vu + cost.Vz_0 = cost.Vz + cost.yref_0 = cost.yref + cost.cost_ext_fun_type_0 = cost.cost_ext_fun_type + model.cost_y_expr_0 = model.cost_y_expr + model.cost_expr_ext_cost_0 = model.cost_expr_ext_cost + model.cost_expr_ext_cost_custom_hess_0 = model.cost_expr_ext_cost_custom_hess + + if cost.cost_type_0 == 'LINEAR_LS': + ny_0 = cost.W_0.shape[0] + if cost.Vx_0.shape[0] != ny_0 or cost.Vu_0.shape[0] != ny_0: + raise Exception('inconsistent dimension ny_0, regarding W_0, Vx_0, Vu_0.' + \ + f'\nGot W_0[{cost.W_0.shape}], Vx_0[{cost.Vx_0.shape}], Vu_0[{cost.Vu_0.shape}]\n') + if dims.nz != 0 and cost.Vz_0.shape[0] != ny_0: + raise Exception('inconsistent dimension ny_0, regarding W_0, Vx_0, Vu_0, Vz_0.' + \ + f'\nGot W_0[{cost.W_0.shape}], Vx_0[{cost.Vx_0.shape}], Vu_0[{cost.Vu_0.shape}], Vz_0[{cost.Vz_0.shape}]\n') + if cost.Vx_0.shape[1] != dims.nx and ny_0 != 0: + raise Exception('inconsistent dimension: Vx_0 should have nx columns.') + if cost.Vu_0.shape[1] != dims.nu and ny_0 != 0: + raise Exception('inconsistent dimension: Vu_0 should have nu columns.') + if cost.yref_0.shape[0] != ny_0: + raise Exception('inconsistent dimension: regarding W_0, yref_0.' + \ + f'\nGot W_0[{cost.W_0.shape}], yref_0[{cost.yref_0.shape}]\n') + dims.ny_0 = ny_0 + + elif cost.cost_type_0 == 'NONLINEAR_LS': + ny_0 = cost.W_0.shape[0] + if is_empty(model.cost_y_expr_0) and ny_0 != 0: + raise Exception('inconsistent dimension ny_0: regarding W_0, cost_y_expr.') + elif casadi_length(model.cost_y_expr_0) != ny_0: + raise Exception('inconsistent dimension ny_0: regarding W_0, cost_y_expr.') + if cost.yref_0.shape[0] != ny_0: + raise Exception('inconsistent dimension: regarding W_0, yref_0.' + \ + f'\nGot W_0[{cost.W.shape}], yref_0[{cost.yref_0.shape}]\n') + dims.ny_0 = ny_0 + + # path + if cost.cost_type == 'LINEAR_LS': + ny = cost.W.shape[0] + if cost.Vx.shape[0] != ny or cost.Vu.shape[0] != ny: + raise Exception('inconsistent dimension ny, regarding W, Vx, Vu.' + \ + f'\nGot W[{cost.W.shape}], Vx[{cost.Vx.shape}], Vu[{cost.Vu.shape}]\n') + if dims.nz != 0 and cost.Vz.shape[0] != ny: + raise Exception('inconsistent dimension ny, regarding W, Vx, Vu, Vz.' + \ + f'\nGot W[{cost.W.shape}], Vx[{cost.Vx.shape}], Vu[{cost.Vu.shape}], Vz[{cost.Vz.shape}]\n') + if cost.Vx.shape[1] != dims.nx and ny != 0: + raise Exception('inconsistent dimension: Vx should have nx columns.') + if cost.Vu.shape[1] != dims.nu and ny != 0: + raise Exception('inconsistent dimension: Vu should have nu columns.') + if cost.yref.shape[0] != ny: + raise Exception('inconsistent dimension: regarding W, yref.' + \ + f'\nGot W[{cost.W.shape}], yref[{cost.yref.shape}]\n') + dims.ny = ny + + elif cost.cost_type == 'NONLINEAR_LS': + ny = cost.W.shape[0] + if is_empty(model.cost_y_expr) and ny != 0: + raise Exception('inconsistent dimension ny: regarding W, cost_y_expr.') + elif casadi_length(model.cost_y_expr) != ny: + raise Exception('inconsistent dimension ny: regarding W, cost_y_expr.') + if cost.yref.shape[0] != ny: + raise Exception('inconsistent dimension: regarding W, yref.' + \ + f'\nGot W[{cost.W.shape}], yref[{cost.yref.shape}]\n') + dims.ny = ny + + # terminal + if cost.cost_type_e == 'LINEAR_LS': + ny_e = cost.W_e.shape[0] + if cost.Vx_e.shape[0] != ny_e: + raise Exception('inconsistent dimension ny_e: regarding W_e, cost_y_expr_e.' + \ + f'\nGot W_e[{cost.W_e.shape}], Vx_e[{cost.Vx_e.shape}]') + if cost.Vx_e.shape[1] != dims.nx and ny_e != 0: + raise Exception('inconsistent dimension: Vx_e should have nx columns.') + if cost.yref_e.shape[0] != ny_e: + raise Exception('inconsistent dimension: regarding W_e, yref_e.') + dims.ny_e = ny_e + + elif cost.cost_type_e == 'NONLINEAR_LS': + ny_e = cost.W_e.shape[0] + if is_empty(model.cost_y_expr_e) and ny_e != 0: + raise Exception('inconsistent dimension ny_e: regarding W_e, cost_y_expr_e.') + elif casadi_length(model.cost_y_expr_e) != ny_e: + raise Exception('inconsistent dimension ny_e: regarding W_e, cost_y_expr_e.') + if cost.yref_e.shape[0] != ny_e: + raise Exception('inconsistent dimension: regarding W_e, yref_e.') + dims.ny_e = ny_e + + + ## constraints + # initial + if (constraints.lbx_0 == [] and constraints.ubx_0 == []): + dims.nbx_0 = 0 + else: + this_shape = constraints.lbx_0.shape + other_shape = constraints.ubx_0.shape + if not this_shape == other_shape: + raise Exception('lbx_0, ubx_0 have different shapes!') + if not is_column(constraints.lbx_0): + raise Exception('lbx_0, ubx_0 must be column vectors!') + dims.nbx_0 = constraints.lbx_0.size + + if all(constraints.lbx_0 == constraints.ubx_0) and dims.nbx_0 == dims.nx \ + and dims.nbxe_0 is None \ + and (constraints.idxbxe_0.shape == constraints.idxbx_0.shape)\ + and all(constraints.idxbxe_0 == constraints.idxbx_0): + # case: x0 was set: nbx0 are all equlities. + dims.nbxe_0 = dims.nbx_0 + elif dims.nbxe_0 is None: + # case: x0 was not set -> dont assume nbx0 to be equality constraints. + dims.nbxe_0 = 0 + + # path + nbx = constraints.idxbx.shape[0] + if constraints.ubx.shape[0] != nbx or constraints.lbx.shape[0] != nbx: + raise Exception('inconsistent dimension nbx, regarding idxbx, ubx, lbx.') + else: + dims.nbx = nbx + + nbu = constraints.idxbu.shape[0] + if constraints.ubu.shape[0] != nbu or constraints.lbu.shape[0] != nbu: + raise Exception('inconsistent dimension nbu, regarding idxbu, ubu, lbu.') + else: + dims.nbu = nbu + + ng = constraints.lg.shape[0] + if constraints.ug.shape[0] != ng or constraints.C.shape[0] != ng \ + or constraints.D.shape[0] != ng: + raise Exception('inconsistent dimension ng, regarding lg, ug, C, D.') + else: + dims.ng = ng + + if not is_empty(model.con_h_expr): + nh = casadi_length(model.con_h_expr) + else: + nh = 0 + + if constraints.uh.shape[0] != nh or constraints.lh.shape[0] != nh: + raise Exception('inconsistent dimension nh, regarding lh, uh, con_h_expr.') + else: + dims.nh = nh + + if is_empty(model.con_phi_expr): + dims.nphi = 0 + dims.nr = 0 + else: + dims.nphi = casadi_length(model.con_phi_expr) + if is_empty(model.con_r_expr): + raise Exception('convex over nonlinear constraints: con_r_expr but con_phi_expr is nonempty') + else: + dims.nr = casadi_length(model.con_r_expr) + + # terminal + nbx_e = constraints.idxbx_e.shape[0] + if constraints.ubx_e.shape[0] != nbx_e or constraints.lbx_e.shape[0] != nbx_e: + raise Exception('inconsistent dimension nbx_e, regarding idxbx_e, ubx_e, lbx_e.') + else: + dims.nbx_e = nbx_e + + ng_e = constraints.lg_e.shape[0] + if constraints.ug_e.shape[0] != ng_e or constraints.C_e.shape[0] != ng_e: + raise Exception('inconsistent dimension ng_e, regarding_e lg_e, ug_e, C_e.') + else: + dims.ng_e = ng_e + + if not is_empty(model.con_h_expr_e): + nh_e = casadi_length(model.con_h_expr_e) + else: + nh_e = 0 + + if constraints.uh_e.shape[0] != nh_e or constraints.lh_e.shape[0] != nh_e: + raise Exception('inconsistent dimension nh_e, regarding lh_e, uh_e, con_h_expr_e.') + else: + dims.nh_e = nh_e + + if is_empty(model.con_phi_expr_e): + dims.nphi_e = 0 + dims.nr_e = 0 + else: + dims.nphi_e = casadi_length(model.con_phi_expr_e) + if is_empty(model.con_r_expr_e): + raise Exception('convex over nonlinear constraints: con_r_expr_e but con_phi_expr_e is nonempty') + else: + dims.nr_e = casadi_length(model.con_r_expr_e) + + # Slack dimensions + nsbx = constraints.idxsbx.shape[0] + if is_empty(constraints.lsbx): + constraints.lsbx = np.zeros((nsbx,)) + elif constraints.lsbx.shape[0] != nsbx: + raise Exception('inconsistent dimension nsbx, regarding idxsbx, lsbx.') + if is_empty(constraints.usbx): + constraints.usbx = np.zeros((nsbx,)) + elif constraints.usbx.shape[0] != nsbx: + raise Exception('inconsistent dimension nsbx, regarding idxsbx, usbx.') + dims.nsbx = nsbx + + nsbu = constraints.idxsbu.shape[0] + if is_empty(constraints.lsbu): + constraints.lsbu = np.zeros((nsbu,)) + elif constraints.lsbu.shape[0] != nsbu: + raise Exception('inconsistent dimension nsbu, regarding idxsbu, lsbu.') + if is_empty(constraints.usbu): + constraints.usbu = np.zeros((nsbu,)) + elif constraints.usbu.shape[0] != nsbu: + raise Exception('inconsistent dimension nsbu, regarding idxsbu, usbu.') + dims.nsbu = nsbu + + nsh = constraints.idxsh.shape[0] + if is_empty(constraints.lsh): + constraints.lsh = np.zeros((nsh,)) + elif constraints.lsh.shape[0] != nsh: + raise Exception('inconsistent dimension nsh, regarding idxsh, lsh.') + if is_empty(constraints.ush): + constraints.ush = np.zeros((nsh,)) + elif constraints.ush.shape[0] != nsh: + raise Exception('inconsistent dimension nsh, regarding idxsh, ush.') + dims.nsh = nsh + + nsphi = constraints.idxsphi.shape[0] + if is_empty(constraints.lsphi): + constraints.lsphi = np.zeros((nsphi,)) + elif constraints.lsphi.shape[0] != nsphi: + raise Exception('inconsistent dimension nsphi, regarding idxsphi, lsphi.') + if is_empty(constraints.usphi): + constraints.usphi = np.zeros((nsphi,)) + elif constraints.usphi.shape[0] != nsphi: + raise Exception('inconsistent dimension nsphi, regarding idxsphi, usphi.') + dims.nsphi = nsphi + + nsg = constraints.idxsg.shape[0] + if is_empty(constraints.lsg): + constraints.lsg = np.zeros((nsg,)) + elif constraints.lsg.shape[0] != nsg: + raise Exception('inconsistent dimension nsg, regarding idxsg, lsg.') + if is_empty(constraints.usg): + constraints.usg = np.zeros((nsg,)) + elif constraints.usg.shape[0] != nsg: + raise Exception('inconsistent dimension nsg, regarding idxsg, usg.') + dims.nsg = nsg + + ns = nsbx + nsbu + nsh + nsg + nsphi + wrong_field = "" + if cost.Zl.shape[0] != ns: + wrong_field = "Zl" + dim = cost.Zl.shape[0] + elif cost.Zu.shape[0] != ns: + wrong_field = "Zu" + dim = cost.Zu.shape[0] + elif cost.zl.shape[0] != ns: + wrong_field = "zl" + dim = cost.zl.shape[0] + elif cost.zu.shape[0] != ns: + wrong_field = "zu" + dim = cost.zu.shape[0] + + if wrong_field != "": + raise Exception(f'Inconsistent size for field {wrong_field}, with dimension {dim}, \n\t'\ + + f'Detected ns = {ns} = nsbx + nsbu + nsg + nsh + nsphi.\n\t'\ + + f'With nsbx = {nsbx}, nsbu = {nsbu}, nsg = {nsg}, nsh = {nsh}, nsphi = {nsphi}') + + dims.ns = ns + + nsbx_e = constraints.idxsbx_e.shape[0] + if is_empty(constraints.lsbx_e): + constraints.lsbx_e = np.zeros((nsbx_e,)) + elif constraints.lsbx_e.shape[0] != nsbx_e: + raise Exception('inconsistent dimension nsbx_e, regarding idxsbx_e, lsbx_e.') + if is_empty(constraints.usbx_e): + constraints.usbx_e = np.zeros((nsbx_e,)) + elif constraints.usbx_e.shape[0] != nsbx_e: + raise Exception('inconsistent dimension nsbx_e, regarding idxsbx_e, usbx_e.') + dims.nsbx_e = nsbx_e + + nsh_e = constraints.idxsh_e.shape[0] + if is_empty(constraints.lsh_e): + constraints.lsh_e = np.zeros((nsh_e,)) + elif constraints.lsh_e.shape[0] != nsh_e: + raise Exception('inconsistent dimension nsh_e, regarding idxsh_e, lsh_e.') + if is_empty(constraints.ush_e): + constraints.ush_e = np.zeros((nsh_e,)) + elif constraints.ush_e.shape[0] != nsh_e: + raise Exception('inconsistent dimension nsh_e, regarding idxsh_e, ush_e.') + dims.nsh_e = nsh_e + + nsg_e = constraints.idxsg_e.shape[0] + if is_empty(constraints.lsg_e): + constraints.lsg_e = np.zeros((nsg_e,)) + elif constraints.lsg_e.shape[0] != nsg_e: + raise Exception('inconsistent dimension nsg_e, regarding idxsg_e, lsg_e.') + if is_empty(constraints.usg_e): + constraints.usg_e = np.zeros((nsg_e,)) + elif constraints.usg_e.shape[0] != nsg_e: + raise Exception('inconsistent dimension nsg_e, regarding idxsg_e, usg_e.') + dims.nsg_e = nsg_e + + nsphi_e = constraints.idxsphi_e.shape[0] + if is_empty(constraints.lsphi_e): + constraints.lsphi_e = np.zeros((nsphi_e,)) + elif constraints.lsphi_e.shape[0] != nsphi_e: + raise Exception('inconsistent dimension nsphi_e, regarding idxsphi_e, lsphi_e.') + if is_empty(constraints.usphi_e): + constraints.usphi_e = np.zeros((nsphi_e,)) + elif constraints.usphi_e.shape[0] != nsphi_e: + raise Exception('inconsistent dimension nsphi_e, regarding idxsphi_e, usphi_e.') + dims.nsphi_e = nsphi_e + + # terminal + ns_e = nsbx_e + nsh_e + nsg_e + nsphi_e + wrong_field = "" + if cost.Zl_e.shape[0] != ns_e: + wrong_field = "Zl_e" + dim = cost.Zl_e.shape[0] + elif cost.Zu_e.shape[0] != ns_e: + wrong_field = "Zu_e" + dim = cost.Zu_e.shape[0] + elif cost.zl_e.shape[0] != ns_e: + wrong_field = "zl_e" + dim = cost.zl_e.shape[0] + elif cost.zu_e.shape[0] != ns_e: + wrong_field = "zu_e" + dim = cost.zu_e.shape[0] + + if wrong_field != "": + raise Exception(f'Inconsistent size for field {wrong_field}, with dimension {dim}, \n\t'\ + + f'Detected ns_e = {ns_e} = nsbx_e + nsg_e + nsh_e + nsphi_e.\n\t'\ + + f'With nsbx_e = {nsbx_e}, nsg_e = {nsg_e}, nsh_e = {nsh_e}, nsphi_e = {nsphi_e}') + + dims.ns_e = ns_e + + # discretization + if is_empty(opts.time_steps) and is_empty(opts.shooting_nodes): + # uniform discretization + opts.time_steps = opts.tf / dims.N * np.ones((dims.N,)) + + elif not is_empty(opts.shooting_nodes): + if np.shape(opts.shooting_nodes)[0] != dims.N+1: + raise Exception('inconsistent dimension N, regarding shooting_nodes.') + + # time_steps = opts.shooting_nodes[1:] - opts.shooting_nodes[0:-1] + # # identify constant time-steps: due to numerical reasons the content of time_steps might vary a bit + # delta_time_steps = time_steps[1:] - time_steps[0:-1] + # avg_time_steps = np.average(time_steps) + # # criterion for constant time-step detection: the min/max difference in values normalized by the average + # check_const_time_step = np.max(delta_time_steps)-np.min(delta_time_steps) / avg_time_steps + # # if the criterion is small, we have a constant time-step + # if check_const_time_step < 1e-9: + # time_steps[:] = avg_time_steps # if we have a constant time-step: apply the average time-step + time_steps = np.zeros((dims.N,)) + for i in range(dims.N): + time_steps[i] = opts.shooting_nodes[i+1] - opts.shooting_nodes[i] # TODO use commented code above + + opts.time_steps = time_steps + + elif (not is_empty(opts.time_steps)) and (not is_empty(opts.shooting_nodes)): + Exception('Please provide either time_steps or shooting_nodes for nonuniform discretization') + + tf = np.sum(opts.time_steps) + if (tf - opts.tf) / tf > 1e-15: + raise Exception(f'Inconsistent discretization: {opts.tf}'\ + f' = tf != sum(opts.time_steps) = {tf}.') + + # num_steps + if isinstance(opts.sim_method_num_steps, np.ndarray) and opts.sim_method_num_steps.size == 1: + opts.sim_method_num_steps = opts.sim_method_num_steps.item() + + if isinstance(opts.sim_method_num_steps, (int, float)) and opts.sim_method_num_steps % 1 == 0: + opts.sim_method_num_steps = opts.sim_method_num_steps * np.ones((dims.N,), dtype=np.int64) + elif isinstance(opts.sim_method_num_steps, np.ndarray) and opts.sim_method_num_steps.size == dims.N \ + and np.all(np.equal(np.mod(opts.sim_method_num_steps, 1), 0)): + opts.sim_method_num_steps = np.reshape(opts.sim_method_num_steps, (dims.N,)).astype(np.int64) + else: + raise Exception("Wrong value for sim_method_num_steps. Should be either int or array of ints of shape (N,).") + + # num_stages + if isinstance(opts.sim_method_num_stages, np.ndarray) and opts.sim_method_num_stages.size == 1: + opts.sim_method_num_stages = opts.sim_method_num_stages.item() + + if isinstance(opts.sim_method_num_stages, (int, float)) and opts.sim_method_num_stages % 1 == 0: + opts.sim_method_num_stages = opts.sim_method_num_stages * np.ones((dims.N,), dtype=np.int64) + elif isinstance(opts.sim_method_num_stages, np.ndarray) and opts.sim_method_num_stages.size == dims.N \ + and np.all(np.equal(np.mod(opts.sim_method_num_stages, 1), 0)): + opts.sim_method_num_stages = np.reshape(opts.sim_method_num_stages, (dims.N,)).astype(np.int64) + else: + raise Exception("Wrong value for sim_method_num_stages. Should be either int or array of ints of shape (N,).") + + # jac_reuse + if isinstance(opts.sim_method_jac_reuse, np.ndarray) and opts.sim_method_jac_reuse.size == 1: + opts.sim_method_jac_reuse = opts.sim_method_jac_reuse.item() + + if isinstance(opts.sim_method_jac_reuse, (int, float)) and opts.sim_method_jac_reuse % 1 == 0: + opts.sim_method_jac_reuse = opts.sim_method_jac_reuse * np.ones((dims.N,), dtype=np.int64) + elif isinstance(opts.sim_method_jac_reuse, np.ndarray) and opts.sim_method_jac_reuse.size == dims.N \ + and np.all(np.equal(np.mod(opts.sim_method_jac_reuse, 1), 0)): + opts.sim_method_jac_reuse = np.reshape(opts.sim_method_jac_reuse, (dims.N,)).astype(np.int64) + else: + raise Exception("Wrong value for sim_method_jac_reuse. Should be either int or array of ints of shape (N,).") + + +def get_simulink_default_opts(): + python_interface_path = get_python_interface_path() + abs_path = os.path.join(python_interface_path, 'simulink_default_opts.json') + with open(abs_path , 'r') as f: + simulink_default_opts = json.load(f) + return simulink_default_opts + + +def ocp_formulation_json_dump(acados_ocp, simulink_opts, json_file='acados_ocp_nlp.json'): + # Load acados_ocp_nlp structure description + ocp_layout = get_ocp_nlp_layout() + + # Copy input ocp object dictionary + ocp_nlp_dict = dict(deepcopy(acados_ocp).__dict__) + # TODO: maybe make one function with formatting + + for acados_struct, v in ocp_layout.items(): + # skip non dict attributes + if not isinstance(v, dict): + continue + # setattr(ocp_nlp, acados_struct, dict(getattr(acados_ocp, acados_struct).__dict__)) + # Copy ocp object attributes dictionaries + ocp_nlp_dict[acados_struct]=dict(getattr(acados_ocp, acados_struct).__dict__) + + ocp_nlp_dict = format_class_dict(ocp_nlp_dict) + + # strip symbolics + ocp_nlp_dict['model'] = acados_model_strip_casadi_symbolics(ocp_nlp_dict['model']) + + # strip shooting_nodes + ocp_nlp_dict['solver_options'].pop('shooting_nodes', None) + + dims_dict = acados_class2dict(acados_ocp.dims) + + ocp_check_against_layout(ocp_nlp_dict, dims_dict) + + # add simulink options + ocp_nlp_dict['simulink_opts'] = simulink_opts + + with open(json_file, 'w') as f: + json.dump(ocp_nlp_dict, f, default=np_array_to_list, indent=4, sort_keys=True) + + + +def ocp_formulation_json_load(json_file='acados_ocp_nlp.json'): + # Load acados_ocp_nlp structure description + ocp_layout = get_ocp_nlp_layout() + + with open(json_file, 'r') as f: + ocp_nlp_json = json.load(f) + + ocp_nlp_dict = json2dict(ocp_nlp_json, ocp_nlp_json['dims']) + + # Instantiate AcadosOcp object + acados_ocp = AcadosOcp() + + # load class dict + acados_ocp.__dict__ = ocp_nlp_dict + + # load class attributes dict, dims, constraints, etc + for acados_struct, v in ocp_layout.items(): + # skip non dict attributes + if not isinstance(v, dict): + continue + acados_attribute = getattr(acados_ocp, acados_struct) + acados_attribute.__dict__ = ocp_nlp_dict[acados_struct] + setattr(acados_ocp, acados_struct, acados_attribute) + + return acados_ocp + + +def ocp_generate_external_functions(acados_ocp, model): + + model = make_model_consistent(model) + + if acados_ocp.solver_options.hessian_approx == 'EXACT': + opts = dict(generate_hess=1) + else: + opts = dict(generate_hess=0) + code_export_dir = acados_ocp.code_export_directory + opts['code_export_directory'] = code_export_dir + + if acados_ocp.model.dyn_ext_fun_type != 'casadi': + raise Exception("ocp_generate_external_functions: dyn_ext_fun_type only supports 'casadi' for now.\ + Extending the Python interface with generic function support is welcome.") + + if acados_ocp.solver_options.integrator_type == 'ERK': + # explicit model -- generate C code + generate_c_code_explicit_ode(model, opts) + elif acados_ocp.solver_options.integrator_type == 'IRK': + # implicit model -- generate C code + generate_c_code_implicit_ode(model, opts) + elif acados_ocp.solver_options.integrator_type == 'LIFTED_IRK': + generate_c_code_implicit_ode(model, opts) + elif acados_ocp.solver_options.integrator_type == 'GNSF': + generate_c_code_gnsf(model, opts) + elif acados_ocp.solver_options.integrator_type == 'DISCRETE': + generate_c_code_discrete_dynamics(model, opts) + else: + raise Exception("ocp_generate_external_functions: unknown integrator type.") + + if acados_ocp.dims.nphi > 0 or acados_ocp.dims.nh > 0: + generate_c_code_constraint(model, model.name, False, opts) + + if acados_ocp.dims.nphi_e > 0 or acados_ocp.dims.nh_e > 0: + generate_c_code_constraint(model, model.name, True, opts) + + # dummy matrices + if not acados_ocp.cost.cost_type_0 == 'LINEAR_LS': + acados_ocp.cost.Vx_0 = np.zeros((acados_ocp.dims.ny_0, acados_ocp.dims.nx)) + acados_ocp.cost.Vu_0 = np.zeros((acados_ocp.dims.ny_0, acados_ocp.dims.nu)) + if not acados_ocp.cost.cost_type == 'LINEAR_LS': + acados_ocp.cost.Vx = np.zeros((acados_ocp.dims.ny, acados_ocp.dims.nx)) + acados_ocp.cost.Vu = np.zeros((acados_ocp.dims.ny, acados_ocp.dims.nu)) + if not acados_ocp.cost.cost_type_e == 'LINEAR_LS': + acados_ocp.cost.Vx_e = np.zeros((acados_ocp.dims.ny_e, acados_ocp.dims.nx)) + + if acados_ocp.cost.cost_type_0 == 'NONLINEAR_LS': + generate_c_code_nls_cost(model, model.name, 'initial', opts) + elif acados_ocp.cost.cost_type_0 == 'EXTERNAL': + generate_c_code_external_cost(model, 'initial', opts) + + if acados_ocp.cost.cost_type == 'NONLINEAR_LS': + generate_c_code_nls_cost(model, model.name, 'path', opts) + elif acados_ocp.cost.cost_type == 'EXTERNAL': + generate_c_code_external_cost(model, 'path', opts) + + if acados_ocp.cost.cost_type_e == 'NONLINEAR_LS': + generate_c_code_nls_cost(model, model.name, 'terminal', opts) + elif acados_ocp.cost.cost_type_e == 'EXTERNAL': + generate_c_code_external_cost(model, 'terminal', opts) + + +def ocp_render_templates(acados_ocp, json_file): + + name = acados_ocp.model.name + + # setting up loader and environment + json_path = os.path.join(os.getcwd(), json_file) + + if not os.path.exists(json_path): + raise Exception('{} not found!'.format(json_path)) + + code_export_dir = acados_ocp.code_export_directory + template_dir = code_export_dir + + ## Render templates + in_file = 'main.in.c' + out_file = f'main_{name}.c' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'acados_solver.in.c' + out_file = f'acados_solver_{name}.c' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'acados_solver.in.h' + out_file = f'acados_solver_{name}.h' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'acados_solver.in.pxd' + out_file = f'acados_solver.pxd' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'Makefile.in' + out_file = 'Makefile' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'acados_solver_sfun.in.c' + out_file = f'acados_solver_sfunction_{name}.c' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'make_sfun.in.m' + out_file = f'make_sfun_{name}.m' + render_template(in_file, out_file, template_dir, json_path) + + # sim + in_file = 'acados_sim_solver.in.c' + out_file = f'acados_sim_solver_{name}.c' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'acados_sim_solver.in.h' + out_file = f'acados_sim_solver_{name}.h' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'main_sim.in.c' + out_file = f'main_sim_{name}.c' + render_template(in_file, out_file, template_dir, json_path) + + ## folder model + template_dir = os.path.join(code_export_dir, name + '_model') + in_file = 'model.in.h' + out_file = f'{name}_model.h' + render_template(in_file, out_file, template_dir, json_path) + + # constraints on convex over nonlinear function + if acados_ocp.constraints.constr_type == 'BGP' and acados_ocp.dims.nphi > 0: + # constraints on outer function + template_dir = os.path.join(code_export_dir, name + '_constraints') + in_file = 'phi_constraint.in.h' + out_file = f'{name}_phi_constraint.h' + render_template(in_file, out_file, template_dir, json_path) + + # terminal constraints on convex over nonlinear function + if acados_ocp.constraints.constr_type_e == 'BGP' and acados_ocp.dims.nphi_e > 0: + # terminal constraints on outer function + template_dir = os.path.join(code_export_dir, name + '_constraints') + in_file = 'phi_e_constraint.in.h' + out_file = f'{name}_phi_e_constraint.h' + render_template(in_file, out_file, template_dir, json_path) + + # nonlinear constraints + if acados_ocp.constraints.constr_type == 'BGH' and acados_ocp.dims.nh > 0: + template_dir = os.path.join(code_export_dir, name + '_constraints') + in_file = 'h_constraint.in.h' + out_file = f'{name}_h_constraint.h' + render_template(in_file, out_file, template_dir, json_path) + + # terminal nonlinear constraints + if acados_ocp.constraints.constr_type_e == 'BGH' and acados_ocp.dims.nh_e > 0: + template_dir = os.path.join(code_export_dir, name + '_constraints') + in_file = 'h_e_constraint.in.h' + out_file = f'{name}_h_e_constraint.h' + render_template(in_file, out_file, template_dir, json_path) + + # initial stage Nonlinear LS cost function + if acados_ocp.cost.cost_type_0 == 'NONLINEAR_LS': + template_dir = os.path.join(code_export_dir, name + '_cost') + in_file = 'cost_y_0_fun.in.h' + out_file = f'{name}_cost_y_0_fun.h' + render_template(in_file, out_file, template_dir, json_path) + # external cost - terminal + elif acados_ocp.cost.cost_type_0 == 'EXTERNAL': + template_dir = os.path.join(code_export_dir, name + '_cost') + in_file = 'external_cost_0.in.h' + out_file = f'{name}_external_cost_0.h' + render_template(in_file, out_file, template_dir, json_path) + + # path Nonlinear LS cost function + if acados_ocp.cost.cost_type == 'NONLINEAR_LS': + template_dir = os.path.join(code_export_dir, name + '_cost') + in_file = 'cost_y_fun.in.h' + out_file = f'{name}_cost_y_fun.h' + render_template(in_file, out_file, template_dir, json_path) + + # terminal Nonlinear LS cost function + if acados_ocp.cost.cost_type_e == 'NONLINEAR_LS': + template_dir = os.path.join(code_export_dir, name + '_cost') + in_file = 'cost_y_e_fun.in.h' + out_file = f'{name}_cost_y_e_fun.h' + render_template(in_file, out_file, template_dir, json_path) + + # external cost + if acados_ocp.cost.cost_type == 'EXTERNAL': + template_dir = os.path.join(code_export_dir, name + '_cost') + in_file = 'external_cost.in.h' + out_file = f'{name}_external_cost.h' + render_template(in_file, out_file, template_dir, json_path) + + # external cost - terminal + if acados_ocp.cost.cost_type_e == 'EXTERNAL': + template_dir = os.path.join(code_export_dir, name + '_cost') + in_file = 'external_cost_e.in.h' + out_file = f'{name}_external_cost_e.h' + render_template(in_file, out_file, template_dir, json_path) + + +def remove_x0_elimination(acados_ocp): + acados_ocp.constraints.idxbxe_0 = np.zeros((0,)) + acados_ocp.dims.nbxe_0 = 0 + + +class AcadosOcpSolver: + """ + Class to interact with the acados ocp solver C object. + + :param acados_ocp: type AcadosOcp - description of the OCP for acados + :param json_file: name for the json file used to render the templated code - default: acados_ocp_nlp.json + :param simulink_opts: Options to configure Simulink S-function blocks, mainly to activate possible Inputs and Outputs + """ + if sys.platform=="win32": + from ctypes import wintypes + dlclose = ctypes.WinDLL('kernel32', use_last_error=True).FreeLibrary + dlclose.argtypes = [wintypes.HMODULE] + else: + dlclose = CDLL(None).dlclose + dlclose.argtypes = [c_void_p] + + @classmethod + def generate(cls, acados_ocp, json_file='acados_ocp_nlp.json', simulink_opts=None, build=True): + model = acados_ocp.model + + if simulink_opts is None: + simulink_opts = get_simulink_default_opts() + + # make dims consistent + make_ocp_dims_consistent(acados_ocp) + + # module dependent post processing + if acados_ocp.solver_options.integrator_type == 'GNSF': + set_up_imported_gnsf_model(acados_ocp) + + if acados_ocp.solver_options.qp_solver == 'PARTIAL_CONDENSING_QPDUNES': + remove_x0_elimination(acados_ocp) + + # set integrator time automatically + acados_ocp.solver_options.Tsim = acados_ocp.solver_options.time_steps[0] + + # generate external functions + ocp_generate_external_functions(acados_ocp, model) + + # dump to json + ocp_formulation_json_dump(acados_ocp, simulink_opts, json_file) + + code_export_dir = acados_ocp.code_export_directory + # render templates + ocp_render_templates(acados_ocp, json_file) + + if build: + ## Compile solver + cwd=os.getcwd() + os.chdir(code_export_dir) + os.system('make clean_ocp_shared_lib') + os.system('make ocp_shared_lib') + os.chdir(cwd) + + def __init__(self, model_name, N, code_export_dir): + self.model_name = model_name + self.N = N + + self.solver_created = False + self.shared_lib_name = f'{code_export_dir}/libacados_ocp_solver_{self.model_name}.so' + + # get shared_lib + self.shared_lib = CDLL(self.shared_lib_name) + + # create capsule + getattr(self.shared_lib, f"{self.model_name}_acados_create_capsule").restype = c_void_p + self.capsule = getattr(self.shared_lib, f"{self.model_name}_acados_create_capsule")() + + # create solver + getattr(self.shared_lib, f"{self.model_name}_acados_create").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_create").restype = c_int + assert getattr(self.shared_lib, f"{self.model_name}_acados_create")(self.capsule)==0 + self.solver_created = True + + # get pointers solver + self.__get_pointers_solver() + + + def __get_pointers_solver(self): + """ + Private function to get the pointers for solver + """ + # get pointers solver + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_opts").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_opts").restype = c_void_p + self.nlp_opts = getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_opts")(self.capsule) + + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_dims").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_dims").restype = c_void_p + self.nlp_dims = getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_dims")(self.capsule) + + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_config").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_config").restype = c_void_p + self.nlp_config = getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_config")(self.capsule) + + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_out").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_out").restype = c_void_p + self.nlp_out = getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_out")(self.capsule) + + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_in").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_in").restype = c_void_p + self.nlp_in = getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_in")(self.capsule) + + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_solver").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_solver").restype = c_void_p + self.nlp_solver = getattr(self.shared_lib, f"{self.model_name}_acados_get_nlp_solver")(self.capsule) + + # treat parameters separately + getattr(self.shared_lib, f"{self.model_name}_acados_update_params").argtypes = [c_void_p, c_int, POINTER(c_double)] + getattr(self.shared_lib, f"{self.model_name}_acados_update_params").restype = c_int + self._set_param = getattr(self.shared_lib, f"{self.model_name}_acados_update_params") + + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, POINTER(c_int)] + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr.restype = c_int + + self.shared_lib.ocp_nlp_cost_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, POINTER(c_int)] + self.shared_lib.ocp_nlp_cost_dims_get_from_attr.restype = c_int + + self.shared_lib.ocp_nlp_constraints_model_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_cost_model_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_out_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_set.argtypes = \ + [c_void_p, c_void_p, c_int, c_char_p, c_void_p] + + def solve(self): + """ + Solve the ocp with current input. + """ + + getattr(self.shared_lib, f"{self.model_name}_acados_solve").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_solve").restype = c_int + status = getattr(self.shared_lib, f"{self.model_name}_acados_solve")(self.capsule) + return status + + + def set_new_time_steps(self, new_time_steps): + """ + Set new time steps before solving. Only reload library without code generation but with new time steps. + + :param new_time_steps: vector of new time steps for the solver + + .. note:: This allows for different use-cases: either set a new size of time-steps or a new distribution of + the shooting nodes without changing the number, e.g., to reach a different final time. Both cases + do not require a new code export and compilation. + """ + + # unlikely but still possible + if not self.solver_created: + raise Exception('Solver was not yet created!') + + # check if time steps really changed in value + if np.array_equal(self.acados_ocp.solver_options.time_steps, new_time_steps): + return + + N = new_time_steps.size + model = self.acados_ocp.model + new_time_steps_data = cast(new_time_steps.ctypes.data, POINTER(c_double)) + + # check if recreation of acados is necessary (no need to recreate acados if sizes are identical) + if self.acados_ocp.solver_options.time_steps.size == N: + getattr(self.shared_lib, f"{self.model_name}_acados_update_time_steps").argtypes = [c_void_p, c_int, c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_update_time_steps").restype = c_int + assert getattr(self.shared_lib, f"{self.model_name}_acados_update_time_steps")(self.capsule, N, new_time_steps_data) == 0 + else: # recreate the solver with the new time steps + self.solver_created = False + + # delete old memory (analog to __del__) + getattr(self.shared_lib, f"{self.model_name}_acados_free").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_free").restype = c_int + getattr(self.shared_lib, f"{self.model_name}_acados_free")(self.capsule) + + # store N and new time steps + self.N = self.acados_ocp.dims.N = N + self.acados_ocp.solver_options.time_steps = new_time_steps + self.acados_ocp.solver_options.Tsim = self.acados_ocp.solver_options.time_steps[0] + + # create solver with new time steps + getattr(self.shared_lib, f"{self.model_name}_acados_create_with_discretization").argtypes = [c_void_p, c_int, c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_create_with_discretization").restype = c_int + assert getattr(self.shared_lib, f"{self.model_name}_acados_create_with_discretization")(self.capsule, N, new_time_steps_data) == 0 + + self.solver_created = True + + # get pointers solver + self.__get_pointers_solver() + + + def get(self, stage_, field_): + """ + Get the last solution of the solver: + + :param stage: integer corresponding to shooting node + :param field: string in ['x', 'u', 'z', 'pi', 'lam', 't', 'sl', 'su',] + + .. note:: regarding lam, t: \n + the inequalities are internally organized in the following order: \n + [ lbu lbx lg lh lphi ubu ubx ug uh uphi; \n + lsbu lsbx lsg lsh lsphi usbu usbx usg ush usphi] + + .. note:: pi: multipliers for dynamics equality constraints \n + lam: multipliers for inequalities \n + t: slack variables corresponding to evaluation of all inequalities (at the solution) \n + sl: slack variables of soft lower inequality constraints \n + su: slack variables of soft upper inequality constraints \n + """ + + out_fields = ['x', 'u', 'z', 'pi', 'lam', 't', 'sl', 'su'] + # mem_fields = ['sl', 'su'] + field = field_ + field = field.encode('utf-8') + + if (field_ not in out_fields): + raise Exception('AcadosOcpSolver.get(): {} is an invalid argument.\ + \n Possible values are {}. Exiting.'.format(field_, out_fields)) + + if not isinstance(stage_, int): + raise Exception('AcadosOcpSolver.get(): stage index must be Integer.') + + if stage_ < 0 or stage_ > self.N: + raise Exception('AcadosOcpSolver.get(): stage index must be in [0, N], got: {}.'.format(self.N)) + + if stage_ == self.N and field_ == 'pi': + raise Exception('AcadosOcpSolver.get(): field {} does not exist at final stage {}.'\ + .format(field_, stage_)) + + self.shared_lib.ocp_nlp_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p] + self.shared_lib.ocp_nlp_dims_get_from_attr.restype = c_int + + dims = self.shared_lib.ocp_nlp_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage_, field) + + out = np.ascontiguousarray(np.zeros((dims,)), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + if (field_ in out_fields): + self.shared_lib.ocp_nlp_out_get.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_out_get(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage_, field, out_data) + # elif field_ in mem_fields: + # self.shared_lib.ocp_nlp_get_at_stage.argtypes = \ + # [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + # self.shared_lib.ocp_nlp_get_at_stage(self.nlp_config, \ + # self.nlp_dims, self.nlp_solver, stage_, field, out_data) + + return out + + + def print_statistics(self): + """ + prints statistics of previous solver run as a table: + - iter: iteration number + - res_stat: stationarity residual + - res_eq: residual wrt equality constraints (dynamics) + - res_ineq: residual wrt inequality constraints (constraints) + - res_comp: residual wrt complementarity conditions + - qp_stat: status of QP solver + - qp_iter: number of QP iterations + - qp_res_stat: stationarity residual of the last QP solution + - qp_res_eq: residual wrt equality constraints (dynamics) of the last QP solution + - qp_res_ineq: residual wrt inequality constraints (constraints) of the last QP solution + - qp_res_comp: residual wrt complementarity conditions of the last QP solution + """ + stat = self.get_stats("statistics") + + if self.acados_ocp.solver_options.nlp_solver_type == 'SQP': + print('\niter\tres_stat\tres_eq\t\tres_ineq\tres_comp\tqp_stat\tqp_iter') + if stat.shape[0]>7: + print('\tqp_res_stat\tqp_res_eq\tqp_res_ineq\tqp_res_comp') + for jj in range(stat.shape[1]): + print('{:d}\t{:e}\t{:e}\t{:e}\t{:e}\t{:d}\t{:d}'.format( \ + int(stat[0][jj]), stat[1][jj], stat[2][jj], \ + stat[3][jj], stat[4][jj], int(stat[5][jj]), int(stat[6][jj]))) + if stat.shape[0]>7: + print('\t{:e}\t{:e}\t{:e}\t{:e}'.format( \ + stat[7][jj], stat[8][jj], stat[9][jj], stat[10][jj])) + print('\n') + elif self.acados_ocp.solver_options.nlp_solver_type == 'SQP_RTI': + print('\niter\tqp_stat\tqp_iter') + if stat.shape[0]>3: + print('\tqp_res_stat\tqp_res_eq\tqp_res_ineq\tqp_res_comp') + for jj in range(stat.shape[1]): + print('{:d}\t{:d}\t{:d}'.format( int(stat[0][jj]), int(stat[1][jj]), int(stat[2][jj]))) + if stat.shape[0]>3: + print('\t{:e}\t{:e}\t{:e}\t{:e}'.format( \ + stat[3][jj], stat[4][jj], stat[5][jj], stat[6][jj])) + print('\n') + + return + + + def store_iterate(self, filename='', overwrite=False): + """ + Stores the current iterate of the ocp solver in a json file. + + :param filename: if not set, use model_name + timestamp + '.json' + :param overwrite: if false and filename exists add timestamp to filename + """ + if filename == '': + filename += self.model_name + '_' + 'iterate' + '.json' + + if not overwrite: + # append timestamp + if os.path.isfile(filename): + filename = filename[:-5] + filename += datetime.utcnow().strftime('%Y-%m-%d-%H:%M:%S.%f') + '.json' + + # get iterate: + solution = dict() + + for i in range(self.N+1): + solution['x_'+str(i)] = self.get(i,'x') + solution['u_'+str(i)] = self.get(i,'u') + solution['z_'+str(i)] = self.get(i,'z') + solution['lam_'+str(i)] = self.get(i,'lam') + solution['t_'+str(i)] = self.get(i, 't') + solution['sl_'+str(i)] = self.get(i, 'sl') + solution['su_'+str(i)] = self.get(i, 'su') + for i in range(self.N): + solution['pi_'+str(i)] = self.get(i,'pi') + + # save + with open(filename, 'w') as f: + json.dump(solution, f, default=np_array_to_list, indent=4, sort_keys=True) + print("stored current iterate in ", os.path.join(os.getcwd(), filename)) + + + def load_iterate(self, filename): + """ + Loads the iterate stored in json file with filename into the ocp solver. + """ + if not os.path.isfile(filename): + raise Exception('load_iterate: failed, file does not exist: ' + os.path.join(os.getcwd(), filename)) + + with open(filename, 'r') as f: + solution = json.load(f) + + for key in solution.keys(): + (field, stage) = key.split('_') + self.set(int(stage), field, np.array(solution[key])) + + + def get_stats(self, field_): + """ + Get the information of the last solver call. + + :param field: string in ['statistics', 'time_tot', 'time_lin', 'time_sim', 'time_sim_ad', 'time_sim_la', 'time_qp', 'time_qp_solver_call', 'time_reg', 'sqp_iter'] + """ + + fields = ['time_tot', # total cpu time previous call + 'time_lin', # cpu time for linearization + 'time_sim', # cpu time for integrator + 'time_sim_ad', # cpu time for integrator contribution of external function calls + 'time_sim_la', # cpu time for integrator contribution of linear algebra + 'time_qp', # cpu time qp solution + 'time_qp_solver_call', # cpu time inside qp solver (without converting the QP) + 'time_qp_xcond', + 'time_glob', # cpu time globalization + 'time_reg', # cpu time regularization + 'sqp_iter', # number of SQP iterations + 'qp_iter', # vector of QP iterations for last SQP call + 'statistics', # table with info about last iteration + 'stat_m', + 'stat_n',] + + field = field_ + field = field.encode('utf-8') + if (field_ not in fields): + raise Exception('AcadosOcpSolver.get_stats(): {} is not a valid argument.\ + \n Possible values are {}. Exiting.'.format(fields, fields)) + + if field_ in ['sqp_iter', 'stat_m', 'stat_n']: + out = np.ascontiguousarray(np.zeros((1,)), dtype=np.int64) + out_data = cast(out.ctypes.data, POINTER(c_int64)) + + elif field_ == 'statistics': + sqp_iter = self.get_stats("sqp_iter") + stat_m = self.get_stats("stat_m") + stat_n = self.get_stats("stat_n") + + min_size = min([stat_m, sqp_iter+1]) + + out = np.ascontiguousarray( + np.zeros((stat_n[0]+1, min_size[0])), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + elif field_ == 'qp_iter': + full_stats = self.get_stats('statistics') + if self.acados_ocp.solver_options.nlp_solver_type == 'SQP': + out = full_stats[6, :] + elif self.acados_ocp.solver_options.nlp_solver_type == 'SQP_RTI': + out = full_stats[2, :] + + else: + out = np.ascontiguousarray(np.zeros((1,)), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + if not field_ == 'qp_iter': + self.shared_lib.ocp_nlp_get.argtypes = [c_void_p, c_void_p, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_get(self.nlp_config, self.nlp_solver, field, out_data) + + return out + + + def get_cost(self): + """ + Returns the cost value of the current solution. + """ + # compute cost internally + self.shared_lib.ocp_nlp_eval_cost.argtypes = [c_void_p, c_void_p, c_void_p] + self.shared_lib.ocp_nlp_eval_cost(self.nlp_solver, self.nlp_in, self.nlp_out) + + # create output array + out = np.ascontiguousarray(np.zeros((1,)), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + # call getter + self.shared_lib.ocp_nlp_get.argtypes = [c_void_p, c_void_p, c_char_p, c_void_p] + + field = "cost_value".encode('utf-8') + self.shared_lib.ocp_nlp_get(self.nlp_config, self.nlp_solver, field, out_data) + + return out[0] + + + def get_residuals(self): + """ + Returns an array of the form [res_stat, res_eq, res_ineq, res_comp]. + """ + # compute residuals if RTI + if self.acados_ocp.solver_options.nlp_solver_type == 'SQP_RTI': + self.shared_lib.ocp_nlp_eval_residuals.argtypes = [c_void_p, c_void_p, c_void_p] + self.shared_lib.ocp_nlp_eval_residuals(self.nlp_solver, self.nlp_in, self.nlp_out) + + # create output array + out = np.ascontiguousarray(np.zeros((4, 1)), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + # call getters + self.shared_lib.ocp_nlp_get.argtypes = [c_void_p, c_void_p, c_char_p, c_void_p] + + field = "res_stat".encode('utf-8') + self.shared_lib.ocp_nlp_get(self.nlp_config, self.nlp_solver, field, out_data) + + out_data = cast(out[1].ctypes.data, POINTER(c_double)) + field = "res_eq".encode('utf-8') + self.shared_lib.ocp_nlp_get(self.nlp_config, self.nlp_solver, field, out_data) + + out_data = cast(out[2].ctypes.data, POINTER(c_double)) + field = "res_ineq".encode('utf-8') + self.shared_lib.ocp_nlp_get(self.nlp_config, self.nlp_solver, field, out_data) + + out_data = cast(out[3].ctypes.data, POINTER(c_double)) + field = "res_comp".encode('utf-8') + self.shared_lib.ocp_nlp_get(self.nlp_config, self.nlp_solver, field, out_data) + return out.flatten() + + + # Note: this function should not be used anymore, better use cost_set, constraints_set + + def set(self, stage_, field_, value_): + + """ + Set numerical data inside the solver. + + :param stage: integer corresponding to shooting node + :param field: string in ['x', 'u', 'pi', 'lam', 't', 'p'] + + .. note:: regarding lam, t: \n + the inequalities are internally organized in the following order: \n + [ lbu lbx lg lh lphi ubu ubx ug uh uphi; \n + lsbu lsbx lsg lsh lsphi usbu usbx usg ush usphi] + + .. note:: pi: multipliers for dynamics equality constraints \n + lam: multipliers for inequalities \n + t: slack variables corresponding to evaluation of all inequalities (at the solution) \n + sl: slack variables of soft lower inequality constraints \n + su: slack variables of soft upper inequality constraints \n + """ + cost_fields = ['y_ref', 'yref'] + constraints_fields = ['lbx', 'ubx', 'lbu', 'ubu'] + out_fields = ['x', 'u', 'pi', 'lam', 't', 'z', 'sl', 'su'] + + # cast value_ to avoid conversion issues + if isinstance(value_, (float, int)): + value_ = np.array([value_]) + value_ = value_.astype(float) + + field = field_ + field = field.encode('utf-8') + + stage = c_int(stage_) + + # treat parameters separately + if field_ == 'p': + getattr(self.shared_lib, f"{self.model_name}_acados_update_params").argtypes = [c_void_p, c_int, POINTER(c_double)] + getattr(self.shared_lib, f"{self.model_name}_acados_update_params").restype = c_int + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + + assert getattr(self.shared_lib, f"{self.model_name}_acados_update_params")(self.capsule, stage, value_data, value_.shape[0])==0 + else: + if field_ not in constraints_fields + cost_fields + out_fields: + raise Exception("AcadosOcpSolver.set(): {} is not a valid argument.\ + \nPossible values are {}. Exiting.".format(field, \ + constraints_fields + cost_fields + out_fields + ['p'])) + + self.shared_lib.ocp_nlp_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p] + self.shared_lib.ocp_nlp_dims_get_from_attr.restype = c_int + + dims = self.shared_lib.ocp_nlp_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage_, field) + + if value_.shape[0] != dims: + msg = 'AcadosOcpSolver.set(): mismatching dimension for field "{}" '.format(field_) + msg += 'with dimension {} (you have {})'.format(dims, value_.shape[0]) + raise Exception(msg) + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + value_data_p = cast((value_data), c_void_p) + + if field_ in constraints_fields: + self.shared_lib.ocp_nlp_constraints_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, value_data_p) + elif field_ in cost_fields: + self.shared_lib.ocp_nlp_cost_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, value_data_p) + elif field_ in out_fields: + self.shared_lib.ocp_nlp_out_set(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage, field, value_data_p) + # elif field_ in mem_fields: + # self.shared_lib.ocp_nlp_set(self.nlp_config, \ + # self.nlp_solver, stage, field, value_data_p) + + return + + + def cost_set(self, stage_, field_, value_, api='warn'): + """ + Set numerical data in the cost module of the solver. + + :param stage: integer corresponding to shooting node + :param field: string, e.g. 'yref', 'W', 'ext_cost_num_hess' + :param value: of appropriate size + """ + # cast value_ to avoid conversion issues + if isinstance(value_, (float, int)): + value_ = np.array([value_]) + value_ = value_.astype(float) + + field = field_ + field = field.encode('utf-8') + + stage = c_int(stage_) + self.shared_lib.ocp_nlp_cost_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, POINTER(c_int)] + self.shared_lib.ocp_nlp_cost_dims_get_from_attr.restype = c_int + + dims = np.ascontiguousarray(np.zeros((2,)), dtype=np.intc) + dims_data = cast(dims.ctypes.data, POINTER(c_int)) + + self.shared_lib.ocp_nlp_cost_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage_, field, dims_data) + + value_shape = value_.shape + if len(value_shape) == 1: + value_shape = (value_shape[0], 0) + + elif len(value_shape) == 2: + if api=='old': + pass + elif api=='warn': + if not np.all(np.ravel(value_, order='F')==np.ravel(value_, order='K')): + raise Exception("Ambiguity in API detected.\n" + "Are you making an acados model from scrach? Add api='new' to cost_set and carry on.\n" + "Are you seeing this error suddenly in previously running code? Read on.\n" + " You are relying on a now-fixed bug in cost_set for field '{}'.\n".format(field_) + + " acados_template now correctly passes on any matrices to acados in column major format.\n" + + " Two options to fix this error: \n" + + " * Add api='old' to cost_set to restore old incorrect behaviour\n" + + " * Add api='new' to cost_set and remove any unnatural manipulation of the value argument " + + "such as non-mathematical transposes, reshaping, casting to fortran order, etc... " + + "If there is no such manipulation, then you have probably been getting an incorrect solution before.") + # Get elements in column major order + value_ = np.ravel(value_, order='F') + elif api=='new': + # Get elements in column major order + value_ = np.ravel(value_, order='F') + else: + raise Exception("Unknown api: '{}'".format(api)) + + if value_shape != tuple(dims): + raise Exception('AcadosOcpSolver.cost_set(): mismatching dimension', \ + ' for field "{}" with dimension {} (you have {})'.format( \ + field_, tuple(dims), value_shape)) + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + value_data_p = cast((value_data), c_void_p) + + self.shared_lib.ocp_nlp_cost_model_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_cost_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, value_data_p) + + return + + + def constraints_set(self, stage_, field_, value_, api='warn'): + """ + Set numerical data in the constraint module of the solver. + + :param stage: integer corresponding to shooting node + :param field: string in ['lbx', 'ubx', 'lbu', 'ubu', 'lg', 'ug', 'lh', 'uh', 'uphi', 'C', 'D'] + :param value: of appropriate size + """ + # cast value_ to avoid conversion issues + if isinstance(value_, (float, int)): + value_ = np.array([value_]) + value_ = value_.astype(float) + + field = field_ + field = field.encode('utf-8') + + stage = c_int(stage_) + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, POINTER(c_int)] + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr.restype = c_int + + dims = np.ascontiguousarray(np.zeros((2,)), dtype=np.intc) + dims_data = cast(dims.ctypes.data, POINTER(c_int)) + + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage_, field, dims_data) + + value_shape = value_.shape + if len(value_shape) == 1: + value_shape = (value_shape[0], 0) + elif len(value_shape) == 2: + if api=='old': + pass + elif api=='warn': + if not np.all(np.ravel(value_, order='F')==np.ravel(value_, order='K')): + raise Exception("Ambiguity in API detected.\n" + "Are you making an acados model from scrach? Add api='new' to constraints_set and carry on.\n" + "Are you seeing this error suddenly in previously running code? Read on.\n" + " You are relying on a now-fixed bug in constraints_set for field '{}'.\n".format(field_) + + " acados_template now correctly passes on any matrices to acados in column major format.\n" + + " Two options to fix this error: \n" + + " * Add api='old' to constraints_set to restore old incorrect behaviour\n" + + " * Add api='new' to constraints_set and remove any unnatural manipulation of the value argument " + + "such as non-mathematical transposes, reshaping, casting to fortran order, etc... " + + "If there is no such manipulation, then you have probably been getting an incorrect solution before.") + # Get elements in column major order + value_ = np.ravel(value_, order='F') + elif api=='new': + # Get elements in column major order + value_ = np.ravel(value_, order='F') + else: + raise Exception("Unknown api: '{}'".format(api)) + + if value_shape != tuple(dims): + raise Exception('AcadosOcpSolver.constraints_set(): mismatching dimension' \ + ' for field "{}" with dimension {} (you have {})'.format(field_, tuple(dims), value_shape)) + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + value_data_p = cast((value_data), c_void_p) + + self.shared_lib.ocp_nlp_constraints_model_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_constraints_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, value_data_p) + + return + + + def dynamics_get(self, stage_, field_): + """ + Get numerical data from the dynamics module of the solver: + + :param stage: integer corresponding to shooting node + :param field: string, e.g. 'A' + """ + + field = field_ + field = field.encode('utf-8') + stage = c_int(stage_) + + # get dims + self.shared_lib.ocp_nlp_dynamics_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, POINTER(c_int)] + self.shared_lib.ocp_nlp_dynamics_dims_get_from_attr.restype = c_int + + dims = np.ascontiguousarray(np.zeros((2,)), dtype=np.intc) + dims_data = cast(dims.ctypes.data, POINTER(c_int)) + + self.shared_lib.ocp_nlp_dynamics_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage_, field, dims_data) + + # create output data + out = np.ascontiguousarray(np.zeros((np.prod(dims),)), dtype=np.float64) + out = out.reshape(dims[0], dims[1], order='F') + + out_data = cast(out.ctypes.data, POINTER(c_double)) + out_data_p = cast((out_data), c_void_p) + + # call getter + self.shared_lib.ocp_nlp_get_at_stage.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_get_at_stage(self.nlp_config, \ + self.nlp_dims, self.nlp_solver, stage, field, out_data_p) + + return out + + + def options_set(self, field_, value_): + """ + Set options of the solver. + + :param field: string, e.g. 'print_level', 'rti_phase', 'initialize_t_slacks', 'step_length', 'alpha_min', 'alpha_reduction' + :param value: of type int, float + """ + int_fields = ['print_level', 'rti_phase', 'initialize_t_slacks'] + double_fields = ['step_length', 'tol_eq', 'tol_stat', 'tol_ineq', 'tol_comp', 'alpha_min', 'alpha_reduction'] + string_fields = ['globalization'] + + # check field availability and type + if field_ in int_fields: + if not isinstance(value_, int): + raise Exception('solver option {} must be of type int. You have {}.'.format(field_, type(value_))) + else: + value_ctypes = c_int(value_) + + elif field_ in double_fields: + if not isinstance(value_, float): + raise Exception('solver option {} must be of type float. You have {}.'.format(field_, type(value_))) + else: + value_ctypes = c_double(value_) + + elif field_ in string_fields: + if not isinstance(value_, str): + raise Exception('solver option {} must be of type str. You have {}.'.format(field_, type(value_))) + else: + value_ctypes = value_.encode('utf-8') + else: + raise Exception('AcadosOcpSolver.options_set() does not support field {}.'\ + '\n Possible values are {}.'.format(field_, ', '.join(int_fields + double_fields + string_fields))) + + + if field_ == 'rti_phase': + if value_ < 0 or value_ > 2: + raise Exception('AcadosOcpSolver.solve(): argument \'rti_phase\' can ' + 'take only values 0, 1, 2 for SQP-RTI-type solvers') + if self.acados_ocp.solver_options.nlp_solver_type != 'SQP_RTI' and value_ > 0: + raise Exception('AcadosOcpSolver.solve(): argument \'rti_phase\' can ' + 'take only value 0 for SQP-type solvers') + + # encode + field = field_ + field = field.encode('utf-8') + + # call C interface + if field_ in string_fields: + self.shared_lib.ocp_nlp_solver_opts_set.argtypes = \ + [c_void_p, c_void_p, c_char_p, c_char_p] + self.shared_lib.ocp_nlp_solver_opts_set(self.nlp_config, \ + self.nlp_opts, field, value_ctypes) + else: + self.shared_lib.ocp_nlp_solver_opts_set.argtypes = \ + [c_void_p, c_void_p, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_solver_opts_set(self.nlp_config, \ + self.nlp_opts, field, byref(value_ctypes)) + return + + + def __del__(self): + if self.solver_created: + getattr(self.shared_lib, f"{self.model_name}_acados_free").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_free").restype = c_int + getattr(self.shared_lib, f"{self.model_name}_acados_free")(self.capsule) + + getattr(self.shared_lib, f"{self.model_name}_acados_free_capsule").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_free_capsule").restype = c_int + getattr(self.shared_lib, f"{self.model_name}_acados_free_capsule")(self.capsule) + + try: + self.dlclose(self.shared_lib._handle) + except: + pass diff --git a/pyextra/acados_template/acados_ocp_solver_fast.py b/pyextra/acados_template/acados_ocp_solver_fast.py new file mode 100644 index 00000000000000..656d288f1c43e4 --- /dev/null +++ b/pyextra/acados_template/acados_ocp_solver_fast.py @@ -0,0 +1,402 @@ +import sys +import os +import json +import numpy as np +from datetime import datetime + +from ctypes import POINTER, CDLL, c_void_p, c_int, cast, c_double, c_char_p + +from copy import deepcopy + +from .generate_c_code_explicit_ode import generate_c_code_explicit_ode +from .generate_c_code_implicit_ode import generate_c_code_implicit_ode +from .generate_c_code_gnsf import generate_c_code_gnsf +from .generate_c_code_discrete_dynamics import generate_c_code_discrete_dynamics +from .generate_c_code_constraint import generate_c_code_constraint +from .generate_c_code_nls_cost import generate_c_code_nls_cost +from .generate_c_code_external_cost import generate_c_code_external_cost +from .acados_ocp import AcadosOcp +from .acados_model import acados_model_strip_casadi_symbolics +from .utils import is_column, is_empty, casadi_length, render_template, acados_class2dict,\ + format_class_dict, ocp_check_against_layout, np_array_to_list, make_model_consistent,\ + set_up_imported_gnsf_model, get_acados_path + + +class AcadosOcpSolverFast: + dlclose = CDLL(None).dlclose + dlclose.argtypes = [c_void_p] + + def __init__(self, model_name, N, code_export_dir): + + self.solver_created = False + self.N = N + self.model_name = model_name + + self.shared_lib_name = f'{code_export_dir}/libacados_ocp_solver_{model_name}.so' + + # get shared_lib + self.shared_lib = CDLL(self.shared_lib_name) + + # create capsule + getattr(self.shared_lib, f"{model_name}_acados_create_capsule").restype = c_void_p + self.capsule = getattr(self.shared_lib, f"{model_name}_acados_create_capsule")() + + # create solver + getattr(self.shared_lib, f"{model_name}_acados_create").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_create").restype = c_int + assert getattr(self.shared_lib, f"{model_name}_acados_create")(self.capsule)==0 + self.solver_created = True + + # get pointers solver + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_opts").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_opts").restype = c_void_p + self.nlp_opts = getattr(self.shared_lib, f"{model_name}_acados_get_nlp_opts")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_dims").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_dims").restype = c_void_p + self.nlp_dims = getattr(self.shared_lib, f"{model_name}_acados_get_nlp_dims")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_config").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_config").restype = c_void_p + self.nlp_config = getattr(self.shared_lib, f"{model_name}_acados_get_nlp_config")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_out").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_out").restype = c_void_p + self.nlp_out = getattr(self.shared_lib, f"{model_name}_acados_get_nlp_out")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_in").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_in").restype = c_void_p + self.nlp_in = getattr(self.shared_lib, f"{model_name}_acados_get_nlp_in")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_solver").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_nlp_solver").restype = c_void_p + self.nlp_solver = getattr(self.shared_lib, f"{model_name}_acados_get_nlp_solver")(self.capsule) + + + def solve(self): + """ + Solve the ocp with current input. + """ + model_name = self.model_name + + getattr(self.shared_lib, f"{model_name}_acados_solve").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_solve").restype = c_int + status = getattr(self.shared_lib, f"{model_name}_acados_solve")(self.capsule) + return status + + def cost_set(self, start_stage_, field_, value_, api='warn'): + self.cost_set_slice(start_stage_, start_stage_+1, field_, value_[None], api='warn') + return + + def cost_set_slice(self, start_stage_, end_stage_, field_, value_, api='warn'): + """ + Set numerical data in the cost module of the solver. + + :param stage: integer corresponding to shooting node + :param field: string, e.g. 'yref', 'W', 'ext_cost_num_hess' + :param value: of appropriate size + """ + # cast value_ to avoid conversion issues + if isinstance(value_, (float, int)): + value_ = np.array([value_]) + value_ = np.ascontiguousarray(np.copy(value_), dtype=np.float64) + field = field_ + field = field.encode('utf-8') + dim = np.product(value_.shape[1:]) + + start_stage = c_int(start_stage_) + end_stage = c_int(end_stage_) + self.shared_lib.ocp_nlp_cost_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, POINTER(c_int)] + self.shared_lib.ocp_nlp_cost_dims_get_from_attr.restype = c_int + + dims = np.ascontiguousarray(np.zeros((2,)), dtype=np.intc) + dims_data = cast(dims.ctypes.data, POINTER(c_int)) + + self.shared_lib.ocp_nlp_cost_dims_get_from_attr(self.nlp_config, + self.nlp_dims, self.nlp_out, start_stage_, field, dims_data) + + value_shape = value_.shape + expected_shape = tuple(np.concatenate([np.array([end_stage_ - start_stage_]), dims])) + if len(value_shape) == 2: + value_shape = (value_shape[0], value_shape[1], 0) + + elif len(value_shape) == 3: + if api=='old': + pass + elif api=='warn': + if not np.all(np.ravel(value_, order='F')==np.ravel(value_, order='K')): + raise Exception("Ambiguity in API detected.\n" + "Are you making an acados model from scrach? Add api='new' to cost_set and carry on.\n" + "Are you seeing this error suddenly in previously running code? Read on.\n" + " You are relying on a now-fixed bug in cost_set for field '{}'.\n".format(field_) + + " acados_template now correctly passes on any matrices to acados in column major format.\n" + + " Two options to fix this error: \n" + + " * Add api='old' to cost_set to restore old incorrect behaviour\n" + + " * Add api='new' to cost_set and remove any unnatural manipulation of the value argument " + + "such as non-mathematical transposes, reshaping, casting to fortran order, etc... " + + "If there is no such manipulation, then you have probably been getting an incorrect solution before.") + # Get elements in column major order + value_ = np.ravel(value_, order='F') + elif api=='new': + # Get elements in column major order + value_ = np.ravel(value_, order='F') + else: + raise Exception("Unknown api: '{}'".format(api)) + + if value_shape != expected_shape: + raise Exception('AcadosOcpSolver.cost_set(): mismatching dimension', + ' for field "{}" with dimension {} (you have {})'.format( + field_, expected_shape, value_shape)) + + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + value_data_p = cast((value_data), c_void_p) + + self.shared_lib.ocp_nlp_cost_model_set_slice.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_int, c_char_p, c_void_p, c_int] + self.shared_lib.ocp_nlp_cost_model_set_slice(self.nlp_config, + self.nlp_dims, self.nlp_in, start_stage, end_stage, field, value_data_p, dim) + return + + def constraints_set(self, start_stage_, field_, value_, api='warn'): + self.constraints_set_slice(start_stage_, start_stage_+1, field_, value_[None], api='warn') + return + + def constraints_set_slice(self, start_stage_, end_stage_, field_, value_, api='warn'): + """ + Set numerical data in the constraint module of the solver. + + :param stage: integer corresponding to shooting node + :param field: string in ['lbx', 'ubx', 'lbu', 'ubu', 'lg', 'ug', 'lh', 'uh', 'uphi'] + :param value: of appropriate size + """ + # cast value_ to avoid conversion issues + if isinstance(value_, (float, int)): + value_ = np.array([value_]) + value_ = value_.astype(float) + + field = field_ + field = field.encode('utf-8') + dim = np.product(value_.shape[1:]) + + start_stage = c_int(start_stage_) + end_stage = c_int(end_stage_) + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, POINTER(c_int)] + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr.restype = c_int + + dims = np.ascontiguousarray(np.zeros((2,)), dtype=np.intc) + dims_data = cast(dims.ctypes.data, POINTER(c_int)) + + self.shared_lib.ocp_nlp_constraint_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, start_stage_, field, dims_data) + + value_shape = value_.shape + expected_shape = tuple(np.concatenate([np.array([end_stage_ - start_stage_]), dims])) + if len(value_shape) == 2: + value_shape = (value_shape[0], value_shape[1], 0) + elif len(value_shape) == 3: + if api=='old': + pass + elif api=='warn': + if not np.all(np.ravel(value_, order='F')==np.ravel(value_, order='K')): + raise Exception("Ambiguity in API detected.\n" + "Are you making an acados model from scrach? Add api='new' to constraints_set and carry on.\n" + "Are you seeing this error suddenly in previously running code? Read on.\n" + " You are relying on a now-fixed bug in constraints_set for field '{}'.\n".format(field_) + + " acados_template now correctly passes on any matrices to acados in column major format.\n" + + " Two options to fix this error: \n" + + " * Add api='old' to constraints_set to restore old incorrect behaviour\n" + + " * Add api='new' to constraints_set and remove any unnatural manipulation of the value argument " + + "such as non-mathematical transposes, reshaping, casting to fortran order, etc... " + + "If there is no such manipulation, then you have probably been getting an incorrect solution before.") + # Get elements in column major order + value_ = np.ravel(value_, order='F') + elif api=='new': + # Get elements in column major order + value_ = np.ravel(value_, order='F') + else: + raise Exception("Unknown api: '{}'".format(api)) + if value_shape != expected_shape: + raise Exception('AcadosOcpSolver.constraints_set(): mismatching dimension' \ + ' for field "{}" with dimension {} (you have {})'.format(field_, expected_shape, value_shape)) + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + value_data_p = cast((value_data), c_void_p) + + self.shared_lib.ocp_nlp_constraints_model_set_slice.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_int, c_char_p, c_void_p, c_int] + self.shared_lib.ocp_nlp_constraints_model_set_slice(self.nlp_config, \ + self.nlp_dims, self.nlp_in, start_stage, end_stage, field, value_data_p, dim) + return + + # Note: this function should not be used anymore, better use cost_set, constraints_set + def set(self, stage_, field_, value_): + """ + Set numerical data inside the solver. + + :param stage: integer corresponding to shooting node + :param field: string in ['x', 'u', 'pi', 'lam', 't', 'p'] + + .. note:: regarding lam, t: \n + the inequalities are internally organized in the following order: \n + [ lbu lbx lg lh lphi ubu ubx ug uh uphi; \n + lsbu lsbx lsg lsh lsphi usbu usbx usg ush usphi] + + .. note:: pi: multipliers for dynamics equality constraints \n + lam: multipliers for inequalities \n + t: slack variables corresponding to evaluation of all inequalities (at the solution) \n + sl: slack variables of soft lower inequality constraints \n + su: slack variables of soft upper inequality constraints \n + """ + cost_fields = ['y_ref', 'yref'] + constraints_fields = ['lbx', 'ubx', 'lbu', 'ubu'] + out_fields = ['x', 'u', 'pi', 'lam', 't', 'z'] + mem_fields = ['sl', 'su'] + + # cast value_ to avoid conversion issues + if isinstance(value_, (float, int)): + value_ = np.array([value_]) + value_ = value_.astype(float) + + model_name = self.model_name + + field = field_ + field = field.encode('utf-8') + + stage = c_int(stage_) + + # treat parameters separately + if field_ == 'p': + getattr(self.shared_lib, f"{model_name}_acados_update_params").argtypes = [c_void_p, c_int, POINTER(c_double)] + getattr(self.shared_lib, f"{model_name}_acados_update_params").restype = c_int + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + + assert getattr(self.shared_lib, f"{model_name}_acados_update_params")(self.capsule, stage, value_data, value_.shape[0])==0 + else: + if field_ not in constraints_fields + cost_fields + out_fields + mem_fields: + raise Exception("AcadosOcpSolver.set(): {} is not a valid argument.\ + \nPossible values are {}. Exiting.".format(field, \ + constraints_fields + cost_fields + out_fields + ['p'])) + + self.shared_lib.ocp_nlp_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p] + self.shared_lib.ocp_nlp_dims_get_from_attr.restype = c_int + + dims = self.shared_lib.ocp_nlp_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage_, field) + + if value_.shape[0] != dims: + msg = 'AcadosOcpSolver.set(): mismatching dimension for field "{}" '.format(field_) + msg += 'with dimension {} (you have {})'.format(dims, value_.shape) + raise Exception(msg) + + value_data = cast(value_.ctypes.data, POINTER(c_double)) + value_data_p = cast((value_data), c_void_p) + + if field_ in constraints_fields: + self.shared_lib.ocp_nlp_constraints_model_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_constraints_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, value_data_p) + elif field_ in cost_fields: + self.shared_lib.ocp_nlp_cost_model_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_cost_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, value_data_p) + elif field_ in out_fields: + self.shared_lib.ocp_nlp_out_set.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_out_set(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage, field, value_data_p) + elif field_ in mem_fields: + self.shared_lib.ocp_nlp_set.argtypes = \ + [c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_set(self.nlp_config, \ + self.nlp_solver, stage, field, value_data_p) + return + + + def get_slice(self, start_stage_, end_stage_, field_): + """ + Get the last solution of the solver: + + :param start_stage: integer corresponding to shooting node that indicates start of slice + :param end_stage: integer corresponding to shooting node that indicates end of slice + :param field: string in ['x', 'u', 'z', 'pi', 'lam', 't', 'sl', 'su',] + + .. note:: regarding lam, t: \n + the inequalities are internally organized in the following order: \n + [ lbu lbx lg lh lphi ubu ubx ug uh uphi; \n + lsbu lsbx lsg lsh lsphi usbu usbx usg ush usphi] + + .. note:: pi: multipliers for dynamics equality constraints \n + lam: multipliers for inequalities \n + t: slack variables corresponding to evaluation of all inequalities (at the solution) \n + sl: slack variables of soft lower inequality constraints \n + su: slack variables of soft upper inequality constraints \n + """ + out_fields = ['x', 'u', 'z', 'pi', 'lam', 't'] + mem_fields = ['sl', 'su'] + field = field_ + field = field.encode('utf-8') + + if (field_ not in out_fields + mem_fields): + raise Exception('AcadosOcpSolver.get_slice(): {} is an invalid argument.\ + \n Possible values are {}. Exiting.'.format(field_, out_fields)) + + if not isinstance(start_stage_, int): + raise Exception('AcadosOcpSolver.get_slice(): stage index must be Integer.') + + if not isinstance(end_stage_, int): + raise Exception('AcadosOcpSolver.get_slice(): stage index must be Integer.') + + if start_stage_ >= end_stage_: + raise Exception('AcadosOcpSolver.get_slice(): end stage index must be larger than start stage index') + + if start_stage_ < 0 or end_stage_ > self.N + 1: + raise Exception('AcadosOcpSolver.get_slice(): stage index must be in [0, N], got: {}.'.format(self.N)) + self.shared_lib.ocp_nlp_dims_get_from_attr.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p] + self.shared_lib.ocp_nlp_dims_get_from_attr.restype = c_int + + dims = self.shared_lib.ocp_nlp_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, start_stage_, field) + + out = np.ascontiguousarray(np.zeros((end_stage_ - start_stage_, dims)), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + if (field_ in out_fields): + self.shared_lib.ocp_nlp_out_get_slice.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_out_get_slice(self.nlp_config, \ + self.nlp_dims, self.nlp_out, start_stage_, end_stage_, field, out_data) + elif field_ in mem_fields: + self.shared_lib.ocp_nlp_get_at_stage.argtypes = \ + [c_void_p, c_void_p, c_void_p, c_int, c_char_p, c_void_p] + self.shared_lib.ocp_nlp_get_at_stage(self.nlp_config, \ + self.nlp_dims, self.nlp_solver, start_stage_, end_stage_, field, out_data) + + return out + + def get_cost(self): + """ + Returns the cost value of the current solution. + """ + # compute cost internally + self.shared_lib.ocp_nlp_eval_cost.argtypes = [c_void_p, c_void_p, c_void_p] + self.shared_lib.ocp_nlp_eval_cost(self.nlp_solver, self.nlp_in, self.nlp_out) + + # create output array + out = np.ascontiguousarray(np.zeros((1,)), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + # call getter + self.shared_lib.ocp_nlp_get.argtypes = [c_void_p, c_void_p, c_char_p, c_void_p] + + field = "cost_value".encode('utf-8') + self.shared_lib.ocp_nlp_get(self.nlp_config, self.nlp_solver, field, out_data) + + return out[0] diff --git a/pyextra/acados_template/acados_ocp_solver_pyx.pyx b/pyextra/acados_template/acados_ocp_solver_pyx.pyx new file mode 100644 index 00000000000000..b950d880b08a01 --- /dev/null +++ b/pyextra/acados_template/acados_ocp_solver_pyx.pyx @@ -0,0 +1,427 @@ +# -*- coding: future_fstrings -*- +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# +# cython: language_level=3 +# cython: profile=False +# distutils: language=c + +cimport cython +from libc cimport string + +cimport acados_solver_common +cimport acados_solver + +cimport numpy as cnp + +import os +import numpy as np + + +cdef class AcadosOcpSolverFast: + """ + Class to interact with the acados ocp solver C object. + + :param acados_ocp: type AcadosOcp - description of the OCP for acados + :param json_file: name for the json file used to render the templated code - default: acados_ocp_nlp.json + :param simulink_opts: Options to configure Simulink S-function blocks, mainly to activate possible Inputs and Outputs + """ + + cdef acados_solver.nlp_solver_capsule *capsule + cdef void *nlp_opts + cdef acados_solver_common.ocp_nlp_dims *nlp_dims + cdef acados_solver_common.ocp_nlp_config *nlp_config + cdef acados_solver_common.ocp_nlp_out *nlp_out + cdef acados_solver_common.ocp_nlp_in *nlp_in + cdef acados_solver_common.ocp_nlp_solver *nlp_solver + + cdef str model_name + cdef int N + cdef bint solver_created + + def __cinit__(self, str model_name, int N, str code_export_dir): + self.model_name = model_name + self.N = N + + self.solver_created = False + + # create capsule + self.capsule = acados_solver.acados_create_capsule() + + # create solver + assert acados_solver.acados_create(self.capsule) == 0 + self.solver_created = True + + # get pointers solver + self.nlp_opts = acados_solver.acados_get_nlp_opts(self.capsule) + self.nlp_dims = acados_solver.acados_get_nlp_dims(self.capsule) + self.nlp_config = acados_solver.acados_get_nlp_config(self.capsule) + self.nlp_out = acados_solver.acados_get_nlp_out(self.capsule) + self.nlp_in = acados_solver.acados_get_nlp_in(self.capsule) + self.nlp_solver = acados_solver.acados_get_nlp_solver(self.capsule) + + + def solve(self): + """ + Solve the ocp with current input. + """ + return acados_solver.acados_solve(self.capsule) + + + def set_new_time_steps(self, new_time_steps): + """ + Set new time steps before solving. Only reload library without code generation but with new time steps. + + :param new_time_steps: vector of new time steps for the solver + + .. note:: This allows for different use-cases: either set a new size of time-steps or a new distribution of + the shooting nodes without changing the number, e.g., to reach a different final time. Both cases + do not require a new code export and compilation. + """ + raise NotImplementedError() + + + def get(self, int stage, str field_): + """ + Get the last solution of the solver: + + :param stage: integer corresponding to shooting node + :param field: string in ['x', 'u', 'z', 'pi', 'lam', 't', 'sl', 'su',] + + .. note:: regarding lam, t: \n + the inequalities are internally organized in the following order: \n + [ lbu lbx lg lh lphi ubu ubx ug uh uphi; \n + lsbu lsbx lsg lsh lsphi usbu usbx usg ush usphi] + + .. note:: pi: multipliers for dynamics equality constraints \n + lam: multipliers for inequalities \n + t: slack variables corresponding to evaluation of all inequalities (at the solution) \n + sl: slack variables of soft lower inequality constraints \n + su: slack variables of soft upper inequality constraints \n + """ + + out_fields = ['x', 'u', 'z', 'pi', 'lam', 't', 'sl', 'su'] + field = field_.encode('utf-8') + + if field_ not in out_fields: + raise Exception('AcadosOcpSolver.get(): {} is an invalid argument.\ + \n Possible values are {}. Exiting.'.format(field_, out_fields)) + + if stage < 0 or stage > self.N: + raise Exception('AcadosOcpSolver.get(): stage index must be in [0, N], got: {}.'.format(self.N)) + + if stage == self.N and field_ == 'pi': + raise Exception('AcadosOcpSolver.get(): field {} does not exist at final stage {}.'\ + .format(field_, stage)) + + cdef int dims = acados_solver_common.ocp_nlp_dims_get_from_attr(self.nlp_config, + self.nlp_dims, self.nlp_out, stage, field) + + cdef cnp.ndarray[cnp.float64_t, ndim=1] out = np.zeros((dims,)) + acados_solver_common.ocp_nlp_out_get(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage, field, out.data) + + return out + + + def print_statistics(self): + """ + prints statistics of previous solver run as a table: + - iter: iteration number + - res_stat: stationarity residual + - res_eq: residual wrt equality constraints (dynamics) + - res_ineq: residual wrt inequality constraints (constraints) + - res_comp: residual wrt complementarity conditions + - qp_stat: status of QP solver + - qp_iter: number of QP iterations + - qp_res_stat: stationarity residual of the last QP solution + - qp_res_eq: residual wrt equality constraints (dynamics) of the last QP solution + - qp_res_ineq: residual wrt inequality constraints (constraints) of the last QP solution + - qp_res_comp: residual wrt complementarity conditions of the last QP solution + """ + raise NotImplementedError() + + + def store_iterate(self, filename='', overwrite=False): + """ + Stores the current iterate of the ocp solver in a json file. + + :param filename: if not set, use model_name + timestamp + '.json' + :param overwrite: if false and filename exists add timestamp to filename + """ + raise NotImplementedError() + + + def load_iterate(self, filename): + """ + Loads the iterate stored in json file with filename into the ocp solver. + """ + raise NotImplementedError() + + + def get_stats(self, field_): + """ + Get the information of the last solver call. + + :param field: string in ['statistics', 'time_tot', 'time_lin', 'time_sim', 'time_sim_ad', 'time_sim_la', 'time_qp', 'time_qp_solver_call', 'time_reg', 'sqp_iter'] + """ + raise NotImplementedError() + + + def get_cost(self): + """ + Returns the cost value of the current solution. + """ + # compute cost internally + acados_solver_common.ocp_nlp_eval_cost(self.nlp_solver, self.nlp_in, self.nlp_out) + + # create output + cdef double out + + # call getter + acados_solver_common.ocp_nlp_get(self.nlp_config, self.nlp_solver, "cost_value", &out) + + return out + + + def get_residuals(self): + """ + Returns an array of the form [res_stat, res_eq, res_ineq, res_comp]. + """ + raise NotImplementedError() + + + # Note: this function should not be used anymore, better use cost_set, constraints_set + def set(self, int stage, str field_, value_): + + """ + Set numerical data inside the solver. + + :param stage: integer corresponding to shooting node + :param field: string in ['x', 'u', 'pi', 'lam', 't', 'p'] + + .. note:: regarding lam, t: \n + the inequalities are internally organized in the following order: \n + [ lbu lbx lg lh lphi ubu ubx ug uh uphi; \n + lsbu lsbx lsg lsh lsphi usbu usbx usg ush usphi] + + .. note:: pi: multipliers for dynamics equality constraints \n + lam: multipliers for inequalities \n + t: slack variables corresponding to evaluation of all inequalities (at the solution) \n + sl: slack variables of soft lower inequality constraints \n + su: slack variables of soft upper inequality constraints \n + """ + cost_fields = ['y_ref', 'yref'] + constraints_fields = ['lbx', 'ubx', 'lbu', 'ubu'] + out_fields = ['x', 'u', 'pi', 'lam', 't', 'z', 'sl', 'su'] + + field = field_.encode('utf-8') + + cdef double[::1] value + + # treat parameters separately + if field_ == 'p': + value = np.ascontiguousarray(value_, dtype=np.double) + assert acados_solver.acados_update_params(self.capsule, stage, &value[0], value.shape[0]) == 0 + else: + if field_ not in constraints_fields + cost_fields + out_fields: + raise Exception("AcadosOcpSolver.set(): {} is not a valid argument.\ + \nPossible values are {}. Exiting.".format(field, \ + constraints_fields + cost_fields + out_fields + ['p'])) + + dims = acados_solver_common.ocp_nlp_dims_get_from_attr(self.nlp_config, + self.nlp_dims, self.nlp_out, stage, field) + + if value_.shape[0] != dims: + msg = 'AcadosOcpSolver.set(): mismatching dimension for field "{}" '.format(field_) + msg += 'with dimension {} (you have {})'.format(dims, value_.shape[0]) + raise Exception(msg) + + value = np.ascontiguousarray(value_, dtype=np.double) + if field_ in constraints_fields: + acados_solver_common.ocp_nlp_constraints_model_set(self.nlp_config, + self.nlp_dims, self.nlp_in, stage, field, &value[0]) + elif field_ in cost_fields: + acados_solver_common.ocp_nlp_cost_model_set(self.nlp_config, + self.nlp_dims, self.nlp_in, stage, field, &value[0]) + elif field_ in out_fields: + acados_solver_common.ocp_nlp_out_set(self.nlp_config, + self.nlp_dims, self.nlp_out, stage, field, &value[0]) + + + def cost_set(self, int stage, str field_, value_): + """ + Set numerical data in the cost module of the solver. + + :param stage: integer corresponding to shooting node + :param field: string, e.g. 'yref', 'W', 'ext_cost_num_hess' + :param value: of appropriate size + """ + field = field_.encode('utf-8') + + cdef int dims[2] + acados_solver_common.ocp_nlp_cost_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage, field, &dims[0]) + + cdef double[::1,:] value + + value_shape = value_.shape + if len(value_shape) == 1: + value_shape = (value_shape[0], 0) + value = np.asfortranarray(value_[None,:]) + + elif len(value_shape) == 2: + # Get elements in column major order + value = np.asfortranarray(value_) + + if value_shape[0] != dims[0] or value_shape[1] != dims[1]: + raise Exception('AcadosOcpSolver.cost_set(): mismatching dimension', \ + ' for field "{}" with dimension {} (you have {})'.format( \ + field_, tuple(dims), value_shape)) + + acados_solver_common.ocp_nlp_cost_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, &value[0][0]) + + + def constraints_set(self, int stage, str field_, value_): + """ + Set numerical data in the constraint module of the solver. + + :param stage: integer corresponding to shooting node + :param field: string in ['lbx', 'ubx', 'lbu', 'ubu', 'lg', 'ug', 'lh', 'uh', 'uphi', 'C', 'D'] + :param value: of appropriate size + """ + field = field_.encode('utf-8') + + cdef int dims[2] + acados_solver_common.ocp_nlp_constraint_dims_get_from_attr(self.nlp_config, \ + self.nlp_dims, self.nlp_out, stage, field, &dims[0]) + + cdef double[::1,:] value + + value_shape = value_.shape + if len(value_shape) == 1: + value_shape = (value_shape[0], 0) + value = np.asfortranarray(value_[None,:]) + + elif len(value_shape) == 2: + # Get elements in column major order + value = np.asfortranarray(value_) + + if value_shape[0] != dims[0] or value_shape[1] != dims[1]: + raise Exception('AcadosOcpSolver.constraints_set(): mismatching dimension' \ + ' for field "{}" with dimension {} (you have {})'.format(field_, tuple(dims), value_shape)) + + acados_solver_common.ocp_nlp_constraints_model_set(self.nlp_config, \ + self.nlp_dims, self.nlp_in, stage, field, &value[0][0]) + + return + + + def dynamics_get(self, int stage, str field_): + """ + Get numerical data from the dynamics module of the solver: + + :param stage: integer corresponding to shooting node + :param field: string, e.g. 'A' + """ + field = field_.encode('utf-8') + + # get dims + cdef int[2] dims + acados_solver_common.ocp_nlp_dynamics_dims_get_from_attr(self.nlp_config, self.nlp_dims, self.nlp_out, stage, field, &dims[0]) + + # create output data + out = np.zeros((dims[0], dims[1]), order='F', dtype=np.float64) + + # call getter + acados_solver_common.ocp_nlp_get_at_stage(self.nlp_config, self.nlp_dims, self.nlp_solver, stage, field, out.data) + + return out + + + def options_set(self, str field_, value_): + """ + Set options of the solver. + + :param field: string, e.g. 'print_level', 'rti_phase', 'initialize_t_slacks', 'step_length', 'alpha_min', 'alpha_reduction' + :param value: of type int, float + """ + int_fields = ['print_level', 'rti_phase', 'initialize_t_slacks'] + double_fields = ['step_length', 'tol_eq', 'tol_stat', 'tol_ineq', 'tol_comp', 'alpha_min', 'alpha_reduction'] + string_fields = ['globalization'] + + # encode + field = field_.encode('utf-8') + + cdef int int_value + cdef double double_value + cdef unsigned char[::1] string_value + + # check field availability and type + if field_ in int_fields: + if not isinstance(value_, int): + raise Exception('solver option {} must be of type int. You have {}.'.format(field_, type(value_))) + + if field_ == 'rti_phase': + if value_ < 0 or value_ > 2: + raise Exception('AcadosOcpSolver.solve(): argument \'rti_phase\' can ' + 'take only values 0, 1, 2 for SQP-RTI-type solvers') + if self.acados_ocp.solver_options.nlp_solver_type != 'SQP_RTI' and value_ > 0: + raise Exception('AcadosOcpSolver.solve(): argument \'rti_phase\' can ' + 'take only value 0 for SQP-type solvers') + + int_value = value_ + acados_solver_common.ocp_nlp_solver_opts_set(self.nlp_config, self.nlp_opts, field, &int_value) + + elif field_ in double_fields: + if not isinstance(value_, float): + raise Exception('solver option {} must be of type float. You have {}.'.format(field_, type(value_))) + + double_value = value_ + acados_solver_common.ocp_nlp_solver_opts_set(self.nlp_config, self.nlp_opts, field, &double_value) + + elif field_ in string_fields: + if not isinstance(value_, bytes): + raise Exception('solver option {} must be of type str. You have {}.'.format(field_, type(value_))) + + string_value = value_.encode('utf-8') + acados_solver_common.ocp_nlp_solver_opts_set(self.nlp_config, self.nlp_opts, field, &string_value[0]) + + raise Exception('AcadosOcpSolver.options_set() does not support field {}.'\ + '\n Possible values are {}.'.format(field_, ', '.join(int_fields + double_fields + string_fields))) + + + def __del__(self): + if self.solver_created: + acados_solver.acados_free(self.capsule) + acados_solver.acados_free_capsule(self.capsule) diff --git a/pyextra/acados_template/acados_sim.py b/pyextra/acados_template/acados_sim.py new file mode 100644 index 00000000000000..d7ad1487dc4a97 --- /dev/null +++ b/pyextra/acados_template/acados_sim.py @@ -0,0 +1,330 @@ +# -*- coding: future_fstrings -*- +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import numpy as np +import casadi as ca +import os +from .acados_model import AcadosModel +from .utils import get_acados_path + +class AcadosSimDims: + """ + Class containing the dimensions of the model to be simulated. + """ + def __init__(self): + self.__nx = None + self.__nu = None + self.__nz = 0 + self.__np = 0 + + @property + def nx(self): + """:math:`n_x` - number of states. Type: int > 0""" + return self.__nx + + @property + def nz(self): + """:math:`n_z` - number of algebraic variables. Type: int >= 0""" + return self.__nz + + @property + def nu(self): + """:math:`n_u` - number of inputs. Type: int >= 0""" + return self.__nu + + @property + def np(self): + """:math:`n_p` - number of parameters. Type: int >= 0""" + return self.__np + + @nx.setter + def nx(self, nx): + if type(nx) == int and nx > 0: + self.__nx = nx + else: + raise Exception('Invalid nx value, expected positive integer. Exiting.') + + @nz.setter + def nz(self, nz): + if type(nz) == int and nz > -1: + self.__nz = nz + else: + raise Exception('Invalid nz value, expected nonnegative integer. Exiting.') + + @nu.setter + def nu(self, nu): + if type(nu) == int and nu > -1: + self.__nu = nu + else: + raise Exception('Invalid nu value, expected nonnegative integer. Exiting.') + + @np.setter + def np(self, np): + if type(np) == int and np > -1: + self.__np = np + else: + raise Exception('Invalid np value, expected nonnegative integer. Exiting.') + + def set(self, attr, value): + setattr(self, attr, value) + + +class AcadosSimOpts: + """ + class containing the solver options + """ + def __init__(self): + self.__integrator_type = 'ERK' + self.__collocation_type = 'GAUSS_LEGENDRE' + self.__Tsim = None + # ints + self.__sim_method_num_stages = 1 + self.__sim_method_num_steps = 1 + self.__sim_method_newton_iter = 3 + # bools + self.__sens_forw = True + self.__sens_adj = False + self.__sens_algebraic = False + self.__sens_hess = False + self.__output_z = False + self.__sim_method_jac_reuse = 0 + + @property + def integrator_type(self): + """Integrator type. Default: 'ERK'.""" + return self.__integrator_type + + @property + def num_stages(self): + """Number of stages in the integrator. Default: 1""" + return self.__sim_method_num_stages + + @property + def num_steps(self): + """Number of steps in the integrator. Default: 1""" + return self.__sim_method_num_steps + + @property + def newton_iter(self): + """Number of Newton iterations in simulation method. Default: 3""" + return self.__sim_method_newton_iter + + @property + def sens_forw(self): + """Boolean determining if forward sensitivities are computed. Default: True""" + return self.__sens_forw + + @property + def sens_adj(self): + """Boolean determining if adjoint sensitivities are computed. Default: False""" + return self.__sens_adj + + @property + def sens_algebraic(self): + """Boolean determining if sensitivities wrt algebraic variables are computed. Default: False""" + return self.__sens_algebraic + + @property + def sens_hess(self): + """Boolean determining if hessians are computed. Default: False""" + return self.__sens_hess + + @property + def output_z(self): + """Boolean determining if values for algebraic variables (corresponding to start of simulation interval) are computed. Default: False""" + return self.__output_z + + @property + def sim_method_jac_reuse(self): + """Integer determining if jacobians are reused (0 or 1). Default: 0""" + return self.__sim_method_jac_reuse + + @property + def T(self): + """Time horizon""" + return self.__Tsim + + @property + def collocation_type(self): + """Collocation type: relevant for implicit integrators + -- string in {GAUSS_RADAU_IIA, GAUSS_LEGENDRE} + + Default: GAUSS_LEGENDRE + """ + return self.__collocation_type + + @integrator_type.setter + def integrator_type(self, integrator_type): + integrator_types = ('ERK', 'IRK', 'GNSF') + if integrator_type in integrator_types: + self.__integrator_type = integrator_type + else: + raise Exception('Invalid integrator_type value. Possible values are:\n\n' \ + + ',\n'.join(integrator_types) + '.\n\nYou have: ' + integrator_type + '.\n\nExiting.') + + @collocation_type.setter + def collocation_type(self, collocation_type): + collocation_types = ('GAUSS_RADAU_IIA', 'GAUSS_LEGENDRE') + if collocation_type in collocation_types: + self.__collocation_type = collocation_type + else: + raise Exception('Invalid collocation_type value. Possible values are:\n\n' \ + + ',\n'.join(collocation_types) + '.\n\nYou have: ' + collocation_type + '.\n\nExiting.') + + @T.setter + def T(self, T): + self.__Tsim = T + + @num_stages.setter + def num_stages(self, num_stages): + if isinstance(num_stages, int): + self.__sim_method_num_stages = num_stages + else: + raise Exception('Invalid num_stages value. num_stages must be an integer.') + + @num_steps.setter + def num_steps(self, num_steps): + if isinstance(num_steps, int): + self.__sim_method_num_steps = num_steps + else: + raise Exception('Invalid num_steps value. num_steps must be an integer.') + + @newton_iter.setter + def newton_iter(self, newton_iter): + if isinstance(newton_iter, int): + self.__sim_method_newton_iter = newton_iter + else: + raise Exception('Invalid newton_iter value. newton_iter must be an integer.') + + @sens_forw.setter + def sens_forw(self, sens_forw): + if sens_forw in (True, False): + self.__sens_forw = sens_forw + else: + raise Exception('Invalid sens_forw value. sens_forw must be a Boolean.') + + @sens_adj.setter + def sens_adj(self, sens_adj): + if sens_adj in (True, False): + self.__sens_adj = sens_adj + else: + raise Exception('Invalid sens_adj value. sens_adj must be a Boolean.') + + @sens_hess.setter + def sens_hess(self, sens_hess): + if sens_hess in (True, False): + self.__sens_hess = sens_hess + else: + raise Exception('Invalid sens_hess value. sens_hess must be a Boolean.') + + @sens_algebraic.setter + def sens_algebraic(self, sens_algebraic): + if sens_algebraic in (True, False): + self.__sens_algebraic = sens_algebraic + else: + raise Exception('Invalid sens_algebraic value. sens_algebraic must be a Boolean.') + + @output_z.setter + def output_z(self, output_z): + if output_z in (True, False): + self.__output_z = output_z + else: + raise Exception('Invalid output_z value. output_z must be a Boolean.') + + @sim_method_jac_reuse.setter + def sim_method_jac_reuse(self, sim_method_jac_reuse): + if sim_method_jac_reuse in (0, 1): + self.__sim_method_jac_reuse = sim_method_jac_reuse + else: + raise Exception('Invalid sim_method_jac_reuse value. sim_method_jac_reuse must be 0 or 1.') + +class AcadosSim: + """ + The class has the following properties that can be modified to formulate a specific simulation problem, see below: + + :param acados_path: string with the path to acados. It is used to generate the include and lib paths. + + - :py:attr:`dims` of type :py:class:`acados_template.acados_ocp.AcadosSimDims` - are automatically detected from model + - :py:attr:`model` of type :py:class:`acados_template.acados_model.AcadosModel` + - :py:attr:`solver_options` of type :py:class:`acados_template.acados_sim.AcadosSimOpts` + + - :py:attr:`acados_include_path` (set automatically) + - :py:attr:`acados_lib_path` (set automatically) + - :py:attr:`parameter_values` - used to initialize the parameters (can be changed) + + """ + def __init__(self, acados_path=''): + if acados_path == '': + acados_path = get_acados_path() + self.dims = AcadosSimDims() + """Dimension definitions, automatically detected from :py:attr:`model`. Type :py:class:`acados_template.acados_sim.AcadosSimDims`""" + self.model = AcadosModel() + """Model definitions, type :py:class:`acados_template.acados_model.AcadosModel`""" + self.solver_options = AcadosSimOpts() + """Solver Options, type :py:class:`acados_template.acados_sim.AcadosSimOpts`""" + + self.acados_include_path = f'{acados_path}/include' + """Path to acados include directors (set automatically), type: `string`""" + self.acados_lib_path = f'{acados_path}/lib' + """Path to where acados library is located (set automatically), type: `string`""" + + self.code_export_directory = 'c_generated_code' + """Path to where code will be exported. Default: `c_generated_code`.""" + + self.__parameter_values = np.array([]) + + @property + def parameter_values(self): + """:math:`p` - initial values for parameter - can be updated""" + return self.__parameter_values + + @parameter_values.setter + def parameter_values(self, parameter_values): + if isinstance(parameter_values, np.ndarray): + self.__parameter_values = parameter_values + else: + raise Exception('Invalid parameter_values value. ' + + f'Expected numpy array, got {type(parameter_values)}.') + + def set(self, attr, value): + # tokenize string + tokens = attr.split('_', 1) + if len(tokens) > 1: + setter_to_call = getattr(getattr(self, tokens[0]), 'set') + else: + setter_to_call = getattr(self, 'set') + + setter_to_call(tokens[1], value) + + return diff --git a/pyextra/acados_template/acados_sim_layout.json b/pyextra/acados_template/acados_sim_layout.json new file mode 100644 index 00000000000000..25b149613b387f --- /dev/null +++ b/pyextra/acados_template/acados_sim_layout.json @@ -0,0 +1,47 @@ +{ + "acados_include_path": [ + "str" + ], + "model": { + "name" : [ + "str" + ] + }, + "acados_lib_path": [ + "str" + ], + "dims": { + "np": [ + "int" + ], + "nu": [ + "int" + ], + "nx": [ + "int" + ], + "nz": [ + "int" + ] + }, + "solver_options": { + "integrator_type": [ + "str" + ], + "collocation_type": [ + "str" + ], + "Tsim": [ + "float" + ], + "sim_method_num_stages": [ + "int" + ], + "sim_method_num_steps": [ + "int" + ], + "sim_method_newton_iter": [ + "int" + ] + } +} diff --git a/pyextra/acados_template/acados_sim_solver.py b/pyextra/acados_template/acados_sim_solver.py new file mode 100644 index 00000000000000..145f90293e2a6d --- /dev/null +++ b/pyextra/acados_template/acados_sim_solver.py @@ -0,0 +1,404 @@ +# -*- coding: future_fstrings -*- +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import sys, os, json + +import numpy as np + +from ctypes import * +from copy import deepcopy + +from .generate_c_code_explicit_ode import generate_c_code_explicit_ode +from .generate_c_code_implicit_ode import generate_c_code_implicit_ode +from .generate_c_code_gnsf import generate_c_code_gnsf +from .acados_sim import AcadosSim +from .acados_ocp import AcadosOcp +from .acados_model import acados_model_strip_casadi_symbolics +from .utils import is_column, render_template, format_class_dict, np_array_to_list,\ + make_model_consistent, set_up_imported_gnsf_model, get_python_interface_path + + +def make_sim_dims_consistent(acados_sim): + dims = acados_sim.dims + model = acados_sim.model + # nx + if is_column(model.x): + dims.nx = model.x.shape[0] + else: + raise Exception("model.x should be column vector!") + + # nu + if is_column(model.u): + dims.nu = model.u.shape[0] + elif model.u == None or model.u == []: + dims.nu = 0 + else: + raise Exception("model.u should be column vector or None!") + + # nz + if is_column(model.z): + dims.nz = model.z.shape[0] + elif model.z == None or model.z == []: + dims.nz = 0 + else: + raise Exception("model.z should be column vector or None!") + + # np + if is_column(model.p): + dims.np = model.p.shape[0] + elif model.p == None or model.p == []: + dims.np = 0 + else: + raise Exception("model.p should be column vector or None!") + + +def get_sim_layout(): + python_interface_path = get_python_interface_path() + abs_path = os.path.join(python_interface_path, 'acados_sim_layout.json') + with open(abs_path, 'r') as f: + sim_layout = json.load(f) + return sim_layout + + +def sim_formulation_json_dump(acados_sim, json_file='acados_sim.json'): + # Load acados_sim structure description + sim_layout = get_sim_layout() + + # Copy input sim object dictionary + sim_dict = dict(deepcopy(acados_sim).__dict__) + + for key, v in sim_layout.items(): + # skip non dict attributes + if not isinstance(v, dict): continue + # Copy sim object attributes dictionaries + sim_dict[key]=dict(getattr(acados_sim, key).__dict__) + + sim_dict['model'] = acados_model_strip_casadi_symbolics(sim_dict['model']) + sim_json = format_class_dict(sim_dict) + + with open(json_file, 'w') as f: + json.dump(sim_json, f, default=np_array_to_list, indent=4, sort_keys=True) + + +def sim_render_templates(json_file, model_name, code_export_dir): + # setting up loader and environment + json_path = os.path.join(os.getcwd(), json_file) + + if not os.path.exists(json_path): + raise Exception(f"{json_path} not found!") + + template_dir = code_export_dir + + ## Render templates + in_file = 'acados_sim_solver.in.c' + out_file = f'acados_sim_solver_{model_name}.c' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'acados_sim_solver.in.h' + out_file = f'acados_sim_solver_{model_name}.h' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'Makefile.in' + out_file = f'Makefile' + render_template(in_file, out_file, template_dir, json_path) + + in_file = 'main_sim.in.c' + out_file = f'main_sim_{model_name}.c' + render_template(in_file, out_file, template_dir, json_path) + + ## folder model + template_dir = os.path.join(code_export_dir, model_name + '_model') + + in_file = 'model.in.h' + out_file = f'{model_name}_model.h' + render_template(in_file, out_file, template_dir, json_path) + + +def sim_generate_casadi_functions(acados_sim): + model = acados_sim.model + model = make_model_consistent(model) + + integrator_type = acados_sim.solver_options.integrator_type + + opts = dict(generate_hess = acados_sim.solver_options.sens_hess, + code_export_directory = acados_sim.code_export_directory) + # generate external functions + if integrator_type == 'ERK': + generate_c_code_explicit_ode(model, opts) + elif integrator_type == 'IRK': + generate_c_code_implicit_ode(model, opts) + elif integrator_type == 'GNSF': + generate_c_code_gnsf(model, opts) + +class AcadosSimSolver: + """ + Class to interact with the acados integrator C object. + + :param acados_sim: type :py:class:`acados_template.acados_ocp.AcadosOcp` (takes values to generate an instance :py:class:`acados_template.acados_sim.AcadosSim`) or :py:class:`acados_template.acados_sim.AcadosSim` + :param json_file: Default: 'acados_sim.json' + :param build: Default: True + """ + def __init__(self, acados_sim_, json_file='acados_sim.json', build=True): + + self.solver_created = False + + if isinstance(acados_sim_, AcadosOcp): + # set up acados_sim_ + acados_sim = AcadosSim() + acados_sim.model = acados_sim_.model + acados_sim.dims.nx = acados_sim_.dims.nx + acados_sim.dims.nu = acados_sim_.dims.nu + acados_sim.dims.nz = acados_sim_.dims.nz + acados_sim.dims.np = acados_sim_.dims.np + acados_sim.solver_options.integrator_type = acados_sim_.solver_options.integrator_type + acados_sim.code_export_directory = acados_sim_.code_export_directory + + elif isinstance(acados_sim_, AcadosSim): + acados_sim = acados_sim_ + + acados_sim.__problem_class = 'SIM' + + model_name = acados_sim.model.name + make_sim_dims_consistent(acados_sim) + + # reuse existing json and casadi functions, when creating integrator from ocp + if isinstance(acados_sim_, AcadosSim): + if acados_sim.solver_options.integrator_type == 'GNSF': + set_up_imported_gnsf_model(acados_sim) + + sim_generate_casadi_functions(acados_sim) + sim_formulation_json_dump(acados_sim, json_file) + + code_export_dir = acados_sim.code_export_directory + if build: + # render templates + sim_render_templates(json_file, model_name, code_export_dir) + + ## Compile solver + cwd = os.getcwd() + os.chdir(code_export_dir) + os.system('make sim_shared_lib') + os.chdir(cwd) + + self.sim_struct = acados_sim + model_name = self.sim_struct.model.name + self.model_name = model_name + + # Ctypes + shared_lib = f'{code_export_dir}/libacados_sim_solver_{model_name}.so' + self.shared_lib = CDLL(shared_lib) + + + # create capsule + getattr(self.shared_lib, f"{model_name}_acados_sim_solver_create_capsule").restype = c_void_p + self.capsule = getattr(self.shared_lib, f"{model_name}_acados_sim_solver_create_capsule")() + + # create solver + getattr(self.shared_lib, f"{model_name}_acados_sim_create").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_sim_create").restype = c_int + assert getattr(self.shared_lib, f"{model_name}_acados_sim_create")(self.capsule)==0 + self.solver_created = True + + getattr(self.shared_lib, f"{model_name}_acados_get_sim_opts").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_sim_opts").restype = c_void_p + self.sim_opts = getattr(self.shared_lib, f"{model_name}_acados_get_sim_opts")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_sim_dims").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_sim_dims").restype = c_void_p + self.sim_dims = getattr(self.shared_lib, f"{model_name}_acados_get_sim_dims")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_sim_config").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_sim_config").restype = c_void_p + self.sim_config = getattr(self.shared_lib, f"{model_name}_acados_get_sim_config")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_sim_out").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_sim_out").restype = c_void_p + self.sim_out = getattr(self.shared_lib, f"{model_name}_acados_get_sim_out")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_sim_in").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_sim_in").restype = c_void_p + self.sim_in = getattr(self.shared_lib, f"{model_name}_acados_get_sim_in")(self.capsule) + + getattr(self.shared_lib, f"{model_name}_acados_get_sim_solver").argtypes = [c_void_p] + getattr(self.shared_lib, f"{model_name}_acados_get_sim_solver").restype = c_void_p + self.sim_solver = getattr(self.shared_lib, f"{model_name}_acados_get_sim_solver")(self.capsule) + + nu = self.sim_struct.dims.nu + nx = self.sim_struct.dims.nx + nz = self.sim_struct.dims.nz + self.gettable = { + 'x': nx, + 'xn': nx, + 'u': nu, + 'z': nz, + 'S_forw': nx*(nx+nu), + 'Sx': nx*nx, + 'Su': nx*nu, + 'S_adj': nx+nu, + 'S_hess': (nx+nu)*(nx+nu), + 'S_algebraic': (nz)*(nx+nu), + } + + self.settable = ['S_adj', 'T', 'x', 'u', 'xdot', 'z', 'p'] # S_forw + + + def solve(self): + """ + Solve the simulation problem with current input. + """ + getattr(self.shared_lib, f"{self.model_name}_acados_sim_solve").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_sim_solve").restype = c_int + + status = getattr(self.shared_lib, f"{self.model_name}_acados_sim_solve")(self.capsule) + return status + + + def get(self, field_): + """ + Get the last solution of the solver. + + :param str field: string in ['x', 'u', 'z', 'S_forw', 'Sx', 'Su', 'S_adj', 'S_hess', 'S_algebraic'] + """ + field = field_ + field = field.encode('utf-8') + + if field_ in self.gettable.keys(): + + # allocate array + dims = self.gettable[field_] + out = np.ascontiguousarray(np.zeros((dims,)), dtype=np.float64) + out_data = cast(out.ctypes.data, POINTER(c_double)) + + self.shared_lib.sim_out_get.argtypes = [c_void_p, c_void_p, c_void_p, c_char_p, c_void_p] + self.shared_lib.sim_out_get(self.sim_config, self.sim_dims, self.sim_out, field, out_data) + + if field_ == 'S_forw': + nu = self.sim_struct.dims.nu + nx = self.sim_struct.dims.nx + out = out.reshape(nx, nx+nu, order='F') + elif field_ == 'Sx': + nx = self.sim_struct.dims.nx + out = out.reshape(nx, nx, order='F') + elif field_ == 'Su': + nx = self.sim_struct.dims.nx + nu = self.sim_struct.dims.nu + out = out.reshape(nx, nu, order='F') + elif field_ == 'S_hess': + nx = self.sim_struct.dims.nx + nu = self.sim_struct.dims.nu + out = out.reshape(nx+nu, nx+nu, order='F') + elif field_ == 'S_algebraic': + nx = self.sim_struct.dims.nx + nu = self.sim_struct.dims.nu + nz = self.sim_struct.dims.nz + out = out.reshape(nz, nx+nu, order='F') + else: + raise Exception(f'AcadosSimSolver.get(): Unknown field {field_},' \ + f' available fields are {", ".join(self.gettable.keys())}') + + return out + + + def set(self, field_, value_): + """ + Set numerical data inside the solver. + + :param field: string in ['p', 'S_adj', 'T', 'x', 'u', 'xdot', 'z'] + :param value: the value with appropriate size. + """ + # cast value_ to avoid conversion issues + if isinstance(value_, (float, int)): + value_ = np.array([value_]) + + value_ = value_.astype(float) + value_data = cast(value_.ctypes.data, POINTER(c_double)) + value_data_p = cast((value_data), c_void_p) + + field = field_ + field = field.encode('utf-8') + + # treat parameters separately + if field_ == 'p': + model_name = self.sim_struct.model.name + getattr(self.shared_lib, f"{model_name}_acados_sim_update_params").argtypes = [c_void_p, POINTER(c_double), c_int] + value_data = cast(value_.ctypes.data, POINTER(c_double)) + getattr(self.shared_lib, f"{model_name}_acados_sim_update_params")(self.capsule, value_data, value_.shape[0]) + return + else: + # dimension check + dims = np.ascontiguousarray(np.zeros((2,)), dtype=np.intc) + dims_data = cast(dims.ctypes.data, POINTER(c_int)) + + self.shared_lib.sim_dims_get_from_attr.argtypes = [c_void_p, c_void_p, c_char_p, POINTER(c_int)] + self.shared_lib.sim_dims_get_from_attr(self.sim_config, self.sim_dims, field, dims_data) + + value_ = np.ravel(value_, order='F') + + value_shape = value_.shape + if len(value_shape) == 1: + value_shape = (value_shape[0], 0) + + if value_shape != tuple(dims): + raise Exception('AcadosSimSolver.set(): mismatching dimension' \ + ' for field "{}" with dimension {} (you have {})'.format(field_, tuple(dims), value_shape)) + + # set + if field_ in ['xdot', 'z']: + self.shared_lib.sim_solver_set.argtypes = [c_void_p, c_char_p, c_void_p] + self.shared_lib.sim_solver_set(self.sim_solver, field, value_data_p) + elif field_ in self.settable: + self.shared_lib.sim_in_set.argtypes = [c_void_p, c_void_p, c_void_p, c_char_p, c_void_p] + self.shared_lib.sim_in_set(self.sim_config, self.sim_dims, self.sim_in, field, value_data_p) + else: + raise Exception(f'AcadosSimSolver.set(): Unknown field {field_},' \ + f' available fields are {", ".join(self.settable)}') + + return + + + def __del__(self): + + if self.solver_created: + getattr(self.shared_lib, f"{self.model_name}_acados_sim_free").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_sim_free").restype = c_int + getattr(self.shared_lib, f"{self.model_name}_acados_sim_free")(self.capsule) + + getattr(self.shared_lib, f"{self.model_name}_acados_sim_solver_free_capsule").argtypes = [c_void_p] + getattr(self.shared_lib, f"{self.model_name}_acados_sim_solver_free_capsule").restype = c_int + getattr(self.shared_lib, f"{self.model_name}_acados_sim_solver_free_capsule")(self.capsule) + + try: + self.dlclose(self.shared_lib._handle) + except: + pass diff --git a/pyextra/acados_template/acados_solver_common.pxd b/pyextra/acados_template/acados_solver_common.pxd new file mode 100644 index 00000000000000..9314802e61b71e --- /dev/null +++ b/pyextra/acados_template/acados_solver_common.pxd @@ -0,0 +1,102 @@ +# -*- coding: future_fstrings -*- +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + + +cdef extern from "acados/ocp_nlp/ocp_nlp_common.h": + ctypedef struct ocp_nlp_config: + pass + + ctypedef struct ocp_nlp_dims: + pass + + ctypedef struct ocp_nlp_in: + pass + + ctypedef struct ocp_nlp_out: + pass + + +cdef extern from "acados_c/ocp_nlp_interface.h": + ctypedef enum ocp_nlp_solver_t: + pass + + ctypedef enum ocp_nlp_cost_t: + pass + + ctypedef enum ocp_nlp_dynamics_t: + pass + + ctypedef enum ocp_nlp_constraints_t: + pass + + ctypedef enum ocp_nlp_reg_t: + pass + + ctypedef struct ocp_nlp_plan: + pass + + ctypedef struct ocp_nlp_solver: + pass + + int ocp_nlp_cost_model_set(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in_, + int start_stage, const char *field, void *value) + int ocp_nlp_constraints_model_set(ocp_nlp_config *config, ocp_nlp_dims *dims, + ocp_nlp_in *in_, int stage, const char *field, void *value) + + # out + void ocp_nlp_out_set(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, void *value) + void ocp_nlp_out_get(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, void *value) + void ocp_nlp_get_at_stage(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_solver *solver, + int stage, const char *field, void *value) + int ocp_nlp_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field) + void ocp_nlp_constraint_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, int *dims_out) + void ocp_nlp_cost_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, int *dims_out) + void ocp_nlp_dynamics_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, int *dims_out) + + # opts + void ocp_nlp_solver_opts_set(ocp_nlp_config *config, void *opts_, const char *field, void* value) + + # solver + void ocp_nlp_eval_residuals(ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out) + void ocp_nlp_eval_cost(ocp_nlp_solver *solver, ocp_nlp_in *nlp_in_, ocp_nlp_out *nlp_out) + + # get/set + void ocp_nlp_get(ocp_nlp_config *config, ocp_nlp_solver *solver, const char *field, void *return_value_) + void ocp_nlp_set(ocp_nlp_config *config, ocp_nlp_solver *solver, int stage, const char *field, void *value) diff --git a/pyextra/acados_template/c_templates_tera/CPPLINT.cfg b/pyextra/acados_template/c_templates_tera/CPPLINT.cfg new file mode 100644 index 00000000000000..bbd1caf0571825 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/CPPLINT.cfg @@ -0,0 +1 @@ +exclude_files=[main, acados_solver, acados_solver_sfun, Makefile, model].*\.? diff --git a/pyextra/acados_template/c_templates_tera/Makefile.in b/pyextra/acados_template/c_templates_tera/Makefile.in new file mode 100644 index 00000000000000..487e66ab072854 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/Makefile.in @@ -0,0 +1,524 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +{%- if solver_options.qp_solver %} + {%- set qp_solver = solver_options.qp_solver %} +{%- else %} + {%- set qp_solver = "FULL_CONDENSING_HPIPM" %} +{%- endif %} + +{%- if solver_options.hessian_approx %} + {%- set hessian_approx = solver_options.hessian_approx %} +{%- elif solver_options.sens_hess %} + {%- set hessian_approx = "EXACT" %} +{%- else %} + {%- set hessian_approx = "GAUSS_NEWTON" %} +{%- endif %} + +{%- if constraints.constr_type %} + {%- set constr_type = constraints.constr_type %} +{%- else %} + {%- set constr_type = "NONE" %} +{%- endif %} + +{%- if constraints.constr_type_e %} + {%- set constr_type_e = constraints.constr_type_e %} +{%- else %} + {%- set constr_type_e = "NONE" %} +{%- endif %} + +{%- if cost.cost_type %} + {%- set cost_type = cost.cost_type %} +{%- else %} + {%- set cost_type = "NONE" %} +{%- endif %} + +{%- if cost.cost_type_e %} + {%- set cost_type_e = cost.cost_type_e %} +{%- else %} + {%- set cost_type_e = "NONE" %} +{%- endif %} + +{%- if cost.cost_type_0 %} + {%- set cost_type_0 = cost.cost_type_0 %} +{%- else %} + {%- set cost_type_0 = "NONE" %} +{%- endif %} + +{%- if dims.nh %} + {%- set dims_nh = dims.nh %} +{%- else %} + {%- set dims_nh = 0 %} +{%- endif %} + +{%- if dims.nphi %} + {%- set dims_nphi = dims.nphi %} +{%- else %} + {%- set dims_nphi = 0 %} +{%- endif %} + +{%- if dims.nh_e %} + {%- set dims_nh_e = dims.nh_e %} +{%- else %} + {%- set dims_nh_e = 0 %} +{%- endif %} + +{%- if dims.nphi_e %} + {%- set dims_nphi_e = dims.nphi_e %} +{%- else %} + {%- set dims_nphi_e = 0 %} +{%- endif %} +{%- if solver_options.model_external_shared_lib_dir %} + {%- set model_external_shared_lib_dir = solver_options.model_external_shared_lib_dir %} +{%- endif %} +{%- if solver_options.model_external_shared_lib_name %} + {%- set model_external_shared_lib_name = solver_options.model_external_shared_lib_name %} +{%- endif %} + +{# control operator #} +{%- if os and os == "pc" %} + {%- set control = "&" %} +{%- else %} + {%- set control = ";" %} +{%- endif %} + +{# acados linking libraries and flags #} +{%- if acados_link_libs and os and os == "pc" %} + {%- set link_libs = acados_link_libs.qpoases ~ " " ~ acados_link_libs.hpmpc ~ " " ~ acados_link_libs.osqp -%} + {%- set openmp_flag = acados_link_libs.openmp %} +{%- else %} + {%- set openmp_flag = " " %} + {%- if qp_solver == "FULL_CONDENSING_QPOASES" %} + {%- set link_libs = "-lqpOASES_e" %} + {%- else %} + {%- set link_libs = "" %} + {%- endif %} +{%- endif %} + +{# acados flags #} +ACADOS_FLAGS = -fPIC -std=c99 {{ openmp_flag }} #-fno-diagnostics-show-line-numbers -g +{%- if qp_solver == "FULL_CONDENSING_QPOASES" %} +ACADOS_FLAGS += -DACADOS_WITH_QPOASES +{%- endif %} +{%- if qp_solver == "PARTIAL_CONDENSING_OSQP" %} +ACADOS_FLAGS += -DACADOS_WITH_OSQP +{%- endif %} +{%- if qp_solver == "PARTIAL_CONDENSING_QPDUNES" %} +ACADOS_FLAGS += -DACADOS_WITH_QPDUNES +{%- endif %} +# # Debugging +# ACADOS_FLAGS += -g3 + +MODEL_OBJ= +{%- if solver_options.integrator_type == "ERK" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_expl_ode_fun.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_expl_vde_forw.o +{%- if hessian_approx == "EXACT" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_expl_ode_hess.o +{%- endif %} +{%- elif solver_options.integrator_type == "IRK" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_impl_dae_fun.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_impl_dae_fun_jac_x_xdot_z.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_impl_dae_jac_x_xdot_u_z.o +{%- if hessian_approx == "EXACT" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_impl_dae_hess.o +{%- endif %} +{%- elif solver_options.integrator_type == "LIFTED_IRK" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_impl_dae_fun.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_impl_dae_fun_jac_x_xdot_u.o +{%- if hessian_approx == "EXACT" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_impl_dae_hess.o +{%- endif %} +{%- elif solver_options.integrator_type == "GNSF" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_gnsf_phi_fun.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_gnsf_phi_fun_jac_y.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_gnsf_phi_jac_y_uhat.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_gnsf_get_matrices_fun.o +{%- elif solver_options.integrator_type == "DISCRETE" %} +{%- if model.dyn_ext_fun_type == "casadi" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun.o +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun_jac.o +{%- if hessian_approx == "EXACT" %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun_jac_hess.o +{%- endif %} +{%- else %} +MODEL_OBJ+= {{ model.name }}_model/{{ model.dyn_source_discrete }} +{%- endif %} +{%- endif %} + + +OCP_OBJ= +{%- if constr_type == "BGP" and dims_nphi > 0 %} +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_phi_constraint.o +{%- endif %} +{%- if constr_type_e == "BGP" and dims_nphi_e > 0 %} +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_phi_e_constraint.o +{%- endif %} + +{%- if constr_type == "BGH" and dims_nh > 0 %} +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_constr_h_fun_jac_uxt_zt.o +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_constr_h_fun.o +{%- if hessian_approx == "EXACT" %} +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_constr_h_fun_jac_uxt_zt_hess.o +{%- endif %} +{%- endif %} + +{%- if constr_type_e == "BGH" and dims_nh_e > 0 %} +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun_jac_uxt_zt.o +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun.o +{%- if hessian_approx == "EXACT" %} +OCP_OBJ+= {{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess.o +{%- endif %} +{%- endif %} + +{%- if cost_type_0 == "NONLINEAR_LS" %} +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_0_fun.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_0_fun_jac_ut_xt.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_0_hess.c +{%- elif cost_type_0 == "EXTERNAL" %} +{% if cost.cost_ext_fun_type_0 == "casadi" %} +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun_jac.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun_jac_hess.c +{% else %} +OCP_OBJ+= {{ model.name }}_cost/{{ cost.cost_source_ext_cost_0 }} +{% endif %} +{%- endif %} +{%- if cost_type == "NONLINEAR_LS" %} +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_fun.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_fun_jac_ut_xt.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_hess.c +{%- elif cost_type == "EXTERNAL" %} +{% if cost.cost_ext_fun_type == "casadi" %} +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun_jac.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun_jac_hess.c +{% elif cost.cost_source_ext_cost != cost.cost_source_ext_cost_0 %} +OCP_OBJ+= {{ model.name }}_cost/{{ cost.cost_source_ext_cost }} +{% endif %} +{%- endif %} +{%- if cost_type_e == "NONLINEAR_LS" %} +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_e_fun.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_e_fun_jac_ut_xt.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_y_e_hess.c +{%- elif cost_type_e == "EXTERNAL" %} +{% if cost.cost_ext_fun_type_e == "casadi" %} +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun_jac.c +OCP_OBJ+= {{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun_jac_hess.c +{% elif cost.cost_source_ext_cost_e != cost.cost_source_ext_cost_0 %} +OCP_OBJ+= {{ model.name }}_cost/{{ cost.cost_source_ext_cost_e }} +{% endif %} +{%- endif %} +OCP_OBJ+= acados_solver_{{ model.name }}.o + + +SIM_OBJ= +SIM_OBJ+= acados_sim_solver_{{ model.name }}.o + +EX_OBJ= +EX_OBJ+= main_{{ model.name }}.o + +EX_SIM_OBJ= +EX_SIM_OBJ+= main_sim_{{ model.name }}.o + +OBJ= +OBJ+= $(MODEL_OBJ) +{%- if solver_options.integrator_type != "DISCRETE" %} +OBJ+= $(SIM_OBJ) +{%- endif %} +OBJ+= $(OCP_OBJ) + +EXTERNAL_DIR= +EXTERNAL_LIB= + +{%- if model_external_shared_lib_dir and model_external_shared_lib_name %} +EXTERNAL_DIR+= {{ model_external_shared_lib_dir }} +EXTERNAL_LIB+= {{ model_external_shared_lib_name }} +{%- endif %} + +INCLUDE_PATH = {{ acados_include_path }} +LIB_PATH = {{ acados_lib_path }} + +{%- if solver_options.integrator_type == "DISCRETE" %} +all: clean casadi_fun example +shared_lib: ocp_shared_lib +{%- else %} +all: clean casadi_fun example_sim example +shared_lib: bundled_shared_lib ocp_shared_lib sim_shared_lib +{%- endif %} + +CASADI_MODEL_SOURCE= +{%- if solver_options.integrator_type == "ERK" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_expl_ode_fun.c +CASADI_MODEL_SOURCE+= {{ model.name }}_expl_vde_forw.c +{%- if hessian_approx == "EXACT" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_expl_ode_hess.c +{%- endif %} +{%- elif solver_options.integrator_type == "IRK" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_fun.c +CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_fun_jac_x_xdot_z.c +CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_jac_x_xdot_u_z.c +{%- if hessian_approx == "EXACT" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_hess.c +{%- endif %} +{%- elif solver_options.integrator_type == "LIFTED_IRK" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_fun.c +# CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_fun_jac_x_xdot_z.c +# CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_jac_x_xdot_u_z.c +CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_fun_jac_x_xdot_u.c +{%- if hessian_approx == "EXACT" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_impl_dae_hess.c +{%- endif %} +{%- elif solver_options.integrator_type == "GNSF" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_gnsf_phi_fun.c +CASADI_MODEL_SOURCE+= {{ model.name }}_gnsf_phi_fun_jac_y.c +CASADI_MODEL_SOURCE+= {{ model.name }}_gnsf_phi_jac_y_uhat.c +CASADI_MODEL_SOURCE+= {{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz.c +CASADI_MODEL_SOURCE+= {{ model.name }}_gnsf_get_matrices_fun.c +{%- elif solver_options.integrator_type == "DISCRETE" and model.dyn_ext_fun_type == "casadi" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_dyn_disc_phi_fun.c +CASADI_MODEL_SOURCE+= {{ model.name }}_dyn_disc_phi_fun_jac.c +{%- if hessian_approx == "EXACT" %} +CASADI_MODEL_SOURCE+= {{ model.name }}_dyn_disc_phi_fun_jac_hess.c +{%- endif %} +{%- endif %} +{%- if constr_type == "BGP" and dims_nphi > 0 %} +CASADI_CON_PHI_SOURCE= +CASADI_CON_PHI_SOURCE+= {{ model.name }}_phi_constraint.c +{%- endif %} +{%- if constr_type_e == "BGP" and dims_nphi_e > 0 %} +CASADI_CON_PHI_E_SOURCE= +CASADI_CON_PHI_E_SOURCE+= {{ model.name }}_phi_e_constraint.c +{%- endif %} +{%- if constr_type == "BGH" and dims_nh > 0 %} +CASADI_CON_H_SOURCE= +CASADI_CON_H_SOURCE+= {{ model.name }}_constr_h_fun_jac_uxt_zt.c +CASADI_CON_H_SOURCE+= {{ model.name }}_constr_h_fun.c +{%- if hessian_approx == "EXACT" %} +CASADI_CON_H_SOURCE+= {{ model.name }}_constr_h_fun_jac_uxt_zt_hess.c +{%- endif %} +{%- endif %} + +{%- if dims_nh_e > 0 %} +CASADI_CON_H_E_SOURCE= +CASADI_CON_H_E_SOURCE+= {{ model.name }}_constr_h_e_fun_jac_uxt_zt.c +CASADI_CON_H_E_SOURCE+= {{ model.name }}_constr_h_e_fun.c +{%- if hessian_approx == "EXACT" %} +CASADI_CON_H_E_SOURCE+= {{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess.c +{%- endif %} +{%- endif %} + +{%- if cost_type == "NONLINEAR_LS" %} +CASADI_COST_Y_SOURCE= +CASADI_COST_Y_SOURCE+= {{ model.name }}_cost_y_fun.c +CASADI_COST_Y_SOURCE+= {{ model.name }}_cost_y_fun_jac_ut_xt.c +CASADI_COST_Y_SOURCE+= {{ model.name }}_cost_y_hess.c +{%- endif %} +{%- if cost_type_e == "NONLINEAR_LS" %} +CASADI_COST_Y_E_SOURCE= +CASADI_COST_Y_E_SOURCE+= {{ model.name }}_cost_y_e_fun.c +CASADI_COST_Y_E_SOURCE+= {{ model.name }}_cost_y_e_fun_jac_ut_xt.c +CASADI_COST_Y_E_SOURCE+= {{ model.name }}_cost_y_e_hess.c +{%- endif %} +{%- if cost_type_0 == "NONLINEAR_LS" %} +CASADI_COST_Y_0_SOURCE= +CASADI_COST_Y_0_SOURCE+= {{ model.name }}_cost_y_0_fun.c +CASADI_COST_Y_0_SOURCE+= {{ model.name }}_cost_y_0_fun_jac_ut_xt.c +CASADI_COST_Y_0_SOURCE+= {{ model.name }}_cost_y_0_hess.c +{%- endif %} + +casadi_fun: + {%- if model.dyn_ext_fun_type == "casadi" %} + ( cd {{ model.name }}_model {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_MODEL_SOURCE)) + {%- endif %} + {%- if constr_type == "BGP" and dims_nphi > 0 %} + ( cd {{ model.name }}_constraints {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_CON_PHI_SOURCE)) + {%- endif %} + {%- if constr_type_e == "BGP" and dims_nphi_e > 0 %} + ( cd {{ model.name }}_constraints {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_CON_PHI_E_SOURCE)) + {%- endif %} + {%- if constr_type == "BGH" and dims_nh > 0 %} + ( cd {{ model.name }}_constraints {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_CON_H_SOURCE)) + {%- endif %} + {%- if constr_type_e == "BGH" and dims_nh_e > 0 %} + ( cd {{ model.name }}_constraints {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_CON_H_E_SOURCE)) + {%- endif %} + {%- if cost_type == "NONLINEAR_LS" %} + ( cd {{ model.name }}_cost {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_COST_Y_SOURCE)) + {%- endif %} + {%- if cost_type_e == "NONLINEAR_LS" %} + ( cd {{ model.name }}_cost {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_COST_Y_E_SOURCE)) + {%- endif %} + {%- if cost_type_0 == "NONLINEAR_LS" %} + ( cd {{ model.name }}_cost {{ control }} gcc $(ACADOS_FLAGS) -c $(CASADI_COST_Y_0_SOURCE)) + {%- endif %} + +main: + gcc $(ACADOS_FLAGS) -c main_{{ model.name }}.c -I $(INCLUDE_PATH)/blasfeo/include/ -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) -I $(INCLUDE_PATH)/acados/ \ + {%- if qp_solver == "FULL_CONDENSING_QPOASES" %} + -I $(INCLUDE_PATH)/qpOASES_e/ + {%- endif %} + +main_sim: + gcc $(ACADOS_FLAGS) -c main_sim_{{ model.name }}.c -I $(INCLUDE_PATH)/blasfeo/include/ -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) -I $(INCLUDE_PATH)/acados/ + +ocp_solver: + gcc $(ACADOS_FLAGS) -c acados_solver_{{ model.name }}.c -I $(INCLUDE_PATH)/blasfeo/include/ -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) -I $(INCLUDE_PATH)/acados/ \ + {%- if qp_solver == "FULL_CONDENSING_QPOASES" %} + -I $(INCLUDE_PATH)/qpOASES_e/ + {%- endif %} + +sim_solver: + gcc $(ACADOS_FLAGS) -c acados_sim_solver_{{ model.name }}.c -I $(INCLUDE_PATH)/blasfeo/include/ -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) -I $(INCLUDE_PATH)/acados/ \ + {%- if qp_solver == "FULL_CONDENSING_QPOASES" %} + -I $(INCLUDE_PATH)/qpOASES_e/ + {%- endif %} + +example: ocp_solver main + gcc $(ACADOS_FLAGS) -o main_{{ model.name }} $(EX_OBJ) $(OBJ) -L $(LIB_PATH) \ + -lacados -lhpipm -lblasfeo \ + {{ link_libs }} \ + -lm \ + -I $(INCLUDE_PATH)/blasfeo/include/ \ + -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) \ + -I $(INCLUDE_PATH)/acados/ \ + {%- if qp_solver == "FULL_CONDENSING_QPOASES" %} + -I $(INCLUDE_PATH)/qpOASES_e/ + {%- endif %} + + +example_sim: sim_solver main_sim + gcc $(ACADOS_FLAGS) -o main_sim_{{ model.name }} $(EX_SIM_OBJ) $(MODEL_OBJ) $(SIM_OBJ) -L $(LIB_PATH) \ + -lacados -lhpipm -lblasfeo \ + {{ link_libs }} \ + -lm \ + -I $(INCLUDE_PATH)/blasfeo/include/ \ + -I $(INCLUDE_PATH)/acados/ \ + +{%- if solver_options.integrator_type != "DISCRETE" %} + +bundled_shared_lib: casadi_fun ocp_solver sim_solver + gcc $(ACADOS_FLAGS) -shared -o libacados_solver_{{ model.name }}.so $(OBJ) \ + -I $(INCLUDE_PATH)/blasfeo/include/ \ + -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) \ + -L $(LIB_PATH) \ + -lacados -lhpipm -lblasfeo \ + {{ link_libs }} \ + -lm \ + +ocp_shared_lib: casadi_fun ocp_solver + gcc $(ACADOS_FLAGS) -shared -o libacados_ocp_solver_{{ model.name }}.so $(OCP_OBJ) $(MODEL_OBJ) \ + -I $(INCLUDE_PATH)/blasfeo/include/ \ + -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) \ + -L$(EXTERNAL_DIR) -l$(EXTERNAL_LIB) \ + -L $(LIB_PATH) -lacados -lhpipm -lblasfeo \ + {{ link_libs }} \ + -lm \ + +{%- else %} + +ocp_shared_lib: casadi_fun ocp_solver + gcc $(ACADOS_FLAGS) -shared -o libacados_ocp_solver_{{ model.name }}.so $(OCP_OBJ) $(MODEL_OBJ) \ + -I $(INCLUDE_PATH)/blasfeo/include/ \ + -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) \ + -L$(EXTERNAL_DIR) -l$(EXTERNAL_LIB) \ + -L $(LIB_PATH) -lacados -lhpipm -lblasfeo \ + {{ link_libs }} \ + -lm \ + +{%- endif %} + +ocp_cython_c: ocp_shared_lib + cython \ + -o acados_ocp_solver_pyx.c \ + -I $(INCLUDE_PATH)/../interfaces/acados_template/acados_template \ + $(INCLUDE_PATH)/../interfaces/acados_template/acados_template/acados_ocp_solver_pyx.pyx \ + +ocp_cython_o: ocp_cython_c + clang $(ACADOS_FLAGS) -c -O2 \ + -o acados_ocp_solver_pyx.o \ + -I /usr/include/python3.8 \ + -I $(INCLUDE_PATH)/blasfeo/include/ \ + -I $(INCLUDE_PATH)/hpipm/include/ \ + -I $(INCLUDE_PATH) \ + acados_ocp_solver_pyx.c \ + +ocp_cython: ocp_cython_o + clang $(ACADOS_FLAGS) -shared \ + -o acados_ocp_solver_pyx.so \ + -Wl,-rpath=$(LIB_PATH) \ + acados_ocp_solver_pyx.o \ + $(abspath .)/libacados_ocp_solver_{{ model.name }}.so \ + -L $(LIB_PATH) -lacados -lhpipm -lblasfeo -lqpOASES_e \ + {{ link_libs }} \ + -lm \ + +sim_shared_lib: casadi_fun sim_solver + gcc $(ACADOS_FLAGS) -shared -o libacados_sim_solver_{{ model.name }}.so $(SIM_OBJ) $(MODEL_OBJ) -L$(EXTERNAL_DIR) -l$(EXTERNAL_LIB) \ + -L $(LIB_PATH) -lacados -lhpipm -lblasfeo \ + {{ link_libs }} \ + -lm \ + +{%- if os and os == "pc" %} + +clean: + del \Q *.o 2>nul + del \Q *.so 2>nul + del \Q main_{{ model.name }} 2>nul + +clean_ocp_shared_lib: + del \Q libacados_ocp_solver_{{ model.name }}.so 2>nul + del \Q acados_solver_{{ model.name }}.o 2>nul + +{%- else %} + +clean: + rm -f *.o + rm -f *.so + rm -f main_{{ model.name }} + +clean_ocp_shared_lib: + rm -f libacados_ocp_solver_{{ model.name }}.so + rm -f acados_solver_{{ model.name }}.o + +{%- endif %} diff --git a/pyextra/acados_template/c_templates_tera/acados_mex_create.in.c b/pyextra/acados_template/c_templates_tera/acados_mex_create.in.c new file mode 100644 index 00000000000000..251b249b2fb655 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_mex_create.in.c @@ -0,0 +1,383 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +// standard +#include +#include +#include + +// acados +#include "acados/utils/print.h" +#include "acados_c/ocp_nlp_interface.h" +#include "acados_solver_{{ model.name }}.h" + +// mex +#include "mex.h" + + +void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +{ + long long *l_ptr; + int status = 0; + + // create solver + {{ model.name }}_solver_capsule *acados_ocp_capsule = {{ model.name }}_acados_create_capsule(); + + status = {{ model.name }}_acados_create(acados_ocp_capsule); + + if (status) + { + mexPrintf("{{ model.name }}_acados_create() returned status %d.\n", status); + } + mexPrintf("{{ model.name }}_acados_create() -> success!\n"); + + // get pointers to nlp solver related objects + ocp_nlp_plan *nlp_plan = {{ model.name }}_acados_get_nlp_plan(acados_ocp_capsule); + ocp_nlp_config *nlp_config = {{ model.name }}_acados_get_nlp_config(acados_ocp_capsule); + ocp_nlp_dims *nlp_dims = {{ model.name }}_acados_get_nlp_dims(acados_ocp_capsule); + ocp_nlp_in *nlp_in = {{ model.name }}_acados_get_nlp_in(acados_ocp_capsule); + ocp_nlp_out *nlp_out = {{ model.name }}_acados_get_nlp_out(acados_ocp_capsule); + ocp_nlp_solver *nlp_solver = {{ model.name }}_acados_get_nlp_solver(acados_ocp_capsule); + void *nlp_opts = {{ model.name }}_acados_get_nlp_opts(acados_ocp_capsule); + + // mexPrintf("acados: got pointer to objectes!\n"); + + // field names of output struct + #define FIELDS_OCP 9 + #define FIELDS_EXT_FUN 25 + #define MAX_FIELDS 25 + char *fieldnames[MAX_FIELDS]; + + for (int i = 0; i < MAX_FIELDS; i++) + { + fieldnames[i] = (char*) mxMalloc(50); + } + + memcpy(fieldnames[0],"config",sizeof("config")); + memcpy(fieldnames[1],"dims",sizeof("dims")); + memcpy(fieldnames[2],"opts",sizeof("opts")); + memcpy(fieldnames[3],"in",sizeof("in")); + memcpy(fieldnames[4],"out",sizeof("out")); + memcpy(fieldnames[5],"solver",sizeof("solver")); + memcpy(fieldnames[6],"sens_out",sizeof("sens_out")); + memcpy(fieldnames[7],"plan",sizeof("plan")); + memcpy(fieldnames[8],"capsule",sizeof("capsule")); + + // create output struct - C_ocp + plhs[0] = mxCreateStructMatrix(1, 1, 9, (const char **) fieldnames); + + // MEX: config, dims, opts, in, out, solver, sens_out, plan + // plan + mxArray *plan_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(plan_mat); + l_ptr[0] = (long long) nlp_plan; + mxSetField(plhs[0], 0, "plan", plan_mat); + + // config + mxArray *config_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(config_mat); + l_ptr[0] = (long long) nlp_config; + mxSetField(plhs[0], 0, "config", config_mat); + + // dims + mxArray *dims_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(dims_mat); + l_ptr[0] = (long long) nlp_dims; + mxSetField(plhs[0], 0, "dims", dims_mat); + + // opts + mxArray *opts_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(opts_mat); + l_ptr[0] = (long long) nlp_opts; + mxSetField(plhs[0], 0, "opts", opts_mat); + + // in + mxArray *in_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(in_mat); + l_ptr[0] = (long long) nlp_in; + mxSetField(plhs[0], 0, "in", in_mat); + + // out + mxArray *out_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(out_mat); + l_ptr[0] = (long long) nlp_out; + mxSetField(plhs[0], 0, "out", out_mat); + + // solver + mxArray *solver_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(solver_mat); + l_ptr[0] = (long long) nlp_solver; + mxSetField(plhs[0], 0, "solver", solver_mat); + + // TODO: sens_out not actually implemented in templates.. + // sens_out + mxArray *sens_out_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(sens_out_mat); + l_ptr[0] = (long long) 1; + mxSetField(plhs[0], 0, "sens_out", sens_out_mat); + + // capsule + mxArray *capsule_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(capsule_mat); + l_ptr[0] = (long long) acados_ocp_capsule; + mxSetField(plhs[0], 0, "capsule", capsule_mat); + + /* store external function pointers */ + // dyn + memcpy(fieldnames[0],"expl_ode_fun",sizeof("expl_ode_fun")); + memcpy(fieldnames[1],"forw_vde",sizeof("forw_vde")); + memcpy(fieldnames[2],"hess_vde",sizeof("hess_vde")); + memcpy(fieldnames[3],"impl_dae_fun",sizeof("impl_dae_fun")); + memcpy(fieldnames[4],"impl_dae_fun_jac_x_xdot_z",sizeof("impl_dae_fun_jac_x_xdot_z")); + memcpy(fieldnames[5],"impl_dae_jac_x_xdot_u_z",sizeof("impl_dae_jac_x_xdot_u_z")); + memcpy(fieldnames[6],"impl_dae_hess",sizeof("impl_dae_hess")); + + memcpy(fieldnames[7],"gnsf_phi_fun",sizeof("gnsf_phi_fun")); + memcpy(fieldnames[8],"gnsf_phi_fun_jac_y",sizeof("gnsf_phi_fun_jac_y")); + memcpy(fieldnames[9],"gnsf_phi_jac_y_uhat",sizeof("gnsf_phi_jac_y_uhat")); + memcpy(fieldnames[10],"gnsf_f_lo_jac_x1_x1dot_u_z",sizeof("gnsf_f_lo_jac_x1_x1dot_u_z")); + memcpy(fieldnames[11],"gnsf_get_matrices_fun",sizeof("gnsf_get_matrices_fun")); + + memcpy(fieldnames[12],"disc_phi_fun",sizeof("disc_phi_fun")); + memcpy(fieldnames[13],"disc_phi_fun_jac",sizeof("disc_phi_fun_jac")); + memcpy(fieldnames[14],"disc_phi_fun_jac_hess",sizeof("disc_phi_fun_jac_hess")); + + // cost + memcpy(fieldnames[15],"cost_y_fun",sizeof("cost_y_fun")); + memcpy(fieldnames[16],"cost_y_fun_jac_ut_xt",sizeof("cost_y_fun_jac_ut_xt")); + memcpy(fieldnames[17],"cost_y_hess",sizeof("cost_y_hess")); + memcpy(fieldnames[18],"ext_cost_fun",sizeof("ext_cost_fun")); + memcpy(fieldnames[19],"ext_cost_fun_jac",sizeof("ext_cost_fun_jac")); + memcpy(fieldnames[20],"ext_cost_fun_jac_hess",sizeof("ext_cost_fun_jac_hess")); + + // constraints + memcpy(fieldnames[21],"phi_constraint",sizeof("phi_constraint")); + memcpy(fieldnames[22],"nl_constr_h_fun_jac",sizeof("nl_constr_h_fun_jac")); + memcpy(fieldnames[23],"nl_constr_h_fun",sizeof("nl_constr_h_fun")); + memcpy(fieldnames[24],"nl_constr_h_fun_jac_hess",sizeof("nl_constr_h_fun_jac_hess")); + + + // create output struct - C_ocp_ext_fun + plhs[1] = mxCreateStructMatrix(1, 1, FIELDS_EXT_FUN, (const char **) fieldnames); + + + for (int i = 0; i < FIELDS_EXT_FUN; i++) + { + mxFree( fieldnames[i] ); + } + +/* dynamics */ + mxArray *expl_ode_fun_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *forw_vde_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *hess_vde_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *impl_dae_fun_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *impl_dae_fun_jac_x_xdot_z_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *impl_dae_jac_x_xdot_u_z_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *impl_dae_hess_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + + mxArray *gnsf_phi_fun_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *gnsf_phi_fun_jac_y_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *gnsf_phi_jac_y_uhat_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *gnsf_f_lo_jac_x1_x1dot_u_z_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *gnsf_get_matrices_fun_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + + mxArray *disc_phi_fun_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *disc_phi_fun_jac_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + mxArray *disc_phi_fun_jac_hess_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL); + +{% if solver_options.integrator_type == "ERK" %} + {# TODO: remove _casadi from these names.. #} + l_ptr = mxGetData(forw_vde_mat); + l_ptr[0] = (long long) acados_ocp_capsule->forw_vde_casadi; + l_ptr = mxGetData(expl_ode_fun_mat); + l_ptr[0] = (long long) acados_ocp_capsule->expl_ode_fun; +{% if solver_options.hessian_approx == "EXACT" %} + l_ptr = mxGetData(hess_vde_mat); + l_ptr[0] = (long long) acados_ocp_capsule->hess_vde_casadi; +{%- endif %} +{% elif solver_options.integrator_type == "IRK" %} + l_ptr = mxGetData(impl_dae_fun_mat); + l_ptr[0] = (long long) acados_ocp_capsule->impl_dae_fun; + l_ptr = mxGetData(impl_dae_fun_jac_x_xdot_z_mat); + l_ptr[0] = (long long) acados_ocp_capsule->impl_dae_fun_jac_x_xdot_z; + l_ptr = mxGetData(impl_dae_jac_x_xdot_u_z_mat); + l_ptr[0] = (long long) acados_ocp_capsule->impl_dae_jac_x_xdot_u_z; +{% if solver_options.hessian_approx == "EXACT" %} + l_ptr = mxGetData(impl_dae_hess_mat); + l_ptr[0] = (long long) acados_ocp_capsule->impl_dae_hess; +{%- endif %} +{% elif solver_options.integrator_type == "GNSF" %} + l_ptr = mxGetData(gnsf_phi_fun_mat); + l_ptr[0] = (long long) acados_ocp_capsule->gnsf_phi_fun; + l_ptr = mxGetData(gnsf_phi_fun_jac_y_mat); + l_ptr[0] = (long long) acados_ocp_capsule->gnsf_phi_fun_jac_y; + l_ptr = mxGetData(gnsf_phi_jac_y_uhat_mat); + l_ptr[0] = (long long) acados_ocp_capsule->gnsf_phi_jac_y_uhat; + l_ptr = mxGetData(gnsf_f_lo_jac_x1_x1dot_u_z_mat); + l_ptr[0] = (long long) acados_ocp_capsule->gnsf_f_lo_jac_x1_x1dot_u_z; + l_ptr = mxGetData(gnsf_get_matrices_fun_mat); + l_ptr[0] = (long long) acados_ocp_capsule->gnsf_get_matrices_fun; +{% elif solver_options.integrator_type == "DISCRETE" %} + l_ptr = mxGetData(disc_phi_fun_mat); + l_ptr[0] = (long long) acados_ocp_capsule->discr_dyn_phi_fun; + l_ptr = mxGetData(disc_phi_fun_jac_mat); + l_ptr[0] = (long long) acados_ocp_capsule->discr_dyn_phi_fun_jac_ut_xt; +{% if solver_options.hessian_approx == "EXACT" %} + l_ptr = mxGetData(disc_phi_fun_jac_hess_mat); + l_ptr[0] = (long long) acados_ocp_capsule->discr_dyn_phi_fun_jac_ut_xt_hess; +{%- endif %} +{%- endif %} + mxSetField(plhs[1], 0, "expl_ode_fun", expl_ode_fun_mat); + mxSetField(plhs[1], 0, "forw_vde", forw_vde_mat); + mxSetField(plhs[1], 0, "hess_vde", hess_vde_mat); + + mxSetField(plhs[1], 0, "gnsf_phi_fun", gnsf_phi_fun_mat); + mxSetField(plhs[1], 0, "gnsf_phi_fun_jac_y", gnsf_phi_fun_jac_y_mat); + mxSetField(plhs[1], 0, "gnsf_phi_jac_y_uhat", gnsf_phi_jac_y_uhat_mat); + mxSetField(plhs[1], 0, "gnsf_f_lo_jac_x1_x1dot_u_z", gnsf_f_lo_jac_x1_x1dot_u_z_mat); + mxSetField(plhs[1], 0, "gnsf_get_matrices_fun", gnsf_get_matrices_fun_mat); + + mxSetField(plhs[1], 0, "impl_dae_fun", impl_dae_fun_mat); + mxSetField(plhs[1], 0, "impl_dae_fun_jac_x_xdot_z", impl_dae_fun_jac_x_xdot_z_mat); + mxSetField(plhs[1], 0, "impl_dae_jac_x_xdot_u_z", impl_dae_jac_x_xdot_u_z_mat); + mxSetField(plhs[1], 0, "impl_dae_hess", impl_dae_hess_mat); + + mxSetField(plhs[1], 0, "disc_phi_fun", disc_phi_fun_mat); + mxSetField(plhs[1], 0, "disc_phi_fun_jac", disc_phi_fun_jac_mat); + mxSetField(plhs[1], 0, "disc_phi_fun_jac_hess", disc_phi_fun_jac_hess_mat); +/* constaints */ + mxArray *phi_constraint_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(phi_constraint_mat); +{%- if constraints.constr_type == "BGP" %} + l_ptr[0] = (long long) acados_ocp_capsule->phi_constraint; +{% endif %} +{% if constraints.constr_type_e == "BGP" %} + l_ptr[1] = (long long) &acados_ocp_capsule->phi_e_constraint; +{% endif %} + mxSetField(plhs[1], 0, "phi_constraint", phi_constraint_mat); + + mxArray *nl_constr_h_fun_jac_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(nl_constr_h_fun_jac_mat); +{% if constraints.constr_type == "BGH" and dims.nh > 0 %} + l_ptr[0] = (long long) acados_ocp_capsule->nl_constr_h_fun_jac; +{% endif %} +{% if constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} + l_ptr[1] = (long long) &acados_ocp_capsule->nl_constr_h_e_fun_jac; +{%- endif %} + mxSetField(plhs[1], 0, "nl_constr_h_fun_jac", nl_constr_h_fun_jac_mat); + + mxArray *nl_constr_h_fun_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(nl_constr_h_fun_mat); +{% if constraints.constr_type == "BGH" and dims.nh > 0 %} + l_ptr[0] = (long long) acados_ocp_capsule->nl_constr_h_fun; +{% endif %} +{% if constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} + l_ptr[1] = (long long) &acados_ocp_capsule->nl_constr_h_e_fun; +{%- endif %} + mxSetField(plhs[1], 0, "nl_constr_h_fun", nl_constr_h_fun_mat); + + mxArray *nl_constr_h_fun_jac_hess_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(nl_constr_h_fun_jac_hess_mat); +{% if constraints.constr_type == "BGH" and dims.nh > 0 and solver_options.hessian_approx == "EXACT" %} + l_ptr[0] = (long long) acados_ocp_capsule->nl_constr_h_fun_jac_hess; +{% endif %} +{% if constraints.constr_type_e == "BGH" and dims.nh_e > 0 and solver_options.hessian_approx == "EXACT" %} + l_ptr[1] = (long long) &acados_ocp_capsule->nl_constr_h_e_fun_jac_hess; +{%- endif %} + mxSetField(plhs[1], 0, "nl_constr_h_fun_jac_hess", nl_constr_h_fun_jac_hess_mat); + +/* cost */ + mxArray *cost_y_fun_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(cost_y_fun_mat); +{% if cost.cost_type == "NONLINEAR_LS" %} + l_ptr[0] = (long long) acados_ocp_capsule->cost_y_fun; +{% endif %} +{% if cost.cost_type_e == "NONLINEAR_LS" %} + l_ptr[1] = (long long) &acados_ocp_capsule->cost_y_e_fun; +{%- endif %} + mxSetField(plhs[1], 0, "cost_y_fun", cost_y_fun_mat); + + mxArray *cost_y_fun_jac_ut_xt_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(cost_y_fun_jac_ut_xt_mat); +{% if cost.cost_type == "NONLINEAR_LS" %} + l_ptr[0] = (long long) acados_ocp_capsule->cost_y_fun_jac_ut_xt; +{% endif %} +{% if cost.cost_type_e == "NONLINEAR_LS" %} + l_ptr[1] = (long long) &acados_ocp_capsule->cost_y_e_fun_jac_ut_xt; +{%- endif %} + mxSetField(plhs[1], 0, "cost_y_fun_jac_ut_xt", cost_y_fun_jac_ut_xt_mat); + + mxArray *cost_y_hess_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(cost_y_hess_mat); +{% if cost.cost_type == "NONLINEAR_LS" %} + l_ptr[0] = (long long) acados_ocp_capsule->cost_y_hess; +{% endif %} +{% if cost.cost_type_e == "NONLINEAR_LS" %} + l_ptr[1] = (long long) &acados_ocp_capsule->cost_y_e_hess; +{%- endif %} + mxSetField(plhs[1], 0, "cost_y_hess", cost_y_hess_mat); + + mxArray *ext_cost_fun_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(ext_cost_fun_mat); +{% if cost.cost_type == "EXTERNAL" %} + l_ptr[0] = (long long) acados_ocp_capsule->ext_cost_fun; +{% endif -%} +{% if cost.cost_type_e == "EXTERNAL" %} + l_ptr[1] = (long long) &acados_ocp_capsule->ext_cost_e_fun; +{%- endif %} + mxSetField(plhs[1], 0, "ext_cost_fun", ext_cost_fun_mat); + + mxArray *ext_cost_fun_jac_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(ext_cost_fun_jac_mat); +{% if cost.cost_type == "EXTERNAL" %} + l_ptr[0] = (long long) acados_ocp_capsule->ext_cost_fun_jac; +{% endif -%} +{% if cost.cost_type_e == "EXTERNAL" %} + l_ptr[1] = (long long) &acados_ocp_capsule->ext_cost_e_fun_jac; +{%- endif %} + mxSetField(plhs[1], 0, "ext_cost_fun_jac", ext_cost_fun_jac_mat); + + mxArray *ext_cost_fun_jac_hess_mat = mxCreateNumericMatrix(1, 2, mxINT64_CLASS, mxREAL); + l_ptr = mxGetData(ext_cost_fun_jac_hess_mat); +{% if cost.cost_type == "EXTERNAL" %} + l_ptr[0] = (long long) acados_ocp_capsule->ext_cost_fun_jac_hess; +{% endif -%} +{% if cost.cost_type_e == "EXTERNAL" %} + l_ptr[1] = (long long) &acados_ocp_capsule->ext_cost_e_fun_jac_hess; +{%- endif %} + mxSetField(plhs[1], 0, "ext_cost_fun_jac_hess", ext_cost_fun_jac_hess_mat); + + + return; +} diff --git a/pyextra/acados_template/c_templates_tera/acados_mex_free.in.c b/pyextra/acados_template/c_templates_tera/acados_mex_free.in.c new file mode 100644 index 00000000000000..560adb0b986955 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_mex_free.in.c @@ -0,0 +1,70 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +// system +#include +#include +#include +// acados +#include "acados_solver_{{ model.name }}.h" + +// mex +#include "mex.h" + + +void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +{ + int status = 0; + long long *ptr; + + // mexPrintf("\nin mex_acados_free\n"); + const mxArray *C_ocp = prhs[0]; + // capsule + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "capsule" ) ); + {{ model.name }}_solver_capsule *capsule = ({{ model.name }}_solver_capsule *) ptr[0]; + + status = {{ model.name }}_acados_free(capsule); + if (status) + { + mexPrintf("{{ model.name }}_acados_free() returned status %d.\n", status); + } + + status = {{ model.name }}_acados_free_capsule(capsule); + if (status) + { + mexPrintf("{{ model.name }}_acados_free_capsule() returned status %d.\n", status); + } + + return; +} + diff --git a/pyextra/acados_template/c_templates_tera/acados_mex_set.in.c b/pyextra/acados_template/c_templates_tera/acados_mex_set.in.c new file mode 100644 index 00000000000000..ae8c3115578069 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_mex_set.in.c @@ -0,0 +1,570 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +// standard +#include +#include +#include + +// acados +#include "acados/utils/print.h" +#include "acados_c/ocp_nlp_interface.h" +#include "acados_solver_{{ model.name }}.h" + +// mex +#include "mex.h" +#include "mex_macros.h" + + +void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +{ + + long long *ptr; + int acados_size; + mxArray *mex_field; + char fun_name[20] = "ocp_set"; + char buffer [500]; // for error messages + + /* RHS */ + int min_nrhs = 6; + + char *ext_fun_type = mxArrayToString( prhs[0] ); + char *ext_fun_type_e = mxArrayToString( prhs[1] ); + + // C ocp + const mxArray *C_ocp = prhs[2]; + // capsule + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "capsule" ) ); + {{ model.name }}_solver_capsule *capsule = ({{ model.name }}_solver_capsule *) ptr[0]; + // plan + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "plan" ) ); + ocp_nlp_plan *plan = (ocp_nlp_plan *) ptr[0]; + // config + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "config" ) ); + ocp_nlp_config *config = (ocp_nlp_config *) ptr[0]; + // dims + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "dims" ) ); + ocp_nlp_dims *dims = (ocp_nlp_dims *) ptr[0]; + // opts + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "opts" ) ); + void *opts = (void *) ptr[0]; + // in + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "in" ) ); + ocp_nlp_in *in = (ocp_nlp_in *) ptr[0]; + // out + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "out" ) ); + ocp_nlp_out *out = (ocp_nlp_out *) ptr[0]; + // solver + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "solver" ) ); + ocp_nlp_solver *solver = (ocp_nlp_solver *) ptr[0]; + + const mxArray *C_ext_fun_pointers = prhs[3]; + // field + char *field = mxArrayToString( prhs[4] ); + // value + double *value = mxGetPr( prhs[5] ); + + // for checks + int matlab_size = (int) mxGetNumberOfElements( prhs[5] ); + int nrow = (int) mxGetM( prhs[5] ); + int ncol = (int) mxGetN( prhs[5] ); + + int N = dims->N; + int nu = dims->nu[0]; + int nx = dims->nx[0]; + + // stage + int s0, se; + if (nrhs==min_nrhs) + { + s0 = 0; + se = N; + } + else if (nrhs==min_nrhs+1) + { + s0 = mxGetScalar( prhs[6] ); + if (s0 > N) + { + sprintf(buffer, "ocp_set: N < specified stage = %d\n", s0); + mexErrMsgTxt(buffer); + } + se = s0 + 1; + } + else + { + sprintf(buffer, "ocp_set: wrong nrhs: %d\n", nrhs); + mexErrMsgTxt(buffer); + } + + /* Set value */ + // constraints + if (!strcmp(field, "constr_x0")) + { + acados_size = nx; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + ocp_nlp_constraints_model_set(config, dims, in, 0, "lbx", value); + ocp_nlp_constraints_model_set(config, dims, in, 0, "ubx", value); + } + else if (!strcmp(field, "constr_C")) + { + for (int ii=s0; iinlp_cost[ii] == LINEAR_LS) || (plan->nlp_cost[ii] == NONLINEAR_LS)) + { + acados_size = ocp_nlp_dims_get_from_attr(config, dims, out, ii, "y_ref"); + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + ocp_nlp_cost_model_set(config, dims, in, ii, "y_ref", value); + } + else + { + MEX_FIELD_NOT_SUPPORTED_FOR_COST_STAGE(fun_name, field, plan->nlp_cost[ii], ii); + } + } + } + else if (!strcmp(field, "cost_y_ref_e")) + { + acados_size = ocp_nlp_dims_get_from_attr(config, dims, out, N, "y_ref"); + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + ocp_nlp_cost_model_set(config, dims, in, N, "y_ref", value); + } + else if (!strcmp(field, "cost_Vu")) + { + for (int ii=s0; iinlp_cost[ii] == LINEAR_LS) || (plan->nlp_cost[ii] == NONLINEAR_LS)) + { + int ny = ocp_nlp_dims_get_from_attr(config, dims, out, ii, "y_ref"); + int nu = ocp_nlp_dims_get_from_attr(config, dims, out, ii, "u"); + acados_size = ny * nu; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + ocp_nlp_cost_model_set(config, dims, in, ii, "Vu", value); + } + else + { + MEX_FIELD_NOT_SUPPORTED_FOR_COST_STAGE(fun_name, field, plan->nlp_cost[ii], ii); + } + } + } + else if (!strcmp(field, "cost_Vx")) + { + for (int ii=s0; iinlp_cost[ii] == LINEAR_LS) || (plan->nlp_cost[ii] == NONLINEAR_LS)) + { + int ny = ocp_nlp_dims_get_from_attr(config, dims, out, ii, "y_ref"); + int nx = ocp_nlp_dims_get_from_attr(config, dims, out, ii, "x"); + acados_size = ny * nx; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + ocp_nlp_cost_model_set(config, dims, in, ii, "Vx", value); + } + else + { + MEX_FIELD_NOT_SUPPORTED_FOR_COST_STAGE(fun_name, field, plan->nlp_cost[ii], ii); + } + } + } + else if (!strcmp(field, "cost_W")) + { + for (int ii=s0; iinlp_cost[ii] == LINEAR_LS) || (plan->nlp_cost[ii] == NONLINEAR_LS)) + { + int ny = ocp_nlp_dims_get_from_attr(config, dims, out, s0, "y_ref"); + acados_size = ny * ny; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + ocp_nlp_cost_model_set(config, dims, in, ii, "W", value); + } + else + { + MEX_FIELD_NOT_SUPPORTED_FOR_COST_STAGE(fun_name, field, plan->nlp_cost[ii], ii); + } + } + } + else if (!strcmp(field, "cost_Z")) + { + acados_size = ocp_nlp_dims_get_from_attr(config, dims, out, s0, "cost_Z"); + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + for (int ii=s0; iisim_solver_plan[0]; + sim_solver_t type = sim_plan.sim_solver; + if (type == IRK) + { + int nz = ocp_nlp_dims_get_from_attr(config, dims, out, 0, "z"); + if (nrhs!=min_nrhs) + MEX_SETTER_NO_STAGE_SUPPORT(fun_name, field) + + acados_size = N*nz; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + for (int ii=0; iisim_solver_plan[0]; + sim_solver_t type = sim_plan.sim_solver; + if (type == IRK) + { + int nx = ocp_nlp_dims_get_from_attr(config, dims, out, 0, "x"); + if (nrhs!=min_nrhs) + MEX_SETTER_NO_STAGE_SUPPORT(fun_name, field) + + acados_size = N*nx; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + for (int ii=0; iisim_solver_plan[0]; + sim_solver_t type = sim_plan.sim_solver; + if (type == GNSF) + { + int nout = ocp_nlp_dims_get_from_attr(config, dims, out, 0, "init_gnsf_phi"); + + if (nrhs!=min_nrhs) + MEX_SETTER_NO_STAGE_SUPPORT(fun_name, field) + + acados_size = N*nout; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + for (int ii=0; iinlp_solver == SQP && rti_phase != 0) + { + MEX_FIELD_ONLY_SUPPORTED_FOR_SOLVER(fun_name, field, "sqp_rti") + } + ocp_nlp_solver_opts_set(config, opts, "rti_phase", &rti_phase); + } + else if (!strcmp(field, "qp_warm_start")) + { + acados_size = 1; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + int qp_warm_start = (int) value[0]; + ocp_nlp_solver_opts_set(config, opts, "qp_warm_start", &qp_warm_start); + } + else if (!strcmp(field, "warm_start_first_qp")) + { + acados_size = 1; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + int warm_start_first_qp = (int) value[0]; + ocp_nlp_solver_opts_set(config, opts, "warm_start_first_qp", &warm_start_first_qp); + } + else if (!strcmp(field, "print_level")) + { + acados_size = 1; + MEX_DIM_CHECK_VEC(fun_name, field, matlab_size, acados_size); + int print_level = (int) value[0]; + ocp_nlp_solver_opts_set(config, opts, "print_level", &print_level); + } + else + { + MEX_FIELD_NOT_SUPPORTED_SUGGEST(fun_name, field, "p, constr_x0,\ + constr_lbx, constr_ubx, constr_C, constr_D, constr_lg, constr_ug, constr_lh, constr_uh\ + constr_lbu, constr_ubu, cost_y_ref[_e],\ + cost_Vu, cost_Vx, cost_Vz, cost_W, cost_Z, cost_Zl, cost_Zu, cost_z,\ + cost_zl, cost_zu, init_x, init_u, init_z, init_xdot, init_gnsf_phi,\ + init_pi, nlp_solver_max_iter, qp_warm_start, warm_start_first_qp, print_level"); + } + + return; +} + diff --git a/pyextra/acados_template/c_templates_tera/acados_mex_solve.in.c b/pyextra/acados_template/c_templates_tera/acados_mex_solve.in.c new file mode 100644 index 00000000000000..c673d4bf22dc51 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_mex_solve.in.c @@ -0,0 +1,59 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +// system +#include +#include +#include +// acados +#include "acados_solver_{{ model.name }}.h" + +// mex +#include "mex.h" + + + +void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +{ + // C_ocp + long long *ptr; + const mxArray *C_ocp = prhs[0]; + + // capsule + ptr = (long long *) mxGetData( mxGetField( C_ocp, 0, "capsule" ) ); + {{ model.name }}_solver_capsule *capsule = ({{ model.name }}_solver_capsule *) ptr[0]; + + // solve + {{ model.name }}_acados_solve(capsule); + +} diff --git a/pyextra/acados_template/c_templates_tera/acados_sim_solver.in.c b/pyextra/acados_template/c_templates_tera/acados_sim_solver.in.c new file mode 100644 index 00000000000000..971fb8a78fc2ee --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_sim_solver.in.c @@ -0,0 +1,488 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +{%- if solver_options.hessian_approx %} + {%- set hessian_approx = solver_options.hessian_approx %} +{%- elif solver_options.sens_hess %} + {%- set hessian_approx = "EXACT" %} +{%- else %} + {%- set hessian_approx = "GAUSS_NEWTON" %} +{%- endif %} +// standard +#include +#include + +// acados +#include "acados_c/external_function_interface.h" +#include "acados_c/sim_interface.h" +#include "acados_c/external_function_interface.h" + +#include "acados/sim/sim_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/print.h" + + +// example specific +#include "{{ model.name }}_model/{{ model.name }}_model.h" +#include "acados_sim_solver_{{ model.name }}.h" + + +// ** solver data ** + +sim_solver_capsule * {{ model.name }}_acados_sim_solver_create_capsule() +{ + void* capsule_mem = malloc(sizeof(sim_solver_capsule)); + sim_solver_capsule *capsule = (sim_solver_capsule *) capsule_mem; + + return capsule; +} + + +int {{ model.name }}_acados_sim_solver_free_capsule(sim_solver_capsule * capsule) +{ + free(capsule); + return 0; +} + + +int {{ model.name }}_acados_sim_create(sim_solver_capsule * capsule) +{ + // initialize + const int nx = {{ model.name | upper }}_NX; + const int nu = {{ model.name | upper }}_NU; + const int nz = {{ model.name | upper }}_NZ; + const int np = {{ model.name | upper }}_NP; + bool tmp_bool; + + {#// double Tsim = {{ solver_options.tf / dims.N }};#} + double Tsim = {{ solver_options.Tsim }}; + + {% if solver_options.integrator_type == "IRK" %} + capsule->sim_impl_dae_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + capsule->sim_impl_dae_fun_jac_x_xdot_z = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + capsule->sim_impl_dae_jac_x_xdot_u_z = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + + // external functions (implicit model) + capsule->sim_impl_dae_fun->casadi_fun = &{{ model.name }}_impl_dae_fun; + capsule->sim_impl_dae_fun->casadi_work = &{{ model.name }}_impl_dae_fun_work; + capsule->sim_impl_dae_fun->casadi_sparsity_in = &{{ model.name }}_impl_dae_fun_sparsity_in; + capsule->sim_impl_dae_fun->casadi_sparsity_out = &{{ model.name }}_impl_dae_fun_sparsity_out; + capsule->sim_impl_dae_fun->casadi_n_in = &{{ model.name }}_impl_dae_fun_n_in; + capsule->sim_impl_dae_fun->casadi_n_out = &{{ model.name }}_impl_dae_fun_n_out; + external_function_param_casadi_create(capsule->sim_impl_dae_fun, np); + + capsule->sim_impl_dae_fun_jac_x_xdot_z->casadi_fun = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z; + capsule->sim_impl_dae_fun_jac_x_xdot_z->casadi_work = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_work; + capsule->sim_impl_dae_fun_jac_x_xdot_z->casadi_sparsity_in = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_sparsity_in; + capsule->sim_impl_dae_fun_jac_x_xdot_z->casadi_sparsity_out = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_sparsity_out; + capsule->sim_impl_dae_fun_jac_x_xdot_z->casadi_n_in = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_n_in; + capsule->sim_impl_dae_fun_jac_x_xdot_z->casadi_n_out = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_n_out; + external_function_param_casadi_create(capsule->sim_impl_dae_fun_jac_x_xdot_z, np); + + // external_function_param_casadi impl_dae_jac_x_xdot_u_z; + capsule->sim_impl_dae_jac_x_xdot_u_z->casadi_fun = &{{ model.name }}_impl_dae_jac_x_xdot_u_z; + capsule->sim_impl_dae_jac_x_xdot_u_z->casadi_work = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_work; + capsule->sim_impl_dae_jac_x_xdot_u_z->casadi_sparsity_in = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_sparsity_in; + capsule->sim_impl_dae_jac_x_xdot_u_z->casadi_sparsity_out = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_sparsity_out; + capsule->sim_impl_dae_jac_x_xdot_u_z->casadi_n_in = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_n_in; + capsule->sim_impl_dae_jac_x_xdot_u_z->casadi_n_out = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_n_out; + external_function_param_casadi_create(capsule->sim_impl_dae_jac_x_xdot_u_z, np); + +{%- if hessian_approx == "EXACT" %} + capsule->sim_impl_dae_hess = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + // external_function_param_casadi impl_dae_jac_x_xdot_u_z; + capsule->sim_impl_dae_hess->casadi_fun = &{{ model.name }}_impl_dae_hess; + capsule->sim_impl_dae_hess->casadi_work = &{{ model.name }}_impl_dae_hess_work; + capsule->sim_impl_dae_hess->casadi_sparsity_in = &{{ model.name }}_impl_dae_hess_sparsity_in; + capsule->sim_impl_dae_hess->casadi_sparsity_out = &{{ model.name }}_impl_dae_hess_sparsity_out; + capsule->sim_impl_dae_hess->casadi_n_in = &{{ model.name }}_impl_dae_hess_n_in; + capsule->sim_impl_dae_hess->casadi_n_out = &{{ model.name }}_impl_dae_hess_n_out; + external_function_param_casadi_create(capsule->sim_impl_dae_hess, np); +{%- endif %} + + {% elif solver_options.integrator_type == "ERK" %} + // explicit ode + capsule->sim_forw_vde_casadi = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + capsule->sim_expl_ode_fun_casadi = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + + capsule->sim_forw_vde_casadi->casadi_fun = &{{ model.name }}_expl_vde_forw; + capsule->sim_forw_vde_casadi->casadi_n_in = &{{ model.name }}_expl_vde_forw_n_in; + capsule->sim_forw_vde_casadi->casadi_n_out = &{{ model.name }}_expl_vde_forw_n_out; + capsule->sim_forw_vde_casadi->casadi_sparsity_in = &{{ model.name }}_expl_vde_forw_sparsity_in; + capsule->sim_forw_vde_casadi->casadi_sparsity_out = &{{ model.name }}_expl_vde_forw_sparsity_out; + capsule->sim_forw_vde_casadi->casadi_work = &{{ model.name }}_expl_vde_forw_work; + external_function_param_casadi_create(capsule->sim_forw_vde_casadi, np); + + capsule->sim_expl_ode_fun_casadi->casadi_fun = &{{ model.name }}_expl_ode_fun; + capsule->sim_expl_ode_fun_casadi->casadi_n_in = &{{ model.name }}_expl_ode_fun_n_in; + capsule->sim_expl_ode_fun_casadi->casadi_n_out = &{{ model.name }}_expl_ode_fun_n_out; + capsule->sim_expl_ode_fun_casadi->casadi_sparsity_in = &{{ model.name }}_expl_ode_fun_sparsity_in; + capsule->sim_expl_ode_fun_casadi->casadi_sparsity_out = &{{ model.name }}_expl_ode_fun_sparsity_out; + capsule->sim_expl_ode_fun_casadi->casadi_work = &{{ model.name }}_expl_ode_fun_work; + external_function_param_casadi_create(capsule->sim_expl_ode_fun_casadi, np); + +{%- if hessian_approx == "EXACT" %} + capsule->sim_expl_ode_hess = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + // external_function_param_casadi impl_dae_jac_x_xdot_u_z; + capsule->sim_expl_ode_hess->casadi_fun = &{{ model.name }}_expl_ode_hess; + capsule->sim_expl_ode_hess->casadi_work = &{{ model.name }}_expl_ode_hess_work; + capsule->sim_expl_ode_hess->casadi_sparsity_in = &{{ model.name }}_expl_ode_hess_sparsity_in; + capsule->sim_expl_ode_hess->casadi_sparsity_out = &{{ model.name }}_expl_ode_hess_sparsity_out; + capsule->sim_expl_ode_hess->casadi_n_in = &{{ model.name }}_expl_ode_hess_n_in; + capsule->sim_expl_ode_hess->casadi_n_out = &{{ model.name }}_expl_ode_hess_n_out; + external_function_param_casadi_create(capsule->sim_expl_ode_hess, np); +{%- endif %} + + {% elif solver_options.integrator_type == "GNSF" -%} + capsule->sim_gnsf_phi_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + capsule->sim_gnsf_phi_fun_jac_y = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + capsule->sim_gnsf_phi_jac_y_uhat = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + capsule->sim_gnsf_get_matrices_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)); + + capsule->sim_gnsf_phi_fun->casadi_fun = &{{ model.name }}_gnsf_phi_fun; + capsule->sim_gnsf_phi_fun->casadi_n_in = &{{ model.name }}_gnsf_phi_fun_n_in; + capsule->sim_gnsf_phi_fun->casadi_n_out = &{{ model.name }}_gnsf_phi_fun_n_out; + capsule->sim_gnsf_phi_fun->casadi_sparsity_in = &{{ model.name }}_gnsf_phi_fun_sparsity_in; + capsule->sim_gnsf_phi_fun->casadi_sparsity_out = &{{ model.name }}_gnsf_phi_fun_sparsity_out; + capsule->sim_gnsf_phi_fun->casadi_work = &{{ model.name }}_gnsf_phi_fun_work; + external_function_param_casadi_create(capsule->sim_gnsf_phi_fun, np); + + capsule->sim_gnsf_phi_fun_jac_y->casadi_fun = &{{ model.name }}_gnsf_phi_fun_jac_y; + capsule->sim_gnsf_phi_fun_jac_y->casadi_n_in = &{{ model.name }}_gnsf_phi_fun_jac_y_n_in; + capsule->sim_gnsf_phi_fun_jac_y->casadi_n_out = &{{ model.name }}_gnsf_phi_fun_jac_y_n_out; + capsule->sim_gnsf_phi_fun_jac_y->casadi_sparsity_in = &{{ model.name }}_gnsf_phi_fun_jac_y_sparsity_in; + capsule->sim_gnsf_phi_fun_jac_y->casadi_sparsity_out = &{{ model.name }}_gnsf_phi_fun_jac_y_sparsity_out; + capsule->sim_gnsf_phi_fun_jac_y->casadi_work = &{{ model.name }}_gnsf_phi_fun_jac_y_work; + external_function_param_casadi_create(capsule->sim_gnsf_phi_fun_jac_y, np); + + capsule->sim_gnsf_phi_jac_y_uhat->casadi_fun = &{{ model.name }}_gnsf_phi_jac_y_uhat; + capsule->sim_gnsf_phi_jac_y_uhat->casadi_n_in = &{{ model.name }}_gnsf_phi_jac_y_uhat_n_in; + capsule->sim_gnsf_phi_jac_y_uhat->casadi_n_out = &{{ model.name }}_gnsf_phi_jac_y_uhat_n_out; + capsule->sim_gnsf_phi_jac_y_uhat->casadi_sparsity_in = &{{ model.name }}_gnsf_phi_jac_y_uhat_sparsity_in; + capsule->sim_gnsf_phi_jac_y_uhat->casadi_sparsity_out = &{{ model.name }}_gnsf_phi_jac_y_uhat_sparsity_out; + capsule->sim_gnsf_phi_jac_y_uhat->casadi_work = &{{ model.name }}_gnsf_phi_jac_y_uhat_work; + external_function_param_casadi_create(capsule->sim_gnsf_phi_jac_y_uhat, np); + + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z->casadi_fun = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz; + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z->casadi_n_in = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_n_in; + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z->casadi_n_out = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_n_out; + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z->casadi_sparsity_in = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_sparsity_in; + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z->casadi_sparsity_out = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_sparsity_out; + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z->casadi_work = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_work; + external_function_param_casadi_create(capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z, np); + + capsule->sim_gnsf_get_matrices_fun->casadi_fun = &{{ model.name }}_gnsf_get_matrices_fun; + capsule->sim_gnsf_get_matrices_fun->casadi_n_in = &{{ model.name }}_gnsf_get_matrices_fun_n_in; + capsule->sim_gnsf_get_matrices_fun->casadi_n_out = &{{ model.name }}_gnsf_get_matrices_fun_n_out; + capsule->sim_gnsf_get_matrices_fun->casadi_sparsity_in = &{{ model.name }}_gnsf_get_matrices_fun_sparsity_in; + capsule->sim_gnsf_get_matrices_fun->casadi_sparsity_out = &{{ model.name }}_gnsf_get_matrices_fun_sparsity_out; + capsule->sim_gnsf_get_matrices_fun->casadi_work = &{{ model.name }}_gnsf_get_matrices_fun_work; + external_function_param_casadi_create(capsule->sim_gnsf_get_matrices_fun, np); + {% endif %} + + // sim plan & config + sim_solver_plan plan; + plan.sim_solver = {{ solver_options.integrator_type }}; + + // create correct config based on plan + sim_config * {{ model.name }}_sim_config = sim_config_create(plan); + capsule->acados_sim_config = {{ model.name }}_sim_config; + + // sim dims + void *{{ model.name }}_sim_dims = sim_dims_create({{ model.name }}_sim_config); + capsule->acados_sim_dims = {{ model.name }}_sim_dims; + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "nx", &nx); + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "nu", &nu); + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "nz", &nz); +{% if solver_options.integrator_type == "GNSF" %} + int gnsf_nx1 = {{ dims.gnsf_nx1 }}; + int gnsf_nz1 = {{ dims.gnsf_nz1 }}; + int gnsf_nout = {{ dims.gnsf_nout }}; + int gnsf_ny = {{ dims.gnsf_ny }}; + int gnsf_nuhat = {{ dims.gnsf_nuhat }}; + + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "nx1", &gnsf_nx1); + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "nz1", &gnsf_nz1); + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "nout", &gnsf_nout); + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "ny", &gnsf_ny); + sim_dims_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, "nuhat", &gnsf_nuhat); +{% endif %} + + // sim opts + sim_opts *{{ model.name }}_sim_opts = sim_opts_create({{ model.name }}_sim_config, {{ model.name }}_sim_dims); + capsule->acados_sim_opts = {{ model.name }}_sim_opts; + int tmp_int = {{ solver_options.sim_method_newton_iter }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "newton_iter", &tmp_int); + sim_collocation_type collocation_type = {{ solver_options.collocation_type }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "collocation_type", &collocation_type); + +{% if problem_class == "SIM" %} + tmp_int = {{ solver_options.sim_method_num_stages }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "num_stages", &tmp_int); + tmp_int = {{ solver_options.sim_method_num_steps }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "num_steps", &tmp_int); + + // options that are not available to AcadosOcpSolver + // (in OCP they will be determined by other options, like exact_hessian) + tmp_bool = {{ solver_options.sens_forw }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "sens_forw", &tmp_bool); + tmp_bool = {{ solver_options.sens_adj }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "sens_adj", &tmp_bool); + tmp_bool = {{ solver_options.sens_algebraic }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "sens_algebraic", &tmp_bool); + tmp_bool = {{ solver_options.sens_hess }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "sens_hess", &tmp_bool); + tmp_bool = {{ solver_options.output_z }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "output_z", &tmp_bool); + +{% else %} {# num_stages and num_steps of first shooting interval are used #} + tmp_int = {{ solver_options.sim_method_num_stages[0] }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "num_stages", &tmp_int); + tmp_int = {{ solver_options.sim_method_num_steps[0] }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "num_steps", &tmp_int); + tmp_bool = {{ solver_options.sim_method_jac_reuse[0] }}; + sim_opts_set({{ model.name }}_sim_config, {{ model.name }}_sim_opts, "jac_reuse", &tmp_bool); +{% endif %} + + // sim in / out + sim_in *{{ model.name }}_sim_in = sim_in_create({{ model.name }}_sim_config, {{ model.name }}_sim_dims); + capsule->acados_sim_in = {{ model.name }}_sim_in; + sim_out *{{ model.name }}_sim_out = sim_out_create({{ model.name }}_sim_config, {{ model.name }}_sim_dims); + capsule->acados_sim_out = {{ model.name }}_sim_out; + + sim_in_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, + {{ model.name }}_sim_in, "T", &Tsim); + + // model functions +{%- if solver_options.integrator_type == "IRK" %} + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "impl_ode_fun", capsule->sim_impl_dae_fun); + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "impl_ode_fun_jac_x_xdot", capsule->sim_impl_dae_fun_jac_x_xdot_z); + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "impl_ode_jac_x_xdot_u", capsule->sim_impl_dae_jac_x_xdot_u_z); +{%- if hessian_approx == "EXACT" %} + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "impl_dae_hess", capsule->sim_impl_dae_hess); +{%- endif %} + +{%- elif solver_options.integrator_type == "ERK" %} + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "expl_vde_for", capsule->sim_forw_vde_casadi); + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "expl_ode_fun", capsule->sim_expl_ode_fun_casadi); +{%- if hessian_approx == "EXACT" %} + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "expl_ode_hess", capsule->sim_expl_ode_hess); +{%- endif %} +{%- elif solver_options.integrator_type == "GNSF" %} + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "phi_fun", capsule->sim_gnsf_phi_fun); + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "phi_fun_jac_y", capsule->sim_gnsf_phi_fun_jac_y); + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "phi_jac_y_uhat", capsule->sim_gnsf_phi_jac_y_uhat); + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "f_lo_jac_x1_x1dot_u_z", capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z); + {{ model.name }}_sim_config->model_set({{ model.name }}_sim_in->model, + "gnsf_get_matrices_fun", capsule->sim_gnsf_get_matrices_fun); +{%- endif %} + + // sim solver + sim_solver *{{ model.name }}_sim_solver = sim_solver_create({{ model.name }}_sim_config, + {{ model.name }}_sim_dims, {{ model.name }}_sim_opts); + capsule->acados_sim_solver = {{ model.name }}_sim_solver; + +{% if dims.np > 0 %} + /* initialize parameter values */ + double* p = calloc(np, sizeof(double)); + {% for item in parameter_values %} + {%- if item != 0 %} + p[{{ loop.index0 }}] = {{ item }}; + {%- endif %} + {%- endfor %} + + {{ model.name }}_acados_sim_update_params(capsule, p, np); + free(p); +{% endif %}{# if dims.np #} + + /* initialize input */ + // x + double x0[{{ dims.nx }}]; + for (int ii = 0; ii < {{ dims.nx }}; ii++) + x0[ii] = 0.0; + + sim_in_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, + {{ model.name }}_sim_in, "x", x0); + + + // u + double u0[{{ dims.nu }}]; + for (int ii = 0; ii < {{ dims.nu }}; ii++) + u0[ii] = 0.0; + + sim_in_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, + {{ model.name }}_sim_in, "u", u0); + + // S_forw + double S_forw[{{ dims.nx * (dims.nx + dims.nu) }}]; + for (int ii = 0; ii < {{ dims.nx * (dims.nx + dims.nu) }}; ii++) + S_forw[ii] = 0.0; + for (int ii = 0; ii < {{ dims.nx }}; ii++) + S_forw[ii + ii * {{ dims.nx }} ] = 1.0; + + + sim_in_set({{ model.name }}_sim_config, {{ model.name }}_sim_dims, + {{ model.name }}_sim_in, "S_forw", S_forw); + + int status = sim_precompute({{ model.name }}_sim_solver, {{ model.name }}_sim_in, {{ model.name }}_sim_out); + + return status; +} + + +int {{ model.name }}_acados_sim_solve(sim_solver_capsule *capsule) +{ + // integrate dynamics using acados sim_solver + int status = sim_solve(capsule->acados_sim_solver, + capsule->acados_sim_in, capsule->acados_sim_out); + if (status != 0) + printf("error in {{ model.name }}_acados_sim_solve()! Exiting.\n"); + + return status; +} + + +int {{ model.name }}_acados_sim_free(sim_solver_capsule *capsule) +{ + // free memory + sim_solver_destroy(capsule->acados_sim_solver); + sim_in_destroy(capsule->acados_sim_in); + sim_out_destroy(capsule->acados_sim_out); + sim_opts_destroy(capsule->acados_sim_opts); + sim_dims_destroy(capsule->acados_sim_dims); + sim_config_destroy(capsule->acados_sim_config); + + // free external function +{%- if solver_options.integrator_type == "IRK" %} + external_function_param_casadi_free(capsule->sim_impl_dae_fun); + external_function_param_casadi_free(capsule->sim_impl_dae_fun_jac_x_xdot_z); + external_function_param_casadi_free(capsule->sim_impl_dae_jac_x_xdot_u_z); +{%- if hessian_approx == "EXACT" %} + external_function_param_casadi_free(capsule->sim_impl_dae_hess); +{%- endif %} +{%- elif solver_options.integrator_type == "ERK" %} + external_function_param_casadi_free(capsule->sim_forw_vde_casadi); + external_function_param_casadi_free(capsule->sim_expl_ode_fun_casadi); +{%- if hessian_approx == "EXACT" %} + external_function_param_casadi_free(capsule->sim_expl_ode_hess); +{%- endif %} +{%- elif solver_options.integrator_type == "GNSF" %} + external_function_param_casadi_free(capsule->sim_gnsf_phi_fun); + external_function_param_casadi_free(capsule->sim_gnsf_phi_fun_jac_y); + external_function_param_casadi_free(capsule->sim_gnsf_phi_jac_y_uhat); + external_function_param_casadi_free(capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z); + external_function_param_casadi_free(capsule->sim_gnsf_get_matrices_fun); +{% endif %} + + return 0; +} + + +int {{ model.name }}_acados_sim_update_params(sim_solver_capsule *capsule, double *p, int np) +{ + int status = 0; + int casadi_np = {{ model.name | upper }}_NP; + + if (casadi_np != np) { + printf("{{ model.name }}_acados_sim_update_params: trying to set %i parameters for external functions." + " External function has %i parameters. Exiting.\n", np, casadi_np); + exit(1); + } + +{%- if solver_options.integrator_type == "ERK" %} + capsule->sim_forw_vde_casadi[0].set_param(capsule->sim_forw_vde_casadi, p); + capsule->sim_expl_ode_fun_casadi[0].set_param(capsule->sim_expl_ode_fun_casadi, p); +{%- if hessian_approx == "EXACT" %} + capsule->sim_expl_ode_hess[0].set_param(capsule->sim_expl_ode_hess, p); +{%- endif %} +{%- elif solver_options.integrator_type == "IRK" %} + capsule->sim_impl_dae_fun[0].set_param(capsule->sim_impl_dae_fun, p); + capsule->sim_impl_dae_fun_jac_x_xdot_z[0].set_param(capsule->sim_impl_dae_fun_jac_x_xdot_z, p); + capsule->sim_impl_dae_jac_x_xdot_u_z[0].set_param(capsule->sim_impl_dae_jac_x_xdot_u_z, p); +{%- if hessian_approx == "EXACT" %} + capsule->sim_impl_dae_hess[0].set_param(capsule->sim_impl_dae_hess, p); +{%- endif %} +{%- elif solver_options.integrator_type == "GNSF" %} + capsule->sim_gnsf_phi_fun[0].set_param(capsule->sim_gnsf_phi_fun, p); + capsule->sim_gnsf_phi_fun_jac_y[0].set_param(capsule->sim_gnsf_phi_fun_jac_y, p); + capsule->sim_gnsf_phi_jac_y_uhat[0].set_param(capsule->sim_gnsf_phi_jac_y_uhat, p); + capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z[0].set_param(capsule->sim_gnsf_f_lo_jac_x1_x1dot_u_z, p); + capsule->sim_gnsf_get_matrices_fun[0].set_param(capsule->sim_gnsf_get_matrices_fun, p); +{% endif %} + + return status; +} + +/* getters pointers to C objects*/ +sim_config * {{ model.name }}_acados_get_sim_config(sim_solver_capsule *capsule) +{ + return capsule->acados_sim_config; +}; + +sim_in * {{ model.name }}_acados_get_sim_in(sim_solver_capsule *capsule) +{ + return capsule->acados_sim_in; +}; + +sim_out * {{ model.name }}_acados_get_sim_out(sim_solver_capsule *capsule) +{ + return capsule->acados_sim_out; +}; + +void * {{ model.name }}_acados_get_sim_dims(sim_solver_capsule *capsule) +{ + return capsule->acados_sim_dims; +}; + +sim_opts * {{ model.name }}_acados_get_sim_opts(sim_solver_capsule *capsule) +{ + return capsule->acados_sim_opts; +}; + +sim_solver * {{ model.name }}_acados_get_sim_solver(sim_solver_capsule *capsule) +{ + return capsule->acados_sim_solver; +}; + diff --git a/pyextra/acados_template/c_templates_tera/acados_sim_solver.in.h b/pyextra/acados_template/c_templates_tera/acados_sim_solver.in.h new file mode 100644 index 00000000000000..4da8202d3cab4a --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_sim_solver.in.h @@ -0,0 +1,103 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#ifndef ACADOS_SIM_{{ model.name }}_H_ +#define ACADOS_SIM_{{ model.name }}_H_ + +#include "acados_c/sim_interface.h" +#include "acados_c/external_function_interface.h" + +#define {{ model.name | upper }}_NX {{ dims.nx }} +#define {{ model.name | upper }}_NZ {{ dims.nz }} +#define {{ model.name | upper }}_NU {{ dims.nu }} +#define {{ model.name | upper }}_NP {{ dims.np }} + +#ifdef __cplusplus +extern "C" { +#endif + + +// ** capsule for solver data ** +typedef struct sim_solver_capsule +{ + // acados objects + sim_in *acados_sim_in; + sim_out *acados_sim_out; + sim_solver *acados_sim_solver; + sim_opts *acados_sim_opts; + sim_config *acados_sim_config; + void *acados_sim_dims; + + /* external functions */ + // ERK + external_function_param_casadi * sim_forw_vde_casadi; + external_function_param_casadi * sim_expl_ode_fun_casadi; + external_function_param_casadi * sim_expl_ode_hess; + + // IRK + external_function_param_casadi * sim_impl_dae_fun; + external_function_param_casadi * sim_impl_dae_fun_jac_x_xdot_z; + external_function_param_casadi * sim_impl_dae_jac_x_xdot_u_z; + external_function_param_casadi * sim_impl_dae_hess; + + // GNSF + external_function_param_casadi * sim_gnsf_phi_fun; + external_function_param_casadi * sim_gnsf_phi_fun_jac_y; + external_function_param_casadi * sim_gnsf_phi_jac_y_uhat; + external_function_param_casadi * sim_gnsf_f_lo_jac_x1_x1dot_u_z; + external_function_param_casadi * sim_gnsf_get_matrices_fun; + +} sim_solver_capsule; + + +int {{ model.name }}_acados_sim_create(sim_solver_capsule *capsule); +int {{ model.name }}_acados_sim_solve(sim_solver_capsule *capsule); +int {{ model.name }}_acados_sim_free(sim_solver_capsule *capsule); +int {{ model.name }}_acados_sim_update_params(sim_solver_capsule *capsule, double *value, int np); + +sim_config * {{ model.name }}_acados_get_sim_config(sim_solver_capsule *capsule); +sim_in * {{ model.name }}_acados_get_sim_in(sim_solver_capsule *capsule); +sim_out * {{ model.name }}_acados_get_sim_out(sim_solver_capsule *capsule); +void * {{ model.name }}_acados_get_sim_dims(sim_solver_capsule *capsule); +sim_opts * {{ model.name }}_acados_get_sim_opts(sim_solver_capsule *capsule); +sim_solver * {{ model.name }}_acados_get_sim_solver(sim_solver_capsule *capsule); + + +sim_solver_capsule * {{ model.name }}_acados_sim_solver_create_capsule(void); +int {{ model.name }}_acados_sim_solver_free_capsule(sim_solver_capsule *capsule); + +#ifdef __cplusplus +} +#endif + +#endif // ACADOS_SIM_{{ model.name }}_H_ diff --git a/pyextra/acados_template/c_templates_tera/acados_sim_solver_sfun.in.c b/pyextra/acados_template/c_templates_tera/acados_sim_solver_sfun.in.c new file mode 100644 index 00000000000000..234295fa29baf3 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_sim_solver_sfun.in.c @@ -0,0 +1,233 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#define S_FUNCTION_NAME acados_sim_solver_sfunction_{{ model.name }} +#define S_FUNCTION_LEVEL 2 + +#define MDL_START + +// acados +#include "acados/utils/print.h" +#include "acados_c/ocp_nlp_interface.h" +#include "acados_c/external_function_interface.h" + +// example specific +#include "{{ model.name }}_model/{{ model.name }}_model.h" +#include "acados_sim_solver_{{ model.name }}.h" + +#include "simstruc.h" + +#define SAMPLINGTIME {{ solver_options.Tsim }} + + +static void mdlInitializeSizes (SimStruct *S) +{ + // specify the number of continuous and discrete states + ssSetNumContStates(S, 0); + ssSetNumDiscStates(S, 0); + + {# compute number of input ports #} + {%- set n_inputs = 1 %} {# x0 #} + {%- if dims.nu > 0 %} {# u0 -#} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif %} + {%- if dims.np > 0 %} {# parameters #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif %} + + // specify the number of input ports + if ( !ssSetNumInputPorts(S, {{ n_inputs }}) ) + return; + + // specify the number of output ports + if ( !ssSetNumOutputPorts(S, 1) ) + return; + + // specify dimension information for the input ports + {%- set i_input = 0 %} + // x0 + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nx }}); + + {%- if dims.nu > 0 %} + {%- set i_input = i_input + 1 %} + // u0 + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nu }}); + {%- endif %} + + {%- if dims.np > 0 %} + {%- set i_input = i_input + 1 %} + // parameters + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.np }}); + {%- endif %} + + // specify dimension information for the output ports + ssSetOutputPortVectorDimension(S, 0, {{ dims.nx }} ); // xnext + + // specify the direct feedthrough status + // should be set to 1 for all inputs used in mdlOutputs + {%- for i in range(end=n_inputs) %} + ssSetInputPortDirectFeedThrough(S, {{ i }}, 1); + {%- endfor %} + + // one sample time + ssSetNumSampleTimes(S, 1); +} + + +#if defined(MATLAB_MEX_FILE) + +#define MDL_SET_INPUT_PORT_DIMENSION_INFO +#define MDL_SET_OUTPUT_PORT_DIMENSION_INFO + +static void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port, const DimsInfo_T *dimsInfo) +{ + if ( !ssSetInputPortDimensionInfo(S, port, dimsInfo) ) + return; +} + +static void mdlSetOutputPortDimensionInfo(SimStruct *S, int_T port, const DimsInfo_T *dimsInfo) +{ + if ( !ssSetOutputPortDimensionInfo(S, port, dimsInfo) ) + return; +} + +#endif /* MATLAB_MEX_FILE */ + + +static void mdlInitializeSampleTimes(SimStruct *S) +{ + ssSetSampleTime(S, 0, SAMPLINGTIME); + ssSetOffsetTime(S, 0, 0.0); +} + + +static void mdlStart(SimStruct *S) +{ + sim_solver_capsule *capsule = {{ model.name }}_acados_sim_solver_create_capsule(); + {{ model.name }}_acados_sim_create(capsule); + + ssSetUserData(S, (void*)capsule); +} + +static void mdlOutputs(SimStruct *S, int_T tid) +{ + sim_solver_capsule *capsule = ssGetUserData(S); + + sim_config *acados_sim_config = {{ model.name }}_acados_get_sim_config(capsule); + sim_in *acados_sim_in = {{ model.name }}_acados_get_sim_in(capsule); + sim_out *acados_sim_out = {{ model.name }}_acados_get_sim_out(capsule); + void *acados_sim_dims = {{ model.name }}_acados_get_sim_dims(capsule); + // sim_opts * {{ model.name }}_acados_get_sim_opts(capsule); + // sim_solver * {{ model.name }}_acados_get_sim_solver(capsule); + + InputRealPtrsType in_sign; + {% set input_sizes = [dims.nx, dims.nu, dims.np] %} + + // local buffer + {%- set buffer_size = input_sizes | sort | last %} + real_t buffer[{{ buffer_size }}]; + + + /* go through inputs */ + {%- set i_input = 0 %} + // initial condition + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int i = 0; i < {{ dims.nx }}; i++) + buffer[i] = (double)(*in_sign[i]); + + sim_in_set(acados_sim_config, acados_sim_dims, + acados_sim_in, "x", buffer); + + + // ssPrintf("\nin acados sim:\n"); + // for (int i = 0; i < {{ dims.nx }}; i++) ssPrintf("x0[%d] = %f\n", i, buffer[i]); + // ssPrintf("\n"); + +{% if dims.nu > 0 %} + // control input - u + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.nu }}; i++) + buffer[i] = (double)(*in_sign[i]); + + sim_in_set(acados_sim_config, acados_sim_dims, + acados_sim_in, "u", buffer); +{%- endif %} + + +{% if dims.np > 0 %} + // parameters + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.np }}; i++) + buffer[i] = (double)(*in_sign[i]); + + // update value of parameters + {{ model.name }}_acados_sim_update_params(capsule, buffer, {{ dims.np }}); +{%- endif %} + + + /* call solver */ + int acados_status = {{ model.name }}_acados_sim_solve(capsule); + + + /* set outputs */ + real_t *out_x = ssGetOutputPortRealSignal(S, 0); + + // get simulated state + sim_out_get(acados_sim_config, acados_sim_dims, acados_sim_out, + "xn", (void *) out_x); + + // ssPrintf("\nacados sim solve: returned %d\n", acados_status); + // for (int i = 0; i < {{ dims.nx }}; i++) ssPrintf("x_sim[%d] = %f\n", i, out_x[i]); + // ssPrintf("\n"); + +} + + +static void mdlTerminate(SimStruct *S) +{ + sim_solver_capsule *capsule = ssGetUserData(S); + + {{ model.name }}_acados_sim_free(capsule); + {{ model.name }}_acados_sim_solver_free_capsule(capsule); +} + + +#ifdef MATLAB_MEX_FILE +#include "simulink.c" +#else +#include "cg_sfun.h" +#endif diff --git a/pyextra/acados_template/c_templates_tera/acados_solver.in.c b/pyextra/acados_template/c_templates_tera/acados_solver.in.c new file mode 100644 index 00000000000000..6e13242a41a258 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_solver.in.c @@ -0,0 +1,2491 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +// standard +#include +#include +// acados +#include "acados/utils/print.h" +#include "acados_c/ocp_nlp_interface.h" +#include "acados_c/external_function_interface.h" + +// example specific +#include "{{ model.name }}_model/{{ model.name }}_model.h" +{% if constraints.constr_type == "BGP" and dims.nphi %} +#include "{{ model.name }}_constraints/{{ model.name }}_phi_constraint.h" +{% endif %} +{% if constraints.constr_type_e == "BGP" and dims.nphi_e > 0 %} +#include "{{ model.name }}_constraints/{{ model.name }}_phi_e_constraint.h" +{% endif %} +{% if constraints.constr_type == "BGH" and dims.nh > 0 %} +#include "{{ model.name }}_constraints/{{ model.name }}_h_constraint.h" +{% endif %} +{% if constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} +#include "{{ model.name }}_constraints/{{ model.name }}_h_e_constraint.h" +{% endif %} +{%- if cost.cost_type == "NONLINEAR_LS" %} +#include "{{ model.name }}_cost/{{ model.name }}_cost_y_fun.h" +{%- elif cost.cost_type == "EXTERNAL" %} +#include "{{ model.name }}_cost/{{ model.name }}_external_cost.h" +{%- endif %} +{%- if cost.cost_type_0 == "NONLINEAR_LS" %} +#include "{{ model.name }}_cost/{{ model.name }}_cost_y_0_fun.h" +{%- elif cost.cost_type_0 == "EXTERNAL" %} +#include "{{ model.name }}_cost/{{ model.name }}_external_cost_0.h" +{%- endif %} +{%- if cost.cost_type_e == "NONLINEAR_LS" %} +#include "{{ model.name }}_cost/{{ model.name }}_cost_y_e_fun.h" +{%- elif cost.cost_type_e == "EXTERNAL" %} +#include "{{ model.name }}_cost/{{ model.name }}_external_cost_e.h" +{%- endif %} + +#include "acados_solver_{{ model.name }}.h" + +#define NX {{ model.name | upper }}_NX +#define NZ {{ model.name | upper }}_NZ +#define NU {{ model.name | upper }}_NU +#define NP {{ model.name | upper }}_NP +#define NBX {{ model.name | upper }}_NBX +#define NBX0 {{ model.name | upper }}_NBX0 +#define NBU {{ model.name | upper }}_NBU +#define NSBX {{ model.name | upper }}_NSBX +#define NSBU {{ model.name | upper }}_NSBU +#define NSH {{ model.name | upper }}_NSH +#define NSG {{ model.name | upper }}_NSG +#define NSPHI {{ model.name | upper }}_NSPHI +#define NSHN {{ model.name | upper }}_NSHN +#define NSGN {{ model.name | upper }}_NSGN +#define NSPHIN {{ model.name | upper }}_NSPHIN +#define NSBXN {{ model.name | upper }}_NSBXN +#define NS {{ model.name | upper }}_NS +#define NSN {{ model.name | upper }}_NSN +#define NG {{ model.name | upper }}_NG +#define NBXN {{ model.name | upper }}_NBXN +#define NGN {{ model.name | upper }}_NGN +#define NY0 {{ model.name | upper }}_NY0 +#define NY {{ model.name | upper }}_NY +#define NYN {{ model.name | upper }}_NYN +// #define N {{ model.name | upper }}_N +#define NH {{ model.name | upper }}_NH +#define NPHI {{ model.name | upper }}_NPHI +#define NHN {{ model.name | upper }}_NHN +#define NPHIN {{ model.name | upper }}_NPHIN +#define NR {{ model.name | upper }}_NR + + +// ** solver data ** + +{{ model.name }}_solver_capsule * {{ model.name }}_acados_create_capsule(void) +{ + void* capsule_mem = malloc(sizeof({{ model.name }}_solver_capsule)); + {{ model.name }}_solver_capsule *capsule = ({{ model.name }}_solver_capsule *) capsule_mem; + + return capsule; +} + + +int {{ model.name }}_acados_free_capsule({{ model.name }}_solver_capsule *capsule) +{ + free(capsule); + return 0; +} + + +int {{ model.name }}_acados_create({{ model.name }}_solver_capsule * capsule) +{ + int N_shooting_intervals = {{ model.name | upper }}_N; + double* new_time_steps = NULL; // NULL -> don't alter the code generated time-steps + return {{ model.name }}_acados_create_with_discretization(capsule, N_shooting_intervals, new_time_steps); +} + +int {{ model.name }}_acados_update_time_steps({{ model.name }}_solver_capsule * capsule, int N, double* new_time_steps) +{ + if (N != capsule->nlp_solver_plan->N) { + fprintf(stderr, "{{ model.name }}_acados_update_time_steps: given number of time steps (= %d) " \ + "differs from the currently allocated number of " \ + "time steps (= %d)!\n" \ + "Please recreate with new discretization and provide a new vector of time_stamps!\n", + N, capsule->nlp_solver_plan->N); + return 1; + } + + ocp_nlp_config * nlp_config = capsule->nlp_config; + ocp_nlp_dims * nlp_dims = capsule->nlp_dims; + ocp_nlp_in * nlp_in = capsule->nlp_in; + + for (int i = 0; i < N; i++) + { + ocp_nlp_in_set(nlp_config, nlp_dims, nlp_in, i, "Ts", &new_time_steps[i]); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "scaling", &new_time_steps[i]); + } + return 0; +} + +int {{ model.name }}_acados_create_with_discretization({{ model.name }}_solver_capsule * capsule, int N, double* new_time_steps) +{ + int status = 0; + // If N does not match the number of shooting intervals used for code generation, new_time_steps must be given. + if (N != {{ model.name | upper }}_N && !new_time_steps) { + fprintf(stderr, "{{ model.name }}_acados_create_with_discretization: new_time_steps is NULL " \ + "but the number of shooting intervals (= %d) differs from the number of " \ + "shooting intervals (= %d) during code generation! Please provide a new vector of time_stamps!\n", \ + N, {{ model.name | upper }}_N); + return 1; + } + + // number of expected runtime parameters + capsule->nlp_np = NP; + + /************************************************ + * plan & config + ************************************************/ + ocp_nlp_plan * nlp_solver_plan = ocp_nlp_plan_create(N); + capsule->nlp_solver_plan = nlp_solver_plan; + + {%- if solver_options.nlp_solver_type == "SQP" %} + nlp_solver_plan->nlp_solver = SQP; + {% else %} + nlp_solver_plan->nlp_solver = SQP_RTI; + {%- endif %} + + nlp_solver_plan->ocp_qp_solver_plan.qp_solver = {{ solver_options.qp_solver }}; + + nlp_solver_plan->nlp_cost[0] = {{ cost.cost_type_0 }}; + for (int i = 1; i < N; i++) + nlp_solver_plan->nlp_cost[i] = {{ cost.cost_type }}; + + nlp_solver_plan->nlp_cost[N] = {{ cost.cost_type_e }}; + + for (int i = 0; i < N; i++) + { + {% if solver_options.integrator_type == "DISCRETE" %} + nlp_solver_plan->nlp_dynamics[i] = DISCRETE_MODEL; + // discrete dynamics does not need sim solver option, this field is ignored + nlp_solver_plan->sim_solver_plan[i].sim_solver = INVALID_SIM_SOLVER; + {% else %} + nlp_solver_plan->nlp_dynamics[i] = CONTINUOUS_MODEL; + nlp_solver_plan->sim_solver_plan[i].sim_solver = {{ solver_options.integrator_type }}; + {%- endif %} + } + + for (int i = 0; i < N; i++) + { + {% if constraints.constr_type == "BGP" %} + nlp_solver_plan->nlp_constraints[i] = BGP; + {%- else -%} + nlp_solver_plan->nlp_constraints[i] = BGH; + {%- endif %} + } + + {%- if constraints.constr_type_e == "BGP" %} + nlp_solver_plan->nlp_constraints[N] = BGP; + {% else %} + nlp_solver_plan->nlp_constraints[N] = BGH; + {%- endif %} + +{%- if solver_options.hessian_approx == "EXACT" %} + {%- if solver_options.regularize_method == "NO_REGULARIZE" %} + nlp_solver_plan->regularization = NO_REGULARIZE; + {%- elif solver_options.regularize_method == "MIRROR" %} + nlp_solver_plan->regularization = MIRROR; + {%- elif solver_options.regularize_method == "PROJECT" %} + nlp_solver_plan->regularization = PROJECT; + {%- elif solver_options.regularize_method == "PROJECT_REDUC_HESS" %} + nlp_solver_plan->regularization = PROJECT_REDUC_HESS; + {%- elif solver_options.regularize_method == "CONVEXIFY" %} + nlp_solver_plan->regularization = CONVEXIFY; + {%- endif %} +{%- endif %} + ocp_nlp_config * nlp_config = ocp_nlp_config_create(*nlp_solver_plan); + capsule->nlp_config = nlp_config; + + + /************************************************ + * dimensions + ************************************************/ + #define NINTNP1MEMS 17 + int* intNp1mem = (int*)malloc( (N+1)*sizeof(int)*NINTNP1MEMS ); + + int* nx = intNp1mem + (N+1)*0; + int* nu = intNp1mem + (N+1)*1; + int* nbx = intNp1mem + (N+1)*2; + int* nbu = intNp1mem + (N+1)*3; + int* nsbx = intNp1mem + (N+1)*4; + int* nsbu = intNp1mem + (N+1)*5; + int* nsg = intNp1mem + (N+1)*6; + int* nsh = intNp1mem + (N+1)*7; + int* nsphi = intNp1mem + (N+1)*8; + int* ns = intNp1mem + (N+1)*9; + int* ng = intNp1mem + (N+1)*10; + int* nh = intNp1mem + (N+1)*11; + int* nphi = intNp1mem + (N+1)*12; + int* nz = intNp1mem + (N+1)*13; + int* ny = intNp1mem + (N+1)*14; + int* nr = intNp1mem + (N+1)*15; + int* nbxe = intNp1mem + (N+1)*16; + + for (int i = 0; i < N+1; i++) + { + // common + nx[i] = NX; + nu[i] = NU; + nz[i] = NZ; + ns[i] = NS; + // cost + ny[i] = NY; + // constraints + nbx[i] = NBX; + nbu[i] = NBU; + nsbx[i] = NSBX; + nsbu[i] = NSBU; + nsg[i] = NSG; + nsh[i] = NSH; + nsphi[i] = NSPHI; + ng[i] = NG; + nh[i] = NH; + nphi[i] = NPHI; + nr[i] = NR; + nbxe[i] = 0; + } + + // for initial state + nbx[0] = NBX0; + nsbx[0] = 0; + ns[0] = NS - NSBX; + nbxe[0] = {{ dims.nbxe_0 }}; + ny[0] = NY0; + + // terminal - common + nu[N] = 0; + nz[N] = 0; + ns[N] = NSN; + // cost + ny[N] = NYN; + // constraint + nbx[N] = NBXN; + nbu[N] = 0; + ng[N] = NGN; + nh[N] = NHN; + nphi[N] = NPHIN; + nr[N] = {{ dims.nr_e }}; + + nsbx[N] = NSBXN; + nsbu[N] = 0; + nsg[N] = NSGN; + nsh[N] = NSHN; + nsphi[N] = NSPHIN; + + /* create and set ocp_nlp_dims */ + ocp_nlp_dims * nlp_dims = ocp_nlp_dims_create(nlp_config); + capsule->nlp_dims = nlp_dims; + + ocp_nlp_dims_set_opt_vars(nlp_config, nlp_dims, "nx", nx); + ocp_nlp_dims_set_opt_vars(nlp_config, nlp_dims, "nu", nu); + ocp_nlp_dims_set_opt_vars(nlp_config, nlp_dims, "nz", nz); + ocp_nlp_dims_set_opt_vars(nlp_config, nlp_dims, "ns", ns); + + for (int i = 0; i <= N; i++) + { + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nbx", &nbx[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nbu", &nbu[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nsbx", &nsbx[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nsbu", &nsbu[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "ng", &ng[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nsg", &nsg[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nbxe", &nbxe[i]); + } + + {%- if cost.cost_type_0 == "NONLINEAR_LS" or cost.cost_type_0 == "LINEAR_LS" %} + ocp_nlp_dims_set_cost(nlp_config, nlp_dims, 0, "ny", &ny[0]); + {%- endif %} + + {%- if cost.cost_type == "NONLINEAR_LS" or cost.cost_type == "LINEAR_LS" %} + for (int i = 1; i < N; i++) + ocp_nlp_dims_set_cost(nlp_config, nlp_dims, i, "ny", &ny[i]); + {%- endif %} + + for (int i = 0; i < N; i++) + { + {%- if constraints.constr_type == "BGH" and dims.nh > 0 %} + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nh", &nh[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nsh", &nsh[i]); + {%- elif constraints.constr_type == "BGP" and dims.nphi > 0 %} + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nr", &nr[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nphi", &nphi[i]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, i, "nsphi", &nsphi[i]); + {%- endif %} + } + + {%- if constraints.constr_type_e == "BGH" %} + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, N, "nh", &nh[N]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, N, "nsh", &nsh[N]); + {%- elif constraints.constr_type_e == "BGP" %} + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, N, "nr", &nr[N]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, N, "nphi", &nphi[N]); + ocp_nlp_dims_set_constraints(nlp_config, nlp_dims, N, "nsphi", &nsphi[N]); + {%- endif %} + {%- if cost.cost_type_e == "NONLINEAR_LS" or cost.cost_type_e == "LINEAR_LS" %} + ocp_nlp_dims_set_cost(nlp_config, nlp_dims, N, "ny", &ny[N]); + {%- endif %} + + free(intNp1mem); + +{% if solver_options.integrator_type == "GNSF" -%} + // GNSF specific dimensions + int gnsf_nx1 = {{ dims.gnsf_nx1 }}; + int gnsf_nz1 = {{ dims.gnsf_nz1 }}; + int gnsf_nout = {{ dims.gnsf_nout }}; + int gnsf_ny = {{ dims.gnsf_ny }}; + int gnsf_nuhat = {{ dims.gnsf_nuhat }}; + + for (int i = 0; i < N; i++) + { + if (nlp_solver_plan->sim_solver_plan[i].sim_solver == GNSF) + { + ocp_nlp_dims_set_dynamics(nlp_config, nlp_dims, i, "gnsf_nx1", &gnsf_nx1); + ocp_nlp_dims_set_dynamics(nlp_config, nlp_dims, i, "gnsf_nz1", &gnsf_nz1); + ocp_nlp_dims_set_dynamics(nlp_config, nlp_dims, i, "gnsf_nout", &gnsf_nout); + ocp_nlp_dims_set_dynamics(nlp_config, nlp_dims, i, "gnsf_ny", &gnsf_ny); + ocp_nlp_dims_set_dynamics(nlp_config, nlp_dims, i, "gnsf_nuhat", &gnsf_nuhat); + } + } +{%- endif %} + + /************************************************ + * external functions + ************************************************/ + {%- if constraints.constr_type == "BGP" %} + capsule->phi_constraint = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) + { + // nonlinear part of convex-composite constraint + capsule->phi_constraint[i].casadi_fun = &{{ model.name }}_phi_constraint; + capsule->phi_constraint[i].casadi_n_in = &{{ model.name }}_phi_constraint_n_in; + capsule->phi_constraint[i].casadi_n_out = &{{ model.name }}_phi_constraint_n_out; + capsule->phi_constraint[i].casadi_sparsity_in = &{{ model.name }}_phi_constraint_sparsity_in; + capsule->phi_constraint[i].casadi_sparsity_out = &{{ model.name }}_phi_constraint_sparsity_out; + capsule->phi_constraint[i].casadi_work = &{{ model.name }}_phi_constraint_work; + + external_function_param_casadi_create(&capsule->phi_constraint[i], {{ dims.np }}); + } + {%- endif %} + + {%- if constraints.constr_type_e == "BGP" %} + // nonlinear part of convex-composite constraint + capsule->phi_e_constraint.casadi_fun = &{{ model.name }}_phi_e_constraint; + capsule->phi_e_constraint.casadi_n_in = &{{ model.name }}_phi_e_constraint_n_in; + capsule->phi_e_constraint.casadi_n_out = &{{ model.name }}_phi_e_constraint_n_out; + capsule->phi_e_constraint.casadi_sparsity_in = &{{ model.name }}_phi_e_constraint_sparsity_in; + capsule->phi_e_constraint.casadi_sparsity_out = &{{ model.name }}_phi_e_constraint_sparsity_out; + capsule->phi_e_constraint.casadi_work = &{{ model.name }}_phi_e_constraint_work; + + external_function_param_casadi_create(&capsule->phi_e_constraint, {{ dims.np }}); + {% endif %} + + {%- if constraints.constr_type == "BGH" and dims.nh > 0 %} + capsule->nl_constr_h_fun_jac = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->nl_constr_h_fun_jac[i].casadi_fun = &{{ model.name }}_constr_h_fun_jac_uxt_zt; + capsule->nl_constr_h_fun_jac[i].casadi_n_in = &{{ model.name }}_constr_h_fun_jac_uxt_zt_n_in; + capsule->nl_constr_h_fun_jac[i].casadi_n_out = &{{ model.name }}_constr_h_fun_jac_uxt_zt_n_out; + capsule->nl_constr_h_fun_jac[i].casadi_sparsity_in = &{{ model.name }}_constr_h_fun_jac_uxt_zt_sparsity_in; + capsule->nl_constr_h_fun_jac[i].casadi_sparsity_out = &{{ model.name }}_constr_h_fun_jac_uxt_zt_sparsity_out; + capsule->nl_constr_h_fun_jac[i].casadi_work = &{{ model.name }}_constr_h_fun_jac_uxt_zt_work; + external_function_param_casadi_create(&capsule->nl_constr_h_fun_jac[i], {{ dims.np }}); + } + capsule->nl_constr_h_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->nl_constr_h_fun[i].casadi_fun = &{{ model.name }}_constr_h_fun; + capsule->nl_constr_h_fun[i].casadi_n_in = &{{ model.name }}_constr_h_fun_n_in; + capsule->nl_constr_h_fun[i].casadi_n_out = &{{ model.name }}_constr_h_fun_n_out; + capsule->nl_constr_h_fun[i].casadi_sparsity_in = &{{ model.name }}_constr_h_fun_sparsity_in; + capsule->nl_constr_h_fun[i].casadi_sparsity_out = &{{ model.name }}_constr_h_fun_sparsity_out; + capsule->nl_constr_h_fun[i].casadi_work = &{{ model.name }}_constr_h_fun_work; + external_function_param_casadi_create(&capsule->nl_constr_h_fun[i], {{ dims.np }}); + } + {% if solver_options.hessian_approx == "EXACT" %} + capsule->nl_constr_h_fun_jac_hess = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->nl_constr_h_fun_jac_hess[i].casadi_fun = &{{ model.name }}_constr_h_fun_jac_uxt_zt_hess; + capsule->nl_constr_h_fun_jac_hess[i].casadi_n_in = &{{ model.name }}_constr_h_fun_jac_uxt_zt_hess_n_in; + capsule->nl_constr_h_fun_jac_hess[i].casadi_n_out = &{{ model.name }}_constr_h_fun_jac_uxt_zt_hess_n_out; + capsule->nl_constr_h_fun_jac_hess[i].casadi_sparsity_in = &{{ model.name }}_constr_h_fun_jac_uxt_zt_hess_sparsity_in; + capsule->nl_constr_h_fun_jac_hess[i].casadi_sparsity_out = &{{ model.name }}_constr_h_fun_jac_uxt_zt_hess_sparsity_out; + capsule->nl_constr_h_fun_jac_hess[i].casadi_work = &{{ model.name }}_constr_h_fun_jac_uxt_zt_hess_work; + + external_function_param_casadi_create(&capsule->nl_constr_h_fun_jac_hess[i], {{ dims.np }}); + } + {% endif %} + {% endif %} + + {%- if constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} + capsule->nl_constr_h_e_fun_jac.casadi_fun = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt; + capsule->nl_constr_h_e_fun_jac.casadi_n_in = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_n_in; + capsule->nl_constr_h_e_fun_jac.casadi_n_out = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_n_out; + capsule->nl_constr_h_e_fun_jac.casadi_sparsity_in = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_sparsity_in; + capsule->nl_constr_h_e_fun_jac.casadi_sparsity_out = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_sparsity_out; + capsule->nl_constr_h_e_fun_jac.casadi_work = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_work; + external_function_param_casadi_create(&capsule->nl_constr_h_e_fun_jac, {{ dims.np }}); + + capsule->nl_constr_h_e_fun.casadi_fun = &{{ model.name }}_constr_h_e_fun; + capsule->nl_constr_h_e_fun.casadi_n_in = &{{ model.name }}_constr_h_e_fun_n_in; + capsule->nl_constr_h_e_fun.casadi_n_out = &{{ model.name }}_constr_h_e_fun_n_out; + capsule->nl_constr_h_e_fun.casadi_sparsity_in = &{{ model.name }}_constr_h_e_fun_sparsity_in; + capsule->nl_constr_h_e_fun.casadi_sparsity_out = &{{ model.name }}_constr_h_e_fun_sparsity_out; + capsule->nl_constr_h_e_fun.casadi_work = &{{ model.name }}_constr_h_e_fun_work; + external_function_param_casadi_create(&capsule->nl_constr_h_e_fun, {{ dims.np }}); + + {% if solver_options.hessian_approx == "EXACT" %} + capsule->nl_constr_h_e_fun_jac_hess.casadi_fun = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess; + capsule->nl_constr_h_e_fun_jac_hess.casadi_n_in = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_n_in; + capsule->nl_constr_h_e_fun_jac_hess.casadi_n_out = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_n_out; + capsule->nl_constr_h_e_fun_jac_hess.casadi_sparsity_in = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_sparsity_in; + capsule->nl_constr_h_e_fun_jac_hess.casadi_sparsity_out = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_sparsity_out; + capsule->nl_constr_h_e_fun_jac_hess.casadi_work = &{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_work; + external_function_param_casadi_create(&capsule->nl_constr_h_e_fun_jac_hess, {{ dims.np }}); + {% endif %} + {%- endif %} + +{% if solver_options.integrator_type == "ERK" %} + // explicit ode + capsule->forw_vde_casadi = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->forw_vde_casadi[i].casadi_fun = &{{ model.name }}_expl_vde_forw; + capsule->forw_vde_casadi[i].casadi_n_in = &{{ model.name }}_expl_vde_forw_n_in; + capsule->forw_vde_casadi[i].casadi_n_out = &{{ model.name }}_expl_vde_forw_n_out; + capsule->forw_vde_casadi[i].casadi_sparsity_in = &{{ model.name }}_expl_vde_forw_sparsity_in; + capsule->forw_vde_casadi[i].casadi_sparsity_out = &{{ model.name }}_expl_vde_forw_sparsity_out; + capsule->forw_vde_casadi[i].casadi_work = &{{ model.name }}_expl_vde_forw_work; + external_function_param_casadi_create(&capsule->forw_vde_casadi[i], {{ dims.np }}); + } + + capsule->expl_ode_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->expl_ode_fun[i].casadi_fun = &{{ model.name }}_expl_ode_fun; + capsule->expl_ode_fun[i].casadi_n_in = &{{ model.name }}_expl_ode_fun_n_in; + capsule->expl_ode_fun[i].casadi_n_out = &{{ model.name }}_expl_ode_fun_n_out; + capsule->expl_ode_fun[i].casadi_sparsity_in = &{{ model.name }}_expl_ode_fun_sparsity_in; + capsule->expl_ode_fun[i].casadi_sparsity_out = &{{ model.name }}_expl_ode_fun_sparsity_out; + capsule->expl_ode_fun[i].casadi_work = &{{ model.name }}_expl_ode_fun_work; + external_function_param_casadi_create(&capsule->expl_ode_fun[i], {{ dims.np }}); + } + + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->hess_vde_casadi = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->hess_vde_casadi[i].casadi_fun = &{{ model.name }}_expl_ode_hess; + capsule->hess_vde_casadi[i].casadi_n_in = &{{ model.name }}_expl_ode_hess_n_in; + capsule->hess_vde_casadi[i].casadi_n_out = &{{ model.name }}_expl_ode_hess_n_out; + capsule->hess_vde_casadi[i].casadi_sparsity_in = &{{ model.name }}_expl_ode_hess_sparsity_in; + capsule->hess_vde_casadi[i].casadi_sparsity_out = &{{ model.name }}_expl_ode_hess_sparsity_out; + capsule->hess_vde_casadi[i].casadi_work = &{{ model.name }}_expl_ode_hess_work; + external_function_param_casadi_create(&capsule->hess_vde_casadi[i], {{ dims.np }}); + } + {%- endif %} + +{% elif solver_options.integrator_type == "IRK" %} + // implicit dae + capsule->impl_dae_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->impl_dae_fun[i].casadi_fun = &{{ model.name }}_impl_dae_fun; + capsule->impl_dae_fun[i].casadi_work = &{{ model.name }}_impl_dae_fun_work; + capsule->impl_dae_fun[i].casadi_sparsity_in = &{{ model.name }}_impl_dae_fun_sparsity_in; + capsule->impl_dae_fun[i].casadi_sparsity_out = &{{ model.name }}_impl_dae_fun_sparsity_out; + capsule->impl_dae_fun[i].casadi_n_in = &{{ model.name }}_impl_dae_fun_n_in; + capsule->impl_dae_fun[i].casadi_n_out = &{{ model.name }}_impl_dae_fun_n_out; + external_function_param_casadi_create(&capsule->impl_dae_fun[i], {{ dims.np }}); + } + + capsule->impl_dae_fun_jac_x_xdot_z = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->impl_dae_fun_jac_x_xdot_z[i].casadi_fun = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z; + capsule->impl_dae_fun_jac_x_xdot_z[i].casadi_work = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_work; + capsule->impl_dae_fun_jac_x_xdot_z[i].casadi_sparsity_in = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_sparsity_in; + capsule->impl_dae_fun_jac_x_xdot_z[i].casadi_sparsity_out = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_sparsity_out; + capsule->impl_dae_fun_jac_x_xdot_z[i].casadi_n_in = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_n_in; + capsule->impl_dae_fun_jac_x_xdot_z[i].casadi_n_out = &{{ model.name }}_impl_dae_fun_jac_x_xdot_z_n_out; + external_function_param_casadi_create(&capsule->impl_dae_fun_jac_x_xdot_z[i], {{ dims.np }}); + } + + capsule->impl_dae_jac_x_xdot_u_z = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->impl_dae_jac_x_xdot_u_z[i].casadi_fun = &{{ model.name }}_impl_dae_jac_x_xdot_u_z; + capsule->impl_dae_jac_x_xdot_u_z[i].casadi_work = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_work; + capsule->impl_dae_jac_x_xdot_u_z[i].casadi_sparsity_in = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_sparsity_in; + capsule->impl_dae_jac_x_xdot_u_z[i].casadi_sparsity_out = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_sparsity_out; + capsule->impl_dae_jac_x_xdot_u_z[i].casadi_n_in = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_n_in; + capsule->impl_dae_jac_x_xdot_u_z[i].casadi_n_out = &{{ model.name }}_impl_dae_jac_x_xdot_u_z_n_out; + external_function_param_casadi_create(&capsule->impl_dae_jac_x_xdot_u_z[i], {{ dims.np }}); + } + + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->impl_dae_hess = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->impl_dae_hess[i].casadi_fun = &{{ model.name }}_impl_dae_hess; + capsule->impl_dae_hess[i].casadi_work = &{{ model.name }}_impl_dae_hess_work; + capsule->impl_dae_hess[i].casadi_sparsity_in = &{{ model.name }}_impl_dae_hess_sparsity_in; + capsule->impl_dae_hess[i].casadi_sparsity_out = &{{ model.name }}_impl_dae_hess_sparsity_out; + capsule->impl_dae_hess[i].casadi_n_in = &{{ model.name }}_impl_dae_hess_n_in; + capsule->impl_dae_hess[i].casadi_n_out = &{{ model.name }}_impl_dae_hess_n_out; + external_function_param_casadi_create(&capsule->impl_dae_hess[i], {{ dims.np }}); + } + {%- endif %} +{% elif solver_options.integrator_type == "LIFTED_IRK" %} + // external functions (implicit model) + capsule->impl_dae_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->impl_dae_fun[i].casadi_fun = &{{ model.name }}_impl_dae_fun; + capsule->impl_dae_fun[i].casadi_work = &{{ model.name }}_impl_dae_fun_work; + capsule->impl_dae_fun[i].casadi_sparsity_in = &{{ model.name }}_impl_dae_fun_sparsity_in; + capsule->impl_dae_fun[i].casadi_sparsity_out = &{{ model.name }}_impl_dae_fun_sparsity_out; + capsule->impl_dae_fun[i].casadi_n_in = &{{ model.name }}_impl_dae_fun_n_in; + capsule->impl_dae_fun[i].casadi_n_out = &{{ model.name }}_impl_dae_fun_n_out; + external_function_param_casadi_create(&capsule->impl_dae_fun[i], {{ dims.np }}); + } + + capsule->impl_dae_fun_jac_x_xdot_u = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); for (int i = 0; i < N; i++) { + capsule->impl_dae_fun_jac_x_xdot_u[i].casadi_fun = &{{ model.name }}_impl_dae_fun_jac_x_xdot_u; + capsule->impl_dae_fun_jac_x_xdot_u[i].casadi_work = &{{ model.name }}_impl_dae_fun_jac_x_xdot_u_work; + capsule->impl_dae_fun_jac_x_xdot_u[i].casadi_sparsity_in = &{{ model.name }}_impl_dae_fun_jac_x_xdot_u_sparsity_in; + capsule->impl_dae_fun_jac_x_xdot_u[i].casadi_sparsity_out = &{{ model.name }}_impl_dae_fun_jac_x_xdot_u_sparsity_out; + capsule->impl_dae_fun_jac_x_xdot_u[i].casadi_n_in = &{{ model.name }}_impl_dae_fun_jac_x_xdot_u_n_in; + capsule->impl_dae_fun_jac_x_xdot_u[i].casadi_n_out = &{{ model.name }}_impl_dae_fun_jac_x_xdot_u_n_out; + external_function_param_casadi_create(&capsule->impl_dae_fun_jac_x_xdot_u[i], {{ dims.np }}); + } + +{% elif solver_options.integrator_type == "GNSF" %} + capsule->gnsf_phi_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->gnsf_phi_fun[i].casadi_fun = &{{ model.name }}_gnsf_phi_fun; + capsule->gnsf_phi_fun[i].casadi_work = &{{ model.name }}_gnsf_phi_fun_work; + capsule->gnsf_phi_fun[i].casadi_sparsity_in = &{{ model.name }}_gnsf_phi_fun_sparsity_in; + capsule->gnsf_phi_fun[i].casadi_sparsity_out = &{{ model.name }}_gnsf_phi_fun_sparsity_out; + capsule->gnsf_phi_fun[i].casadi_n_in = &{{ model.name }}_gnsf_phi_fun_n_in; + capsule->gnsf_phi_fun[i].casadi_n_out = &{{ model.name }}_gnsf_phi_fun_n_out; + external_function_param_casadi_create(&capsule->gnsf_phi_fun[i], {{ dims.np }}); + } + + capsule->gnsf_phi_fun_jac_y = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->gnsf_phi_fun_jac_y[i].casadi_fun = &{{ model.name }}_gnsf_phi_fun_jac_y; + capsule->gnsf_phi_fun_jac_y[i].casadi_work = &{{ model.name }}_gnsf_phi_fun_jac_y_work; + capsule->gnsf_phi_fun_jac_y[i].casadi_sparsity_in = &{{ model.name }}_gnsf_phi_fun_jac_y_sparsity_in; + capsule->gnsf_phi_fun_jac_y[i].casadi_sparsity_out = &{{ model.name }}_gnsf_phi_fun_jac_y_sparsity_out; + capsule->gnsf_phi_fun_jac_y[i].casadi_n_in = &{{ model.name }}_gnsf_phi_fun_jac_y_n_in; + capsule->gnsf_phi_fun_jac_y[i].casadi_n_out = &{{ model.name }}_gnsf_phi_fun_jac_y_n_out; + external_function_param_casadi_create(&capsule->gnsf_phi_fun_jac_y[i], {{ dims.np }}); + } + + capsule->gnsf_phi_jac_y_uhat = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->gnsf_phi_jac_y_uhat[i].casadi_fun = &{{ model.name }}_gnsf_phi_jac_y_uhat; + capsule->gnsf_phi_jac_y_uhat[i].casadi_work = &{{ model.name }}_gnsf_phi_jac_y_uhat_work; + capsule->gnsf_phi_jac_y_uhat[i].casadi_sparsity_in = &{{ model.name }}_gnsf_phi_jac_y_uhat_sparsity_in; + capsule->gnsf_phi_jac_y_uhat[i].casadi_sparsity_out = &{{ model.name }}_gnsf_phi_jac_y_uhat_sparsity_out; + capsule->gnsf_phi_jac_y_uhat[i].casadi_n_in = &{{ model.name }}_gnsf_phi_jac_y_uhat_n_in; + capsule->gnsf_phi_jac_y_uhat[i].casadi_n_out = &{{ model.name }}_gnsf_phi_jac_y_uhat_n_out; + external_function_param_casadi_create(&capsule->gnsf_phi_jac_y_uhat[i], {{ dims.np }}); + } + + capsule->gnsf_f_lo_jac_x1_x1dot_u_z = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i].casadi_fun = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz; + capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i].casadi_work = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_work; + capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i].casadi_sparsity_in = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_sparsity_in; + capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i].casadi_sparsity_out = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_sparsity_out; + capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i].casadi_n_in = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_n_in; + capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i].casadi_n_out = &{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_n_out; + external_function_param_casadi_create(&capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i], {{ dims.np }}); + } + + capsule->gnsf_get_matrices_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N; i++) { + capsule->gnsf_get_matrices_fun[i].casadi_fun = &{{ model.name }}_gnsf_get_matrices_fun; + capsule->gnsf_get_matrices_fun[i].casadi_work = &{{ model.name }}_gnsf_get_matrices_fun_work; + capsule->gnsf_get_matrices_fun[i].casadi_sparsity_in = &{{ model.name }}_gnsf_get_matrices_fun_sparsity_in; + capsule->gnsf_get_matrices_fun[i].casadi_sparsity_out = &{{ model.name }}_gnsf_get_matrices_fun_sparsity_out; + capsule->gnsf_get_matrices_fun[i].casadi_n_in = &{{ model.name }}_gnsf_get_matrices_fun_n_in; + capsule->gnsf_get_matrices_fun[i].casadi_n_out = &{{ model.name }}_gnsf_get_matrices_fun_n_out; + external_function_param_casadi_create(&capsule->gnsf_get_matrices_fun[i], {{ dims.np }}); + } +{% elif solver_options.integrator_type == "DISCRETE" %} + // discrete dynamics + capsule->discr_dyn_phi_fun = (external_function_param_{{ model.dyn_ext_fun_type }} *) malloc(sizeof(external_function_param_{{ model.dyn_ext_fun_type }})*N); + for (int i = 0; i < N; i++) + { + {%- if model.dyn_ext_fun_type == "casadi" %} + capsule->discr_dyn_phi_fun[i].casadi_fun = &{{ model.name }}_dyn_disc_phi_fun; + capsule->discr_dyn_phi_fun[i].casadi_n_in = &{{ model.name }}_dyn_disc_phi_fun_n_in; + capsule->discr_dyn_phi_fun[i].casadi_n_out = &{{ model.name }}_dyn_disc_phi_fun_n_out; + capsule->discr_dyn_phi_fun[i].casadi_sparsity_in = &{{ model.name }}_dyn_disc_phi_fun_sparsity_in; + capsule->discr_dyn_phi_fun[i].casadi_sparsity_out = &{{ model.name }}_dyn_disc_phi_fun_sparsity_out; + capsule->discr_dyn_phi_fun[i].casadi_work = &{{ model.name }}_dyn_disc_phi_fun_work; + {%- else %} + capsule->discr_dyn_phi_fun[i].fun = &{{ model.dyn_disc_fun }}; + {%- endif %} + external_function_param_{{ model.dyn_ext_fun_type }}_create(&capsule->discr_dyn_phi_fun[i], {{ dims.np }}); + } + + capsule->discr_dyn_phi_fun_jac_ut_xt = (external_function_param_{{ model.dyn_ext_fun_type }} *) malloc(sizeof(external_function_param_{{ model.dyn_ext_fun_type }})*N); + for (int i = 0; i < N; i++) + { + {%- if model.dyn_ext_fun_type == "casadi" %} + capsule->discr_dyn_phi_fun_jac_ut_xt[i].casadi_fun = &{{ model.name }}_dyn_disc_phi_fun_jac; + capsule->discr_dyn_phi_fun_jac_ut_xt[i].casadi_n_in = &{{ model.name }}_dyn_disc_phi_fun_jac_n_in; + capsule->discr_dyn_phi_fun_jac_ut_xt[i].casadi_n_out = &{{ model.name }}_dyn_disc_phi_fun_jac_n_out; + capsule->discr_dyn_phi_fun_jac_ut_xt[i].casadi_sparsity_in = &{{ model.name }}_dyn_disc_phi_fun_jac_sparsity_in; + capsule->discr_dyn_phi_fun_jac_ut_xt[i].casadi_sparsity_out = &{{ model.name }}_dyn_disc_phi_fun_jac_sparsity_out; + capsule->discr_dyn_phi_fun_jac_ut_xt[i].casadi_work = &{{ model.name }}_dyn_disc_phi_fun_jac_work; + {%- else %} + capsule->discr_dyn_phi_fun_jac_ut_xt[i].fun = &{{ model.dyn_disc_fun_jac }}; + {%- endif %} + external_function_param_{{ model.dyn_ext_fun_type }}_create(&capsule->discr_dyn_phi_fun_jac_ut_xt[i], {{ dims.np }}); + } + + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->discr_dyn_phi_fun_jac_ut_xt_hess = (external_function_param_{{ model.dyn_ext_fun_type }} *) malloc(sizeof(external_function_param_{{ model.dyn_ext_fun_type }})*N); + for (int i = 0; i < N; i++) + { + {%- if model.dyn_ext_fun_type == "casadi" %} + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i].casadi_fun = &{{ model.name }}_dyn_disc_phi_fun_jac_hess; + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i].casadi_n_in = &{{ model.name }}_dyn_disc_phi_fun_jac_hess_n_in; + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i].casadi_n_out = &{{ model.name }}_dyn_disc_phi_fun_jac_hess_n_out; + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i].casadi_sparsity_in = &{{ model.name }}_dyn_disc_phi_fun_jac_hess_sparsity_in; + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i].casadi_sparsity_out = &{{ model.name }}_dyn_disc_phi_fun_jac_hess_sparsity_out; + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i].casadi_work = &{{ model.name }}_dyn_disc_phi_fun_jac_hess_work; + {%- else %} + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i].fun = &{{ model.dyn_disc_fun_jac_hess }}; + {%- endif %} + external_function_param_{{ model.dyn_ext_fun_type }}_create(&capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i], {{ dims.np }}); + } + {%- endif %} +{%- endif %} + + +{%- if cost.cost_type_0 == "NONLINEAR_LS" %} + // nonlinear least square function + capsule->cost_y_0_fun.casadi_fun = &{{ model.name }}_cost_y_0_fun; + capsule->cost_y_0_fun.casadi_n_in = &{{ model.name }}_cost_y_0_fun_n_in; + capsule->cost_y_0_fun.casadi_n_out = &{{ model.name }}_cost_y_0_fun_n_out; + capsule->cost_y_0_fun.casadi_sparsity_in = &{{ model.name }}_cost_y_0_fun_sparsity_in; + capsule->cost_y_0_fun.casadi_sparsity_out = &{{ model.name }}_cost_y_0_fun_sparsity_out; + capsule->cost_y_0_fun.casadi_work = &{{ model.name }}_cost_y_0_fun_work; + external_function_param_casadi_create(&capsule->cost_y_0_fun, {{ dims.np }}); + + capsule->cost_y_0_fun_jac_ut_xt.casadi_fun = &{{ model.name }}_cost_y_0_fun_jac_ut_xt; + capsule->cost_y_0_fun_jac_ut_xt.casadi_n_in = &{{ model.name }}_cost_y_0_fun_jac_ut_xt_n_in; + capsule->cost_y_0_fun_jac_ut_xt.casadi_n_out = &{{ model.name }}_cost_y_0_fun_jac_ut_xt_n_out; + capsule->cost_y_0_fun_jac_ut_xt.casadi_sparsity_in = &{{ model.name }}_cost_y_0_fun_jac_ut_xt_sparsity_in; + capsule->cost_y_0_fun_jac_ut_xt.casadi_sparsity_out = &{{ model.name }}_cost_y_0_fun_jac_ut_xt_sparsity_out; + capsule->cost_y_0_fun_jac_ut_xt.casadi_work = &{{ model.name }}_cost_y_0_fun_jac_ut_xt_work; + external_function_param_casadi_create(&capsule->cost_y_0_fun_jac_ut_xt, {{ dims.np }}); + + capsule->cost_y_0_hess.casadi_fun = &{{ model.name }}_cost_y_0_hess; + capsule->cost_y_0_hess.casadi_n_in = &{{ model.name }}_cost_y_0_hess_n_in; + capsule->cost_y_0_hess.casadi_n_out = &{{ model.name }}_cost_y_0_hess_n_out; + capsule->cost_y_0_hess.casadi_sparsity_in = &{{ model.name }}_cost_y_0_hess_sparsity_in; + capsule->cost_y_0_hess.casadi_sparsity_out = &{{ model.name }}_cost_y_0_hess_sparsity_out; + capsule->cost_y_0_hess.casadi_work = &{{ model.name }}_cost_y_0_hess_work; + external_function_param_casadi_create(&capsule->cost_y_0_hess, {{ dims.np }}); + +{%- elif cost.cost_type_0 == "EXTERNAL" %} + // external cost + {% if cost.cost_ext_fun_type_0 == "casadi" %} + capsule->ext_cost_0_fun.casadi_fun = &{{ model.name }}_cost_ext_cost_0_fun; + capsule->ext_cost_0_fun.casadi_n_in = &{{ model.name }}_cost_ext_cost_0_fun_n_in; + capsule->ext_cost_0_fun.casadi_n_out = &{{ model.name }}_cost_ext_cost_0_fun_n_out; + capsule->ext_cost_0_fun.casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_0_fun_sparsity_in; + capsule->ext_cost_0_fun.casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_0_fun_sparsity_out; + capsule->ext_cost_0_fun.casadi_work = &{{ model.name }}_cost_ext_cost_0_fun_work; + {% else %} + capsule->ext_cost_0_fun.fun = &{{ cost.cost_function_ext_cost_0 }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type_0 }}_create(&capsule->ext_cost_0_fun, {{ dims.np }}); + + // external cost + {% if cost.cost_ext_fun_type_0 == "casadi" %} + capsule->ext_cost_0_fun_jac.casadi_fun = &{{ model.name }}_cost_ext_cost_0_fun_jac; + capsule->ext_cost_0_fun_jac.casadi_n_in = &{{ model.name }}_cost_ext_cost_0_fun_jac_n_in; + capsule->ext_cost_0_fun_jac.casadi_n_out = &{{ model.name }}_cost_ext_cost_0_fun_jac_n_out; + capsule->ext_cost_0_fun_jac.casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_0_fun_jac_sparsity_in; + capsule->ext_cost_0_fun_jac.casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_0_fun_jac_sparsity_out; + capsule->ext_cost_0_fun_jac.casadi_work = &{{ model.name }}_cost_ext_cost_0_fun_jac_work; + {% else %} + capsule->ext_cost_0_fun_jac.fun = &{{ cost.cost_function_ext_cost_0 }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type_0 }}_create(&capsule->ext_cost_0_fun_jac, {{ dims.np }}); + + // external cost + {% if cost.cost_ext_fun_type_0 == "casadi" %} + capsule->ext_cost_0_fun_jac_hess.casadi_fun = &{{ model.name }}_cost_ext_cost_0_fun_jac_hess; + capsule->ext_cost_0_fun_jac_hess.casadi_n_in = &{{ model.name }}_cost_ext_cost_0_fun_jac_hess_n_in; + capsule->ext_cost_0_fun_jac_hess.casadi_n_out = &{{ model.name }}_cost_ext_cost_0_fun_jac_hess_n_out; + capsule->ext_cost_0_fun_jac_hess.casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_0_fun_jac_hess_sparsity_in; + capsule->ext_cost_0_fun_jac_hess.casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_0_fun_jac_hess_sparsity_out; + capsule->ext_cost_0_fun_jac_hess.casadi_work = &{{ model.name }}_cost_ext_cost_0_fun_jac_hess_work; + {% else %} + capsule->ext_cost_0_fun_jac_hess.fun = &{{ cost.cost_function_ext_cost_0 }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type_0 }}_create(&capsule->ext_cost_0_fun_jac_hess, {{ dims.np }}); +{%- endif %} + +{%- if cost.cost_type == "NONLINEAR_LS" %} + // nonlinear least squares cost + capsule->cost_y_fun = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N-1; i++) + { + capsule->cost_y_fun[i].casadi_fun = &{{ model.name }}_cost_y_fun; + capsule->cost_y_fun[i].casadi_n_in = &{{ model.name }}_cost_y_fun_n_in; + capsule->cost_y_fun[i].casadi_n_out = &{{ model.name }}_cost_y_fun_n_out; + capsule->cost_y_fun[i].casadi_sparsity_in = &{{ model.name }}_cost_y_fun_sparsity_in; + capsule->cost_y_fun[i].casadi_sparsity_out = &{{ model.name }}_cost_y_fun_sparsity_out; + capsule->cost_y_fun[i].casadi_work = &{{ model.name }}_cost_y_fun_work; + + external_function_param_casadi_create(&capsule->cost_y_fun[i], {{ dims.np }}); + } + + capsule->cost_y_fun_jac_ut_xt = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N-1; i++) + { + capsule->cost_y_fun_jac_ut_xt[i].casadi_fun = &{{ model.name }}_cost_y_fun_jac_ut_xt; + capsule->cost_y_fun_jac_ut_xt[i].casadi_n_in = &{{ model.name }}_cost_y_fun_jac_ut_xt_n_in; + capsule->cost_y_fun_jac_ut_xt[i].casadi_n_out = &{{ model.name }}_cost_y_fun_jac_ut_xt_n_out; + capsule->cost_y_fun_jac_ut_xt[i].casadi_sparsity_in = &{{ model.name }}_cost_y_fun_jac_ut_xt_sparsity_in; + capsule->cost_y_fun_jac_ut_xt[i].casadi_sparsity_out = &{{ model.name }}_cost_y_fun_jac_ut_xt_sparsity_out; + capsule->cost_y_fun_jac_ut_xt[i].casadi_work = &{{ model.name }}_cost_y_fun_jac_ut_xt_work; + + external_function_param_casadi_create(&capsule->cost_y_fun_jac_ut_xt[i], {{ dims.np }}); + } + + capsule->cost_y_hess = (external_function_param_casadi *) malloc(sizeof(external_function_param_casadi)*N); + for (int i = 0; i < N-1; i++) + { + capsule->cost_y_hess[i].casadi_fun = &{{ model.name }}_cost_y_hess; + capsule->cost_y_hess[i].casadi_n_in = &{{ model.name }}_cost_y_hess_n_in; + capsule->cost_y_hess[i].casadi_n_out = &{{ model.name }}_cost_y_hess_n_out; + capsule->cost_y_hess[i].casadi_sparsity_in = &{{ model.name }}_cost_y_hess_sparsity_in; + capsule->cost_y_hess[i].casadi_sparsity_out = &{{ model.name }}_cost_y_hess_sparsity_out; + capsule->cost_y_hess[i].casadi_work = &{{ model.name }}_cost_y_hess_work; + + external_function_param_casadi_create(&capsule->cost_y_hess[i], {{ dims.np }}); + } +{%- elif cost.cost_type == "EXTERNAL" %} + // external cost + capsule->ext_cost_fun = (external_function_param_{{ cost.cost_ext_fun_type }} *) malloc(sizeof(external_function_param_{{ cost.cost_ext_fun_type }})*N); + for (int i = 0; i < N-1; i++) + { + {% if cost.cost_ext_fun_type == "casadi" %} + capsule->ext_cost_fun[i].casadi_fun = &{{ model.name }}_cost_ext_cost_fun; + capsule->ext_cost_fun[i].casadi_n_in = &{{ model.name }}_cost_ext_cost_fun_n_in; + capsule->ext_cost_fun[i].casadi_n_out = &{{ model.name }}_cost_ext_cost_fun_n_out; + capsule->ext_cost_fun[i].casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_fun_sparsity_in; + capsule->ext_cost_fun[i].casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_fun_sparsity_out; + capsule->ext_cost_fun[i].casadi_work = &{{ model.name }}_cost_ext_cost_fun_work; + {% else %} + capsule->ext_cost_fun[i].fun = &{{ cost.cost_function_ext_cost }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type }}_create(&capsule->ext_cost_fun[i], {{ dims.np }}); + } + + capsule->ext_cost_fun_jac = (external_function_param_{{ cost.cost_ext_fun_type }} *) malloc(sizeof(external_function_param_{{ cost.cost_ext_fun_type }})*N); + for (int i = 0; i < N-1; i++) + { + {% if cost.cost_ext_fun_type == "casadi" %} + capsule->ext_cost_fun_jac[i].casadi_fun = &{{ model.name }}_cost_ext_cost_fun_jac; + capsule->ext_cost_fun_jac[i].casadi_n_in = &{{ model.name }}_cost_ext_cost_fun_jac_n_in; + capsule->ext_cost_fun_jac[i].casadi_n_out = &{{ model.name }}_cost_ext_cost_fun_jac_n_out; + capsule->ext_cost_fun_jac[i].casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_fun_jac_sparsity_in; + capsule->ext_cost_fun_jac[i].casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_fun_jac_sparsity_out; + capsule->ext_cost_fun_jac[i].casadi_work = &{{ model.name }}_cost_ext_cost_fun_jac_work; + {% else %} + capsule->ext_cost_fun_jac[i].fun = &{{ cost.cost_function_ext_cost }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type }}_create(&capsule->ext_cost_fun_jac[i], {{ dims.np }}); + } + + capsule->ext_cost_fun_jac_hess = (external_function_param_{{ cost.cost_ext_fun_type }} *) malloc(sizeof(external_function_param_{{ cost.cost_ext_fun_type }})*N); + for (int i = 0; i < N-1; i++) + { + {% if cost.cost_ext_fun_type == "casadi" %} + capsule->ext_cost_fun_jac_hess[i].casadi_fun = &{{ model.name }}_cost_ext_cost_fun_jac_hess; + capsule->ext_cost_fun_jac_hess[i].casadi_n_in = &{{ model.name }}_cost_ext_cost_fun_jac_hess_n_in; + capsule->ext_cost_fun_jac_hess[i].casadi_n_out = &{{ model.name }}_cost_ext_cost_fun_jac_hess_n_out; + capsule->ext_cost_fun_jac_hess[i].casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_fun_jac_hess_sparsity_in; + capsule->ext_cost_fun_jac_hess[i].casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_fun_jac_hess_sparsity_out; + capsule->ext_cost_fun_jac_hess[i].casadi_work = &{{ model.name }}_cost_ext_cost_fun_jac_hess_work; + {% else %} + capsule->ext_cost_fun_jac_hess[i].fun = &{{ cost.cost_function_ext_cost }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type }}_create(&capsule->ext_cost_fun_jac_hess[i], {{ dims.np }}); + } +{%- endif %} + +{%- if cost.cost_type_e == "NONLINEAR_LS" %} + // nonlinear least square function + capsule->cost_y_e_fun.casadi_fun = &{{ model.name }}_cost_y_e_fun; + capsule->cost_y_e_fun.casadi_n_in = &{{ model.name }}_cost_y_e_fun_n_in; + capsule->cost_y_e_fun.casadi_n_out = &{{ model.name }}_cost_y_e_fun_n_out; + capsule->cost_y_e_fun.casadi_sparsity_in = &{{ model.name }}_cost_y_e_fun_sparsity_in; + capsule->cost_y_e_fun.casadi_sparsity_out = &{{ model.name }}_cost_y_e_fun_sparsity_out; + capsule->cost_y_e_fun.casadi_work = &{{ model.name }}_cost_y_e_fun_work; + external_function_param_casadi_create(&capsule->cost_y_e_fun, {{ dims.np }}); + + capsule->cost_y_e_fun_jac_ut_xt.casadi_fun = &{{ model.name }}_cost_y_e_fun_jac_ut_xt; + capsule->cost_y_e_fun_jac_ut_xt.casadi_n_in = &{{ model.name }}_cost_y_e_fun_jac_ut_xt_n_in; + capsule->cost_y_e_fun_jac_ut_xt.casadi_n_out = &{{ model.name }}_cost_y_e_fun_jac_ut_xt_n_out; + capsule->cost_y_e_fun_jac_ut_xt.casadi_sparsity_in = &{{ model.name }}_cost_y_e_fun_jac_ut_xt_sparsity_in; + capsule->cost_y_e_fun_jac_ut_xt.casadi_sparsity_out = &{{ model.name }}_cost_y_e_fun_jac_ut_xt_sparsity_out; + capsule->cost_y_e_fun_jac_ut_xt.casadi_work = &{{ model.name }}_cost_y_e_fun_jac_ut_xt_work; + external_function_param_casadi_create(&capsule->cost_y_e_fun_jac_ut_xt, {{ dims.np }}); + + capsule->cost_y_e_hess.casadi_fun = &{{ model.name }}_cost_y_e_hess; + capsule->cost_y_e_hess.casadi_n_in = &{{ model.name }}_cost_y_e_hess_n_in; + capsule->cost_y_e_hess.casadi_n_out = &{{ model.name }}_cost_y_e_hess_n_out; + capsule->cost_y_e_hess.casadi_sparsity_in = &{{ model.name }}_cost_y_e_hess_sparsity_in; + capsule->cost_y_e_hess.casadi_sparsity_out = &{{ model.name }}_cost_y_e_hess_sparsity_out; + capsule->cost_y_e_hess.casadi_work = &{{ model.name }}_cost_y_e_hess_work; + external_function_param_casadi_create(&capsule->cost_y_e_hess, {{ dims.np }}); + +{%- elif cost.cost_type_e == "EXTERNAL" %} + // external cost + {% if cost.cost_ext_fun_type_e == "casadi" %} + capsule->ext_cost_e_fun.casadi_fun = &{{ model.name }}_cost_ext_cost_e_fun; + capsule->ext_cost_e_fun.casadi_n_in = &{{ model.name }}_cost_ext_cost_e_fun_n_in; + capsule->ext_cost_e_fun.casadi_n_out = &{{ model.name }}_cost_ext_cost_e_fun_n_out; + capsule->ext_cost_e_fun.casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_e_fun_sparsity_in; + capsule->ext_cost_e_fun.casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_e_fun_sparsity_out; + capsule->ext_cost_e_fun.casadi_work = &{{ model.name }}_cost_ext_cost_e_fun_work; + {% else %} + capsule->ext_cost_e_fun.fun = &{{ cost.cost_function_ext_cost_e }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type_e }}_create(&capsule->ext_cost_e_fun, {{ dims.np }}); + + // external cost + {% if cost.cost_ext_fun_type_e == "casadi" %} + capsule->ext_cost_e_fun_jac.casadi_fun = &{{ model.name }}_cost_ext_cost_e_fun_jac; + capsule->ext_cost_e_fun_jac.casadi_n_in = &{{ model.name }}_cost_ext_cost_e_fun_jac_n_in; + capsule->ext_cost_e_fun_jac.casadi_n_out = &{{ model.name }}_cost_ext_cost_e_fun_jac_n_out; + capsule->ext_cost_e_fun_jac.casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_e_fun_jac_sparsity_in; + capsule->ext_cost_e_fun_jac.casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_e_fun_jac_sparsity_out; + capsule->ext_cost_e_fun_jac.casadi_work = &{{ model.name }}_cost_ext_cost_e_fun_jac_work; + {% else %} + capsule->ext_cost_e_fun_jac.fun = &{{ cost.cost_function_ext_cost_e }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type_e }}_create(&capsule->ext_cost_e_fun_jac, {{ dims.np }}); + + // external cost + {% if cost.cost_ext_fun_type_e == "casadi" %} + capsule->ext_cost_e_fun_jac_hess.casadi_fun = &{{ model.name }}_cost_ext_cost_e_fun_jac_hess; + capsule->ext_cost_e_fun_jac_hess.casadi_n_in = &{{ model.name }}_cost_ext_cost_e_fun_jac_hess_n_in; + capsule->ext_cost_e_fun_jac_hess.casadi_n_out = &{{ model.name }}_cost_ext_cost_e_fun_jac_hess_n_out; + capsule->ext_cost_e_fun_jac_hess.casadi_sparsity_in = &{{ model.name }}_cost_ext_cost_e_fun_jac_hess_sparsity_in; + capsule->ext_cost_e_fun_jac_hess.casadi_sparsity_out = &{{ model.name }}_cost_ext_cost_e_fun_jac_hess_sparsity_out; + capsule->ext_cost_e_fun_jac_hess.casadi_work = &{{ model.name }}_cost_ext_cost_e_fun_jac_hess_work; + {% else %} + capsule->ext_cost_e_fun_jac_hess.fun = &{{ cost.cost_function_ext_cost_e }}; + {% endif %} + external_function_param_{{ cost.cost_ext_fun_type_e }}_create(&capsule->ext_cost_e_fun_jac_hess, {{ dims.np }}); +{%- endif %} + + /************************************************ + * nlp_in + ************************************************/ + ocp_nlp_in * nlp_in = ocp_nlp_in_create(nlp_config, nlp_dims); + capsule->nlp_in = nlp_in; + + // set up time_steps + {% set all_equal = true -%} + {%- set val = solver_options.time_steps[0] %} + {%- for j in range(start=1, end=dims.N) %} + {%- if val != solver_options.time_steps[j] %} + {%- set_global all_equal = false %} + {%- break %} + {%- endif %} + {%- endfor %} + + if (new_time_steps) { + {{ model.name }}_acados_update_time_steps(capsule, N, new_time_steps); + } else { + {%- if all_equal == true -%} + // all time_steps are identical + double time_step = {{ solver_options.time_steps[0] }}; + for (int i = 0; i < N; i++) + { + ocp_nlp_in_set(nlp_config, nlp_dims, nlp_in, i, "Ts", &time_step); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "scaling", &time_step); + } + {%- else -%} + // time_steps are different + double* time_steps = malloc(N*sizeof(double)); + {%- for j in range(end=dims.N) %} + time_steps[{{ j }}] = {{ solver_options.time_steps[j] }}; + {%- endfor %} + {{ model.name }}_acados_update_time_steps(capsule, N, time_steps); + free(time_steps); + {%- endif %} + } + + /**** Dynamics ****/ + for (int i = 0; i < N; i++) + { + {%- if solver_options.integrator_type == "ERK" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "expl_vde_forw", &capsule->forw_vde_casadi[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "expl_ode_fun", &capsule->expl_ode_fun[i]); + {%- if solver_options.hessian_approx == "EXACT" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "expl_ode_hess", &capsule->hess_vde_casadi[i]); + {%- endif %} + {% elif solver_options.integrator_type == "IRK" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "impl_dae_fun", &capsule->impl_dae_fun[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, + "impl_dae_fun_jac_x_xdot_z", &capsule->impl_dae_fun_jac_x_xdot_z[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, + "impl_dae_jac_x_xdot_u", &capsule->impl_dae_jac_x_xdot_u_z[i]); + {%- if solver_options.hessian_approx == "EXACT" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "impl_dae_hess", &capsule->impl_dae_hess[i]); + {%- endif %} + {% elif solver_options.integrator_type == "LIFTED_IRK" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "impl_dae_fun", &capsule->impl_dae_fun[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, + "impl_dae_fun_jac_x_xdot_u", &capsule->impl_dae_fun_jac_x_xdot_u[i]); + {% elif solver_options.integrator_type == "GNSF" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "phi_fun", &capsule->gnsf_phi_fun[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "phi_fun_jac_y", &capsule->gnsf_phi_fun_jac_y[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "phi_jac_y_uhat", &capsule->gnsf_phi_jac_y_uhat[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "f_lo_jac_x1_x1dot_u_z", + &capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "gnsf_get_matrices_fun", + &capsule->gnsf_get_matrices_fun[i]); + {% elif solver_options.integrator_type == "DISCRETE" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "disc_dyn_fun", &capsule->discr_dyn_phi_fun[i]); + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "disc_dyn_fun_jac", + &capsule->discr_dyn_phi_fun_jac_ut_xt[i]); + {%- if solver_options.hessian_approx == "EXACT" %} + ocp_nlp_dynamics_model_set(nlp_config, nlp_dims, nlp_in, i, "disc_dyn_fun_jac_hess", + &capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i]); + {%- endif %} + {%- endif %} + } + + + /**** Cost ****/ +{%- if cost.cost_type_0 == "NONLINEAR_LS" or cost.cost_type_0 == "LINEAR_LS" %} +{% if dims.ny_0 > 0 %} + double* W_0 = calloc(NY0*NY0, sizeof(double)); + // change only the non-zero elements: + {%- for j in range(end=dims.ny_0) %} + {%- for k in range(end=dims.ny_0) %} + {%- if cost.W_0[j][k] != 0 %} + W_0[{{ j }}+(NY0) * {{ k }}] = {{ cost.W_0[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "W", W_0); + free(W_0); + + double* yref_0 = calloc(NY0, sizeof(double)); + // change only the non-zero elements: + {%- for j in range(end=dims.ny_0) %} + {%- if cost.yref_0[j] != 0 %} + yref_0[{{ j }}] = {{ cost.yref_0[j] }}; + {%- endif %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "yref", yref_0); + free(yref_0); +{% endif %} +{% endif %} + +{%- if cost.cost_type == "NONLINEAR_LS" or cost.cost_type == "LINEAR_LS" %} +{% if dims.ny > 0 %} + double* W = calloc(NY*NY, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny) %} + {%- for k in range(end=dims.ny) %} + {%- if cost.W[j][k] != 0 %} + W[{{ j }}+(NY) * {{ k }}] = {{ cost.W[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + + double* yref = calloc(NY, sizeof(double)); + // change only the non-zero elements: + {%- for j in range(end=dims.ny) %} + {%- if cost.yref[j] != 0 %} + yref[{{ j }}] = {{ cost.yref[j] }}; + {%- endif %} + {%- endfor %} + + for (int i = 1; i < N; i++) + { + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "W", W); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "yref", yref); + } + free(W); + free(yref); +{% endif %} +{% endif %} + +{%- if cost.cost_type_0 == "LINEAR_LS" %} + double* Vx_0 = calloc(NY0*NX, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny_0) %} + {%- for k in range(end=dims.nx) %} + {%- if cost.Vx_0[j][k] != 0 %} + Vx_0[{{ j }}+(NY0) * {{ k }}] = {{ cost.Vx_0[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "Vx", Vx_0); + free(Vx_0); + +{% if dims.ny_0 > 0 and dims.nu > 0 %} + double* Vu_0 = calloc(NY0*NU, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny_0) %} + {%- for k in range(end=dims.nu) %} + {%- if cost.Vu_0[j][k] != 0 %} + Vu_0[{{ j }}+(NY0) * {{ k }}] = {{ cost.Vu_0[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "Vu", Vu_0); + free(Vu_0); +{% endif %} +{% if dims.ny_0 > 0 and dims.nz > 0 %} + double* Vz_0 = calloc(NY0*NZ, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny_0) %} + {%- for k in range(end=dims.nz) %} + {%- if cost.Vz_0[j][k] != 0 %} + Vz_0[{{ j }}+(NY0) * {{ k }}] = {{ cost.Vz_0[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "Vz", Vz_0); + free(Vz_0); +{%- endif %} +{%- endif %}{# LINEAR LS #} + + +{%- if cost.cost_type == "LINEAR_LS" %} + double* Vx = calloc(NY*NX, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny) %} + {%- for k in range(end=dims.nx) %} + {%- if cost.Vx[j][k] != 0 %} + Vx[{{ j }}+(NY) * {{ k }}] = {{ cost.Vx[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + for (int i = 1; i < N; i++) + { + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "Vx", Vx); + } + free(Vx); + +{% if dims.ny > 0 and dims.nu > 0 %} + double* Vu = calloc(NY*NU, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny) %} + {%- for k in range(end=dims.nu) %} + {%- if cost.Vu[j][k] != 0 %} + Vu[{{ j }}+(NY) * {{ k }}] = {{ cost.Vu[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + + for (int i = 1; i < N; i++) + { + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "Vu", Vu); + } + free(Vu); +{% endif %} + +{% if dims.ny > 0 and dims.nz > 0 %} + double* Vz = calloc(NY*NZ, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny) %} + {%- for k in range(end=dims.nz) %} + {%- if cost.Vz[j][k] != 0 %} + Vz[{{ j }}+(NY) * {{ k }}] = {{ cost.Vz[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + + for (int i = 1; i < N; i++) + { + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "Vz", Vz); + } + free(Vz); +{%- endif %} +{%- endif %}{# LINEAR LS #} + + +{%- if cost.cost_type_0 == "NONLINEAR_LS" %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "nls_y_fun", &capsule->cost_y_0_fun); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "nls_y_fun_jac", &capsule->cost_y_0_fun_jac_ut_xt); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "nls_y_hess", &capsule->cost_y_0_hess); +{%- elif cost.cost_type_0 == "EXTERNAL" %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "ext_cost_fun", &capsule->ext_cost_0_fun); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "ext_cost_fun_jac", &capsule->ext_cost_0_fun_jac); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "ext_cost_fun_jac_hess", &capsule->ext_cost_0_fun_jac_hess); +{%- endif %} + +{%- if cost.cost_type == "NONLINEAR_LS" %} + for (int i = 1; i < N; i++) + { + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "nls_y_fun", &capsule->cost_y_fun[i-1]); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "nls_y_fun_jac", &capsule->cost_y_fun_jac_ut_xt[i-1]); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "nls_y_hess", &capsule->cost_y_hess[i-1]); + } +{%- elif cost.cost_type == "EXTERNAL" %} + for (int i = 1; i < N; i++) + { + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "ext_cost_fun", &capsule->ext_cost_fun[i-1]); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "ext_cost_fun_jac", &capsule->ext_cost_fun_jac[i-1]); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "ext_cost_fun_jac_hess", &capsule->ext_cost_fun_jac_hess[i-1]); + } +{%- endif %} + + +{% if dims.ns > 0 %} + double* zlumem = calloc(4*NS, sizeof(double)); + double* Zl = zlumem+NS*0; + double* Zu = zlumem+NS*1; + double* zl = zlumem+NS*2; + double* zu = zlumem+NS*3; + // change only the non-zero elements: + {%- for j in range(end=dims.ns) %} + {%- if cost.Zl[j] != 0 %} + Zl[{{ j }}] = {{ cost.Zl[j] }}; + {%- endif %} + {%- endfor %} + + {%- for j in range(end=dims.ns) %} + {%- if cost.Zu[j] != 0 %} + Zu[{{ j }}] = {{ cost.Zu[j] }}; + {%- endif %} + {%- endfor %} + + {%- for j in range(end=dims.ns) %} + {%- if cost.zl[j] != 0 %} + zl[{{ j }}] = {{ cost.zl[j] }}; + {%- endif %} + {%- endfor %} + + {%- for j in range(end=dims.ns) %} + {%- if cost.zu[j] != 0 %} + zu[{{ j }}] = {{ cost.zu[j] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "Zl", Zl); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "Zu", Zu); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "zl", zl); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, i, "zu", zu); + } + free(zlumem); +{% endif %} + + // terminal cost +{% if cost.cost_type_e == "LINEAR_LS" or cost.cost_type_e == "NONLINEAR_LS" %} +{% if dims.ny_e > 0 %} + double* yref_e = calloc(NYN, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny_e) %} + {%- if cost.yref_e[j] != 0 %} + yref_e[{{ j }}] = {{ cost.yref_e[j] }}; + {%- endif %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "yref", yref_e); + free(yref_e); + + double* W_e = calloc(NYN*NYN, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny_e) %} + {%- for k in range(end=dims.ny_e) %} + {%- if cost.W_e[j][k] != 0 %} + W_e[{{ j }}+(NYN) * {{ k }}] = {{ cost.W_e[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "W", W_e); + free(W_e); + + {%- if cost.cost_type_e == "LINEAR_LS" %} + double* Vx_e = calloc(NYN*NX, sizeof(double)); + // change only the non-zero elements: + {% for j in range(end=dims.ny_e) %} + {%- for k in range(end=dims.nx) %} + {%- if cost.Vx_e[j][k] != 0 %} + Vx_e[{{ j }}+(NYN) * {{ k }}] = {{ cost.Vx_e[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "Vx", Vx_e); + free(Vx_e); + {%- endif %} + + {%- if cost.cost_type_e == "NONLINEAR_LS" %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "nls_y_fun", &capsule->cost_y_e_fun); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "nls_y_fun_jac", &capsule->cost_y_e_fun_jac_ut_xt); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "nls_y_hess", &capsule->cost_y_e_hess); + {%- endif %} +{%- endif %}{# ny_e > 0 #} + +{%- elif cost.cost_type_e == "EXTERNAL" %} + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "ext_cost_fun", &capsule->ext_cost_e_fun); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "ext_cost_fun_jac", &capsule->ext_cost_e_fun_jac); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "ext_cost_fun_jac_hess", &capsule->ext_cost_e_fun_jac_hess); +{%- endif %} + +{% if dims.ns_e > 0 %} + double* zluemem = calloc(4*NSN, sizeof(double)); + double* Zl_e = zluemem+NSN*0; + double* Zu_e = zluemem+NSN*1; + double* zl_e = zluemem+NSN*2; + double* zu_e = zluemem+NSN*3; + + // change only the non-zero elements: + {% for j in range(end=dims.ns_e) %} + {%- if cost.Zl_e[j] != 0 %} + Zl_e[{{ j }}] = {{ cost.Zl_e[j] }}; + {%- endif %} + {%- endfor %} + + {% for j in range(end=dims.ns_e) %} + {%- if cost.Zu_e[j] != 0 %} + Zu_e[{{ j }}] = {{ cost.Zu_e[j] }}; + {%- endif %} + {%- endfor %} + + {% for j in range(end=dims.ns_e) %} + {%- if cost.zl_e[j] != 0 %} + zl_e[{{ j }}] = {{ cost.zl_e[j] }}; + {%- endif %} + {%- endfor %} + + {% for j in range(end=dims.ns_e) %} + {%- if cost.zu_e[j] != 0 %} + zu_e[{{ j }}] = {{ cost.zu_e[j] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "Zl", Zl_e); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "Zu", Zu_e); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "zl", zl_e); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, N, "zu", zu_e); + free(zluemem); +{%- endif %} + + /**** Constraints ****/ + + // bounds for initial stage +{% if dims.nbx_0 > 0 %} + // x0 + int* idxbx0 = malloc(NBX0 * sizeof(int)); + {%- for i in range(end=dims.nbx_0) %} + idxbx0[{{ i }}] = {{ constraints.idxbx_0[i] }}; + {%- endfor %} + + double* lubx0 = calloc(2*NBX0, sizeof(double)); + double* lbx0 = lubx0; + double* ubx0 = lubx0 + NBX0; + // change only the non-zero elements: + {%- for i in range(end=dims.nbx_0) %} + {%- if constraints.lbx_0[i] != 0 %} + lbx0[{{ i }}] = {{ constraints.lbx_0[i] }}; + {%- endif %} + {%- if constraints.ubx_0[i] != 0 %} + ubx0[{{ i }}] = {{ constraints.ubx_0[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "idxbx", idxbx0); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "lbx", lbx0); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "ubx", ubx0); + free(idxbx0); + free(lubx0); +{% endif %} +{% if dims.nbxe_0 > 0 %} + // idxbxe_0 + int* idxbxe_0 = malloc({{ dims.nbxe_0 }} * sizeof(int)); + {% for i in range(end=dims.nbxe_0) %} + idxbxe_0[{{ i }}] = {{ constraints.idxbxe_0[i] }}; + {%- endfor %} + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "idxbxe", idxbxe_0); + free(idxbxe_0); +{% endif %} + + /* constraints that are the same for initial and intermediate */ +{%- if dims.nsbx > 0 %} +{# TODO: introduce nsbx0 & move this block down!! #} + // ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "idxsbx", idxsbx); + // ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "lsbx", lsbx); + // ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "usbx", usbx); + + // soft bounds on x + int* idxsbx = malloc(NSBX * sizeof(int)); + {% for i in range(end=dims.nsbx) %} + idxsbx[{{ i }}] = {{ constraints.idxsbx[i] }}; + {%- endfor %} + + double* lusbx = calloc(2*NSBX, sizeof(double)); + double* lsbx = lusbx; + double* usbx = lusbx + NSBX; + {% for i in range(end=dims.nsbx) %} + {%- if constraints.lsbx[i] != 0 %} + lsbx[{{ i }}] = {{ constraints.lsbx[i] }}; + {%- endif %} + {%- if constraints.usbx[i] != 0 %} + usbx[{{ i }}] = {{ constraints.usbx[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 1; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "idxsbx", idxsbx); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lsbx", lsbx); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "usbx", usbx); + } + free(idxsbx); + free(lusbx); +{%- endif %} + + +{% if dims.nbu > 0 %} + // u + int* idxbu = malloc(NBU * sizeof(int)); + {% for i in range(end=dims.nbu) %} + idxbu[{{ i }}] = {{ constraints.idxbu[i] }}; + {%- endfor %} + double* lubu = calloc(2*NBU, sizeof(double)); + double* lbu = lubu; + double* ubu = lubu + NBU; + {% for i in range(end=dims.nbu) %} + {%- if constraints.lbu[i] != 0 %} + lbu[{{ i }}] = {{ constraints.lbu[i] }}; + {%- endif %} + {%- if constraints.ubu[i] != 0 %} + ubu[{{ i }}] = {{ constraints.ubu[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "idxbu", idxbu); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lbu", lbu); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "ubu", ubu); + } + free(idxbu); + free(lubu); +{% endif %} + +{% if dims.nsbu > 0 %} + // set up soft bounds for u + int* idxsbu = malloc(NSBU * sizeof(int)); + {% for i in range(end=dims.nsbu) %} + idxsbu[{{ i }}] = {{ constraints.idxsbu[i] }}; + {%- endfor %} + double* lusbu = calloc(2*NSBU, sizeof(double)); + double* lsbu = lusbu; + double* usbu = lusbu + NSBU; + {% for i in range(end=dims.nsbu) %} + {%- if constraints.lsbu[i] != 0 %} + lsbu[{{ i }}] = {{ constraints.lsbu[i] }}; + {%- endif %} + {%- if constraints.usbu[i] != 0 %} + usbu[{{ i }}] = {{ constraints.usbu[i] }}; + {%- endif %} + {%- endfor %} + for (int i = 0; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "idxsbu", idxsbu); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lsbu", lsbu); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "usbu", usbu); + } + free(idxsbu); + free(lusbu); +{% endif %} + +{% if dims.nsg > 0 %} + // set up soft bounds for general linear constraints + int* idxsg = malloc(NSG * sizeof(int)); + {% for i in range(end=dims.nsg) %} + idxsg[{{ i }}] = {{ constraints.idxsg[i] }}; + {%- endfor %} + double* lusg = calloc(2*NSG, sizeof(double)); + double* lsg = lusg; + double* usg = lusg + NSG; + {% for i in range(end=dims.nsg) %} + {%- if constraints.lsg[i] != 0 %} + lsg[{{ i }}] = {{ constraints.lsg[i] }}; + {%- endif %} + {%- if constraints.usg[i] != 0 %} + usg[{{ i }}] = {{ constraints.usg[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "idxsg", idxsg); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lsg", lsg); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "usg", usg); + } + free(idxsg); + free(lusg); +{% endif %} + +{% if dims.nsh > 0 %} + // set up soft bounds for nonlinear constraints + int* idxsh = malloc(NSH * sizeof(int)); + {% for i in range(end=dims.nsh) %} + idxsh[{{ i }}] = {{ constraints.idxsh[i] }}; + {%- endfor %} + double* lush = calloc(2*NSH, sizeof(double)); + double* lsh = lush; + double* ush = lush + NSH; + {% for i in range(end=dims.nsh) %} + {%- if constraints.lsh[i] != 0 %} + lsh[{{ i }}] = {{ constraints.lsh[i] }}; + {%- endif %} + {%- if constraints.ush[i] != 0 %} + ush[{{ i }}] = {{ constraints.ush[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "idxsh", idxsh); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lsh", lsh); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "ush", ush); + } + free(idxsh); + free(lush); +{% endif %} + +{% if dims.nsphi > 0 %} + // set up soft bounds for convex-over-nonlinear constraints + int* idxsphi = malloc(NSPHI * sizeof(int)); + {% for i in range(end=dims.nsphi) %} + idxsphi[{{ i }}] = {{ constraints.idxsphi[i] }}; + {%- endfor %} + double* lusphi = calloc(2*NSPHI, sizeof(double)); + double* lsphi = lusphi; + double* usphi = lusphi + NSPHI; + {% for i in range(end=dims.nsphi) %} + {%- if constraints.lsphi[i] != 0 %} + lsphi[{{ i }}] = {{ constraints.lsphi[i] }}; + {%- endif %} + {%- if constraints.usphi[i] != 0 %} + usphi[{{ i }}] = {{ constraints.usphi[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "idxsphi", idxsphi); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lsphi", lsphi); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "usphi", usphi); + } + free(idxsphi); + free(lusphi); +{% endif %} + +{% if dims.nbx > 0 %} + // x + int* idxbx = malloc(NBX * sizeof(int)); + {% for i in range(end=dims.nbx) %} + idxbx[{{ i }}] = {{ constraints.idxbx[i] }}; + {%- endfor %} + double* lubx = calloc(2*NBX, sizeof(double)); + double* lbx = lubx; + double* ubx = lubx + NBX; + {% for i in range(end=dims.nbx) %} + {%- if constraints.lbx[i] != 0 %} + lbx[{{ i }}] = {{ constraints.lbx[i] }}; + {%- endif %} + {%- if constraints.ubx[i] != 0 %} + ubx[{{ i }}] = {{ constraints.ubx[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 1; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "idxbx", idxbx); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lbx", lbx); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "ubx", ubx); + } + free(idxbx); + free(lubx); +{% endif %} + +{% if dims.ng > 0 %} + // set up general constraints for stage 0 to N-1 + double* D = calloc(NG*NU, sizeof(double)); + double* C = calloc(NG*NX, sizeof(double)); + double* lug = calloc(2*NG, sizeof(double)); + double* lg = lug; + double* ug = lug + NG; + + {% for j in range(end=dims.ng) -%} + {% for k in range(end=dims.nu) %} + {%- if constraints.D[j][k] != 0 %} + D[{{ j }}+NG * {{ k }}] = {{ constraints.D[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + + {% for j in range(end=dims.ng) -%} + {% for k in range(end=dims.nx) %} + {%- if constraints.C[j][k] != 0 %} + C[{{ j }}+NG * {{ k }}] = {{ constraints.C[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + + {% for i in range(end=dims.ng) %} + {%- if constraints.lg[i] != 0 %} + lg[{{ i }}] = {{ constraints.lg[i] }}; + {%- endif %} + {%- endfor %} + + {% for i in range(end=dims.ng) %} + {%- if constraints.ug[i] != 0 %} + ug[{{ i }}] = {{ constraints.ug[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "D", D); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "C", C); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lg", lg); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "ug", ug); + } + free(D); + free(C); + free(lug); +{% endif %} + +{% if dims.nh > 0 %} + // set up nonlinear constraints for stage 0 to N-1 + double* luh = calloc(2*NH, sizeof(double)); + double* lh = luh; + double* uh = luh + NH; + + {% for i in range(end=dims.nh) %} + {%- if constraints.lh[i] != 0 %} + lh[{{ i }}] = {{ constraints.lh[i] }}; + {%- endif %} + {%- endfor %} + + {% for i in range(end=dims.nh) %} + {%- if constraints.uh[i] != 0 %} + uh[{{ i }}] = {{ constraints.uh[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + // nonlinear constraints for stages 0 to N-1 + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "nl_constr_h_fun_jac", + &capsule->nl_constr_h_fun_jac[i]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "nl_constr_h_fun", + &capsule->nl_constr_h_fun[i]); + {% if solver_options.hessian_approx == "EXACT" %} + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, + "nl_constr_h_fun_jac_hess", &capsule->nl_constr_h_fun_jac_hess[i]); + {% endif %} + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lh", lh); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "uh", uh); + } + free(luh); +{% endif %} + +{% if dims.nphi > 0 and constraints.constr_type == "BGP" %} + // set up convex-over-nonlinear constraints for stage 0 to N-1 + double* luphi = calloc(2*NPHI, sizeof(double)); + double* lphi = luphi; + double* uphi = luphi + NPHI; + {% for i in range(end=dims.nphi) %} + {%- if constraints.lphi[i] != 0 %} + lphi[{{ i }}] = {{ constraints.lphi[i] }}; + {%- endif %} + {%- endfor %} + + {% for i in range(end=dims.nphi) %} + {%- if constraints.uphi[i] != 0 %} + uphi[{{ i }}] = {{ constraints.uphi[i] }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i < N; i++) + { + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, + "nl_constr_phi_o_r_fun_phi_jac_ux_z_phi_hess_r_jac_ux", &capsule->phi_constraint[i]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "lphi", lphi); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, i, "uphi", uphi); + } + free(luphi); +{% endif %} + + /* terminal constraints */ +{% if dims.nbx_e > 0 %} + // set up bounds for last stage + // x + int* idxbx_e = malloc(NBXN * sizeof(int)); + {% for i in range(end=dims.nbx_e) %} + idxbx_e[{{ i }}] = {{ constraints.idxbx_e[i] }}; + {%- endfor %} + double* lubx_e = calloc(2*NBXN, sizeof(double)); + double* lbx_e = lubx_e; + double* ubx_e = lubx_e + NBXN; + {% for i in range(end=dims.nbx_e) %} + {%- if constraints.lbx_e[i] != 0 %} + lbx_e[{{ i }}] = {{ constraints.lbx_e[i] }}; + {%- endif %} + {%- if constraints.ubx_e[i] != 0 %} + ubx_e[{{ i }}] = {{ constraints.ubx_e[i] }}; + {%- endif %} + {%- endfor %} + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "idxbx", idxbx_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lbx", lbx_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "ubx", ubx_e); + free(idxbx_e); + free(lubx_e); +{%- endif %} + +{% if dims.nsg_e > 0 %} + // set up soft bounds for general linear constraints + int* idxsg_e = calloc(NSGN, sizeof(int)); + {% for i in range(end=dims.nsg_e) %} + idxsg_e[{{ i }}] = {{ constraints.idxsg_e[i] }}; + {%- endfor %} + double* lusg_e = calloc(2*NSGN, sizeof(double)); + double* lsg_e = lusg_e; + double* usg_e = lusg_e + NSGN; + {% for i in range(end=dims.nsg_e) %} + {%- if constraints.lsg_e[i] != 0 %} + lsg_e[{{ i }}] = {{ constraints.lsg_e[i] }}; + {%- endif %} + {%- if constraints.usg_e[i] != 0 %} + usg_e[{{ i }}] = {{ constraints.usg_e[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "idxsg", idxsg_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lsg", lsg_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "usg", usg_e); + free(idxsg_e); + free(lusg_e); +{%- endif %} + +{% if dims.nsh_e > 0 %} + // set up soft bounds for nonlinear constraints + int* idxsh_e = malloc(NSHN * sizeof(int)); + {% for i in range(end=dims.nsh_e) %} + idxsh_e[{{ i }}] = {{ constraints.idxsh_e[i] }}; + {%- endfor %} + double* lush_e = calloc(2*NSHN, sizeof(double)); + double* lsh_e = lush_e; + double* ush_e = lush_e + NSHN; + {% for i in range(end=dims.nsh_e) %} + {%- if constraints.lsh_e[i] != 0 %} + lsh_e[{{ i }}] = {{ constraints.lsh_e[i] }}; + {%- endif %} + {%- if constraints.ush_e[i] != 0 %} + ush_e[{{ i }}] = {{ constraints.ush_e[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "idxsh", idxsh_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lsh", lsh_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "ush", ush_e); + free(idxsh_e); + free(lush_e); +{%- endif %} + +{% if dims.nsphi_e > 0 %} + // set up soft bounds for convex-over-nonlinear constraints + int* idxsphi_e = malloc(NSPHIN * sizeof(int)); + {% for i in range(end=dims.nsphi_e) %} + idxsphi_e[{{ i }}] = {{ constraints.idxsphi_e[i] }}; + {%- endfor %} + double* lusphi_e = calloc(2*NSPHIN, sizeof(double)); + double* lsphi_e = lusphi_e; + double* usphi_e = lusphi_e + NSPHIN; + {% for i in range(end=dims.nsphi_e) %} + {%- if constraints.lsphi_e[i] != 0 %} + lsphi_e[{{ i }}] = {{ constraints.lsphi_e[i] }}; + {%- endif %} + {%- if constraints.usphi_e[i] != 0 %} + usphi_e[{{ i }}] = {{ constraints.usphi_e[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "idxsphi", idxsphi_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lsphi", lsphi_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "usphi", usphi_e); + free(idxsphi_e); + free(lusphi_e); +{%- endif %} + +{% if dims.nsbx_e > 0 %} + // soft bounds on x + int* idxsbx_e = malloc(NSBXN * sizeof(int)); + {% for i in range(end=dims.nsbx_e) %} + idxsbx_e[{{ i }}] = {{ constraints.idxsbx_e[i] }}; + {%- endfor %} + double* lusbx_e = calloc(2*NSBXN, sizeof(double)); + double* lsbx_e = lusbx_e; + double* usbx_e = lusbx_e + NSBXN; + {% for i in range(end=dims.nsbx_e) %} + {%- if constraints.lsbx_e[i] != 0 %} + lsbx_e[{{ i }}] = {{ constraints.lsbx_e[i] }}; + {%- endif %} + {%- if constraints.usbx_e[i] != 0 %} + usbx_e[{{ i }}] = {{ constraints.usbx_e[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "idxsbx", idxsbx_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lsbx", lsbx_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "usbx", usbx_e); + free(idxsbx_e); + free(lusbx_e); +{% endif %} + +{% if dims.ng_e > 0 %} + // set up general constraints for last stage + double* C_e = calloc(NGN*NX, sizeof(double)); + double* lug_e = calloc(2*NGN, sizeof(double)); + double* lg_e = lug_e; + double* ug_e = lug_e + NGN; + + {% for j in range(end=dims.ng) %} + {%- for k in range(end=dims.nx) %} + {%- if constraints.C_e[j][k] != 0 %} + C_e[{{ j }}+NG * {{ k }}] = {{ constraints.C_e[j][k] }}; + {%- endif %} + {%- endfor %} + {%- endfor %} + + {% for i in range(end=dims.ng_e) %} + {%- if constraints.lg_e[i] != 0 %} + lg_e[{{ i }}] = {{ constraints.lg_e[i] }}; + {%- endif %} + {%- if constraints.ug_e[i] != 0 %} + ug_e[{{ i }}] = {{ constraints.ug_e[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "C", C_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lg", lg_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "ug", ug_e); + free(C_e); + free(lug_e); +{%- endif %} + +{% if dims.nh_e > 0 %} + // set up nonlinear constraints for last stage + double* luh_e = calloc(2*NHN, sizeof(double)); + double* lh_e = luh_e; + double* uh_e = luh_e + NHN; + {% for i in range(end=dims.nh_e) %} + {%- if constraints.lh_e[i] != 0 %} + lh_e[{{ i }}] = {{ constraints.lh_e[i] }}; + {%- endif %} + {%- endfor %} + + {% for i in range(end=dims.nh_e) %} + {%- if constraints.uh_e[i] != 0 %} + uh_e[{{ i }}] = {{ constraints.uh_e[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "nl_constr_h_fun_jac", &capsule->nl_constr_h_e_fun_jac); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "nl_constr_h_fun", &capsule->nl_constr_h_e_fun); + {% if solver_options.hessian_approx == "EXACT" %} + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "nl_constr_h_fun_jac_hess", + &capsule->nl_constr_h_e_fun_jac_hess); + {% endif %} + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lh", lh_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "uh", uh_e); + free(luh_e); +{%- endif %} + +{% if dims.nphi_e > 0 and constraints.constr_type_e == "BGP" %} + // set up convex-over-nonlinear constraints for last stage + double* luphi_e = calloc(2*NPHIN, sizeof(double)); + double* lphi_e = luphi_e; + double* uphi_e = luphi_e + NPHIN; + {% for i in range(end=dims.nphi_e) %} + {%- if constraints.lphi_e[i] != 0 %} + lphi_e[{{ i }}] = {{ constraints.lphi_e[i] }}; + {%- endif %} + {%- if constraints.uphi_e[i] != 0 %} + uphi_e[{{ i }}] = {{ constraints.uphi_e[i] }}; + {%- endif %} + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "lphi", lphi_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, "uphi", uphi_e); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, N, + "nl_constr_phi_o_r_fun_phi_jac_ux_z_phi_hess_r_jac_ux", &capsule->phi_e_constraint); + free(luphi_e); +{% endif %} + + + /************************************************ + * opts + ************************************************/ + + capsule->nlp_opts = ocp_nlp_solver_opts_create(nlp_config, nlp_dims); + +{% if solver_options.hessian_approx == "EXACT" %} + bool nlp_solver_exact_hessian = true; + // TODO: this if should not be needed! however, calling the setter with false leads to weird behavior. Investigate! + if (nlp_solver_exact_hessian) + { + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "exact_hess", &nlp_solver_exact_hessian); + } + int exact_hess_dyn = {{ solver_options.exact_hess_dyn }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "exact_hess_dyn", &exact_hess_dyn); + + int exact_hess_cost = {{ solver_options.exact_hess_cost }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "exact_hess_cost", &exact_hess_cost); + + int exact_hess_constr = {{ solver_options.exact_hess_constr }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "exact_hess_constr", &exact_hess_constr); +{%- endif -%} + +{%- if solver_options.globalization == "FIXED_STEP" %} + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "globalization", "fixed_step"); +{%- elif solver_options.globalization == "MERIT_BACKTRACKING" %} + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "globalization", "merit_backtracking"); + + double alpha_min = {{ solver_options.alpha_min }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "alpha_min", &alpha_min); + + double alpha_reduction = {{ solver_options.alpha_reduction }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "alpha_reduction", &alpha_reduction); +{%- endif -%} + +{%- if dims.nz > 0 %} + // TODO: these options are lower level -> should be encapsulated! maybe through hessian approx option. + bool output_z_val = true; + bool sens_algebraic_val = true; + + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_output_z", &output_z_val); + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_sens_algebraic", &sens_algebraic_val); +{%- endif %} + +{%- if solver_options.integrator_type != "DISCRETE" %} + + // set collocation type (relevant for implicit integrators) + sim_collocation_type collocation_type = {{ solver_options.collocation_type }}; + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_collocation_type", &collocation_type); + + // set up sim_method_num_steps + {%- set all_equal = true %} + {%- set val = solver_options.sim_method_num_steps[0] %} + {%- for j in range(start=1, end=dims.N) %} + {%- if val != solver_options.sim_method_num_steps[j] %} + {%- set_global all_equal = false %} + {%- break %} + {%- endif %} + {%- endfor %} + + {%- if all_equal == true %} + // all sim_method_num_steps are identical + int sim_method_num_steps = {{ solver_options.sim_method_num_steps[0] }}; + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_num_steps", &sim_method_num_steps); + {%- else %} + // sim_method_num_steps are different + int* sim_method_num_steps = malloc(N*sizeof(int)); + {%- for j in range(end=dims.N) %} + sim_method_num_steps[{{ j }}] = {{ solver_options.sim_method_num_steps[j] }}; + {%- endfor %} + + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_num_steps", &sim_method_num_steps[i]); + free(sim_method_num_steps); + {%- endif %} + + // set up sim_method_num_stages + {%- set all_equal = true %} + {%- set val = solver_options.sim_method_num_stages[0] %} + {%- for j in range(start=1, end=dims.N) %} + {%- if val != solver_options.sim_method_num_stages[j] %} + {%- set_global all_equal = false %} + {%- break %} + {%- endif %} + {%- endfor %} + + {%- if all_equal == true %} + // all sim_method_num_stages are identical + int sim_method_num_stages = {{ solver_options.sim_method_num_stages[0] }}; + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_num_stages", &sim_method_num_stages); + {%- else %} + int* sim_method_num_stages = malloc(N*sizeof(int)); + {%- for j in range(end=dims.N) %} + sim_method_num_stages[{{ j }}] = {{ solver_options.sim_method_num_stages[j] }}; + {%- endfor %} + + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_num_stages", &sim_method_num_stages[i]); + free(sim_method_num_stages); + {%- endif %} + + int newton_iter_val = {{ solver_options.sim_method_newton_iter }}; + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_newton_iter", &newton_iter_val); + + + // set up sim_method_jac_reuse + {%- set all_equal = true %} + {%- set val = solver_options.sim_method_jac_reuse[0] %} + {%- for j in range(start=1, end=dims.N) %} + {%- if val != solver_options.sim_method_jac_reuse[j] %} + {%- set_global all_equal = false %} + {%- break %} + {%- endif %} + {%- endfor %} + {%- if all_equal == true %} + bool tmp_bool = (bool) {{ solver_options.sim_method_jac_reuse[0] }}; + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_jac_reuse", &tmp_bool); + {%- else %} + bool* sim_method_jac_reuse = malloc(N*sizeof(bool)); + {%- for j in range(end=dims.N) %} + sim_method_jac_reuse[{{ j }}] = (bool){{ solver_options.sim_method_jac_reuse[j] }}; + {%- endfor %} + + for (int i = 0; i < N; i++) + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "dynamics_jac_reuse", &sim_method_jac_reuse[i]); + free(sim_method_jac_reuse); + {%- endif %} + +{%- endif %} + + double nlp_solver_step_length = {{ solver_options.nlp_solver_step_length }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "step_length", &nlp_solver_step_length); + + {%- if solver_options.nlp_solver_warm_start_first_qp %} + int nlp_solver_warm_start_first_qp = {{ solver_options.nlp_solver_warm_start_first_qp }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "warm_start_first_qp", &nlp_solver_warm_start_first_qp); + {%- endif %} + + double levenberg_marquardt = {{ solver_options.levenberg_marquardt }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "levenberg_marquardt", &levenberg_marquardt); + + /* options QP solver */ +{%- if solver_options.qp_solver is starting_with("PARTIAL_CONDENSING") %} + int qp_solver_cond_N; + + {%- if solver_options.qp_solver_cond_N %} + qp_solver_cond_N = {{ solver_options.qp_solver_cond_N }}; + {% else %} + // NOTE: there is no condensing happening here! + qp_solver_cond_N = N; + {%- endif %} + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "qp_cond_N", &qp_solver_cond_N); +{% endif %} + + int qp_solver_iter_max = {{ solver_options.qp_solver_iter_max }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "qp_iter_max", &qp_solver_iter_max); + + {%- if solver_options.qp_solver_tol_stat %} + double qp_solver_tol_stat = {{ solver_options.qp_solver_tol_stat }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "qp_tol_stat", &qp_solver_tol_stat); + {%- endif -%} + + {%- if solver_options.qp_solver_tol_eq %} + double qp_solver_tol_eq = {{ solver_options.qp_solver_tol_eq }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "qp_tol_eq", &qp_solver_tol_eq); + {%- endif -%} + + {%- if solver_options.qp_solver_tol_ineq %} + double qp_solver_tol_ineq = {{ solver_options.qp_solver_tol_ineq }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "qp_tol_ineq", &qp_solver_tol_ineq); + {%- endif -%} + + {%- if solver_options.qp_solver_tol_comp %} + double qp_solver_tol_comp = {{ solver_options.qp_solver_tol_comp }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "qp_tol_comp", &qp_solver_tol_comp); + {%- endif -%} + + {%- if solver_options.qp_solver_warm_start %} + int qp_solver_warm_start = {{ solver_options.qp_solver_warm_start }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "qp_warm_start", &qp_solver_warm_start); + {%- endif -%} + +{% if solver_options.nlp_solver_type == "SQP" %} + // set SQP specific options + double nlp_solver_tol_stat = {{ solver_options.nlp_solver_tol_stat }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "tol_stat", &nlp_solver_tol_stat); + + double nlp_solver_tol_eq = {{ solver_options.nlp_solver_tol_eq }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "tol_eq", &nlp_solver_tol_eq); + + double nlp_solver_tol_ineq = {{ solver_options.nlp_solver_tol_ineq }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "tol_ineq", &nlp_solver_tol_ineq); + + double nlp_solver_tol_comp = {{ solver_options.nlp_solver_tol_comp }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "tol_comp", &nlp_solver_tol_comp); + + int nlp_solver_max_iter = {{ solver_options.nlp_solver_max_iter }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "max_iter", &nlp_solver_max_iter); + + int initialize_t_slacks = {{ solver_options.initialize_t_slacks }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "initialize_t_slacks", &initialize_t_slacks); +{%- endif %} + + int print_level = {{ solver_options.print_level }}; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "print_level", &print_level); + + + int ext_cost_num_hess = {{ solver_options.ext_cost_num_hess }}; +{%- if cost.cost_type == "EXTERNAL" %} + for (int i = 0; i < N; i++) + { + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, i, "cost_numerical_hessian", &ext_cost_num_hess); + } +{%- endif %} +{%- if cost.cost_type_e == "EXTERNAL" %} + ocp_nlp_solver_opts_set_at_stage(nlp_config, capsule->nlp_opts, N, "cost_numerical_hessian", &ext_cost_num_hess); +{%- endif %} + + + /* out */ + ocp_nlp_out * nlp_out = ocp_nlp_out_create(nlp_config, nlp_dims); + capsule->nlp_out = nlp_out; + + // initialize primal solution + double* xu0 = calloc(NX+NU, sizeof(double)); + double* x0 = xu0; +{% if dims.nbx_0 == dims.nx %} + // initialize with x0 + {% for item in constraints.lbx_0 %} + {%- if item != 0 %} + x0[{{ loop.index0 }}] = {{ item }}; + {%- endif %} + {%- endfor %} +{% else %} + // initialize with zeros +{%- endif %} + + double* u0 = xu0 + NX; + + for (int i = 0; i < N; i++) + { + // x0 + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "x", x0); + // u0 + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "u", u0); + } + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, N, "x", x0); + free(xu0); + + capsule->nlp_solver = ocp_nlp_solver_create(nlp_config, nlp_dims, capsule->nlp_opts); + + +{% if dims.np > 0 %} + // initialize parameters to nominal value + double* p = calloc(NP, sizeof(double)); + {% for item in parameter_values %} + {%- if item != 0 %} + p[{{ loop.index0 }}] = {{ item }}; + {%- endif %} + {%- endfor %} + + for (int i = 0; i <= N; i++) + { + {{ model.name }}_acados_update_params(capsule, i, p, NP); + } + free(p); +{%- endif %}{# if dims.np #} + + status = ocp_nlp_precompute(capsule->nlp_solver, nlp_in, nlp_out); + + if (status != ACADOS_SUCCESS) + { + printf("\nocp_precompute failed!\n\n"); + exit(1); + } + + return status; +} + + +int {{ model.name }}_acados_update_params({{ model.name }}_solver_capsule * capsule, int stage, double *p, int np) +{ + int solver_status = 0; + + int casadi_np = {{ dims.np }}; + if (casadi_np != np) { + printf("acados_update_params: trying to set %i parameters for external functions." + " External function has %i parameters. Exiting.\n", np, casadi_np); + exit(1); + } + +{%- if dims.np > 0 %} + const int N = capsule->nlp_solver_plan->N; + if (stage < N && stage >= 0) + { + {%- if solver_options.integrator_type == "IRK" %} + capsule->impl_dae_fun[stage].set_param(capsule->impl_dae_fun+stage, p); + capsule->impl_dae_fun_jac_x_xdot_z[stage].set_param(capsule->impl_dae_fun_jac_x_xdot_z+stage, p); + capsule->impl_dae_jac_x_xdot_u_z[stage].set_param(capsule->impl_dae_jac_x_xdot_u_z+stage, p); + + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->impl_dae_hess[stage].set_param(capsule->impl_dae_hess+stage, p); + {%- endif %} + {% elif solver_options.integrator_type == "LIFTED_IRK" %} + capsule->impl_dae_fun[stage].set_param(capsule->impl_dae_fun+stage, p); + capsule->impl_dae_fun_jac_x_xdot_z[stage].set_param(capsule->impl_dae_fun_jac_x_xdot_z+stage, p); + {% elif solver_options.integrator_type == "ERK" %} + capsule->forw_vde_casadi[stage].set_param(capsule->forw_vde_casadi+stage, p); + capsule->expl_ode_fun[stage].set_param(capsule->expl_ode_fun+stage, p); + + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->hess_vde_casadi[stage].set_param(capsule->hess_vde_casadi+stage, p); + {%- endif %} + {% elif solver_options.integrator_type == "GNSF" %} + capsule->gnsf_phi_fun[stage].set_param(capsule->gnsf_phi_fun+stage, p); + capsule->gnsf_phi_fun_jac_y[stage].set_param(capsule->gnsf_phi_fun_jac_y+stage, p); + capsule->gnsf_phi_jac_y_uhat[stage].set_param(capsule->gnsf_phi_jac_y_uhat+stage, p); + + capsule->gnsf_f_lo_jac_x1_x1dot_u_z[stage].set_param(capsule->gnsf_f_lo_jac_x1_x1dot_u_z+stage, p); + {% elif solver_options.integrator_type == "DISCRETE" %} + capsule->discr_dyn_phi_fun[stage].set_param(capsule->discr_dyn_phi_fun+stage, p); + capsule->discr_dyn_phi_fun_jac_ut_xt[stage].set_param(capsule->discr_dyn_phi_fun_jac_ut_xt+stage, p); + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->discr_dyn_phi_fun_jac_ut_xt_hess[stage].set_param(capsule->discr_dyn_phi_fun_jac_ut_xt_hess+stage, p); + {% endif %} + {%- endif %}{# integrator_type #} + + // constraints + {% if constraints.constr_type == "BGP" %} + capsule->phi_constraint[stage].set_param(capsule->phi_constraint+stage, p); + {% elif constraints.constr_type == "BGH" and dims.nh > 0 %} + capsule->nl_constr_h_fun_jac[stage].set_param(capsule->nl_constr_h_fun_jac+stage, p); + capsule->nl_constr_h_fun[stage].set_param(capsule->nl_constr_h_fun+stage, p); + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->nl_constr_h_fun_jac_hess[stage].set_param(capsule->nl_constr_h_fun_jac_hess+stage, p); + {%- endif %} + {%- endif %} + + // cost + if (stage == 0) + { + {%- if cost.cost_type_0 == "NONLINEAR_LS" %} + capsule->cost_y_0_fun.set_param(&capsule->cost_y_0_fun, p); + capsule->cost_y_0_fun_jac_ut_xt.set_param(&capsule->cost_y_0_fun_jac_ut_xt, p); + capsule->cost_y_0_hess.set_param(&capsule->cost_y_0_hess, p); + {%- elif cost.cost_type_0 == "EXTERNAL" %} + capsule->ext_cost_0_fun.set_param(&capsule->ext_cost_0_fun, p); + capsule->ext_cost_0_fun_jac.set_param(&capsule->ext_cost_0_fun_jac, p); + capsule->ext_cost_0_fun_jac_hess.set_param(&capsule->ext_cost_0_fun_jac_hess, p); + {% endif %} + } + else // 0 < stage < N + { + {%- if cost.cost_type == "NONLINEAR_LS" %} + capsule->cost_y_fun[stage-1].set_param(capsule->cost_y_fun+stage-1, p); + capsule->cost_y_fun_jac_ut_xt[stage-1].set_param(capsule->cost_y_fun_jac_ut_xt+stage-1, p); + capsule->cost_y_hess[stage-1].set_param(capsule->cost_y_hess+stage-1, p); + {%- elif cost.cost_type == "EXTERNAL" %} + capsule->ext_cost_fun[stage-1].set_param(capsule->ext_cost_fun+stage-1, p); + capsule->ext_cost_fun_jac[stage-1].set_param(capsule->ext_cost_fun_jac+stage-1, p); + capsule->ext_cost_fun_jac_hess[stage-1].set_param(capsule->ext_cost_fun_jac_hess+stage-1, p); + {%- endif %} + } + } + + else // stage == N + { + // terminal shooting node has no dynamics + // cost + {%- if cost.cost_type_e == "NONLINEAR_LS" %} + capsule->cost_y_e_fun.set_param(&capsule->cost_y_e_fun, p); + capsule->cost_y_e_fun_jac_ut_xt.set_param(&capsule->cost_y_e_fun_jac_ut_xt, p); + capsule->cost_y_e_hess.set_param(&capsule->cost_y_e_hess, p); + {%- elif cost.cost_type_e == "EXTERNAL" %} + capsule->ext_cost_e_fun.set_param(&capsule->ext_cost_e_fun, p); + capsule->ext_cost_e_fun_jac.set_param(&capsule->ext_cost_e_fun_jac, p); + capsule->ext_cost_e_fun_jac_hess.set_param(&capsule->ext_cost_e_fun_jac_hess, p); + {% endif %} + // constraints + {% if constraints.constr_type_e == "BGP" %} + capsule->phi_e_constraint.set_param(&capsule->phi_e_constraint, p); + {% elif constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} + capsule->nl_constr_h_e_fun_jac.set_param(&capsule->nl_constr_h_e_fun_jac, p); + capsule->nl_constr_h_e_fun.set_param(&capsule->nl_constr_h_e_fun, p); + {%- if solver_options.hessian_approx == "EXACT" %} + capsule->nl_constr_h_e_fun_jac_hess.set_param(&capsule->nl_constr_h_e_fun_jac_hess, p); + {%- endif %} + {% endif %} + } +{% endif %}{# if dims.np #} + + return solver_status; +} + + + +int {{ model.name }}_acados_solve({{ model.name }}_solver_capsule * capsule) +{ + // solve NLP + int solver_status = ocp_nlp_solve(capsule->nlp_solver, capsule->nlp_in, capsule->nlp_out); + + return solver_status; +} + + +int {{ model.name }}_acados_free({{ model.name }}_solver_capsule * capsule) +{ + // before destroying, keep some info + const int N = capsule->nlp_solver_plan->N; + // free memory + ocp_nlp_solver_opts_destroy(capsule->nlp_opts); + ocp_nlp_in_destroy(capsule->nlp_in); + ocp_nlp_out_destroy(capsule->nlp_out); + ocp_nlp_solver_destroy(capsule->nlp_solver); + ocp_nlp_dims_destroy(capsule->nlp_dims); + ocp_nlp_config_destroy(capsule->nlp_config); + ocp_nlp_plan_destroy(capsule->nlp_solver_plan); + + /* free external function */ + // dynamics +{%- if solver_options.integrator_type == "IRK" %} + for (int i = 0; i < N; i++) + { + external_function_param_casadi_free(&capsule->impl_dae_fun[i]); + external_function_param_casadi_free(&capsule->impl_dae_fun_jac_x_xdot_z[i]); + external_function_param_casadi_free(&capsule->impl_dae_jac_x_xdot_u_z[i]); + {%- if solver_options.hessian_approx == "EXACT" %} + external_function_param_casadi_free(&capsule->impl_dae_hess[i]); + {%- endif %} + } + free(capsule->impl_dae_fun); + free(capsule->impl_dae_fun_jac_x_xdot_z); + free(capsule->impl_dae_jac_x_xdot_u_z); + {%- if solver_options.hessian_approx == "EXACT" %} + free(capsule->impl_dae_hess); + {%- endif %} + +{%- elif solver_options.integrator_type == "LIFTED_IRK" %} + for (int i = 0; i < N; i++) + { + external_function_param_casadi_free(&capsule->impl_dae_fun[i]); + external_function_param_casadi_free(&capsule->impl_dae_fun_jac_x_xdot_u[i]); + } + free(capsule->impl_dae_fun); + free(capsule->impl_dae_fun_jac_x_xdot_u); + +{%- elif solver_options.integrator_type == "ERK" %} + for (int i = 0; i < N; i++) + { + external_function_param_casadi_free(&capsule->forw_vde_casadi[i]); + external_function_param_casadi_free(&capsule->expl_ode_fun[i]); + {%- if solver_options.hessian_approx == "EXACT" %} + external_function_param_casadi_free(&capsule->hess_vde_casadi[i]); + {%- endif %} + } + free(capsule->forw_vde_casadi); + free(capsule->expl_ode_fun); + {%- if solver_options.hessian_approx == "EXACT" %} + free(capsule->hess_vde_casadi); + {%- endif %} + +{%- elif solver_options.integrator_type == "GNSF" %} + for (int i = 0; i < N; i++) + { + external_function_param_casadi_free(&capsule->gnsf_phi_fun[i]); + external_function_param_casadi_free(&capsule->gnsf_phi_fun_jac_y[i]); + external_function_param_casadi_free(&capsule->gnsf_phi_jac_y_uhat[i]); + external_function_param_casadi_free(&capsule->gnsf_f_lo_jac_x1_x1dot_u_z[i]); + external_function_param_casadi_free(&capsule->gnsf_get_matrices_fun[i]); + } + free(capsule->gnsf_phi_fun); + free(capsule->gnsf_phi_fun_jac_y); + free(capsule->gnsf_phi_jac_y_uhat); + free(capsule->gnsf_f_lo_jac_x1_x1dot_u_z); + free(capsule->gnsf_get_matrices_fun); +{%- elif solver_options.integrator_type == "DISCRETE" %} + for (int i = 0; i < N; i++) + { + external_function_param_{{ model.dyn_ext_fun_type }}_free(&capsule->discr_dyn_phi_fun[i]); + external_function_param_{{ model.dyn_ext_fun_type }}_free(&capsule->discr_dyn_phi_fun_jac_ut_xt[i]); + {%- if solver_options.hessian_approx == "EXACT" %} + external_function_param_{{ model.dyn_ext_fun_type }}_free(&capsule->discr_dyn_phi_fun_jac_ut_xt_hess[i]); + {%- endif %} + } + free(capsule->discr_dyn_phi_fun); + free(capsule->discr_dyn_phi_fun_jac_ut_xt); + {%- if solver_options.hessian_approx == "EXACT" %} + free(capsule->discr_dyn_phi_fun_jac_ut_xt_hess); + {%- endif %} + +{%- endif %} + + // cost +{%- if cost.cost_type_0 == "NONLINEAR_LS" %} + external_function_param_casadi_free(&capsule->cost_y_0_fun); + external_function_param_casadi_free(&capsule->cost_y_0_fun_jac_ut_xt); + external_function_param_casadi_free(&capsule->cost_y_0_hess); +{%- elif cost.cost_type_0 == "EXTERNAL" %} + external_function_param_{{ cost.cost_ext_fun_type_0 }}_free(&capsule->ext_cost_0_fun); + external_function_param_{{ cost.cost_ext_fun_type_0 }}_free(&capsule->ext_cost_0_fun_jac); + external_function_param_{{ cost.cost_ext_fun_type_0 }}_free(&capsule->ext_cost_0_fun_jac_hess); +{%- endif %} +{%- if cost.cost_type == "NONLINEAR_LS" %} + for (int i = 0; i < N - 1; i++) + { + external_function_param_casadi_free(&capsule->cost_y_fun[i]); + external_function_param_casadi_free(&capsule->cost_y_fun_jac_ut_xt[i]); + external_function_param_casadi_free(&capsule->cost_y_hess[i]); + } + free(capsule->cost_y_fun); + free(capsule->cost_y_fun_jac_ut_xt); + free(capsule->cost_y_hess); +{%- elif cost.cost_type == "EXTERNAL" %} + for (int i = 0; i < N - 1; i++) + { + external_function_param_{{ cost.cost_ext_fun_type }}_free(&capsule->ext_cost_fun[i]); + external_function_param_{{ cost.cost_ext_fun_type }}_free(&capsule->ext_cost_fun_jac[i]); + external_function_param_{{ cost.cost_ext_fun_type }}_free(&capsule->ext_cost_fun_jac_hess[i]); + } + free(capsule->ext_cost_fun); + free(capsule->ext_cost_fun_jac); + free(capsule->ext_cost_fun_jac_hess); +{%- endif %} +{%- if cost.cost_type_e == "NONLINEAR_LS" %} + external_function_param_casadi_free(&capsule->cost_y_e_fun); + external_function_param_casadi_free(&capsule->cost_y_e_fun_jac_ut_xt); + external_function_param_casadi_free(&capsule->cost_y_e_hess); +{%- elif cost.cost_type_e == "EXTERNAL" %} + external_function_param_{{ cost.cost_ext_fun_type_e }}_free(&capsule->ext_cost_e_fun); + external_function_param_{{ cost.cost_ext_fun_type_e }}_free(&capsule->ext_cost_e_fun_jac); + external_function_param_{{ cost.cost_ext_fun_type_e }}_free(&capsule->ext_cost_e_fun_jac_hess); +{%- endif %} + + // constraints +{%- if constraints.constr_type == "BGH" and dims.nh > 0 %} + for (int i = 0; i < N; i++) + { + external_function_param_casadi_free(&capsule->nl_constr_h_fun_jac[i]); + external_function_param_casadi_free(&capsule->nl_constr_h_fun[i]); + } + {%- if solver_options.hessian_approx == "EXACT" %} + for (int i = 0; i < N; i++) + { + external_function_param_casadi_free(&capsule->nl_constr_h_fun_jac_hess[i]); + } + {%- endif %} + free(capsule->nl_constr_h_fun_jac); + free(capsule->nl_constr_h_fun); + {%- if solver_options.hessian_approx == "EXACT" %} + free(capsule->nl_constr_h_fun_jac_hess); + {%- endif %} + +{%- elif constraints.constr_type == "BGP" and dims.nphi > 0 %} + for (int i = 0; i < N; i++) + { + external_function_param_casadi_free(&capsule->phi_constraint[i]); + } + free(capsule->phi_constraint); +{%- endif %} + +{%- if constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} + external_function_param_casadi_free(&capsule->nl_constr_h_e_fun_jac); + external_function_param_casadi_free(&capsule->nl_constr_h_e_fun); +{%- if solver_options.hessian_approx == "EXACT" %} + external_function_param_casadi_free(&capsule->nl_constr_h_e_fun_jac_hess); +{%- endif %} +{%- elif constraints.constr_type_e == "BGP" and dims.nphi_e > 0 %} + external_function_param_casadi_free(&capsule->phi_e_constraint); +{%- endif %} + + return 0; +} + +ocp_nlp_in *{{ model.name }}_acados_get_nlp_in({{ model.name }}_solver_capsule * capsule) { return capsule->nlp_in; } +ocp_nlp_out *{{ model.name }}_acados_get_nlp_out({{ model.name }}_solver_capsule * capsule) { return capsule->nlp_out; } +ocp_nlp_solver *{{ model.name }}_acados_get_nlp_solver({{ model.name }}_solver_capsule * capsule) { return capsule->nlp_solver; } +ocp_nlp_config *{{ model.name }}_acados_get_nlp_config({{ model.name }}_solver_capsule * capsule) { return capsule->nlp_config; } +void *{{ model.name }}_acados_get_nlp_opts({{ model.name }}_solver_capsule * capsule) { return capsule->nlp_opts; } +ocp_nlp_dims *{{ model.name }}_acados_get_nlp_dims({{ model.name }}_solver_capsule * capsule) { return capsule->nlp_dims; } +ocp_nlp_plan *{{ model.name }}_acados_get_nlp_plan({{ model.name }}_solver_capsule * capsule) { return capsule->nlp_solver_plan; } + + +void {{ model.name }}_acados_print_stats({{ model.name }}_solver_capsule * capsule) +{ + int sqp_iter, stat_m, stat_n, tmp_int; + ocp_nlp_get(capsule->nlp_config, capsule->nlp_solver, "sqp_iter", &sqp_iter); + ocp_nlp_get(capsule->nlp_config, capsule->nlp_solver, "stat_n", &stat_n); + ocp_nlp_get(capsule->nlp_config, capsule->nlp_solver, "stat_m", &stat_m); + + {% set stat_n_max = 10 %} + double stat[{{ solver_options.nlp_solver_max_iter * stat_n_max }}]; + ocp_nlp_get(capsule->nlp_config, capsule->nlp_solver, "statistics", stat); + + int nrow = sqp_iter+1 < stat_m ? sqp_iter+1 : stat_m; + + printf("iter\tres_stat\tres_eq\t\tres_ineq\tres_comp\tqp_stat\tqp_iter\n"); + for (int i = 0; i < nrow; i++) + { + for (int j = 0; j < stat_n + 1; j++) + { + if (j == 0 || j > 4) + { + tmp_int = (int) stat[i + j * nrow]; + printf("%d\t", tmp_int); + } + else + { + printf("%e\t", stat[i + j * nrow]); + } + } + printf("\n"); + } +} + diff --git a/pyextra/acados_template/c_templates_tera/acados_solver.in.h b/pyextra/acados_template/c_templates_tera/acados_solver.in.h new file mode 100644 index 00000000000000..e8c0a38ca36162 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_solver.in.h @@ -0,0 +1,206 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#ifndef ACADOS_SOLVER_{{ model.name }}_H_ +#define ACADOS_SOLVER_{{ model.name }}_H_ + +#include "acados_c/ocp_nlp_interface.h" +#include "acados_c/external_function_interface.h" + +#define {{ model.name | upper }}_NX {{ dims.nx }} +#define {{ model.name | upper }}_NZ {{ dims.nz }} +#define {{ model.name | upper }}_NU {{ dims.nu }} +#define {{ model.name | upper }}_NP {{ dims.np }} +#define {{ model.name | upper }}_NBX {{ dims.nbx }} +#define {{ model.name | upper }}_NBX0 {{ dims.nbx_0 }} +#define {{ model.name | upper }}_NBU {{ dims.nbu }} +#define {{ model.name | upper }}_NSBX {{ dims.nsbx }} +#define {{ model.name | upper }}_NSBU {{ dims.nsbu }} +#define {{ model.name | upper }}_NSH {{ dims.nsh }} +#define {{ model.name | upper }}_NSG {{ dims.nsg }} +#define {{ model.name | upper }}_NSPHI {{ dims.nsphi }} +#define {{ model.name | upper }}_NSHN {{ dims.nsh_e }} +#define {{ model.name | upper }}_NSGN {{ dims.nsg_e }} +#define {{ model.name | upper }}_NSPHIN {{ dims.nsphi_e }} +#define {{ model.name | upper }}_NSBXN {{ dims.nsbx_e }} +#define {{ model.name | upper }}_NS {{ dims.ns }} +#define {{ model.name | upper }}_NSN {{ dims.ns_e }} +#define {{ model.name | upper }}_NG {{ dims.ng }} +#define {{ model.name | upper }}_NBXN {{ dims.nbx_e }} +#define {{ model.name | upper }}_NGN {{ dims.ng_e }} +#define {{ model.name | upper }}_NY0 {{ dims.ny_0 }} +#define {{ model.name | upper }}_NY {{ dims.ny }} +#define {{ model.name | upper }}_NYN {{ dims.ny_e }} +#define {{ model.name | upper }}_N {{ dims.N }} +#define {{ model.name | upper }}_NH {{ dims.nh }} +#define {{ model.name | upper }}_NPHI {{ dims.nphi }} +#define {{ model.name | upper }}_NHN {{ dims.nh_e }} +#define {{ model.name | upper }}_NPHIN {{ dims.nphi_e }} +#define {{ model.name | upper }}_NR {{ dims.nr }} + +#ifdef __cplusplus +extern "C" { +#endif + +// ** capsule for solver data ** +typedef struct {{ model.name }}_solver_capsule +{ + // acados objects + ocp_nlp_in *nlp_in; + ocp_nlp_out *nlp_out; + ocp_nlp_solver *nlp_solver; + void *nlp_opts; + ocp_nlp_plan *nlp_solver_plan; + ocp_nlp_config *nlp_config; + ocp_nlp_dims *nlp_dims; + + // number of expected runtime parameters + unsigned int nlp_np; + + /* external functions */ + // dynamics +{% if solver_options.integrator_type == "ERK" %} + external_function_param_casadi *forw_vde_casadi; + external_function_param_casadi *expl_ode_fun; +{% if solver_options.hessian_approx == "EXACT" %} + external_function_param_casadi *hess_vde_casadi; +{%- endif %} +{% elif solver_options.integrator_type == "IRK" %} + external_function_param_casadi *impl_dae_fun; + external_function_param_casadi *impl_dae_fun_jac_x_xdot_z; + external_function_param_casadi *impl_dae_jac_x_xdot_u_z; +{% if solver_options.hessian_approx == "EXACT" %} + external_function_param_casadi *impl_dae_hess; +{%- endif %} +{% elif solver_options.integrator_type == "LIFTED_IRK" %} + external_function_param_casadi *impl_dae_fun; + external_function_param_casadi *impl_dae_fun_jac_x_xdot_u; +{% elif solver_options.integrator_type == "GNSF" %} + external_function_param_casadi *gnsf_phi_fun; + external_function_param_casadi *gnsf_phi_fun_jac_y; + external_function_param_casadi *gnsf_phi_jac_y_uhat; + external_function_param_casadi *gnsf_f_lo_jac_x1_x1dot_u_z; + external_function_param_casadi *gnsf_get_matrices_fun; +{% elif solver_options.integrator_type == "DISCRETE" %} + external_function_param_{{ model.dyn_ext_fun_type }} *discr_dyn_phi_fun; + external_function_param_{{ model.dyn_ext_fun_type }} *discr_dyn_phi_fun_jac_ut_xt; +{%- if solver_options.hessian_approx == "EXACT" %} + external_function_param_{{ model.dyn_ext_fun_type }} *discr_dyn_phi_fun_jac_ut_xt_hess; +{%- endif %} +{%- endif %} + + + // cost +{% if cost.cost_type == "NONLINEAR_LS" %} + external_function_param_casadi *cost_y_fun; + external_function_param_casadi *cost_y_fun_jac_ut_xt; + external_function_param_casadi *cost_y_hess; +{%- elif cost.cost_type == "EXTERNAL" %} + external_function_param_{{ cost.cost_ext_fun_type }} *ext_cost_fun; + external_function_param_{{ cost.cost_ext_fun_type }} *ext_cost_fun_jac; + external_function_param_{{ cost.cost_ext_fun_type }} *ext_cost_fun_jac_hess; +{% endif %} + +{% if cost.cost_type_0 == "NONLINEAR_LS" %} + external_function_param_casadi cost_y_0_fun; + external_function_param_casadi cost_y_0_fun_jac_ut_xt; + external_function_param_casadi cost_y_0_hess; +{% elif cost.cost_type_0 == "EXTERNAL" %} + external_function_param_{{ cost.cost_ext_fun_type_0 }} ext_cost_0_fun; + external_function_param_{{ cost.cost_ext_fun_type_0 }} ext_cost_0_fun_jac; + external_function_param_{{ cost.cost_ext_fun_type_0 }} ext_cost_0_fun_jac_hess; +{%- endif %} + +{% if cost.cost_type_e == "NONLINEAR_LS" %} + external_function_param_casadi cost_y_e_fun; + external_function_param_casadi cost_y_e_fun_jac_ut_xt; + external_function_param_casadi cost_y_e_hess; +{% elif cost.cost_type_e == "EXTERNAL" %} + external_function_param_{{ cost.cost_ext_fun_type_e }} ext_cost_e_fun; + external_function_param_{{ cost.cost_ext_fun_type_e }} ext_cost_e_fun_jac; + external_function_param_{{ cost.cost_ext_fun_type_e }} ext_cost_e_fun_jac_hess; +{%- endif %} + + // constraints +{%- if constraints.constr_type == "BGP" %} + external_function_param_casadi *phi_constraint; +{% elif constraints.constr_type == "BGH" and dims.nh > 0 %} + external_function_param_casadi *nl_constr_h_fun_jac; + external_function_param_casadi *nl_constr_h_fun; + external_function_param_casadi *nl_constr_h_fun_jac_hess; +{%- endif %} + + +{% if constraints.constr_type_e == "BGP" %} + external_function_param_casadi phi_e_constraint; +{% elif constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} + external_function_param_casadi nl_constr_h_e_fun_jac; + external_function_param_casadi nl_constr_h_e_fun; + external_function_param_casadi nl_constr_h_e_fun_jac_hess; +{%- endif %} + +} {{ model.name }}_solver_capsule; + +{{ model.name }}_solver_capsule * {{ model.name }}_acados_create_capsule(void); +int {{ model.name }}_acados_free_capsule({{ model.name }}_solver_capsule *capsule); + +int {{ model.name }}_acados_create({{ model.name }}_solver_capsule * capsule); +/** + * Generic version of {{ model.name }}_acados_create which allows to use a different number of shooting intervals than + * the number used for code generation. If new_time_steps=NULL and n_time_steps matches the number used for code + * generation, the time-steps from code generation is used. + */ +int {{ model.name }}_acados_create_with_discretization({{ model.name }}_solver_capsule * capsule, int n_time_steps, double* new_time_steps); +/** + * Update the time step vector. Number N must be identical to the currently set number of shooting nodes in the + * nlp_solver_plan. Returns 0 if no error occurred and a otherwise a value other than 0. + */ +int {{ model.name }}_acados_update_time_steps({{ model.name }}_solver_capsule * capsule, int N, double* new_time_steps); +int {{ model.name }}_acados_update_params({{ model.name }}_solver_capsule * capsule, int stage, double *value, int np); +int {{ model.name }}_acados_solve({{ model.name }}_solver_capsule * capsule); +int {{ model.name }}_acados_free({{ model.name }}_solver_capsule * capsule); +void {{ model.name }}_acados_print_stats({{ model.name }}_solver_capsule * capsule); + +ocp_nlp_in *{{ model.name }}_acados_get_nlp_in({{ model.name }}_solver_capsule * capsule); +ocp_nlp_out *{{ model.name }}_acados_get_nlp_out({{ model.name }}_solver_capsule * capsule); +ocp_nlp_solver *{{ model.name }}_acados_get_nlp_solver({{ model.name }}_solver_capsule * capsule); +ocp_nlp_config *{{ model.name }}_acados_get_nlp_config({{ model.name }}_solver_capsule * capsule); +void *{{ model.name }}_acados_get_nlp_opts({{ model.name }}_solver_capsule * capsule); +ocp_nlp_dims *{{ model.name }}_acados_get_nlp_dims({{ model.name }}_solver_capsule * capsule); +ocp_nlp_plan *{{ model.name }}_acados_get_nlp_plan({{ model.name }}_solver_capsule * capsule); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_SOLVER_{{ model.name }}_H_ diff --git a/pyextra/acados_template/c_templates_tera/acados_solver.in.pxd b/pyextra/acados_template/c_templates_tera/acados_solver.in.pxd new file mode 100644 index 00000000000000..8387980c24560d --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_solver.in.pxd @@ -0,0 +1,22 @@ +cimport acados_solver_common + +cdef extern from "acados_solver_{{ model.name }}.h": + ctypedef struct nlp_solver_capsule "{{ model.name }}_solver_capsule": + pass + + nlp_solver_capsule * acados_create_capsule "{{ model.name }}_acados_create_capsule"() + int acados_free_capsule "{{ model.name }}_acados_free_capsule"(nlp_solver_capsule *capsule) + + int acados_create "{{ model.name }}_acados_create"(nlp_solver_capsule * capsule) + int acados_update_params "{{ model.name }}_acados_update_params"(nlp_solver_capsule * capsule, int stage, double *value, int np_) + int acados_solve "{{ model.name }}_acados_solve"(nlp_solver_capsule * capsule) + int acados_free "{{ model.name }}_acados_free"(nlp_solver_capsule * capsule) + void acados_print_stats "{{ model.name }}_acados_print_stats"(nlp_solver_capsule * capsule) + + acados_solver_common.ocp_nlp_in *acados_get_nlp_in "{{ model.name }}_acados_get_nlp_in"(nlp_solver_capsule * capsule) + acados_solver_common.ocp_nlp_out *acados_get_nlp_out "{{ model.name }}_acados_get_nlp_out"(nlp_solver_capsule * capsule) + acados_solver_common.ocp_nlp_solver *acados_get_nlp_solver "{{ model.name }}_acados_get_nlp_solver"(nlp_solver_capsule * capsule) + acados_solver_common.ocp_nlp_config *acados_get_nlp_config "{{ model.name }}_acados_get_nlp_config"(nlp_solver_capsule * capsule) + void *acados_get_nlp_opts "{{ model.name }}_acados_get_nlp_opts"(nlp_solver_capsule * capsule) + acados_solver_common.ocp_nlp_dims *acados_get_nlp_dims "{{ model.name }}_acados_get_nlp_dims"(nlp_solver_capsule * capsule) + acados_solver_common.ocp_nlp_plan *acados_get_nlp_plan "{{ model.name }}_acados_get_nlp_plan"(nlp_solver_capsule * capsule) diff --git a/pyextra/acados_template/c_templates_tera/acados_solver_sfun.in.c b/pyextra/acados_template/c_templates_tera/acados_solver_sfun.in.c new file mode 100644 index 00000000000000..a6cd1faa8c2104 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/acados_solver_sfun.in.c @@ -0,0 +1,761 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#define S_FUNCTION_NAME acados_solver_sfunction_{{ model.name }} +#define S_FUNCTION_LEVEL 2 + +#define MDL_START + +// acados +#include "acados/utils/print.h" +#include "acados_c/sim_interface.h" +#include "acados_c/external_function_interface.h" + +// example specific +#include "{{ model.name }}_model/{{ model.name }}_model.h" +#include "acados_solver_{{ model.name }}.h" + +#include "simstruc.h" + +{% if simulink_opts.samplingtime == "t0" -%} +#define SAMPLINGTIME {{ solver_options.time_steps[0] }} +{%- elif simulink_opts.samplingtime == "-1" -%} +#define SAMPLINGTIME -1 +{%- else -%} + {{ throw(message = "simulink_opts.samplingtime must be '-1' or 't0', got val") }} +{%- endif %} + +static void mdlInitializeSizes (SimStruct *S) +{ + // specify the number of continuous and discrete states + ssSetNumContStates(S, 0); + ssSetNumDiscStates(S, 0); + + {%- for key, val in simulink_opts.inputs -%} + {%- if val != 0 and val != 1 -%} + {{ throw(message = "simulink_opts.inputs must be 0 or 1, got val") }} + {%- endif -%} + {%- endfor -%} + + {#- compute number of input ports #} + {%- set n_inputs = 0 -%} + {%- if dims.nbx_0 > 0 and simulink_opts.inputs.lbx_0 -%} {#- lbx_0 #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nbx_0 > 0 and simulink_opts.inputs.ubx_0 -%} {#- ubx_0 #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.np > 0 and simulink_opts.inputs.parameter_traj -%} {#- parameter_traj #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.ny_0 > 0 and simulink_opts.inputs.y_ref_0 -%} {#- y_ref_0 -#} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.ny > 0 and dims.N > 1 and simulink_opts.inputs.y_ref -%} {#- y_ref -#} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.ny_e > 0 and dims.N > 0 and simulink_opts.inputs.y_ref_e -%} {#- y_ref_e #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.lbx -%} {#- lbx #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.ubx -%} {#- ubx #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.lbx_e -%} {#- lbx_e #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.ubx_e -%} {#- ubx_e #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.lbu -%} {#- lbu #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.ubu -%} {#- ubu #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.ng > 0 and simulink_opts.inputs.lg -%} {#- lg #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.ng > 0 and simulink_opts.inputs.ug -%} {#- ug #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nh > 0 and simulink_opts.inputs.lh -%} {#- lh #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + {%- if dims.nh > 0 and simulink_opts.inputs.uh -%} {#- uh #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + + {%- for key, val in simulink_opts.inputs -%} + {%- if val != 0 and val != 1 -%} + {{ throw(message = "simulink_opts.inputs must be 0 or 1, got val") }} + {%- endif -%} + {%- endfor -%} + {%- if dims.ny_0 > 0 and simulink_opts.inputs.cost_W_0 %} {#- cost_W_0 #} + {%- set n_inputs = n_inputs + 1 %} + {%- endif -%} + {%- if dims.ny > 0 and simulink_opts.inputs.cost_W -%} {#- cost_W #} + {%- set n_inputs = n_inputs + 1 %} + {%- endif -%} + {%- if dims.ny_e > 0 and simulink_opts.inputs.cost_W_e -%} {#- cost_W_e #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + + {%- if simulink_opts.inputs.x_init -%} {#- x_init #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + + {%- if simulink_opts.inputs.u_init -%} {#- u_init #} + {%- set n_inputs = n_inputs + 1 -%} + {%- endif -%} + + // specify the number of input ports + if ( !ssSetNumInputPorts(S, {{ n_inputs }}) ) + return; + + // specify the number of output ports + {%- set_global n_outputs = 0 %} + {%- for key, val in simulink_opts.outputs %} + {%- if val == 1 %} + {%- set_global n_outputs = n_outputs + val %} + {%- elif val != 0 %} + {{ throw(message = "simulink_opts.outputs must be 0 or 1, got val") }} + {%- endif %} + {%- endfor %} + if ( !ssSetNumOutputPorts(S, {{ n_outputs }}) ) + return; + + // specify dimension information for the input ports + {%- set i_input = -1 %}{# note here i_input is 0-based #} + {%- if dims.nbx_0 > 0 and simulink_opts.inputs.lbx_0 -%} {#- lbx_0 #} + {%- set i_input = i_input + 1 %} + // lbx_0 + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nbx_0 }}); + {%- endif %} + {%- if dims.nbx_0 > 0 and simulink_opts.inputs.ubx_0 -%} {#- ubx_0 #} + {%- set i_input = i_input + 1 %} + // ubx_0 + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nbx_0 }}); + {%- endif %} + + {%- if dims.np > 0 and simulink_opts.inputs.parameter_traj -%} {#- parameter_traj #} + {%- set i_input = i_input + 1 %} + // parameters + ssSetInputPortVectorDimension(S, {{ i_input }}, ({{ dims.N }}+1) * {{ dims.np }}); + {%- endif %} + + {%- if dims.ny > 0 and simulink_opts.inputs.y_ref_0 %} + {%- set i_input = i_input + 1 %} + // y_ref_0 + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.ny_0 }}); + {%- endif %} + + {%- if dims.ny > 0 and dims.N > 1 and simulink_opts.inputs.y_ref %} + {%- set i_input = i_input + 1 %} + // y_ref + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ (dims.N-1) * dims.ny }}); + {%- endif %} + + {%- if dims.ny_e > 0 and dims.N > 0 and simulink_opts.inputs.y_ref_e %} + {%- set i_input = i_input + 1 %} + // y_ref_e + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.ny_e }}); + {%- endif %} + + {%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.lbx -%} {#- lbx #} + {%- set i_input = i_input + 1 %} + // lbx + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ (dims.N-1) * dims.nbx }}); + {%- endif %} + {%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.ubx -%} {#- ubx #} + {%- set i_input = i_input + 1 %} + // ubx + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ (dims.N-1) * dims.nbx }}); + {%- endif %} + + {%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.lbx_e -%} {#- lbx_e #} + {%- set i_input = i_input + 1 %} + // lbx_e + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nbx_e }}); + {%- endif %} + {%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.ubx_e -%} {#- ubx_e #} + {%- set i_input = i_input + 1 %} + // ubx_e + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nbx_e }}); + {%- endif %} + + {%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.lbu -%} {#- lbu #} + {%- set i_input = i_input + 1 %} + // lbu + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.N*dims.nbu }}); + {%- endif -%} + {%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.ubu -%} {#- ubu #} + {%- set i_input = i_input + 1 %} + // ubu + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.N*dims.nbu }}); + {%- endif -%} + + + {%- if dims.ng > 0 and simulink_opts.inputs.lg -%} {#- lg #} + {%- set i_input = i_input + 1 %} + // lg + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.ng }}); + {%- endif -%} + {%- if dims.ng > 0 and simulink_opts.inputs.ug -%} {#- ug #} + {%- set i_input = i_input + 1 %} + // ug + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.ng }}); + {%- endif -%} + + {%- if dims.nh > 0 and simulink_opts.inputs.lh -%} {#- lh #} + {%- set i_input = i_input + 1 %} + // lh + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nh }}); + {%- endif -%} + {%- if dims.nh > 0 and simulink_opts.inputs.uh -%} {#- uh #} + {%- set i_input = i_input + 1 %} + // uh + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nh }}); + {%- endif -%} + + {%- if dims.ny_0 > 0 and simulink_opts.inputs.cost_W_0 %} {#- cost_W_0 #} + {%- set i_input = i_input + 1 %} + // cost_W_0 + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.ny_0 * dims.ny_0 }}); + {%- endif %} + + {%- if dims.ny_0 > 0 and simulink_opts.inputs.cost_W %} {#- cost_W #} + {%- set i_input = i_input + 1 %} + // cost_W + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.ny * dims.ny }}); + {%- endif %} + + {%- if dims.ny_e > 0 and simulink_opts.inputs.cost_W_e %} {#- cost_W_e #} + {%- set i_input = i_input + 1 %} + // cost_W_e + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.ny_e * dims.ny_e }}); + {%- endif %} + + {%- if simulink_opts.inputs.x_init -%} {#- x_init #} + {%- set i_input = i_input + 1 %} + // x_init + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nx * (dims.N+1) }}); + {%- endif -%} + + {%- if simulink_opts.inputs.u_init -%} {#- u_init #} + {%- set i_input = i_input + 1 %} + // u_init + ssSetInputPortVectorDimension(S, {{ i_input }}, {{ dims.nu * (dims.N) }}); + {%- endif -%} + + /* specify dimension information for the OUTPUT ports */ + {%- set i_output = -1 %}{# note here i_output is 0-based #} + {%- if dims.nu > 0 and simulink_opts.outputs.u0 == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, {{ dims.nu }} ); + {%- endif %} + + {%- if simulink_opts.outputs.utraj == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, {{ dims.nu * dims.N }} ); + {%- endif %} + + {%- if simulink_opts.outputs.xtraj == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, {{ dims.nx * (dims.N+1) }} ); + {%- endif %} + + {%- if simulink_opts.outputs.solver_status == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, 1 ); + {%- endif %} + + {%- if simulink_opts.outputs.KKT_residual == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, 1 ); + {%- endif %} + + {%- if dims.N > 0 and simulink_opts.outputs.x1 == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, {{ dims.nx }} ); // state at shooting node 1 + {%- endif %} + + {%- if simulink_opts.outputs.CPU_time == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, 1); + {%- endif %} + + {%- if simulink_opts.outputs.CPU_time_sim == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, 1); + {%- endif %} + + {%- if simulink_opts.outputs.CPU_time_qp == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, 1); + {%- endif %} + + {%- if simulink_opts.outputs.CPU_time_lin == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, 1); + {%- endif %} + + {%- if simulink_opts.outputs.sqp_iter == 1 %} + {%- set i_output = i_output + 1 %} + ssSetOutputPortVectorDimension(S, {{ i_output }}, 1 ); + {%- endif %} + + // specify the direct feedthrough status + // should be set to 1 for all inputs used in mdlOutputs + {%- for i in range(end=n_inputs) %} + ssSetInputPortDirectFeedThrough(S, {{ i }}, 1); + {%- endfor %} + + // one sample time + ssSetNumSampleTimes(S, 1); +} + + +#if defined(MATLAB_MEX_FILE) + +#define MDL_SET_INPUT_PORT_DIMENSION_INFO +#define MDL_SET_OUTPUT_PORT_DIMENSION_INFO + +static void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port, const DimsInfo_T *dimsInfo) +{ + if ( !ssSetInputPortDimensionInfo(S, port, dimsInfo) ) + return; +} + +static void mdlSetOutputPortDimensionInfo(SimStruct *S, int_T port, const DimsInfo_T *dimsInfo) +{ + if ( !ssSetOutputPortDimensionInfo(S, port, dimsInfo) ) + return; +} + +#endif /* MATLAB_MEX_FILE */ + + +static void mdlInitializeSampleTimes(SimStruct *S) +{ + ssSetSampleTime(S, 0, SAMPLINGTIME); + ssSetOffsetTime(S, 0, 0.0); +} + + +static void mdlStart(SimStruct *S) +{ + {{ model.name }}_solver_capsule *capsule = {{ model.name }}_acados_create_capsule(); + {{ model.name }}_acados_create(capsule); + + ssSetUserData(S, (void*)capsule); +} + + +static void mdlOutputs(SimStruct *S, int_T tid) +{ + {{ model.name }}_solver_capsule *capsule = ssGetUserData(S); + ocp_nlp_config *nlp_config = {{ model.name }}_acados_get_nlp_config(capsule); + ocp_nlp_dims *nlp_dims = {{ model.name }}_acados_get_nlp_dims(capsule); + ocp_nlp_in *nlp_in = {{ model.name }}_acados_get_nlp_in(capsule); + ocp_nlp_out *nlp_out = {{ model.name }}_acados_get_nlp_out(capsule); + + InputRealPtrsType in_sign; + + {%- set buffer_sizes = [dims.nbx_0, dims.np, dims.nbx, dims.nbu, dims.ng, dims.nh, dims.nx] -%} + + {%- if dims.ny_0 > 0 and simulink_opts.inputs.y_ref_0 %} {# y_ref_0 #} + {%- set buffer_sizes = buffer_sizes | concat(with=(dims.ny_0)) %} + {%- endif %} + {%- if dims.ny > 0 and dims.N > 1 and simulink_opts.inputs.y_ref %} {# y_ref #} + {%- set buffer_sizes = buffer_sizes | concat(with=(dims.ny)) %} + {%- endif %} + {%- if dims.ny_e > 0 and dims.N > 0 and simulink_opts.inputs.y_ref_e %} {# y_ref_e #} + {%- set buffer_sizes = buffer_sizes | concat(with=(dims.ny_e)) %} + {%- endif %} + + {%- if dims.ny_0 > 0 and simulink_opts.inputs.cost_W_0 %} {# cost_W_0 #} + {%- set buffer_sizes = buffer_sizes | concat(with=(dims.ny_0 * dims.ny_0)) %} + {%- endif %} + {%- if dims.ny > 0 and simulink_opts.inputs.cost_W %} {# cost_W #} + {%- set buffer_sizes = buffer_sizes | concat(with=(dims.ny * dims.ny)) %} + {%- endif %} + {%- if dims.ny_e > 0 and simulink_opts.inputs.cost_W_e %} {# cost_W_e #} + {%- set buffer_sizes = buffer_sizes | concat(with=(dims.ny_e * dims.ny_e)) %} + {%- endif %} + + // local buffer + {%- set buffer_size = buffer_sizes | sort | last %} + real_t buffer[{{ buffer_size }}]; + + /* go through inputs */ + {%- set i_input = -1 %} + {%- if dims.nbx_0 > 0 and simulink_opts.inputs.lbx_0 -%} {#- lbx_0 #} + // lbx_0 + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int i = 0; i < {{ dims.nbx_0 }}; i++) + buffer[i] = (double)(*in_sign[i]); + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "lbx", buffer); + {%- endif %} + + {%- if dims.nbx_0 > 0 and simulink_opts.inputs.ubx_0 -%} {#- ubx_0 #} + // ubx_0 + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int i = 0; i < {{ dims.nbx_0 }}; i++) + buffer[i] = (double)(*in_sign[i]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "ubx", buffer); + {%- endif %} + + {%- if dims.np > 0 and simulink_opts.inputs.parameter_traj -%} {#- parameter_traj #} + // parameters - stage-variant !!! + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + // update value of parameters + for (int ii = 0; ii <= {{ dims.N }}; ii++) + { + for (int jj = 0; jj < {{ dims.np }}; jj++) + buffer[jj] = (double)(*in_sign[ii*{{dims.np}}+jj]); + {{ model.name }}_acados_update_params(capsule, ii, buffer, {{ dims.np }}); + } + {%- endif %} + + {% if dims.ny_0 > 0 and simulink_opts.inputs.y_ref_0 %} + // y_ref_0 + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.ny_0 }}; i++) + buffer[i] = (double)(*in_sign[i]); + + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "yref", (void *) buffer); + {%- endif %} + + {% if dims.ny > 0 and dims.N > 1 and simulink_opts.inputs.y_ref %} + // y_ref - for stages 1 to N-1 + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int ii = 1; ii < {{ dims.N }}; ii++) + { + for (int jj = 0; jj < {{ dims.ny }}; jj++) + buffer[jj] = (double)(*in_sign[(ii-1)*{{ dims.ny }}+jj]); + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, ii, "yref", (void *) buffer); + } + {%- endif %} + + {% if dims.ny_e > 0 and dims.N > 0 and simulink_opts.inputs.y_ref_e %} + // y_ref_e + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.ny_e }}; i++) + buffer[i] = (double)(*in_sign[i]); + + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, {{ dims.N }}, "yref", (void *) buffer); + {%- endif %} + + {%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.lbx -%} {#- lbx #} + // lbx + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int ii = 1; ii < {{ dims.N }}; ii++) + { + for (int jj = 0; jj < {{ dims.nbx }}; jj++) + buffer[jj] = (double)(*in_sign[(ii-1)*{{ dims.nbx }}+jj]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "lbx", (void *) buffer); + } + {%- endif %} + {%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.ubx -%} {#- ubx #} + // ubx + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int ii = 1; ii < {{ dims.N }}; ii++) + { + for (int jj = 0; jj < {{ dims.nbx }}; jj++) + buffer[jj] = (double)(*in_sign[(ii-1)*{{ dims.nbx }}+jj]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "ubx", (void *) buffer); + } + {%- endif %} + + + {%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.lbx_e -%} {#- lbx_e #} + // lbx_e + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.nbx_e }}; i++) + buffer[i] = (double)(*in_sign[i]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, {{ dims.N }}, "lbx", buffer); + {%- endif %} + {%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.ubx_e -%} {#- ubx_e #} + // ubx_e + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.nbx_e }}; i++) + buffer[i] = (double)(*in_sign[i]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, {{ dims.N }}, "ubx", buffer); + {%- endif %} + + + {%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.lbu -%} {#- lbu #} + // lbu + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int ii = 0; ii < {{ dims.N }}; ii++) + { + for (int jj = 0; jj < {{ dims.nbu }}; jj++) + buffer[jj] = (double)(*in_sign[ii*{{ dims.nbu }}+jj]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "lbu", (void *) buffer); + } + {%- endif -%} + {%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.ubu -%} {#- ubu #} + // ubu + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int ii = 0; ii < {{ dims.N }}; ii++) + { + for (int jj = 0; jj < {{ dims.nbu }}; jj++) + buffer[jj] = (double)(*in_sign[ii*{{ dims.nbu }}+jj]); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "ubu", (void *) buffer); + } + {%- endif -%} + + {%- if dims.ng > 0 and simulink_opts.inputs.lg -%} {#- lg #} + // lg + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.ng }}; i++) + buffer[i] = (double)(*in_sign[i]); + + for (int ii = 0; ii < {{ dims.N }}; ii++) + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "lg", buffer); + {%- endif -%} + {%- if dims.ng > 0 and simulink_opts.inputs.ug -%} {#- ug #} + // ug + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.ng }}; i++) + buffer[i] = (double)(*in_sign[i]); + + for (int ii = 0; ii < {{ dims.N }}; ii++) + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "ug", buffer); + {%- endif -%} + {%- if dims.nh > 0 and simulink_opts.inputs.lh -%} {#- lh #} + // lh + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.nh }}; i++) + buffer[i] = (double)(*in_sign[i]); + + for (int ii = 0; ii < {{ dims.N }}; ii++) + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "lh", buffer); + {%- endif -%} + {%- if dims.nh > 0 and simulink_opts.inputs.uh -%} {#- uh #} + // uh + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + + for (int i = 0; i < {{ dims.nh }}; i++) + buffer[i] = (double)(*in_sign[i]); + + for (int ii = 0; ii < {{ dims.N }}; ii++) + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, ii, "uh", buffer); + {%- endif -%} + + {%- if dims.ny_0 > 0 and simulink_opts.inputs.cost_W_0 %} {# cost_W_0 #} + // cost_W_0 + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int i = 0; i < {{ dims.ny_0 * dims.ny_0 }}; i++) + buffer[i] = (double)(*in_sign[i]); + + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, 0, "W", buffer); + {%- endif %} + + {%- if dims.ny > 0 and simulink_opts.inputs.cost_W %} {# cost_W #} + // cost_W + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int i = 0; i < {{ dims.ny * dims.ny }}; i++) + buffer[i] = (double)(*in_sign[i]); + + for (int ii = 1; ii < {{ dims.N }}; ii++) + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, ii, "W", buffer); + {%- endif %} + + {%- if dims.ny_e > 0 and simulink_opts.inputs.cost_W_e %} {#- cost_W_e #} + // cost_W_e + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int i = 0; i < {{ dims.ny_e * dims.ny_e }}; i++) + buffer[i] = (double)(*in_sign[i]); + + ocp_nlp_cost_model_set(nlp_config, nlp_dims, nlp_in, {{ dims.N }}, "W", buffer); + {%- endif %} + + {%- if simulink_opts.inputs.x_init %} {#- x_init #} + // x_init + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int ii = 0; ii < {{ dims.N + 1 }}; ii++) + { + for (int jj = 0; jj < {{ dims.nx }}; jj++) + buffer[jj] = (double)(*in_sign[(ii)*{{ dims.nx }}+jj]); + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, ii, "x", (void *) buffer); + } + {%- endif %} + + {%- if simulink_opts.inputs.u_init %} {#- u_init #} + // u_init + {%- set i_input = i_input + 1 %} + in_sign = ssGetInputPortRealSignalPtrs(S, {{ i_input }}); + for (int ii = 0; ii < {{ dims.N }}; ii++) + { + for (int jj = 0; jj < {{ dims.nu }}; jj++) + buffer[jj] = (double)(*in_sign[(ii)*{{ dims.nu }}+jj]); + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, ii, "u", (void *) buffer); + } + {%- endif %} + + /* call solver */ + int rti_phase = 0; + ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "rti_phase", &rti_phase); + int acados_status = {{ model.name }}_acados_solve(capsule); + + + /* set outputs */ + // assign pointers to output signals + real_t *out_u0, *out_utraj, *out_xtraj, *out_status, *out_sqp_iter, *out_KKT_res, *out_x1, *out_cpu_time, *out_cpu_time_sim, *out_cpu_time_qp, *out_cpu_time_lin; + int tmp_int; + + {%- set i_output = -1 -%}{# note here i_output is 0-based #} + {%- if dims.nu > 0 and simulink_opts.outputs.u0 == 1 %} + {%- set i_output = i_output + 1 %} + out_u0 = ssGetOutputPortRealSignal(S, {{ i_output }}); + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "u", (void *) out_u0); + {%- endif %} + + {%- if simulink_opts.outputs.utraj == 1 %} + {%- set i_output = i_output + 1 %} + out_utraj = ssGetOutputPortRealSignal(S, {{ i_output }}); + for (int ii = 0; ii < {{ dims.N }}; ii++) + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, + "u", (void *) (out_utraj + ii * {{ dims.nu }})); + {%- endif %} + + {% if simulink_opts.outputs.xtraj == 1 %} + {%- set i_output = i_output + 1 %} + + out_xtraj = ssGetOutputPortRealSignal(S, {{ i_output }}); + for (int ii = 0; ii < {{ dims.N + 1 }}; ii++) + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, + "x", (void *) (out_xtraj + ii * {{ dims.nx }})); + {%- endif %} + + {%- if simulink_opts.outputs.solver_status == 1 %} + {%- set i_output = i_output + 1 %} + out_status = ssGetOutputPortRealSignal(S, {{ i_output }}); + *out_status = (real_t) acados_status; + {%- endif %} + + {%- if simulink_opts.outputs.KKT_residual == 1 %} + {%- set i_output = i_output + 1 %} + out_KKT_res = ssGetOutputPortRealSignal(S, {{ i_output }}); + *out_KKT_res = (real_t) nlp_out->inf_norm_res; + {%- endif %} + + {%- if dims.N > 0 and simulink_opts.outputs.x1 == 1 %} + {%- set i_output = i_output + 1 %} + out_x1 = ssGetOutputPortRealSignal(S, {{ i_output }}); + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 1, "x", (void *) out_x1); + {%- endif %} + + {%- if simulink_opts.outputs.CPU_time == 1 %} + {%- set i_output = i_output + 1 %} + out_cpu_time = ssGetOutputPortRealSignal(S, {{ i_output }}); + // get solution time + ocp_nlp_get(nlp_config, capsule->nlp_solver, "time_tot", (void *) out_cpu_time); + {%- endif -%} + + {%- if simulink_opts.outputs.CPU_time_sim == 1 %} + {%- set i_output = i_output + 1 %} + out_cpu_time_sim = ssGetOutputPortRealSignal(S, {{ i_output }}); + ocp_nlp_get(nlp_config, capsule->nlp_solver, "time_sim", (void *) out_cpu_time_sim); + {%- endif -%} + + {%- if simulink_opts.outputs.CPU_time_qp == 1 %} + {%- set i_output = i_output + 1 %} + out_cpu_time_qp = ssGetOutputPortRealSignal(S, {{ i_output }}); + ocp_nlp_get(nlp_config, capsule->nlp_solver, "time_qp", (void *) out_cpu_time_qp); + {%- endif -%} + + {%- if simulink_opts.outputs.CPU_time_lin == 1 %} + {%- set i_output = i_output + 1 %} + out_cpu_time_lin = ssGetOutputPortRealSignal(S, {{ i_output }}); + ocp_nlp_get(nlp_config, capsule->nlp_solver, "time_lin", (void *) out_cpu_time_lin); + {%- endif -%} + + {%- if simulink_opts.outputs.sqp_iter == 1 %} + {%- set i_output = i_output + 1 %} + out_sqp_iter = ssGetOutputPortRealSignal(S, {{ i_output }}); + // get sqp iter + ocp_nlp_get(nlp_config, capsule->nlp_solver, "sqp_iter", (void *) &tmp_int); + *out_sqp_iter = (real_t) tmp_int; + {%- endif %} + +} + +static void mdlTerminate(SimStruct *S) +{ + {{ model.name }}_solver_capsule *capsule = ssGetUserData(S); + + {{ model.name }}_acados_free(capsule); + {{ model.name }}_acados_free_capsule(capsule); +} + + +#ifdef MATLAB_MEX_FILE +#include "simulink.c" +#else +#include "cg_sfun.h" +#endif diff --git a/pyextra/acados_template/c_templates_tera/cost_y_0_fun.in.h b/pyextra/acados_template/c_templates_tera/cost_y_0_fun.in.h new file mode 100644 index 00000000000000..347446e3f4e895 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/cost_y_0_fun.in.h @@ -0,0 +1,69 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef {{ model.name }}_Y_0_COST +#define {{ model.name }}_Y_0_COST + +#ifdef __cplusplus +extern "C" { +#endif + +{% if cost.cost_type_0 == "NONLINEAR_LS" %} +int {{ model.name }}_cost_y_0_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_0_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_0_fun_sparsity_in(int); +const int *{{ model.name }}_cost_y_0_fun_sparsity_out(int); +int {{ model.name }}_cost_y_0_fun_n_in(void); +int {{ model.name }}_cost_y_0_fun_n_out(void); + +int {{ model.name }}_cost_y_0_fun_jac_ut_xt(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_0_fun_jac_ut_xt_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_0_fun_jac_ut_xt_sparsity_in(int); +const int *{{ model.name }}_cost_y_0_fun_jac_ut_xt_sparsity_out(int); +int {{ model.name }}_cost_y_0_fun_jac_ut_xt_n_in(void); +int {{ model.name }}_cost_y_0_fun_jac_ut_xt_n_out(void); + +int {{ model.name }}_cost_y_0_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_0_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_0_hess_sparsity_in(int); +const int *{{ model.name }}_cost_y_0_hess_sparsity_out(int); +int {{ model.name }}_cost_y_0_hess_n_in(void); +int {{ model.name }}_cost_y_0_hess_n_out(void); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_Y_0_COST diff --git a/pyextra/acados_template/c_templates_tera/cost_y_e_fun.in.h b/pyextra/acados_template/c_templates_tera/cost_y_e_fun.in.h new file mode 100644 index 00000000000000..acc99009fef648 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/cost_y_e_fun.in.h @@ -0,0 +1,69 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef {{ model.name }}_Y_E_COST +#define {{ model.name }}_Y_E_COST + +#ifdef __cplusplus +extern "C" { +#endif + +{% if cost.cost_type_e == "NONLINEAR_LS" %} +int {{ model.name }}_cost_y_e_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_e_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_e_fun_sparsity_in(int); +const int *{{ model.name }}_cost_y_e_fun_sparsity_out(int); +int {{ model.name }}_cost_y_e_fun_n_in(void); +int {{ model.name }}_cost_y_e_fun_n_out(void); + +int {{ model.name }}_cost_y_e_fun_jac_ut_xt(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_e_fun_jac_ut_xt_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_e_fun_jac_ut_xt_sparsity_in(int); +const int *{{ model.name }}_cost_y_e_fun_jac_ut_xt_sparsity_out(int); +int {{ model.name }}_cost_y_e_fun_jac_ut_xt_n_in(void); +int {{ model.name }}_cost_y_e_fun_jac_ut_xt_n_out(void); + +int {{ model.name }}_cost_y_e_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_e_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_e_hess_sparsity_in(int); +const int *{{ model.name }}_cost_y_e_hess_sparsity_out(int); +int {{ model.name }}_cost_y_e_hess_n_in(void); +int {{ model.name }}_cost_y_e_hess_n_out(void); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_Y_E_COST diff --git a/pyextra/acados_template/c_templates_tera/cost_y_fun.in.h b/pyextra/acados_template/c_templates_tera/cost_y_fun.in.h new file mode 100644 index 00000000000000..1e03780cc1b59b --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/cost_y_fun.in.h @@ -0,0 +1,69 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef {{ model.name }}_Y_COST +#define {{ model.name }}_Y_COST + +#ifdef __cplusplus +extern "C" { +#endif + +{% if cost.cost_type == "NONLINEAR_LS" %} +int {{ model.name }}_cost_y_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_fun_sparsity_in(int); +const int *{{ model.name }}_cost_y_fun_sparsity_out(int); +int {{ model.name }}_cost_y_fun_n_in(void); +int {{ model.name }}_cost_y_fun_n_out(void); + +int {{ model.name }}_cost_y_fun_jac_ut_xt(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_fun_jac_ut_xt_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_fun_jac_ut_xt_sparsity_in(int); +const int *{{ model.name }}_cost_y_fun_jac_ut_xt_sparsity_out(int); +int {{ model.name }}_cost_y_fun_jac_ut_xt_n_in(void); +int {{ model.name }}_cost_y_fun_jac_ut_xt_n_out(void); + +int {{ model.name }}_cost_y_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_y_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_y_hess_sparsity_in(int); +const int *{{ model.name }}_cost_y_hess_sparsity_out(int); +int {{ model.name }}_cost_y_hess_n_in(void); +int {{ model.name }}_cost_y_hess_n_out(void); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_Y_COST diff --git a/pyextra/acados_template/c_templates_tera/external_cost.in.h b/pyextra/acados_template/c_templates_tera/external_cost.in.h new file mode 100644 index 00000000000000..d200dba45e318c --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/external_cost.in.h @@ -0,0 +1,74 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef {{ model.name }}_EXT_COST +#define {{ model.name }}_EXT_COST + +#ifdef __cplusplus +extern "C" { +#endif + +{% if cost.cost_ext_fun_type == "casadi" %} +{% if cost.cost_type == "EXTERNAL" %} +int {{ model.name }}_cost_ext_cost_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_fun_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_fun_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_fun_n_in(void); +int {{ model.name }}_cost_ext_cost_fun_n_out(void); + +int {{ model.name }}_cost_ext_cost_fun_jac_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_fun_jac_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_fun_jac_hess_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_fun_jac_hess_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_fun_jac_hess_n_in(void); +int {{ model.name }}_cost_ext_cost_fun_jac_hess_n_out(void); + +int {{ model.name }}_cost_ext_cost_fun_jac(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_fun_jac_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_fun_jac_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_fun_jac_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_fun_jac_n_in(void); +int {{ model.name }}_cost_ext_cost_fun_jac_n_out(void); +{% endif %} + +{% else %} +int {{ cost.cost_function_ext_cost }}(void **, void **, void *); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_EXT_COST diff --git a/pyextra/acados_template/c_templates_tera/external_cost_0.in.h b/pyextra/acados_template/c_templates_tera/external_cost_0.in.h new file mode 100644 index 00000000000000..8152447e5f8abe --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/external_cost_0.in.h @@ -0,0 +1,75 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef {{ model.name }}_EXT_COST_0 +#define {{ model.name }}_EXT_COST_0 + +#ifdef __cplusplus +extern "C" { +#endif + +{% if cost.cost_ext_fun_type_0 == "casadi" %} + +{% if cost.cost_type_0 == "EXTERNAL" %} +int {{ model.name }}_cost_ext_cost_0_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_0_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_0_fun_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_0_fun_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_0_fun_n_in(void); +int {{ model.name }}_cost_ext_cost_0_fun_n_out(void); + +int {{ model.name }}_cost_ext_cost_0_fun_jac_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_0_fun_jac_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_0_fun_jac_hess_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_0_fun_jac_hess_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_0_fun_jac_hess_n_in(void); +int {{ model.name }}_cost_ext_cost_0_fun_jac_hess_n_out(void); + +int {{ model.name }}_cost_ext_cost_0_fun_jac(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_0_fun_jac_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_0_fun_jac_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_0_fun_jac_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_0_fun_jac_n_in(void); +int {{ model.name }}_cost_ext_cost_0_fun_jac_n_out(void); +{% endif %} + +{% else %} +int {{ cost.cost_function_ext_cost_0 }}(void **, void **, void *); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_EXT_COST_0 diff --git a/pyextra/acados_template/c_templates_tera/external_cost_e.in.h b/pyextra/acados_template/c_templates_tera/external_cost_e.in.h new file mode 100644 index 00000000000000..56485db4c73ed1 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/external_cost_e.in.h @@ -0,0 +1,74 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef {{ model.name }}_EXT_COST_E +#define {{ model.name }}_EXT_COST_E + +#ifdef __cplusplus +extern "C" { +#endif + +{% if cost.cost_ext_fun_type_e == "casadi" %} +{% if cost.cost_type_e == "EXTERNAL" %} +int {{ model.name }}_cost_ext_cost_e_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_e_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_e_fun_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_e_fun_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_e_fun_n_in(void); +int {{ model.name }}_cost_ext_cost_e_fun_n_out(void); + +int {{ model.name }}_cost_ext_cost_e_fun_jac_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_e_fun_jac_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_e_fun_jac_hess_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_e_fun_jac_hess_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_e_fun_jac_hess_n_in(void); +int {{ model.name }}_cost_ext_cost_e_fun_jac_hess_n_out(void); + +int {{ model.name }}_cost_ext_cost_e_fun_jac(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_cost_ext_cost_e_fun_jac_work(int *, int *, int *, int *); +const int *{{ model.name }}_cost_ext_cost_e_fun_jac_sparsity_in(int); +const int *{{ model.name }}_cost_ext_cost_e_fun_jac_sparsity_out(int); +int {{ model.name }}_cost_ext_cost_e_fun_jac_n_in(void); +int {{ model.name }}_cost_ext_cost_e_fun_jac_n_out(void); +{% endif %} + +{% else %} +int {{ cost.cost_function_ext_cost_e }}(void **, void **, void *); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_EXT_COST_E diff --git a/pyextra/acados_template/c_templates_tera/h_constraint.in.h b/pyextra/acados_template/c_templates_tera/h_constraint.in.h new file mode 100644 index 00000000000000..e49176c6efea1e --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/h_constraint.in.h @@ -0,0 +1,70 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#ifndef {{ model.name }}_H_CONSTRAINT +#define {{ model.name }}_H_CONSTRAINT + +#ifdef __cplusplus +extern "C" { +#endif + +{% if dims.nh > 0 %} +int {{ model.name }}_constr_h_fun_jac_uxt_zt(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_constr_h_fun_jac_uxt_zt_work(int *, int *, int *, int *); +const int *{{ model.name }}_constr_h_fun_jac_uxt_zt_sparsity_in(int); +const int *{{ model.name }}_constr_h_fun_jac_uxt_zt_sparsity_out(int); +int {{ model.name }}_constr_h_fun_jac_uxt_zt_n_in(void); +int {{ model.name }}_constr_h_fun_jac_uxt_zt_n_out(void); + +int {{ model.name }}_constr_h_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_constr_h_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_constr_h_fun_sparsity_in(int); +const int *{{ model.name }}_constr_h_fun_sparsity_out(int); +int {{ model.name }}_constr_h_fun_n_in(void); +int {{ model.name }}_constr_h_fun_n_out(void); + +{% if solver_options.hessian_approx == "EXACT" -%} +int {{ model.name }}_constr_h_fun_jac_uxt_zt_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_constr_h_fun_jac_uxt_zt_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_constr_h_fun_jac_uxt_zt_hess_sparsity_in(int); +const int *{{ model.name }}_constr_h_fun_jac_uxt_zt_hess_sparsity_out(int); +int {{ model.name }}_constr_h_fun_jac_uxt_zt_hess_n_in(void); +int {{ model.name }}_constr_h_fun_jac_uxt_zt_hess_n_out(void); +{% endif %} +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_H_CONSTRAINT diff --git a/pyextra/acados_template/c_templates_tera/h_e_constraint.in.h b/pyextra/acados_template/c_templates_tera/h_e_constraint.in.h new file mode 100644 index 00000000000000..a5dd7116415252 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/h_e_constraint.in.h @@ -0,0 +1,71 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef {{ model.name }}_H_E_CONSTRAINT +#define {{ model.name }}_H_E_CONSTRAINT + +#ifdef __cplusplus +extern "C" { +#endif + +{% if dims.nh_e > 0 %} +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt_work(int *, int *, int *, int *); +const int *{{ model.name }}_constr_h_e_fun_jac_uxt_zt_sparsity_in(int); +const int *{{ model.name }}_constr_h_e_fun_jac_uxt_zt_sparsity_out(int); +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt_n_in(void); +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt_n_out(void); + +int {{ model.name }}_constr_h_e_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_constr_h_e_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_constr_h_e_fun_sparsity_in(int); +const int *{{ model.name }}_constr_h_e_fun_sparsity_out(int); +int {{ model.name }}_constr_h_e_fun_n_in(void); +int {{ model.name }}_constr_h_e_fun_n_out(void); + +{% if solver_options.hessian_approx == "EXACT" -%} +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_sparsity_in(int); +const int *{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_sparsity_out(int); +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_n_in(void); +int {{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess_n_out(void); +{% endif %} +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_H_E_CONSTRAINT diff --git a/pyextra/acados_template/c_templates_tera/main.in.c b/pyextra/acados_template/c_templates_tera/main.in.c new file mode 100644 index 00000000000000..3348eea5cb644e --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/main.in.c @@ -0,0 +1,215 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +// standard +#include +#include +// acados +#include "acados/utils/print.h" +#include "acados/utils/math.h" +#include "acados_c/ocp_nlp_interface.h" +#include "acados_c/external_function_interface.h" +#include "acados_solver_{{ model.name }}.h" + +#define NX {{ model.name | upper }}_NX +#define NZ {{ model.name | upper }}_NZ +#define NU {{ model.name | upper }}_NU +#define NP {{ model.name | upper }}_NP +#define NBX {{ model.name | upper }}_NBX +#define NBX0 {{ model.name | upper }}_NBX0 +#define NBU {{ model.name | upper }}_NBU +#define NSBX {{ model.name | upper }}_NSBX +#define NSBU {{ model.name | upper }}_NSBU +#define NSH {{ model.name | upper }}_NSH +#define NSG {{ model.name | upper }}_NSG +#define NSPHI {{ model.name | upper }}_NSPHI +#define NSHN {{ model.name | upper }}_NSHN +#define NSGN {{ model.name | upper }}_NSGN +#define NSPHIN {{ model.name | upper }}_NSPHIN +#define NSBXN {{ model.name | upper }}_NSBXN +#define NS {{ model.name | upper }}_NS +#define NSN {{ model.name | upper }}_NSN +#define NG {{ model.name | upper }}_NG +#define NBXN {{ model.name | upper }}_NBXN +#define NGN {{ model.name | upper }}_NGN +#define NY0 {{ model.name | upper }}_NY0 +#define NY {{ model.name | upper }}_NY +#define NYN {{ model.name | upper }}_NYN +#define NH {{ model.name | upper }}_NH +#define NPHI {{ model.name | upper }}_NPHI +#define NHN {{ model.name | upper }}_NHN +#define NPHIN {{ model.name | upper }}_NPHIN +#define NR {{ model.name | upper }}_NR + + +int main() +{ + + {{ model.name }}_solver_capsule *acados_ocp_capsule = {{ model.name }}_acados_create_capsule(); + // there is an opportunity to change the number of shooting intervals in C without new code generation + int N = {{ model.name | upper }}_N; + // allocate the array and fill it accordingly + double* new_time_steps = NULL; + int status = {{ model.name }}_acados_create_with_discretization(acados_ocp_capsule, N, new_time_steps); + + if (status) + { + printf("{{ model.name }}_acados_create() returned status %d. Exiting.\n", status); + exit(1); + } + + ocp_nlp_config *nlp_config = {{ model.name }}_acados_get_nlp_config(acados_ocp_capsule); + ocp_nlp_dims *nlp_dims = {{ model.name }}_acados_get_nlp_dims(acados_ocp_capsule); + ocp_nlp_in *nlp_in = {{ model.name }}_acados_get_nlp_in(acados_ocp_capsule); + ocp_nlp_out *nlp_out = {{ model.name }}_acados_get_nlp_out(acados_ocp_capsule); + ocp_nlp_solver *nlp_solver = {{ model.name }}_acados_get_nlp_solver(acados_ocp_capsule); + void *nlp_opts = {{ model.name }}_acados_get_nlp_opts(acados_ocp_capsule); + + // initial condition + int idxbx0[NBX0]; + {%- for i in range(end=dims.nbx_0) %} + idxbx0[{{ i }}] = {{ constraints.idxbx_0[i] }}; + {%- endfor %} + + double lbx0[NBX0]; + double ubx0[NBX0]; + {%- for i in range(end=dims.nbx_0) %} + lbx0[{{ i }}] = {{ constraints.lbx_0[i] }}; + ubx0[{{ i }}] = {{ constraints.ubx_0[i] }}; + {%- endfor %} + + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "idxbx", idxbx0); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "lbx", lbx0); + ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "ubx", ubx0); + + // initialization for state values + double x_init[NX]; + {%- for i in range(end=dims.nx) %} + x_init[{{ i }}] = 0.0; + {%- endfor %} + + // initial value for control input + double u0[NU]; + {%- for i in range(end=dims.nu) %} + u0[{{ i }}] = 0.0; + {%- endfor %} + + + {%- if dims.np > 0 %} + // set parameters + double p[NP]; + {%- for item in parameter_values %} + p[{{ loop.index0 }}] = {{ item }}; + {%- endfor %} + + for (int ii = 0; ii <= N; ii++) + { + {{ model.name }}_acados_update_params(acados_ocp_capsule, ii, p, NP); + } + {% endif %}{# if np > 0 #} + + // prepare evaluation + int NTIMINGS = 1; + double min_time = 1e12; + double kkt_norm_inf; + double elapsed_time; + int sqp_iter; + + double xtraj[NX * (N+1)]; + double utraj[NU * N]; + + + // solve ocp in loop + int rti_phase = 0; + + for (int ii = 0; ii < NTIMINGS; ii++) + { + // initialize solution + for (int i = 0; i <= nlp_dims->N; i++) + { + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "x", x_init); + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "u", u0); + } + ocp_nlp_solver_opts_set(nlp_config, nlp_opts, "rti_phase", &rti_phase); + status = {{ model.name }}_acados_solve(acados_ocp_capsule); + ocp_nlp_get(nlp_config, nlp_solver, "time_tot", &elapsed_time); + min_time = MIN(elapsed_time, min_time); + } + + /* print solution and statistics */ + for (int ii = 0; ii <= nlp_dims->N; ii++) + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, "x", &xtraj[ii*NX]); + for (int ii = 0; ii < nlp_dims->N; ii++) + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, "u", &utraj[ii*NU]); + + printf("\n--- xtraj ---\n"); + d_print_exp_tran_mat( NX, N+1, xtraj, NX); + printf("\n--- utraj ---\n"); + d_print_exp_tran_mat( NU, N, utraj, NU ); + // ocp_nlp_out_print(nlp_solver->dims, nlp_out); + + printf("\nsolved ocp %d times, solution printed above\n\n", NTIMINGS); + + if (status == ACADOS_SUCCESS) + { + printf("{{ model.name }}_acados_solve(): SUCCESS!\n"); + } + else + { + printf("{{ model.name }}_acados_solve() failed with status %d.\n", status); + } + + // get solution + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "kkt_norm_inf", &kkt_norm_inf); + ocp_nlp_get(nlp_config, nlp_solver, "sqp_iter", &sqp_iter); + + {{ model.name }}_acados_print_stats(acados_ocp_capsule); + + printf("\nSolver info:\n"); + printf(" SQP iterations %2d\n minimum time for %d solve %f [ms]\n KKT %e\n", + sqp_iter, NTIMINGS, min_time*1000, kkt_norm_inf); + + // free solver + status = {{ model.name }}_acados_free(acados_ocp_capsule); + if (status) { + printf("{{ model.name }}_acados_free() returned status %d. \n", status); + } + // free solver capsule + status = {{ model.name }}_acados_free_capsule(acados_ocp_capsule); + if (status) { + printf("{{ model.name }}_acados_free_capsule() returned status %d. \n", status); + } + + return status; +} diff --git a/pyextra/acados_template/c_templates_tera/main_mex.in.c b/pyextra/acados_template/c_templates_tera/main_mex.in.c new file mode 100644 index 00000000000000..8da5db29a0aaa7 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/main_mex.in.c @@ -0,0 +1,184 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +// standard +#include +#include +// acados +#include "acados/utils/print.h" +#include "acados/utils/math.h" +#include "acados_c/ocp_nlp_interface.h" +#include "acados_solver_{{ model.name }}.h" +// mex +#include "mex.h" + +/* auxilary mex */ +// prints a matrix in column-major format (exponential notation) +void MEX_print_exp_mat(int m, int n, double *A, int lda) +{ + for (int i=0; iN; i++) + { + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "x", x_init); + ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "u", u0); + } + status = {{ model.name }}_acados_solve(); + ocp_nlp_get(nlp_config, nlp_solver, "time_tot", &elapsed_time); + min_time = MIN(elapsed_time, min_time); + } + + /* print solution and statistics */ + for (int ii = 0; ii <= nlp_dims->N; ii++) + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, "x", &xtraj[ii*{{ dims.nx }}]); + for (int ii = 0; ii < nlp_dims->N; ii++) + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, "u", &utraj[ii*{{ dims.nu }}]); + + mexPrintf("\n--- xtraj ---\n"); + MEX_print_exp_tran_mat( {{ dims.nx }}, {{ dims.N }}+1, xtraj, {{ dims.nx }} ); + mexPrintf("\n--- utraj ---\n"); + MEX_print_exp_tran_mat( {{ dims.nu }}, {{ dims.N }}, utraj, {{ dims.nu }} ); + + mexPrintf("\nsolved ocp %d times, solution printed above\n\n", NTIMINGS); + + if (status == ACADOS_SUCCESS) + mexPrintf("{{ model.name }}_acados_solve(): SUCCESS!\n"); + else + mexPrintf("{{ model.name }}_acados_solve() failed with status %d.\n", status); + + // get solution + ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "kkt_norm_inf", &kkt_norm_inf); + ocp_nlp_get(nlp_config, nlp_solver, "sqp_iter", &sqp_iter); + + mexPrintf("\nSolver info:\n"); + mexPrintf(" SQP iterations %2d\n minimum time for 1 solve %f [ms]\n KKT %e\n", + sqp_iter, min_time*1000, kkt_norm_inf); + + // free solver + status = {{ model.name }}_acados_free(); + if (status) + { + mexPrintf("{{ model.name }}_acados_free() returned status %d.\n", status); + } + + return; +} diff --git a/pyextra/acados_template/c_templates_tera/main_sim.in.c b/pyextra/acados_template/c_templates_tera/main_sim.in.c new file mode 100644 index 00000000000000..743e81d593d798 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/main_sim.in.c @@ -0,0 +1,135 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +// standard +#include +#include +// acados +#include "acados/utils/print.h" +#include "acados/utils/math.h" +#include "acados_c/sim_interface.h" +#include "acados_sim_solver_{{ model.name }}.h" + +#define NX {{ model.name | upper }}_NX +#define NZ {{ model.name | upper }}_NZ +#define NU {{ model.name | upper }}_NU +#define NP {{ model.name | upper }}_NP + + +int main() +{ + int status = 0; + sim_solver_capsule *capsule = {{ model.name }}_acados_sim_solver_create_capsule(); + status = {{ model.name }}_acados_sim_create(capsule); + + if (status) + { + printf("acados_create() returned status %d. Exiting.\n", status); + exit(1); + } + + sim_config *acados_sim_config = {{ model.name }}_acados_get_sim_config(capsule); + sim_in *acados_sim_in = {{ model.name }}_acados_get_sim_in(capsule); + sim_out *acados_sim_out = {{ model.name }}_acados_get_sim_out(capsule); + void *acados_sim_dims = {{ model.name }}_acados_get_sim_dims(capsule); + + // initial condition + double x_current[NX]; + {%- for i in range(end=dims.nx) %} + x_current[{{ i }}] = 0.0; + {%- endfor %} + + {% if constraints.lbx_0 %} + {%- for i in range(end=dims.nbx_0) %} + x_current[{{ constraints.idxbx_0[i] }}] = {{ constraints.lbx_0[i] }}; + {%- endfor %} + {% if dims.nbx_0 != dims.nx %} + printf("main_sim: NOTE: initial state not fully defined via lbx_0, using 0.0 for indices that are not in idxbx_0."); + {%- endif %} + {% else %} + printf("main_sim: initial state not defined, should be in lbx_0, using zero vector."); + {%- endif %} + + + // initial value for control input + double u0[NU]; + {%- for i in range(end=dims.nu) %} + u0[{{ i }}] = 0.0; + {%- endfor %} + + {%- if dims.np > 0 %} + // set parameters + double p[NP]; + {%- for item in parameter_values %} + p[{{ loop.index0 }}] = {{ item }}; + {%- endfor %} + + {{ model.name }}_acados_sim_update_params(capsule, p, NP); + {% endif %}{# if np > 0 #} + + int n_sim_steps = 3; + // solve ocp in loop + for (int ii = 0; ii < n_sim_steps; ii++) + { + sim_in_set(acados_sim_config, acados_sim_dims, + acados_sim_in, "x", x_current); + status = {{ model.name }}_acados_sim_solve(capsule); + + if (status != ACADOS_SUCCESS) + { + printf("acados_solve() failed with status %d.\n", status); + } + + sim_out_get(acados_sim_config, acados_sim_dims, + acados_sim_out, "x", x_current); + + printf("\nx_current, %d\n", ii); + for (int jj = 0; jj < NX; jj++) + { + printf("%e\n", x_current[jj]); + } + } + + printf("\nPerformed %d simulation steps with acados integrator successfully.\n\n", n_sim_steps); + + // free solver + status = {{ model.name }}_acados_sim_free(capsule); + if (status) { + printf("{{ model.name }}_acados_sim_free() returned status %d. \n", status); + } + + {{ model.name }}_acados_sim_solver_free_capsule(capsule); + + return status; +} diff --git a/pyextra/acados_template/c_templates_tera/make_main_mex.in.m b/pyextra/acados_template/c_templates_tera/make_main_mex.in.m new file mode 100644 index 00000000000000..9188686a0d4763 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/make_main_mex.in.m @@ -0,0 +1,105 @@ +% +% Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +% Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +% Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +% Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +% +% This file is part of acados. +% +% The 2-Clause BSD License +% +% 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. +% +% 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.; +% + +function make_main_mex_{{ model.name }}() + + opts.output_dir = pwd; + + % get acados folder + acados_folder = getenv('ACADOS_INSTALL_DIR'); + + % set paths + acados_include = ['-I' fullfile(acados_folder, 'include')]; + template_lib_include = ['-l' 'acados_solver_{{ model.name }}']; + template_lib_path = ['-L' fullfile(pwd)]; + + acados_lib_path = ['-L' fullfile(acados_folder, 'lib')]; + external_include = ['-I', fullfile(acados_folder, 'external')]; + blasfeo_include = ['-I', fullfile(acados_folder, 'external', 'blasfeo', 'include')]; + hpipm_include = ['-I', fullfile(acados_folder, 'external', 'hpipm', 'include')]; + + mex_names = { ... + 'main_mex_{{ model.name }}' ... + }; + + mex_files = cell(length(mex_names), 1); + for k=1:length(mex_names) + mex_files{k} = fullfile([mex_names{k}, '.c']); + end + + %% octave C flags + if is_octave() + if ~exist(fullfile(opts.output_dir, 'cflags_octave.txt'), 'file') + diary(fullfile(opts.output_dir, 'cflags_octave.txt')); + diary on + mkoctfile -p CFLAGS + diary off + input_file = fopen(fullfile(opts.output_dir, 'cflags_octave.txt'), 'r'); + cflags_tmp = fscanf(input_file, '%[^\n]s'); + fclose(input_file); + if ~ismac() + cflags_tmp = [cflags_tmp, ' -std=c99 -fopenmp']; + else + cflags_tmp = [cflags_tmp, ' -std=c99']; + end + input_file = fopen(fullfile(opts.output_dir, 'cflags_octave.txt'), 'w'); + fprintf(input_file, '%s', cflags_tmp); + fclose(input_file); + end + % read cflags from file + input_file = fopen(fullfile(opts.output_dir, 'cflags_octave.txt'), 'r'); + cflags_tmp = fscanf(input_file, '%[^\n]s'); + fclose(input_file); + setenv('CFLAGS', cflags_tmp); + end + + %% compile mex + for ii=1:length(mex_files) + disp(['compiling ', mex_files{ii}]) + if is_octave() + % mkoctfile -p CFLAGS + mex(acados_include, template_lib_include, external_include, blasfeo_include, hpipm_include,... + acados_lib_path, template_lib_path, '-lacados', '-lhpipm', '-lblasfeo', mex_files{ii}) + else + if ismac() + FLAGS = 'CFLAGS=$CFLAGS -std=c99'; + else + FLAGS = 'CFLAGS=$CFLAGS -std=c99 -fopenmp'; + end + mex(FLAGS, acados_include, template_lib_include, external_include, blasfeo_include, hpipm_include,... + acados_lib_path, template_lib_path, '-lacados', '-lhpipm', '-lblasfeo', mex_files{ii}) + end + end + + +end \ No newline at end of file diff --git a/pyextra/acados_template/c_templates_tera/make_mex.in.m b/pyextra/acados_template/c_templates_tera/make_mex.in.m new file mode 100644 index 00000000000000..cde30f6f413c63 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/make_mex.in.m @@ -0,0 +1,110 @@ +% +% Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +% Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +% Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +% Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +% +% This file is part of acados. +% +% The 2-Clause BSD License +% +% 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. +% +% 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.; +% + +function make_mex_{{ model.name }}() + + opts.output_dir = pwd; + + % get acados folder + acados_folder = getenv('ACADOS_INSTALL_DIR'); + + % set paths + acados_include = ['-I' fullfile(acados_folder, 'include')]; + template_lib_include = ['-l' 'acados_ocp_solver_{{ model.name }}']; + template_lib_path = ['-L' fullfile(pwd)]; + + acados_lib_path = ['-L' fullfile(acados_folder, 'lib')]; + external_include = ['-I', fullfile(acados_folder, 'external')]; + blasfeo_include = ['-I', fullfile(acados_folder, 'external', 'blasfeo', 'include')]; + hpipm_include = ['-I', fullfile(acados_folder, 'external', 'hpipm', 'include')]; + + mex_include = ['-I', fullfile(acados_folder, 'interfaces', 'acados_matlab_octave')]; + + mex_names = { ... + 'acados_mex_create_{{ model.name }}' ... + 'acados_mex_free_{{ model.name }}' ... + 'acados_mex_solve_{{ model.name }}' ... + 'acados_mex_set_{{ model.name }}' ... + }; + + mex_files = cell(length(mex_names), 1); + for k=1:length(mex_names) + mex_files{k} = fullfile([mex_names{k}, '.c']); + end + + %% octave C flags + if is_octave() + if ~exist(fullfile(opts.output_dir, 'cflags_octave.txt'), 'file') + diary(fullfile(opts.output_dir, 'cflags_octave.txt')); + diary on + mkoctfile -p CFLAGS + diary off + input_file = fopen(fullfile(opts.output_dir, 'cflags_octave.txt'), 'r'); + cflags_tmp = fscanf(input_file, '%[^\n]s'); + fclose(input_file); + if ~ismac() + cflags_tmp = [cflags_tmp, ' -std=c99 -fopenmp']; + else + cflags_tmp = [cflags_tmp, ' -std=c99']; + end + input_file = fopen(fullfile(opts.output_dir, 'cflags_octave.txt'), 'w'); + fprintf(input_file, '%s', cflags_tmp); + fclose(input_file); + end + % read cflags from file + input_file = fopen(fullfile(opts.output_dir, 'cflags_octave.txt'), 'r'); + cflags_tmp = fscanf(input_file, '%[^\n]s'); + fclose(input_file); + setenv('CFLAGS', cflags_tmp); + end + + %% compile mex + for ii=1:length(mex_files) + disp(['compiling ', mex_files{ii}]) + if is_octave() + % mkoctfile -p CFLAGS + mex(acados_include, template_lib_include, external_include, blasfeo_include, hpipm_include,... + acados_lib_path, template_lib_path, mex_include, '-lacados', '-lhpipm', '-lblasfeo', mex_files{ii}) + else + if ismac() + FLAGS = 'CFLAGS=$CFLAGS -std=c99'; + else + FLAGS = 'CFLAGS=$CFLAGS -std=c99 -fopenmp'; + end + mex(FLAGS, acados_include, template_lib_include, external_include, blasfeo_include, hpipm_include,... + acados_lib_path, template_lib_path, mex_include, '-lacados', '-lhpipm', '-lblasfeo', mex_files{ii}) + end + end + + +end \ No newline at end of file diff --git a/pyextra/acados_template/c_templates_tera/make_sfun.in.m b/pyextra/acados_template/c_templates_tera/make_sfun.in.m new file mode 100644 index 00000000000000..172da654ee13c0 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/make_sfun.in.m @@ -0,0 +1,335 @@ +% +% Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +% Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +% Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +% Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +% +% This file is part of acados. +% +% The 2-Clause BSD License +% +% 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. +% +% 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.; +% + +SOURCES = { ... + {%- if solver_options.integrator_type == 'ERK' %} + '{{ model.name }}_model/{{ model.name }}_expl_ode_fun.c', ... + '{{ model.name }}_model/{{ model.name }}_expl_vde_forw.c',... + {%- if solver_options.hessian_approx == 'EXACT' %} + '{{ model.name }}_model/{{ model.name }}_expl_ode_hess.c',... + {%- endif %} + {%- elif solver_options.integrator_type == "IRK" %} + '{{ model.name }}_model/{{ model.name }}_impl_dae_fun.c', ... + '{{ model.name }}_model/{{ model.name }}_impl_dae_fun_jac_x_xdot_z.c', ... + '{{ model.name }}_model/{{ model.name }}_impl_dae_jac_x_xdot_u_z.c', ... + {%- if solver_options.hessian_approx == 'EXACT' %} + '{{ model.name }}_model/{{ model.name }}_impl_dae_hess.c',... + {%- endif %} + {%- elif solver_options.integrator_type == "GNSF" %} + '{{ model.name }}_model/{{ model.name }}_gnsf_phi_fun.c',... + '{{ model.name }}_model/{{ model.name }}_gnsf_phi_fun_jac_y.c',... + '{{ model.name }}_model/{{ model.name }}_gnsf_phi_jac_y_uhat.c',... + '{{ model.name }}_model/{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz.c',... + '{{ model.name }}_model/{{ model.name }}_gnsf_get_matrices_fun.c',... + {%- elif solver_options.integrator_type == "DISCRETE" %} + '{{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun.c',... + '{{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun_jac.c',... + {%- if solver_options.hessian_approx == "EXACT" %} + '{{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun_jac_hess.c',... + {%- endif %} + {%- endif %} + {%- if cost.cost_type_0 == "NONLINEAR_LS" %} + '{{ model.name }}_cost/{{ model.name }}_cost_y_0_fun.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_y_0_fun_jac_ut_xt.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_y_0_hess.c',... + {%- elif cost.cost_type_0 == "EXTERNAL" %} + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun_jac.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun_jac_hess.c',... + {%- endif %} + + {%- if cost.cost_type == "NONLINEAR_LS" %} + '{{ model.name }}_cost/{{ model.name }}_cost_y_fun.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_y_fun_jac_ut_xt.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_y_hess.c',... + {%- elif cost.cost_type == "EXTERNAL" %} + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun_jac.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun_jac_hess.c',... + {%- endif %} + {%- if cost.cost_type_e == "NONLINEAR_LS" %} + '{{ model.name }}_cost/{{ model.name }}_cost_y_e_fun.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_y_e_fun_jac_ut_xt.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_y_e_hess.c',... + {%- elif cost.cost_type_e == "EXTERNAL" %} + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun_jac.c',... + '{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun_jac_hess.c',... + {%- endif %} + {%- if constraints.constr_type == "BGH" and dims.nh > 0 %} + '{{ model.name }}_constraints/{{ model.name }}_constr_h_fun.c', ... + '{{ model.name }}_constraints/{{ model.name }}_constr_h_fun_jac_uxt_zt_hess.c', ... + '{{ model.name }}_constraints/{{ model.name }}_constr_h_fun_jac_uxt_zt.c', ... + {%- elif constraints.constr_type == "BGP" and dims.nphi > 0 %} + '{{ model.name }}_constraints/{{ model.name }}_phi_constraint.c', ... + {%- endif %} + {%- if constraints.constr_type_e == "BGH" and dims.nh_e > 0 %} + '{{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun.c', ... + '{{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess.c', ... + '{{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun_jac_uxt_zt.c', ... + {%- elif constraints.constr_type_e == "BGP" and dims.nphi_e > 0 %} + '{{ model.name }}_constraints/{{ model.name }}_phi_e_constraint.c', ... + {%- endif %} + 'acados_solver_sfunction_{{ model.name }}.c', ... + 'acados_solver_{{ model.name }}.c' + }; + +INC_PATH = '{{ acados_include_path }}'; + +INCS = {['-I', fullfile(INC_PATH, 'blasfeo', 'include')], ... + ['-I', fullfile(INC_PATH, 'hpipm', 'include')], ... + ['-I', fullfile(INC_PATH, 'acados')], ... + ['-I', fullfile(INC_PATH)]}; + +{% if solver_options.qp_solver is containing("QPOASES") %} +INCS{end+1} = ['-I', fullfile(INC_PATH, 'qpOASES_e')]; +{% endif %} + +CFLAGS = 'CFLAGS=$CFLAGS'; +LDFLAGS = 'LDFLAGS=$LDFLAGS'; +COMPFLAGS = 'COMPFLAGS=$COMPFLAGS'; +COMPDEFINES = 'COMPDEFINES=$COMPDEFINES'; + +{% if solver_options.qp_solver is containing("QPOASES") %} +CFLAGS = [ CFLAGS, ' -DACADOS_WITH_QPOASES ' ]; +COMPDEFINES = [ COMPDEFINES, ' -DACADOS_WITH_QPOASES ' ]; +{%- elif solver_options.qp_solver is containing("OSQP") %} +CFLAGS = [ CFLAGS, ' -DACADOS_WITH_OSQP ' ]; +COMPDEFINES = [ COMPDEFINES, ' -DACADOS_WITH_OSQP ' ]; +{%- elif solver_options.qp_solver is containing("QPDUNES") %} +CFLAGS = [ CFLAGS, ' -DACADOS_WITH_QPDUNES ' ]; +COMPDEFINES = [ COMPDEFINES, ' -DACADOS_WITH_QPDUNES ' ]; +{%- elif solver_options.qp_solver is containing("HPMPC") %} +CFLAGS = [ CFLAGS, ' -DACADOS_WITH_HPMPC ' ]; +COMPDEFINES = [ COMPDEFINES, ' -DACADOS_WITH_HPMPC ' ]; +{% endif %} + +LIB_PATH = ['-L', fullfile('{{ acados_lib_path }}')]; + +LIBS = {'-lacados', '-lhpipm', '-lblasfeo'}; + +% acados linking libraries and flags +{%- if acados_link_libs and os and os == "pc" %} +LDFLAGS = [LDFLAGS ' {{ acados_link_libs.openmp }}']; +COMPFLAGS = [COMPFLAGS ' {{ acados_link_libs.openmp }}']; +LIBS{end+1} = '{{ acados_link_libs.qpoases }}'; +LIBS{end+1} = '{{ acados_link_libs.hpmpc }}'; +LIBS{end+1} = '{{ acados_link_libs.osqp }}'; +{%- else %} + {% if solver_options.qp_solver is containing("QPOASES") %} +LIBS{end+1} = '-lqpOASES_e'; + {% endif %} +{%- endif %} + +mex('-v', '-O', CFLAGS, LDFLAGS, COMPFLAGS, COMPDEFINES, INCS{:}, ... + LIB_PATH, LIBS{:}, SOURCES{:}, ... + '-output', 'acados_solver_sfunction_{{ model.name }}' ); + +fprintf( [ '\n\nSuccessfully created sfunction:\nacados_solver_sfunction_{{ model.name }}', '.', ... + eval('mexext')] ); + + +%% print note on usage of s-function +fprintf('\n\nNote: Usage of Sfunction is as follows:\n') +input_note = 'Inputs are:\n'; +i_in = 1; + + +{%- if dims.nbx_0 > 0 and simulink_opts.inputs.lbx_0 -%} {#- lbx_0 #} +input_note = strcat(input_note, num2str(i_in), ') lbx_0 - lower bound on x for stage 0,',... + ' size [{{ dims.nbx_0 }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.nbx_0 > 0 and simulink_opts.inputs.ubx_0 -%} {#- ubx_0 #} +input_note = strcat(input_note, num2str(i_in), ') ubx_0 - upper bound on x for stage 0,',... + ' size [{{ dims.nbx_0 }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.np > 0 and simulink_opts.inputs.parameter_traj -%} {#- parameter_traj #} +input_note = strcat(input_note, num2str(i_in), ') parameters - concatenated for all shooting nodes 0 to N+1,',... + ' size [{{ (dims.N+1)*dims.np }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.ny_0 > 0 and simulink_opts.inputs.y_ref_0 %} +input_note = strcat(input_note, num2str(i_in), ') y_ref_0, size [{{ dims.ny_0 }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.ny > 0 and dims.N > 1 and simulink_opts.inputs.y_ref %} +input_note = strcat(input_note, num2str(i_in), ') y_ref - concatenated for shooting nodes 1 to N-1,',... + ' size [{{ (dims.N-1) * dims.ny }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.ny_e > 0 and dims.N > 0 and simulink_opts.inputs.y_ref_e %} +input_note = strcat(input_note, num2str(i_in), ') y_ref_e, size [{{ dims.ny_e }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.lbx -%} {#- lbx #} +input_note = strcat(input_note, num2str(i_in), ') lbx for shooting nodes 1 to N-1, size [{{ (dims.N-1) * dims.nbx }}]\n '); +i_in = i_in + 1; +{%- endif %} +{%- if dims.nbx > 0 and dims.N > 1 and simulink_opts.inputs.ubx -%} {#- ubx #} +input_note = strcat(input_note, num2str(i_in), ') ubx for shooting nodes 1 to N-1, size [{{ (dims.N-1) * dims.nbx }}]\n '); +i_in = i_in + 1; +{%- endif %} + + +{%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.lbx_e -%} {#- lbx_e #} +input_note = strcat(input_note, num2str(i_in), ') lbx_e (lbx at shooting node N), size [{{ dims.nbx_e }}]\n '); +i_in = i_in + 1; +{%- endif %} +{%- if dims.nbx_e > 0 and dims.N > 0 and simulink_opts.inputs.ubx_e -%} {#- ubx_e #} +input_note = strcat(input_note, num2str(i_in), ') ubx_e (ubx at shooting node N), size [{{ dims.nbx_e }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.lbu -%} {#- lbu #} +input_note = strcat(input_note, num2str(i_in), ') lbu for shooting nodes 0 to N-1, size [{{ dims.N*dims.nbu }}]\n '); +i_in = i_in + 1; +{%- endif -%} +{%- if dims.nbu > 0 and dims.N > 0 and simulink_opts.inputs.ubu -%} {#- ubu #} +input_note = strcat(input_note, num2str(i_in), ') ubu for shooting nodes 0 to N-1, size [{{ dims.N*dims.nbu }}]\n '); +i_in = i_in + 1; +{%- endif -%} + +{%- if dims.ng > 0 and simulink_opts.inputs.lg -%} {#- lg #} +input_note = strcat(input_note, num2str(i_in), ') lg, size [{{ dims.ng }}]\n '); +i_in = i_in + 1; +{%- endif %} +{%- if dims.ng > 0 and simulink_opts.inputs.ug -%} {#- ug #} +input_note = strcat(input_note, num2str(i_in), ') ug, size [{{ dims.ng }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.nh > 0 and simulink_opts.inputs.lh -%} {#- lh #} +input_note = strcat(input_note, num2str(i_in), ') lh, size [{{ dims.nh }}]\n '); +i_in = i_in + 1; +{%- endif %} +{%- if dims.nh > 0 and simulink_opts.inputs.uh -%} {#- uh #} +input_note = strcat(input_note, num2str(i_in), ') uh, size [{{ dims.nh }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.ny_0 > 0 and simulink_opts.inputs.cost_W_0 %} {#- cost_W_0 #} +input_note = strcat(input_note, num2str(i_in), ') cost_W_0 in column-major format, size [{{ dims.ny_0 * dims.ny_0 }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.ny > 0 and simulink_opts.inputs.cost_W %} {#- cost_W #} +input_note = strcat(input_note, num2str(i_in), ') cost_W in column-major format, that is set for all intermediate shooting nodes: 1 to N-1, size [{{ dims.ny * dims.ny }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.ny_e > 0 and simulink_opts.inputs.cost_W_e %} {#- cost_W_e #} +input_note = strcat(input_note, num2str(i_in), ') cost_W_e in column-major format, size [{{ dims.ny_e * dims.ny_e }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if simulink_opts.inputs.x_init %} {#- x_init #} +input_note = strcat(input_note, num2str(i_in), ') initialization of x for all shooting nodes, size [{{ dims.nx * (dims.N+1) }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if simulink_opts.inputs.u_init %} {#- u_init #} +input_note = strcat(input_note, num2str(i_in), ') initialization of u for shooting nodes 0 to N-1, size [{{ dims.nu * (dims.N) }}]\n '); +i_in = i_in + 1; +{%- endif %} + +fprintf(input_note) + +disp(' ') + +output_note = 'Outputs are:\n'; +i_out = 0; + +{%- if dims.nu > 0 and simulink_opts.outputs.u0 == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') u0, control input at node 0, size [{{ dims.nu }}]\n '); +{%- endif %} + +{%- if simulink_opts.outputs.utraj == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') utraj, control input concatenated for nodes 0 to N-1, size [{{ dims.nu * dims.N }}]\n '); +{%- endif %} + +{%- if simulink_opts.outputs.xtraj == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') xtraj, state concatenated for nodes 0 to N, size [{{ dims.nx * (dims.N + 1) }}]\n '); +{%- endif %} + +{%- if simulink_opts.outputs.solver_status == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') acados solver status (0 = SUCCESS)\n '); +{%- endif %} + +{%- if simulink_opts.outputs.KKT_residual == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') KKT residual\n '); +{%- endif %} + +{%- if dims.N > 0 and simulink_opts.outputs.x1 == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') x1, state at node 1\n '); +{%- endif %} + +{%- if simulink_opts.outputs.CPU_time == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') CPU time\n '); +{%- endif %} + +{%- if simulink_opts.outputs.CPU_time_sim == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') CPU time integrator\n '); +{%- endif %} + +{%- if simulink_opts.outputs.CPU_time_qp == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') CPU time QP solution\n '); +{%- endif %} + +{%- if simulink_opts.outputs.CPU_time_lin == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') CPU time linearization (including integrator)\n '); +{%- endif %} + +{%- if simulink_opts.outputs.sqp_iter == 1 %} +i_out = i_out + 1; +output_note = strcat(output_note, num2str(i_out), ') SQP iterations\n '); +{%- endif %} + +fprintf(output_note) diff --git a/pyextra/acados_template/c_templates_tera/make_sfun_sim.in.m b/pyextra/acados_template/c_templates_tera/make_sfun_sim.in.m new file mode 100644 index 00000000000000..1c5cf0b123c3cc --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/make_sfun_sim.in.m @@ -0,0 +1,99 @@ +% +% Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +% Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +% Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +% Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +% +% This file is part of acados. +% +% The 2-Clause BSD License +% +% 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. +% +% 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.; +% + +SOURCES = [ 'acados_sim_solver_sfunction_{{ model.name }}.c ', ... + 'acados_sim_solver_{{ model.name }}.c ', ... + {%- if solver_options.integrator_type == 'ERK' %} + '{{ model.name }}_model/{{ model.name }}_expl_ode_fun.c ', ... + '{{ model.name }}_model/{{ model.name }}_expl_vde_forw.c ',... + {%- if solver_options.hessian_approx == 'EXACT' %} + '{{ model.name }}_model/{{ model.name }}_expl_ode_hess.c ',... + {%- endif %} + {%- elif solver_options.integrator_type == "IRK" %} + '{{ model.name }}_model/{{ model.name }}_impl_dae_fun.c ', ... + '{{ model.name }}_model/{{ model.name }}_impl_dae_fun_jac_x_xdot_z.c ', ... + '{{ model.name }}_model/{{ model.name }}_impl_dae_jac_x_xdot_u_z.c ', ... + {%- if solver_options.hessian_approx == 'EXACT' %} + '{{ model.name }}_model/{{ model.name }}_impl_dae_hess.c ',... + {%- endif %} + {%- elif solver_options.integrator_type == "GNSF" %} + '{{ model.name }}_model/{{ model.name }}_gnsf_phi_fun.c ' + '{{ model.name }}_model/{{ model.name }}_gnsf_phi_fun_jac_y.c ' + '{{ model.name }}_model/{{ model.name }}_gnsf_phi_jac_y_uhat.c ' + '{{ model.name }}_model/{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz.c ' + '{{ model.name }}_model/{{ model.name }}_gnsf_get_matrices_fun.c ' + {%- endif %} + ]; + +INC_PATH = '{{ acados_include_path }}'; + +INCS = [ ' -I', fullfile(INC_PATH, 'blasfeo', 'include'), ... + ' -I', fullfile(INC_PATH, 'hpipm', 'include'), ... + ' -I', INC_PATH, ' -I', fullfile(INC_PATH, 'acados'), ' ']; + +CFLAGS = ' -O'; + +LIB_PATH = '{{ acados_lib_path }}'; + +LIBS = '-lacados -lblasfeo -lhpipm'; + +eval( [ 'mex -v -output acados_sim_solver_sfunction_{{ model.name }} ', ... + CFLAGS, INCS, ' ', SOURCES, ' -L', LIB_PATH, ' ', LIBS ]); + +fprintf( [ '\n\nSuccessfully created sfunction:\nacados_sim_solver_sfunction_{{ model.name }}', '.', ... + eval('mexext')] ); + + +%% print note on usage of s-function +fprintf('\n\nNote: Usage of Sfunction is as follows:\n') +input_note = 'Inputs are:\n1) x0, initial state, size [{{ dims.nx }}]\n '; +i_in = 2; +{%- if dims.nu > 0 %} +input_note = strcat(input_note, num2str(i_in), ') u, size [{{ dims.nu }}]\n '); +i_in = i_in + 1; +{%- endif %} + +{%- if dims.np > 0 %} +input_note = strcat(input_note, num2str(i_in), ') parameters, size [{{ dims.np }}]\n '); +i_in = i_in + 1; +{%- endif %} + + +fprintf(input_note) + +disp(' ') + +output_note = strcat('Outputs are:\n', ... + '1) x1 - simulated state, size [{{ dims.nx }}]\n'); + +fprintf(output_note) diff --git a/pyextra/acados_template/c_templates_tera/mex_solver.in.m b/pyextra/acados_template/c_templates_tera/mex_solver.in.m new file mode 100644 index 00000000000000..728741a46e511f --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/mex_solver.in.m @@ -0,0 +1,166 @@ +% +% Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +% Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +% Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +% Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +% +% This file is part of acados. +% +% The 2-Clause BSD License +% +% 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. +% +% 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.; +% + +classdef {{ model.name }}_mex_solver < handle + + properties + C_ocp + C_ocp_ext_fun + cost_ext_fun_type + cost_ext_fun_type_e + end % properties + + + + methods + + % constructor + function obj = {{ model.name }}_mex_solver() + make_mex_{{ model.name }}(); + [obj.C_ocp, obj.C_ocp_ext_fun] = acados_mex_create_{{ model.name }}(); + % to have path to destructor when changing directory + addpath('.') + obj.cost_ext_fun_type = '{{ cost.cost_ext_fun_type }}'; + obj.cost_ext_fun_type_e = '{{ cost.cost_ext_fun_type_e }}'; + end + + % destructor + function delete(obj) + if ~isempty(obj.C_ocp) + acados_mex_free_{{ model.name }}(obj.C_ocp); + end + end + + % solve + function solve(obj) + acados_mex_solve_{{ model.name }}(obj.C_ocp); + end + + % set -- borrowed from MEX interface + function set(varargin) + obj = varargin{1}; + field = varargin{2}; + value = varargin{3}; + if ~isa(field, 'char') + error('field must be a char vector, use '' '''); + end + if nargin==3 + acados_mex_set_{{ model.name }}(obj.cost_ext_fun_type, obj.cost_ext_fun_type_e, obj.C_ocp, obj.C_ocp_ext_fun, field, value); + elseif nargin==4 + stage = varargin{4}; + acados_mex_set_{{ model.name }}(obj.cost_ext_fun_type, obj.cost_ext_fun_type_e, obj.C_ocp, obj.C_ocp_ext_fun, field, value, stage); + else + disp('acados_ocp.set: wrong number of input arguments (2 or 3 allowed)'); + end + end + + function value = get_cost(obj) + value = ocp_get_cost(obj.C_ocp); + end + + % get -- borrowed from MEX interface + function value = get(varargin) + % usage: + % obj.get(field, value, [stage]) + obj = varargin{1}; + field = varargin{2}; + if any(strfind('sens', field)) + error('field sens* (sensitivities of optimal solution) not yet supported for templated MEX.') + end + if ~isa(field, 'char') + error('field must be a char vector, use '' '''); + end + + if nargin==2 + value = ocp_get(obj.C_ocp, field); + elseif nargin==3 + stage = varargin{3}; + value = ocp_get(obj.C_ocp, field, stage); + else + disp('acados_ocp.get: wrong number of input arguments (1 or 2 allowed)'); + end + end + + + % print + function print(varargin) + if nargin < 2 + field = 'stat'; + else + field = varargin{2}; + end + + obj = varargin{1}; + + if strcmp(field, 'stat') + stat = obj.get('stat'); + {%- if solver_options.nlp_solver_type == "SQP" %} + fprintf('\niter\tres_stat\tres_eq\t\tres_ineq\tres_comp\tqp_stat\tqp_iter'); + if size(stat,2)>7 + fprintf('\tqp_res_stat\tqp_res_eq\tqp_res_ineq\tqp_res_comp'); + end + fprintf('\n'); + for jj=1:size(stat,1) + fprintf('%d\t%e\t%e\t%e\t%e\t%d\t%d', stat(jj,1), stat(jj,2), stat(jj,3), stat(jj,4), stat(jj,5), stat(jj,6), stat(jj,7)); + if size(stat,2)>7 + fprintf('\t%e\t%e\t%e\t%e', stat(jj,8), stat(jj,9), stat(jj,10), stat(jj,11)); + end + fprintf('\n'); + end + fprintf('\n'); + {%- else %} + fprintf('\niter\tqp_status\tqp_iter'); + if size(stat,2)>3 + fprintf('\tqp_res_stat\tqp_res_eq\tqp_res_ineq\tqp_res_comp'); + end + fprintf('\n'); + for jj=1:size(stat,1) + fprintf('%d\t%d\t\t%d', stat(jj,1), stat(jj,2), stat(jj,3)); + if size(stat,2)>3 + fprintf('\t%e\t%e\t%e\t%e', stat(jj,4), stat(jj,5), stat(jj,6), stat(jj,7)); + end + fprintf('\n'); + end + {% endif %} + + else + fprintf('unsupported field in function print of acados_ocp.print, got %s', field); + keyboard + end + + end + + end % methods + +end % class + diff --git a/pyextra/acados_template/c_templates_tera/model.in.h b/pyextra/acados_template/c_templates_tera/model.in.h new file mode 100644 index 00000000000000..661811232c86be --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/model.in.h @@ -0,0 +1,209 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#ifndef {{ model.name }}_MODEL +#define {{ model.name }}_MODEL + +#ifdef __cplusplus +extern "C" { +#endif + +{%- if solver_options.hessian_approx %} + {%- set hessian_approx = solver_options.hessian_approx %} +{%- elif solver_options.sens_hess %} + {%- set hessian_approx = "EXACT" %} +{%- else %} + {%- set hessian_approx = "GAUSS_NEWTON" %} +{%- endif %} + +{% if solver_options.integrator_type == "IRK" or solver_options.integrator_type == "LIFTED_IRK" %} +// implicit ODE +int {{ model.name }}_impl_dae_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_impl_dae_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_impl_dae_fun_sparsity_in(int); +const int *{{ model.name }}_impl_dae_fun_sparsity_out(int); +int {{ model.name }}_impl_dae_fun_n_in(void); +int {{ model.name }}_impl_dae_fun_n_out(void); + +// implicit ODE +int {{ model.name }}_impl_dae_fun_jac_x_xdot_z(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_impl_dae_fun_jac_x_xdot_z_work(int *, int *, int *, int *); +const int *{{ model.name }}_impl_dae_fun_jac_x_xdot_z_sparsity_in(int); +const int *{{ model.name }}_impl_dae_fun_jac_x_xdot_z_sparsity_out(int); +int {{ model.name }}_impl_dae_fun_jac_x_xdot_z_n_in(void); +int {{ model.name }}_impl_dae_fun_jac_x_xdot_z_n_out(void); + +// implicit ODE +int {{ model.name }}_impl_dae_jac_x_xdot_u_z(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_impl_dae_jac_x_xdot_u_z_work(int *, int *, int *, int *); +const int *{{ model.name }}_impl_dae_jac_x_xdot_u_z_sparsity_in(int); +const int *{{ model.name }}_impl_dae_jac_x_xdot_u_z_sparsity_out(int); +int {{ model.name }}_impl_dae_jac_x_xdot_u_z_n_in(void); +int {{ model.name }}_impl_dae_jac_x_xdot_u_z_n_out(void); + +// implicit ODE - for lifted_irk +int {{ model.name }}_impl_dae_fun_jac_x_xdot_u(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_impl_dae_fun_jac_x_xdot_u_work(int *, int *, int *, int *); +const int *{{ model.name }}_impl_dae_fun_jac_x_xdot_u_sparsity_in(int); +const int *{{ model.name }}_impl_dae_fun_jac_x_xdot_u_sparsity_out(int); +int {{ model.name }}_impl_dae_fun_jac_x_xdot_u_n_in(void); +int {{ model.name }}_impl_dae_fun_jac_x_xdot_u_n_out(void); + +{%- if hessian_approx == "EXACT" %} +int {{ model.name }}_impl_dae_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_impl_dae_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_impl_dae_hess_sparsity_in(int); +const int *{{ model.name }}_impl_dae_hess_sparsity_out(int); +int {{ model.name }}_impl_dae_hess_n_in(void); +int {{ model.name }}_impl_dae_hess_n_out(void); +{%- endif %} + +{% elif solver_options.integrator_type == "GNSF" %} +/* GNSF Functions */ +// used to import model matrices +int {{ model.name }}_gnsf_get_matrices_fun(const double** arg, double** res, int* iw, double* w, void *mem); +int {{ model.name }}_gnsf_get_matrices_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_gnsf_get_matrices_fun_sparsity_in(int); +const int *{{ model.name }}_gnsf_get_matrices_fun_sparsity_out(int); +int {{ model.name }}_gnsf_get_matrices_fun_n_in(void); +int {{ model.name }}_gnsf_get_matrices_fun_n_out(void); + +// phi_fun +int {{ model.name }}_gnsf_phi_fun(const double** arg, double** res, int* iw, double* w, void *mem); +int {{ model.name }}_gnsf_phi_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_gnsf_phi_fun_sparsity_in(int); +const int *{{ model.name }}_gnsf_phi_fun_sparsity_out(int); +int {{ model.name }}_gnsf_phi_fun_n_in(void); +int {{ model.name }}_gnsf_phi_fun_n_out(void); + +// phi_fun_jac_y +int {{ model.name }}_gnsf_phi_fun_jac_y(const double** arg, double** res, int* iw, double* w, void *mem); +int {{ model.name }}_gnsf_phi_fun_jac_y_work(int *, int *, int *, int *); +const int *{{ model.name }}_gnsf_phi_fun_jac_y_sparsity_in(int); +const int *{{ model.name }}_gnsf_phi_fun_jac_y_sparsity_out(int); +int {{ model.name }}_gnsf_phi_fun_jac_y_n_in(void); +int {{ model.name }}_gnsf_phi_fun_jac_y_n_out(void); + +// phi_jac_y_uhat +int {{ model.name }}_gnsf_phi_jac_y_uhat(const double** arg, double** res, int* iw, double* w, void *mem); +int {{ model.name }}_gnsf_phi_jac_y_uhat_work(int *, int *, int *, int *); +const int *{{ model.name }}_gnsf_phi_jac_y_uhat_sparsity_in(int); +const int *{{ model.name }}_gnsf_phi_jac_y_uhat_sparsity_out(int); +int {{ model.name }}_gnsf_phi_jac_y_uhat_n_in(void); +int {{ model.name }}_gnsf_phi_jac_y_uhat_n_out(void); + +// f_lo_fun_jac_x1k1uz +int {{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz(const double** arg, double** res, int* iw, double* w, void *mem); +int {{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_work(int *, int *, int *, int *); +const int *{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_sparsity_in(int); +const int *{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_sparsity_out(int); +int {{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_n_in(void); +int {{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz_n_out(void); + +{% elif solver_options.integrator_type == "ERK" %} +/* explicit ODE */ + +// explicit ODE +int {{ model.name }}_expl_ode_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_expl_ode_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_expl_ode_fun_sparsity_in(int); +const int *{{ model.name }}_expl_ode_fun_sparsity_out(int); +int {{ model.name }}_expl_ode_fun_n_in(void); +int {{ model.name }}_expl_ode_fun_n_out(void); + +// explicit forward VDE +int {{ model.name }}_expl_vde_forw(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_expl_vde_forw_work(int *, int *, int *, int *); +const int *{{ model.name }}_expl_vde_forw_sparsity_in(int); +const int *{{ model.name }}_expl_vde_forw_sparsity_out(int); +int {{ model.name }}_expl_vde_forw_n_in(void); +int {{ model.name }}_expl_vde_forw_n_out(void); + +// explicit adjoint VDE +int {{ model.name }}_expl_vde_adj(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_expl_vde_adj_work(int *, int *, int *, int *); +const int *{{ model.name }}_expl_vde_adj_sparsity_in(int); +const int *{{ model.name }}_expl_vde_adj_sparsity_out(int); +int {{ model.name }}_expl_vde_adj_n_in(void); +int {{ model.name }}_expl_vde_adj_n_out(void); + +{%- if hessian_approx == "EXACT" %} +int {{ model.name }}_expl_ode_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_expl_ode_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_expl_ode_hess_sparsity_in(int); +const int *{{ model.name }}_expl_ode_hess_sparsity_out(int); +int {{ model.name }}_expl_ode_hess_n_in(void); +int {{ model.name }}_expl_ode_hess_n_out(void); +{%- endif %} + +{% elif solver_options.integrator_type == "DISCRETE" %} + +{% if model.dyn_ext_fun_type == "casadi" %} +int {{ model.name }}_dyn_disc_phi_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_dyn_disc_phi_fun_work(int *, int *, int *, int *); +const int *{{ model.name }}_dyn_disc_phi_fun_sparsity_in(int); +const int *{{ model.name }}_dyn_disc_phi_fun_sparsity_out(int); +int {{ model.name }}_dyn_disc_phi_fun_n_in(void); +int {{ model.name }}_dyn_disc_phi_fun_n_out(void); + +int {{ model.name }}_dyn_disc_phi_fun_jac(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_dyn_disc_phi_fun_jac_work(int *, int *, int *, int *); +const int *{{ model.name }}_dyn_disc_phi_fun_jac_sparsity_in(int); +const int *{{ model.name }}_dyn_disc_phi_fun_jac_sparsity_out(int); +int {{ model.name }}_dyn_disc_phi_fun_jac_n_in(void); +int {{ model.name }}_dyn_disc_phi_fun_jac_n_out(void); + +{%- if hessian_approx == "EXACT" %} +int {{ model.name }}_dyn_disc_phi_fun_jac_hess(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_dyn_disc_phi_fun_jac_hess_work(int *, int *, int *, int *); +const int *{{ model.name }}_dyn_disc_phi_fun_jac_hess_sparsity_in(int); +const int *{{ model.name }}_dyn_disc_phi_fun_jac_hess_sparsity_out(int); +int {{ model.name }}_dyn_disc_phi_fun_jac_hess_n_in(void); +int {{ model.name }}_dyn_disc_phi_fun_jac_hess_n_out(void); +{%- endif %} +{% else %} + {%- if hessian_approx == "EXACT" %} +int {{ model.dyn_disc_fun_jac_hess }}(void **, void **, void *); + {% endif %} +int {{ model.dyn_disc_fun_jac }}(void **, void **, void *); +int {{ model.dyn_disc_fun }}(void **, void **, void *); +{% endif %} + + +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_MODEL diff --git a/pyextra/acados_template/c_templates_tera/phi_constraint.in.h b/pyextra/acados_template/c_templates_tera/phi_constraint.in.h new file mode 100644 index 00000000000000..283ed7f88953b8 --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/phi_constraint.in.h @@ -0,0 +1,55 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#ifndef {{ model.name }}_PHI_CONSTRAINT +#define {{ model.name }}_PHI_CONSTRAINT + +#ifdef __cplusplus +extern "C" { +#endif + +{% if dims.nphi > 0 %} +// implicit ODE +int {{ model.name }}_phi_constraint(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_phi_constraint_work(int *, int *, int *, int *); +const int *{{ model.name }}_phi_constraint_sparsity_in(int); +const int *{{ model.name }}_phi_constraint_sparsity_out(int); +int {{ model.name }}_phi_constraint_n_in(void); +int {{ model.name }}_phi_constraint_n_out(void); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_PHI_CONSTRAINT diff --git a/pyextra/acados_template/c_templates_tera/phi_e_constraint.in.h b/pyextra/acados_template/c_templates_tera/phi_e_constraint.in.h new file mode 100644 index 00000000000000..dc8e293ad7cdfa --- /dev/null +++ b/pyextra/acados_template/c_templates_tera/phi_e_constraint.in.h @@ -0,0 +1,21 @@ +#ifndef {{ model.name }}_PHI_E_CONSTRAINT +#define {{ model.name }}_PHI_E_CONSTRAINT + +#ifdef __cplusplus +extern "C" { +#endif + +{% if dims.nphi_e > 0 %} +int {{ model.name }}_phi_e_constraint(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); +int {{ model.name }}_phi_e_constraint_work(int *, int *, int *, int *); +const int *{{ model.name }}_phi_e_constraint_sparsity_in(int); +const int *{{ model.name }}_phi_e_constraint_sparsity_out(int); +int {{ model.name }}_phi_e_constraint_n_in(void); +int {{ model.name }}_phi_e_constraint_n_out(void); +{% endif %} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // {{ model.name }}_PHI_E_CONSTRAINT diff --git a/pyextra/acados_template/generate_c_code_constraint.py b/pyextra/acados_template/generate_c_code_constraint.py new file mode 100644 index 00000000000000..c79ddc129a57eb --- /dev/null +++ b/pyextra/acados_template/generate_c_code_constraint.py @@ -0,0 +1,180 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import os +from casadi import * +from .utils import ALLOWED_CASADI_VERSIONS, is_empty, casadi_length, casadi_version_warning + +def generate_c_code_constraint( model, con_name, is_terminal, opts ): + + casadi_version = CasadiMeta.version() + casadi_opts = dict(mex=False, casadi_int='int', casadi_real='double') + + if casadi_version not in (ALLOWED_CASADI_VERSIONS): + casadi_version_warning(casadi_version) + + # load constraint variables and expression + x = model.x + p = model.p + + if isinstance(x, casadi.MX): + symbol = MX.sym + else: + symbol = SX.sym + + if is_terminal: + con_h_expr = model.con_h_expr_e + con_phi_expr = model.con_phi_expr_e + # create dummy u, z + u = symbol('u', 0, 0) + z = symbol('z', 0, 0) + else: + con_h_expr = model.con_h_expr + con_phi_expr = model.con_phi_expr + u = model.u + z = model.z + + if (not is_empty(con_h_expr)) and (not is_empty(con_phi_expr)): + raise Exception("acados: you can either have constraint_h, or constraint_phi, not both.") + + if not (is_empty(con_h_expr) and is_empty(con_phi_expr)): + if is_empty(con_h_expr): + constr_type = 'BGP' + else: + constr_type = 'BGH' + + if is_empty(p): + p = symbol('p', 0, 0) + + if is_empty(z): + z = symbol('z', 0, 0) + + if not (is_empty(con_h_expr)) and opts['generate_hess']: + # multipliers for hessian + nh = casadi_length(con_h_expr) + lam_h = symbol('lam_h', nh, 1) + + # set up & change directory + code_export_dir = opts["code_export_directory"] + if not os.path.exists(code_export_dir): + os.makedirs(code_export_dir) + + cwd = os.getcwd() + os.chdir(code_export_dir) + gen_dir = con_name + '_constraints' + if not os.path.exists(gen_dir): + os.mkdir(gen_dir) + gen_dir_location = os.path.join('.', gen_dir) + os.chdir(gen_dir_location) + + # export casadi functions + if constr_type == 'BGH': + if is_terminal: + fun_name = con_name + '_constr_h_e_fun_jac_uxt_zt' + else: + fun_name = con_name + '_constr_h_fun_jac_uxt_zt' + + jac_ux_t = transpose(jacobian(con_h_expr, vertcat(u,x))) + jac_z_t = jacobian(con_h_expr, z) + constraint_fun_jac_tran = Function(fun_name, [x, u, z, p], \ + [con_h_expr, jac_ux_t, jac_z_t]) + + constraint_fun_jac_tran.generate(fun_name, casadi_opts) + if opts['generate_hess']: + + if is_terminal: + fun_name = con_name + '_constr_h_e_fun_jac_uxt_zt_hess' + else: + fun_name = con_name + '_constr_h_fun_jac_uxt_zt_hess' + + # adjoint + adj_ux = jtimes(con_h_expr, vertcat(u, x), lam_h, True) + # hessian + hess_ux = jacobian(adj_ux, vertcat(u, x)) + + adj_z = jtimes(con_h_expr, z, lam_h, True) + hess_z = jacobian(adj_z, z) + + # set up functions + constraint_fun_jac_tran_hess = \ + Function(fun_name, [x, u, lam_h, z, p], \ + [con_h_expr, jac_ux_t, hess_ux, jac_z_t, hess_z]) + + # generate C code + constraint_fun_jac_tran_hess.generate(fun_name, casadi_opts) + + if is_terminal: + fun_name = con_name + '_constr_h_e_fun' + else: + fun_name = con_name + '_constr_h_fun' + h_fun = Function(fun_name, [x, u, z, p], [con_h_expr]) + h_fun.generate(fun_name, casadi_opts) + + else: # BGP constraint + if is_terminal: + fun_name = con_name + '_phi_e_constraint' + r = model.con_r_in_phi_e + con_r_expr = model.con_r_expr_e + else: + fun_name = con_name + '_phi_constraint' + r = model.con_r_in_phi + con_r_expr = model.con_r_expr + + nphi = casadi_length(con_phi_expr) + con_phi_expr_x_u_z = substitute(con_phi_expr, r, con_r_expr) + phi_jac_u = jacobian(con_phi_expr_x_u_z, u) + phi_jac_x = jacobian(con_phi_expr_x_u_z, x) + phi_jac_z = jacobian(con_phi_expr_x_u_z, z) + + hess = hessian(con_phi_expr[0], r)[0] + for i in range(1, nphi): + hess = vertcat(hess, hessian(con_phi_expr[i], r)[0]) + + r_jac_u = jacobian(con_r_expr, u) + r_jac_x = jacobian(con_r_expr, x) + + constraint_phi = \ + Function(fun_name, [x, u, z, p], \ + [con_phi_expr_x_u_z, \ + vertcat(transpose(phi_jac_u), \ + transpose(phi_jac_x)), \ + transpose(phi_jac_z), \ + hess, vertcat(transpose(r_jac_u), \ + transpose(r_jac_x))]) + + constraint_phi.generate(fun_name, casadi_opts) + + # change directory back + os.chdir(cwd) + + return diff --git a/pyextra/acados_template/generate_c_code_discrete_dynamics.py b/pyextra/acados_template/generate_c_code_discrete_dynamics.py new file mode 100644 index 00000000000000..334e18dab79fbc --- /dev/null +++ b/pyextra/acados_template/generate_c_code_discrete_dynamics.py @@ -0,0 +1,99 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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. +# + +import os +from casadi import * +from .utils import ALLOWED_CASADI_VERSIONS, casadi_length, casadi_version_warning + +def generate_c_code_discrete_dynamics( model, opts ): + + casadi_version = CasadiMeta.version() + casadi_opts = dict(mex=False, casadi_int='int', casadi_real='double') + + if casadi_version not in (ALLOWED_CASADI_VERSIONS): + casadi_version_warning(casadi_version) + + # load model + x = model.x + u = model.u + p = model.p + phi = model.disc_dyn_expr + model_name = model.name + nx = x.size()[0] + + + if isinstance(phi, casadi.MX): + symbol = MX.sym + elif isinstance(phi, casadi.SX): + symbol = SX.sym + else: + Exception("generate_c_code_disc_dyn: disc_dyn_expr must be a CasADi expression, you have type: {}".format(type(phi))) + + # assume nx1 = nx !!! + lam = symbol('lam', nx, 1) + + # generate jacobians + ux = vertcat(u,x) + jac_ux = jacobian(phi, ux) + # generate adjoint + adj_ux = jtimes(phi, ux, lam, True) + # generate hessian + hess_ux = jacobian(adj_ux, ux) + + ## change directory + code_export_dir = opts["code_export_directory"] + if not os.path.exists(code_export_dir): + os.makedirs(code_export_dir) + + cwd = os.getcwd() + os.chdir(code_export_dir) + model_dir = model_name + '_model' + if not os.path.exists(model_dir): + os.mkdir(model_dir) + model_dir_location = os.path.join('.', model_dir) + os.chdir(model_dir_location) + + # set up & generate Functions + fun_name = model_name + '_dyn_disc_phi_fun' + phi_fun = Function(fun_name, [x, u, p], [phi]) + phi_fun.generate(fun_name, casadi_opts) + + fun_name = model_name + '_dyn_disc_phi_fun_jac' + phi_fun_jac_ut_xt = Function(fun_name, [x, u, p], [phi, jac_ux.T]) + phi_fun_jac_ut_xt.generate(fun_name, casadi_opts) + + fun_name = model_name + '_dyn_disc_phi_fun_jac_hess' + phi_fun_jac_ut_xt_hess = Function(fun_name, [x, u, lam, p], [phi, jac_ux.T, hess_ux]) + phi_fun_jac_ut_xt_hess.generate(fun_name, casadi_opts) + + os.chdir(cwd) diff --git a/pyextra/acados_template/generate_c_code_explicit_ode.py b/pyextra/acados_template/generate_c_code_explicit_ode.py new file mode 100644 index 00000000000000..76e64005352a65 --- /dev/null +++ b/pyextra/acados_template/generate_c_code_explicit_ode.py @@ -0,0 +1,124 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import os +from casadi import * +from .utils import ALLOWED_CASADI_VERSIONS, is_empty, casadi_version_warning + +def generate_c_code_explicit_ode( model, opts ): + + casadi_version = CasadiMeta.version() + casadi_opts = dict(mex=False, casadi_int='int', casadi_real='double') + if casadi_version not in (ALLOWED_CASADI_VERSIONS): + casadi_version_warning(casadi_version) + + + generate_hess = opts["generate_hess"] + code_export_dir = opts["code_export_directory"] + + # load model + x = model.x + u = model.u + p = model.p + f_expl = model.f_expl_expr + model_name = model.name + + ## get model dimensions + nx = x.size()[0] + nu = u.size()[0] + + if isinstance(f_expl, casadi.MX): + symbol = MX.sym + elif isinstance(f_expl, casadi.SX): + symbol = SX.sym + else: + raise Exception("Invalid type for f_expl! Possible types are 'SX' and 'MX'. Exiting.") + ## set up functions to be exported + Sx = symbol('Sx', nx, nx) + Sp = symbol('Sp', nx, nu) + lambdaX = symbol('lambdaX', nx, 1) + + fun_name = model_name + '_expl_ode_fun' + + ## Set up functions + expl_ode_fun = Function(fun_name, [x, u, p], [f_expl]) + + vdeX = jtimes(f_expl,x,Sx) + vdeP = jacobian(f_expl,u) + jtimes(f_expl,x,Sp) + + fun_name = model_name + '_expl_vde_forw' + + expl_vde_forw = Function(fun_name, [x, Sx, Sp, u, p], [f_expl, vdeX, vdeP]) + + adj = jtimes(f_expl, vertcat(x, u), lambdaX, True) + + fun_name = model_name + '_expl_vde_adj' + expl_vde_adj = Function(fun_name, [x, lambdaX, u, p], [adj]) + + if generate_hess: + S_forw = vertcat(horzcat(Sx, Sp), horzcat(DM.zeros(nu,nx), DM.eye(nu))) + hess = mtimes(transpose(S_forw),jtimes(adj, vertcat(x,u), S_forw)) + hess2 = [] + for j in range(nx+nu): + for i in range(j,nx+nu): + hess2 = vertcat(hess2, hess[i,j]) + + fun_name = model_name + '_expl_ode_hess' + expl_ode_hess = Function(fun_name, [x, Sx, Sp, lambdaX, u, p], [adj, hess2]) + + ## generate C code + if not os.path.exists(code_export_dir): + os.makedirs(code_export_dir) + + cwd = os.getcwd() + os.chdir(code_export_dir) + model_dir = model_name + '_model' + if not os.path.exists(model_dir): + os.mkdir(model_dir) + model_dir_location = os.path.join('.', model_dir) + os.chdir(model_dir_location) + fun_name = model_name + '_expl_ode_fun' + expl_ode_fun.generate(fun_name, casadi_opts) + + fun_name = model_name + '_expl_vde_forw' + expl_vde_forw.generate(fun_name, casadi_opts) + + fun_name = model_name + '_expl_vde_adj' + expl_vde_adj.generate(fun_name, casadi_opts) + + if generate_hess: + fun_name = model_name + '_expl_ode_hess' + expl_ode_hess.generate(fun_name, casadi_opts) + os.chdir(cwd) + + return diff --git a/pyextra/acados_template/generate_c_code_external_cost.py b/pyextra/acados_template/generate_c_code_external_cost.py new file mode 100644 index 00000000000000..8396522619c138 --- /dev/null +++ b/pyextra/acados_template/generate_c_code_external_cost.py @@ -0,0 +1,116 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import os +from casadi import SX, MX, Function, transpose, vertcat, horzcat, hessian, CasadiMeta +from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning + + +def generate_c_code_external_cost(model, stage_type, opts): + + casadi_version = CasadiMeta.version() + casadi_opts = dict(mex=False, casadi_int="int", casadi_real="double") + + if casadi_version not in (ALLOWED_CASADI_VERSIONS): + casadi_version_warning(casadi_version) + + x = model.x + p = model.p + + if isinstance(x, MX): + symbol = MX.sym + else: + symbol = SX.sym + + if stage_type == 'terminal': + suffix_name = "_cost_ext_cost_e_fun" + suffix_name_hess = "_cost_ext_cost_e_fun_jac_hess" + suffix_name_jac = "_cost_ext_cost_e_fun_jac" + u = symbol("u", 0, 0) + ext_cost = model.cost_expr_ext_cost_e + custom_hess = model.cost_expr_ext_cost_custom_hess_e + + elif stage_type == 'path': + suffix_name = "_cost_ext_cost_fun" + suffix_name_hess = "_cost_ext_cost_fun_jac_hess" + suffix_name_jac = "_cost_ext_cost_fun_jac" + u = model.u + ext_cost = model.cost_expr_ext_cost + custom_hess = model.cost_expr_ext_cost_custom_hess + + elif stage_type == 'initial': + suffix_name = "_cost_ext_cost_0_fun" + suffix_name_hess = "_cost_ext_cost_0_fun_jac_hess" + suffix_name_jac = "_cost_ext_cost_0_fun_jac" + u = model.u + ext_cost = model.cost_expr_ext_cost_0 + custom_hess = model.cost_expr_ext_cost_custom_hess_0 + + # set up functions to be exported + fun_name = model.name + suffix_name + fun_name_hess = model.name + suffix_name_hess + fun_name_jac = model.name + suffix_name_jac + + # generate expression for full gradient and Hessian + full_hess, grad = hessian(ext_cost, vertcat(u, x)) + + if custom_hess is not None: + full_hess = custom_hess + + ext_cost_fun = Function(fun_name, [x, u, p], [ext_cost]) + ext_cost_fun_jac_hess = Function( + fun_name_hess, [x, u, p], [ext_cost, grad, full_hess] + ) + ext_cost_fun_jac = Function( + fun_name_jac, [x, u, p], [ext_cost, grad] + ) + + # generate C code + code_export_dir = opts["code_export_directory"] + if not os.path.exists(code_export_dir): + os.makedirs(code_export_dir) + + cwd = os.getcwd() + os.chdir(code_export_dir) + gen_dir = model.name + '_cost' + if not os.path.exists(gen_dir): + os.mkdir(gen_dir) + gen_dir_location = "./" + gen_dir + os.chdir(gen_dir_location) + + ext_cost_fun.generate(fun_name, casadi_opts) + ext_cost_fun_jac_hess.generate(fun_name_hess, casadi_opts) + ext_cost_fun_jac.generate(fun_name_jac, casadi_opts) + + os.chdir(cwd) + return diff --git a/pyextra/acados_template/generate_c_code_gnsf.py b/pyextra/acados_template/generate_c_code_gnsf.py new file mode 100644 index 00000000000000..97acb8e330f817 --- /dev/null +++ b/pyextra/acados_template/generate_c_code_gnsf.py @@ -0,0 +1,131 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import os +from casadi import * +from .utils import ALLOWED_CASADI_VERSIONS, is_empty, casadi_version_warning + +def generate_c_code_gnsf( model, opts ): + + casadi_version = CasadiMeta.version() + casadi_opts = dict(mex=False, casadi_int='int', casadi_real='double') + if casadi_version not in (ALLOWED_CASADI_VERSIONS): + casadi_version_warning(casadi_version) + + model_name = model.name + code_export_dir = opts["code_export_directory"] + + # set up directory + if not os.path.exists(code_export_dir): + os.makedirs(code_export_dir) + + cwd = os.getcwd() + os.chdir(code_export_dir) + model_dir = model_name + '_model' + if not os.path.exists(model_dir): + os.mkdir(model_dir) + model_dir_location = os.path.join('.', model_dir) + os.chdir(model_dir_location) + + # obtain gnsf dimensions + get_matrices_fun = model.get_matrices_fun + phi_fun = model.phi_fun + + size_gnsf_A = get_matrices_fun.size_out(0) + gnsf_nx1 = size_gnsf_A[1] + gnsf_nz1 = size_gnsf_A[0] - size_gnsf_A[1] + gnsf_nuhat = max(phi_fun.size_in(1)) + gnsf_ny = max(phi_fun.size_in(0)) + gnsf_nout = max(phi_fun.size_out(0)) + + # set up expressions + # if the model uses MX because of cost/constraints + # the DAE can be exported as SX -> detect GNSF in Matlab + # -> evaluated SX GNSF functions with MX. + u = model.u + + if isinstance(u, casadi.MX): + symbol = MX.sym + else: + symbol = SX.sym + + y = symbol("y", gnsf_ny, 1) + uhat = symbol("uhat", gnsf_nuhat, 1) + p = model.p + x1 = symbol("gnsf_x1", gnsf_nx1, 1) + x1dot = symbol("gnsf_x1dot", gnsf_nx1, 1) + z1 = symbol("gnsf_z1", gnsf_nz1, 1) + dummy = symbol("gnsf_dummy", 1, 1) + empty_var = symbol("gnsf_empty_var", 0, 0) + + ## generate C code + fun_name = model_name + '_gnsf_phi_fun' + phi_fun_ = Function(fun_name, [y, uhat, p], [phi_fun(y, uhat, p)]) + phi_fun_.generate(fun_name, casadi_opts) + + fun_name = model_name + '_gnsf_phi_fun_jac_y' + phi_fun_jac_y = model.phi_fun_jac_y + phi_fun_jac_y_ = Function(fun_name, [y, uhat, p], phi_fun_jac_y(y, uhat, p)) + phi_fun_jac_y_.generate(fun_name, casadi_opts) + + fun_name = model_name + '_gnsf_phi_jac_y_uhat' + phi_jac_y_uhat = model.phi_jac_y_uhat + phi_jac_y_uhat_ = Function(fun_name, [y, uhat, p], phi_jac_y_uhat(y, uhat, p)) + phi_jac_y_uhat_.generate(fun_name, casadi_opts) + + fun_name = model_name + '_gnsf_f_lo_fun_jac_x1k1uz' + f_lo_fun_jac_x1k1uz = model.f_lo_fun_jac_x1k1uz + f_lo_fun_jac_x1k1uz_eval = f_lo_fun_jac_x1k1uz(x1, x1dot, z1, u, p) + + # avoid codegeneration issue + if not isinstance(f_lo_fun_jac_x1k1uz_eval, tuple) and is_empty(f_lo_fun_jac_x1k1uz_eval): + f_lo_fun_jac_x1k1uz_eval = [empty_var] + + f_lo_fun_jac_x1k1uz_ = Function(fun_name, [x1, x1dot, z1, u, p], + f_lo_fun_jac_x1k1uz_eval) + f_lo_fun_jac_x1k1uz_.generate(fun_name, casadi_opts) + + fun_name = model_name + '_gnsf_get_matrices_fun' + get_matrices_fun_ = Function(fun_name, [dummy], get_matrices_fun(1)) + get_matrices_fun_.generate(fun_name, casadi_opts) + + # remove fields for json dump + del model.phi_fun + del model.phi_fun_jac_y + del model.phi_jac_y_uhat + del model.f_lo_fun_jac_x1k1uz + del model.get_matrices_fun + + os.chdir(cwd) + + return diff --git a/pyextra/acados_template/generate_c_code_implicit_ode.py b/pyextra/acados_template/generate_c_code_implicit_ode.py new file mode 100644 index 00000000000000..f2d50b43abbb7a --- /dev/null +++ b/pyextra/acados_template/generate_c_code_implicit_ode.py @@ -0,0 +1,139 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import os +from casadi import * +from .utils import ALLOWED_CASADI_VERSIONS, is_empty, casadi_length, casadi_version_warning + +def generate_c_code_implicit_ode( model, opts ): + + casadi_version = CasadiMeta.version() + casadi_opts = dict(mex=False, casadi_int='int', casadi_real='double') + if casadi_version not in (ALLOWED_CASADI_VERSIONS): + casadi_version_warning(casadi_version) + + generate_hess = opts["generate_hess"] + code_export_dir = opts["code_export_directory"] + + ## load model + x = model.x + xdot = model.xdot + u = model.u + z = model.z + p = model.p + f_impl = model.f_impl_expr + model_name = model.name + + ## get model dimensions + nx = casadi_length(x) + nu = casadi_length(u) + nz = casadi_length(z) + + ## generate jacobians + jac_x = jacobian(f_impl, x) + jac_xdot = jacobian(f_impl, xdot) + jac_u = jacobian(f_impl, u) + jac_z = jacobian(f_impl, z) + + ## generate hessian + x_xdot_z_u = vertcat(x, xdot, z, u) + + if isinstance(x, casadi.MX): + symbol = MX.sym + else: + symbol = SX.sym + + multiplier = symbol('multiplier', nx + nz) + + ADJ = jtimes(f_impl, x_xdot_z_u, multiplier, True) + HESS = jacobian(ADJ, x_xdot_z_u) + + ## Set up functions + p = model.p + fun_name = model_name + '_impl_dae_fun' + impl_dae_fun = Function(fun_name, [x, xdot, u, z, p], [f_impl]) + + fun_name = model_name + '_impl_dae_fun_jac_x_xdot_z' + impl_dae_fun_jac_x_xdot_z = Function(fun_name, [x, xdot, u, z, p], [f_impl, jac_x, jac_xdot, jac_z]) + + # fun_name = model_name + '_impl_dae_fun_jac_x_xdot_z' + # impl_dae_fun_jac_x_xdot = Function(fun_name, [x, xdot, u, z, p], [f_impl, jac_x, jac_xdot, jac_z]) + + # fun_name = model_name + '_impl_dae_jac_x_xdot_u' + # impl_dae_jac_x_xdot_u = Function(fun_name, [x, xdot, u, z, p], [jac_x, jac_xdot, jac_u, jac_z]) + + fun_name = model_name + '_impl_dae_fun_jac_x_xdot_u_z' + impl_dae_fun_jac_x_xdot_u_z = Function(fun_name, [x, xdot, u, z, p], [f_impl, jac_x, jac_xdot, jac_u, jac_z]) + + fun_name = model_name + '_impl_dae_fun_jac_x_xdot_u' + impl_dae_fun_jac_x_xdot_u = Function(fun_name, [x, xdot, u, z, p], [f_impl, jac_x, jac_xdot, jac_u]) + + fun_name = model_name + '_impl_dae_jac_x_xdot_u_z' + impl_dae_jac_x_xdot_u_z = Function(fun_name, [x, xdot, u, z, p], [jac_x, jac_xdot, jac_u, jac_z]) + + + fun_name = model_name + '_impl_dae_hess' + impl_dae_hess = Function(fun_name, [x, xdot, u, z, multiplier, p], [HESS]) + + # generate C code + if not os.path.exists(code_export_dir): + os.makedirs(code_export_dir) + + cwd = os.getcwd() + os.chdir(code_export_dir) + model_dir = model_name + '_model' + if not os.path.exists(model_dir): + os.mkdir(model_dir) + model_dir_location = os.path.join('.', model_dir) + os.chdir(model_dir_location) + + fun_name = model_name + '_impl_dae_fun' + impl_dae_fun.generate(fun_name, casadi_opts) + + fun_name = model_name + '_impl_dae_fun_jac_x_xdot_z' + impl_dae_fun_jac_x_xdot_z.generate(fun_name, casadi_opts) + + fun_name = model_name + '_impl_dae_jac_x_xdot_u_z' + impl_dae_jac_x_xdot_u_z.generate(fun_name, casadi_opts) + + fun_name = model_name + '_impl_dae_fun_jac_x_xdot_u_z' + impl_dae_fun_jac_x_xdot_u_z.generate(fun_name, casadi_opts) + + fun_name = model_name + '_impl_dae_fun_jac_x_xdot_u' + impl_dae_fun_jac_x_xdot_u.generate(fun_name, casadi_opts) + + if generate_hess: + fun_name = model_name + '_impl_dae_hess' + impl_dae_hess.generate(fun_name, casadi_opts) + + os.chdir(cwd) diff --git a/pyextra/acados_template/generate_c_code_nls_cost.py b/pyextra/acados_template/generate_c_code_nls_cost.py new file mode 100644 index 00000000000000..ffcd78ca7bf785 --- /dev/null +++ b/pyextra/acados_template/generate_c_code_nls_cost.py @@ -0,0 +1,113 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import os +from casadi import * +from .utils import ALLOWED_CASADI_VERSIONS, casadi_length, casadi_version_warning + +def generate_c_code_nls_cost( model, cost_name, stage_type, opts ): + + casadi_version = CasadiMeta.version() + casadi_opts = dict(mex=False, casadi_int='int', casadi_real='double') + + if casadi_version not in (ALLOWED_CASADI_VERSIONS): + casadi_version_warning(casadi_version) + + x = model.x + p = model.p + + if isinstance(x, casadi.MX): + symbol = MX.sym + else: + symbol = SX.sym + + if stage_type == 'terminal': + middle_name = '_cost_y_e' + u = symbol('u', 0, 0) + cost_expr = model.cost_y_expr_e + + elif stage_type == 'initial': + middle_name = '_cost_y_0' + u = model.u + cost_expr = model.cost_y_expr_0 + + elif stage_type == 'path': + middle_name = '_cost_y' + u = model.u + cost_expr = model.cost_y_expr + + # set up directory + code_export_dir = opts["code_export_directory"] + if not os.path.exists(code_export_dir): + os.makedirs(code_export_dir) + + cwd = os.getcwd() + os.chdir(code_export_dir) + gen_dir = cost_name + '_cost' + if not os.path.exists(gen_dir): + os.mkdir(gen_dir) + gen_dir_location = os.path.join('.', gen_dir) + os.chdir(gen_dir_location) + + # set up expressions + cost_jac_expr = transpose(jacobian(cost_expr, vertcat(u, x))) + + ny = casadi_length(cost_expr) + + y = symbol('y', ny, 1) + + y_adj = jtimes(cost_expr, vertcat(u, x), y, True) + y_hess = jacobian(y_adj, vertcat(u, x)) + + ## generate C code + suffix_name = '_fun' + fun_name = cost_name + middle_name + suffix_name + y_fun = Function( fun_name, [x, u, p], \ + [ cost_expr ]) + y_fun.generate( fun_name, casadi_opts ) + + suffix_name = '_fun_jac_ut_xt' + fun_name = cost_name + middle_name + suffix_name + y_fun_jac_ut_xt = Function(fun_name, [x, u, p], \ + [ cost_expr, cost_jac_expr ]) + y_fun_jac_ut_xt.generate( fun_name, casadi_opts ) + + suffix_name = '_hess' + fun_name = cost_name + middle_name + suffix_name + y_hess = Function(fun_name, [x, u, y, p], [ y_hess ]) + y_hess.generate( fun_name, casadi_opts ) + + os.chdir(cwd) + + return + diff --git a/pyextra/acados_template/simulink_default_opts.json b/pyextra/acados_template/simulink_default_opts.json new file mode 100644 index 00000000000000..258a224cb24e35 --- /dev/null +++ b/pyextra/acados_template/simulink_default_opts.json @@ -0,0 +1,39 @@ +{ + "outputs": { + "u0": 1, + "utraj": 0, + "xtraj": 0, + "solver_status": 1, + "KKT_residual": 1, + "x1": 1, + "CPU_time": 1, + "CPU_time_sim": 0, + "CPU_time_qp": 0, + "CPU_time_lin": 0, + "sqp_iter": 1 + }, + "inputs": { + "lbx_0": 1, + "ubx_0": 1, + "parameter_traj": 1, + "y_ref_0": 1, + "y_ref": 1, + "y_ref_e": 1, + "lbx": 1, + "ubx": 1, + "lbx_e": 1, + "ubx_e": 1, + "lbu": 1, + "ubu": 1, + "lg": 1, + "ug": 1, + "lh": 1, + "uh": 1, + "cost_W_0": 0, + "cost_W": 0, + "cost_W_e": 0, + "x_init": 0, + "u_init": 0 + }, + "samplingtime": "t0" +} diff --git a/pyextra/acados_template/utils.py b/pyextra/acados_template/utils.py new file mode 100644 index 00000000000000..bf8ae4d5db74cc --- /dev/null +++ b/pyextra/acados_template/utils.py @@ -0,0 +1,452 @@ +# +# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, +# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, +# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, +# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl +# +# This file is part of acados. +# +# The 2-Clause BSD License +# +# 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. +# +# 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.; +# + +import os, sys, json +import urllib.request +import shutil +import numpy as np +from casadi import SX, MX, DM, Function, CasadiMeta + +ALLOWED_CASADI_VERSIONS = ('3.5.5', '3.5.4', '3.5.3', '3.5.2', '3.5.1', '3.4.5', '3.4.0') + +TERA_VERSION = "0.0.34" + +def get_acados_path(): + ACADOS_PATH = os.environ.get('ACADOS_SOURCE_DIR') + if not ACADOS_PATH: + acados_template_path = os.path.dirname(os.path.abspath(__file__)) + acados_path = os.path.join(acados_template_path, '..','..','..') + ACADOS_PATH = os.path.realpath(acados_path) + msg = 'Warning: Did not find environment variable ACADOS_SOURCE_DIR, ' + msg += 'guessed ACADOS_PATH to be {}.\n'.format(ACADOS_PATH) + msg += 'Please export ACADOS_SOURCE_DIR to not avoid this warning.' + print(msg) + return ACADOS_PATH + + +def get_python_interface_path(): + ACADOS_PYTHON_INTERFACE_PATH = os.environ.get('ACADOS_PYTHON_INTERFACE_PATH') + if not ACADOS_PYTHON_INTERFACE_PATH: + acados_path = get_acados_path() + ACADOS_PYTHON_INTERFACE_PATH = os.path.join(acados_path, 'interfaces', 'acados_template', 'acados_template') + return ACADOS_PYTHON_INTERFACE_PATH + + +def get_tera_exec_path(): + TERA_PATH = os.environ.get('TERA_PATH') + if not TERA_PATH: + TERA_PATH = os.path.join(get_acados_path(), 'bin', 't_renderer') + if os.name == 'nt': + TERA_PATH += '.exe' + return TERA_PATH + + +platform2tera = { + "linux": "linux", + "darwin": "osx", + "win32": "window.exe" +} + + +def casadi_version_warning(casadi_version): + msg = 'Warning: Please note that the following versions of CasADi are ' + msg += 'officially supported: {}.\n '.format(" or ".join(ALLOWED_CASADI_VERSIONS)) + msg += 'If there is an incompatibility with the CasADi generated code, ' + msg += 'please consider changing your CasADi version.\n' + msg += 'Version {} currently in use.'.format(casadi_version) + print(msg) + + +def is_column(x): + if isinstance(x, np.ndarray): + if x.ndim == 1: + return True + elif x.ndim == 2 and x.shape[1] == 1: + return True + else: + return False + elif isinstance(x, (MX, SX, DM)): + if x.shape[1] == 1: + return True + elif x.shape[0] == 0 and x.shape[1] == 0: + return True + else: + return False + elif x == None or x == []: + return False + else: + raise Exception("is_column expects one of the following types: np.ndarray, casadi.MX, casadi.SX." + + " Got: " + str(type(x))) + + +def is_empty(x): + if isinstance(x, (MX, SX, DM)): + return x.is_empty() + elif isinstance(x, np.ndarray): + if np.prod(x.shape) == 0: + return True + else: + return False + elif x == None or x == []: + return True + else: + raise Exception("is_empty expects one of the following types: casadi.MX, casadi.SX, " + + "None, numpy array empty list. Got: " + str(type(x))) + + +def casadi_length(x): + if isinstance(x, (MX, SX, DM)): + return int(np.prod(x.shape)) + else: + raise Exception("casadi_length expects one of the following types: casadi.MX, casadi.SX." + + " Got: " + str(type(x))) + + +def make_model_consistent(model): + x = model.x + xdot = model.xdot + u = model.u + z = model.z + p = model.p + + if isinstance(x, MX): + symbol = MX.sym + elif isinstance(x, SX): + symbol = SX.sym + else: + raise Exception("model.x must be casadi.SX or casadi.MX, got {}".format(type(x))) + + if is_empty(p): + model.p = symbol('p', 0, 0) + + if is_empty(z): + model.z = symbol('z', 0, 0) + + return model + + +def get_tera(): + tera_path = get_tera_exec_path() + acados_path = get_acados_path() + + if os.path.exists(tera_path) and os.access(tera_path, os.X_OK): + return tera_path + + repo_url = "https://github.com/acados/tera_renderer/releases" + url = "{}/download/v{}/t_renderer-v{}-{}".format( + repo_url, TERA_VERSION, TERA_VERSION, platform2tera[sys.platform]) + + manual_install = 'For manual installation follow these instructions:\n' + manual_install += '1 Download binaries from {}\n'.format(url) + manual_install += '2 Copy them in {}/bin\n'.format(acados_path) + manual_install += '3 Strip the version and platform from the binaries: ' + manual_install += 'as t_renderer-v0.0.34-X -> t_renderer)\n' + manual_install += '4 Enable execution privilege on the file "t_renderer" with:\n' + manual_install += '"chmod +x {}"\n\n'.format(tera_path) + + msg = "\n" + msg += 'Tera template render executable not found, ' + msg += 'while looking in path:\n{}\n'.format(tera_path) + msg += 'In order to be able to render the templates, ' + msg += 'you need to download the tera renderer binaries from:\n' + msg += '{}\n\n'.format(repo_url) + msg += 'Do you wish to set up Tera renderer automatically?\n' + msg += 'y/N? (press y to download tera or any key for manual installation)\n' + + if input(msg) == 'y': + print("Dowloading {}".format(url)) + with urllib.request.urlopen(url) as response, open(tera_path, 'wb') as out_file: + shutil.copyfileobj(response, out_file) + print("Successfully downloaded t_renderer.") + os.chmod(tera_path, 0o755) + return tera_path + + msg_cancel = "\nYou cancelled automatic download.\n\n" + msg_cancel += manual_install + msg_cancel += "Once installed re-run your script.\n\n" + print(msg_cancel) + + sys.exit(1) + + +def render_template(in_file, out_file, template_dir, json_path): + cwd = os.getcwd() + if not os.path.exists(template_dir): + os.mkdir(template_dir) + os.chdir(template_dir) + + tera_path = get_tera() + + # setting up loader and environment + acados_path = os.path.dirname(os.path.abspath(__file__)) + template_glob = os.path.join(acados_path, 'c_templates_tera', '*') + + # call tera as system cmd + os_cmd = "{tera_path} '{template_glob}' '{in_file}' '{json_path}' '{out_file}'".format( + tera_path=tera_path, + template_glob=template_glob, + json_path=json_path, + in_file=in_file, + out_file=out_file + ) + status = os.system(os_cmd) + if (status != 0): + raise Exception('Rendering of {} failed!\n\nAttempted to execute OS command:\n{}\n\nExiting.\n'.format(in_file, os_cmd)) + + os.chdir(cwd) + + +## Conversion functions +def np_array_to_list(np_array): + if isinstance(np_array, (np.ndarray)): + return np_array.tolist() + elif isinstance(np_array, (SX)): + return DM(np_array).full() + elif isinstance(np_array, (DM)): + return np_array.full() + else: + raise(Exception( + "Cannot convert to list type {}".format(type(np_array)) + )) + + +def format_class_dict(d): + """ + removes the __ artifact from class to dict conversion + """ + out = {} + for k, v in d.items(): + if isinstance(v, dict): + v = format_class_dict(v) + + out_key = k.split('__', 1)[-1] + out[k.replace(k, out_key)] = v + return out + + +def acados_class2dict(class_instance): + """ + removes the __ artifact from class to dict conversion + """ + + d = dict(class_instance.__dict__) + out = {} + for k, v in d.items(): + if isinstance(v, dict): + v = format_class_dict(v) + + out_key = k.split('__', 1)[-1] + out[k.replace(k, out_key)] = v + return out + + +def get_ocp_nlp_layout(): + python_interface_path = get_python_interface_path() + abs_path = os.path.join(python_interface_path, 'acados_layout.json') + with open(abs_path, 'r') as f: + ocp_nlp_layout = json.load(f) + return ocp_nlp_layout + + +def ocp_check_against_layout(ocp_nlp, ocp_dims): + """ + Check dimensions against layout + Parameters + --------- + ocp_nlp : dict + dictionary loaded from JSON to be post-processed. + + ocp_dims : instance of AcadosOcpDims + """ + + ocp_nlp_layout = get_ocp_nlp_layout() + + ocp_check_against_layout_recursion(ocp_nlp, ocp_dims, ocp_nlp_layout) + return + + +def ocp_check_against_layout_recursion(ocp_nlp, ocp_dims, layout): + + for key, item in ocp_nlp.items(): + + try: + layout_of_key = layout[key] + except KeyError: + raise Exception("ocp_check_against_layout_recursion: field" \ + " '{0}' is not in layout but in OCP description.".format(key)) + + if isinstance(item, dict): + ocp_check_against_layout_recursion(item, ocp_dims, layout_of_key) + + if 'ndarray' in layout_of_key: + if isinstance(item, int) or isinstance(item, float): + item = np.array([item]) + if isinstance(item, (list, np.ndarray)) and (layout_of_key[0] != 'str'): + dim_layout = [] + dim_names = layout_of_key[1] + + for dim_name in dim_names: + dim_layout.append(ocp_dims[dim_name]) + + dims = tuple(dim_layout) + + item = np.array(item) + item_dims = item.shape + if len(item_dims) != len(dims): + raise Exception('Mismatching dimensions for field {0}. ' \ + 'Expected {1} dimensional array, got {2} dimensional array.' \ + .format(key, len(dims), len(item_dims))) + + if np.prod(item_dims) != 0 or np.prod(dims) != 0: + if dims != item_dims: + raise Exception('acados -- mismatching dimensions for field {0}. ' \ + 'Provided data has dimensions {1}, ' \ + 'while associated dimensions {2} are {3}' \ + .format(key, item_dims, dim_names, dims)) + return + + +def J_to_idx(J): + nrows = J.shape[0] + idx = np.zeros((nrows, )) + for i in range(nrows): + this_idx = np.nonzero(J[i,:])[0] + if len(this_idx) != 1: + raise Exception('Invalid J matrix structure detected, ' \ + 'must contain one nonzero element per row. Exiting.') + if this_idx.size > 0 and J[i,this_idx[0]] != 1: + raise Exception('J matrices can only contain 1s. Exiting.') + idx[i] = this_idx[0] + return idx + + +def J_to_idx_slack(J): + nrows = J.shape[0] + ncol = J.shape[1] + idx = np.zeros((ncol, )) + i_idx = 0 + for i in range(nrows): + this_idx = np.nonzero(J[i,:])[0] + if len(this_idx) == 1: + idx[i_idx] = i + i_idx = i_idx + 1 + elif len(this_idx) > 1: + raise Exception('J_to_idx_slack: Invalid J matrix. Exiting. ' \ + 'Found more than one nonzero in row ' + str(i)) + if this_idx.size > 0 and J[i,this_idx[0]] != 1: + raise Exception('J_to_idx_slack: J matrices can only contain 1s, ' \ + 'got J(' + str(i) + ', ' + str(this_idx[0]) + ') = ' + str(J[i,this_idx[0]]) ) + if not i_idx == ncol: + raise Exception('J_to_idx_slack: J must contain a 1 in every column!') + return idx + + +def acados_dae_model_json_dump(model): + + # load model + x = model.x + xdot = model.xdot + u = model.u + z = model.z + p = model.p + + f_impl = model.f_impl_expr + model_name = model.name + + # create struct with impl_dae_fun, casadi_version + fun_name = model_name + '_impl_dae_fun' + impl_dae_fun = Function(fun_name, [x, xdot, u, z, p], [f_impl]) + + casadi_version = CasadiMeta.version() + str_impl_dae_fun = impl_dae_fun.serialize() + + dae_dict = {"str_impl_dae_fun": str_impl_dae_fun, "casadi_version": casadi_version} + + # dump + json_file = model_name + '_acados_dae.json' + with open(json_file, 'w') as f: + json.dump(dae_dict, f, default=np_array_to_list, indent=4, sort_keys=True) + print("dumped ", model_name, " dae to file:", json_file, "\n") + + +def set_up_imported_gnsf_model(acados_formulation): + + gnsf = acados_formulation.gnsf_model + + # check CasADi version + # dump_casadi_version = gnsf['casadi_version'] + # casadi_version = CasadiMeta.version() + + # if not casadi_version == dump_casadi_version: + # print("WARNING: GNSF model was dumped with another CasADi version.\n" + # + "This might yield errors. Please use the same version for compatibility, serialize version: " + # + dump_casadi_version + " current Python CasADi verison: " + casadi_version) + # input("Press any key to attempt to continue...") + + # load model + phi_fun = Function.deserialize(gnsf['phi_fun']) + phi_fun_jac_y = Function.deserialize(gnsf['phi_fun_jac_y']) + phi_jac_y_uhat = Function.deserialize(gnsf['phi_jac_y_uhat']) + get_matrices_fun = Function.deserialize(gnsf['get_matrices_fun']) + + # obtain gnsf dimensions + size_gnsf_A = get_matrices_fun.size_out(0) + acados_formulation.dims.gnsf_nx1 = size_gnsf_A[1] + acados_formulation.dims.gnsf_nz1 = size_gnsf_A[0] - size_gnsf_A[1] + acados_formulation.dims.gnsf_nuhat = max(phi_fun.size_in(1)) + acados_formulation.dims.gnsf_ny = max(phi_fun.size_in(0)) + acados_formulation.dims.gnsf_nout = max(phi_fun.size_out(0)) + + # save gnsf functions in model + acados_formulation.model.phi_fun = phi_fun + acados_formulation.model.phi_fun_jac_y = phi_fun_jac_y + acados_formulation.model.phi_jac_y_uhat = phi_jac_y_uhat + acados_formulation.model.get_matrices_fun = get_matrices_fun + + if "f_lo_fun_jac_x1k1uz" in gnsf: + f_lo_fun_jac_x1k1uz = Function.deserialize(gnsf['f_lo_fun_jac_x1k1uz']) + acados_formulation.model.f_lo_fun_jac_x1k1uz = f_lo_fun_jac_x1k1uz + else: + dummy_var_x1 = SX.sym('dummy_var_x1', acados_formulation.dims.gnsf_nx1) + dummy_var_x1dot = SX.sym('dummy_var_x1dot', acados_formulation.dims.gnsf_nx1) + dummy_var_z1 = SX.sym('dummy_var_z1', acados_formulation.dims.gnsf_nz1) + dummy_var_u = SX.sym('dummy_var_z1', acados_formulation.dims.nu) + dummy_var_p = SX.sym('dummy_var_z1', acados_formulation.dims.np) + empty_var = SX.sym('empty_var', 0, 0) + + empty_fun = Function('empty_fun', \ + [dummy_var_x1, dummy_var_x1dot, dummy_var_z1, dummy_var_u, dummy_var_p], + [empty_var]) + acados_formulation.model.f_lo_fun_jac_x1k1uz = empty_fun + + del acados_formulation.gnsf_model 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/SConscript b/rednose/SConscript new file mode 100644 index 00000000000000..ca1b284232ed0a --- /dev/null +++ b/rednose/SConscript @@ -0,0 +1,41 @@ +Import('env', 'envCython', 'arch', 'rednose_config', 'common') + +generated_folder = rednose_config['generated_folder'] + +templates = Glob('#rednose/templates/*') + +sympy_helpers = "#rednose/helpers/sympy_helpers.py" +ekf_sym = "#rednose/helpers/ekf_sym.py" +ekf_sym_pyx = "#rednose/helpers/ekf_sym_pyx.pyx" +ekf_sym_cc = env.Object("#rednose/helpers/ekf_sym.cc") +common_ekf = "#rednose/helpers/common_ekf.cc" + +found = {} +for target, (command, combined_lib, extra_generated) in rednose_config['to_build'].items(): + if File(command).exists(): + found[target] = (command, combined_lib, extra_generated) + +lib_target = [common_ekf] +for target, (command, combined_lib, extra_generated) in found.items(): + target_files = File([f'{generated_folder}/{target}.cpp', f'{generated_folder}/{target}.h']) + extra_generated = [File(f'{generated_folder}/{x}') for x in extra_generated] + command_file = File(command) + + env.Command(target_files + extra_generated, + [templates, command_file, sympy_helpers, ekf_sym], + command_file.get_abspath() + " " + target + " " + Dir(generated_folder).get_abspath()) + + if combined_lib: + lib_target.append(target_files[0]) + else: + env.SharedLibrary(f'{generated_folder}/' + target, [target_files[0], common_ekf]) + +libkf = env.SharedLibrary(f'{generated_folder}/libkf', lib_target) + +lenv = envCython.Clone() +lenv["LINKFLAGS"] += [libkf[0].get_labspath()] +lenv["LIBS"] = ['zmq', common] + lenv["LIBS"] +ekf_sym_so = lenv.Program('#rednose/helpers/ekf_sym_pyx.so', [ekf_sym_pyx, ekf_sym_cc, common_ekf]) +lenv.Depends(ekf_sym_so, libkf) + +Export('libkf') diff --git a/rednose/helpers/__init__.py b/rednose/helpers/__init__.py new file mode 100644 index 00000000000000..bbd239b7748537 --- /dev/null +++ b/rednose/helpers/__init__.py @@ -0,0 +1,35 @@ +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, lib_name=None): + if lib_name is None: + lib_name = name + shared_ext = "dylib" if platform.system() == "Darwin" else "so" + shared_fn = os.path.join(folder, f"lib{lib_name}.{shared_ext}") + header_fn = os.path.join(folder, f"{name}.h") + + with open(header_fn) as f: + header = f.read() + + # is the only thing that can be parsed by cffi + header = "\n".join([line for line in header.split("\n") if line.startswith("void ")]) + + 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/common_ekf.cc b/rednose/helpers/common_ekf.cc new file mode 100644 index 00000000000000..1e639025088edd --- /dev/null +++ b/rednose/helpers/common_ekf.cc @@ -0,0 +1,19 @@ +#include "common_ekf.h" + +std::vector& get_ekfs() { + static std::vector vec; + return vec; +} + +void ekf_register(const EKF* ekf) { + get_ekfs().push_back(ekf); +} + +const EKF* ekf_lookup(const std::string& ekf_name) { + for (const auto& ekfi : get_ekfs()) { + if (ekf_name == ekfi->name) { + return ekfi; + } + } + return NULL; +} diff --git a/rednose/helpers/common_ekf.h b/rednose/helpers/common_ekf.h new file mode 100644 index 00000000000000..5dfdd448b6e530 --- /dev/null +++ b/rednose/helpers/common_ekf.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +typedef void (*extra_routine_t)(double *, double *); + +struct EKF { + std::string name; + std::vector kinds; + std::vector feature_kinds; + + void (*f_fun)(double *, double, double *); + void (*F_fun)(double *, double, double *); + void (*err_fun)(double *, double *, double *); + void (*inv_err_fun)(double *, double *, double *); + void (*H_mod_fun)(double *, double *); + void (*predict)(double *, double *, double *, double); + std::unordered_map hs = {}; + std::unordered_map Hs = {}; + std::unordered_map updates = {}; + std::unordered_map Hes = {}; + std::unordered_map sets = {}; + std::unordered_map extra_routines = {}; +}; + +std::vector& get_ekfs(); +const EKF* ekf_lookup(const std::string& ekf_name); + +void ekf_register(const EKF* ekf); + +#define ekf_init(ekf) \ +static void __attribute__((constructor)) do_ekf_init_ ## ekf(void) { \ + ekf_register(&ekf); \ +} diff --git a/rednose/helpers/ekf_sym.cc b/rednose/helpers/ekf_sym.cc new file mode 100644 index 00000000000000..8a2f2b88a9ca87 --- /dev/null +++ b/rednose/helpers/ekf_sym.cc @@ -0,0 +1,224 @@ +#include "ekf_sym.h" +#include "logger/logger.h" + +using namespace EKFS; +using namespace Eigen; + +EKFSym::EKFSym(std::string name, Map Q, Map x_initial, Map P_initial, int dim_main, + int dim_main_err, int N, int dim_augment, int dim_augment_err, std::vector maha_test_kinds, + std::vector quaternion_idxs, std::vector global_vars, double max_rewind_age) +{ + // TODO: add logger + + this->ekf = ekf_lookup(name); + assert(this->ekf); + + this->msckf = N > 0; + this->N = N; + this->dim_augment = dim_augment; + this->dim_augment_err = dim_augment_err; + this->dim_main = dim_main; + this->dim_main_err = dim_main_err; + + this->dim_x = x_initial.rows(); + this->dim_err = P_initial.rows(); + + assert(dim_main + dim_augment * N == dim_x); + assert(dim_main_err + dim_augment_err * N == this->dim_err); + assert(Q.rows() == P_initial.rows() && Q.cols() == P_initial.cols()); + + // kinds that should get mahalanobis distance + // tested for outlier rejection + this->maha_test_kinds = maha_test_kinds; + + // quaternions need normalization + this->quaternion_idxs = quaternion_idxs; + + this->global_vars = global_vars; + + // Process noise + this->Q = Q; + + this->max_rewind_age = max_rewind_age; + this->init_state(x_initial, P_initial, NAN); +} + +void EKFSym::init_state(Map state, Map covs, double init_filter_time) { + this->x = state; + this->P = covs; + this->filter_time = init_filter_time; + this->augment_times = VectorXd::Zero(this->N); + this->reset_rewind(); +} + +VectorXd EKFSym::state() { + return this->x; +} + +MatrixXdr EKFSym::covs() { + return this->P; +} + +void EKFSym::set_filter_time(double t) { + this->filter_time = t; +} + +double EKFSym::get_filter_time() { + return this->filter_time; +} + +void EKFSym::normalize_quaternions() { + for(std::size_t i = 0; i < this->quaternion_idxs.size(); ++i) { + this->normalize_slice(this->quaternion_idxs[i], this->quaternion_idxs[i] + 4); + } +} + +void EKFSym::normalize_slice(int slice_start, int slice_end_ex) { + this->x.block(slice_start, 0, slice_end_ex - slice_start, this->x.cols()).normalize(); +} + +void EKFSym::set_global(std::string global_var, double val) { + this->ekf->sets.at(global_var)(val); +} + +std::optional EKFSym::predict_and_update_batch(double t, int kind, std::vector> z_map, + std::vector> R_map, std::vector> extra_args, bool augment) +{ + // TODO handle rewinding at this level + + std::deque rewound; + if (!std::isnan(this->filter_time) && t < this->filter_time) { + if (this->rewind_t.empty() || t < this->rewind_t.front() || t < this->rewind_t.back() - this->max_rewind_age) { + LOGD("observation too old at %d with filter at %d, ignoring!", t, this->filter_time); + return std::nullopt; + } + rewound = this->rewind(t); + } + + Observation obs; + obs.t = t; + obs.kind = kind; + obs.extra_args = extra_args; + for (Map zi : z_map) { + obs.z.push_back(zi); + } + for (Map Ri : R_map) { + obs.R.push_back(Ri); + } + + std::optional res = std::make_optional(this->predict_and_update_batch(obs, augment)); + + // optional fast forward + while (!rewound.empty()) { + this->predict_and_update_batch(rewound.front(), false); + rewound.pop_front(); + } + + return res; +} + +void EKFSym::reset_rewind() { + this->rewind_obscache.clear(); + this->rewind_t.clear(); + this->rewind_states.clear(); +} + +std::deque EKFSym::rewind(double t) { + std::deque rewound; + + // rewind observations until t is after previous observation + while (this->rewind_t.back() > t) { + rewound.push_front(this->rewind_obscache.back()); + this->rewind_t.pop_back(); + this->rewind_states.pop_back(); + this->rewind_obscache.pop_back(); + } + + // set the state to the time right before that + this->filter_time = this->rewind_t.back(); + this->x = this->rewind_states.back().first; + this->P = this->rewind_states.back().second; + + return rewound; +} + +void EKFSym::checkpoint(Observation& obs) { + // push to rewinder + this->rewind_t.push_back(this->filter_time); + this->rewind_states.push_back(std::make_pair(this->x, this->P)); + this->rewind_obscache.push_back(obs); + + // only keep a certain number around + if (this->rewind_t.size() > REWIND_TO_KEEP) { + this->rewind_t.pop_front(); + this->rewind_states.pop_front(); + this->rewind_obscache.pop_front(); + } +} + +Estimate EKFSym::predict_and_update_batch(Observation& obs, bool augment) { + assert(obs.z.size() == obs.R.size()); + assert(obs.z.size() == obs.extra_args.size()); + + this->predict(obs.t); + + Estimate res; + res.t = obs.t; + res.kind = obs.kind; + res.z = obs.z; + res.extra_args = obs.extra_args; + res.xk1 = this->x; + res.Pk1 = this->P; + + // update batch + std::vector y; + for (int i = 0; i < obs.z.size(); i++) { + assert(obs.z[i].rows() == obs.R[i].rows()); + assert(obs.z[i].rows() == obs.R[i].cols()); + + // update state + y.push_back(this->update(obs.kind, obs.z[i], obs.R[i], obs.extra_args[i])); + } + + res.xk = this->x; + res.Pk = this->P; + res.y = y; + + assert(!augment); // TODO + // if (augment) { + // this->augment(); + // } + + this->checkpoint(obs); + + return res; +} + +void EKFSym::predict(double t) { + // initialize time + if (std::isnan(this->filter_time)) { + this->filter_time = t; + } + + // predict + double dt = t - this->filter_time; + assert(dt >= 0.0); + + this->ekf->predict(this->x.data(), this->P.data(), this->Q.data(), dt); + this->normalize_quaternions(); + this->filter_time = t; +} + +VectorXd EKFSym::update(int kind, VectorXd z, MatrixXdr R, std::vector extra_args) { + this->ekf->updates.at(kind)(this->x.data(), this->P.data(), z.data(), R.data(), extra_args.data()); + this->normalize_quaternions(); + + if (this->msckf && std::find(this->feature_track_kinds.begin(), this->feature_track_kinds.end(), kind) != this->feature_track_kinds.end()) { + return z.head(z.rows() - extra_args.size()); + } + return z; +} + +extra_routine_t EKFSym::get_extra_routine(const std::string& routine) { + return this->ekf->extra_routines.at(routine); +} diff --git a/rednose/helpers/ekf_sym.h b/rednose/helpers/ekf_sym.h new file mode 100644 index 00000000000000..86d6ca1938cb95 --- /dev/null +++ b/rednose/helpers/ekf_sym.h @@ -0,0 +1,112 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "common_ekf.h" + +#define REWIND_TO_KEEP 512 + +namespace EKFS { + +typedef Eigen::Matrix MatrixXdr; + +typedef struct Observation { + double t; + int kind; + std::vector z; + std::vector R; + std::vector> extra_args; +} Observation; + +typedef struct Estimate { + Eigen::VectorXd xk1; + Eigen::VectorXd xk; + MatrixXdr Pk1; + MatrixXdr Pk; + double t; + int kind; + std::vector y; + std::vector z; + std::vector> extra_args; +} Estimate; + +class EKFSym { +public: + EKFSym(std::string name, Eigen::Map Q, Eigen::Map x_initial, + Eigen::Map P_initial, int dim_main, int dim_main_err, int N = 0, int dim_augment = 0, + int dim_augment_err = 0, std::vector maha_test_kinds = std::vector(), + std::vector quaternion_idxs = std::vector(), + std::vector global_vars = std::vector(), double max_rewind_age = 1.0); + void init_state(Eigen::Map state, Eigen::Map covs, double filter_time); + + Eigen::VectorXd state(); + MatrixXdr covs(); + void set_filter_time(double t); + double get_filter_time(); + void normalize_quaternions(); + void normalize_slice(int slice_start, int slice_end_ex); + void set_global(std::string global_var, double val); + void reset_rewind(); + + void predict(double t); + std::optional predict_and_update_batch(double t, int kind, std::vector> z, + std::vector> R, std::vector> extra_args = {{}}, bool augment = false); + + extra_routine_t get_extra_routine(const std::string& routine); + +private: + std::deque rewind(double t); + void checkpoint(Observation& obs); + + Estimate predict_and_update_batch(Observation& obs, bool augment); + Eigen::VectorXd update(int kind, Eigen::VectorXd z, MatrixXdr R, std::vector extra_args); + + // stuct with linked sympy generated functions + const EKF *ekf = NULL; + + Eigen::VectorXd x; // state + MatrixXdr P; // covs + + bool msckf; + int N; + int dim_augment; + int dim_augment_err; + int dim_main; + int dim_main_err; + + // state + int dim_x; + int dim_err; + + double filter_time; + + std::vector maha_test_kinds; + std::vector quaternion_idxs; + + std::vector global_vars; + + // process noise + MatrixXdr Q; + + // rewind stuff + double max_rewind_age; + std::deque rewind_t; + std::deque> rewind_states; + std::deque rewind_obscache; + + Eigen::VectorXd augment_times; + + std::vector feature_track_kinds; +}; + +} diff --git a/rednose/helpers/ekf_sym.py b/rednose/helpers/ekf_sym.py new file mode 100644 index 00000000000000..c9cf0bc22e4204 --- /dev/null +++ b/rednose/helpers/ekf_sym.py @@ -0,0 +1,687 @@ +import os +import logging +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 +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=[], quaternion_idxs=[], global_vars=None, extra_routines=[]): + # 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 = [] + + # extra routines + sympy_functions += extra_routines + + # 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 + sympy_header, code = sympy_into_c(sympy_functions, global_vars) + + header = "#pragma once\n" + header += "#include \"rednose/helpers/common_ekf.h\"\n" + header += "extern \"C\" {\n" + + pre_code = f"#include \"{name}.h\"\n" + pre_code += "\nnamespace {\n" + pre_code += "#define DIM %d\n" % dim_x + pre_code += "#define EDIM %d\n" % dim_err + pre_code += "#define MEDIM %d\n" % dim_main_err + pre_code += "typedef void (*Hfun)(double *, double *, double *);\n" + + if global_vars is not None: + for var in global_vars: + pre_code += f"\ndouble {var.name};\n" + pre_code += f"\nvoid set_{var.name}(double x){{ {var.name} = x;}}\n" + + post_code = "\n}\n" # namespace + post_code += "extern \"C\" {\n\n" + + 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 + + pre_code += f"const static double MAHA_THRESH_{kind} = {maha_thresh};\n" + + header += f"void {name}_update_{kind}(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);\n" + post_code += f"void {name}_update_{kind}(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {{\n" + post_code += f" update<{h_sym.shape[0]}, 3, {int(maha_test)}>(in_x, in_P, h_{kind}, H_{kind}, {He_str}, in_z, in_R, in_ea, MAHA_THRESH_{kind});\n" + post_code += "}\n" + + # For ffi loading of specific functions + for line in sympy_header.split("\n"): + if line.startswith("void "): # sympy functions + func_call = line[5: line.index(')') + 1] + header += f"void {name}_{func_call};\n" + post_code += f"void {name}_{func_call} {{\n" + post_code += f" {func_call.replace('double *', '').replace('double', '')};\n" + post_code += "}\n" + header += f"void {name}_predict(double *in_x, double *in_P, double *in_Q, double dt);\n" + post_code += f"void {name}_predict(double *in_x, double *in_P, double *in_Q, double dt) {{\n" + post_code += " predict(in_x, in_P, in_Q, dt);\n" + post_code += "}\n" + if global_vars is not None: + for var in global_vars: + header += f"void {name}_set_{var.name}(double x);\n" + post_code += f"void {name}_set_{var.name}(double x) {{\n" + post_code += f" set_{var.name}(x);\n" + post_code += "}\n" + + post_code += "}\n\n" # extern c + + funcs = ['f_fun', 'F_fun', 'err_fun', 'inv_err_fun', 'H_mod_fun', 'predict'] + func_lists = { + 'h': [kind for _, kind, _, _, _ in obs_eqs], + 'H': [kind for _, kind, _, _, _ in obs_eqs], + 'update': [kind for _, kind, _, _, _ in obs_eqs], + 'He': [kind for _, kind, _, _, _ in obs_eqs if msckf and kind in feature_track_kinds], + 'set': [var.name for var in global_vars] if global_vars is not None else [], + } + func_extra = [x[0] for x in extra_routines] + + # For dynamic loading of specific functions + post_code += f"const EKF {name} = {{\n" + post_code += f" .name = \"{name}\",\n" + post_code += f" .kinds = {{ {', '.join([str(kind) for _, kind, _, _, _ in obs_eqs])} }},\n" + post_code += f" .feature_kinds = {{ {', '.join([str(kind) for _, kind, _, _, _ in obs_eqs if msckf and kind in feature_track_kinds])} }},\n" + for func in funcs: + post_code += f" .{func} = {name}_{func},\n" + for group, kinds in func_lists.items(): + post_code += f" .{group}s = {{\n" + for kind in kinds: + str_kind = f"\"{kind}\"" if type(kind) == str else kind + post_code += f" {{ {str_kind}, {name}_{group}_{kind} }},\n" + post_code += " },\n" + post_code += " .extra_routines = {\n" + for f in func_extra: + post_code += f" {{ \"{f}\", {name}_{f} }},\n" + post_code += " },\n" + post_code += "};\n\n" + post_code += f"ekf_init({name});\n" + + # merge code blocks + header += "}" + code = "\n".join([pre_code, code, open(os.path.join(TEMPLATE_DIR, "ekf_c.c")).read(), post_code]) + + # write to file + if not os.path.exists(folder): + os.mkdir(folder) + + open(os.path.join(folder, f"{name}.h"), 'w').write(header) # header is used for ffi import + open(os.path.join(folder, f"{name}.cpp"), 'w').write(code) + + +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=[], quaternion_idxs=[], global_vars=None, max_rewind_age=1.0, logger=logging): + """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 + + self.logger = logger + + # 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 + + # quaternions need normalization + self.quaternion_idxs = quaternion_idxs + + # 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, "kf") + kinds, self.feature_track_kinds = [], [] + for func in dir(lib): + if func[:len(name) + 3] == f'{name}_h_': + kinds.append(int(func[len(name) + 3:])) + if func[:len(name) + 4] == f'{name}_He_': + self.feature_track_kinds.append(int(func[len(name) + 4:])) + + # wrap all the sympy functions + def wrap_1lists(func_name): + func = eval(f"lib.{name}_{func_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(func_name): + func = eval(f"lib.{name}_{func_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(func_name): + func = eval(f"lib.{name}_{func_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(f"h_{kind}") + self.Hs[kind] = wrap_2lists(f"H_{kind}") + if self.msckf and kind in self.feature_track_kinds: + self.Hes[kind] = wrap_2lists(f"He_{kind}") + + self.set_globals = {} + if global_vars is not None: + for global_var in global_vars: + self.set_globals[global_var] = getattr(lib, f"{name}_set_{global_var}") + + # wrap the C++ predict function + def _predict_blas(x, P, dt): + func = eval(f"lib.{name}_predict", {"lib": lib}) # pylint: disable=eval-used + func(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(f"lib.{name}_{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 set_filter_time(self, t): + self.filter_time = t + + def get_filter_time(self): + return self.filter_time + + def normalize_quaternions(self): + for idx in self.quaternion_idxs: + self.normalize_slice(idx, idx+4) + + def normalize_slice(self, slice_start, slice_end_ex): + self.x[slice_start:slice_end_ex] /= np.linalg.norm(self.x[slice_start:slice_end_ex]) + + def get_augment_times(self): + return self.augment_times + + def set_global(self, global_var, val): + self.set_globals[global_var](val) + + 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.normalize_quaternions() + 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: + self.logger.error("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) + self.normalize_quaternions() + 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]: + self.logger.warning('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/ekf_sym_pyx.pyx b/rednose/helpers/ekf_sym_pyx.pyx new file mode 100644 index 00000000000000..a5c0d56811e40d --- /dev/null +++ b/rednose/helpers/ekf_sym_pyx.pyx @@ -0,0 +1,190 @@ +# cython: language_level=3 +# cython: profile=True +# distutils: language = c++ + +cimport cython + +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp cimport bool +cimport numpy as np + +import numpy as np + +cdef extern from "" namespace "std" nogil: + cdef cppclass optional[T]: + ctypedef T value_type + bool has_value() + T& value() + +cdef extern from "rednose/helpers/ekf_sym.h" namespace "EKFS": + cdef cppclass MapVectorXd "Eigen::Map": + MapVectorXd(double*, int) + + cdef cppclass MapMatrixXdr "Eigen::Map >": + MapMatrixXdr(double*, int, int) + + cdef cppclass VectorXd "Eigen::VectorXd": + VectorXd() + double* data() + int rows() + + cdef cppclass MatrixXdr "Eigen::Matrix": + MatrixXdr() + double* data() + int rows() + int cols() + + ctypedef struct Estimate: + VectorXd xk1 + VectorXd xk + MatrixXdr Pk1 + MatrixXdr Pk + double t + int kind + vector[VectorXd] y + vector[VectorXd] z + vector[vector[double]] extra_args + + cdef cppclass EKFSym: + EKFSym(string name, MapMatrixXdr Q, MapVectorXd x_initial, MapMatrixXdr P_initial, int dim_main, + int dim_main_err, int N, int dim_augment, int dim_augment_err, vector[int] maha_test_kinds, + vector[int] quaternion_idxs, vector[string] global_vars, double max_rewind_age) + void init_state(MapVectorXd state, MapMatrixXdr covs, double filter_time) + + VectorXd state() + MatrixXdr covs() + void set_filter_time(double t) + double get_filter_time() + void set_global(string name, double val) + void reset_rewind() + + void predict(double t) + optional[Estimate] predict_and_update_batch(double t, int kind, vector[MapVectorXd] z, vector[MapMatrixXdr] z, + vector[vector[double]] extra_args, bool augment) + +# Functions like `numpy_to_matrix` are not possible, cython requires default +# constructor for return variable types which aren't available with Eigen::Map + +@cython.wraparound(False) +@cython.boundscheck(False) +cdef np.ndarray[np.float64_t, ndim=2, mode="c"] matrix_to_numpy(MatrixXdr arr): + cdef double[:,:] mem_view = arr.data() + return np.copy(np.asarray(mem_view, dtype=np.double, order="C")) + +@cython.wraparound(False) +@cython.boundscheck(False) +cdef np.ndarray[np.float64_t, ndim=1, mode="c"] vector_to_numpy(VectorXd arr): + cdef double[:] mem_view = arr.data() + return np.copy(np.asarray(mem_view, dtype=np.double, order="C")) + +cdef class EKF_sym: + cdef EKFSym* ekf + def __cinit__(self, str gen_dir, str name, np.ndarray[np.float64_t, ndim=2] Q, + np.ndarray[np.float64_t, ndim=1] x_initial, np.ndarray[np.float64_t, ndim=2] P_initial, int dim_main, + int dim_main_err, int N=0, int dim_augment=0, int dim_augment_err=0, list maha_test_kinds=[], + list quaternion_idxs=[], list global_vars=[], double max_rewind_age=1.0, logger=None): + # TODO logger + + cdef np.ndarray[np.float64_t, ndim=2, mode='c'] Q_b = np.ascontiguousarray(Q, dtype=np.double) + cdef np.ndarray[np.float64_t, ndim=1, mode='c'] x_initial_b = np.ascontiguousarray(x_initial, dtype=np.double) + cdef np.ndarray[np.float64_t, ndim=2, mode='c'] P_initial_b = np.ascontiguousarray(P_initial, dtype=np.double) + self.ekf = new EKFSym( + name.encode('utf8'), + MapMatrixXdr( Q_b.data, Q.shape[0], Q.shape[1]), + MapVectorXd( x_initial_b.data, x_initial.shape[0]), + MapMatrixXdr( P_initial_b.data, P_initial.shape[0], P_initial.shape[1]), + dim_main, + dim_main_err, + N, + dim_augment, + dim_augment_err, + maha_test_kinds, + quaternion_idxs, + [x.encode('utf8') for x in global_vars], + max_rewind_age + ) + + def init_state(self, np.ndarray[np.float64_t, ndim=1] state, np.ndarray[np.float64_t, ndim=2] covs, filter_time): + cdef np.ndarray[np.float64_t, ndim=1, mode='c'] state_b = np.ascontiguousarray(state, dtype=np.double) + cdef np.ndarray[np.float64_t, ndim=2, mode='c'] covs_b = np.ascontiguousarray(covs, dtype=np.double) + self.ekf.init_state( + MapVectorXd( state_b.data, state.shape[0]), + MapMatrixXdr( covs_b.data, covs.shape[0], covs.shape[1]), + np.nan if filter_time is None else filter_time + ) + + def state(self): + cdef np.ndarray res = vector_to_numpy(self.ekf.state()) + return res + + def covs(self): + return matrix_to_numpy(self.ekf.covs()) + + def set_filter_time(self, double t): + self.ekf.set_filter_time(t) + + def get_filter_time(self): + return self.ekf.get_filter_time() + + def set_global(self, str global_var, double val): + self.ekf.set_global(global_var.encode('utf8'), val) + + def reset_rewind(self): + self.ekf.reset_rewind() + + def predict(self, double t): + self.ekf.predict(t) + + def predict_and_update_batch(self, double t, int kind, z, R, extra_args=[[]], bool augment=False): + cdef vector[MapVectorXd] z_map + cdef np.ndarray[np.float64_t, ndim=1, mode='c'] zi_b + for zi in z: + zi_b = np.ascontiguousarray(zi, dtype=np.double) + z_map.push_back(MapVectorXd( zi_b.data, zi.shape[0])) + + cdef vector[MapMatrixXdr] R_map + cdef np.ndarray[np.float64_t, ndim=2, mode='c'] Ri_b + for Ri in R: + Ri_b = np.ascontiguousarray(Ri, dtype=np.double) + R_map.push_back(MapMatrixXdr( Ri_b.data, Ri.shape[0], Ri.shape[1])) + + cdef vector[vector[double]] extra_args_map + cdef vector[double] args_map + for args in extra_args: + args_map.clear() + for a in args: + args_map.push_back(a) + extra_args_map.push_back(args_map) + + cdef optional[Estimate] res = self.ekf.predict_and_update_batch(t, kind, z_map, R_map, extra_args_map, augment) + if not res.has_value(): + return None + + cdef VectorXd tmpvec + return ( + vector_to_numpy(res.value().xk1), + vector_to_numpy(res.value().xk), + matrix_to_numpy(res.value().Pk1), + matrix_to_numpy(res.value().Pk), + res.value().t, + res.value().kind, + [vector_to_numpy(tmpvec) for tmpvec in res.value().y], + z, # TODO: take return values? + extra_args, + ) + + def augment(self): + raise NotImplementedError() # TODO + + def get_augment_times(self): + raise NotImplementedError() # TODO + + def rts_smooth(self, estimates, norm_quats=False): + raise NotImplementedError() # TODO + + def maha_test(self, x, P, kind, z, R, extra_args=[], maha_thresh=0.95): + raise NotImplementedError() # TODO + + def __dealloc__(self): + del self.ekf diff --git a/rednose/helpers/feature_handler.py b/rednose/helpers/feature_handler.py new file mode 100755 index 00000000000000..6a20b85e1c7b06 --- /dev/null +++ b/rednose/helpers/feature_handler.py @@ -0,0 +1,160 @@ +#!/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 += "extern \"C\" {\n" + c_code += "\n" + open(os.path.join(TEMPLATE_DIR, "feature_handler.c")).read() + c_code += "\n}\n" + + 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/kalmanfilter.py b/rednose/helpers/kalmanfilter.py new file mode 100644 index 00000000000000..0c30e491642684 --- /dev/null +++ b/rednose/helpers/kalmanfilter.py @@ -0,0 +1,51 @@ +from typing import Any, Dict + +import numpy as np + + +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] = {} + + filter = None # Should be initialized when initializating a KalmanFilter implementation + + @property + def x(self): + return self.filter.state() + + @property + def t(self): + return self.filter.get_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/lst_sq_computer.py b/rednose/helpers/lst_sq_computer.py new file mode 100755 index 00000000000000..56c3bc8c419ee6 --- /dev/null +++ b/rednose/helpers/lst_sq_computer.py @@ -0,0 +1,175 @@ +#!/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, sympy_code = sympy_into_c(sympy_functions) + + code = "\n#include \"rednose/helpers/common_ekf.h\"\n" + code += "\n#define KDIM %d\n" % K + code += "extern \"C\" {\n" + code += sympy_code + code += "\n" + open(os.path.join(TEMPLATE_DIR, "compute_pos.c")).read() + "\n" + code += "}\n" + + header += "\nvoid compute_pos(double *to_c, double *in_poses, double *in_img_positions, double *param, double *pos);\n" + + 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..716e94e0187abe --- /dev/null +++ b/rednose/helpers/sympy_helpers.py @@ -0,0 +1,155 @@ +#!/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] != '#') + + return c_header, c_code diff --git a/rednose/logger/logger.h b/rednose/logger/logger.h new file mode 100644 index 00000000000000..e21509352f76db --- /dev/null +++ b/rednose/logger/logger.h @@ -0,0 +1,20 @@ +#pragma once + +#ifdef SWAGLOG +#include "selfdrive/common/swaglog.h" +#else + +#define CLOUDLOG_DEBUG 10 +#define CLOUDLOG_INFO 20 +#define CLOUDLOG_WARNING 30 +#define CLOUDLOG_ERROR 40 +#define CLOUDLOG_CRITICAL 50 + +#define cloudlog(lvl, fmt, ...) printf(fmt "\n", ## __VA_ARGS__) + +#define LOGD(fmt, ...) cloudlog(CLOUDLOG_DEBUG, fmt, ## __VA_ARGS__) +#define LOG(fmt, ...) cloudlog(CLOUDLOG_INFO, fmt, ## __VA_ARGS__) +#define LOGW(fmt, ...) cloudlog(CLOUDLOG_WARNING, fmt, ## __VA_ARGS__) +#define LOGE(fmt, ...) cloudlog(CLOUDLOG_ERROR, fmt, ## __VA_ARGS__) + +#endif diff --git a/rednose/templates/compute_pos.c b/rednose/templates/compute_pos.c new file mode 100644 index 00000000000000..742c7d618701f4 --- /dev/null +++ b/rednose/templates/compute_pos.c @@ -0,0 +1,52 @@ +#include +#include +#include + +typedef Eigen::Matrix R3M; +typedef Eigen::Matrix R1M; +typedef Eigen::Matrix O1M; +typedef Eigen::Matrix M3D; + +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..9c580c2eac6d56 --- /dev/null +++ b/rednose/templates/feature_handler.c @@ -0,0 +1,56 @@ +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_devel.sh b/release/build_devel.sh new file mode 100755 index 00000000000000..db8c69bd7a6184 --- /dev/null +++ b/release/build_devel.sh @@ -0,0 +1,70 @@ +#!/usr/bin/bash -e + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" + +TARGET_DIR=/data/openpilot +SOURCE_DIR="$(git rev-parse --show-toplevel)" + +# set git identity +source $DIR/identity.sh + +echo "[-] Setting up repo T=$SECONDS" +if [ ! -d "$TARGET_DIR" ]; then + mkdir -p $TARGET_DIR + cd $TARGET_DIR + git init + git remote add origin git@github.com:commaai/openpilot.git +fi + +echo "[-] bringing master-ci and devel in sync T=$SECONDS" +cd $TARGET_DIR +git prune || true +git remote prune origin || true +git fetch origin master-ci +git fetch origin devel + +git checkout -f --track origin/master-ci +git reset --hard master-ci +git checkout master-ci +git reset --hard origin/devel +git clean -xdf + +# remove everything except .git +echo "[-] erasing old openpilot T=$SECONDS" +find . -maxdepth 1 -not -path './.git' -not -name '.' -not -name '..' -exec rm -rf '{}' \; + +# reset source tree +cd $SOURCE_DIR +git clean -xdf + +# do the files copy +echo "[-] copying files T=$SECONDS" +cd $SOURCE_DIR +cp -pR --parents $(cat release/files_common) $TARGET_DIR/ +cp -pR --parents $(cat release/files_tici) $TARGET_DIR/ +if [ ! -z "$EXTRA_FILES" ]; then + cp -pR --parents $EXTRA_FILES $TARGET_DIR/ +fi + +# append source commit hash and build date to version +GIT_HASH=$(git --git-dir=$SOURCE_DIR/.git rev-parse --short HEAD) +DATETIME=$(date '+%Y-%m-%dT%H:%M:%S') +VERSION=$(cat selfdrive/common/version.h | awk -F\" '{print $2}') +echo "#define COMMA_VERSION \"$VERSION-$GIT_HASH-$DATETIME\"" > selfdrive/common/version.h + +# in the directory +cd $TARGET_DIR +rm -f panda/board/obj/panda.bin.signed + +echo "[-] committing version $VERSION T=$SECONDS" +git add -f . +git status +git commit -a -m "openpilot v$VERSION release" + +if [ ! -z "$PUSH" ]; then + echo "[-] Pushing to $PUSH T=$SECONDS" + git remote set-url origin git@github.com:commaai/openpilot.git + git push -f origin master-ci:$PUSH +fi + +echo "[-] done T=$SECONDS" diff --git a/release/build_release.sh b/release/build_release.sh new file mode 100755 index 00000000000000..95fcfea1a1bbac --- /dev/null +++ b/release/build_release.sh @@ -0,0 +1,118 @@ +#!/usr/bin/bash -e + +# git diff --name-status origin/release3-staging | grep "^A" | less + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" + +cd $DIR + +BUILD_DIR=/data/openpilot +SOURCE_DIR="$(git rev-parse --show-toplevel)" + +if [ -f /TICI ]; then + FILES_SRC="release/files_tici" + RELEASE_BRANCH=release3-staging + DASHCAM_BRANCH=dashcam3-staging +elif [ -f /EON ]; then + FILES_SRC="release/files_eon" + RELEASE_BRANCH=release2-staging + DASHCAM_BRANCH=dashcam-staging +else + exit 0 +fi + +# set git identity +source $DIR/identity.sh + +echo "[-] Setting up repo T=$SECONDS" +rm -rf $BUILD_DIR +mkdir -p $BUILD_DIR +cd $BUILD_DIR +git init +git remote add origin git@github.com:commaai/openpilot.git +git fetch origin $RELEASE_BRANCH +git checkout --orphan $RELEASE_BRANCH + +# do the files copy +echo "[-] copying files T=$SECONDS" +cd $SOURCE_DIR +cp -pR --parents $(cat release/files_common) $BUILD_DIR/ +cp -pR --parents $(cat $FILES_SRC) $BUILD_DIR/ + +# in the directory +cd $BUILD_DIR + +rm -f panda/board/obj/panda.bin.signed + +VERSION=$(cat selfdrive/common/version.h | awk -F[\"-] '{print $2}') +echo "#define COMMA_VERSION \"$VERSION-release\"" > selfdrive/common/version.h + +echo "[-] committing version $VERSION T=$SECONDS" +git add -f . +git commit -a -m "openpilot v$VERSION release" +git branch --set-upstream-to=origin/$RELEASE_BRANCH + +# Build panda firmware +pushd panda/ +CERT=/data/pandaextra/certs/release RELEASE=1 scons -u . +mv board/obj/panda.bin.signed /tmp/panda.bin.signed +popd + +# Build +export PYTHONPATH="$BUILD_DIR" +scons -j$(nproc) + +# Ensure no submodules in release +if test "$(git submodule--helper list | wc -l)" -gt "0"; then + echo "submodules found:" + git submodule--helper list + exit 1 +fi +git submodule status + +# Cleanup +find . -name '*.a' -delete +find . -name '*.o' -delete +find . -name '*.os' -delete +find . -name '*.pyc' -delete +find . -name 'moc_*' -delete +find . -name '__pycache__' -delete +rm -rf panda/board panda/certs panda/crypto +rm -rf .sconsign.dblite Jenkinsfile release/ +rm models/supercombo.dlc + +# Move back signed panda fw +mkdir -p panda/board/obj +mv /tmp/panda.bin.signed panda/board/obj/panda.bin.signed + +# Restore third_party +git checkout third_party/ + +# Mark as prebuilt release +touch prebuilt + +# Add built files to git +git add -f . +git commit --amend -m "openpilot v$VERSION" + +# Run tests +TEST_FILES="tools/" +cd $SOURCE_DIR +cp -pR -n --parents $TEST_FILES $BUILD_DIR/ +cd $BUILD_DIR +RELEASE=1 selfdrive/test/test_onroad.py +#selfdrive/manager/test/test_manager.py +selfdrive/car/tests/test_car_interfaces.py +rm -rf $TEST_FILES + +if [ ! -z "$PUSH" ]; then + echo "[-] pushing T=$SECONDS" + git push -f origin $RELEASE_BRANCH + + # Create dashcam + git rm selfdrive/car/*/carcontroller.py + git commit -m "create dashcam release from release" + git push -f origin $RELEASE_BRANCH:$DASHCAM_BRANCH +fi + +echo "[-] done T=$SECONDS" diff --git a/release/check-submodules.sh b/release/check-submodules.sh new file mode 100755 index 00000000000000..182042e6b4918d --- /dev/null +++ b/release/check-submodules.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +while read hash submodule ref; do + git -C $submodule fetch --depth 100 origin master + git -C $submodule branch -r --contains $hash | grep "origin/master" + if [ "$?" -eq 0 ]; then + echo "$submodule ok" + else + echo "$submodule: $hash is not on master" + exit 1 + fi +done <<< $(git submodule status --recursive) diff --git a/release/files_common b/release/files_common new file mode 100644 index 00000000000000..3fc354396a220c --- /dev/null +++ b/release/files_common @@ -0,0 +1,615 @@ +.gitignore +LICENSE +launch_env.sh +launch_chffrplus.sh +launch_openpilot.sh + +Jenkinsfile +SConstruct + +README.md +RELEASES.md +docs/CARS.md +docs/CONTRIBUTING.md +docs/INTEGRATION.md +docs/LIMITATIONS.md +site_scons/site_tools/cython.py + +common/.gitignore +common/__init__.py +common/gpio.py +common/realtime.py +common/clock.pyx +common/timeout.py +common/ffi_wrapper.py +common/file_helpers.py +common/logging_extra.py +common/numpy_fast.py +common/markdown.py +common/params.py +common/params_pyx.pyx +common/xattr.py +common/profiler.py +common/basedir.py +common/dict_helpers.py +common/filter_simple.py +common/stat_live.py +common/spinner.py +common/text_window.py +common/SConscript + +common/kalman/.gitignore +common/kalman/* + +common/transformations/__init__.py +common/transformations/camera.py +common/transformations/model.py + +common/transformations/SConscript +common/transformations/coordinates.py +common/transformations/coordinates.cc +common/transformations/coordinates.hpp +common/transformations/orientation.py +common/transformations/orientation.cc +common/transformations/orientation.hpp +common/transformations/transformations.pxd +common/transformations/transformations.pyx + +common/api/__init__.py + +models/supercombo.dlc +models/dmonitoring_model_q.dlc + +release/* + +tools/lib/* + +installer/updater/updater + +selfdrive/version.py + +selfdrive/__init__.py +selfdrive/config.py +selfdrive/crash.py +selfdrive/swaglog.py +selfdrive/logmessaged.py +selfdrive/tombstoned.py +selfdrive/pandad.py +selfdrive/updated.py +selfdrive/rtshield.py + +selfdrive/athena/__init__.py +selfdrive/athena/athenad.py +selfdrive/athena/manage_athenad.py +selfdrive/athena/registration.py + +selfdrive/boardd/.gitignore +selfdrive/boardd/SConscript +selfdrive/boardd/__init__.py +selfdrive/boardd/boardd.cc +selfdrive/boardd/boardd.py +selfdrive/boardd/boardd_api_impl.pyx +selfdrive/boardd/can_list_to_can_capnp.cc +selfdrive/boardd/panda.cc +selfdrive/boardd/panda.h +selfdrive/boardd/pigeon.cc +selfdrive/boardd/pigeon.h +selfdrive/boardd/set_time.py + +selfdrive/car/__init__.py +selfdrive/car/car_helpers.py +selfdrive/car/fingerprints.py +selfdrive/car/interfaces.py +selfdrive/car/vin.py +selfdrive/car/disable_ecu.py +selfdrive/car/fw_versions.py +selfdrive/car/isotp_parallel_query.py +selfdrive/car/tests/__init__.py +selfdrive/car/tests/test_car_interfaces.py +selfdrive/car/chrysler/__init__.py +selfdrive/car/chrysler/carstate.py +selfdrive/car/chrysler/interface.py +selfdrive/car/chrysler/radar_interface.py +selfdrive/car/chrysler/values.py +selfdrive/car/chrysler/carcontroller.py +selfdrive/car/chrysler/chryslercan.py +selfdrive/car/honda/__init__.py +selfdrive/car/honda/carstate.py +selfdrive/car/honda/interface.py +selfdrive/car/honda/radar_interface.py +selfdrive/car/honda/values.py +selfdrive/car/honda/carcontroller.py +selfdrive/car/honda/hondacan.py +selfdrive/car/hyundai/__init__.py +selfdrive/car/hyundai/carstate.py +selfdrive/car/hyundai/interface.py +selfdrive/car/hyundai/radar_interface.py +selfdrive/car/hyundai/values.py +selfdrive/car/hyundai/carcontroller.py +selfdrive/car/hyundai/hyundaican.py +selfdrive/car/toyota/__init__.py +selfdrive/car/toyota/carstate.py +selfdrive/car/toyota/tunes.py +selfdrive/car/toyota/interface.py +selfdrive/car/toyota/radar_interface.py +selfdrive/car/toyota/values.py +selfdrive/car/toyota/carcontroller.py +selfdrive/car/toyota/toyotacan.py +selfdrive/car/nissan/__init__.py +selfdrive/car/nissan/carcontroller.py +selfdrive/car/nissan/carstate.py +selfdrive/car/nissan/interface.py +selfdrive/car/nissan/nissancan.py +selfdrive/car/nissan/radar_interface.py +selfdrive/car/nissan/values.py +selfdrive/car/volkswagen/__init__.py +selfdrive/car/volkswagen/carstate.py +selfdrive/car/volkswagen/interface.py +selfdrive/car/volkswagen/radar_interface.py +selfdrive/car/volkswagen/values.py +selfdrive/car/volkswagen/carcontroller.py +selfdrive/car/volkswagen/volkswagencan.py +selfdrive/car/gm/__init__.py +selfdrive/car/gm/carstate.py +selfdrive/car/gm/interface.py +selfdrive/car/gm/radar_interface.py +selfdrive/car/gm/values.py +selfdrive/car/gm/carcontroller.py +selfdrive/car/gm/gmcan.py +selfdrive/car/ford/__init__.py +selfdrive/car/ford/carstate.py +selfdrive/car/ford/interface.py +selfdrive/car/ford/radar_interface.py +selfdrive/car/ford/values.py +selfdrive/car/ford/carcontroller.py +selfdrive/car/ford/fordcan.py +selfdrive/car/subaru/__init__.py +selfdrive/car/subaru/carstate.py +selfdrive/car/subaru/interface.py +selfdrive/car/subaru/radar_interface.py +selfdrive/car/subaru/values.py +selfdrive/car/subaru/carcontroller.py +selfdrive/car/subaru/subarucan.py +selfdrive/car/mazda/__init__.py +selfdrive/car/mazda/carstate.py +selfdrive/car/mazda/interface.py +selfdrive/car/mazda/radar_interface.py +selfdrive/car/mazda/values.py +selfdrive/car/mazda/carcontroller.py +selfdrive/car/mazda/mazdacan.py +selfdrive/car/tesla/__init__.py +selfdrive/car/tesla/teslacan.py +selfdrive/car/tesla/carcontroller.py +selfdrive/car/tesla/radar_interface.py +selfdrive/car/tesla/values.py +selfdrive/car/tesla/carstate.py +selfdrive/car/tesla/interface.py +selfdrive/car/mock/*.py + +selfdrive/clocksd/.gitignore +selfdrive/clocksd/SConscript +selfdrive/clocksd/clocksd.cc + +selfdrive/debug/*.py + +selfdrive/common/SConscript +selfdrive/common/version.h + +selfdrive/common/swaglog.h +selfdrive/common/swaglog.cc +selfdrive/common/util.cc +selfdrive/common/util.h +selfdrive/common/queue.h +selfdrive/common/clutil.cc +selfdrive/common/clutil.h +selfdrive/common/params.h +selfdrive/common/params.cc +selfdrive/common/watchdog.cc +selfdrive/common/watchdog.h + +selfdrive/common/modeldata.h +selfdrive/common/mat.h +selfdrive/common/timing.h + +selfdrive/common/visionimg.cc +selfdrive/common/visionimg.h + +selfdrive/common/gpio.cc +selfdrive/common/gpio.h +selfdrive/common/i2c.cc +selfdrive/common/i2c.h + + +selfdrive/controls/__init__.py +selfdrive/controls/controlsd.py +selfdrive/controls/plannerd.py +selfdrive/controls/radard.py +selfdrive/controls/lib/__init__.py +selfdrive/controls/lib/alertmanager.py +selfdrive/controls/lib/alerts_offroad.json +selfdrive/controls/lib/events.py +selfdrive/controls/lib/drive_helpers.py +selfdrive/controls/lib/latcontrol_pid.py +selfdrive/controls/lib/latcontrol_indi.py +selfdrive/controls/lib/latcontrol_lqr.py +selfdrive/controls/lib/latcontrol_angle.py +selfdrive/controls/lib/longcontrol.py +selfdrive/controls/lib/lateral_planner.py +selfdrive/controls/lib/lane_planner.py +selfdrive/controls/lib/pid.py +selfdrive/controls/lib/longitudinal_planner.py +selfdrive/controls/lib/radar_helpers.py +selfdrive/controls/lib/vehicle_model.py + +selfdrive/controls/lib/cluster/* + +selfdrive/controls/lib/lateral_mpc_lib/.gitignore +selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore +selfdrive/controls/lib/lateral_mpc_lib/* +selfdrive/controls/lib/longitudinal_mpc_lib/* + +selfdrive/hardware/__init__.py +selfdrive/hardware/base.h +selfdrive/hardware/base.py +selfdrive/hardware/hw.h +selfdrive/hardware/eon/__init__.py +selfdrive/hardware/eon/androidd.py +selfdrive/hardware/eon/hardware.h +selfdrive/hardware/eon/hardware.py +selfdrive/hardware/eon/neos.py +selfdrive/hardware/eon/neos.json +selfdrive/hardware/eon/updater +selfdrive/hardware/tici/__init__.py +selfdrive/hardware/tici/hardware.py +selfdrive/hardware/tici/amplifier.py +selfdrive/hardware/tici/iwlist.py +selfdrive/hardware/pc/__init__.py +selfdrive/hardware/pc/hardware.py + +selfdrive/locationd/__init__.py +selfdrive/locationd/.gitignore +selfdrive/locationd/SConscript +selfdrive/locationd/ubloxd.cc +selfdrive/locationd/ublox_msg.cc +selfdrive/locationd/ublox_msg.h +selfdrive/locationd/generated/ubx.cpp +selfdrive/locationd/generated/ubx.h +selfdrive/locationd/generated/gps.cpp +selfdrive/locationd/generated/gps.h + +selfdrive/locationd/locationd.h +selfdrive/locationd/locationd.cc +selfdrive/locationd/paramsd.py +selfdrive/locationd/models/.gitignore +selfdrive/locationd/models/live_kf.py +selfdrive/locationd/models/car_kf.py +selfdrive/locationd/models/constants.py +selfdrive/locationd/models/live_kf.h +selfdrive/locationd/models/live_kf.cc + +selfdrive/locationd/calibrationd.py + +selfdrive/logcatd/SConscript +selfdrive/logcatd/logcatd_android.cc +selfdrive/logcatd/logcatd_systemd.cc + +selfdrive/proclogd/SConscript +selfdrive/proclogd/main.cc +selfdrive/proclogd/proclog.cc +selfdrive/proclogd/proclog.h + +selfdrive/loggerd/SConscript +selfdrive/loggerd/encoder.h +selfdrive/loggerd/omx_encoder.cc +selfdrive/loggerd/omx_encoder.h +selfdrive/loggerd/logger.cc +selfdrive/loggerd/logger.h +selfdrive/loggerd/loggerd.cc +selfdrive/loggerd/loggerd.h +selfdrive/loggerd/main.cc +selfdrive/loggerd/bootlog.cc +selfdrive/loggerd/raw_logger.cc +selfdrive/loggerd/raw_logger.h +selfdrive/loggerd/include/msm_media_info.h + +selfdrive/loggerd/__init__.py +selfdrive/loggerd/config.py +selfdrive/loggerd/uploader.py +selfdrive/loggerd/deleter.py +selfdrive/loggerd/xattr_cache.py + +selfdrive/sensord/SConscript +selfdrive/sensord/libdiag.h +selfdrive/sensord/sensors_qcom.cc +selfdrive/sensord/sensors_qcom2.cc +selfdrive/sensord/sensors/*.cc +selfdrive/sensord/sensors/*.h +selfdrive/sensord/sensord + +selfdrive/thermald/thermald.py +selfdrive/thermald/power_monitoring.py + +selfdrive/test/__init__.py +selfdrive/test/helpers.py +selfdrive/test/setup_device_ci.sh +selfdrive/test/test_fingerprints.py +selfdrive/test/test_onroad.py + +selfdrive/ui/.gitignore +selfdrive/ui/SConscript +selfdrive/ui/*.cc +selfdrive/ui/*.h +selfdrive/ui/ui +selfdrive/ui/text +selfdrive/ui/spinner +selfdrive/ui/soundd/*.cc +selfdrive/ui/soundd/*.h +selfdrive/ui/soundd/soundd +selfdrive/ui/soundd/.gitignore + +selfdrive/ui/qt/*.cc +selfdrive/ui/qt/*.h +selfdrive/ui/qt/offroad/*.cc +selfdrive/ui/qt/offroad/*.h +selfdrive/ui/qt/offroad/*.qml +selfdrive/ui/qt/widgets/*.cc +selfdrive/ui/qt/widgets/*.h +selfdrive/ui/qt/spinner_aarch64 +selfdrive/ui/qt/text_aarch64 + +selfdrive/ui/replay/*.cc +selfdrive/ui/replay/*.h + +selfdrive/camerad/SConscript +selfdrive/camerad/main.cc + +selfdrive/camerad/snapshot/* +selfdrive/camerad/include/* +selfdrive/camerad/cameras/camera_common.h +selfdrive/camerad/cameras/camera_common.cc +selfdrive/camerad/cameras/camera_qcom.cc +selfdrive/camerad/cameras/camera_qcom.h +selfdrive/camerad/cameras/camera_replay.cc +selfdrive/camerad/cameras/camera_replay.h +selfdrive/camerad/cameras/debayer.cl +selfdrive/camerad/cameras/sensor_i2c.h +selfdrive/camerad/cameras/sensor2_i2c.h + +selfdrive/camerad/transforms/rgb_to_yuv.cc +selfdrive/camerad/transforms/rgb_to_yuv.h +selfdrive/camerad/transforms/rgb_to_yuv.cl +selfdrive/camerad/transforms/rgb_to_yuv_test.cc + +selfdrive/camerad/imgproc/conv.cl +selfdrive/camerad/imgproc/pool.cl +selfdrive/camerad/imgproc/utils.cc +selfdrive/camerad/imgproc/utils.h + +selfdrive/manager/__init__.py +selfdrive/manager/build.py +selfdrive/manager/helpers.py +selfdrive/manager/manager.py +selfdrive/manager/process_config.py +selfdrive/manager/process.py +selfdrive/manager/test/__init__.py +selfdrive/manager/test/test_manager.py + +selfdrive/modeld/SConscript +selfdrive/modeld/modeld.cc +selfdrive/modeld/dmonitoringmodeld.cc +selfdrive/modeld/constants.py +selfdrive/modeld/modeld +selfdrive/modeld/dmonitoringmodeld + +selfdrive/modeld/models/commonmodel.cc +selfdrive/modeld/models/commonmodel.h +selfdrive/modeld/models/driving.cc +selfdrive/modeld/models/driving.h +selfdrive/modeld/models/dmonitoring.cc +selfdrive/modeld/models/dmonitoring.h + +selfdrive/modeld/transforms/loadyuv.cc +selfdrive/modeld/transforms/loadyuv.h +selfdrive/modeld/transforms/loadyuv.cl +selfdrive/modeld/transforms/transform.cc +selfdrive/modeld/transforms/transform.h +selfdrive/modeld/transforms/transform.cl + +selfdrive/modeld/thneed/thneed.* +selfdrive/modeld/thneed/serialize.cc +selfdrive/modeld/thneed/compile.cc +selfdrive/modeld/thneed/include/* + +selfdrive/modeld/runners/snpemodel.cc +selfdrive/modeld/runners/snpemodel.h +selfdrive/modeld/runners/thneedmodel.cc +selfdrive/modeld/runners/thneedmodel.h +selfdrive/modeld/runners/runmodel.h +selfdrive/modeld/runners/run.h + +selfdrive/monitoring/dmonitoringd.py +selfdrive/monitoring/driver_monitor.py + +selfdrive/assets/.gitignore +selfdrive/assets/assets.qrc +selfdrive/assets/*.png +selfdrive/assets/*.svg +selfdrive/assets/fonts/*.ttf +selfdrive/assets/icons/* +selfdrive/assets/images/* +selfdrive/assets/offroad/* +selfdrive/assets/sounds/* +selfdrive/assets/training/* + +third_party/SConscript + +third_party/libgralloc/** +third_party/linux/** +third_party/opencl/** +third_party/zlib/* +third_party/bzip2/* +third_party/openmax/** + +third_party/json11/json11.cpp +third_party/json11/json11.hpp + +third_party/qrcode/*.cc +third_party/qrcode/*.hpp + +third_party/kaitai/*.h +third_party/kaitai/*.cpp + +third_party/libyuv/include/** +third_party/libyuv/lib/** +third_party/libyuv/larch64/** + +third_party/snpe/include/** +third_party/snpe/aarch64** +third_party/snpe/larch64** +third_party/snpe/dsp** + +third_party/acados/x86_64/** +third_party/acados/aarch64/** +third_party/acados/larch64/** +third_party/acados/include/** + +third_party/android_frameworks_native/** +third_party/android_hardware_libhardware/** +third_party/android_system_core/** + +scripts/update_now.sh +scripts/stop_updater.sh + +pyextra/.gitignore +pyextra/acados_template/** + +rednose/** + +cereal/.gitignore +cereal/__init__.py +cereal/car.capnp +cereal/legacy.capnp +cereal/log.capnp +cereal/services.py +cereal/SConscript +cereal/include/** +cereal/logger/logger.h +cereal/messaging/.gitignore +cereal/messaging/__init__.py +cereal/messaging/bridge.cc +cereal/messaging/impl_msgq.cc +cereal/messaging/impl_msgq.h +cereal/messaging/impl_zmq.cc +cereal/messaging/impl_zmq.h +cereal/messaging/messaging.cc +cereal/messaging/messaging.h +cereal/messaging/messaging.pxd +cereal/messaging/messaging_pyx.pyx +cereal/messaging/msgq.cc +cereal/messaging/msgq.h +cereal/messaging/socketmaster.cc +cereal/visionipc/.gitignore +cereal/visionipc/__init__.py +cereal/visionipc/*.cc +cereal/visionipc/*.h +cereal/visionipc/*.pyx +cereal/visionipc/*.pxd + +panda/.gitignore +panda/__init__.py +panda/board/** +panda/certs/** +panda/crypto/** +panda/examples/query_fw_versions.py +panda/python/** + +opendbc/.gitignore +opendbc/__init__.py +opendbc/can/__init__.py +opendbc/can/SConscript +opendbc/can/can_define.py +opendbc/can/common.cc +opendbc/can/common.h +opendbc/can/common.pxd +opendbc/can/common_dbc.h +opendbc/can/dbc.cc +opendbc/can/dbc.py +opendbc/can/dbc_template.cc +opendbc/can/packer.cc +opendbc/can/packer.py +opendbc/can/packer_pyx.pyx +opendbc/can/parser.cc +opendbc/can/parser.py +opendbc/can/parser_pyx.pyx +opendbc/can/process_dbc.py +opendbc/can/dbc_out/.gitkeep +opendbc/can/dbc_out/.gitignore + +opendbc/chrysler_pacifica_2017_hybrid.dbc +opendbc/chrysler_pacifica_2017_hybrid_private_fusion.dbc + +opendbc/gm_global_a_powertrain.dbc +opendbc/gm_global_a_object.dbc +opendbc/gm_global_a_chassis.dbc + +opendbc/ford_fusion_2018_pt.dbc +opendbc/ford_fusion_2018_adas.dbc + +opendbc/honda_accord_2018_can_generated.dbc +opendbc/acura_ilx_2016_can_generated.dbc +opendbc/acura_rdx_2018_can_generated.dbc +opendbc/acura_rdx_2020_can_generated.dbc +opendbc/honda_civic_touring_2016_can_generated.dbc +opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc +opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc +opendbc/honda_crv_touring_2016_can_generated.dbc +opendbc/honda_crv_ex_2017_can_generated.dbc +opendbc/honda_crv_ex_2017_body_generated.dbc +opendbc/honda_crv_executive_2016_can_generated.dbc +opendbc/honda_crv_hybrid_2019_can_generated.dbc +opendbc/honda_fit_ex_2018_can_generated.dbc +opendbc/honda_odyssey_exl_2018_generated.dbc +opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc +opendbc/honda_pilot_touring_2017_can_generated.dbc +opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc +opendbc/honda_insight_ex_2019_can_generated.dbc +opendbc/acura_ilx_2016_nidec.dbc + +opendbc/hyundai_kia_generic.dbc +opendbc/hyundai_kia_mando_front_radar.dbc + +opendbc/mazda_2017.dbc + +opendbc/nissan_x_trail_2017.dbc +opendbc/nissan_leaf_2018.dbc + +opendbc/subaru_global_2017_generated.dbc +opendbc/subaru_outback_2015_generated.dbc +opendbc/subaru_outback_2019_generated.dbc +opendbc/subaru_forester_2017_generated.dbc + +opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc +opendbc/toyota_rav4_2017_pt_generated.dbc +opendbc/toyota_prius_2017_pt_generated.dbc +opendbc/toyota_corolla_2017_pt_generated.dbc +opendbc/lexus_rx_350_2016_pt_generated.dbc +opendbc/lexus_rx_hybrid_2017_pt_generated.dbc +opendbc/toyota_nodsu_pt_generated.dbc +opendbc/toyota_nodsu_hybrid_pt_generated.dbc +opendbc/toyota_camry_hybrid_2018_pt_generated.dbc +opendbc/toyota_highlander_2017_pt_generated.dbc +opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc +opendbc/toyota_avalon_2017_pt_generated.dbc +opendbc/toyota_sienna_xle_2018_pt_generated.dbc +opendbc/lexus_is_2018_pt_generated.dbc +opendbc/lexus_ct200h_2018_pt_generated.dbc +opendbc/lexus_nx300h_2018_pt_generated.dbc +opendbc/lexus_nx300_2018_pt_generated.dbc +opendbc/toyota_adas.dbc +opendbc/toyota_tss2_adas.dbc + +opendbc/vw_mqb_2010.dbc + +opendbc/tesla_can.dbc +opendbc/tesla_radar.dbc +opendbc/tesla_powertrain.dbc diff --git a/release/files_eon b/release/files_eon new file mode 100644 index 00000000000000..b43bf86b50fd8d --- /dev/null +++ b/release/files_eon @@ -0,0 +1 @@ +README.md diff --git a/release/files_pc b/release/files_pc new file mode 100644 index 00000000000000..d00de7e47523a8 --- /dev/null +++ b/release/files_pc @@ -0,0 +1,5 @@ +selfdrive/ui/replay/* + +third_party/mapbox-gl-native-qt/x86_64/** + +third_party/qt-plugins/x86_64/** diff --git a/release/files_tici b/release/files_tici new file mode 100644 index 00000000000000..59cc41918ff983 --- /dev/null +++ b/release/files_tici @@ -0,0 +1,30 @@ +third_party/mapbox-gl-native-qt/include/* + +selfdrive/timezoned.py + +selfdrive/assets/navigation/* +selfdrive/assets/training_wide/* + +selfdrive/camerad/cameras/camera_qcom2.cc +selfdrive/camerad/cameras/camera_qcom2.h +selfdrive/camerad/cameras/real_debayer.cl + +selfdrive/hardware/tici/__init__.py +selfdrive/hardware/tici/hardware.h +selfdrive/hardware/tici/hardware.py +selfdrive/hardware/tici/pins.py +selfdrive/hardware/tici/agnos.py +selfdrive/hardware/tici/agnos.json +selfdrive/hardware/tici/amplifier.py +selfdrive/hardware/tici/updater + +selfdrive/ui/qt/spinner_larch64 +selfdrive/ui/qt/text_larch64 +selfdrive/ui/qt/maps/*.cc +selfdrive/ui/qt/maps/*.h + +selfdrive/ui/navd/*.cc +selfdrive/ui/navd/*.h +selfdrive/ui/navd/navd +selfdrive/ui/navd/.gitignore + diff --git a/release/identity.sh b/release/identity.sh new file mode 100644 index 00000000000000..b90372d825efd4 --- /dev/null +++ b/release/identity.sh @@ -0,0 +1,5 @@ +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" diff --git a/release/verify.sh b/release/verify.sh new file mode 100755 index 00000000000000..2ebd50a29dedde --- /dev/null +++ b/release/verify.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +RED="\033[0;31m" +GREEN="\033[0;32m" +CLEAR="\033[0m" + +BRANCHES="devel dashcam dashcam3 release2 release3" +for b in $BRANCHES; do + if git diff --quiet origin/$b origin/$b-staging && [ "$(git rev-parse origin/$b)" = "$(git rev-parse origin/$b-staging)" ]; then + printf "%-10s $GREEN ok $CLEAR\n" "$b" + else + printf "%-10s $RED mismatch $CLEAR\n" "$b" + fi +done diff --git a/run_docker_tests.sh b/run_docker_tests.sh deleted file mode 100755 index 10d1bbc835c3d7..00000000000000 --- a/run_docker_tests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e - -docker build -t tmppilot -f Dockerfile.openpilot . - -docker run --rm tmppilot /bin/sh -c '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' 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/.gitignore b/selfdrive/assets/.gitignore new file mode 100644 index 00000000000000..283034ca8b4104 --- /dev/null +++ b/selfdrive/assets/.gitignore @@ -0,0 +1 @@ +*.cc diff --git a/selfdrive/assets/Roboto-Bold.ttf b/selfdrive/assets/Roboto-Bold.ttf deleted file mode 100644 index a355c27cde02b1..00000000000000 Binary files a/selfdrive/assets/Roboto-Bold.ttf and /dev/null differ diff --git a/selfdrive/assets/assets.qrc b/selfdrive/assets/assets.qrc new file mode 100644 index 00000000000000..39be41aa65d56c --- /dev/null +++ b/selfdrive/assets/assets.qrc @@ -0,0 +1,17 @@ + + + img_continue_triangle.svg + img_circled_check.svg + img_circled_slash.svg + img_eye_open.svg + img_eye_closed.svg + icons/close.svg + offroad/icon_lock_closed.svg + offroad/icon_checkmark.svg + offroad/icon_warning.png + offroad/icon_wifi_strength_low.svg + offroad/icon_wifi_strength_medium.svg + offroad/icon_wifi_strength_high.svg + offroad/icon_wifi_strength_full.svg + + diff --git a/selfdrive/assets/courbd.ttf b/selfdrive/assets/courbd.ttf deleted file mode 100644 index a4f26b4b5e15c2..00000000000000 Binary files a/selfdrive/assets/courbd.ttf and /dev/null differ diff --git a/selfdrive/assets/fonts/Inter-Black.ttf b/selfdrive/assets/fonts/Inter-Black.ttf new file mode 100644 index 00000000000000..565375773523cf Binary files /dev/null and b/selfdrive/assets/fonts/Inter-Black.ttf differ diff --git a/selfdrive/assets/fonts/Inter-Bold.ttf b/selfdrive/assets/fonts/Inter-Bold.ttf new file mode 100644 index 00000000000000..e98b84ce87fa0b Binary files /dev/null and b/selfdrive/assets/fonts/Inter-Bold.ttf differ diff --git a/selfdrive/assets/fonts/Inter-ExtraBold.ttf b/selfdrive/assets/fonts/Inter-ExtraBold.ttf new file mode 100644 index 00000000000000..7f16a0f0f59479 Binary files /dev/null and b/selfdrive/assets/fonts/Inter-ExtraBold.ttf differ diff --git a/selfdrive/assets/fonts/Inter-ExtraLight.ttf b/selfdrive/assets/fonts/Inter-ExtraLight.ttf new file mode 100644 index 00000000000000..69426a3eb5660e Binary files /dev/null and b/selfdrive/assets/fonts/Inter-ExtraLight.ttf differ diff --git a/selfdrive/assets/fonts/Inter-Light.ttf b/selfdrive/assets/fonts/Inter-Light.ttf new file mode 100644 index 00000000000000..a5f073690d3ffe Binary files /dev/null and b/selfdrive/assets/fonts/Inter-Light.ttf differ diff --git a/selfdrive/assets/fonts/Inter-Medium.ttf b/selfdrive/assets/fonts/Inter-Medium.ttf new file mode 100644 index 00000000000000..721147d8311f1b Binary files /dev/null and b/selfdrive/assets/fonts/Inter-Medium.ttf differ diff --git a/selfdrive/assets/fonts/Inter-Regular.ttf b/selfdrive/assets/fonts/Inter-Regular.ttf new file mode 100644 index 00000000000000..96fd6a12d0e20d Binary files /dev/null and b/selfdrive/assets/fonts/Inter-Regular.ttf differ diff --git a/selfdrive/assets/fonts/Inter-SemiBold.ttf b/selfdrive/assets/fonts/Inter-SemiBold.ttf new file mode 100644 index 00000000000000..ddb279290ba32b Binary files /dev/null and b/selfdrive/assets/fonts/Inter-SemiBold.ttf differ diff --git a/selfdrive/assets/fonts/Inter-Thin.ttf b/selfdrive/assets/fonts/Inter-Thin.ttf new file mode 100644 index 00000000000000..76be6252b91e87 Binary files /dev/null and b/selfdrive/assets/fonts/Inter-Thin.ttf differ diff --git a/selfdrive/assets/OpenSans-Bold.ttf b/selfdrive/assets/fonts/opensans_bold.ttf similarity index 100% rename from selfdrive/assets/OpenSans-Bold.ttf rename to selfdrive/assets/fonts/opensans_bold.ttf diff --git a/selfdrive/assets/OpenSans-Regular.ttf b/selfdrive/assets/fonts/opensans_regular.ttf similarity index 100% rename from selfdrive/assets/OpenSans-Regular.ttf rename to selfdrive/assets/fonts/opensans_regular.ttf diff --git a/selfdrive/assets/OpenSans-SemiBold.ttf b/selfdrive/assets/fonts/opensans_semibold.ttf similarity index 100% rename from selfdrive/assets/OpenSans-SemiBold.ttf rename to selfdrive/assets/fonts/opensans_semibold.ttf diff --git a/selfdrive/assets/icons/close.svg b/selfdrive/assets/icons/close.svg new file mode 100644 index 00000000000000..b1e6d3b867580b --- /dev/null +++ b/selfdrive/assets/icons/close.svg @@ -0,0 +1,4 @@ + + + + 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/triangle.svg b/selfdrive/assets/images/triangle.svg new file mode 100644 index 00000000000000..9320269bde3cd5 --- /dev/null +++ b/selfdrive/assets/images/triangle.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/selfdrive/assets/img_circled_check.svg b/selfdrive/assets/img_circled_check.svg new file mode 100644 index 00000000000000..27c37395b29bda --- /dev/null +++ b/selfdrive/assets/img_circled_check.svg @@ -0,0 +1,4 @@ + + + + diff --git a/selfdrive/assets/img_circled_slash.svg b/selfdrive/assets/img_circled_slash.svg new file mode 100644 index 00000000000000..b10a3938d5d644 --- /dev/null +++ b/selfdrive/assets/img_circled_slash.svg @@ -0,0 +1,4 @@ + + + + diff --git a/selfdrive/assets/img_continue_triangle.svg b/selfdrive/assets/img_continue_triangle.svg new file mode 100644 index 00000000000000..20f9e45dcfaa9d --- /dev/null +++ b/selfdrive/assets/img_continue_triangle.svg @@ -0,0 +1,3 @@ + + + diff --git a/selfdrive/assets/img_eye_closed.svg b/selfdrive/assets/img_eye_closed.svg new file mode 100644 index 00000000000000..91b229e911bc2a --- /dev/null +++ b/selfdrive/assets/img_eye_closed.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/selfdrive/assets/img_eye_open.svg b/selfdrive/assets/img_eye_open.svg new file mode 100644 index 00000000000000..ea6e41ac54532d --- /dev/null +++ b/selfdrive/assets/img_eye_open.svg @@ -0,0 +1,4 @@ + + + + diff --git a/selfdrive/assets/img_trafficLight_green.png b/selfdrive/assets/img_trafficLight_green.png deleted file mode 100644 index b2e07dab0323cc..00000000000000 Binary files a/selfdrive/assets/img_trafficLight_green.png and /dev/null differ diff --git a/selfdrive/assets/img_trafficLight_none.png b/selfdrive/assets/img_trafficLight_none.png deleted file mode 100644 index 01deb5a009980a..00000000000000 Binary files a/selfdrive/assets/img_trafficLight_none.png and /dev/null differ diff --git a/selfdrive/assets/img_trafficLight_red.png b/selfdrive/assets/img_trafficLight_red.png deleted file mode 100644 index 4c440250e4e1c7..00000000000000 Binary files a/selfdrive/assets/img_trafficLight_red.png and /dev/null differ diff --git a/selfdrive/assets/img_trafficLight_yellow.png b/selfdrive/assets/img_trafficLight_yellow.png deleted file mode 100644 index 8dd5bd42c37a33..00000000000000 Binary files a/selfdrive/assets/img_trafficLight_yellow.png and /dev/null differ diff --git a/selfdrive/assets/img_trafficSign_stop.png b/selfdrive/assets/img_trafficSign_stop.png deleted file mode 100644 index 9261c47472e9a5..00000000000000 Binary files a/selfdrive/assets/img_trafficSign_stop.png and /dev/null differ diff --git a/selfdrive/assets/img_trafficSign_turn.png b/selfdrive/assets/img_trafficSign_turn.png deleted file mode 100644 index c304d1bf2c8e53..00000000000000 Binary files a/selfdrive/assets/img_trafficSign_turn.png and /dev/null differ diff --git a/selfdrive/assets/navigation/direction_arrive.png b/selfdrive/assets/navigation/direction_arrive.png new file mode 100644 index 00000000000000..733c1290911269 Binary files /dev/null and b/selfdrive/assets/navigation/direction_arrive.png differ diff --git a/selfdrive/assets/navigation/direction_arrive_left.png b/selfdrive/assets/navigation/direction_arrive_left.png new file mode 100644 index 00000000000000..92ff8e034141ac Binary files /dev/null and b/selfdrive/assets/navigation/direction_arrive_left.png differ diff --git a/selfdrive/assets/navigation/direction_arrive_right.png b/selfdrive/assets/navigation/direction_arrive_right.png new file mode 100644 index 00000000000000..f5983bfe61777a Binary files /dev/null and b/selfdrive/assets/navigation/direction_arrive_right.png differ diff --git a/selfdrive/assets/navigation/direction_arrive_straight.png b/selfdrive/assets/navigation/direction_arrive_straight.png new file mode 100644 index 00000000000000..733c1290911269 Binary files /dev/null and b/selfdrive/assets/navigation/direction_arrive_straight.png differ diff --git a/selfdrive/assets/navigation/direction_close.png b/selfdrive/assets/navigation/direction_close.png new file mode 100644 index 00000000000000..4fdb5d195df1c0 Binary files /dev/null and b/selfdrive/assets/navigation/direction_close.png differ diff --git a/selfdrive/assets/navigation/direction_continue.png b/selfdrive/assets/navigation/direction_continue.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_continue.png differ diff --git a/selfdrive/assets/navigation/direction_continue_left.png b/selfdrive/assets/navigation/direction_continue_left.png new file mode 100644 index 00000000000000..9a618026f0e00d Binary files /dev/null and b/selfdrive/assets/navigation/direction_continue_left.png differ diff --git a/selfdrive/assets/navigation/direction_continue_right.png b/selfdrive/assets/navigation/direction_continue_right.png new file mode 100644 index 00000000000000..0fbaa3f253edb8 Binary files /dev/null and b/selfdrive/assets/navigation/direction_continue_right.png differ diff --git a/selfdrive/assets/navigation/direction_continue_slight_left.png b/selfdrive/assets/navigation/direction_continue_slight_left.png new file mode 100644 index 00000000000000..08e964dbd6a68a Binary files /dev/null and b/selfdrive/assets/navigation/direction_continue_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_continue_slight_right.png b/selfdrive/assets/navigation/direction_continue_slight_right.png new file mode 100644 index 00000000000000..3e21cae11ed520 Binary files /dev/null and b/selfdrive/assets/navigation/direction_continue_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_continue_straight.png b/selfdrive/assets/navigation/direction_continue_straight.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_continue_straight.png differ diff --git a/selfdrive/assets/navigation/direction_continue_uturn.png b/selfdrive/assets/navigation/direction_continue_uturn.png new file mode 100644 index 00000000000000..0bd1b91777ed8d Binary files /dev/null and b/selfdrive/assets/navigation/direction_continue_uturn.png differ diff --git a/selfdrive/assets/navigation/direction_depart.png b/selfdrive/assets/navigation/direction_depart.png new file mode 100644 index 00000000000000..4bf32c870d5f26 Binary files /dev/null and b/selfdrive/assets/navigation/direction_depart.png differ diff --git a/selfdrive/assets/navigation/direction_depart_left.png b/selfdrive/assets/navigation/direction_depart_left.png new file mode 100644 index 00000000000000..1f8d726911fcb7 Binary files /dev/null and b/selfdrive/assets/navigation/direction_depart_left.png differ diff --git a/selfdrive/assets/navigation/direction_depart_right.png b/selfdrive/assets/navigation/direction_depart_right.png new file mode 100644 index 00000000000000..f359a685ffa568 Binary files /dev/null and b/selfdrive/assets/navigation/direction_depart_right.png differ diff --git a/selfdrive/assets/navigation/direction_depart_straight.png b/selfdrive/assets/navigation/direction_depart_straight.png new file mode 100644 index 00000000000000..4bf32c870d5f26 Binary files /dev/null and b/selfdrive/assets/navigation/direction_depart_straight.png differ diff --git a/selfdrive/assets/navigation/direction_end_of_road_left.png b/selfdrive/assets/navigation/direction_end_of_road_left.png new file mode 100644 index 00000000000000..5c0a24e7cb11c4 Binary files /dev/null and b/selfdrive/assets/navigation/direction_end_of_road_left.png differ diff --git a/selfdrive/assets/navigation/direction_end_of_road_right.png b/selfdrive/assets/navigation/direction_end_of_road_right.png new file mode 100644 index 00000000000000..8d9b89d36cdd61 Binary files /dev/null and b/selfdrive/assets/navigation/direction_end_of_road_right.png differ diff --git a/selfdrive/assets/navigation/direction_flag.png b/selfdrive/assets/navigation/direction_flag.png new file mode 100644 index 00000000000000..bad12ec6664679 Binary files /dev/null and b/selfdrive/assets/navigation/direction_flag.png differ diff --git a/selfdrive/assets/navigation/direction_fork.png b/selfdrive/assets/navigation/direction_fork.png new file mode 100644 index 00000000000000..3e0c262e2a2785 Binary files /dev/null and b/selfdrive/assets/navigation/direction_fork.png differ diff --git a/selfdrive/assets/navigation/direction_fork_left.png b/selfdrive/assets/navigation/direction_fork_left.png new file mode 100644 index 00000000000000..b244b42b51e906 Binary files /dev/null and b/selfdrive/assets/navigation/direction_fork_left.png differ diff --git a/selfdrive/assets/navigation/direction_fork_right.png b/selfdrive/assets/navigation/direction_fork_right.png new file mode 100644 index 00000000000000..aa3efaabca2cf7 Binary files /dev/null and b/selfdrive/assets/navigation/direction_fork_right.png differ diff --git a/selfdrive/assets/navigation/direction_fork_slight_left.png b/selfdrive/assets/navigation/direction_fork_slight_left.png new file mode 100644 index 00000000000000..82fa59859b603e Binary files /dev/null and b/selfdrive/assets/navigation/direction_fork_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_fork_slight_right.png b/selfdrive/assets/navigation/direction_fork_slight_right.png new file mode 100644 index 00000000000000..3596a2fbf2945d Binary files /dev/null and b/selfdrive/assets/navigation/direction_fork_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_fork_straight.png b/selfdrive/assets/navigation/direction_fork_straight.png new file mode 100644 index 00000000000000..86f30ab9b6edec Binary files /dev/null and b/selfdrive/assets/navigation/direction_fork_straight.png differ diff --git a/selfdrive/assets/navigation/direction_invalid.png b/selfdrive/assets/navigation/direction_invalid.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_invalid.png differ diff --git a/selfdrive/assets/navigation/direction_invalid_left.png b/selfdrive/assets/navigation/direction_invalid_left.png new file mode 100644 index 00000000000000..9a618026f0e00d Binary files /dev/null and b/selfdrive/assets/navigation/direction_invalid_left.png differ diff --git a/selfdrive/assets/navigation/direction_invalid_right.png b/selfdrive/assets/navigation/direction_invalid_right.png new file mode 100644 index 00000000000000..0fbaa3f253edb8 Binary files /dev/null and b/selfdrive/assets/navigation/direction_invalid_right.png differ diff --git a/selfdrive/assets/navigation/direction_invalid_slight_left.png b/selfdrive/assets/navigation/direction_invalid_slight_left.png new file mode 100644 index 00000000000000..08e964dbd6a68a Binary files /dev/null and b/selfdrive/assets/navigation/direction_invalid_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_invalid_slight_right.png b/selfdrive/assets/navigation/direction_invalid_slight_right.png new file mode 100644 index 00000000000000..3e21cae11ed520 Binary files /dev/null and b/selfdrive/assets/navigation/direction_invalid_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_invalid_straight.png b/selfdrive/assets/navigation/direction_invalid_straight.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_invalid_straight.png differ diff --git a/selfdrive/assets/navigation/direction_invalid_uturn.png b/selfdrive/assets/navigation/direction_invalid_uturn.png new file mode 100644 index 00000000000000..0bd1b91777ed8d Binary files /dev/null and b/selfdrive/assets/navigation/direction_invalid_uturn.png differ diff --git a/selfdrive/assets/navigation/direction_merge_left.png b/selfdrive/assets/navigation/direction_merge_left.png new file mode 100644 index 00000000000000..a713f52c56dddf Binary files /dev/null and b/selfdrive/assets/navigation/direction_merge_left.png differ diff --git a/selfdrive/assets/navigation/direction_merge_right.png b/selfdrive/assets/navigation/direction_merge_right.png new file mode 100644 index 00000000000000..3390b31a05b26b Binary files /dev/null and b/selfdrive/assets/navigation/direction_merge_right.png differ diff --git a/selfdrive/assets/navigation/direction_merge_slight_left.png b/selfdrive/assets/navigation/direction_merge_slight_left.png new file mode 100644 index 00000000000000..308f97b5a5d5b7 Binary files /dev/null and b/selfdrive/assets/navigation/direction_merge_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_merge_slight_right.png b/selfdrive/assets/navigation/direction_merge_slight_right.png new file mode 100644 index 00000000000000..8f5289011d67b4 Binary files /dev/null and b/selfdrive/assets/navigation/direction_merge_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_merge_straight.png b/selfdrive/assets/navigation/direction_merge_straight.png new file mode 100644 index 00000000000000..49c464389d2da2 Binary files /dev/null and b/selfdrive/assets/navigation/direction_merge_straight.png differ diff --git a/selfdrive/assets/navigation/direction_new_name_left.png b/selfdrive/assets/navigation/direction_new_name_left.png new file mode 100644 index 00000000000000..9a618026f0e00d Binary files /dev/null and b/selfdrive/assets/navigation/direction_new_name_left.png differ diff --git a/selfdrive/assets/navigation/direction_new_name_right.png b/selfdrive/assets/navigation/direction_new_name_right.png new file mode 100644 index 00000000000000..0fbaa3f253edb8 Binary files /dev/null and b/selfdrive/assets/navigation/direction_new_name_right.png differ diff --git a/selfdrive/assets/navigation/direction_new_name_sharp_left.png b/selfdrive/assets/navigation/direction_new_name_sharp_left.png new file mode 100644 index 00000000000000..77106b493ff6d5 Binary files /dev/null and b/selfdrive/assets/navigation/direction_new_name_sharp_left.png differ diff --git a/selfdrive/assets/navigation/direction_new_name_sharp_right.png b/selfdrive/assets/navigation/direction_new_name_sharp_right.png new file mode 100644 index 00000000000000..eb3a02f8b3adfe Binary files /dev/null and b/selfdrive/assets/navigation/direction_new_name_sharp_right.png differ diff --git a/selfdrive/assets/navigation/direction_new_name_slight_left.png b/selfdrive/assets/navigation/direction_new_name_slight_left.png new file mode 100644 index 00000000000000..08e964dbd6a68a Binary files /dev/null and b/selfdrive/assets/navigation/direction_new_name_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_new_name_slight_right.png b/selfdrive/assets/navigation/direction_new_name_slight_right.png new file mode 100644 index 00000000000000..3e21cae11ed520 Binary files /dev/null and b/selfdrive/assets/navigation/direction_new_name_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_new_name_straight.png b/selfdrive/assets/navigation/direction_new_name_straight.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_new_name_straight.png differ diff --git a/selfdrive/assets/navigation/direction_notificaiton_right.png b/selfdrive/assets/navigation/direction_notificaiton_right.png new file mode 100644 index 00000000000000..0fbaa3f253edb8 Binary files /dev/null and b/selfdrive/assets/navigation/direction_notificaiton_right.png differ diff --git a/selfdrive/assets/navigation/direction_notificaiton_sharp_right.png b/selfdrive/assets/navigation/direction_notificaiton_sharp_right.png new file mode 100644 index 00000000000000..a7e3c4cee56a7d Binary files /dev/null and b/selfdrive/assets/navigation/direction_notificaiton_sharp_right.png differ diff --git a/selfdrive/assets/navigation/direction_notification_left.png b/selfdrive/assets/navigation/direction_notification_left.png new file mode 100644 index 00000000000000..9a618026f0e00d Binary files /dev/null and b/selfdrive/assets/navigation/direction_notification_left.png differ diff --git a/selfdrive/assets/navigation/direction_notification_sharp_left.png b/selfdrive/assets/navigation/direction_notification_sharp_left.png new file mode 100644 index 00000000000000..dd8a4301db6dbe Binary files /dev/null and b/selfdrive/assets/navigation/direction_notification_sharp_left.png differ diff --git a/selfdrive/assets/navigation/direction_notification_slight_left.png b/selfdrive/assets/navigation/direction_notification_slight_left.png new file mode 100644 index 00000000000000..08e964dbd6a68a Binary files /dev/null and b/selfdrive/assets/navigation/direction_notification_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_notification_slight_right.png b/selfdrive/assets/navigation/direction_notification_slight_right.png new file mode 100644 index 00000000000000..3e21cae11ed520 Binary files /dev/null and b/selfdrive/assets/navigation/direction_notification_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_notification_straight.png b/selfdrive/assets/navigation/direction_notification_straight.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_notification_straight.png differ diff --git a/selfdrive/assets/navigation/direction_off_ramp_left.png b/selfdrive/assets/navigation/direction_off_ramp_left.png new file mode 100644 index 00000000000000..d3fd182893762e Binary files /dev/null and b/selfdrive/assets/navigation/direction_off_ramp_left.png differ diff --git a/selfdrive/assets/navigation/direction_off_ramp_right.png b/selfdrive/assets/navigation/direction_off_ramp_right.png new file mode 100644 index 00000000000000..722e3f808f632c Binary files /dev/null and b/selfdrive/assets/navigation/direction_off_ramp_right.png differ diff --git a/selfdrive/assets/navigation/direction_off_ramp_slight_left.png b/selfdrive/assets/navigation/direction_off_ramp_slight_left.png new file mode 100644 index 00000000000000..ddac4aad664592 Binary files /dev/null and b/selfdrive/assets/navigation/direction_off_ramp_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_off_ramp_slight_right.png b/selfdrive/assets/navigation/direction_off_ramp_slight_right.png new file mode 100644 index 00000000000000..ed576088645187 Binary files /dev/null and b/selfdrive/assets/navigation/direction_off_ramp_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_on_ramp_left.png b/selfdrive/assets/navigation/direction_on_ramp_left.png new file mode 100644 index 00000000000000..9a618026f0e00d Binary files /dev/null and b/selfdrive/assets/navigation/direction_on_ramp_left.png differ diff --git a/selfdrive/assets/navigation/direction_on_ramp_right.png b/selfdrive/assets/navigation/direction_on_ramp_right.png new file mode 100644 index 00000000000000..0fbaa3f253edb8 Binary files /dev/null and b/selfdrive/assets/navigation/direction_on_ramp_right.png differ diff --git a/selfdrive/assets/navigation/direction_on_ramp_sharp_left.png b/selfdrive/assets/navigation/direction_on_ramp_sharp_left.png new file mode 100644 index 00000000000000..77106b493ff6d5 Binary files /dev/null and b/selfdrive/assets/navigation/direction_on_ramp_sharp_left.png differ diff --git a/selfdrive/assets/navigation/direction_on_ramp_sharp_right.png b/selfdrive/assets/navigation/direction_on_ramp_sharp_right.png new file mode 100644 index 00000000000000..a7e3c4cee56a7d Binary files /dev/null and b/selfdrive/assets/navigation/direction_on_ramp_sharp_right.png differ diff --git a/selfdrive/assets/navigation/direction_on_ramp_slight_left.png b/selfdrive/assets/navigation/direction_on_ramp_slight_left.png new file mode 100644 index 00000000000000..a5ea8a881e6b5e Binary files /dev/null and b/selfdrive/assets/navigation/direction_on_ramp_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_on_ramp_slight_right.png b/selfdrive/assets/navigation/direction_on_ramp_slight_right.png new file mode 100644 index 00000000000000..f8ea3800e880fc Binary files /dev/null and b/selfdrive/assets/navigation/direction_on_ramp_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_on_ramp_straight.png b/selfdrive/assets/navigation/direction_on_ramp_straight.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_on_ramp_straight.png differ diff --git a/selfdrive/assets/navigation/direction_rotary.png b/selfdrive/assets/navigation/direction_rotary.png new file mode 100644 index 00000000000000..2a5d264bd27426 Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary.png differ diff --git a/selfdrive/assets/navigation/direction_rotary_left.png b/selfdrive/assets/navigation/direction_rotary_left.png new file mode 100644 index 00000000000000..0c4e4ab5e6cb83 Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary_left.png differ diff --git a/selfdrive/assets/navigation/direction_rotary_right.png b/selfdrive/assets/navigation/direction_rotary_right.png new file mode 100644 index 00000000000000..32a6b2504ba9d9 Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary_right.png differ diff --git a/selfdrive/assets/navigation/direction_rotary_sharp_left.png b/selfdrive/assets/navigation/direction_rotary_sharp_left.png new file mode 100644 index 00000000000000..c84a6d96c01c67 Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary_sharp_left.png differ diff --git a/selfdrive/assets/navigation/direction_rotary_sharp_right.png b/selfdrive/assets/navigation/direction_rotary_sharp_right.png new file mode 100644 index 00000000000000..d15cbee00232cc Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary_sharp_right.png differ diff --git a/selfdrive/assets/navigation/direction_rotary_slight_left.png b/selfdrive/assets/navigation/direction_rotary_slight_left.png new file mode 100644 index 00000000000000..3838e720a3553a Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_rotary_slight_right.png b/selfdrive/assets/navigation/direction_rotary_slight_right.png new file mode 100644 index 00000000000000..8cd45fe6125748 Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_rotary_straight.png b/selfdrive/assets/navigation/direction_rotary_straight.png new file mode 100644 index 00000000000000..b6b0a7311bb2f5 Binary files /dev/null and b/selfdrive/assets/navigation/direction_rotary_straight.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout.png b/selfdrive/assets/navigation/direction_roundabout.png new file mode 100644 index 00000000000000..2a5d264bd27426 Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout_left.png b/selfdrive/assets/navigation/direction_roundabout_left.png new file mode 100644 index 00000000000000..0c4e4ab5e6cb83 Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout_left.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout_right.png b/selfdrive/assets/navigation/direction_roundabout_right.png new file mode 100644 index 00000000000000..32a6b2504ba9d9 Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout_right.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout_sharp_left.png b/selfdrive/assets/navigation/direction_roundabout_sharp_left.png new file mode 100644 index 00000000000000..1e8cce8c8e19d8 Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout_sharp_left.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout_sharp_right.png b/selfdrive/assets/navigation/direction_roundabout_sharp_right.png new file mode 100644 index 00000000000000..d15cbee00232cc Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout_sharp_right.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout_slight_left.png b/selfdrive/assets/navigation/direction_roundabout_slight_left.png new file mode 100644 index 00000000000000..da1b1127051a19 Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout_slight_right.png b/selfdrive/assets/navigation/direction_roundabout_slight_right.png new file mode 100644 index 00000000000000..8cd45fe6125748 Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_roundabout_straight.png b/selfdrive/assets/navigation/direction_roundabout_straight.png new file mode 100644 index 00000000000000..b6b0a7311bb2f5 Binary files /dev/null and b/selfdrive/assets/navigation/direction_roundabout_straight.png differ diff --git a/selfdrive/assets/navigation/direction_turn_left.png b/selfdrive/assets/navigation/direction_turn_left.png new file mode 100644 index 00000000000000..9a618026f0e00d Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_left.png differ diff --git a/selfdrive/assets/navigation/direction_turn_right.png b/selfdrive/assets/navigation/direction_turn_right.png new file mode 100644 index 00000000000000..0fbaa3f253edb8 Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_right.png differ diff --git a/selfdrive/assets/navigation/direction_turn_sharp_left.png b/selfdrive/assets/navigation/direction_turn_sharp_left.png new file mode 100644 index 00000000000000..dd8a4301db6dbe Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_sharp_left.png differ diff --git a/selfdrive/assets/navigation/direction_turn_sharp_right.png b/selfdrive/assets/navigation/direction_turn_sharp_right.png new file mode 100644 index 00000000000000..a7e3c4cee56a7d Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_sharp_right.png differ diff --git a/selfdrive/assets/navigation/direction_turn_slight_left.png b/selfdrive/assets/navigation/direction_turn_slight_left.png new file mode 100644 index 00000000000000..08e964dbd6a68a Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_slight_left.png differ diff --git a/selfdrive/assets/navigation/direction_turn_slight_right.png b/selfdrive/assets/navigation/direction_turn_slight_right.png new file mode 100644 index 00000000000000..3e21cae11ed520 Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_slight_right.png differ diff --git a/selfdrive/assets/navigation/direction_turn_straight.png b/selfdrive/assets/navigation/direction_turn_straight.png new file mode 100644 index 00000000000000..a01045ae6a2b58 Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_straight.png differ diff --git a/selfdrive/assets/navigation/direction_turn_uturn.png b/selfdrive/assets/navigation/direction_turn_uturn.png new file mode 100644 index 00000000000000..0bd1b91777ed8d Binary files /dev/null and b/selfdrive/assets/navigation/direction_turn_uturn.png differ diff --git a/selfdrive/assets/navigation/direction_updown.png b/selfdrive/assets/navigation/direction_updown.png new file mode 100644 index 00000000000000..16d0979f3ed040 Binary files /dev/null and b/selfdrive/assets/navigation/direction_updown.png differ diff --git a/selfdrive/assets/navigation/home.png b/selfdrive/assets/navigation/home.png new file mode 100644 index 00000000000000..8a4f65c7d7a836 Binary files /dev/null and b/selfdrive/assets/navigation/home.png differ diff --git a/selfdrive/assets/navigation/home.svg b/selfdrive/assets/navigation/home.svg new file mode 100644 index 00000000000000..f5d89514c36bc0 --- /dev/null +++ b/selfdrive/assets/navigation/home.svg @@ -0,0 +1,65 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/selfdrive/assets/navigation/home_inactive.png b/selfdrive/assets/navigation/home_inactive.png new file mode 100644 index 00000000000000..a58fd3864fdf30 Binary files /dev/null and b/selfdrive/assets/navigation/home_inactive.png differ diff --git a/selfdrive/assets/navigation/screenshot.png b/selfdrive/assets/navigation/screenshot.png new file mode 100644 index 00000000000000..3e89c04759fd8e Binary files /dev/null and b/selfdrive/assets/navigation/screenshot.png differ diff --git a/selfdrive/assets/navigation/work.png b/selfdrive/assets/navigation/work.png new file mode 100644 index 00000000000000..611f9b038dc9cd Binary files /dev/null and b/selfdrive/assets/navigation/work.png differ diff --git a/selfdrive/assets/navigation/work.svg b/selfdrive/assets/navigation/work.svg new file mode 100644 index 00000000000000..2da7bb7d39f2e9 --- /dev/null +++ b/selfdrive/assets/navigation/work.svg @@ -0,0 +1,66 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/selfdrive/assets/navigation/work_inactive.png b/selfdrive/assets/navigation/work_inactive.png new file mode 100644 index 00000000000000..679e6a54b2852e Binary files /dev/null and b/selfdrive/assets/navigation/work_inactive.png differ diff --git a/selfdrive/assets/offroad/fcc.html b/selfdrive/assets/offroad/fcc.html new file mode 100644 index 00000000000000..793bea533c61ef --- /dev/null +++ b/selfdrive/assets/offroad/fcc.html @@ -0,0 +1,56 @@ + + +

    Supplier's Declaration of Conformity: 47 CFR § 2.1077 Compliance Information

    + +

    Unique Identifier

    +

    comma three

    + +

    Authorized Components

    + +
    Thundersoft TurboX D845 SOM
    +

    FCC ID: 2AOHHTURBOXSOMD845

    + +
    Quectel/EG25-G
    +

    FCC ID: XMR201903EG25G

    +

    + This device complies with Part 15 of the FCC Rules. + Operation is subject to the following two conditions: + +

    (1) this device may not cause harmful interference, and +

    (2) this device must accept any interference received, including interference that may cause undesired operation.

    + + The following test reports are subject to this declaration: + Test report number: HR20191001605 + Issue date: 2019-2-21 + + The following manufacturer/importer/entity (located in the USA) is responsible for this declaration: + Company name: Quectel Wireless Solutions Co., Ltd. + Name/Title (legal representative): Yin JiXiong + Address: 7th Floor, Hongye Building, No.1801 Hongmei Road, Xuhui District, Shanghai 200233, China + Phone: +8602150086326 Extension: 800 + Fax: +862153253668 + E-mail: johnny.xiang@quectel.com +

    + +

    Responsible Party - U.S. Contact Information

    +

    comma.ai

    +

    501 W Broadway St

    +

    STE A #403

    +

    San Diego, California

    +

    92101

    +

    United States

    +

    support@comma.ai

    + +

    FCC Compliance Statement

    +

    This device complies with part 15 of the FCC Rules. Operation is subject to the following two conditions: (1) This device may not cause harmful interference, and (2) this device must accept any interference received, including interference that may cause undesired operation. Note: This equipment has been tested and found to comply with the limits for a Class B digital device, pursuant to part 15 of the FCC Rules. These limits are designed to provide reasonable protection against harmful interference in a residential installation.

    +

    This equipment generates, uses, and can radiate radio frequency energy and, if not installed and used in accordance with the instructions, may cause harmful interference to radio communications. However, there is no guarantee that interference will not occur in a particular installation.

    +

    If this equipment does cause harmful interference to radio or television reception, which can be determined by turning the equipment off and on, the user is encouraged to try to correct the interference by one or more of the following measures:

    +

    Reorient or relocate the receiving antenna.

    +

    Increase the separation between the equipment and receiver.

    +

    Connect the equipment to an outlet on a circuit different from that to which the receiver is connected.

    +

    Consult the dealer or an experienced radio/TV technician for help.

    +

    Changes or modifications to this product not expressly approved by the party responsible for compliance could void the electromagnetic compatibility (EMC) and wireless compliance and negate your authority to operate the product.

    +

    This product has demonstrated EMC compliance under conditions that included the use of compliant peripheral devices and shielded cables between system components. It is important that you use compliant peripheral devices and shielded cables between system components to reduce the possibility of causing interference to radios, televisions, and other electronic devices.

    +

    The radiated output power of this device meets the limits of FCC/IC radio frequency exposure limits. This device should be operated with a minimum separation distance of 20 cm (8 inches) between the equipment and a person's body.

    + + 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.svg b/selfdrive/assets/offroad/icon_checkmark.svg new file mode 100644 index 00000000000000..b024eccd9e8192 --- /dev/null +++ b/selfdrive/assets/offroad/icon_checkmark.svg @@ -0,0 +1,3 @@ + + + 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_close.svg b/selfdrive/assets/offroad/icon_close.svg new file mode 100644 index 00000000000000..4c063371afcfa5 --- /dev/null +++ b/selfdrive/assets/offroad/icon_close.svg @@ -0,0 +1,4 @@ + + + + diff --git a/selfdrive/assets/offroad/icon_lock_closed.svg b/selfdrive/assets/offroad/icon_lock_closed.svg new file mode 100644 index 00000000000000..7dc9283c81fde3 --- /dev/null +++ b/selfdrive/assets/offroad/icon_lock_closed.svg @@ -0,0 +1,4 @@ + + + + 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_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_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/icon_wifi_strength_full.svg b/selfdrive/assets/offroad/icon_wifi_strength_full.svg new file mode 100644 index 00000000000000..758198e97fcd7e --- /dev/null +++ b/selfdrive/assets/offroad/icon_wifi_strength_full.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/selfdrive/assets/offroad/icon_wifi_strength_high.svg b/selfdrive/assets/offroad/icon_wifi_strength_high.svg new file mode 100644 index 00000000000000..a8db07f91ef043 --- /dev/null +++ b/selfdrive/assets/offroad/icon_wifi_strength_high.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/selfdrive/assets/offroad/icon_wifi_strength_low.svg b/selfdrive/assets/offroad/icon_wifi_strength_low.svg new file mode 100644 index 00000000000000..8963c3dbc1ca0b --- /dev/null +++ b/selfdrive/assets/offroad/icon_wifi_strength_low.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/selfdrive/assets/offroad/icon_wifi_strength_medium.svg b/selfdrive/assets/offroad/icon_wifi_strength_medium.svg new file mode 100644 index 00000000000000..8f8d503260b7cc --- /dev/null +++ b/selfdrive/assets/offroad/icon_wifi_strength_medium.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/selfdrive/assets/offroad/tc.html b/selfdrive/assets/offroad/tc.html new file mode 100644 index 00000000000000..f88daf08f24602 --- /dev/null +++ b/selfdrive/assets/offroad/tc.html @@ -0,0 +1,44 @@ + + + + + openpilot Terms of Service + + + + +

    The Terms and Conditions below are effective for all users

    +

    Last Updated on October 18, 2019

    +

    Please read these Terms of Use (“Termsâ€) carefully before using openpilot which is open-sourced software developed by Comma.ai, Inc., a corporation organized under the laws of Delaware (“comma,†“us,†“we,†or “ourâ€).

    +

    Before using and by accessing openpilot, you indicate that you have read, understood, and agree to these Terms. These Terms apply to all users and others who access or use openpilot. If others use openpilot through your user account or vehicle, you are responsible to ensure that they only use openpilot when it is safe to do so, and in compliance with these Terms and with applicable law. If you disagree with any part of the Terms, you should not access or use openpilot.

    +

    Communications

    +

    You agree that comma may contact you by email or telephone in connection with openpilot or for other business purposes. You may opt out of receiving email messages at any time by contacting us at support@comma.ai.

    +

    We collect, use, and share information from and about you and your vehicle in connection with openpilot. You consent to comma accessing the systems associated with openpilot, without additional notice or consent, for the purposes of providing openpilot, data collection, software updates, safety and cybersecurity, suspension or removal of your account, and as disclosed in the Privacy Policy (available at https://connect.comma.ai/privacy).

    +

    Safety

    +

    openpilot performs the functions of Adaptive Cruise Control (ACC) and Lane Keeping Assist System (LKAS) designed for use in compatible motor vehicles. While using openpilot, it is your responsibility to obey all laws, traffic rules, and traffic regulations governing your vehicle and its operation. Access to and use of openpilot is at your own risk and responsibility, and openpilot should be accessed and/or used only when you can do so safely.

    +

    openpilot does not make your vehicle “autonomous†or capable of operation without the active monitoring of a licensed driver. It is designed to assist a licensed driver. A licensed driver must pay attention to the road, remain aware of navigation at all times, and be prepared to take immediate action. Failure to do so can cause damage, injury, or death.

    +

    Supported Locations and Models

    +

    openpilot is compatible only with particular makes and models of vehicles. For a complete list of currently supported vehicles, visit https://comma.ai. openpilot will not function properly when installed in an incompatible vehicle. openpilot is compatible only within the geographical boundaries of the United States of America.

    +

    Indemnification

    +

    To the maximum extent allowable by law, you agree to defend, indemnify and hold harmless comma, and its employees, partners, suppliers, contractors, investors, agents, officers, directors, and affiliates, from and against any and all claims, damages, causes of action, penalties, interest, demands, obligations, losses, liabilities, costs or debt, additional taxes, and expenses (including but not limited to attorneys’ fees), resulting from or arising out of (i) your use and access of, or inability to use or access, openpilot, (ii) your breach of these Terms, (iii) the inaccuracy of any information, representation or warranty made by you, (iv) activities of anyone other than you in connection with openpilot conducted through your comma device or account, (v) any other of your activities under or in connection with these Terms or openpilot.

    +

    Limitation of Liability

    +

    In no event shall comma, nor its directors, employees, partners, agents, suppliers, or affiliates, be liable for any indirect, incidental, special, consequential or punitive damages, including without limitation, loss of profits, data, use, goodwill, or other intangible losses, resulting from (i) your access to or use of or inability to access or use of the Software; or (ii) any conduct or content of any third party on the Software whether based on warranty, contract, tort (including negligence) or any other legal theory, whether or not we have been informed of the possibility of such damage, and even if a remedy set forth herein is found to have failed of its essential purpose.

    +

    No Warranty or Obligations to Maintain or Service

    +

    comma provides openpilot without representations, conditions, or warranties of any kind. openpilot is provided on an “AS IS†and “AS AVAILABLE†basis, including with all faults and errors as may occur. To the extent permitted by law and unless prohibited by law, comma on behalf of itself and all persons and parties acting by, through, or for comma, explicitly disclaims all warranties or conditions, express, implied, or collateral, including any implied warranties of merchantability, satisfactory quality, and fitness for a particular purpose in respect of openpilot.

    +

    To the extent permitted by law, comma does not warrant the operation, performance, or availability of openpilot under all conditions. comma is not responsible for any failures caused by server errors, misdirected or redirected transmissions, failed internet connections, interruptions or failures in the transmission of data, any computer virus, or any acts or omissions of third parties that damage the network or impair wireless service.

    +

    We undertake reasonable measures to preserve and secure information collected through our openpilot. However, no data collection, transmission or storage system is 100% secure, and there is always a risk that your information may be intercepted without our consent. In using openpilot, you acknowledge that comma is not responsible for intercepted information, and you hereby release us from any and all claims arising out of or related to the use of intercepted information in any unauthorized manner.

    +

    By providing openpilot, comma does not transfer or license its intellectual property or grant rights in its brand names, nor does comma make representations with respect to third-party intellectual property rights.

    +

    We are not obligated to provide any maintenance or support for openpilot, technical or otherwise. If we voluntarily provide any maintenance or support for openpilot, we may stop any such maintenance, support, or services at any time in our sole discretion.

    +

    Modification of Software

    +

    In no event shall comma, nor its directors, employees, partners, agents, suppliers, or affiliates, be liable if you choose to modify the software.

    +

    Changes

    +

    We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is material we will provide at least 15 days’ notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion.

    +

    By continuing to access or use our Software after any revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, you are no longer authorized to use the Software.

    +

    Contact Us

    +

    If you have any questions about these Terms, please contact us at support@comma.ai.

    + + diff --git a/selfdrive/assets/sounds/disengage.wav b/selfdrive/assets/sounds/disengage.wav new file mode 100644 index 00000000000000..ba583c41f362d3 Binary files /dev/null and b/selfdrive/assets/sounds/disengage.wav differ diff --git a/selfdrive/assets/sounds/disengaged.wav b/selfdrive/assets/sounds/disengaged.wav deleted file mode 100644 index 958e08fd85b3e6..00000000000000 Binary files a/selfdrive/assets/sounds/disengaged.wav and /dev/null differ diff --git a/selfdrive/assets/sounds/engage.wav b/selfdrive/assets/sounds/engage.wav new file mode 100644 index 00000000000000..41e9b2d588d4aa Binary files /dev/null and b/selfdrive/assets/sounds/engage.wav differ diff --git a/selfdrive/assets/sounds/engaged.wav b/selfdrive/assets/sounds/engaged.wav deleted file mode 100644 index c6c088e01c8b73..00000000000000 Binary files a/selfdrive/assets/sounds/engaged.wav and /dev/null differ diff --git a/selfdrive/assets/sounds/error.wav b/selfdrive/assets/sounds/error.wav deleted file mode 100644 index 1ff0c540d26ab0..00000000000000 Binary files a/selfdrive/assets/sounds/error.wav and /dev/null differ diff --git a/selfdrive/assets/sounds/prompt.wav b/selfdrive/assets/sounds/prompt.wav new file mode 100644 index 00000000000000..420e9fabee62e2 Binary files /dev/null and b/selfdrive/assets/sounds/prompt.wav differ diff --git a/selfdrive/assets/sounds/prompt_distracted.wav b/selfdrive/assets/sounds/prompt_distracted.wav new file mode 100644 index 00000000000000..c3d4475caa70ce Binary files /dev/null and b/selfdrive/assets/sounds/prompt_distracted.wav differ diff --git a/selfdrive/assets/sounds/refuse.wav b/selfdrive/assets/sounds/refuse.wav new file mode 100644 index 00000000000000..0e80f7d127dcd4 Binary files /dev/null and b/selfdrive/assets/sounds/refuse.wav differ diff --git a/selfdrive/assets/sounds/warning_1.wav b/selfdrive/assets/sounds/warning_1.wav deleted file mode 100644 index 67b8d76fe804fa..00000000000000 Binary files a/selfdrive/assets/sounds/warning_1.wav and /dev/null differ diff --git a/selfdrive/assets/sounds/warning_2.wav b/selfdrive/assets/sounds/warning_2.wav deleted file mode 100644 index 8e1b1d7d9161a7..00000000000000 Binary files a/selfdrive/assets/sounds/warning_2.wav and /dev/null differ diff --git a/selfdrive/assets/sounds/warning_immediate.wav b/selfdrive/assets/sounds/warning_immediate.wav new file mode 100644 index 00000000000000..9f6f672e2829c0 Binary files /dev/null and b/selfdrive/assets/sounds/warning_immediate.wav differ diff --git a/selfdrive/assets/sounds/warning_soft.wav b/selfdrive/assets/sounds/warning_soft.wav new file mode 100644 index 00000000000000..261c7e1376c672 Binary files /dev/null and b/selfdrive/assets/sounds/warning_soft.wav differ diff --git a/selfdrive/assets/training/step0.png b/selfdrive/assets/training/step0.png new file mode 100644 index 00000000000000..8ea90610d1f2a4 Binary files /dev/null and b/selfdrive/assets/training/step0.png differ diff --git a/selfdrive/assets/training/step1.png b/selfdrive/assets/training/step1.png new file mode 100644 index 00000000000000..22a629beaa300e Binary files /dev/null and b/selfdrive/assets/training/step1.png differ diff --git a/selfdrive/assets/training/step10.png b/selfdrive/assets/training/step10.png new file mode 100644 index 00000000000000..96390aa324a149 Binary files /dev/null and b/selfdrive/assets/training/step10.png differ diff --git a/selfdrive/assets/training/step11.png b/selfdrive/assets/training/step11.png new file mode 100644 index 00000000000000..94342a4b5bfc0f Binary files /dev/null and b/selfdrive/assets/training/step11.png differ diff --git a/selfdrive/assets/training/step12.png b/selfdrive/assets/training/step12.png new file mode 100644 index 00000000000000..8b2b01af21e3b2 Binary files /dev/null and b/selfdrive/assets/training/step12.png differ diff --git a/selfdrive/assets/training/step13.png b/selfdrive/assets/training/step13.png new file mode 100644 index 00000000000000..6593b93d79e188 Binary files /dev/null and b/selfdrive/assets/training/step13.png differ diff --git a/selfdrive/assets/training/step14.png b/selfdrive/assets/training/step14.png new file mode 100644 index 00000000000000..1cb8fb9921f19a Binary files /dev/null and b/selfdrive/assets/training/step14.png differ diff --git a/selfdrive/assets/training/step15.png b/selfdrive/assets/training/step15.png new file mode 100644 index 00000000000000..b4c0841b715363 Binary files /dev/null and b/selfdrive/assets/training/step15.png differ diff --git a/selfdrive/assets/training/step16.png b/selfdrive/assets/training/step16.png new file mode 100644 index 00000000000000..d8518b10b53415 Binary files /dev/null and b/selfdrive/assets/training/step16.png differ diff --git a/selfdrive/assets/training/step17.png b/selfdrive/assets/training/step17.png new file mode 100644 index 00000000000000..a9ab91269725b3 Binary files /dev/null and b/selfdrive/assets/training/step17.png differ diff --git a/selfdrive/assets/training/step18.png b/selfdrive/assets/training/step18.png new file mode 100644 index 00000000000000..a5d8833a32de52 Binary files /dev/null and b/selfdrive/assets/training/step18.png differ diff --git a/selfdrive/assets/training/step2.png b/selfdrive/assets/training/step2.png new file mode 100644 index 00000000000000..03a45f8de9cfd0 Binary files /dev/null and b/selfdrive/assets/training/step2.png differ diff --git a/selfdrive/assets/training/step3.png b/selfdrive/assets/training/step3.png new file mode 100644 index 00000000000000..0712678ac98534 Binary files /dev/null and b/selfdrive/assets/training/step3.png differ diff --git a/selfdrive/assets/training/step4.png b/selfdrive/assets/training/step4.png new file mode 100644 index 00000000000000..60a99310fdce7a Binary files /dev/null and b/selfdrive/assets/training/step4.png differ diff --git a/selfdrive/assets/training/step5.png b/selfdrive/assets/training/step5.png new file mode 100644 index 00000000000000..54aa049dd14adb Binary files /dev/null and b/selfdrive/assets/training/step5.png differ diff --git a/selfdrive/assets/training/step6.png b/selfdrive/assets/training/step6.png new file mode 100644 index 00000000000000..80cbb0a5587634 Binary files /dev/null and b/selfdrive/assets/training/step6.png differ diff --git a/selfdrive/assets/training/step7.png b/selfdrive/assets/training/step7.png new file mode 100644 index 00000000000000..e5e403df225cc8 Binary files /dev/null and b/selfdrive/assets/training/step7.png differ diff --git a/selfdrive/assets/training/step8.png b/selfdrive/assets/training/step8.png new file mode 100644 index 00000000000000..d5193ae3331275 Binary files /dev/null and b/selfdrive/assets/training/step8.png differ diff --git a/selfdrive/assets/training/step9.png b/selfdrive/assets/training/step9.png new file mode 100644 index 00000000000000..10dadc2ae07143 Binary files /dev/null and b/selfdrive/assets/training/step9.png differ diff --git a/selfdrive/assets/training_wide/step0.png b/selfdrive/assets/training_wide/step0.png new file mode 100644 index 00000000000000..cff6d4f88bb100 Binary files /dev/null and b/selfdrive/assets/training_wide/step0.png differ diff --git a/selfdrive/assets/training_wide/step1.png b/selfdrive/assets/training_wide/step1.png new file mode 100644 index 00000000000000..e81e2ce8011cf5 Binary files /dev/null and b/selfdrive/assets/training_wide/step1.png differ diff --git a/selfdrive/assets/training_wide/step10.png b/selfdrive/assets/training_wide/step10.png new file mode 100644 index 00000000000000..c595f602a1d7a6 Binary files /dev/null and b/selfdrive/assets/training_wide/step10.png differ diff --git a/selfdrive/assets/training_wide/step11.png b/selfdrive/assets/training_wide/step11.png new file mode 100644 index 00000000000000..26680b9021fdb5 Binary files /dev/null and b/selfdrive/assets/training_wide/step11.png differ diff --git a/selfdrive/assets/training_wide/step12.png b/selfdrive/assets/training_wide/step12.png new file mode 100644 index 00000000000000..c93ea6b251da9c Binary files /dev/null and b/selfdrive/assets/training_wide/step12.png differ diff --git a/selfdrive/assets/training_wide/step13.png b/selfdrive/assets/training_wide/step13.png new file mode 100644 index 00000000000000..103b6db9749bf0 Binary files /dev/null and b/selfdrive/assets/training_wide/step13.png differ diff --git a/selfdrive/assets/training_wide/step14.png b/selfdrive/assets/training_wide/step14.png new file mode 100644 index 00000000000000..cf4f35b7240b5e Binary files /dev/null and b/selfdrive/assets/training_wide/step14.png differ diff --git a/selfdrive/assets/training_wide/step15.png b/selfdrive/assets/training_wide/step15.png new file mode 100644 index 00000000000000..29999f0ada5fc9 Binary files /dev/null and b/selfdrive/assets/training_wide/step15.png differ diff --git a/selfdrive/assets/training_wide/step16.png b/selfdrive/assets/training_wide/step16.png new file mode 100644 index 00000000000000..601ff4eb03d47c Binary files /dev/null and b/selfdrive/assets/training_wide/step16.png differ diff --git a/selfdrive/assets/training_wide/step17.png b/selfdrive/assets/training_wide/step17.png new file mode 100644 index 00000000000000..d110451af2773a Binary files /dev/null and b/selfdrive/assets/training_wide/step17.png differ diff --git a/selfdrive/assets/training_wide/step18.png b/selfdrive/assets/training_wide/step18.png new file mode 100644 index 00000000000000..c1ce4ec1e3fdba Binary files /dev/null and b/selfdrive/assets/training_wide/step18.png differ diff --git a/selfdrive/assets/training_wide/step2.png b/selfdrive/assets/training_wide/step2.png new file mode 100644 index 00000000000000..ac03677ef57ed2 Binary files /dev/null and b/selfdrive/assets/training_wide/step2.png differ diff --git a/selfdrive/assets/training_wide/step3.png b/selfdrive/assets/training_wide/step3.png new file mode 100644 index 00000000000000..70649b82b9a562 Binary files /dev/null and b/selfdrive/assets/training_wide/step3.png differ diff --git a/selfdrive/assets/training_wide/step4.png b/selfdrive/assets/training_wide/step4.png new file mode 100644 index 00000000000000..3f393ca79711c2 Binary files /dev/null and b/selfdrive/assets/training_wide/step4.png differ diff --git a/selfdrive/assets/training_wide/step5.png b/selfdrive/assets/training_wide/step5.png new file mode 100644 index 00000000000000..a26ecbf1eba4c1 Binary files /dev/null and b/selfdrive/assets/training_wide/step5.png differ diff --git a/selfdrive/assets/training_wide/step6.png b/selfdrive/assets/training_wide/step6.png new file mode 100644 index 00000000000000..bb1b11602294a2 Binary files /dev/null and b/selfdrive/assets/training_wide/step6.png differ diff --git a/selfdrive/assets/training_wide/step7.png b/selfdrive/assets/training_wide/step7.png new file mode 100644 index 00000000000000..8a3d930811c984 Binary files /dev/null and b/selfdrive/assets/training_wide/step7.png differ diff --git a/selfdrive/assets/training_wide/step8.png b/selfdrive/assets/training_wide/step8.png new file mode 100644 index 00000000000000..c559d6a6c14365 Binary files /dev/null and b/selfdrive/assets/training_wide/step8.png differ diff --git a/selfdrive/assets/training_wide/step9.png b/selfdrive/assets/training_wide/step9.png new file mode 100644 index 00000000000000..19b2d483d7b608 Binary files /dev/null and b/selfdrive/assets/training_wide/step9.png differ diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index 58918de81ae37c..d1969266119649 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -1,43 +1,76 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 +import base64 +import hashlib +import io import json import os +import sys +import queue import random -import time +import select +import socket import threading -import traceback -import zmq +import time +from collections import namedtuple +from functools import partial +from typing import Any + import requests -import six.moves.queue from jsonrpc import JSONRPCResponseManager, dispatcher -from websocket import create_connection, WebSocketTimeoutException -from selfdrive.loggerd.config import ROOT +from websocket import ABNF, WebSocketTimeoutException, WebSocketException, 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.file_helpers import CallbackReader +from common.basedir import PERSIST from common.params import Params -from selfdrive.services import service_list -from selfdrive.swaglog import cloudlog -from selfdrive.version import version, dirty +from common.realtime import sec_since_boot +from selfdrive.hardware import HARDWARE, PC +from selfdrive.loggerd.config import ROOT +from selfdrive.loggerd.xattr_cache import getxattr, setxattr +from selfdrive.swaglog import cloudlog, SWAGLOG_DIR +from selfdrive.version import get_version, get_origin, get_short_branch, get_commit 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]) + +LOG_ATTR_NAME = 'user.upload' +LOG_ATTR_VALUE_MAX_UNIX_TIME = int.to_bytes(2147483647, 4, sys.byteorder) +RECONNECT_TIMEOUT_S = 70 + +RETRY_DELAY = 10 # seconds +MAX_RETRY_COUNT = 30 # Try for at most 5 minutes if upload fails immediately +WS_FRAME_SIZE = 4096 dispatcher["echo"] = lambda s: s -payload_queue = six.moves.queue.Queue() -response_queue = six.moves.queue.Queue() +recv_queue: Any = queue.Queue() +send_queue: Any = queue.Queue() +upload_queue: Any = queue.Queue() +log_send_queue: Any = queue.Queue() +log_recv_queue: Any = queue.Queue() +cancelled_uploads: Any = set() +UploadItem = namedtuple('UploadItem', ['path', 'url', 'headers', 'created_at', 'id', 'retry_count', 'current', 'progress'], defaults=(0, False, 0)) + +cur_upload_items = {} + 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_recv, args=(ws, end_event), name='ws_recv'), + threading.Thread(target=ws_send, args=(ws, end_event), name='ws_send'), + threading.Thread(target=upload_handler, args=(end_event,), name='upload_handler'), + threading.Thread(target=log_handler, args=(end_event,), name='log_handler'), ] + [ - threading.Thread(target=jsonrpc_handler, args=(end_event,)) - for x in xrange(HANDLER_THREADS) + threading.Thread(target=jsonrpc_handler, args=(end_event,), name=f'worker_{x}') + 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) @@ -45,98 +78,496 @@ def handle_long_poll(ws): end_event.set() raise finally: - for i, thread in enumerate(threads): + for thread in threads: + cloudlog.debug(f"athena.joining {thread.name}") thread.join() + def jsonrpc_handler(end_event): + dispatcher["startLocalProxy"] = partial(startLocalProxy, end_event) while not end_event.is_set(): try: - data = payload_queue.get(timeout=1) - response = JSONRPCResponseManager.handle(data, dispatcher) - response_queue.put_nowait(response) - except six.moves.queue.Empty: + data = recv_queue.get(timeout=1) + if "method" in data: + cloudlog.debug(f"athena.jsonrpc_handler.call_method {data}") + response = JSONRPCResponseManager.handle(data, dispatcher) + send_queue.put_nowait(response.json) + elif "id" in data and ("result" in data or "error" in data): + log_recv_queue.put_nowait(data) + else: + raise Exception("not a valid request or response") + 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)})) + send_queue.put_nowait(json.dumps({"error": str(e)})) + + +def upload_handler(end_event): + tid = threading.get_ident() + + while not end_event.is_set(): + cur_upload_items[tid] = None + + try: + cur_upload_items[tid] = upload_queue.get(timeout=1)._replace(current=True) + if cur_upload_items[tid].id in cancelled_uploads: + cancelled_uploads.remove(cur_upload_items[tid].id) + continue + + try: + def cb(sz, cur): + cur_upload_items[tid] = cur_upload_items[tid]._replace(progress=cur / sz if sz else 1) + + _do_upload(cur_upload_items[tid], cb) + except (requests.exceptions.Timeout, requests.exceptions.ConnectionError, requests.exceptions.SSLError) as e: + cloudlog.warning(f"athena.upload_handler.retry {e} {cur_upload_items[tid]}") + + if cur_upload_items[tid].retry_count < MAX_RETRY_COUNT: + item = cur_upload_items[tid] + item = item._replace( + retry_count=item.retry_count + 1, + progress=0, + current=False + ) + upload_queue.put_nowait(item) + cur_upload_items[tid] = None + + for _ in range(RETRY_DELAY): + time.sleep(1) + if end_event.is_set(): + break + + except queue.Empty: + pass + except Exception: + cloudlog.exception("athena.upload_handler.exception") + + +def _do_upload(upload_item, callback=None): + with open(upload_item.path, "rb") as f: + size = os.fstat(f.fileno()).st_size + + if callback: + f = CallbackReader(f, callback, size) + + return requests.put(upload_item.url, + data=f, + headers={**upload_item.headers, 'Content-Length': str(size)}, + timeout=30) + # 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] +def getVersion(): + return { + "version": get_version(), + "remote": get_origin(), + "branch": get_short_branch(), + "commit": get_commit(), + } + + +@dispatcher.add_method +def setNavDestination(latitude=0, longitude=0, place_name=None, place_details=None): + destination = { + "latitude": latitude, + "longitude": longitude, + "place_name": place_name, + "place_details": place_details, + } + Params().put("NavDestination", json.dumps(destination)) + + return {"success": 1} + + +def scan_dir(path, prefix): + files = list() + # only walk directories that match the prefix + # (glob and friends traverse entire dir tree) + with os.scandir(path) as i: + for e in i: + rel_path = os.path.relpath(e.path, ROOT) + if e.is_dir(follow_symlinks=False): + # add trailing slash + rel_path = os.path.join(rel_path, '') + # if prefix is a partial dir name, current dir will start with prefix + # if prefix is a partial file name, prefix with start with dir name + if rel_path.startswith(prefix) or prefix.startswith(rel_path): + files.extend(scan_dir(e.path, prefix)) + else: + if rel_path.startswith(prefix): + files.append(rel_path) return files +@dispatcher.add_method +def listDataDirectory(prefix=''): + return scan_dir(ROOT, prefix) + + +@dispatcher.add_method +def reboot(): + sock = messaging.sub_sock("deviceState", timeout=1000) + ret = messaging.recv_one(sock) + if ret is None or ret.deviceState.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 -def ws_recv(ws, end_event): + 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(): + items = list(upload_queue.queue) + list(cur_upload_items.values()) + return [i._asdict() for i in items if (i is not None) and (i.id not in cancelled_uploads)] + + +@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} + + +@dispatcher.add_method +def primeActivated(activated): + return {"success": 1} + + +def startLocalProxy(global_end_event, remote_ws_uri, local_port): + try: + if local_port not in LOCAL_PORT_WHITELIST: + raise Exception("Requested local port not whitelisted") + + cloudlog.debug("athena.startLocalProxy.starting") + + params = Params() + 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) + + ssock, csock = socket.socketpair() + local_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + local_sock.connect(('127.0.0.1', local_port)) + local_sock.setblocking(0) + + proxy_end_event = threading.Event() + threads = [ + 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)) + ] + for thread in threads: + thread.start() + + cloudlog.debug("athena.startLocalProxy.started") + return {"success": 1} + except Exception as e: + cloudlog.exception("athenad.startLocalProxy.exception") + raise e + + +@dispatcher.add_method +def getPublicKey(): + if not os.path.isfile(PERSIST + '/comma/id_rsa.pub'): + return None + + with open(PERSIST + '/comma/id_rsa.pub', 'r') as f: + return f.read() + + +@dispatcher.add_method +def getSshAuthorizedKeys(): + return Params().get("GithubSshKeys", encoding='utf8') or '' + + +@dispatcher.add_method +def getSimInfo(): + return HARDWARE.get_sim_info() + + +@dispatcher.add_method +def getNetworkType(): + return HARDWARE.get_network_type() + + +@dispatcher.add_method +def getNetworks(): + return HARDWARE.get_networks() + + +@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: + raise Exception("not available while camerad is started") + + +def get_logs_to_send_sorted(): + # TODO: scan once then use inotify to detect file creation/deletion + curr_time = int(time.time()) + logs = [] + for log_entry in os.listdir(SWAGLOG_DIR): + log_path = os.path.join(SWAGLOG_DIR, log_entry) + try: + time_sent = int.from_bytes(getxattr(log_path, LOG_ATTR_NAME), sys.byteorder) + except (ValueError, TypeError): + time_sent = 0 + # assume send failed and we lost the response if sent more than one hour ago + if not time_sent or curr_time - time_sent > 3600: + logs.append(log_entry) + # excluding most recent (active) log file + return sorted(logs)[:-1] + + +def log_handler(end_event): + if PC: + return + + log_files = [] + last_scan = 0 while not end_event.is_set(): + try: + curr_scan = sec_since_boot() + if curr_scan - last_scan > 10: + log_files = get_logs_to_send_sorted() + last_scan = curr_scan + + # send one log + curr_log = None + if len(log_files) > 0: + log_entry = log_files.pop() # newest log file + cloudlog.debug(f"athena.log_handler.forward_request {log_entry}") + try: + curr_time = int(time.time()) + log_path = os.path.join(SWAGLOG_DIR, log_entry) + setxattr(log_path, LOG_ATTR_NAME, int.to_bytes(curr_time, 4, sys.byteorder)) + with open(log_path, "r") as f: + jsonrpc = { + "method": "forwardLogs", + "params": { + "logs": f.read() + }, + "jsonrpc": "2.0", + "id": log_entry + } + log_send_queue.put_nowait(json.dumps(jsonrpc)) + curr_log = log_entry + except OSError: + pass # file could be deleted by log rotation + + # wait for response up to ~100 seconds + # always read queue at least once to process any old responses that arrive + for _ in range(100): + if end_event.is_set(): + break + try: + log_resp = json.loads(log_recv_queue.get(timeout=1)) + log_entry = log_resp.get("id") + log_success = "result" in log_resp and log_resp["result"].get("success") + cloudlog.debug(f"athena.log_handler.forward_response {log_entry} {log_success}") + if log_entry and log_success: + log_path = os.path.join(SWAGLOG_DIR, log_entry) + try: + setxattr(log_path, LOG_ATTR_NAME, LOG_ATTR_VALUE_MAX_UNIX_TIME) + except OSError: + pass # file could be deleted by log rotation + if curr_log == log_entry: + break + except queue.Empty: + if curr_log is None: + break + + except Exception: + cloudlog.exception("athena.log_handler.exception") + + +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()): try: data = ws.recv() - payload_queue.put_nowait(data) + local_sock.sendall(data) except WebSocketTimeoutException: pass except Exception: - traceback.print_exc() + cloudlog.exception("athenad.ws_proxy_recv.exception") + break + + cloudlog.debug("athena.ws_proxy_recv closing sockets") + ssock.close() + local_sock.close() + cloudlog.debug("athena.ws_proxy_recv done closing sockets") + + end_event.set() + + +def ws_proxy_send(ws, local_sock, signal_sock, end_event): + while not end_event.is_set(): + try: + r, _, _ = select.select((local_sock, signal_sock), (), ()) + if r: + if r[0].fileno() == signal_sock.fileno(): + # got end signal from ws_proxy_recv + end_event.set() + break + data = local_sock.recv(4096) + if not data: + # local_sock is dead + end_event.set() + break + + ws.send(data, ABNF.OPCODE_BINARY) + except Exception: + cloudlog.exception("athenad.ws_proxy_send.exception") end_event.set() + cloudlog.debug("athena.ws_proxy_send closing sockets") + signal_sock.close() + cloudlog.debug("athena.ws_proxy_send done closing sockets") + + +def ws_recv(ws, end_event): + last_ping = int(sec_since_boot() * 1e9) + while not end_event.is_set(): + try: + 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") + recv_queue.put_nowait(data) + elif opcode == ABNF.OPCODE_PING: + last_ping = int(sec_since_boot() * 1e9) + Params().put("LastAthenaPingTime", str(last_ping)) + except WebSocketTimeoutException: + ns_since_last_ping = int(sec_since_boot() * 1e9) - last_ping + if ns_since_last_ping > RECONNECT_TIMEOUT_S * 1e9: + cloudlog.exception("athenad.ws_recv.timeout") + end_event.set() + except Exception: + 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: + try: + data = send_queue.get_nowait() + except queue.Empty: + data = log_send_queue.get(timeout=1) + for i in range(0, len(data), WS_FRAME_SIZE): + frame = data[i:i+WS_FRAME_SIZE] + last = i + WS_FRAME_SIZE >= len(data) + opcode = ABNF.OPCODE_TEXT if i == 0 else ABNF.OPCODE_CONT + ws.send_frame(ABNF.create_frame(frame, opcode, last)) + 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") - access_token = params.get("AccessToken") - ws_uri = ATHENA_HOST + "/ws/" + dongle_id + dongle_id = params.get("DongleId", encoding='utf-8') - crash.bind_user(id=dongle_id) - crash.bind_extra(version=version, dirty=dirty, is_eon=True) - crash.install() + ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id + api = Api(dongle_id) conn_retries = 0 while 1: try: - print("connecting to %s" % ws_uri) + cloudlog.event("athenad.main.connecting_ws", ws_uri=ws_uri) ws = create_connection(ws_uri, - cookie="jwt=" + access_token, - enable_multithread=True) - ws.settimeout(1) + cookie="jwt=" + api.get_token(), + enable_multithread=True, + timeout=30.0) + cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri) + params.delete("PrimeRedirected") + conn_retries = 0 + cur_upload_items.clear() + handle_long_poll(ws) except (KeyboardInterrupt, SystemExit): break + except (ConnectionError, TimeoutError, WebSocketException): + conn_retries += 1 + params.delete("PrimeRedirected") + params.delete("LastAthenaPingTime") + except socket.timeout: + try: + r = requests.get("http://api.commadotai.com/v1/me", allow_redirects=False, + headers={"User-Agent": f"openpilot-{get_version()}"}, timeout=15.0) + if r.status_code == 302 and r.headers['Location'].startswith("http://u.web2go.com"): + params.put_bool("PrimeRedirected", True) + except Exception: + cloudlog.exception("athenad.socket_timeout.exception") + params.delete("LastAthenaPingTime") except Exception: + cloudlog.exception("athenad.main.exception") + conn_retries += 1 - traceback.print_exc() + params.delete("PrimeRedirected") + params.delete("LastAthenaPingTime") time.sleep(backoff(conn_retries)) + if __name__ == "__main__": main() diff --git a/selfdrive/athena/manage_athenad.py b/selfdrive/athena/manage_athenad.py new file mode 100755 index 00000000000000..fa95eacd8e9d02 --- /dev/null +++ b/selfdrive/athena/manage_athenad.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import time +from multiprocessing import Process + +from common.params import Params +from selfdrive.manager.process import launcher +from selfdrive.swaglog import cloudlog +from selfdrive.version import get_version, get_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=get_version(), dirty=get_dirty()) + + 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/athena/registration.py b/selfdrive/athena/registration.py new file mode 100755 index 00000000000000..e06bae5060959f --- /dev/null +++ b/selfdrive/athena/registration.py @@ -0,0 +1,94 @@ +#/!/usr/bin/env python3 +import time +import json +import jwt +from pathlib import Path + +from datetime import datetime, timedelta +from common.api import api_get +from common.params import Params +from common.spinner import Spinner +from common.basedir import PERSIST +from selfdrive.controls.lib.alertmanager import set_offroad_alert +from selfdrive.hardware import HARDWARE +from selfdrive.swaglog import cloudlog + + +UNREGISTERED_DONGLE_ID = "UnregisteredDevice" + + +def register(show_spinner=False) -> str: + params = Params() + params.put("SubscriberInfo", HARDWARE.get_subscriber_info()) + + IMEI = params.get("IMEI", encoding='utf8') + HardwareSerial = params.get("HardwareSerial", encoding='utf8') + dongle_id = params.get("DongleId", encoding='utf8') + needs_registration = None in (IMEI, HardwareSerial, dongle_id) + + pubkey = Path(PERSIST+"/comma/id_rsa.pub") + if not pubkey.is_file(): + dongle_id = UNREGISTERED_DONGLE_ID + cloudlog.warning(f"missing public key: {pubkey}") + elif needs_registration: + if show_spinner: + spinner = Spinner() + spinner.update("registering device") + + # Create registration token, in the future, this key will make JWTs directly + with open(PERSIST+"/comma/id_rsa.pub") as f1, open(PERSIST+"/comma/id_rsa") as f2: + public_key = f1.read() + private_key = f2.read() + + # Block until we get the imei + serial = HARDWARE.get_serial() + start_time = time.monotonic() + imei1, imei2 = None, None + while imei1 is None and imei2 is None: + try: + imei1, imei2 = HARDWARE.get_imei(0), HARDWARE.get_imei(1) + except Exception: + cloudlog.exception("Error getting imei, trying again...") + time.sleep(1) + + if time.monotonic() - start_time > 60 and show_spinner: + spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})") + + params.put("IMEI", imei1) + params.put("HardwareSerial", serial) + + backoff = 0 + start_time = time.monotonic() + while True: + try: + register_token = jwt.encode({'register': True, 'exp': datetime.utcnow() + timedelta(hours=1)}, private_key, algorithm='RS256') + cloudlog.info("getting pilotauth") + resp = api_get("v2/pilotauth/", method='POST', timeout=15, + imei=imei1, imei2=imei2, serial=serial, public_key=public_key, register_token=register_token) + + if resp.status_code in (402, 403): + cloudlog.info(f"Unable to register device, got {resp.status_code}") + dongle_id = UNREGISTERED_DONGLE_ID + else: + dongleauth = json.loads(resp.text) + dongle_id = dongleauth["dongle_id"] + break + except Exception: + cloudlog.exception("failed to authenticate") + backoff = min(backoff + 1, 15) + time.sleep(backoff) + + if time.monotonic() - start_time > 60 and show_spinner: + spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})") + + if show_spinner: + spinner.close() + + if dongle_id: + params.put("DongleId", dongle_id) + set_offroad_alert("Offroad_UnofficialHardware", dongle_id == UNREGISTERED_DONGLE_ID) + return dongle_id + + +if __name__ == "__main__": + print(register()) diff --git a/selfdrive/boardd/.gitignore b/selfdrive/boardd/.gitignore index b030dc97cdec07..e8daa2ef273e5c 100644 --- a/selfdrive/boardd/.gitignore +++ b/selfdrive/boardd/.gitignore @@ -1 +1,3 @@ boardd +boardd_api_impl.cpp +tests/test_boardd_usbprotocol 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..07ded56e1b8a89 --- /dev/null +++ b/selfdrive/boardd/SConscript @@ -0,0 +1,9 @@ +Import('env', 'envCython', 'common', 'cereal', 'messaging') + +libs = ['usb-1.0', common, cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj'] +env.Program('boardd', ['boardd.cc', 'panda.cc', 'pigeon.cc'], LIBS=libs) +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"]) +if GetOption('test'): + env.Program('tests/test_boardd_usbprotocol', ['tests/test_boardd_usbprotocol.cc', 'panda.cc'], LIBS=libs) diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 1a64416e9f4b4b..d09738a709de82 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -1,676 +1,670 @@ -#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 +#include +#include -#include #include -#include -#include "cereal/gen/cpp/log.capnp.h" #include "cereal/gen/cpp/car.capnp.h" +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/locationd/ublox_msg.h" + +#include "selfdrive/boardd/panda.h" +#include "selfdrive/boardd/pigeon.h" + +// -- Multi-panda conventions -- +// Ordering: +// - The internal panda will always be the first panda +// - Consecutive pandas will be sorted based on panda type, and then serial number +// Connecting: +// - If a panda connection is dropped, boardd wil reconnect to all pandas +// - If a panda is added, we will only reconnect when we are offroad +// CAN buses: +// - Each panda will have it's block of 4 buses. E.g.: the second panda will use +// bus numbers 4, 5, 6 and 7 +// - The internal panda will always be used for accessing the OBD2 port, +// and thus firmware queries +// Safety: +// - SafetyConfig is a list, which is mapped to the connected pandas +// - If there are more pandas connected than there are SafetyConfigs, +// the excess pandas will remain in "silent" ot "noOutput" mode +// Ignition: +// - If any of the ignition sources in any panda is high, ignition is high + +#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') +using namespace std::chrono_literals; + +std::atomic ignition(false); +std::atomic pigeon_active(false); + +ExitHandler do_exit; + +static std::string get_time_str(const struct tm &time) { + char s[30] = {'\0'}; + std::strftime(s, std::size(s), "%Y-%m-%d %H:%M:%S", &time); + return s; +} -#include "common/messaging.h" -#include "common/params.h" -#include "common/swaglog.h" -#include "common/timing.h" +bool check_all_connected(const std::vector &pandas) { + for (const auto& panda : pandas) { + if (!panda->connected) { + do_exit = true; + return false; + } + } + return true; +} -#include +enum class SyncTimeDir { TO_PANDA, FROM_PANDA }; -// 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; - -bool spoofing_started = false; -bool fake_send = false; -bool loopback_can = false; -bool is_grey_panda = false; - -pthread_t safety_setter_thread_handle = -1; -pthread_t pigeon_thread_handle = -1; -bool pigeon_needs_init; - -void pigeon_init(); -void *pigeon_thread(void *crap); - -void *safety_setter_thread(void *s) { - char *value; - size_t value_sz = 0; +void sync_time(Panda *panda, SyncTimeDir dir) { + if (!panda->has_rtc) return; - LOGW("waiting for params to set safety model"); - while (1) { - if (do_exit) return NULL; + setenv("TZ", "UTC", 1); + struct tm sys_time = util::get_time(); + struct tm rtc_time = panda->get_rtc(); - const int result = read_db_value(NULL, "CarParams", &value, &value_sz); - if (value_sz > 0) break; - usleep(100*1000); + if (dir == SyncTimeDir::TO_PANDA) { + if (util::time_valid(sys_time)) { + // Write time to RTC if it looks reasonable + double seconds = difftime(mktime(&rtc_time), mktime(&sys_time)); + if (std::abs(seconds) > 1.1) { + panda->set_rtc(sys_time); + LOGW("Updating panda RTC. dt = %.2f System: %s RTC: %s", + seconds, get_time_str(sys_time).c_str(), get_time_str(rtc_time).c_str()); + } + } + } else if (dir == SyncTimeDir::FROM_PANDA) { + if (!util::time_valid(sys_time) && util::time_valid(rtc_time)) { + const struct timeval tv = {mktime(&rtc_time), 0}; + settimeofday(&tv, 0); + LOGE("System time wrong, setting from RTC. System: %s RTC: %s", + get_time_str(sys_time).c_str(), get_time_str(rtc_time).c_str()); + } } - LOGW("got %d bytes CarParams", value_sz); - - // 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); +} - capnp::FlatArrayMessageReader cmsg(amsg); - cereal::CarParams::Reader car_params = cmsg.getRoot(); +bool safety_setter_thread(std::vector pandas) { + LOGD("Starting safety setter thread"); - 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; - default: - LOGE("unknown safety model: %d", safety_model); + // there should be at least one panda connected + if (pandas.size() == 0) { + return false; } - pthread_mutex_lock(&usb_lock); - - // set in the mutex to avoid race - safety_setter_thread_handle = -1; - - // 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); + pandas[0]->set_safety_model(cereal::CarParams::SafetyModel::ELM327); - libusb_control_transfer(dev_handle, 0x40, 0xdc, safety_setting, safety_param, NULL, 0, TIMEOUT); + Params p = Params(); - pthread_mutex_unlock(&usb_lock); - - return NULL; -} - -// must be called before threads or with mutex -bool usb_connect() { - int err; - unsigned char is_pigeon[1] = {0}; + // switch to SILENT when CarVin param is read + while (true) { + if (do_exit || !check_all_connected(pandas) || !ignition) { + return false; + } - dev_handle = libusb_open_device_with_vid_pid(ctx, 0xbbaa, 0xddcc); - if (dev_handle == NULL) { goto fail; } + std::string value_vin = p.get("CarVin"); + if (value_vin.size() > 0) { + // sanity check VIN format + assert(value_vin.size() == 17); + LOGW("got CarVin %s", value_vin.c_str()); + break; + } + util::sleep_for(20); + } - err = libusb_set_configuration(dev_handle, 1); - if (err != 0) { goto fail; } + pandas[0]->set_safety_model(cereal::CarParams::SafetyModel::ELM327, 1); - err = libusb_claim_interface(dev_handle, 0); - if (err != 0) { goto fail; } + std::string params; + LOGW("waiting for params to set safety model"); + while (true) { + for (const auto& panda : pandas) { + if (do_exit || !panda->connected || !ignition) { + return false; + } + } - if (loopback_can) { - libusb_control_transfer(dev_handle, 0xc0, 0xe5, 1, 0, NULL, 0, TIMEOUT); + if (p.getBool("ControlsReady")) { + params = p.get("CarParams"); + if (params.size() > 0) break; + } + util::sleep_for(100); } + LOGW("got %d bytes CarParams", params.size()); - // power off ESP - libusb_control_transfer(dev_handle, 0xc0, 0xd9, 0, 0, NULL, 0, TIMEOUT); - - // 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 + AlignedBuffer aligned_buf; + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(params.data(), params.size())); + cereal::CarParams::Reader car_params = cmsg.getRoot(); + cereal::CarParams::SafetyModel safety_model; + int safety_param; - // diagnostic only is the default, needed for VIN query - libusb_control_transfer(dev_handle, 0x40, 0xdc, SAFETY_ELM327, 0, NULL, 0, TIMEOUT); + auto safety_configs = car_params.getSafetyConfigs(); + for (uint32_t i=0; i i) { + safety_model = safety_configs[i].getSafetyModel(); + safety_param = safety_configs[i].getSafetyParam(); + } else { + // If no safety mode is specified, default to silent + safety_model = cereal::CarParams::SafetyModel::SILENT; + safety_param = 0; + } - libusb_control_transfer(dev_handle, 0xc0, 0xc1, 0, 0, is_pigeon, 1, TIMEOUT); + LOGW("panda %d: setting safety model: %d with param %d", i, (int)safety_model, safety_param); - if (is_pigeon[0]) { - LOGW("grey panda detected"); - is_grey_panda = true; - pigeon_needs_init = true; - if (pigeon_thread_handle == -1) { - err = pthread_create(&pigeon_thread_handle, NULL, pigeon_thread, NULL); - assert(err == 0); - } + panda->set_unsafe_mode(0); // see safety_declarations.h for allowed values + panda->set_safety_model(safety_model, safety_param); } return true; -fail: - return false; } -void usb_retry_connect() { - LOG("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(); +Panda *usb_connect(std::string serial="", uint32_t index=0) { + std::unique_ptr panda; + try { + panda = std::make_unique(serial, (index * PANDA_BUS_CNT)); + } catch (std::exception &e) { + return nullptr; } - // 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; + if (getenv("BOARDD_LOOPBACK")) { + panda->set_loopback(true); + } - uint64_t start_time = nanos_since_boot(); + // power on charging, only the first time. Panda can also change mode and it causes a brief disconneciton +#ifndef __x86_64__ + static std::once_flag connected_once; + std::call_once(connected_once, &Panda::set_usb_power_mode, panda, cereal::PeripheralState::UsbPowerMode::CDP); +#endif - // do recv - pthread_mutex_lock(&usb_lock); + sync_time(panda.get(), SyncTimeDir::FROM_PANDA); + return panda.release(); +} - 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); }; +void can_send_thread(std::vector pandas, bool fake_send) { + util::set_thread_name("boardd_can_send"); - // timeout is okay to exit, recv still happened - if (err == -7) { break; } - } while(err != 0); + AlignedBuffer aligned_buf; + std::unique_ptr context(Context::create()); + std::unique_ptr subscriber(SubSocket::create(context.get(), "sendcan")); + assert(subscriber != NULL); + subscriber->setTimeout(100); - pthread_mutex_unlock(&usb_lock); + // run as fast as messages come in + while (!do_exit && check_all_connected(pandas)) { + std::unique_ptr msg(subscriber->receive()); + if (!msg) { + if (errno == EINTR) { + do_exit = true; + } + continue; + } - // return if length is 0 - if (recv <= 0) { - return; - } + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(msg.get())); + cereal::Event::Reader event = cmsg.getRoot(); - // 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); + //Dont send if older than 1 second + if ((nanos_since_boot() - event.getLogMonoTime() < 1e9) && !fake_send) { + for (const auto& panda : pandas) { + panda->can_send(event.getSendcan()); + } } - 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; +void can_recv_thread(std::vector pandas) { + util::set_thread_name("boardd_can_recv"); - // copied from board/main.c - struct __attribute__((packed)) 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; - } health; + // can = 8006 + PubMaster pm({"can"}); - // recv from board - pthread_mutex_lock(&usb_lock); + // run at 100hz + const uint64_t dt = 10000000ULL; + uint64_t next_frame_time = nanos_since_boot() + dt; + std::vector raw_can_data; + + while (!do_exit && check_all_connected(pandas)) { + bool comms_healthy = true; + raw_can_data.clear(); + for (const auto& panda : pandas) { + comms_healthy &= panda->can_receive(raw_can_data); + } - 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)); + MessageBuilder msg; + auto evt = msg.initEvent(); + evt.setValid(comms_healthy); + auto canData = evt.initCan(raw_can_data.size()); + for (uint i = 0; i 0) { + std::this_thread::sleep_for(std::chrono::nanoseconds(remaining)); + } else { + if (ignition) { + LOGW("missed cycles (%d) %lld", (int)-1*remaining/dt, remaining); + } + next_frame_time = cur_time; + } - // 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); + next_frame_time += dt; } - healthData.setControlsAllowed(health.controls_allowed); - healthData.setGasInterceptorDetected(health.gas_interceptor_detected); - healthData.setStartedSignalDetected(health.started_signal_detected); - healthData.setIsGreyPanda(is_grey_panda); - - // send to health - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s, bytes.begin(), bytes.size(), 0); } +void send_empty_peripheral_state(PubMaster *pm) { + MessageBuilder msg; + auto peripheralState = msg.initEvent().initPeripheralState(); + peripheralState.setPandaType(cereal::PandaState::PandaType::UNKNOWN); + pm->send("peripheralState", msg); +} + +void send_empty_panda_state(PubMaster *pm) { + MessageBuilder msg; + auto pandaStates = msg.initEvent().initPandaStates(1); + pandaStates[0].setPandaType(cereal::PandaState::PandaType::UNKNOWN); + pm->send("pandaStates", msg); +} -void can_send(void *s) { - int err; +bool send_panda_states(PubMaster *pm, const std::vector &pandas, bool spoofing_started) { + bool ignition_local = false; - // recv from sendcan - zmq_msg_t msg; - zmq_msg_init(&msg); - err = zmq_msg_recv(&msg, s, 0); - assert(err >= 0); + // build msg + MessageBuilder msg; + auto evt = msg.initEvent(); + auto pss = evt.initPandaStates(pandas.size()); - // 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)); + std::vector pandaStates; + for (const auto& panda : pandas){ + health_t pandaState = panda->get_state(); + + if (spoofing_started) { + pandaState.ignition_line = 1; + } - 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; + ignition_local |= ((pandaState.ignition_line != 0) || (pandaState.ignition_can != 0)); + + pandaStates.push_back(pandaState); } - int msg_count = event.getCan().size(); - uint32_t *send = (uint32_t*)malloc(msg_count*0x10); - memset(send, 0, msg_count*0x10); + for (uint32_t i=0; i= 0x800) { - // extended - send[i*4] = (cmsg.getAddress() << 3) | 5; - } else { - // normal - send[i*4] = (cmsg.getAddress() << 21) | 1; + // Make sure CAN buses are live: safety_setter_thread does not work if Panda CAN are silent and there is only one other CAN node + if (pandaState.safety_model == (uint8_t)(cereal::CarParams::SafetyModel::SILENT)) { + panda->set_safety_model(cereal::CarParams::SafetyModel::NO_OUTPUT); } - 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); + #ifndef __x86_64__ + bool power_save_desired = !ignition_local && !pigeon_active; + if (pandaState.power_save_enabled != power_save_desired) { + panda->set_power_saving(power_save_desired); + } - // send to board - int sent; - pthread_mutex_lock(&usb_lock); + // set safety mode to NO_OUTPUT when car is off. ELM327 is an alternative if we want to leverage athenad/connect + if (!ignition_local && (pandaState.safety_model != (uint8_t)(cereal::CarParams::SafetyModel::NO_OUTPUT))) { + panda->set_safety_model(cereal::CarParams::SafetyModel::NO_OUTPUT); + } + #endif - 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); - } + if (!panda->comms_healthy) { + evt.setValid(false); + } - pthread_mutex_unlock(&usb_lock); + auto ps = pss[i]; + ps.setUptime(pandaState.uptime); + ps.setIgnitionLine(pandaState.ignition_line); + ps.setIgnitionCan(pandaState.ignition_can); + ps.setControlsAllowed(pandaState.controls_allowed); + ps.setGasInterceptorDetected(pandaState.gas_interceptor_detected); + ps.setCanRxErrs(pandaState.can_rx_errs); + ps.setCanSendErrs(pandaState.can_send_errs); + ps.setCanFwdErrs(pandaState.can_fwd_errs); + ps.setGmlanSendErrs(pandaState.gmlan_send_errs); + ps.setPandaType(panda->hw_type); + ps.setSafetyModel(cereal::CarParams::SafetyModel(pandaState.safety_model)); + ps.setSafetyParam(pandaState.safety_param); + ps.setFaultStatus(cereal::PandaState::FaultStatus(pandaState.fault_status)); + ps.setPowerSaveEnabled((bool)(pandaState.power_save_enabled)); + ps.setHeartbeatLost((bool)(pandaState.heartbeat_lost)); + ps.setHarnessStatus(cereal::PandaState::HarnessStatus(pandaState.car_harness_status)); + + // Convert faults bitset to capnp list + std::bitset fault_bits(pandaState.faults); + auto faults = ps.initFaults(fault_bits.count()); + + size_t j = 0; + for (size_t f = size_t(cereal::PandaState::FaultType::RELAY_MALFUNCTION); + f <= size_t(cereal::PandaState::FaultType::INTERRUPT_RATE_TICK); f++) { + if (fault_bits.test(f)) { + faults.set(j, cereal::PandaState::FaultType(f)); + j++; + } + } + } - // done - free(send); + pm->send("pandaStates", msg); + return ignition_local; } -// **** threads **** +void send_peripheral_state(PubMaster *pm, Panda *panda) { + health_t pandaState = panda->get_state(); -void *can_send_thread(void *crap) { - LOGD("start send thread"); + // build msg + MessageBuilder msg; + auto evt = msg.initEvent(); + evt.setValid(panda->comms_healthy); - // sendcan = 8017 - void *context = zmq_ctx_new(); - void *subscriber = sub_sock(context, "tcp://127.0.0.1:8017"); + auto ps = evt.initPeripheralState(); + ps.setPandaType(panda->hw_type); - // 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); + if (Hardware::TICI()) { + double read_time = millis_since_boot(); + ps.setVoltage(std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str())); + ps.setCurrent(std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str())); + read_time = millis_since_boot() - read_time; + if (read_time > 50) { + LOGW("reading hwmon took %lfms", read_time); + } + } else { + ps.setVoltage(pandaState.voltage); + ps.setCurrent(pandaState.current); } - // run as fast as messages come in - while (!do_exit) { - can_send(subscriber); - } - return NULL; + uint16_t fan_speed_rpm = panda->get_fan_speed(); + ps.setUsbPowerMode(cereal::PeripheralState::UsbPowerMode(pandaState.usb_power_mode)); + ps.setFanSpeedRpm(fan_speed_rpm); + + pm->send("peripheralState", msg); } -void *can_recv_thread(void *crap) { - LOGD("start recv thread"); +void panda_state_thread(PubMaster *pm, std::vector pandas, bool spoofing_started) { + util::set_thread_name("boardd_panda_state"); - // can = 8006 - void *context = zmq_ctx_new(); - void *publisher = zmq_socket(context, ZMQ_PUB); - zmq_bind(publisher, "tcp://*:8006"); + Params params; + Panda *peripheral_panda = pandas[0]; + bool ignition_last = false; + std::future safety_future; - // run at 100hz - const uint64_t dt = 10000000ULL; - uint64_t next_frame_time = nanos_since_boot() + dt; + LOGD("start panda state thread"); - while (!do_exit) { - can_recv(publisher); + // run at 2hz + while (!do_exit && check_all_connected(pandas)) { + // send out peripheralState + send_peripheral_state(pm, peripheral_panda); + ignition = send_panda_states(pm, pandas, spoofing_started); - uint64_t cur_time = nanos_since_boot(); - int64_t remaining = next_frame_time - cur_time; - if (remaining > 0){ - useconds_t sleep = remaining / 1000; - usleep(sleep); - } else { - LOGW("missed cycle"); - next_frame_time = cur_time; + // TODO: make this check fast, currently takes 16ms + // check if we have new pandas and are offroad + if (!ignition && (pandas.size() != Panda::list().size())) { + LOGW("Reconnecting to changed amount of pandas!"); + do_exit = true; + break; } - next_frame_time += dt; - } - return NULL; -} - -void *can_health_thread(void *crap) { - LOGD("start health thread"); + // clear ignition-based params and set new safety on car start + if (ignition && !ignition_last) { + params.clearAll(CLEAR_ON_IGNITION_ON); + if (!safety_future.valid() || safety_future.wait_for(0ms) == std::future_status::ready) { + safety_future = std::async(std::launch::async, safety_setter_thread, pandas); + } else { + LOGW("Safety setter thread already running"); + } + } else if (!ignition && ignition_last) { + params.clearAll(CLEAR_ON_IGNITION_OFF); + } - // health = 8011 - void *context = zmq_ctx_new(); - void *publisher = zmq_socket(context, ZMQ_PUB); - zmq_bind(publisher, "tcp://*:8011"); + ignition_last = ignition; - // run at 1hz - while (!do_exit) { - can_health(publisher); - usleep(1000*1000); + for (const auto &panda : pandas) { + panda->send_heartbeat(); + } + util::sleep_for(500); } - return NULL; } -#define pigeon_send(x) _pigeon_send(x, sizeof(x)-1) -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"); -} +void peripheral_control_thread(Panda *panda) { + util::set_thread_name("boardd_peripheral_control"); -void _pigeon_send(const char *dat, int len) { - int sent; - unsigned char a[0x20]; - int err; - a[0] = 1; - for (int i=0; iconnected) { + cnt++; + sm.update(1000); // TODO: what happens if EINTR is sent while in sm.update? + + if (!Hardware::PC() && sm.updated("deviceState")) { + // Charging mode + bool charging_disabled = sm["deviceState"].getDeviceState().getChargingDisabled(); + if (charging_disabled != prev_charging_disabled) { + if (charging_disabled) { + panda->set_usb_power_mode(cereal::PeripheralState::UsbPowerMode::CLIENT); + LOGW("TURN OFF CHARGING!\n"); + } else { + panda->set_usb_power_mode(cereal::PeripheralState::UsbPowerMode::CDP); + LOGW("TURN ON CHARGING!\n"); + } + prev_charging_disabled = charging_disabled; + } + } -static void pigeon_publish_raw(void *publisher, unsigned char *dat, int alen) { - // 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); -} + // Other pandas don't have fan/IR to control + if (panda->hw_type != cereal::PandaState::PandaType::UNO && panda->hw_type != cereal::PandaState::PandaType::DOS) continue; + if (sm.updated("deviceState")) { + // Fan speed + uint16_t fan_speed = sm["deviceState"].getDeviceState().getFanSpeedPercentDesired(); + if (fan_speed != prev_fan_speed || cnt % 100 == 0) { + panda->set_fan_speed(fan_speed); + prev_fan_speed = fan_speed; + } + } + if (sm.updated("driverCameraState")) { + auto event = sm["driverCameraState"]; + int cur_integ_lines = event.getDriverCameraState().getIntegLines(); + float cur_gain = event.getDriverCameraState().getGain(); + if (Hardware::TICI()) { + cur_integ_lines = integ_lines_filter.update(cur_integ_lines * cur_gain); + } + last_front_frame_t = event.getLogMonoTime(); -void *pigeon_thread(void *crap) { - // 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(); + 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 { - pigeon_publish_raw(publisher, dat, alen); + 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; + } - // 10ms - usleep(10*1000); - cnt++; - } - - return NULL; -} + if (ir_pwr != prev_ir_pwr || cnt % 100 == 0 || ir_pwr >= 50.0) { + panda->set_ir_pwr(ir_pwr); + prev_ir_pwr = ir_pwr; + } -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); + // Write to rtc once per minute when no ignition present + if (!ignition && (cnt % 120 == 1)) { + sync_time(panda, SyncTimeDir::TO_PANDA); + } + } } +static void pigeon_publish_raw(PubMaster &pm, const std::string &dat) { + // create message + MessageBuilder msg; + msg.initEvent().setUbloxRaw(capnp::Data::Reader((uint8_t*)dat.data(), dat.length())); + pm.send("ubloxRaw", msg); } -int main() { - int err; - LOGW("starting boardd"); - - // set process priority - err = set_realtime_priority(4); - LOG("setpriority returns %d", err); +void pigeon_thread(Panda *panda) { + util::set_thread_name("boardd_pigeon"); + + PubMaster pm({"ubloxRaw"}); + bool ignition_last = false; + + std::unique_ptr pigeon(Hardware::TICI() ? Pigeon::connect("/dev/ttyHS0") : Pigeon::connect(panda)); + + std::unordered_map last_recv_time; + std::unordered_map cls_max_dt = { + {(char)ublox::CLASS_NAV, int64_t(900000000ULL)}, // 0.9s + {(char)ublox::CLASS_RXM, int64_t(900000000ULL)}, // 0.9s + }; + + while (!do_exit && panda->connected) { + bool need_reset = false; + bool ignition_local = ignition; + std::string recv = pigeon->receive(); + + // Parse message header + if (ignition_local && recv.length() >= 3) { + if (recv[0] == (char)ublox::PREAMBLE1 && recv[1] == (char)ublox::PREAMBLE2) { + const char msg_cls = recv[2]; + uint64_t t = nanos_since_boot(); + if (t > last_recv_time[msg_cls]) { + last_recv_time[msg_cls] = t; + } + } + } - // check the environment - if (getenv("STARTED")) { - spoofing_started = true; - } + // Check based on message frequency + for (const auto& [msg_cls, max_dt] : cls_max_dt) { + int64_t dt = (int64_t)nanos_since_boot() - (int64_t)last_recv_time[msg_cls]; + if (ignition_last && ignition_local && dt > max_dt) { + LOGD("ublox receive timeout, msg class: 0x%02x, dt %llu", msg_cls, dt); + // TODO: turn on reset after verification of logs + // need_reset = true; + } + } - if (getenv("FAKESEND")) { - fake_send = true; - } + // Check based on null bytes + if (ignition_local && recv.length() > 0 && recv[0] == (char)0x00) { + need_reset = true; + LOGW("received invalid ublox message while onroad, resetting panda GPS"); + } - if (getenv("BOARDD_LOOPBACK")){ - loopback_can = true; - } + if (recv.length() > 0) { + pigeon_publish_raw(pm, recv); + } - // init libusb - err = libusb_init(&ctx); - assert(err == 0); - libusb_set_debug(ctx, 3); + // init pigeon on rising ignition edge + // since it was turned off in low power mode + if((ignition_local && !ignition_last) || need_reset) { + pigeon_active = true; + pigeon->init(); - // connect to the board - usb_retry_connect(); + // Set receive times to current time + uint64_t t = nanos_since_boot() + 10000000000ULL; // Give ublox 10 seconds to start + for (const auto& [msg_cls, dt] : cls_max_dt) { + last_recv_time[msg_cls] = t; + } + } else if (!ignition_local && ignition_last) { + // power off on falling edge of ignition + LOGD("powering off pigeon\n"); + pigeon->stop(); + pigeon->set_power(false); + pigeon_active = false; + } + ignition_last = ignition_local; - // create threads - pthread_t can_health_thread_handle; - err = pthread_create(&can_health_thread_handle, NULL, - can_health_thread, NULL); - assert(err == 0); + // 10ms - 100 Hz + util::sleep_for(10); + } +} - pthread_t can_send_thread_handle; - err = pthread_create(&can_send_thread_handle, NULL, - can_send_thread, NULL); - assert(err == 0); +int main(int argc, char *argv[]) { + LOGW("starting boardd"); - pthread_t can_recv_thread_handle; - err = pthread_create(&can_recv_thread_handle, NULL, - can_recv_thread, NULL); - assert(err == 0); + if (!Hardware::PC()) { + int err; + err = util::set_realtime_priority(54); + assert(err == 0); + err = util::set_core_affinity({Hardware::TICI() ? 4 : 3}); + assert(err == 0); + } - // join threads + LOGW("attempting to connect"); + PubMaster pm({"pandaStates", "peripheralState"}); + + std::vector serials(argv + 1, argv + argc); + if (serials.size() == 0) serials.push_back(""); + + // connect to all provided serials + std::vector pandas; + for (int i = 0; i < serials.size() && !do_exit; /**/) { + Panda *p = usb_connect(serials[i], i); + if (!p) { + // send empty pandaState & peripheralState and try again + send_empty_panda_state(&pm); + send_empty_peripheral_state(&pm); + util::sleep_for(500); + continue; + } - err = pthread_join(can_recv_thread_handle, NULL); - assert(err == 0); + pandas.push_back(p); + ++i; + } - err = pthread_join(can_send_thread_handle, NULL); - assert(err == 0); + if (!do_exit) { + LOGW("connected to board"); + Panda *peripheral_panda = pandas[0]; + std::vector threads; - err = pthread_join(can_health_thread_handle, NULL); - assert(err == 0); + threads.emplace_back(panda_state_thread, &pm, pandas, getenv("STARTED") != nullptr); + threads.emplace_back(peripheral_control_thread, peripheral_panda); + threads.emplace_back(pigeon_thread, peripheral_panda); - //while (!do_exit) usleep(1000); + threads.emplace_back(can_send_thread, pandas, getenv("FAKESEND") != nullptr); + threads.emplace_back(can_recv_thread, pandas); - // destruct libusb + for (auto &t : threads) t.join(); + } - libusb_close(dev_handle); - libusb_exit(ctx); + // we have exited, clean up pandas + for (Panda *panda : pandas) { + delete panda; + } } 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..0d428a9259c7af 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 @@ -13,6 +14,8 @@ cdef extern void can_list_to_can_capnp_cpp(const vector[can_frame] &can_list, st def can_list_to_can_capnp(can_msgs, msgtype='can', valid=True): cdef vector[can_frame] can_list + can_list.reserve(len(can_msgs)) + cdef can_frame f for can_msg in can_msgs: f.address = can_msg[0] 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..faa0e37373546e 100644 --- a/selfdrive/boardd/can_list_to_can_capnp.cc +++ b/selfdrive/boardd/can_list_to_can_capnp.cc @@ -1,37 +1,25 @@ -#include -#include -#include -#include "common/timing.h" -#include -#include "cereal/gen/cpp/log.capnp.h" -#include "cereal/gen/cpp/car.capnp.h" - -typedef struct { - long address; - std::string dat; - long busTime; - long src; -} can_frame; +#include "cereal/messaging/messaging.h" +#include "panda.h" 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(); - out.append((const char *)bytes.begin(), bytes.size()); + const uint64_t msg_size = capnp::computeSerializedSizeInWords(msg) * sizeof(capnp::word); + out.resize(msg_size); + kj::ArrayOutputStream output_stream(kj::ArrayPtr((unsigned char *)out.data(), msg_size)); + capnp::writeMessage(output_stream, msg); } } diff --git a/selfdrive/boardd/panda.cc b/selfdrive/boardd/panda.cc new file mode 100644 index 00000000000000..751f735ca589c4 --- /dev/null +++ b/selfdrive/boardd/panda.cc @@ -0,0 +1,460 @@ +#include "selfdrive/boardd/panda.h" + +#include + +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "panda/board/dlc_to_len.h" +#include "selfdrive/common/gpio.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" + +static int init_usb_ctx(libusb_context **context) { + assert(context != nullptr); + + int err = libusb_init(context); + if (err != 0) { + LOGE("libusb initialization error"); + return err; + } + +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option(*context, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO); +#else + libusb_set_debug(*context, 3); +#endif + + return err; +} + + +Panda::Panda(std::string serial, uint32_t bus_offset) : bus_offset(bus_offset) { + // init libusb + ssize_t num_devices; + libusb_device **dev_list = NULL; + int err = init_usb_ctx(&ctx); + if (err != 0) { goto fail; } + + // connect by serial + num_devices = libusb_get_device_list(ctx, &dev_list); + if (num_devices < 0) { goto fail; } + for (size_t i = 0; i < num_devices; ++i) { + libusb_device_descriptor desc; + libusb_get_device_descriptor(dev_list[i], &desc); + if (desc.idVendor == 0xbbaa && desc.idProduct == 0xddcc) { + libusb_open(dev_list[i], &dev_handle); + if (dev_handle == NULL) { goto fail; } + + unsigned char desc_serial[26] = { 0 }; + int ret = libusb_get_string_descriptor_ascii(dev_handle, desc.iSerialNumber, desc_serial, std::size(desc_serial)); + if (ret < 0) { goto fail; } + + usb_serial = std::string((char *)desc_serial, ret).c_str(); + if (serial.empty() || serial == usb_serial) { + break; + } + libusb_close(dev_handle); + dev_handle = NULL; + } + } + if (dev_handle == NULL) goto fail; + libusb_free_device_list(dev_list, 1); + dev_list = nullptr; + + 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(); + + assert((hw_type != cereal::PandaState::PandaType::WHITE_PANDA) && + (hw_type != cereal::PandaState::PandaType::GREY_PANDA)); + + has_rtc = (hw_type == cereal::PandaState::PandaType::UNO) || + (hw_type == cereal::PandaState::PandaType::DOS); + + return; + +fail: + if (dev_list != NULL) { + libusb_free_device_list(dev_list, 1); + } + cleanup(); + throw std::runtime_error("Error connecting to panda"); +} + +Panda::~Panda() { + std::lock_guard lk(usb_lock); + cleanup(); + connected = false; +} + +void Panda::cleanup() { + if (dev_handle) { + libusb_release_interface(dev_handle, 0); + libusb_close(dev_handle); + } + + if (ctx) { + libusb_exit(ctx); + } +} + +std::vector Panda::list() { + // init libusb + ssize_t num_devices; + libusb_context *context = NULL; + libusb_device **dev_list = NULL; + std::vector serials; + + int err = init_usb_ctx(&context); + if (err != 0) { return serials; } + + num_devices = libusb_get_device_list(context, &dev_list); + if (num_devices < 0) { + LOGE("libusb can't get device list"); + goto finish; + } + for (size_t i = 0; i < num_devices; ++i) { + libusb_device *device = dev_list[i]; + libusb_device_descriptor desc; + libusb_get_device_descriptor(device, &desc); + if (desc.idVendor == 0xbbaa && desc.idProduct == 0xddcc) { + libusb_device_handle *handle = NULL; + libusb_open(device, &handle); + unsigned char desc_serial[26] = { 0 }; + int ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, desc_serial, std::size(desc_serial)); + libusb_close(handle); + + if (ret < 0) { goto finish; } + serials.push_back(std::string((char *)desc_serial, ret).c_str()); + } + } + +finish: + if (dev_list != NULL) { + libusb_free_device_list(dev_list, 1); + } + if (context) { + libusb_exit(context); + } + return serials; +} + +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; + } + + std::lock_guard lk(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); + + 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; + + if (!connected) { + return LIBUSB_ERROR_NO_DEVICE; + } + + std::lock_guard lk(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); + + 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; + } + + std::lock_guard lk(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); + + 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; + } + + std::lock_guard lk(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) { + comms_healthy = false; + LOGE_100("overflow got 0x%x", transferred); + } else if (err != 0) { + handle_usb_issue(err, __func__); + } + + } while(err != 0 && connected); + + 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::PandaState::PandaType Panda::get_hw_type() { + unsigned char hw_query[1] = {0}; + + usb_read(0xc1, 0, 0, hw_query, 1); + return (cereal::PandaState::PandaType)(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_state() { + 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); +} + +std::optional> Panda::get_firmware_version() { + std::vector fw_sig_buf(128); + int read_1 = usb_read(0xd3, 0, 0, &fw_sig_buf[0], 64); + int read_2 = usb_read(0xd4, 0, 0, &fw_sig_buf[64], 64); + return ((read_1 == 64) && (read_2 == 64)) ? std::make_optional(fw_sig_buf) : std::nullopt; +} + +std::optional Panda::get_serial() { + char serial_buf[17] = {'\0'}; + int err = usb_read(0xd0, 0, 0, (uint8_t*)serial_buf, 16); + return err >= 0 ? std::make_optional(serial_buf) : std::nullopt; +} + +void Panda::set_power_saving(bool power_saving) { + usb_write(0xe7, power_saving, 0); +} + +void Panda::set_usb_power_mode(cereal::PeripheralState::UsbPowerMode power_mode) { + usb_write(0xe6, (uint16_t)power_mode, 0); +} + +void Panda::send_heartbeat() { + usb_write(0xf3, 1, 0); +} + +void Panda::set_can_speed_kbps(uint16_t bus, uint16_t speed) { + usb_write(0xde, bus, (speed * 10)); +} + +void Panda::set_data_speed_kbps(uint16_t bus, uint16_t speed) { + usb_write(0xf9, bus, (speed * 10)); +} + +static uint8_t len_to_dlc(uint8_t len) { + if (len <= 8) { + return len; + } + if (len <= 24) { + return 8 + ((len - 8) / 4) + ((len % 4) ? 1 : 0); + } else { + return 11 + (len / 16) + ((len % 16) ? 1 : 0); + } +} + +static void write_packet(uint8_t *dest, int *write_pos, const uint8_t *src, size_t size) { + for (int i = 0, &pos = *write_pos; i < size; ++i, ++pos) { + // Insert counter every 64 bytes (first byte of 64 bytes USB packet) + if (pos % USBPACKET_MAX_SIZE == 0) { + dest[pos] = pos / USBPACKET_MAX_SIZE; + pos++; + } + dest[pos] = src[i]; + } +} + +void Panda::pack_can_buffer(const capnp::List::Reader &can_data_list, + std::function write_func) { + int32_t pos = 0; + uint8_t send_buf[2 * USB_TX_SOFT_LIMIT]; + + for (auto cmsg : can_data_list) { + // check if the message is intended for this panda + uint8_t bus = cmsg.getSrc(); + if (bus < bus_offset || bus >= (bus_offset + PANDA_BUS_CNT)) { + continue; + } + auto can_data = cmsg.getDat(); + uint8_t data_len_code = len_to_dlc(can_data.size()); + assert(can_data.size() <= ((hw_type == cereal::PandaState::PandaType::RED_PANDA) ? 64 : 8)); + assert(can_data.size() == dlc_to_len[data_len_code]); + + can_header header; + header.addr = cmsg.getAddress(); + header.extended = (cmsg.getAddress() >= 0x800) ? 1 : 0; + header.data_len_code = data_len_code; + header.bus = bus - bus_offset; + + write_packet(send_buf, &pos, (uint8_t *)&header, sizeof(can_header)); + write_packet(send_buf, &pos, (uint8_t *)can_data.begin(), can_data.size()); + if (pos >= USB_TX_SOFT_LIMIT) { + write_func(send_buf, pos); + pos = 0; + } + } + + // send remaining packets + if (pos > 0) write_func(send_buf, pos); +} + +void Panda::can_send(capnp::List::Reader can_data_list) { + pack_can_buffer(can_data_list, [=](uint8_t* data, size_t size) { + usb_bulk_write(3, data, size, 5); + }); +} + +bool Panda::can_receive(std::vector& out_vec) { + uint8_t data[RECV_SIZE]; + int recv = usb_bulk_read(0x81, (uint8_t*)data, RECV_SIZE); + if (!comms_healthy) { + return false; + } + if (recv == RECV_SIZE) { + LOGW("Panda receive buffer full"); + } + + return (recv <= 0) ? true : unpack_can_buffer(data, recv, out_vec); +} + +bool Panda::unpack_can_buffer(uint8_t *data, int size, std::vector &out_vec) { + recv_buf.clear(); + for (int i = 0; i < size; i += USBPACKET_MAX_SIZE) { + if (data[i] != i / USBPACKET_MAX_SIZE) { + LOGE("CAN: MALFORMED USB RECV PACKET"); + comms_healthy = false; + return false; + } + int chunk_len = std::min(USBPACKET_MAX_SIZE, (size - i)); + recv_buf.insert(recv_buf.end(), &data[i + 1], &data[i + chunk_len]); + } + + int pos = 0; + while (pos < recv_buf.size()) { + can_header header; + memcpy(&header, &recv_buf[pos], CANPACKET_HEAD_SIZE); + + can_frame &canData = out_vec.emplace_back(); + canData.busTime = 0; + canData.address = header.addr; + canData.src = header.bus + bus_offset; + if (header.rejected) { canData.src += CANPACKET_REJECTED; } + if (header.returned) { canData.src += CANPACKET_RETURNED; } + + const uint8_t data_len = dlc_to_len[header.data_len_code]; + canData.dat.assign((char *)&recv_buf[pos + CANPACKET_HEAD_SIZE], data_len); + + pos += CANPACKET_HEAD_SIZE + data_len; + } + return true; +} diff --git a/selfdrive/boardd/panda.h b/selfdrive/boardd/panda.h new file mode 100644 index 00000000000000..fe69189489e4fe --- /dev/null +++ b/selfdrive/boardd/panda.h @@ -0,0 +1,123 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "cereal/gen/cpp/car.capnp.h" +#include "cereal/gen/cpp/log.capnp.h" + +#define TIMEOUT 0 +#define PANDA_BUS_CNT 4 +#define RECV_SIZE (0x4000U) +#define USB_TX_SOFT_LIMIT (0x100U) +#define USBPACKET_MAX_SIZE (0x40) +#define CANPACKET_HEAD_SIZE 5U +#define CANPACKET_MAX_SIZE 72U +#define CANPACKET_REJECTED (0xC0U) +#define CANPACKET_RETURNED (0x80U) + +// 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; + int16_t safety_param; + uint8_t fault_status; + uint8_t power_save_enabled; + uint8_t heartbeat_lost; +}; + +struct __attribute__((packed)) can_header { + uint8_t reserved : 1; + uint8_t bus : 3; + uint8_t data_len_code : 4; + uint8_t rejected : 1; + uint8_t returned : 1; + uint8_t extended : 1; + uint32_t addr : 29; +}; + +struct can_frame { + long address; + std::string dat; + long busTime; + long src; +}; + +class Panda { + private: + libusb_context *ctx = NULL; + libusb_device_handle *dev_handle = NULL; + std::mutex usb_lock; + std::vector recv_buf; + void handle_usb_issue(int err, const char func[]); + void cleanup(); + + public: + Panda(std::string serial="", uint32_t bus_offset=0); + ~Panda(); + + std::string usb_serial; + std::atomic connected = true; + std::atomic comms_healthy = true; + cereal::PandaState::PandaType hw_type = cereal::PandaState::PandaType::UNKNOWN; + bool has_rtc = false; + const uint32_t bus_offset; + + // Static functions + static std::vector list(); + + // 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::PandaState::PandaType 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_state(); + void set_loopback(bool loopback); + std::optional> get_firmware_version(); + std::optional get_serial(); + void set_power_saving(bool power_saving); + void set_usb_power_mode(cereal::PeripheralState::UsbPowerMode power_mode); + void send_heartbeat(); + void set_can_speed_kbps(uint16_t bus, uint16_t speed); + void set_data_speed_kbps(uint16_t bus, uint16_t speed); + void can_send(capnp::List::Reader can_data_list); + bool can_receive(std::vector& out_vec); + +protected: + // for unit tests + Panda(uint32_t bus_offset) : bus_offset(bus_offset) {} + void pack_can_buffer(const capnp::List::Reader &can_data_list, + std::function write_func); + bool unpack_can_buffer(uint8_t *data, int size, std::vector &out_vec); +}; diff --git a/selfdrive/boardd/pigeon.cc b/selfdrive/boardd/pigeon.cc new file mode 100644 index 00000000000000..912f4b03e7d372 --- /dev/null +++ b/selfdrive/boardd/pigeon.cc @@ -0,0 +1,333 @@ +#include "selfdrive/boardd/pigeon.h" + +#include +#include +#include + +#include +#include +#include + +#include "selfdrive/common/gpio.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/locationd/ublox_msg.h" + +// Termios on macos doesn't define all baud rate constants +#ifndef B460800 +#define B460800 0010004 +#endif + +using namespace std::string_literals; + +extern ExitHandler do_exit; + +const std::string ack = "\xb5\x62\x05\x01\x02\x00"; +const std::string nack = "\xb5\x62\x05\x00\x02\x00"; +const std::string sos_save_ack = "\xb5\x62\x09\x14\x08\x00\x02\x00\x00\x00\x01\x00\x00\x00"; +const std::string sos_save_nack = "\xb5\x62\x09\x14\x08\x00\x02\x00\x00\x00\x00\x00\x00\x00"; + +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; +} + +bool Pigeon::wait_for_ack(const std::string &ack_, const std::string &nack_, int timeout_ms) { + std::string s; + const double start_t = millis_since_boot(); + while (!do_exit) { + s += receive(); + + if (s.find(ack_) != std::string::npos) { + LOGD("Received ACK from ublox"); + return true; + } else if (s.find(nack_) != std::string::npos) { + LOGE("Received NACK from ublox"); + return false; + } else if (s.size() > 0x1000 || ((millis_since_boot() - start_t) > timeout_ms)) { + LOGE("No response from ublox"); + return false; + } + + util::sleep_for(1); // Allow other threads to be scheduled + } + return false; +} + +bool Pigeon::wait_for_ack() { + return wait_for_ack(ack, nack); +} + +bool Pigeon::send_with_ack(const std::string &cmd) { + send(cmd); + return wait_for_ack(); +} + +sos_restore_response Pigeon::wait_for_backup_restore_status(int timeout_ms) { + std::string s; + const double start_t = millis_since_boot(); + while (!do_exit) { + s += receive(); + + size_t position = s.find("\xb5\x62\x09\x14\x08\x00\x03"); + if (position != std::string::npos && s.size() >= (position + 11)) { + return static_cast(s[position + 10]); + } else if (s.size() > 0x1000 || ((millis_since_boot() - start_t) > timeout_ms)) { + LOGE("No backup restore response from ublox"); + return error; + } + + util::sleep_for(1); // Allow other threads to be scheduled + } + return error; +} + +void Pigeon::init() { + for (int i = 0; i < 10; i++) { + if (do_exit) return; + LOGW("panda GPS start"); + + // power off pigeon + set_power(false); + util::sleep_for(100); + + // 9600 baud at init + set_baud(9600); + + // power on pigeon + set_power(true); + util::sleep_for(500); + + // 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); + util::sleep_for(100); + + // set baud rate to 460800 + set_baud(460800); + + // init from ubloxd + // To generate this data, run selfdrive/locationd/test/ubloxd.py + if (!send_with_ack("\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)) continue; + if (!send_with_ack("\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)) continue; + if (!send_with_ack("\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)) continue; + if (!send_with_ack("\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)) continue; + if (!send_with_ack("\xB5\x62\x06\x00\x00\x00\x06\x18"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x00\x01\x00\x01\x08\x22"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x00\x01\x00\x03\x0A\x24"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x08\x06\x00\x64\x00\x01\x00\x00\x00\x79\x10"s)) continue; + if (!send_with_ack("\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)) continue; + if (!send_with_ack("\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)) continue; + if (!send_with_ack("\xB5\x62\x06\x39\x08\x00\xFF\xAD\x62\xAD\x1E\x63\x00\x00\x83\x0C"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x24\x00\x00\x2A\x84"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x23\x00\x00\x29\x81"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x1E\x00\x00\x24\x72"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x39\x00\x00\x3F\xC3"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x01\x03\x00\x01\x07\x01\x13\x51"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x01\x03\x00\x02\x15\x01\x22\x70"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x01\x03\x00\x02\x13\x01\x20\x6C"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x01\x03\x00\x0A\x09\x01\x1E\x70"s)) continue; + if (!send_with_ack("\xB5\x62\x06\x01\x03\x00\x0A\x0B\x01\x20\x74"s)) continue; + + // check the backup restore status + send("\xB5\x62\x09\x14\x00\x00\x1D\x60"s); + sos_restore_response restore_status = wait_for_backup_restore_status(); + switch(restore_status) { + case restored: + LOGW("almanac backup restored"); + // clear the backup + send_with_ack("\xB5\x62\x06\x01\x03\x00\x0A\x0B\x01\x20\x74"s); + break; + case no_backup: + LOGW("no almanac backup found"); + break; + default: + LOGE("failed to restore almanac backup, status: %d", restore_status); + } + + auto time = util::get_time(); + if (util::time_valid(time)) { + LOGW("Sending current time to ublox"); + send(ublox::build_ubx_mga_ini_time_utc(time)); + } + + LOGW("panda GPS on"); + return; + } + LOGE("failed to initialize panda GPS"); +} + +void Pigeon::stop() { + LOGW("Storing almanac in ublox flash"); + + // Controlled GNSS stop + send("\xB5\x62\x06\x04\x04\x00\x00\x00\x08\x00\x16\x74"s); + + // Store almanac in flash + send("\xB5\x62\x09\x14\x04\x00\x00\x00\x00\x00\x21\xEC"s); + + if (wait_for_ack(sos_save_ack, sos_save_nack)) { + LOGW("Done storing almanac"); + } else { + LOGE("Error storing almanac"); + } +} + +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(const 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; + r.reserve(0x1000 + 0x40); + unsigned char dat[0x40]; + while (r.length() < 0x1000) { + int len = panda->usb_read(0xe0, 1, 0, dat, sizeof(dat)); + if (len <= 0) 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 = HANDLE_EINTR(open(tty, O_RDWR)); + if (pigeon_tty_fd < 0) { + handle_tty_issue(errno, __func__); + assert(pigeon_tty_fd >= 0); + } + int err = tcgetattr(pigeon_tty_fd, &pigeon_tty); + assert(err == 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) + + err = tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty); + assert(err == 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 + int err = tcdrain(pigeon_tty_fd); + assert(err == 0); + + // change baud + err = tcgetattr(pigeon_tty_fd, &pigeon_tty); + assert(err == 0); + err = cfsetspeed(&pigeon_tty, baud_const); + assert(err == 0); + err = tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty); + assert(err == 0); + + // flush + err = tcflush(pigeon_tty_fd, TCIOFLUSH); + assert(err == 0); +} + +void TTYPigeon::send(const std::string &s) { + int err = HANDLE_EINTR(write(pigeon_tty_fd, s.data(), s.length())); + + 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; + r.reserve(0x1000 + 0x40); + char dat[0x40]; + while (r.length() < 0x1000) { + int len = read(pigeon_tty_fd, dat, sizeof(dat)); + if(len < 0) { + handle_tty_issue(len, __func__); + } else if (len == 0) { + 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..c9ea4739dce700 --- /dev/null +++ b/selfdrive/boardd/pigeon.h @@ -0,0 +1,58 @@ +#pragma once + +#include + +#include +#include + +#include "selfdrive/boardd/panda.h" + +enum sos_restore_response : int { + unknown = 0, + failed = 1, + restored = 2, + no_backup = 3, + error = -1 +}; + +class Pigeon { + public: + static Pigeon* connect(Panda * p); + static Pigeon* connect(const char * tty); + virtual ~Pigeon(){}; + + void init(); + void stop(); + bool wait_for_ack(); + bool wait_for_ack(const std::string &ack, const std::string &nack, int timeout_ms = 1000); + bool send_with_ack(const std::string &cmd); + sos_restore_response wait_for_backup_restore_status(int timeout_ms = 1000); + virtual void set_baud(int baud) = 0; + virtual void send(const 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(const 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(const std::string &s); + std::string receive(); + void set_power(bool power); +}; diff --git a/selfdrive/boardd/set_time.py b/selfdrive/boardd/set_time.py new file mode 100755 index 00000000000000..7d17be4de90d74 --- /dev/null +++ b/selfdrive/boardd/set_time.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +import datetime +import os +import struct +import usb1 + +REQUEST_IN = usb1.ENDPOINT_IN | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE +MIN_DATE = datetime.datetime(year=2021, month=4, day=1) + +def set_time(logger): + sys_time = datetime.datetime.today() + if sys_time > MIN_DATE: + logger.info("System time valid") + return + + try: + ctx = usb1.USBContext() + dev = ctx.openByVendorIDAndProductID(0xbbaa, 0xddcc) + if dev is None: + logger.info("No panda found") + return + + # Set system time from panda RTC time + dat = dev.controlRead(REQUEST_IN, 0xa0, 0, 0, 8) + a = struct.unpack("HBBBBBB", dat) + panda_time = datetime.datetime(a[0], a[1], a[2], a[4], a[5], a[6]) + if panda_time > MIN_DATE: + logger.info(f"adjusting time from '{sys_time}' to '{panda_time}'") + os.system(f"TZ=UTC date -s '{panda_time}'") + except Exception: + logger.warn("Failed to fetch time from panda") + +if __name__ == "__main__": + import logging + logging.basicConfig(level=logging.INFO) + + set_time(logging) 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..85bc756bc1319c --- /dev/null +++ b/selfdrive/camerad/SConscript @@ -0,0 +1,47 @@ +Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc', 'USE_WEBCAM') + +libs = ['m', 'pthread', common, 'jpeg', 'OpenCL', 'yuv', cereal, messaging, 'zmq', 'capnp', 'kj', visionipc, gpucommon] + +if arch == "aarch64": + libs += ['gsl', 'CB', 'adreno_utils', 'EGL', 'GLESv3', 'cutils', 'ui'] + cameras = ['cameras/camera_qcom.cc'] +elif arch == "larch64": + libs += ['atomic'] + cameras = ['cameras/camera_qcom2.cc'] +else: + env['CXXFLAGS'] += ["-Wno-deprecated-declarations"] + 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/include/opencv4', '/usr/local/include/opencv4']) + else: + libs += ['avutil', 'avcodec', 'avformat', 'bz2', 'ssl', 'curl', 'crypto'] + # TODO: import replay_lib from root SConstruct + cameras = ['cameras/camera_replay.cc', + env.Object('camera-util', '#/selfdrive/ui/replay/util.cc'), + env.Object('camera-framereader', '#/selfdrive/ui/replay/framereader.cc'), + env.Object('camera-filereader', '#/selfdrive/ui/replay/filereader.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.Program('camerad', [ + 'main.cc', + 'cameras/camera_common.cc', + 'transforms/rgb_to_yuv.cc', + 'imgproc/utils.cc', + cameras, + ], LIBS=libs) + +if GetOption("test"): + env.Program('test/ae_gray_test', [ + 'test/ae_gray_test.cc', + 'cameras/camera_common.cc', + 'transforms/rgb_to_yuv.cc', + ], LIBS=libs) diff --git a/selfdrive/camerad/cameras/camera_common.cc b/selfdrive/camerad/cameras/camera_common.cc new file mode 100644 index 00000000000000..6dcbf18c4bf632 --- /dev/null +++ b/selfdrive/camerad/cameras/camera_common.cc @@ -0,0 +1,425 @@ +#include "selfdrive/camerad/cameras/camera_common.h" + +#include + +#include +#include +#include +#include + +#include "libyuv.h" +#include + +#include "selfdrive/camerad/imgproc/utils.h" +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/modeldata.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" + +#ifdef QCOM +#include "selfdrive/camerad/cameras/camera_qcom.h" +#elif QCOM2 +#include "selfdrive/camerad/cameras/camera_qcom2.h" +#elif WEBCAM +#include "selfdrive/camerad/cameras/camera_webcam.h" +#else +#include "selfdrive/camerad/cameras/camera_replay.h" +#endif + +class Debayer { +public: + Debayer(cl_device_id device_id, cl_context context, const CameraBuf *b, const CameraState *s) { + char args[4096]; + const CameraInfo *ci = &s->ci; + 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 -DCAM_NUM=%d", + ci->frame_width, ci->frame_height, ci->frame_stride, + b->rgb_width, b->rgb_height, b->rgb_stride, + ci->bayer_flip, ci->hdr, s->camera_num); + const char *cl_file = Hardware::TICI() ? "cameras/real_debayer.cl" : "cameras/debayer.cl"; + cl_program prg_debayer = cl_program_from_file(context, device_id, cl_file, args); + krnl_ = CL_CHECK_ERR(clCreateKernel(prg_debayer, "debayer10", &err)); + CL_CHECK(clReleaseProgram(prg_debayer)); + } + + void queue(cl_command_queue q, cl_mem cam_buf_cl, cl_mem buf_cl, int width, int height, float gain, cl_event *debayer_event) { + CL_CHECK(clSetKernelArg(krnl_, 0, sizeof(cl_mem), &cam_buf_cl)); + CL_CHECK(clSetKernelArg(krnl_, 1, sizeof(cl_mem), &buf_cl)); + + if (Hardware::TICI()) { + const int debayer_local_worksize = 16; + constexpr int localMemSize = (debayer_local_worksize + 2 * (3 / 2)) * (debayer_local_worksize + 2 * (3 / 2)) * sizeof(short int); + const size_t globalWorkSize[] = {size_t(width), size_t(height)}; + const size_t localWorkSize[] = {debayer_local_worksize, debayer_local_worksize}; + CL_CHECK(clSetKernelArg(krnl_, 2, localMemSize, 0)); + CL_CHECK(clEnqueueNDRangeKernel(q, krnl_, 2, NULL, globalWorkSize, localWorkSize, 0, 0, debayer_event)); + } else { + const size_t debayer_work_size = height; // doesn't divide evenly, is this okay? + CL_CHECK(clSetKernelArg(krnl_, 2, sizeof(float), &gain)); + CL_CHECK(clEnqueueNDRangeKernel(q, krnl_, 1, NULL, &debayer_work_size, NULL, 0, 0, debayer_event)); + } + } + + ~Debayer() { + CL_CHECK(clReleaseKernel(krnl_)); + } + +private: + cl_kernel krnl_; +}; + +void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType init_rgb_type, VisionStreamType init_yuv_type, release_cb init_release_callback) { + vipc_server = v; + this->rgb_type = init_rgb_type; + this->yuv_type = init_yuv_type; + this->release_callback = init_release_callback; + + const CameraInfo *ci = &s->ci; + camera_state = s; + frame_buf_count = frame_cnt; + + // RAW frame + const int 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].allocate(frame_size); + camera_bufs[i].init_cl(device_id, context); + } + + rgb_width = ci->frame_width; + rgb_height = ci->frame_height; + + if (!Hardware::TICI() && ci->bayer) { + // debayering does a 2x downscale + rgb_width = ci->frame_width / 2; + rgb_height = ci->frame_height / 2; + } + + yuv_transform = get_model_yuv_transform(ci->bayer); + + vipc_server->create_buffers(rgb_type, UI_BUF_COUNT, true, rgb_width, rgb_height); + rgb_stride = vipc_server->get_buffer(rgb_type)->stride; + + vipc_server->create_buffers(yuv_type, YUV_BUFFER_COUNT, false, rgb_width, rgb_height); + + if (ci->bayer) { + debayer = new Debayer(device_id, context, this, s); + } + rgb2yuv = std::make_unique(context, device_id, rgb_width, rgb_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++) { + camera_bufs[i].free(); + } + if (debayer) delete debayer; + if (q) CL_CHECK(clReleaseCommandQueue(q)); +} + +bool CameraBuf::acquire() { + if (!safe_queue.try_pop(cur_buf_idx, 1)) return false; + + if (camera_bufs_metadata[cur_buf_idx].frame_id == -1) { + LOGE("no frame data? wtf"); + release(); + return false; + } + + cur_frame_data = camera_bufs_metadata[cur_buf_idx]; + cur_rgb_buf = vipc_server->get_buffer(rgb_type); + cl_mem camrabuf_cl = camera_bufs[cur_buf_idx].buf_cl; + cl_event event; + + if (debayer) { + float gain = 0.0; + +#ifndef QCOM2 + gain = camera_state->digital_gain; + if ((int)gain == 0) gain = 1.0; +#endif + + debayer->queue(q, camrabuf_cl, cur_rgb_buf->buf_cl, rgb_width, rgb_height, gain, &event); + } else { + 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, &event)); + } + + clWaitForEvents(1, &event); + CL_CHECK(clReleaseEvent(event)); + + cur_yuv_buf = vipc_server->get_buffer(yuv_type); + rgb2yuv->queue(q, cur_rgb_buf->buf_cl, cur_yuv_buf->buf_cl); + + VisionIpcBufExtra extra = { + cur_frame_data.frame_id, + cur_frame_data.timestamp_sof, + cur_frame_data.timestamp_eof, + }; + cur_rgb_buf->set_frame_id(cur_frame_data.frame_id); + cur_yuv_buf->set_frame_id(cur_frame_data.frame_id); + vipc_server->send(cur_rgb_buf, &extra); + vipc_server->send(cur_yuv_buf, &extra); + + return true; +} + +void CameraBuf::release() { + if (release_callback) { + release_callback((void*)camera_state, cur_buf_idx); + } +} + +void CameraBuf::queue(size_t buf_idx) { + safe_queue.push(buf_idx); +} + +// common functions + +void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data) { + framed.setFrameId(frame_data.frame_id); + framed.setTimestampEof(frame_data.timestamp_eof); + framed.setTimestampSof(frame_data.timestamp_sof); + framed.setFrameLength(frame_data.frame_length); + framed.setIntegLines(frame_data.integ_lines); + framed.setGain(frame_data.gain); + framed.setHighConversionGain(frame_data.high_conversion_gain); + framed.setMeasuredGreyFraction(frame_data.measured_grey_fraction); + framed.setTargetGreyFraction(frame_data.target_grey_fraction); + 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); +} + +kj::Array get_frame_image(const CameraBuf *b) { + static const int x_min = util::getenv("XMIN", 0); + static const int y_min = util::getenv("YMIN", 0); + static const int env_xmax = util::getenv("XMAX", -1); + static const int env_ymax = util::getenv("YMAX", -1); + static const int scale = util::getenv("SCALE", 1); + + assert(b->cur_rgb_buf); + + const int x_max = env_xmax != -1 ? env_xmax : b->rgb_width - 1; + const int y_max = env_ymax != -1 ? env_ymax : b->rgb_height - 1; + const int new_width = (x_max - x_min + 1) / scale; + const int new_height = (y_max - y_min + 1) / scale; + const uint8_t *dat = (const uint8_t *)b->cur_rgb_buf->addr; + + kj::Array frame_image = kj::heapArray(new_width*new_height*3); + uint8_t *resized_dat = frame_image.begin(); + int goff = x_min*3 + y_min*b->rgb_stride; + for (int r=0;rrgb_stride*scale+c*3*scale], 3*sizeof(uint8_t)); + } + } + return kj::mv(frame_image); +} + +static kj::Array yuv420_to_jpeg(const CameraBuf *b, int thumbnail_width, int thumbnail_height) { + // make the buffer big enough. jpeg_write_raw_data requires 16-pixels aligned height to be used. + std::unique_ptr buf(new uint8_t[(thumbnail_width * ((thumbnail_height + 15) & ~15) * 3) / 2]); + uint8_t *y_plane = buf.get(); + uint8_t *u_plane = y_plane + thumbnail_width * thumbnail_height; + uint8_t *v_plane = u_plane + (thumbnail_width * thumbnail_height) / 4; + { + int result = libyuv::I420Scale( + b->cur_yuv_buf->y, b->rgb_width, b->cur_yuv_buf->u, b->rgb_width / 2, b->cur_yuv_buf->v, b->rgb_width / 2, + b->rgb_width, b->rgb_height, + y_plane, thumbnail_width, u_plane, thumbnail_width / 2, v_plane, thumbnail_width / 2, + thumbnail_width, thumbnail_height, libyuv::kFilterNone); + if (result != 0) { + LOGE("Generate YUV thumbnail failed."); + return {}; + } + } + + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + + uint8_t *thumbnail_buffer = nullptr; + size_t thumbnail_len = 0; + jpeg_mem_dest(&cinfo, &thumbnail_buffer, &thumbnail_len); + + cinfo.image_width = thumbnail_width; + cinfo.image_height = thumbnail_height; + cinfo.input_components = 3; + + jpeg_set_defaults(&cinfo); + jpeg_set_colorspace(&cinfo, JCS_YCbCr); + // configure sampling factors for yuv420. + cinfo.comp_info[0].h_samp_factor = 2; // Y + cinfo.comp_info[0].v_samp_factor = 2; + cinfo.comp_info[1].h_samp_factor = 1; // U + cinfo.comp_info[1].v_samp_factor = 1; + cinfo.comp_info[2].h_samp_factor = 1; // V + cinfo.comp_info[2].v_samp_factor = 1; + cinfo.raw_data_in = TRUE; + + jpeg_set_quality(&cinfo, 50, TRUE); + jpeg_start_compress(&cinfo, TRUE); + + JSAMPROW y[16], u[8], v[8]; + JSAMPARRAY planes[3]{y, u, v}; + + for (int line = 0; line < cinfo.image_height; line += 16) { + for (int i = 0; i < 16; ++i) { + y[i] = y_plane + (line + i) * cinfo.image_width; + if (i % 2 == 0) { + int offset = (cinfo.image_width / 2) * ((i + line) / 2); + u[i / 2] = u_plane + offset; + v[i / 2] = v_plane + offset; + } + } + jpeg_write_raw_data(&cinfo, planes, 16); + } + + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + + kj::Array dat = kj::heapArray(thumbnail_buffer, thumbnail_len); + free(thumbnail_buffer); + return dat; +} + +static void publish_thumbnail(PubMaster *pm, const CameraBuf *b) { + auto thumbnail = yuv420_to_jpeg(b, b->rgb_width / 4, b->rgb_height / 4); + if (thumbnail.size() == 0) return; + + 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(thumbnail); + + pm->send("thumbnail", msg); +} + +float set_exposure_target(const CameraBuf *b, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip) { + int lum_med; + uint32_t lum_binning[256] = {0}; + const uint8_t *pix_ptr = b->cur_yuv_buf->y; + + unsigned int lum_total = 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->rgb_width) + x]; + lum_binning[lum]++; + lum_total += 1; + } + } + + + // Find mean lumimance value + unsigned int lum_cur = 0; + for (lum_med = 255; lum_med >= 0; lum_med--) { + lum_cur += lum_binning[lum_med]; + + if (lum_cur >= lum_total / 2) { + break; + } + } + + return lum_med / 256.0; +} + +extern ExitHandler do_exit; + +void *processing_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback) { + const char *thread_name = nullptr; + if (cs == &cameras->road_cam) { + thread_name = "RoadCamera"; + } else if (cs == &cameras->driver_cam) { + thread_name = "DriverCamera"; + } else { + thread_name = "WideRoadCamera"; + } + util::set_thread_name(thread_name); + + uint32_t cnt = 0; + while (!do_exit) { + if (!cs->buf.acquire()) continue; + + callback(cameras, cs, cnt); + + if (cs == &(cameras->road_cam) && cameras->pm && cnt % 100 == 3) { + // this takes 10ms??? + publish_thumbnail(cameras->pm, &(cs->buf)); + } + cs->buf.release(); + ++cnt; + } + return NULL; +} + +std::thread start_process_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback) { + return std::thread(processing_thread, cameras, cs, callback); +} + +static void driver_cam_auto_exposure(CameraState *c, SubMaster &sm) { + static const bool is_rhd = Params().getBool("IsRHD"); + struct ExpRect {int x1, x2, x_skip, y1, y2, y_skip;}; + const CameraBuf *b = &c->buf; + + int x_offset = 0, y_offset = 0; + int frame_width = b->rgb_width, frame_height = b->rgb_height; + + + ExpRect def_rect; + if (Hardware::TICI()) { + x_offset = 630, y_offset = 156; + frame_width = 668, frame_height = frame_width / 1.33; + def_rect = {96, 1832, 2, 242, 1148, 4}; + } else { + def_rect = {is_rhd ? 0 : b->rgb_width * 3 / 5, is_rhd ? b->rgb_width * 2 / 5 : b->rgb_width, 2, + b->rgb_height / 3, b->rgb_height, 1}; + } + + static ExpRect rect = def_rect; + // use driver face crop for AE + if (Hardware::EON() && sm.updated("driverState")) { + if (auto state = sm["driverState"].getDriverState(); state.getFaceProb() > 0.4) { + auto face_position = state.getFacePosition(); + int x = is_rhd ? 0 : frame_width - (0.5 * frame_height); + x += (face_position[0] * (is_rhd ? -1.0 : 1.0) + 0.5) * (0.5 * frame_height) + x_offset; + int y = (face_position[1] + 0.5) * frame_height + y_offset; + rect = {std::max(0, x - 72), std::min(b->rgb_width - 1, x + 72), 2, + std::max(0, y - 72), std::min(b->rgb_height - 1, y + 72), 1}; + } + } + + camera_autoexposure(c, set_exposure_target(b, rect.x1, rect.x2, rect.x_skip, rect.y1, rect.y2, rect.y_skip)); +} + +void common_process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) { + int j = Hardware::TICI() ? 1 : 3; + if (cnt % j == 0) { + s->sm->update(0); + driver_cam_auto_exposure(c, *(s->sm)); + } + MessageBuilder msg; + auto framed = msg.initEvent().initDriverCameraState(); + framed.setFrameType(cereal::FrameData::FrameType::FRONT); + fill_frame_data(framed, c->buf.cur_frame_data); + if (env_send_driver) { + framed.setImage(get_frame_image(&c->buf)); + } + s->pm->send("driverCameraState", msg); +} diff --git a/selfdrive/camerad/cameras/camera_common.h b/selfdrive/camerad/cameras/camera_common.h new file mode 100644 index 00000000000000..9394f90756862f --- /dev/null +++ b/selfdrive/camerad/cameras/camera_common.h @@ -0,0 +1,132 @@ +#pragma once + +#include +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "cereal/visionipc/visionbuf.h" +#include "cereal/visionipc/visionipc.h" +#include "cereal/visionipc/visionipc_server.h" +#include "selfdrive/camerad/transforms/rgb_to_yuv.h" +#include "selfdrive/common/mat.h" +#include "selfdrive/common/queue.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/visionimg.h" +#include "selfdrive/hardware/hw.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 + +const int UI_BUF_COUNT = 4; +const int YUV_BUFFER_COUNT = Hardware::EON() ? 100 : 40; + +enum CameraType { + RoadCam = 0, + DriverCam, + WideRoadCam +}; + +// TODO: remove these once all the internal tools are moved to vipc +const bool env_send_driver = getenv("SEND_DRIVER") != NULL; +const bool env_send_road = getenv("SEND_ROAD") != NULL; +const bool env_send_wide_road = getenv("SEND_WIDE_ROAD") != NULL; + +typedef void (*release_cb)(void *cookie, int buf_idx); + +typedef struct CameraInfo { + int frame_width, frame_height; + int frame_stride; + bool bayer; + int bayer_flip; + bool hdr; +} CameraInfo; + +typedef struct FrameMetadata { + uint32_t frame_id; + unsigned int frame_length; + + // Timestamps + uint64_t timestamp_sof; // only set on tici + uint64_t timestamp_eof; + + // Exposure + unsigned int integ_lines; + bool high_conversion_gain; + float gain; + float measured_grey_fraction; + float target_grey_fraction; + + // Focus + unsigned int lens_pos; + float lens_sag; + float lens_err; + float lens_true_pos; +} FrameMetadata; + +typedef struct CameraExpInfo { + int op_id; + float grey_frac; +} CameraExpInfo; + +struct MultiCameraState; +struct CameraState; +class Debayer; + +class CameraBuf { +private: + VisionIpcServer *vipc_server; + CameraState *camera_state; + Debayer *debayer = nullptr; + std::unique_ptr rgb2yuv; + + VisionStreamType rgb_type, yuv_type; + + int cur_buf_idx; + + SafeQueue safe_queue; + + int frame_buf_count; + release_cb release_callback; + +public: + cl_command_queue q; + FrameMetadata cur_frame_data; + VisionBuf *cur_rgb_buf; + VisionBuf *cur_yuv_buf; + std::unique_ptr camera_bufs; + std::unique_ptr camera_bufs_metadata; + int rgb_width, rgb_height, rgb_stride; + + mat3 yuv_transform; + + CameraBuf() = default; + ~CameraBuf(); + void init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType rgb_type, VisionStreamType yuv_type, release_cb release_callback=nullptr); + bool acquire(); + void release(); + void queue(size_t buf_idx); +}; + +typedef void (*process_thread_cb)(MultiCameraState *s, CameraState *c, int cnt); + +void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data); +kj::Array get_frame_image(const CameraBuf *b); +float set_exposure_target(const CameraBuf *b, 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, CameraState *cs, process_thread_cb callback); +void common_process_driver_camera(MultiCameraState *s, CameraState *c, int cnt); + +void cameras_init(VisionIpcServer *v, 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..06d58f2b01ab76 --- /dev/null +++ b/selfdrive/camerad/cameras/camera_qcom.cc @@ -0,0 +1,1202 @@ +#include "selfdrive/camerad/cameras/camera_qcom.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "selfdrive/camerad/cameras/sensor_i2c.h" +#include "selfdrive/camerad/include/msm_cam_sensor.h" +#include "selfdrive/camerad/include/msmb_camera.h" +#include "selfdrive/camerad/include/msmb_isp.h" +#include "selfdrive/camerad/include/msmb_ispif.h" +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" + +// leeco actuator (DW9800W H-Bridge Driver IC) +// from sniff +const uint16_t INFINITY_DAC = 364; + +extern ExitHandler do_exit; + +static int cam_ioctl(int fd, unsigned long int request, void *arg, const char *log_msg = nullptr) { + int err = HANDLE_EINTR(ioctl(fd, request, arg)); + if (err != 0 && log_msg) { + LOG(util::string_format("%s: %d", log_msg, err).c_str()); + } + return err; +} +// global var for AE/AF ops +std::atomic road_cam_exp{{0}}; +std::atomic driver_cam_exp{{0}}; + +CameraInfo cameras_supported[CAMERA_ID_MAX] = { + [CAMERA_ID_IMX298] = { + .frame_width = 2328, + .frame_height = 1748, + .frame_stride = 2912, + .bayer = true, + .bayer_flip = 3, + .hdr = true + }, + [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; + HANDLE_EINTR(ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &s->ss[0].qbuf_info[buf_idx])); +} + +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, + }; + sensorb_cfg_data cfg_data = {.cfgtype = CFG_WRITE_I2C_ARRAY, .cfg.setting = &out_settings}; + return HANDLE_EINTR(ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &cfg_data)); +} + +static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, uint32_t frame_length) { + int analog_gain = std::min(gain, 448); + s->digital_gain = gain > 448 ? (512.0/(512-(gain))) / 8.0 : 1.0; + //printf("%5d/%5d %5d %f\n", s->cur_integ_lines, s->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}, + }; + return sensor_write_regs(s, reg_array, std::size(reg_array), MSM_CAMERA_I2C_BYTE_DATA); +} + +static int ov8865_apply_exposure(CameraState *s, int gain, int integ_lines, uint32_t frame_length) { + //printf("driver camera: %d %d %d\n", gain, integ_lines, frame_length); + int 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 < std::size(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}, + }; + return sensor_write_regs(s, reg_array, std::size(reg_array), MSM_CAMERA_I2C_BYTE_DATA); +} + +static void camera_init(VisionIpcServer *v, CameraState *s, int camera_id, int camera_num, + uint32_t pixel_clock, uint32_t line_length_pclk, + uint32_t max_gain, uint32_t fps, cl_device_id device_id, cl_context ctx, + VisionStreamType rgb_type, VisionStreamType yuv_type) { + s->camera_num = camera_num; + s->camera_id = camera_id; + + assert(camera_id < std::size(cameras_supported)); + s->ci = cameras_supported[camera_id]; + assert(s->ci.frame_width != 0); + + s->pixel_clock = pixel_clock; + s->max_gain = max_gain; + s->fps = fps; + s->frame_length = s->pixel_clock / line_length_pclk / s->fps; + s->self_recover = 0; + + s->apply_exposure = (camera_id == CAMERA_ID_IMX298) ? imx298_apply_exposure : ov8865_apply_exposure; + s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type, camera_release_buffer); +} + +void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { + char project_name[1024] = {0}; + property_get("ro.boot.project_name", project_name, ""); + assert(strlen(project_name) == 0); + + // sensor is flipped in LP3 + // IMAGE_ORIENT = 3 + init_array_imx298[0].reg_data = 3; + + // 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(v, &s->road_cam, 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, + VISION_STREAM_RGB_BACK, VISION_STREAM_ROAD); + + camera_init(v, &s->driver_cam, CAMERA_ID_OV8865, 1, + /*pixel_clock=*/72000000, /*line_length_pclk=*/1602, + /*max_gain=*/510, 10, device_id, ctx, + VISION_STREAM_RGB_FRONT, VISION_STREAM_DRIVER); + + s->sm = new SubMaster({"driverState"}); + s->pm = new PubMaster({"roadCameraState", "driverCameraState", "thumbnail"}); + + for (int i = 0; i < FRAME_BUF_COUNT; i++) { + // TODO: make lengths correct + s->focus_bufs[i].allocate(0xb80); + s->stats_bufs[i].allocate(0xb80); + } + std::fill_n(s->lapres, std::size(s->lapres), 16160); + s->lap_conv = new LapConv(device_id, ctx, s->road_cam.buf.rgb_width, s->road_cam.buf.rgb_height, s->road_cam.buf.rgb_stride, 3); +} + +static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) { + int err = 0; + uint32_t gain = s->cur_gain; + uint32_t integ_lines = s->cur_integ_lines; + + if (exposure_frac >= 0) { + exposure_frac = std::clamp(exposure_frac, 2.0f / s->frame_length, 1.0f); + integ_lines = s->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, s->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 driver 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) { + if (s->apply_exposure == ov8865_apply_exposure) { + gain = 800 * gain_frac; // ISO + } + err = s->apply_exposure(s, gain, integ_lines, s->frame_length); + if (err == 0) { + std::lock_guard lk(s->frame_info_lock); + s->cur_gain = gain; + s->cur_integ_lines = integ_lines; + } else { + LOGE("camera %d apply_exposure err: %d", s->camera_num, err); + } + } + + if (err == 0) { + s->cur_exposure_frac = exposure_frac; + std::lock_guard lk(s->frame_info_lock); + 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; + + s->frame_info_lock.lock(); + s->measured_grey_fraction = grey_frac; + s->target_grey_fraction = target_grey; + s->frame_info_lock.unlock(); + + 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 + const uint32_t exposure_time_min = 16; + const uint32_t exposure_time_max = s->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; + } + s->frame_info_lock.lock(); + s->cur_gain_frac = cur_gain_frac; + s->frame_info_lock.unlock(); + + 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 void sensors_init(MultiCameraState *s) { + msm_camera_sensor_slave_info slave_infos[2] = { + (msm_camera_sensor_slave_info){ // road camera + .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, .module_id = 9, .vcm_id = 6}, + .power_setting_array = { + .power_setting_a = { + {.seq_type = SENSOR_GPIO, .delay = 1}, + {.seq_type = SENSOR_VREG, .seq_val = 2}, + {.seq_type = SENSOR_GPIO, .seq_val = 5, .config_val = 2}, + {.seq_type = SENSOR_VREG, .seq_val = 1}, + {.seq_type = SENSOR_VREG, .seq_val = 3, .delay = 1}, + {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 1}, + {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 10}, + }, + .size = 7, + .power_down_setting_a = { + {.seq_type = SENSOR_CLK, .delay = 1}, + {.seq_type = SENSOR_GPIO, .delay = 1}, + {.seq_type = SENSOR_VREG, .seq_val = 1}, + {.seq_type = SENSOR_GPIO, .seq_val = 5}, + {.seq_type = SENSOR_VREG, .seq_val = 2}, + {.seq_type = SENSOR_VREG, .seq_val = 3, .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, + }, + (msm_camera_sensor_slave_info){ // driver camera + .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, .module_id = 2}, + .power_setting_array = { + .power_setting_a = { + {.seq_type = SENSOR_GPIO, .delay = 5}, + {.seq_type = SENSOR_VREG, .seq_val = 1}, + {.seq_type = SENSOR_VREG, .seq_val = 2}, + {.seq_type = SENSOR_VREG}, + {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 1}, + {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 1}, + }, + .size = 6, + .power_down_setting_a = { + {.seq_type = SENSOR_GPIO, .delay = 5}, + {.seq_type = SENSOR_CLK, .delay = 1}, + {.seq_type = SENSOR_VREG}, + {.seq_type = SENSOR_VREG, .seq_val = 1}, + {.seq_type = SENSOR_VREG, .seq_val = 2, .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, + }}; + + unique_fd sensorinit_fd = HANDLE_EINTR(open("/dev/v4l-subdev11", O_RDWR | O_NONBLOCK)); + assert(sensorinit_fd >= 0); + for (auto &info : slave_infos) { + info.power_setting_array.power_setting = &info.power_setting_array.power_setting_a[0]; + info.power_setting_array.power_down_setting = &info.power_setting_array.power_down_setting_a[0]; + sensor_init_cfg_data sensor_init_cfg = {.cfgtype = CFG_SINIT_PROBE, .cfg.setting = &info}; + int err = cam_ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg, "sensor init cfg"); + assert(err >= 0); + } +} + +static void camera_open(CameraState *s, bool is_road_cam) { + struct csid_cfg_data csid_cfg_data = {}; + struct v4l2_event_subscription sub = {}; + + struct msm_actuator_cfg_data actuator_cfg_data = {}; + + // open devices + const char *sensor_dev; + if (is_road_cam) { + s->csid_fd = HANDLE_EINTR(open("/dev/v4l-subdev3", O_RDWR | O_NONBLOCK)); + assert(s->csid_fd >= 0); + s->csiphy_fd = HANDLE_EINTR(open("/dev/v4l-subdev0", O_RDWR | O_NONBLOCK)); + assert(s->csiphy_fd >= 0); + sensor_dev = "/dev/v4l-subdev17"; + s->isp_fd = HANDLE_EINTR(open("/dev/v4l-subdev13", O_RDWR | O_NONBLOCK)); + assert(s->isp_fd >= 0); + s->actuator_fd = HANDLE_EINTR(open("/dev/v4l-subdev7", O_RDWR | O_NONBLOCK)); + assert(s->actuator_fd >= 0); + } else { + s->csid_fd = HANDLE_EINTR(open("/dev/v4l-subdev5", O_RDWR | O_NONBLOCK)); + assert(s->csid_fd >= 0); + s->csiphy_fd = HANDLE_EINTR(open("/dev/v4l-subdev2", O_RDWR | O_NONBLOCK)); + assert(s->csiphy_fd >= 0); + sensor_dev = "/dev/v4l-subdev18"; + s->isp_fd = HANDLE_EINTR(open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK)); + assert(s->isp_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 = HANDLE_EINTR(open(sensor_dev, O_RDWR | O_NONBLOCK)); + if (s->sensor_fd >= 0) break; + LOGW("waiting for sensors..."); + util::sleep_for(1000); // sleep one second + } + 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 csiphy_cfg_data = { .cfg.csi_lane_params = &csi_lane_params, .cfgtype = CSIPHY_RELEASE}; + int err = cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "release csiphy"); + + // CSID: release csid + csid_cfg_data.cfgtype = CSID_RELEASE; + cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "release csid"); + + // SENSOR: send power down + struct sensorb_cfg_data sensorb_cfg_data = {.cfgtype = CFG_POWER_DOWN}; + cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "sensor power down"); + + // actuator powerdown + actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERDOWN; + cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator powerdown"); + + // 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 ************************"); + + // CSID: init csid + csid_cfg_data.cfgtype = CSID_INIT; + cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "init csid"); + + // CSIPHY: init csiphy + csiphy_cfg_data = {.cfgtype = CSIPHY_INIT}; + cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "init csiphy"); + + // SENSOR: stop stream + struct msm_camera_i2c_reg_setting stop_settings = { + .reg_setting = stop_reg_array, + .size = std::size(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; + cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "stop stream"); + + // SENSOR: send power up + sensorb_cfg_data = {.cfgtype = CFG_POWER_UP}; + cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "sensor power up"); + + // **** configure the sensor **** + + // SENSOR: send i2c configuration + if (s->camera_id == CAMERA_ID_IMX298) { + err = sensor_write_regs(s, init_array_imx298, std::size(init_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); + } else if (s->camera_id == CAMERA_ID_OV8865) { + err = sensor_write_regs(s, init_array_ov8865, std::size(init_array_ov8865), MSM_CAMERA_I2C_BYTE_DATA); + } else { + assert(false); + } + LOG("sensor init i2c: %d", err); + + if (is_road_cam) { + // init the actuator + actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERUP; + cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator powerup"); + + actuator_cfg_data.cfgtype = CFG_ACTUATOR_INIT; + cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator init"); + + struct msm_actuator_reg_params_t actuator_reg_params[] = { + { + .reg_write_type = MSM_ACTUATOR_WRITE_DAC, + // MSB here at address 3 + .reg_addr = 3, + .data_type = 9, + .addr_type = 4, + }, + }; + + 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 = INFINITY_DAC, + .pwd_step = 0, + .region_size = 1, + .total_steps = 238, + .region_params = ®ion_params[0], + }, + }; + + cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator set info"); + } + + if (s->camera_id == CAMERA_ID_IMX298) { + err = sensor_write_regs(s, mode_setting_array_imx298, std::size(mode_setting_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); + LOG("sensor setup: %d", err); + } + + // CSIPHY: configure csiphy + struct msm_camera_csiphy_params csiphy_params = {}; + if (s->camera_id == CAMERA_ID_IMX298) { + csiphy_params = {.lane_cnt = 4, .settle_cnt = 14, .lane_mask = 0x1f, .csid_core = 0}; + } else if (s->camera_id == CAMERA_ID_OV8865) { + // guess! + csiphy_params = {.lane_cnt = 4, .settle_cnt = 24, .lane_mask = 0x1f, .csid_core = 2}; + } + csiphy_cfg_data.cfgtype = CSIPHY_CFG; + csiphy_cfg_data.cfg.csiphy_params = &csiphy_params; + cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "csiphy configure"); + + // CSID: configure csid +#define CSI_STATS 0x35 +#define CSI_PD 0x36 + struct msm_camera_csid_params csid_params = { + .lane_cnt = 4, + .lane_assign = 0x4320, + .phy_sel = (uint8_t)(is_road_cam ? 0 : 2), + .lut_params.num_cid = (uint8_t)(is_road_cam ? 3 : 1), + .lut_params.vc_cfg_a = { + {.cid = 0, .dt = CSI_RAW10, .decode_format = CSI_DECODE_10BIT}, + {.cid = 1, .dt = CSI_PD, .decode_format = CSI_DECODE_10BIT}, + {.cid = 2, .dt = CSI_STATS, .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; + cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "csid configure"); + + // ISP: SMMU_ATTACH + msm_vfe_smmu_attach_cmd smmu_attach_cmd = {.security_mode = 0, .iommu_attach_mode = IOMMU_ATTACH}; + cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_SMMU_ATTACH, &smmu_attach_cmd, "isp smmu attach"); + + // ******************* STREAM RAW ***************************** + + // configure QMET input + struct msm_vfe_input_cfg input_cfg = {}; + for (int i = 0; i < (is_road_cam ? 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 (is_road_cam) { + 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 (is_road_cam) { + 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; + cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_BUF, &ss->buf_request, "isp request buf"); + 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 + struct msm_vfe_axi_stream_update_cmd update_cmd = {}; + 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; + cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_UPDATE_STREAM, &update_cmd, "isp update stream"); + } + + LOG("******** START STREAMS ********"); + + sub.id = 0; + sub.type = 0x1ff; + cam_ioctl(s->isp_fd, VIDIOC_SUBSCRIBE_EVENT, &sub, "isp subscribe"); + + // ISP: START_STREAM + s->stream_cfg.cmd = START_STREAM; + s->stream_cfg.num_streams = is_road_cam ? 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; + } + cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg, "isp start stream"); +} + +static void road_camera_start(CameraState *s) { + set_exposure(s, 1.0, 1.0); + + int err = sensor_write_regs(s, start_reg_array, std::size(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); + LOG("sensor start regs: %d", err); + + int inf_step = 512 - INFINITY_DAC; + + // initial guess + s->lens_true_pos = 400; + + // reset lens position + struct msm_actuator_cfg_data 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)7, + .pos = {INFINITY_DAC, 0}, + .delay = {0,} + }; + cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator set pos"); + + // 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) { + // LP3 moves only on even positions. TODO: use proper sensor params + + // focus on infinity assuming phone is perpendicular + static struct damping_params_t actuator_ringing_params = { + .damping_step = 1023, + .damping_delay = 20000, + .hw_params = 13, + }; + + int step = (target - s->cur_lens_pos) / 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) ? MOVE_NEAR : MOVE_FAR), + .sign_dir = (int8_t)((step > 0) ? MSM_ACTUATOR_MOVE_SIGNED_NEAR : MSM_ACTUATOR_MOVE_SIGNED_FAR), + .dest_step_pos = (int16_t)dest_step_pos, + .num_steps = abs(step), + .curr_lens_pos = s->cur_lens_pos, + .ringing_params = &actuator_ringing_params, + }; + HANDLE_EINTR(ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data)); + + 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) { + sm->update(0); + if(sm->updated("sensorEvents")) { + 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) { + 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(LP3_AF_DAC_DOWN), float(LP3_AF_DAC_UP)); + int target = std::clamp(lens_true_pos - sag, float(LP3_AF_DAC_DOWN), float(LP3_AF_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 = road_cam_exp.load(); + tmp.op_id++; + tmp.grey_frac = grey_frac; + road_cam_exp.store(tmp); + } else { + CameraExpInfo tmp = driver_cam_exp.load(); + tmp.op_id++; + tmp.grey_frac = grey_frac; + driver_cam_exp.store(tmp); + } +} + +static void driver_camera_start(CameraState *s) { + set_exposure(s, 1.0, 1.0); + int err = sensor_write_regs(s, start_reg_array, std::size(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); + LOG("sensor start regs: %d", err); +} + +void cameras_open(MultiCameraState *s) { + struct msm_ispif_param_data ispif_params = { + .num = 4, + .entries = { + // road camera + {.vfe_intf = VFE0, .intftype = RDI0, .num_cids = 1, .cids[0] = CID0, .csid = CSID0}, + // driver camera + {.vfe_intf = VFE1, .intftype = RDI0, .num_cids = 1, .cids[0] = CID0, .csid = CSID2}, + // road camera (focus) + {.vfe_intf = VFE0, .intftype = RDI1, .num_cids = 1, .cids[0] = CID1, .csid = CSID0}, + // road camera (stats, for AE) + {.vfe_intf = VFE0, .intftype = RDI2, .num_cids = 1, .cids[0] = CID2, .csid = CSID0}, + }, + }; + s->msmcfg_fd = HANDLE_EINTR(open("/dev/media0", O_RDWR | O_NONBLOCK)); + assert(s->msmcfg_fd >= 0); + + sensors_init(s); + + s->v4l_fd = HANDLE_EINTR(open("/dev/video0", O_RDWR | O_NONBLOCK)); + assert(s->v4l_fd >= 0); + + s->ispif_fd = HANDLE_EINTR(open("/dev/v4l-subdev15", 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 driver camera ***"); + s->driver_cam.ss[0].bufs = s->driver_cam.buf.camera_bufs.get(); + camera_open(&s->driver_cam, false); + + LOG("*** open road camera ***"); + s->road_cam.ss[0].bufs = s->road_cam.buf.camera_bufs.get(); + s->road_cam.ss[1].bufs = s->focus_bufs; + s->road_cam.ss[2].bufs = s->stats_bufs; + camera_open(&s->road_cam, true); + + if (getenv("CAMERA_TEST")) { + cameras_close(s); + exit(0); + } + + // ISPIF: set vfe info + struct ispif_cfg_data ispif_cfg_data = {.cfg_type = ISPIF_SET_VFE_INFO, .vfe_info.num_vfe = 2}; + int err = HANDLE_EINTR(ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data)); + LOG("ispif set vfe info: %d", err); + + // ISPIF: setup + ispif_cfg_data = {.cfg_type = ISPIF_INIT, .csid_version = 0x30050000 /* CSID_VERSION_V35*/}; + cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif setup"); + + ispif_cfg_data = {.cfg_type = ISPIF_CFG, .params = ispif_params}; + cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif cfg"); + + ispif_cfg_data.cfg_type = ISPIF_START_FRAME_BOUNDARY; + cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif start_frame_boundary"); + + driver_camera_start(&s->driver_cam); + road_camera_start(&s->road_cam); +} + + +static void camera_close(CameraState *s) { + // ISP: STOP_STREAM + s->stream_cfg.cmd = STOP_STREAM; + cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg, "isp stop stream"); + + for (int i = 0; i < 3; i++) { + StreamState *ss = &s->ss[i]; + if (ss->stream_req.axi_stream_handle != 0) { + cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_BUF, &ss->buf_request, "isp release buf"); + + struct msm_vfe_axi_stream_release_cmd stream_release = { + .stream_handle = ss->stream_req.axi_stream_handle, + }; + cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_STREAM, &stream_release, "isp release stream"); + } + } +} + +const char* get_isp_event_name(uint32_t 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) { + std::lock_guard lk(s->frame_info_lock); + for (auto &i : s->frame_metadata) { + if (i.frame_id == frame_id) { + return i; + } + } + // should never happen + return (FrameMetadata){ + .frame_id = (uint32_t)-1, + }; +} + +static void ops_thread(MultiCameraState *s) { + int last_road_cam_op_id = 0; + int last_driver_cam_op_id = 0; + + CameraExpInfo road_cam_op; + CameraExpInfo driver_cam_op; + + util::set_thread_name("camera_settings"); + SubMaster sm({"sensorEvents"}); + while(!do_exit) { + road_cam_op = road_cam_exp.load(); + if (road_cam_op.op_id != last_road_cam_op_id) { + do_autoexposure(&s->road_cam, road_cam_op.grey_frac); + do_autofocus(&s->road_cam, &sm); + last_road_cam_op_id = road_cam_op.op_id; + } + + driver_cam_op = driver_cam_exp.load(); + if (driver_cam_op.op_id != last_driver_cam_op_id) { + do_autoexposure(&s->driver_cam, driver_cam_op.grey_frac); + last_driver_cam_op_id = driver_cam_op.op_id; + } + + util::sleep_for(50); + } +} + +static void setup_self_recover(CameraState *c, const uint16_t *lapres, size_t lapres_size) { + const float lens_true_pos = c->lens_true_pos.load(); + int self_recover = c->self_recover.load(); + if (self_recover < 2 && (lens_true_pos < (LP3_AF_DAC_DOWN + 1) || lens_true_pos > (LP3_AF_DAC_UP - 1)) && is_blur(lapres, lapres_size)) { + // truly stuck, needs help + if (--self_recover < -FOCUS_RECOVER_PATIENCE) { + LOGD("road 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 < LP3_AF_DAC_M ? 1 : 0); + } + } else if (self_recover < 2 && (lens_true_pos < (LP3_AF_DAC_M - LP3_AF_DAC_3SIG) || lens_true_pos > (LP3_AF_DAC_M + LP3_AF_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 < LP3_AF_DAC_M ? 1 : 0); + } + } else if (self_recover < 0) { + self_recover += 1; // reset if fine + } + c->self_recover.store(self_recover); +} + +// called by processing_thread +void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) { + const CameraBuf *b = &c->buf; + const int roi_id = cnt % std::size(s->lapres); // rolling roi + s->lapres[roi_id] = s->lap_conv->Update(b->q, (uint8_t *)b->cur_rgb_buf->addr, roi_id); + setup_self_recover(c, &s->lapres[0], std::size(s->lapres)); + + MessageBuilder msg; + auto framed = msg.initEvent().initRoadCameraState(); + fill_frame_data(framed, b->cur_frame_data); + if (env_send_road) { + framed.setImage(get_frame_image(b)); + } + framed.setFocusVal(s->road_cam.focus); + framed.setFocusConf(s->road_cam.confidence); + framed.setRecoverState(s->road_cam.self_recover); + framed.setSharpnessScore(s->lapres); + framed.setTransform(b->yuv_transform.v); + s->pm->send("roadCameraState", msg); + + if (cnt % 3 == 0) { + const int x = 290, y = 322, width = 560, height = 314; + const int skip = 1; + camera_autoexposure(c, set_exposure_target(b, x, x + width, skip, y, y + height, skip)); + } +} + +void cameras_run(MultiCameraState *s) { + std::vector threads; + threads.push_back(std::thread(ops_thread, s)); + threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera)); + threads.push_back(start_process_thread(s, &s->driver_cam, common_process_driver_camera)); + + CameraState* cameras[2] = {&s->road_cam, &s->driver_cam}; + + while (!do_exit) { + struct pollfd fds[2] = {{.fd = cameras[0]->isp_fd, .events = POLLPRI}, + {.fd = cameras[1]->isp_fd, .events = POLLPRI}}; + int ret = poll(fds, std::size(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 = HANDLE_EINTR(ioctl(c->isp_fd, VIDIOC_DQEVENT, &ev)); + const msm_isp_event_data *isp_event_data = (const msm_isp_event_data *)ev.u.data; + + if (ev.type == ISP_EVENT_BUF_DIVERT) { + const int buf_idx = isp_event_data->u.buf_done.buf_idx; + const int buffer = (isp_event_data->u.buf_done.stream_id & 0xFFFF) - 1; + if (buffer == 0) { + c->buf.camera_bufs_metadata[buf_idx] = get_frame_metadata(c, isp_event_data->frame_id); + c->buf.queue(buf_idx); + } else { + auto &ss = c->ss[buffer]; + if (buffer == 1) { + parse_autofocus(c, (uint8_t *)(ss.bufs[buf_idx].addr)); + } + ss.qbuf_info[buf_idx].dirty_buf = 1; + HANDLE_EINTR(ioctl(c->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss.qbuf_info[buf_idx])); + } + + } else if (ev.type == ISP_EVENT_EOF) { + const uint64_t timestamp = (isp_event_data->mono_timestamp.tv_sec * 1000000000ULL + isp_event_data->mono_timestamp.tv_usec * 1000); + std::lock_guard lk(c->frame_info_lock); + c->frame_metadata[c->frame_metadata_idx] = (FrameMetadata){ + .frame_id = isp_event_data->frame_id, + .timestamp_eof = timestamp, + .frame_length = (uint32_t)c->frame_length, + .integ_lines = (uint32_t)c->cur_integ_lines, + .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 = c->cur_gain_frac, + .measured_grey_fraction = c->measured_grey_fraction, + .target_grey_fraction = c->target_grey_fraction, + .high_conversion_gain = false, + }; + c->frame_metadata_idx = (c->frame_metadata_idx + 1) % METADATA_BUF_COUNT; + + } else if (ev.type == ISP_EVENT_ERROR) { + LOGE("ISP_EVENT_ERROR! err type: 0x%08x", isp_event_data->u.error_info.err_type); + } + } + } + + LOG(" ************** STOPPING **************"); + + for (auto &t : threads) t.join(); + + cameras_close(s); +} + +void cameras_close(MultiCameraState *s) { + camera_close(&s->road_cam); + camera_close(&s->driver_cam); + for (int i = 0; i < FRAME_BUF_COUNT; i++) { + s->focus_bufs[i].free(); + s->stats_bufs[i].free(); + } + + delete s->lap_conv; + delete s->sm; + 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..207857e05c6c6a --- /dev/null +++ b/selfdrive/camerad/cameras/camera_qcom.h @@ -0,0 +1,107 @@ +#pragma once + +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "cereal/visionipc/visionbuf.h" +#include "selfdrive/camerad/cameras/camera_common.h" +#include "selfdrive/camerad/imgproc/utils.h" +#include "selfdrive/camerad/include/msm_cam_sensor.h" +#include "selfdrive/camerad/include/msmb_camera.h" +#include "selfdrive/camerad/include/msmb_isp.h" +#include "selfdrive/camerad/include/msmb_ispif.h" +#include "selfdrive/common/mat.h" +#include "selfdrive/common/util.h" + +#define FRAME_BUF_COUNT 4 +#define METADATA_BUF_COUNT 4 + +#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 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, uint32_t 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; + + int fps; + CameraInfo ci; + + unique_fd csid_fd; + unique_fd csiphy_fd; + unique_fd sensor_fd; + unique_fd isp_fd; + + struct msm_vfe_axi_stream_cfg_cmd stream_cfg; + + StreamState ss[3]; + CameraBuf buf; + + std::mutex frame_info_lock; + FrameMetadata frame_metadata[METADATA_BUF_COUNT]; + int frame_metadata_idx; + + // exposure + uint32_t pixel_clock, line_length_pclk; + uint32_t frame_length; + unsigned int max_gain; + float cur_exposure_frac, cur_gain_frac; + int cur_gain, cur_integ_lines; + + float measured_grey_fraction; + float target_grey_fraction; + + std::atomic digital_gain; + camera_apply_exposure_func apply_exposure; + + // rear camera only,used for focusing + unique_fd actuator_fd; + std::atomic focus_err; + std::atomic last_sag_acc_z; + std::atomic lens_true_pos; + std::atomic self_recover; // af recovery counter, neg is patience, pos is active + uint16_t cur_step_pos; + uint16_t cur_lens_pos; + int16_t focus[NUM_FOCUS]; + uint8_t confidence[NUM_FOCUS]; +} CameraState; + + +typedef struct MultiCameraState { + unique_fd ispif_fd; + unique_fd msmcfg_fd; + unique_fd v4l_fd; + 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]; + + CameraState road_cam; + CameraState driver_cam; + + SubMaster *sm; + PubMaster *pm; + LapConv *lap_conv; +} MultiCameraState; + +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/camerad/cameras/camera_qcom2.cc b/selfdrive/camerad/cameras/camera_qcom2.cc new file mode 100644 index 00000000000000..030bbe47e1e15a --- /dev/null +++ b/selfdrive/camerad/cameras/camera_qcom2.cc @@ -0,0 +1,1070 @@ +#include "selfdrive/camerad/cameras/camera_qcom2.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "media/cam_defs.h" +#include "media/cam_isp.h" +#include "media/cam_isp_ife.h" +#include "media/cam_sensor.h" +#include "media/cam_sensor_cmn_header.h" +#include "media/cam_sync.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/camerad/cameras/sensor2_i2c.h" + +extern ExitHandler do_exit; + +const size_t FRAME_WIDTH = 1928; +const size_t FRAME_HEIGHT = 1208; +const size_t FRAME_STRIDE = 2416; // for 10 bit output + +const int MIPI_SETTLE_CNT = 33; // Calculated by camera_freqs.py + +CameraInfo cameras_supported[CAMERA_ID_MAX] = { + [CAMERA_ID_AR0231] = { + .frame_width = FRAME_WIDTH, + .frame_height = FRAME_HEIGHT, + .frame_stride = FRAME_STRIDE, + .bayer = true, + .bayer_flip = 1, + .hdr = false + }, +}; + +const float DC_GAIN = 2.5; +const float sensor_analog_gains[] = { + 1.0/8.0, 2.0/8.0, 2.0/7.0, 3.0/7.0, // 0, 1, 2, 3 + 3.0/6.0, 4.0/6.0, 4.0/5.0, 5.0/5.0, // 4, 5, 6, 7 + 5.0/4.0, 6.0/4.0, 6.0/3.0, 7.0/3.0, // 8, 9, 10, 11 + 7.0/2.0, 8.0/2.0, 8.0/1.0}; // 12, 13, 14, 15 = bypass + +const int ANALOG_GAIN_MIN_IDX = 0x1; // 0.25x +const int ANALOG_GAIN_REC_IDX = 0x6; // 0.8x +const int ANALOG_GAIN_MAX_IDX = 0xD; // 4.0x + +const int EXPOSURE_TIME_MIN = 2; // with HDR, fastest ss +const int EXPOSURE_TIME_MAX = 1904; // with HDR, slowest ss + +// ************** low level camera helpers **************** +int cam_control(int fd, int op_code, void *handle, int size) { + struct cam_control camcontrol = {0}; + camcontrol.op_code = op_code; + camcontrol.handle = (uint64_t)handle; + if (size == 0) { + camcontrol.size = 8; + camcontrol.handle_type = CAM_HANDLE_MEM_HANDLE; + } else { + camcontrol.size = size; + camcontrol.handle_type = CAM_HANDLE_USER_POINTER; + } + + int ret = HANDLE_EINTR(ioctl(fd, VIDIOC_CAM_CONTROL, &camcontrol)); + if (ret == -1) { + printf("OP CODE ERR - %d \n", op_code); + perror("wat"); + } + return ret; +} + +std::optional device_acquire(int fd, int32_t session_handle, void *data) { + struct cam_acquire_dev_cmd cmd = { + .session_handle = session_handle, + .handle_type = CAM_HANDLE_USER_POINTER, + .num_resources = (uint32_t)(data ? 1 : 0), + .resource_hdl = (uint64_t)data, + }; + int err = cam_control(fd, CAM_ACQUIRE_DEV, &cmd, sizeof(cmd)); + return err == 0 ? std::make_optional(cmd.dev_handle) : std::nullopt; +}; + +int device_config(int fd, int32_t session_handle, int32_t dev_handle, uint64_t packet_handle) { + struct cam_config_dev_cmd cmd = { + .session_handle = session_handle, + .dev_handle = dev_handle, + .packet_handle = packet_handle, + }; + return cam_control(fd, CAM_CONFIG_DEV, &cmd, sizeof(cmd)); +} + +int device_control(int fd, int op_code, int session_handle, int dev_handle) { + // start stop and release are all the same + struct cam_start_stop_dev_cmd cmd { .session_handle = session_handle, .dev_handle = dev_handle }; + return cam_control(fd, op_code, &cmd, sizeof(cmd)); +} + +void *alloc_w_mmu_hdl(int video0_fd, int len, uint32_t *handle, int align = 8, int flags = CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE, + int mmu_hdl = 0, int mmu_hdl2 = 0) { + struct cam_mem_mgr_alloc_cmd mem_mgr_alloc_cmd = {0}; + mem_mgr_alloc_cmd.len = len; + mem_mgr_alloc_cmd.align = align; + mem_mgr_alloc_cmd.flags = flags; + mem_mgr_alloc_cmd.num_hdl = 0; + if (mmu_hdl != 0) { + mem_mgr_alloc_cmd.mmu_hdls[0] = mmu_hdl; + mem_mgr_alloc_cmd.num_hdl++; + } + if (mmu_hdl2 != 0) { + mem_mgr_alloc_cmd.mmu_hdls[1] = mmu_hdl2; + mem_mgr_alloc_cmd.num_hdl++; + } + + cam_control(video0_fd, CAM_REQ_MGR_ALLOC_BUF, &mem_mgr_alloc_cmd, sizeof(mem_mgr_alloc_cmd)); + *handle = mem_mgr_alloc_cmd.out.buf_handle; + + void *ptr = NULL; + if (mem_mgr_alloc_cmd.out.fd > 0) { + ptr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, mem_mgr_alloc_cmd.out.fd, 0); + assert(ptr != MAP_FAILED); + } + + // LOGD("allocated: %x %d %llx mapped %p", mem_mgr_alloc_cmd.out.buf_handle, mem_mgr_alloc_cmd.out.fd, mem_mgr_alloc_cmd.out.vaddr, ptr); + + return ptr; +} + +void release(int video0_fd, uint32_t handle) { + int ret; + struct cam_mem_mgr_release_cmd mem_mgr_release_cmd = {0}; + mem_mgr_release_cmd.buf_handle = handle; + + ret = cam_control(video0_fd, CAM_REQ_MGR_RELEASE_BUF, &mem_mgr_release_cmd, sizeof(mem_mgr_release_cmd)); + assert(ret == 0); +} + +void release_fd(int video0_fd, uint32_t handle) { + // handle to fd + close(handle>>16); + release(video0_fd, handle); +} + +void clear_req_queue(int fd, int32_t session_hdl, int32_t link_hdl) { + struct cam_req_mgr_flush_info req_mgr_flush_request = {0}; + req_mgr_flush_request.session_hdl = session_hdl; + req_mgr_flush_request.link_hdl = link_hdl; + req_mgr_flush_request.flush_type = CAM_REQ_MGR_FLUSH_TYPE_ALL; + int ret; + ret = cam_control(fd, CAM_REQ_MGR_FLUSH_REQ, &req_mgr_flush_request, sizeof(req_mgr_flush_request)); + // LOGD("flushed all req: %d", ret); +} + +// ************** high level camera helpers **************** + +void sensors_poke(struct CameraState *s, int request_id) { + uint32_t cam_packet_handle = 0; + int size = sizeof(struct cam_packet); + struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); + pkt->num_cmd_buf = 0; + pkt->kmd_cmd_buf_index = -1; + pkt->header.size = size; + pkt->header.op_code = 0x7f; + pkt->header.request_id = request_id; + + int ret = device_config(s->sensor_fd, s->session_handle, s->sensor_dev_handle, cam_packet_handle); + assert(ret == 0); + + munmap(pkt, size); + release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); +} + +void sensors_i2c(struct CameraState *s, struct i2c_random_wr_payload* dat, int len, int op_code) { + // LOGD("sensors_i2c: %d", len); + uint32_t cam_packet_handle = 0; + int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*1; + struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); + pkt->num_cmd_buf = 1; + pkt->kmd_cmd_buf_index = -1; + pkt->header.size = size; + pkt->header.op_code = op_code; + struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; + + buf_desc[0].size = buf_desc[0].length = sizeof(struct i2c_rdwr_header) + len*sizeof(struct i2c_random_wr_payload); + buf_desc[0].type = CAM_CMD_BUF_I2C; + + struct cam_cmd_i2c_random_wr *i2c_random_wr = (struct cam_cmd_i2c_random_wr *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle); + i2c_random_wr->header.count = len; + i2c_random_wr->header.op_code = 1; + i2c_random_wr->header.cmd_type = CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR; + i2c_random_wr->header.data_type = CAMERA_SENSOR_I2C_TYPE_WORD; + i2c_random_wr->header.addr_type = CAMERA_SENSOR_I2C_TYPE_WORD; + memcpy(i2c_random_wr->random_wr_payload, dat, len*sizeof(struct i2c_random_wr_payload)); + + int ret = device_config(s->sensor_fd, s->session_handle, s->sensor_dev_handle, cam_packet_handle); + assert(ret == 0); + + munmap(i2c_random_wr, buf_desc[0].size); + release_fd(s->multi_cam_state->video0_fd, buf_desc[0].mem_handle); + munmap(pkt, size); + release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); +} +static cam_cmd_power *power_set_wait(cam_cmd_power *power, int16_t delay_ms) { + cam_cmd_unconditional_wait *unconditional_wait = (cam_cmd_unconditional_wait *)((char *)power + (sizeof(struct cam_cmd_power) + (power->count - 1) * sizeof(struct cam_power_settings))); + unconditional_wait->cmd_type = CAMERA_SENSOR_CMD_TYPE_WAIT; + unconditional_wait->delay = delay_ms; + unconditional_wait->op_code = CAMERA_SENSOR_WAIT_OP_SW_UCND; + return (struct cam_cmd_power *)(unconditional_wait + 1); +}; + +void sensors_init(int video0_fd, int sensor_fd, int camera_num) { + uint32_t cam_packet_handle = 0; + int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*2; + struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(video0_fd, size, &cam_packet_handle); + pkt->num_cmd_buf = 2; + pkt->kmd_cmd_buf_index = -1; + pkt->header.op_code = 0x1000003; + pkt->header.size = size; + struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; + + buf_desc[0].size = buf_desc[0].length = sizeof(struct cam_cmd_i2c_info) + sizeof(struct cam_cmd_probe); + buf_desc[0].type = CAM_CMD_BUF_LEGACY; + struct cam_cmd_i2c_info *i2c_info = (struct cam_cmd_i2c_info *)alloc_w_mmu_hdl(video0_fd, buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle); + struct cam_cmd_probe *probe = (struct cam_cmd_probe *)((uint8_t *)i2c_info) + sizeof(struct cam_cmd_i2c_info); + + switch (camera_num) { + case 0: + // port 0 + i2c_info->slave_addr = 0x20; + probe->camera_id = 0; + break; + case 1: + // port 1 + i2c_info->slave_addr = 0x30; + probe->camera_id = 1; + break; + case 2: + // port 2 + i2c_info->slave_addr = 0x20; + probe->camera_id = 2; + break; + } + + // 0(I2C_STANDARD_MODE) = 100khz, 1(I2C_FAST_MODE) = 400khz + //i2c_info->i2c_freq_mode = I2C_STANDARD_MODE; + i2c_info->i2c_freq_mode = I2C_FAST_MODE; + i2c_info->cmd_type = CAMERA_SENSOR_CMD_TYPE_I2C_INFO; + + probe->data_type = CAMERA_SENSOR_I2C_TYPE_WORD; + probe->addr_type = CAMERA_SENSOR_I2C_TYPE_WORD; + probe->op_code = 3; // don't care? + probe->cmd_type = CAMERA_SENSOR_CMD_TYPE_PROBE; + probe->reg_addr = 0x3000; //0x300a; //0x300b; + probe->expected_data = 0x354; //0x7750; //0x885a; + probe->data_mask = 0; + + //buf_desc[1].size = buf_desc[1].length = 148; + buf_desc[1].size = buf_desc[1].length = 196; + buf_desc[1].type = CAM_CMD_BUF_I2C; + struct cam_cmd_power *power_settings = (struct cam_cmd_power *)alloc_w_mmu_hdl(video0_fd, buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle); + memset(power_settings, 0, buf_desc[1].size); + // 7750 + /*power->count = 2; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; + power->power_settings[0].power_seq_type = 2; + power->power_settings[1].power_seq_type = 8; + power = (void*)power + (sizeof(struct cam_cmd_power) + (power->count-1)*sizeof(struct cam_power_settings));*/ + + // 885a + struct cam_cmd_power *power = power_settings; + power->count = 4; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; + power->power_settings[0].power_seq_type = 3; // clock?? + power->power_settings[1].power_seq_type = 1; // analog + power->power_settings[2].power_seq_type = 2; // digital + power->power_settings[3].power_seq_type = 8; // reset low + power = power_set_wait(power, 5); + + // set clock + power->count = 1; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; + power->power_settings[0].power_seq_type = 0; + power->power_settings[0].config_val_low = 19200000; //Hz + power = power_set_wait(power, 10); + + // 8,1 is this reset? + power->count = 1; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; + power->power_settings[0].power_seq_type = 8; + power->power_settings[0].config_val_low = 1; + power = power_set_wait(power, 100); + + // probe happens here + + // disable clock + power->count = 1; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; + power->power_settings[0].power_seq_type = 0; + power->power_settings[0].config_val_low = 0; + power = power_set_wait(power, 1); + + // reset high + power->count = 1; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; + power->power_settings[0].power_seq_type = 8; + power->power_settings[0].config_val_low = 1; + power = power_set_wait(power, 1); + + // reset low + power->count = 1; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; + power->power_settings[0].power_seq_type = 8; + power->power_settings[0].config_val_low = 0; + power = power_set_wait(power, 1); + + // 7750 + /*power->count = 1; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; + power->power_settings[0].power_seq_type = 2; + power = (void*)power + (sizeof(struct cam_cmd_power) + (power->count-1)*sizeof(struct cam_power_settings));*/ + + // 885a + power->count = 3; + power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; + power->power_settings[0].power_seq_type = 2; + power->power_settings[1].power_seq_type = 1; + power->power_settings[2].power_seq_type = 3; + + LOGD("probing the sensor"); + int ret = cam_control(sensor_fd, CAM_SENSOR_PROBE_CMD, (void *)(uintptr_t)cam_packet_handle, 0); + assert(ret == 0); + + munmap(i2c_info, buf_desc[0].size); + release_fd(video0_fd, buf_desc[0].mem_handle); + munmap(power_settings, buf_desc[1].size); + release_fd(video0_fd, buf_desc[1].mem_handle); + munmap(pkt, size); + release_fd(video0_fd, cam_packet_handle); +} + +void config_isp(struct CameraState *s, int io_mem_handle, int fence, int request_id, int buf0_mem_handle, int buf0_offset) { + uint32_t cam_packet_handle = 0; + int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*2; + if (io_mem_handle != 0) { + size += sizeof(struct cam_buf_io_cfg); + } + struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); + pkt->num_cmd_buf = 2; + pkt->kmd_cmd_buf_index = 0; + + if (io_mem_handle != 0) { + pkt->io_configs_offset = sizeof(struct cam_cmd_buf_desc)*2; + pkt->num_io_configs = 1; + } + + if (io_mem_handle != 0) { + pkt->header.op_code = 0xf000001; + pkt->header.request_id = request_id; + } else { + pkt->header.op_code = 0xf000000; + } + pkt->header.size = size; + struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; + struct cam_buf_io_cfg *io_cfg = (struct cam_buf_io_cfg *)((char*)&pkt->payload + pkt->io_configs_offset); + + // TODO: support MMU + buf_desc[0].size = 65624; + buf_desc[0].length = 0; + buf_desc[0].type = CAM_CMD_BUF_DIRECT; + buf_desc[0].meta_data = 3; + buf_desc[0].mem_handle = buf0_mem_handle; + buf_desc[0].offset = buf0_offset; + + // cam_isp_packet_generic_blob_handler + uint32_t tmp[] = { + // size is 0x20, type is 0(CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG) + 0x2000, + 0x1, 0x0, CAM_ISP_IFE_OUT_RES_RDI_0, 0x1, 0x0, 0x1, 0x0, 0x0, // 1 port, CAM_ISP_IFE_OUT_RES_RDI_0 + // size is 0x38, type is 1(CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG), clocks + 0x3801, + 0x1, 0x4, // Dual mode, 4 RDI wires + 0x18148d00, 0x0, 0x18148d00, 0x0, 0x18148d00, 0x0, // rdi clock + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // junk? + // offset 0x60 + // size is 0xe0, type is 2(CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG), bandwidth + 0xe002, + 0x1, 0x4, // 4 RDI + 0x0, 0x0, 0x1ad27480, 0x0, 0x1ad27480, 0x0, // left_pix_vote + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // right_pix_vote + 0x0, 0x0, 0x6ee11c0, 0x2, 0x6ee11c0, 0x2, // rdi_vote + 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + + buf_desc[1].size = sizeof(tmp); + buf_desc[1].offset = io_mem_handle != 0 ? 0x60 : 0; + buf_desc[1].length = buf_desc[1].size - buf_desc[1].offset; + buf_desc[1].type = CAM_CMD_BUF_GENERIC; + buf_desc[1].meta_data = CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON; + uint32_t *buf2 = (uint32_t *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle, 0x20); + memcpy(buf2, tmp, sizeof(tmp)); + + if (io_mem_handle != 0) { + io_cfg[0].mem_handle[0] = io_mem_handle; + io_cfg[0].planes[0] = (struct cam_plane_cfg){ + .width = FRAME_WIDTH, + .height = FRAME_HEIGHT, + .plane_stride = FRAME_STRIDE, + .slice_height = FRAME_HEIGHT, + .meta_stride = 0x0, + .meta_size = 0x0, + .meta_offset = 0x0, + .packer_config = 0x0, + .mode_config = 0x0, + .tile_config = 0x0, + .h_init = 0x0, + .v_init = 0x0, + }; + io_cfg[0].format = CAM_FORMAT_MIPI_RAW_10; + io_cfg[0].color_pattern = 0x5; + io_cfg[0].bpp = 0xc; + io_cfg[0].resource_type = CAM_ISP_IFE_OUT_RES_RDI_0; + io_cfg[0].fence = fence; + io_cfg[0].direction = CAM_BUF_OUTPUT; + io_cfg[0].subsample_pattern = 0x1; + io_cfg[0].framedrop_pattern = 0x1; + } + + int ret = device_config(s->multi_cam_state->isp_fd, s->session_handle, s->isp_dev_handle, cam_packet_handle); + assert(ret == 0); + if (ret != 0) { + printf("ISP CONFIG FAILED\n"); + } + + munmap(buf2, buf_desc[1].size); + release_fd(s->multi_cam_state->video0_fd, buf_desc[1].mem_handle); + // release_fd(s->multi_cam_state->video0_fd, buf_desc[0].mem_handle); + munmap(pkt, size); + release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); +} + +void enqueue_buffer(struct CameraState *s, int i, bool dp) { + int ret; + int request_id = s->request_ids[i]; + + if (s->buf_handle[i]) { + release(s->multi_cam_state->video0_fd, s->buf_handle[i]); + // wait + struct cam_sync_wait sync_wait = {0}; + sync_wait.sync_obj = s->sync_objs[i]; + sync_wait.timeout_ms = 50; // max dt tolerance, typical should be 23 + ret = cam_control(s->multi_cam_state->video1_fd, CAM_SYNC_WAIT, &sync_wait, sizeof(sync_wait)); + // LOGD("fence wait: %d %d", ret, sync_wait.sync_obj); + + s->buf.camera_bufs_metadata[i].timestamp_eof = (uint64_t)nanos_since_boot(); // set true eof + if (dp) s->buf.queue(i); + + // destroy old output fence + struct cam_sync_info sync_destroy = {0}; + strcpy(sync_destroy.name, "NodeOutputPortFence"); + sync_destroy.sync_obj = s->sync_objs[i]; + ret = cam_control(s->multi_cam_state->video1_fd, CAM_SYNC_DESTROY, &sync_destroy, sizeof(sync_destroy)); + // LOGD("fence destroy: %d %d", ret, sync_destroy.sync_obj); + } + + // do stuff + struct cam_req_mgr_sched_request req_mgr_sched_request = {0}; + req_mgr_sched_request.session_hdl = s->session_handle; + req_mgr_sched_request.link_hdl = s->link_handle; + req_mgr_sched_request.req_id = request_id; + ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_SCHED_REQ, &req_mgr_sched_request, sizeof(req_mgr_sched_request)); + // LOGD("sched req: %d %d", ret, request_id); + + // create output fence + struct cam_sync_info sync_create = {0}; + strcpy(sync_create.name, "NodeOutputPortFence"); + ret = cam_control(s->multi_cam_state->video1_fd, CAM_SYNC_CREATE, &sync_create, sizeof(sync_create)); + // LOGD("fence req: %d %d", ret, sync_create.sync_obj); + s->sync_objs[i] = sync_create.sync_obj; + + // configure ISP to put the image in place + struct cam_mem_mgr_map_cmd mem_mgr_map_cmd = {0}; + mem_mgr_map_cmd.mmu_hdls[0] = s->multi_cam_state->device_iommu; + mem_mgr_map_cmd.num_hdl = 1; + mem_mgr_map_cmd.flags = CAM_MEM_FLAG_HW_READ_WRITE; + mem_mgr_map_cmd.fd = s->buf.camera_bufs[i].fd; + ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_MAP_BUF, &mem_mgr_map_cmd, sizeof(mem_mgr_map_cmd)); + // LOGD("map buf req: (fd: %d) 0x%x %d", s->bufs[i].fd, mem_mgr_map_cmd.out.buf_handle, ret); + s->buf_handle[i] = mem_mgr_map_cmd.out.buf_handle; + + // poke sensor + sensors_poke(s, request_id); + // LOGD("Poked sensor"); + + // push the buffer + config_isp(s, s->buf_handle[i], s->sync_objs[i], request_id, s->buf0_handle, 65632*(i+1)); +} + +void enqueue_req_multi(struct CameraState *s, int start, int n, bool dp) { + for (int i=start;irequest_ids[(i - 1) % FRAME_BUF_COUNT] = i; + enqueue_buffer(s, (i - 1) % FRAME_BUF_COUNT, dp); + } +} + +// ******************* camera ******************* + +static void camera_init(MultiCameraState *multi_cam_state, VisionIpcServer * v, CameraState *s, int camera_id, int camera_num, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) { + LOGD("camera init %d", camera_num); + s->multi_cam_state = multi_cam_state; + assert(camera_id < std::size(cameras_supported)); + s->ci = cameras_supported[camera_id]; + assert(s->ci.frame_width != 0); + + s->camera_num = camera_num; + + s->request_id_last = 0; + s->skipped = true; + + s->min_ev = EXPOSURE_TIME_MIN * sensor_analog_gains[ANALOG_GAIN_MIN_IDX]; + s->max_ev = EXPOSURE_TIME_MAX * sensor_analog_gains[ANALOG_GAIN_MAX_IDX] * DC_GAIN; + s->target_grey_fraction = 0.3; + + s->dc_gain_enabled = false; + s->gain_idx = ANALOG_GAIN_REC_IDX; + s->exposure_time = 5; + s->cur_ev[0] = s->cur_ev[1] = s->cur_ev[2] = (s->dc_gain_enabled ? DC_GAIN : 1) * sensor_analog_gains[s->gain_idx] * s->exposure_time; + + s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type); +} + +int open_v4l_by_name_and_index(const char name[], int index, int flags = O_RDWR | O_NONBLOCK) { + for (int v4l_index = 0; /**/; ++v4l_index) { + std::string v4l_name = util::read_file(util::string_format("/sys/class/video4linux/v4l-subdev%d/name", v4l_index)); + if (v4l_name.empty()) return -1; + if (v4l_name.find(name) == 0) { + if (index == 0) { + return open(util::string_format("/dev/v4l-subdev%d", v4l_index).c_str(), flags); + } + index--; + } + } +} + +static void camera_open(CameraState *s) { + s->sensor_fd = open_v4l_by_name_and_index("cam-sensor-driver", s->camera_num); + assert(s->sensor_fd >= 0); + LOGD("opened sensor"); + + s->csiphy_fd = open_v4l_by_name_and_index("cam-csiphy-driver", s->camera_num); + assert(s->csiphy_fd >= 0); + LOGD("opened csiphy"); + + // probe the sensor + LOGD("-- Probing sensor %d", s->camera_num); + sensors_init(s->multi_cam_state->video0_fd, s->sensor_fd, s->camera_num); + + // create session + struct cam_req_mgr_session_info session_info = {}; + int ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_CREATE_SESSION, &session_info, sizeof(session_info)); + LOGD("get session: %d 0x%X", ret, session_info.session_hdl); + s->session_handle = session_info.session_hdl; + + // access the sensor + LOGD("-- Accessing sensor"); + auto sensor_dev_handle = device_acquire(s->sensor_fd, s->session_handle, nullptr); + assert(sensor_dev_handle); + s->sensor_dev_handle = *sensor_dev_handle; + LOGD("acquire sensor dev"); + + struct cam_isp_in_port_info in_port_info = { + .res_type = (uint32_t[]){CAM_ISP_IFE_IN_RES_PHY_0, CAM_ISP_IFE_IN_RES_PHY_1, CAM_ISP_IFE_IN_RES_PHY_2}[s->camera_num], + + .lane_type = CAM_ISP_LANE_TYPE_DPHY, + .lane_num = 4, + .lane_cfg = 0x3210, + + .vc = 0x0, + // .dt = 0x2C; //CSI_RAW12 + .dt = 0x2B, //CSI_RAW10 + .format = CAM_FORMAT_MIPI_RAW_10, + + .test_pattern = 0x2, // 0x3? + .usage_type = 0x0, + + .left_start = 0, + .left_stop = FRAME_WIDTH - 1, + .left_width = FRAME_WIDTH, + + .right_start = 0, + .right_stop = FRAME_WIDTH - 1, + .right_width = FRAME_WIDTH, + + .line_start = 0, + .line_stop = FRAME_HEIGHT - 1, + .height = FRAME_HEIGHT, + + .pixel_clk = 0x0, + .batch_size = 0x0, + .dsp_mode = 0x0, + .hbi_cnt = 0x0, + .custom_csid = 0x0, + + .num_out_res = 0x1, + .data[0] = (struct cam_isp_out_port_info){ + .res_type = CAM_ISP_IFE_OUT_RES_RDI_0, + .format = CAM_FORMAT_MIPI_RAW_10, + .width = FRAME_WIDTH, + .height = FRAME_HEIGHT, + .comp_grp_id = 0x0, .split_point = 0x0, .secure_mode = 0x0, + }, + }; + struct cam_isp_resource isp_resource = { + .resource_id = CAM_ISP_RES_ID_PORT, + .handle_type = CAM_HANDLE_USER_POINTER, + .res_hdl = (uint64_t)&in_port_info, + .length = sizeof(in_port_info), + }; + + auto isp_dev_handle = device_acquire(s->multi_cam_state->isp_fd, s->session_handle, &isp_resource); + assert(isp_dev_handle); + s->isp_dev_handle = *isp_dev_handle; + LOGD("acquire isp dev"); + + struct cam_csiphy_acquire_dev_info csiphy_acquire_dev_info = {.combo_mode = 0}; + auto csiphy_dev_handle = device_acquire(s->csiphy_fd, s->session_handle, &csiphy_acquire_dev_info); + assert(csiphy_dev_handle); + s->csiphy_dev_handle = *csiphy_dev_handle; + LOGD("acquire csiphy dev"); + + // config ISP + alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, 984480, (uint32_t*)&s->buf0_handle, 0x20, CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE, s->multi_cam_state->device_iommu, s->multi_cam_state->cdm_iommu); + config_isp(s, 0, 0, 1, s->buf0_handle, 0); + + LOG("-- Configuring sensor"); + sensors_i2c(s, init_array_ar0231, std::size(init_array_ar0231), CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); + //sensors_i2c(s, start_reg_array, std::size(start_reg_array), CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMON); + //sensors_i2c(s, stop_reg_array, std::size(stop_reg_array), CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMOFF); + + // config csiphy + LOG("-- Config CSI PHY"); + { + uint32_t cam_packet_handle = 0; + int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*1; + struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); + pkt->num_cmd_buf = 1; + pkt->kmd_cmd_buf_index = -1; + pkt->header.size = size; + struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; + + buf_desc[0].size = buf_desc[0].length = sizeof(struct cam_csiphy_info); + buf_desc[0].type = CAM_CMD_BUF_GENERIC; + + struct cam_csiphy_info *csiphy_info = (struct cam_csiphy_info *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle); + csiphy_info->lane_mask = 0x1f; + csiphy_info->lane_assign = 0x3210;// skip clk. How is this 16 bit for 5 channels?? + csiphy_info->csiphy_3phase = 0x0; // no 3 phase, only 2 conductors per lane + csiphy_info->combo_mode = 0x0; + csiphy_info->lane_cnt = 0x4; + csiphy_info->secure_mode = 0x0; + csiphy_info->settle_time = MIPI_SETTLE_CNT * 200000000ULL; + csiphy_info->data_rate = 48000000; // Calculated by camera_freqs.py + + int ret_ = device_config(s->csiphy_fd, s->session_handle, s->csiphy_dev_handle, cam_packet_handle); + assert(ret_ == 0); + + munmap(csiphy_info, buf_desc[0].size); + release_fd(s->multi_cam_state->video0_fd, buf_desc[0].mem_handle); + munmap(pkt, size); + release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); + } + + // link devices + LOG("-- Link devices"); + struct cam_req_mgr_link_info req_mgr_link_info = {0}; + req_mgr_link_info.session_hdl = s->session_handle; + req_mgr_link_info.num_devices = 2; + req_mgr_link_info.dev_hdls[0] = s->isp_dev_handle; + req_mgr_link_info.dev_hdls[1] = s->sensor_dev_handle; + ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_LINK, &req_mgr_link_info, sizeof(req_mgr_link_info)); + LOGD("link: %d", ret); + s->link_handle = req_mgr_link_info.link_hdl; + + struct cam_req_mgr_link_control req_mgr_link_control = {0}; + req_mgr_link_control.ops = CAM_REQ_MGR_LINK_ACTIVATE; + req_mgr_link_control.session_hdl = s->session_handle; + req_mgr_link_control.num_links = 1; + req_mgr_link_control.link_hdls[0] = s->link_handle; + ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_LINK_CONTROL, &req_mgr_link_control, sizeof(req_mgr_link_control)); + LOGD("link control: %d", ret); + + ret = device_control(s->csiphy_fd, CAM_START_DEV, s->session_handle, s->csiphy_dev_handle); + LOGD("start csiphy: %d", ret); + ret = device_control(s->multi_cam_state->isp_fd, CAM_START_DEV, s->session_handle, s->isp_dev_handle); + LOGD("start isp: %d", ret); + ret = device_control(s->sensor_fd, CAM_START_DEV, s->session_handle, s->sensor_dev_handle); + LOGD("start sensor: %d", ret); + + enqueue_req_multi(s, 1, FRAME_BUF_COUNT, 0); +} + +void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { + camera_init(s, v, &s->road_cam, CAMERA_ID_AR0231, 1, 20, device_id, ctx, + VISION_STREAM_RGB_BACK, VISION_STREAM_ROAD); // swap left/right + printf("road camera initted \n"); + camera_init(s, v, &s->wide_road_cam, CAMERA_ID_AR0231, 0, 20, device_id, ctx, + VISION_STREAM_RGB_WIDE, VISION_STREAM_WIDE_ROAD); + printf("wide road camera initted \n"); + camera_init(s, v, &s->driver_cam, CAMERA_ID_AR0231, 2, 20, device_id, ctx, + VISION_STREAM_RGB_FRONT, VISION_STREAM_DRIVER); + printf("driver camera initted \n"); + + s->sm = new SubMaster({"driverState"}); + s->pm = new PubMaster({"roadCameraState", "driverCameraState", "wideRoadCameraState", "thumbnail"}); +} + +void cameras_open(MultiCameraState *s) { + int ret; + + LOG("-- Opening devices"); + // video0 is req_mgr, the target of many ioctls + s->video0_fd = HANDLE_EINTR(open("/dev/v4l/by-path/platform-soc:qcom_cam-req-mgr-video-index0", O_RDWR | O_NONBLOCK)); + assert(s->video0_fd >= 0); + LOGD("opened video0"); + + // video1 is cam_sync, the target of some ioctls + s->video1_fd = HANDLE_EINTR(open("/dev/v4l/by-path/platform-cam_sync-video-index0", O_RDWR | O_NONBLOCK)); + assert(s->video1_fd >= 0); + LOGD("opened video1"); + + // looks like there's only one of these + s->isp_fd = HANDLE_EINTR(open("/dev/v4l-subdev1", O_RDWR | O_NONBLOCK)); + assert(s->isp_fd >= 0); + LOGD("opened isp"); + + // query icp for MMU handles + LOG("-- Query ICP for MMU handles"); + static struct cam_isp_query_cap_cmd isp_query_cap_cmd = {0}; + static struct cam_query_cap_cmd query_cap_cmd = {0}; + query_cap_cmd.handle_type = 1; + query_cap_cmd.caps_handle = (uint64_t)&isp_query_cap_cmd; + query_cap_cmd.size = sizeof(isp_query_cap_cmd); + ret = cam_control(s->isp_fd, CAM_QUERY_CAP, &query_cap_cmd, sizeof(query_cap_cmd)); + assert(ret == 0); + LOGD("using MMU handle: %x", isp_query_cap_cmd.device_iommu.non_secure); + LOGD("using MMU handle: %x", isp_query_cap_cmd.cdm_iommu.non_secure); + s->device_iommu = isp_query_cap_cmd.device_iommu.non_secure; + s->cdm_iommu = isp_query_cap_cmd.cdm_iommu.non_secure; + + // subscribe + LOG("-- Subscribing"); + static struct v4l2_event_subscription sub = {0}; + sub.type = V4L_EVENT_CAM_REQ_MGR_EVENT; + sub.id = 2; // should use boot time for sof + ret = HANDLE_EINTR(ioctl(s->video0_fd, VIDIOC_SUBSCRIBE_EVENT, &sub)); + printf("req mgr subscribe: %d\n", ret); + + camera_open(&s->road_cam); + printf("road camera opened \n"); + camera_open(&s->wide_road_cam); + printf("wide road camera opened \n"); + camera_open(&s->driver_cam); + printf("driver camera opened \n"); +} + +static void camera_close(CameraState *s) { + int ret; + + // stop devices + LOG("-- Stop devices"); + // ret = device_control(s->sensor_fd, CAM_STOP_DEV, s->session_handle, s->sensor_dev_handle); + // LOGD("stop sensor: %d", ret); + ret = device_control(s->multi_cam_state->isp_fd, CAM_STOP_DEV, s->session_handle, s->isp_dev_handle); + LOGD("stop isp: %d", ret); + ret = device_control(s->csiphy_fd, CAM_STOP_DEV, s->session_handle, s->csiphy_dev_handle); + LOGD("stop csiphy: %d", ret); + // link control stop + LOG("-- Stop link control"); + static struct cam_req_mgr_link_control req_mgr_link_control = {0}; + req_mgr_link_control.ops = CAM_REQ_MGR_LINK_DEACTIVATE; + req_mgr_link_control.session_hdl = s->session_handle; + req_mgr_link_control.num_links = 1; + req_mgr_link_control.link_hdls[0] = s->link_handle; + ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_LINK_CONTROL, &req_mgr_link_control, sizeof(req_mgr_link_control)); + LOGD("link control stop: %d", ret); + + // unlink + LOG("-- Unlink"); + static struct cam_req_mgr_unlink_info req_mgr_unlink_info = {0}; + req_mgr_unlink_info.session_hdl = s->session_handle; + req_mgr_unlink_info.link_hdl = s->link_handle; + ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_UNLINK, &req_mgr_unlink_info, sizeof(req_mgr_unlink_info)); + LOGD("unlink: %d", ret); + + // release devices + LOGD("-- Release devices"); + ret = device_control(s->sensor_fd, CAM_RELEASE_DEV, s->session_handle, s->sensor_dev_handle); + LOGD("release sensor: %d", ret); + ret = device_control(s->multi_cam_state->isp_fd, CAM_RELEASE_DEV, s->session_handle, s->isp_dev_handle); + LOGD("release isp: %d", ret); + ret = device_control(s->csiphy_fd, CAM_RELEASE_DEV, s->session_handle, s->csiphy_dev_handle); + LOGD("release csiphy: %d", ret); + + // destroyed session + struct cam_req_mgr_session_info session_info = {.session_hdl = s->session_handle}; + ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_DESTROY_SESSION, &session_info, sizeof(session_info)); + LOGD("destroyed session: %d", ret); +} + +void cameras_close(MultiCameraState *s) { + camera_close(&s->road_cam); + camera_close(&s->wide_road_cam); + camera_close(&s->driver_cam); + + delete s->sm; + delete s->pm; +} + +// ******************* just a helper ******************* + +void handle_camera_event(CameraState *s, void *evdat) { + struct cam_req_mgr_message *event_data = (struct cam_req_mgr_message *)evdat; + + uint64_t timestamp = event_data->u.frame_msg.timestamp; + int main_id = event_data->u.frame_msg.frame_id; + int real_id = event_data->u.frame_msg.request_id; + + if (real_id != 0) { // next ready + if (real_id == 1) {s->idx_offset = main_id;} + int buf_idx = (real_id - 1) % FRAME_BUF_COUNT; + + // check for skipped frames + if (main_id > s->frame_id_last + 1 && !s->skipped) { + // realign + clear_req_queue(s->multi_cam_state->video0_fd, event_data->session_hdl, event_data->u.frame_msg.link_hdl); + enqueue_req_multi(s, real_id + 1, FRAME_BUF_COUNT - 1, 0); + s->skipped = true; + } else if (main_id == s->frame_id_last + 1) { + s->skipped = false; + } + + // check for dropped requests + if (real_id > s->request_id_last + 1) { + enqueue_req_multi(s, s->request_id_last + 1 + FRAME_BUF_COUNT, real_id - (s->request_id_last + 1), 0); + } + + // metas + s->frame_id_last = main_id; + s->request_id_last = real_id; + + auto &meta_data = s->buf.camera_bufs_metadata[buf_idx]; + meta_data.frame_id = main_id - s->idx_offset; + meta_data.timestamp_sof = timestamp; + s->exp_lock.lock(); + meta_data.gain = s->dc_gain_enabled ? s->analog_gain_frac * DC_GAIN : s->analog_gain_frac; + meta_data.high_conversion_gain = s->dc_gain_enabled; + meta_data.integ_lines = s->exposure_time; + meta_data.measured_grey_fraction = s->measured_grey_fraction; + meta_data.target_grey_fraction = s->target_grey_fraction; + s->exp_lock.unlock(); + + // dispatch + enqueue_req_multi(s, real_id + FRAME_BUF_COUNT, 1, 1); + } else { // not ready + // reset after half second of no response + if (main_id > s->frame_id_last + 10) { + clear_req_queue(s->multi_cam_state->video0_fd, event_data->session_hdl, event_data->u.frame_msg.link_hdl); + enqueue_req_multi(s, s->request_id_last + 1, FRAME_BUF_COUNT, 0); + s->frame_id_last = main_id; + s->skipped = true; + } + } +} + +static void set_camera_exposure(CameraState *s, float grey_frac) { + const float dt = 0.05; + + const float ts_grey = 10.0; + const float ts_ev = 0.05; + + const float k_grey = (dt / ts_grey) / (1.0 + dt / ts_grey); + const float k_ev = (dt / ts_ev) / (1.0 + dt / ts_ev); + + // It takes 3 frames for the commanded exposure settings to take effect. The first frame is already started by the time + // we reach this function, the other 2 are due to the register buffering in the sensor. + // Therefore we use the target EV from 3 frames ago, the grey fraction that was just measured was the result of that control action. + // TODO: Lower latency to 2 frames, by using the histogram outputed by the sensor we can do AE before the debayering is complete + + const float cur_ev = s->cur_ev[s->buf.cur_frame_data.frame_id % 3]; + + // Scale target grey between 0.1 and 0.4 depending on lighting conditions + float new_target_grey = std::clamp(0.4 - 0.3 * log2(1.0 + cur_ev) / log2(6000.0), 0.1, 0.4); + float target_grey = (1.0 - k_grey) * s->target_grey_fraction + k_grey * new_target_grey; + + float desired_ev = std::clamp(cur_ev * target_grey / grey_frac, s->min_ev, s->max_ev); + float k = (1.0 - k_ev) / 3.0; + desired_ev = (k * s->cur_ev[0]) + (k * s->cur_ev[1]) + (k * s->cur_ev[2]) + (k_ev * desired_ev); + + float best_ev_score = 1e6; + int new_g = 0; + int new_t = 0; + + // Hysteresis around high conversion gain + // We usually want this on since it results in lower noise, but turn off in very bright day scenes + bool enable_dc_gain = s->dc_gain_enabled; + if (!enable_dc_gain && target_grey < 0.2) { + enable_dc_gain = true; + } else if (enable_dc_gain && target_grey > 0.3) { + enable_dc_gain = false; + } + + // Simple brute force optimizer to choose sensor parameters + // to reach desired EV + for (int g = std::max((int)ANALOG_GAIN_MIN_IDX, s->gain_idx - 1); g <= std::min((int)ANALOG_GAIN_MAX_IDX, s->gain_idx + 1); g++) { + float gain = sensor_analog_gains[g] * (enable_dc_gain ? DC_GAIN : 1); + + // Compute optimal time for given gain + int t = std::clamp(int(std::round(desired_ev / gain)), EXPOSURE_TIME_MIN, EXPOSURE_TIME_MAX); + + // Only go below recomended gain when absolutely necessary to not overexpose + if (g < ANALOG_GAIN_REC_IDX && t > 20 && g < s->gain_idx) { + continue; + } + + // Compute error to desired ev + float score = std::abs(desired_ev - (t * gain)) * 10; + + // Going below recomended gain needs lower penalty to not overexpose + float m = g > ANALOG_GAIN_REC_IDX ? 5.0 : 0.1; + score += std::abs(g - (int)ANALOG_GAIN_REC_IDX) * m; + + // LOGE("cam: %d - gain: %d, t: %d (%.2f), score %.2f, score + gain %.2f, %.3f, %.3f", s->camera_num, g, t, desired_ev / gain, score, score + std::abs(g - s->gain_idx) * (score + 1.0) / 10.0, desired_ev, s->min_ev); + + // Small penalty on changing gain + score += std::abs(g - s->gain_idx) * (score + 1.0) / 10.0; + + if (score < best_ev_score) { + new_t = t; + new_g = g; + best_ev_score = score; + } + } + + s->exp_lock.lock(); + + s->measured_grey_fraction = grey_frac; + s->target_grey_fraction = target_grey; + + s->analog_gain_frac = sensor_analog_gains[new_g]; + s->gain_idx = new_g; + s->exposure_time = new_t; + s->dc_gain_enabled = enable_dc_gain; + + float gain = s->analog_gain_frac * (s->dc_gain_enabled ? DC_GAIN : 1.0); + s->cur_ev[s->buf.cur_frame_data.frame_id % 3] = s->exposure_time * gain; + + s->exp_lock.unlock(); + + // Processing a frame takes right about 50ms, so we need to wait a few ms + // so we don't send i2c commands around the frame start. + int ms = (nanos_since_boot() - s->buf.cur_frame_data.timestamp_sof) / 1000000; + if (ms < 60) { + util::sleep_for(60 - ms); + } + // LOGE("ae - camera %d, cur_t %.5f, sof %.5f, dt %.5f", s->camera_num, 1e-9 * nanos_since_boot(), 1e-9 * s->buf.cur_frame_data.timestamp_sof, 1e-9 * (nanos_since_boot() - s->buf.cur_frame_data.timestamp_sof)); + + uint16_t analog_gain_reg = 0xFF00 | (new_g << 4) | new_g; + struct i2c_random_wr_payload exp_reg_array[] = { + {0x3366, analog_gain_reg}, + {0x3362, (uint16_t)(s->dc_gain_enabled ? 0x1 : 0x0)}, + {0x3012, (uint16_t)s->exposure_time}, + }; + sensors_i2c(s, exp_reg_array, sizeof(exp_reg_array)/sizeof(struct i2c_random_wr_payload), + CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); + +} + +void camera_autoexposure(CameraState *s, float grey_frac) { + set_camera_exposure(s, grey_frac); +} + +// called by processing_thread +void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) { + const CameraBuf *b = &c->buf; + + MessageBuilder msg; + auto framed = c == &s->road_cam ? msg.initEvent().initRoadCameraState() : msg.initEvent().initWideRoadCameraState(); + fill_frame_data(framed, b->cur_frame_data); + if ((c == &s->road_cam && env_send_road) || (c == &s->wide_road_cam && env_send_wide_road)) { + framed.setImage(get_frame_image(b)); + } + if (c == &s->road_cam) { + framed.setTransform(b->yuv_transform.v); + } + s->pm->send(c == &s->road_cam ? "roadCameraState" : "wideRoadCameraState", msg); + + const auto [x, y, w, h] = (c == &s->wide_road_cam) ? std::tuple(96, 250, 1734, 524) : std::tuple(96, 160, 1734, 986); + const int skip = 2; + camera_autoexposure(c, set_exposure_target(b, x, x + w, skip, y, y + h, skip)); +} + +void cameras_run(MultiCameraState *s) { + LOG("-- Starting threads"); + std::vector threads; + threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera)); + threads.push_back(start_process_thread(s, &s->driver_cam, common_process_driver_camera)); + threads.push_back(start_process_thread(s, &s->wide_road_cam, process_road_camera)); + + // start devices + LOG("-- Starting devices"); + int start_reg_len = sizeof(start_reg_array) / sizeof(struct i2c_random_wr_payload); + sensors_i2c(&s->road_cam, start_reg_array, start_reg_len, CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); + sensors_i2c(&s->wide_road_cam, start_reg_array, start_reg_len, CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); + sensors_i2c(&s->driver_cam, start_reg_array, start_reg_len, CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); + + // poll events + LOG("-- Dequeueing Video events"); + while (!do_exit) { + struct pollfd fds[1] = {{0}}; + + fds[0].fd = s->video0_fd; + fds[0].events = POLLPRI; + + int ret = poll(fds, std::size(fds), 1000); + if (ret < 0) { + if (errno == EINTR || errno == EAGAIN) continue; + LOGE("poll failed (%d - %d)", ret, errno); + break; + } + + if (!fds[0].revents) continue; + + struct v4l2_event ev = {0}; + ret = HANDLE_EINTR(ioctl(fds[0].fd, VIDIOC_DQEVENT, &ev)); + if (ret == 0) { + if (ev.type == V4L_EVENT_CAM_REQ_MGR_EVENT) { + struct cam_req_mgr_message *event_data = (struct cam_req_mgr_message *)ev.u.data; + // LOGD("v4l2 event: sess_hdl %d, link_hdl %d, frame_id %d, req_id %lld, timestamp 0x%llx, sof_status %d\n", event_data->session_hdl, event_data->u.frame_msg.link_hdl, event_data->u.frame_msg.frame_id, event_data->u.frame_msg.request_id, event_data->u.frame_msg.timestamp, event_data->u.frame_msg.sof_status); + // printf("sess_hdl %d, link_hdl %d, frame_id %lu, req_id %lu, timestamp 0x%lx, sof_status %d\n", event_data->session_hdl, event_data->u.frame_msg.link_hdl, event_data->u.frame_msg.frame_id, event_data->u.frame_msg.request_id, event_data->u.frame_msg.timestamp, event_data->u.frame_msg.sof_status); + + if (event_data->session_hdl == s->road_cam.session_handle) { + handle_camera_event(&s->road_cam, event_data); + } else if (event_data->session_hdl == s->wide_road_cam.session_handle) { + handle_camera_event(&s->wide_road_cam, event_data); + } else if (event_data->session_hdl == s->driver_cam.session_handle) { + handle_camera_event(&s->driver_cam, event_data); + } else { + printf("Unknown vidioc event source\n"); + assert(false); + } + } + } else { + LOGE("VIDIOC_DQEVENT failed, errno=%d", errno); + } + } + + LOG(" ************** STOPPING **************"); + + for (auto &t : threads) t.join(); + + cameras_close(s); +} diff --git a/selfdrive/camerad/cameras/camera_qcom2.h b/selfdrive/camerad/cameras/camera_qcom2.h new file mode 100644 index 00000000000000..f8ab2da8ae5fc2 --- /dev/null +++ b/selfdrive/camerad/cameras/camera_qcom2.h @@ -0,0 +1,67 @@ +#pragma once + +#include + +#include + +#include "selfdrive/camerad/cameras/camera_common.h" +#include "selfdrive/common/util.h" + +#define FRAME_BUF_COUNT 4 + +typedef struct CameraState { + MultiCameraState *multi_cam_state; + CameraInfo ci; + + std::mutex exp_lock; + + int exposure_time; + bool dc_gain_enabled; + float analog_gain_frac; + + float cur_ev[3]; + float min_ev, max_ev; + + float measured_grey_fraction; + float target_grey_fraction; + int gain_idx; + + unique_fd sensor_fd; + unique_fd csiphy_fd; + + int camera_num; + + int32_t session_handle; + int32_t sensor_dev_handle; + int32_t isp_dev_handle; + int32_t csiphy_dev_handle; + + int32_t link_handle; + + int buf0_handle; + int buf_handle[FRAME_BUF_COUNT]; + int sync_objs[FRAME_BUF_COUNT]; + int request_ids[FRAME_BUF_COUNT]; + int request_id_last; + int frame_id_last; + int idx_offset; + bool skipped; + + CameraBuf buf; +} CameraState; + +typedef struct MultiCameraState { + unique_fd video0_fd; + unique_fd video1_fd; + unique_fd isp_fd; + int device_iommu; + int cdm_iommu; + + + CameraState road_cam; + CameraState wide_road_cam; + CameraState driver_cam; + + SubMaster *sm; + PubMaster *pm; +} MultiCameraState; diff --git a/selfdrive/camerad/cameras/camera_replay.cc b/selfdrive/camerad/cameras/camera_replay.cc new file mode 100644 index 00000000000000..b5b2e6ad298acd --- /dev/null +++ b/selfdrive/camerad/cameras/camera_replay.cc @@ -0,0 +1,125 @@ +#include "selfdrive/camerad/cameras/camera_replay.h" + +#include +#include + +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/util.h" + +extern ExitHandler do_exit; + +void camera_autoexposure(CameraState *s, float grey_frac) {} + +namespace { + +const char *BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/"; + +const std::string road_camera_route = "0c94aa1e1296d7c6|2021-05-05--19-48-37"; +// const std::string driver_camera_route = "534ccd8a0950a00c|2021-06-08--12-15-37"; + +std::string get_url(std::string route_name, const std::string &camera, int segment_num) { + std::replace(route_name.begin(), route_name.end(), '|', '/'); + return util::string_format("%s%s/%d/%s.hevc", BASE_URL, route_name.c_str(), segment_num, camera.c_str()); +} + +void camera_init(VisionIpcServer *v, CameraState *s, int camera_id, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type, const std::string &url) { + s->frame = new FrameReader(); + if (!s->frame->load(url)) { + printf("failed to load stream from %s", url.c_str()); + assert(0); + } + + CameraInfo ci = { + .frame_width = s->frame->width, + .frame_height = s->frame->height, + .frame_stride = s->frame->width * 3, + }; + s->ci = ci; + s->camera_num = camera_id; + s->fps = fps; + s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type); +} + +void camera_close(CameraState *s) { + delete s->frame; +} + +void run_camera(CameraState *s) { + uint32_t stream_frame_id = 0, frame_id = 0; + size_t buf_idx = 0; + std::unique_ptr rgb_buf = std::make_unique(s->frame->getRGBSize()); + std::unique_ptr yuv_buf = std::make_unique(s->frame->getYUVSize()); + while (!do_exit) { + if (stream_frame_id == s->frame->getFrameCount()) { + // loop stream + stream_frame_id = 0; + } + if (s->frame->get(stream_frame_id++, rgb_buf.get(), yuv_buf.get())) { + s->buf.camera_bufs_metadata[buf_idx] = {.frame_id = frame_id}; + auto &buf = s->buf.camera_bufs[buf_idx]; + CL_CHECK(clEnqueueWriteBuffer(buf.copy_q, buf.buf_cl, CL_TRUE, 0, s->frame->getRGBSize(), rgb_buf.get(), 0, NULL, NULL)); + s->buf.queue(buf_idx); + ++frame_id; + buf_idx = (buf_idx + 1) % FRAME_BUF_COUNT; + } + util::sleep_for(1000 / s->fps); + } +} + +void road_camera_thread(CameraState *s) { + util::set_thread_name("replay_road_camera_thread"); + run_camera(s); +} + +// void driver_camera_thread(CameraState *s) { +// util::set_thread_name("replay_driver_camera_thread"); +// run_camera(s); +// } + +void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) { + const CameraBuf *b = &c->buf; + MessageBuilder msg; + auto framed = msg.initEvent().initRoadCameraState(); + fill_frame_data(framed, b->cur_frame_data); + framed.setImage(kj::arrayPtr((const uint8_t *)b->cur_yuv_buf->addr, b->cur_yuv_buf->len)); + framed.setTransform(b->yuv_transform.v); + s->pm->send("roadCameraState", msg); +} + +// void process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) { +// MessageBuilder msg; +// auto framed = msg.initEvent().initDriverCameraState(); +// framed.setFrameType(cereal::FrameData::FrameType::FRONT); +// fill_frame_data(framed, c->buf.cur_frame_data); +// s->pm->send("driverCameraState", msg); +// } + +} // namespace + +void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { + camera_init(v, &s->road_cam, CAMERA_ID_LGC920, 20, device_id, ctx, + VISION_STREAM_RGB_BACK, VISION_STREAM_ROAD, get_url(road_camera_route, "fcamera", 0)); + // camera_init(v, &s->driver_cam, CAMERA_ID_LGC615, 10, device_id, ctx, + // VISION_STREAM_RGB_FRONT, VISION_STREAM_DRIVER, get_url(driver_camera_route, "dcamera", 0)); + s->pm = new PubMaster({"roadCameraState", "driverCameraState", "thumbnail"}); +} + +void cameras_open(MultiCameraState *s) {} + +void cameras_close(MultiCameraState *s) { + camera_close(&s->road_cam); + camera_close(&s->driver_cam); + delete s->pm; +} + +void cameras_run(MultiCameraState *s) { + std::vector threads; + threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera)); + // threads.push_back(start_process_thread(s, &s->driver_cam, process_driver_camera)); + // threads.push_back(std::thread(driver_camera_thread, &s->driver_cam)); + road_camera_thread(&s->road_cam); + + for (auto &t : threads) t.join(); + + cameras_close(s); +} diff --git a/selfdrive/camerad/cameras/camera_replay.h b/selfdrive/camerad/cameras/camera_replay.h new file mode 100644 index 00000000000000..7c41af0ab4d3ba --- /dev/null +++ b/selfdrive/camerad/cameras/camera_replay.h @@ -0,0 +1,25 @@ +#pragma once + +#include "selfdrive/camerad/cameras/camera_common.h" +#include "selfdrive/ui/replay/framereader.h" + +#define FRAME_BUF_COUNT 16 + +typedef struct CameraState { + int camera_num; + CameraInfo ci; + + int fps; + float digital_gain = 0; + + CameraBuf buf; + FrameReader *frame = nullptr; +} CameraState; + +typedef struct MultiCameraState { + CameraState road_cam; + CameraState driver_cam; + + SubMaster *sm = nullptr; + PubMaster *pm = nullptr; +} MultiCameraState; 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/camerad/cameras/real_debayer.cl b/selfdrive/camerad/cameras/real_debayer.cl new file mode 100644 index 00000000000000..fe6a99f3732aed --- /dev/null +++ b/selfdrive/camerad/cameras/real_debayer.cl @@ -0,0 +1,207 @@ +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +const half black_level = 42.0; + +const __constant half3 color_correction[3] = { + // post wb CCM + (half3)(1.82717181, -0.31231438, 0.07307673), + (half3)(-0.5743977, 1.36858544, -0.53183455), + (half3)(-0.25277411, -0.05627105, 1.45875782), +}; + +// tone mapping params +const half cpk = 0.75; +const half cpb = 0.125; +const half cpxk = 0.0025; +const half cpxb = 0.01; + +half mf(half x, half cp) { + half rk = 9 - 100*cp; + if (x > cp) { + return (rk * (x-cp) * (1-(cpk*cp+cpb)) * (1+1/(rk*(1-cp))) / (1+rk*(x-cp))) + cpk*cp + cpb; + } else if (x < cp) { + return (rk * (x-cp) * (cpk*cp+cpb) * (1+1/(rk*cp)) / (1-rk*(x-cp))) + cpk*cp + cpb; + } else { + return x; + } +} + +half3 color_correct(half3 rgb) { + half3 ret = (0,0,0); + half cpx = 0.01; + ret += (half)rgb.x * color_correction[0]; + ret += (half)rgb.y * color_correction[1]; + ret += (half)rgb.z * color_correction[2]; + ret.x = mf(ret.x, cpx); + ret.y = mf(ret.y, cpx); + ret.z = mf(ret.z, cpx); + ret = clamp(0.0h, 255.0h, ret*255.0h); + return ret; +} + +half val_from_10(const uchar * source, int gx, int gy) { + // parse 10bit + int start = gy * FRAME_STRIDE + (5 * (gx / 4)); + int offset = gx % 4; + uint major = (uint)source[start + offset] << 2; + uint minor = (source[start + 4] >> (2 * offset)) & 3; + half pv = (half)(major + minor); + + // normalize + pv = max(0.0h, pv - black_level); + pv *= 0.00101833h; // /= (1024.0f - black_level); + + // correct vignetting + if (CAM_NUM == 1) { // fcamera + gx = (gx - RGB_WIDTH/2); + gy = (gy - RGB_HEIGHT/2); + float r = gx*gx + gy*gy; + half s; + if (r < 62500) { + s = (half)(1.0f + 0.0000008f*r); + } else if (r < 490000) { + s = (half)(0.9625f + 0.0000014f*r); + } else if (r < 1102500) { + s = (half)(1.26434f + 0.0000000000016f*r*r); + } else { + s = (half)(0.53503625f + 0.0000000000022f*r*r); + } + pv = s * pv; + } + + pv = clamp(0.0h, 1.0h, pv); + return pv; +} + +half fabs_diff(half x, half y) { + return fabs(x-y); +} + +half phi(half x) { + // detection funtion + return 2 - x; + // if (x > 1) { + // return 1 / x; + // } else { + // return 2 - x; + // } +} + +__kernel void debayer10(const __global uchar * in, + __global uchar * out, + __local half * cached + ) +{ + const int x_global = get_global_id(0); + const int y_global = get_global_id(1); + + const int localRowLen = 2 + get_local_size(0); // 2 padding + const int x_local = get_local_id(0); // 0-15 + const int y_local = get_local_id(1); // 0-15 + const int localOffset = (y_local + 1) * localRowLen + x_local + 1; // max 18x18-1 + + int out_idx = 3 * x_global + 3 * y_global * RGB_WIDTH; + + half pv = val_from_10(in, x_global, y_global); + cached[localOffset] = pv; + + // don't care + if (x_global < 1 || x_global >= RGB_WIDTH - 1 || y_global < 1 || y_global >= RGB_HEIGHT - 1) { + return; + } + + // cache padding + int localColOffset = -1; + int globalColOffset = -1; + + // cache padding + if (x_local < 1) { + localColOffset = x_local; + globalColOffset = -1; + cached[(y_local + 1) * localRowLen + x_local] = val_from_10(in, x_global-1, y_global); + } else if (x_local >= get_local_size(0) - 1) { + localColOffset = x_local + 2; + globalColOffset = 1; + cached[localOffset + 1] = val_from_10(in, x_global+1, y_global); + } + + if (y_local < 1) { + cached[y_local * localRowLen + x_local + 1] = val_from_10(in, x_global, y_global-1); + if (localColOffset != -1) { + cached[y_local * localRowLen + localColOffset] = val_from_10(in, x_global+globalColOffset, y_global-1); + } + } else if (y_local >= get_local_size(1) - 1) { + cached[(y_local + 2) * localRowLen + x_local + 1] = val_from_10(in, x_global, y_global+1); + if (localColOffset != -1) { + cached[(y_local + 2) * localRowLen + localColOffset] = val_from_10(in, x_global+globalColOffset, y_global+1); + } + } + + // sync + barrier(CLK_LOCAL_MEM_FENCE); + + half d1 = cached[localOffset - localRowLen - 1]; + half d2 = cached[localOffset - localRowLen + 1]; + half d3 = cached[localOffset + localRowLen - 1]; + half d4 = cached[localOffset + localRowLen + 1]; + half n1 = cached[localOffset - localRowLen]; + half n2 = cached[localOffset + 1]; + half n3 = cached[localOffset + localRowLen]; + half n4 = cached[localOffset - 1]; + + half3 rgb; + + // a simplified version of https://opensignalprocessingjournal.com/contents/volumes/V6/TOSIGPJ-6-1/TOSIGPJ-6-1.pdf + if (x_global % 2 == 0) { + if (y_global % 2 == 0) { + rgb.y = pv; // G1(R) + half k1 = phi(fabs_diff(d1, pv) + fabs_diff(d2, pv)); + half k2 = phi(fabs_diff(d2, pv) + fabs_diff(d4, pv)); + half k3 = phi(fabs_diff(d3, pv) + fabs_diff(d4, pv)); + half k4 = phi(fabs_diff(d1, pv) + fabs_diff(d3, pv)); + // R_G1 + rgb.x = (k2*n2+k4*n4)/(k2+k4); + // B_G1 + rgb.z = (k1*n1+k3*n3)/(k1+k3); + } else { + rgb.z = pv; // B + half k1 = phi(fabs_diff(d1, d3) + fabs_diff(d2, d4)); + half k2 = phi(fabs_diff(n1, n4) + fabs_diff(n2, n3)); + half k3 = phi(fabs_diff(d1, d2) + fabs_diff(d3, d4)); + half k4 = phi(fabs_diff(n1, n2) + fabs_diff(n3, n4)); + // G_B + rgb.y = (k1*(n1+n3)*0.5+k3*(n2+n4)*0.5)/(k1+k3); + // R_B + rgb.x = (k2*(d2+d3)*0.5+k4*(d1+d4)*0.5)/(k2+k4); + } + } else { + if (y_global % 2 == 0) { + rgb.x = pv; // R + half k1 = phi(fabs_diff(d1, d3) + fabs_diff(d2, d4)); + half k2 = phi(fabs_diff(n1, n4) + fabs_diff(n2, n3)); + half k3 = phi(fabs_diff(d1, d2) + fabs_diff(d3, d4)); + half k4 = phi(fabs_diff(n1, n2) + fabs_diff(n3, n4)); + // G_R + rgb.y = (k1*(n1+n3)*0.5+k3*(n2+n4)*0.5)/(k1+k3); + // B_R + rgb.z = (k2*(d2+d3)*0.5+k4*(d1+d4)*0.5)/(k2+k4); + } else { + rgb.y = pv; // G2(B) + half k1 = phi(fabs_diff(d1, pv) + fabs_diff(d2, pv)); + half k2 = phi(fabs_diff(d2, pv) + fabs_diff(d4, pv)); + half k3 = phi(fabs_diff(d3, pv) + fabs_diff(d4, pv)); + half k4 = phi(fabs_diff(d1, pv) + fabs_diff(d3, pv)); + // R_G2 + rgb.x = (k1*n1+k3*n3)/(k1+k3); + // B_G2 + rgb.z = (k2*n2+k4*n4)/(k2+k4); + } + } + + rgb = clamp(0.0h, 1.0h, rgb); + rgb = color_correct(rgb); + + out[out_idx + 0] = (uchar)(rgb.z); + out[out_idx + 1] = (uchar)(rgb.y); + out[out_idx + 2] = (uchar)(rgb.x); +} diff --git a/selfdrive/camerad/cameras/sensor2_i2c.h b/selfdrive/camerad/cameras/sensor2_i2c.h new file mode 100644 index 00000000000000..c3d8861a9749af --- /dev/null +++ b/selfdrive/camerad/cameras/sensor2_i2c.h @@ -0,0 +1,124 @@ +struct i2c_random_wr_payload start_reg_array[] = {{0x301A, 0x91C}}; +struct i2c_random_wr_payload stop_reg_array[] = {{0x301A, 0x918}}; + +struct i2c_random_wr_payload init_array_ar0231[] = { + {0x301A, 0x0018}, // RESET_REGISTER + + // CLOCK Settings + {0x302A, 0x0006}, // VT_PIX_CLK_DIV + {0x302C, 0x0001}, // VT_SYS_CLK_DIV + {0x302E, 0x0002}, // PRE_PLL_CLK_DIV + {0x3030, 0x0032}, // PLL_MULTIPLIER + {0x3036, 0x000A}, // OP_WORD_CLK_DIV + {0x3038, 0x0001}, // OP_SYS_CLK_DIV + + // FORMAT + {0x3040, 0xC000}, // READ_MODE + {0x3004, 0x0000}, // X_ADDR_START_ (A) + {0x308A, 0x0000}, // X_ADDR_START_ (B) + {0x3008, 0x0787}, // X_ADDR_END_ (A) + {0x308E, 0x0787}, // X_ADDR_END_ (B) + {0x3002, 0x0000}, // Y_ADDR_START_ (A) + {0x308C, 0x0000}, // Y_ADDR_START_ (B) + {0x3006, 0x04B7}, // Y_ADDR_END_ (A) + {0x3090, 0x04B7}, // Y_ADDR_END_ (B) + {0x3032, 0x0000}, // SCALING_MODE + {0x30A2, 0x0001}, // X_ODD_INC_ (A) + {0x30AE, 0x0001}, // X_ODD_INC_ (B) + {0x30A6, 0x0001}, // Y_ODD_INC_ (A) + {0x30A8, 0x0001}, // Y_ODD_INC_ (B) + {0x3402, 0x0F10}, // X_OUTPUT_CONTROL + {0x3404, 0x0970}, // Y_OUTPUT_CONTROL + {0x3064, 0x1802}, // SMIA_TEST + {0x30BA, 0x11F2}, // DIGITAL_CTRL + + // SLAV* MODE + {0x30CE, 0x0120}, + {0x340A, 0xE6}, // E6 // 0000 1110 0110 + {0x340C, 0x802}, // 2 // 0000 0000 0010 + + // Readout timing + {0x300C, 0x07B9}, // LINE_LENGTH_PCK (A) + {0x303E, 0x07B9}, // LINE_LENGTH_PCK (B) + {0x300A, 0x07E7}, // FRAME_LENGTH_LINES (A) + {0x30AA, 0x07E7}, // FRAME_LENGTH_LINES (B) + {0x3042, 0x0000}, // EXTRA_DELAY + + // Readout Settings + {0x31AE, 0x0204}, // SERIAL_FORMAT, 4-lane MIPI + {0x31AC, 0x0C0A}, // DATA_FORMAT_BITS, 12 -> 10 + {0x3342, 0x122B}, // MIPI_F1_PDT_EDT + {0x3346, 0x122B}, // MIPI_F2_PDT_EDT + {0x334A, 0x122B}, // MIPI_F3_PDT_EDT + {0x334E, 0x122B}, // MIPI_F4_PDT_EDT + {0x3344, 0x0011}, // MIPI_F1_VDT_VC + {0x3348, 0x0111}, // MIPI_F2_VDT_VC + {0x334C, 0x0211}, // MIPI_F3_VDT_VC + {0x3350, 0x0311}, // MIPI_F4_VDT_VC + {0x31B0, 0x0053}, // FRAME_PREAMBLE + {0x31B2, 0x003B}, // LINE_PREAMBLE + {0x301A, 0x001C}, // RESET_REGISTER + + // Noise Corrections + {0x3092, 0x0C24}, // ROW_NOISE_CONTROL + {0x337A, 0x0C80}, // DBLC_SCALE0 + {0x3370, 0x03B1}, // DBLC + {0x3044, 0x0400}, // DARK_CONTROL + + // Enable dead pixel correction using + // the 1D line correction scheme + {0x31E0, 0x0003}, + + // HDR Settings + {0x3082, 0x0004}, // OPERATION_MODE_CTRL (A) + {0x3084, 0x0004}, // OPERATION_MODE_CTRL (B) + + {0x3238, 0x0004}, // EXPOSURE_RATIO (A) + {0x323A, 0x0004}, // EXPOSURE_RATIO (B) + + {0x3014, 0x098E}, // FINE_INTEGRATION_TIME_ (A) + {0x3018, 0x098E}, // FINE_INTEGRATION_TIME_ (B) + + {0x321E, 0x098E}, // FINE_INTEGRATION_TIME2 (A) + {0x3220, 0x098E}, // FINE_INTEGRATION_TIME2 (B) + + {0x31D0, 0x0000}, // COMPANDING, no good in 10 bit? + {0x33DA, 0x0000}, // COMPANDING + {0x318E, 0x0200}, // PRE_HDR_GAIN_EN + + // DLO Settings + {0x3100, 0x4000}, // DLO_CONTROL0 + {0x3280, 0x0CCC}, // T1 G1 + {0x3282, 0x0CCC}, // T1 R + {0x3284, 0x0CCC}, // T1 B + {0x3286, 0x0CCC}, // T1 G2 + {0x3288, 0x0FA0}, // T2 G1 + {0x328A, 0x0FA0}, // T2 R + {0x328C, 0x0FA0}, // T2 B + {0x328E, 0x0FA0}, // T2 G2 + + // Initial Gains + {0x3022, 0x0001}, // GROUPED_PARAMETER_HOLD_ + {0x3366, 0xFF77}, // ANALOG_GAIN (1x) (A) + {0x3368, 0xFF77}, // ANALOG_GAIN (1x) (B) + + {0x3060, 0x3333}, // ANALOG_COLOR_GAIN + + {0x3362, 0x0000}, // DC GAIN (A & B) + + {0x305A, 0x00F8}, // red gain (A) + {0x3058, 0x0122}, // blue gain (A) + {0x3056, 0x009A}, // g1 gain (A) + {0x305C, 0x009A}, // g2 gain (A) + + {0x30C0, 0x00F8}, // red gain (B) + {0x30BE, 0x0122}, // blue gain (B) + {0x30BC, 0x009A}, // g1 gain (B) + {0x30C2, 0x009A}, // g2 gain (B) + + {0x3022, 0x0000}, // GROUPED_PARAMETER_HOLD_ + + // Initial Integration Time + {0x3012, 0x0005}, // (A) + {0x3016, 0x0005}, // (B) +}; diff --git a/selfdrive/camerad/cameras/sensor_i2c.h b/selfdrive/camerad/cameras/sensor_i2c.h new file mode 100644 index 00000000000000..b46ebb370a9c57 --- /dev/null +++ b/selfdrive/camerad/cameras/sensor_i2c.h @@ -0,0 +1,651 @@ +static struct msm_camera_i2c_reg_array init_array_imx298[] = { + {0x101,0x0,0}, // IMAGE_ORIENT + {0x601,0x0,0}, // test pattern + //{0xb02,0,0}, // green correction? + // external clock setting + {0x136,0x18,0}, {0x137,0x0,0}, // EXCK_FREQ = Extclk_frequency_mhz + // global setting? + {0x30f4,0x1,0}, + {0x30f5,0x7a,0}, + {0x30f6,0x0,0}, + {0x30f7,0xec,0}, + {0x30fc,0x1,0}, + {0x3101,0x1,0}, + {0x5b2f,0x8,0}, + {0x5d32,0x5,0}, + {0x5d7c,0x0,0}, + {0x5d7d,0x0,0}, + {0x5db9,0x1,0}, + {0x5e43,0x0,0}, + {0x6300,0x0,0}, + {0x6301,0xea,0}, + {0x6302,0x0,0}, + {0x6303,0xb4,0}, + {0x6564,0x0,0}, + {0x6565,0xb6,0}, + {0x6566,0x0,0}, + {0x6567,0xe6,0}, + {0x6714,0x1,0}, + {0x6758,0xb,0}, + {0x6910,0x4,0}, + {0x6916,0x1,0}, + {0x6918,0x4,0}, + {0x691e,0x1,0}, + {0x6931,0x1,0}, + {0x6937,0x2,0}, + {0x693b,0x2,0}, + {0x6d00,0x4a,0}, + {0x6d01,0x41,0}, + {0x6d02,0x23,0}, + {0x6d05,0x4c,0}, + {0x6d06,0x10,0}, + {0x6d08,0x30,0}, + {0x6d09,0x38,0}, + {0x6d0a,0x2c,0}, + {0x6d0b,0x2d,0}, + {0x6d0c,0x34,0}, + {0x6d0d,0x42,0}, + {0x6d19,0x1c,0}, + {0x6d1a,0x71,0}, + {0x6d1b,0xc6,0}, + {0x6d1c,0x94,0}, + {0x6d24,0xe4,0}, + {0x6d30,0xa,0}, + {0x6d31,0x1,0}, + {0x6d33,0xb,0}, + {0x6d34,0x5,0}, + {0x6d35,0x0,0}, + {0x83c2,0x3,0}, + {0x83c3,0x8,0}, + {0x83c4,0x48,0}, + {0x83c7,0x8,0}, + {0x83cb,0x0,0}, + {0xb101,0xff,0}, + {0xb103,0xff,0}, + {0xb105,0xff,0}, + {0xb107,0xff,0}, + {0xb109,0xff,0}, + {0xb10b,0xff,0}, + {0xb10d,0xff,0}, + {0xb10f,0xff,0}, + {0xb111,0xff,0}, + {0xb163,0x3c,0}, + {0xc2a0,0x8,0}, + {0xc2a3,0x3,0}, + {0xc2a5,0x8,0}, + {0xc2a6,0x48,0}, + {0xc2a9,0x0,0}, + {0xf800,0x5e,0}, + {0xf801,0x5e,0}, + {0xf802,0xcd,0}, + {0xf803,0x20,0}, + {0xf804,0x55,0}, + {0xf805,0xd4,0}, + {0xf806,0x1f,0}, + {0xf808,0xf8,0}, + {0xf809,0x3a,0}, + {0xf80a,0xf1,0}, + {0xf80b,0x7e,0}, + {0xf80c,0x55,0}, + {0xf80d,0x38,0}, + {0xf80e,0xe3,0}, + {0xf810,0x74,0}, + {0xf811,0x41,0}, + {0xf812,0xbf,0}, + {0xf844,0x40,0}, + {0xf845,0xba,0}, + {0xf846,0x70,0}, + {0xf847,0x47,0}, + {0xf848,0xc0,0}, + {0xf849,0xba,0}, + {0xf84a,0x70,0}, + {0xf84b,0x47,0}, + {0xf84c,0x82,0}, + {0xf84d,0xf6,0}, + {0xf84e,0x32,0}, + {0xf84f,0xfd,0}, + {0xf851,0xf0,0}, + {0xf852,0x2,0}, + {0xf853,0xf8,0}, + {0xf854,0x81,0}, + {0xf855,0xf6,0}, + {0xf856,0xc0,0}, + {0xf857,0xff,0}, + {0xf858,0x10,0}, + {0xf859,0xb5,0}, + {0xf85a,0xd,0}, + {0xf85b,0x48,0}, + {0xf85c,0x40,0}, + {0xf85d,0x7a,0}, + {0xf85e,0x1,0}, + {0xf85f,0x28,0}, + {0xf860,0x15,0}, + {0xf861,0xd1,0}, + {0xf862,0xc,0}, + {0xf863,0x49,0}, + {0xf864,0xc,0}, + {0xf865,0x46,0}, + {0xf866,0x40,0}, + {0xf867,0x3c,0}, + {0xf868,0x48,0}, + {0xf869,0x8a,0}, + {0xf86a,0x62,0}, + {0xf86b,0x8a,0}, + {0xf86c,0x80,0}, + {0xf86d,0x1a,0}, + {0xf86e,0x8a,0}, + {0xf86f,0x89,0}, + {0xf871,0xb2,0}, + {0xf872,0x10,0}, + {0xf873,0x18,0}, + {0xf874,0xa,0}, + {0xf875,0x46,0}, + {0xf876,0x20,0}, + {0xf877,0x32,0}, + {0xf878,0x12,0}, + {0xf879,0x88,0}, + {0xf87a,0x90,0}, + {0xf87b,0x42,0}, + {0xf87d,0xda,0}, + {0xf87e,0x10,0}, + {0xf87f,0x46,0}, + {0xf880,0x80,0}, + {0xf881,0xb2,0}, + {0xf882,0x88,0}, + {0xf883,0x81,0}, + {0xf884,0x84,0}, + {0xf885,0xf6,0}, + {0xf886,0xd2,0}, + {0xf887,0xf9,0}, + {0xf888,0xe0,0}, + {0xf889,0x67,0}, + {0xf88a,0x85,0}, + {0xf88b,0xf6,0}, + {0xf88c,0xa1,0}, + {0xf88d,0xfc,0}, + {0xf88e,0x10,0}, + {0xf88f,0xbd,0}, + {0xf891,0x18,0}, + {0xf892,0x21,0}, + {0xf893,0x24,0}, + {0xf895,0x18,0}, + {0xf896,0x19,0}, + {0xf897,0xb4,0}, + {0x4e29,0x1,0}, + // PDAF stuff + {0x3166,0x1,0}, //AREA_EN_0 + {0x3167,0x1,0}, + {0x3168,0x1,0}, + {0x3169,0x1,0}, + {0x316a,0x1,0}, + {0x316b,0x1,0}, + {0x316c,0x1,0}, + {0x316d,0x1,0}, + {0x3158,0x2,0}, + {0x3159,0x2,0}, + {0x315a,0x2,0}, + {0x315b,0x3,0}, + {0x3013,0x7,0}, //RMSC_NR_MODE + {0x3035,0x1,0}, + {0x3051,0x0,0}, + {0x3056,0x2,0}, + {0x3057,0x1,0}, + {0x3060,0x0,0}, + {0x8435,0x0,0}, + {0x8455,0x0,0}, + {0x847c,0x0,0}, + {0x84fb,0x1,0}, + {0x9619,0xa0,0}, + {0x961b,0xa0,0}, + {0x961d,0xa0,0}, + {0x961f,0x20,0}, + {0x9621,0x20,0}, + {0x9623,0x20,0}, + {0x9625,0xa0,0}, + {0x9627,0xa0,0}, + {0x9629,0xa0,0}, + {0x962b,0x20,0}, + {0x962d,0x20,0}, + {0x962f,0x20,0}, + {0x9901,0x35,0}, + {0x9903,0x23,0}, + {0x9905,0x23,0}, + {0x9906,0x0,0}, + {0x9907,0x31,0}, + {0x9908,0x0,0}, + {0x9909,0x1b,0}, + {0x990a,0x0,0}, + {0x990b,0x15,0}, + {0x990d,0x3f,0}, + {0x990f,0x3f,0}, + {0x9911,0x3f,0}, + {0x9913,0x64,0}, + {0x9915,0x64,0}, + {0x9917,0x64,0}, + {0x9919,0x50,0}, + {0x991b,0x60,0}, + {0x991d,0x65,0}, + {0x991f,0x1,0}, + {0x9921,0x1,0}, + {0x9923,0x1,0}, + {0x9925,0x23,0}, + {0x9927,0x23,0}, + {0x9929,0x23,0}, + {0x992b,0x2f,0}, + {0x992d,0x1a,0}, + {0x992f,0x14,0}, + {0x9931,0x3f,0}, + {0x9933,0x3f,0}, + {0x9935,0x3f,0}, + {0x9937,0x6b,0}, + {0x9939,0x7c,0}, + {0x993b,0x81,0}, + {0x9943,0xf,0}, + {0x9945,0xf,0}, + {0x9947,0xf,0}, + {0x9949,0xf,0}, + {0x994b,0xf,0}, + {0x994d,0xf,0}, + {0x994f,0x42,0}, + {0x9951,0xf,0}, + {0x9953,0xb,0}, + {0x9955,0x5a,0}, + {0x9957,0x13,0}, + {0x9959,0xc,0}, + {0x995a,0x0,0}, + {0x995b,0x0,0}, + {0x995c,0x0,0}, + {0x996b,0x0,0}, + {0x996d,0x10,0}, + {0x996f,0x10,0}, + {0x9971,0xc8,0}, + {0x9973,0x32,0}, + {0x9975,0x4,0}, + {0x9976,0xa,0}, + {0x9977,0xa,0}, + {0x9978,0xa,0}, + {0x99a4,0x2f,0}, + {0x99a5,0x2f,0}, + {0x99a6,0x2f,0}, + {0x99a7,0xa,0}, + {0x99a8,0xa,0}, + {0x99a9,0xa,0}, + {0x99aa,0x2f,0}, + {0x99ab,0x2f,0}, + {0x99ac,0x2f,0}, + {0x99ad,0x0,0}, + {0x99ae,0x0,0}, + {0x99af,0x0,0}, + {0x99b0,0x40,0}, + {0x99b1,0x40,0}, + {0x99b2,0x40,0}, + {0x99b3,0x30,0}, + {0x99b4,0x30,0}, + {0x99b5,0x30,0}, + {0x99bb,0xa,0}, + {0x99bd,0xa,0}, + {0x99bf,0xa,0}, + {0x99c0,0x9,0}, + {0x99c1,0x9,0}, + {0x99c2,0x9,0}, + {0x99c6,0x3c,0}, + {0x99c7,0x3c,0}, + {0x99c8,0x3c,0}, + {0x99c9,0xff,0}, + {0x99ca,0xff,0}, + {0x99cb,0xff,0}, + {0x9b01,0x35,0}, + {0x9b03,0x14,0}, + {0x9b05,0x14,0}, + {0x9b07,0x31,0}, + {0x9b09,0x1b,0}, + {0x9b0b,0x15,0}, + {0x9b0d,0x1e,0}, + {0x9b0f,0x1e,0}, + {0x9b11,0x1e,0}, + {0x9b13,0x64,0}, + {0x9b15,0x64,0}, + {0x9b17,0x64,0}, + {0x9b19,0x50,0}, + {0x9b1b,0x60,0}, + {0x9b1d,0x65,0}, + {0x9b1f,0x1,0}, + {0x9b21,0x1,0}, + {0x9b23,0x1,0}, + {0x9b25,0x14,0}, + {0x9b27,0x14,0}, + {0x9b29,0x14,0}, + {0x9b2b,0x2f,0}, + {0x9b2d,0x1a,0}, + {0x9b2f,0x14,0}, + {0x9b31,0x1e,0}, + {0x9b33,0x1e,0}, + {0x9b35,0x1e,0}, + {0x9b37,0x6b,0}, + {0x9b39,0x7c,0}, + {0x9b3b,0x81,0}, + {0x9b43,0xf,0}, + {0x9b45,0xf,0}, + {0x9b47,0xf,0}, + {0x9b49,0xf,0}, + {0x9b4b,0xf,0}, + {0x9b4d,0xf,0}, + {0x9b4f,0x2d,0}, + {0x9b51,0xb,0}, + {0x9b53,0x8,0}, + {0x9b55,0x40,0}, + {0x9b57,0xd,0}, + {0x9b59,0x8,0}, + {0x9b5a,0x0,0}, + {0x9b5b,0x0,0}, + {0x9b5c,0x0,0}, + {0x9b6b,0x0,0}, + {0x9b6d,0x10,0}, + {0x9b6f,0x10,0}, + {0x9b71,0xc8,0}, + {0x9b73,0x32,0}, + {0x9b75,0x4,0}, + {0x9bb0,0x40,0}, + {0x9bb1,0x40,0}, + {0x9bb2,0x40,0}, + {0x9bb3,0x30,0}, + {0x9bb4,0x30,0}, + {0x9bb5,0x30,0}, + {0x9bbb,0xa,0}, + {0x9bbd,0xa,0}, + {0x9bbf,0xa,0}, + {0x9bc0,0x9,0}, + {0x9bc1,0x9,0}, + {0x9bc2,0x9,0}, + {0x9bc6,0x18,0}, + {0x9bc7,0x18,0}, + {0x9bc8,0x18,0}, + {0x9bc9,0xff,0}, + {0x9bca,0xff,0}, + {0x9bcb,0xff,0}, + {0xb2b2,0x1,0}, +}; + +static struct msm_camera_i2c_reg_array mode_setting_array_imx298[] = { +// i2c settings for mode 3 +// { +// .x_output = 2328, +// .y_output = 1748, +// .line_length_pclk = 5536, +// .frame_length_lines = 1802, +// .vt_pixel_clk = 299300000, +// .op_pixel_clk = 299300000, +// .binning_factor = 2, +// .min_fps = 15.000000, +// .max_fps = 30.020000, +// .mode = 1, +// .offset_x = 0, +// .offset_y = 0, +// .scale_factor = 1.000000, +// .is_pdaf_supported = 1, +// } + +// mode settings + +// hdr settings +{0x0114, 0x03, 0}, // CSI_LANE_MODE = 4-lane +/*{0x0220, 0x00, 0}, // HDR_MODE = disable +{0x0221, 0x11, 0}, // HDR_RESO_REDU_H/V = Full Pixel +{0x0222, 0x10, 0}, // EXPO_RATIO = 16*/ +{0x0220, 0x01, 0}, // HDR_MODE = enable with combined gain and 16x ratio +{0x0221, 0x22, 0}, // HDR_RESO_REDU_H/V = 2 binning +{0x0222, 0x10, 0}, // EXPO_RATIO = 16 + +{0x0340, 0x07, 0}, {0x0341, 0x0a, 0}, // FRM_LENGTH = frame_length_lines = 1802 +{0x0342, 0x15, 0}, {0x0343, 0xa0, 0}, // LINE_LENGTH = line_length_pclk = 5536 +{0x0344, 0x00, 0}, {0x0345, 0x00, 0}, // x_addr_start +{0x0346, 0x00, 0}, {0x0347, 0x00, 0}, // y_addr_start +{0x0348, 0x12, 0}, {0x0349, 0x2f, 0}, // x_addr_end +{0x034a, 0x0d, 0}, {0x034b, 0xa7, 0}, // y_addr_end +{0x0381, 0x01, 0}, // x_even_inc +{0x0383, 0x01, 0}, // x_odd_inc +{0x0385, 0x01, 0}, // y_even_inc +{0x0387, 0x01, 0}, // y_odd_inc +{0x0900, 0x01, 0}, // BINNING_MODE = enable +{0x0901, 0x22, 0}, // BINING_TYPE_H/V = 2binning +{0x0902, 0x00, 0}, // binning_weighting = average + +{0x0b06, 1, 0}, // SING_DEF_CORR_EN +{0x0b0a, 1, 0}, // combined defect correct + +{0x3010, 0x66, 0}, // HDR_OUTPUT_CTRL = ATR + HDR compose + DPC1D + DCP2D +{0x3011, 0x01, 0}, // HDR_OUTPUT_CTRL2 = PD enable +{0x30c0, 0x11, 0}, // RED_GAIN_CB? +{0x300d, 0x00, 0}, // FORCE_FDSUM = disable +{0x30fd, 0x00, 0}, +{0x8493, 0x00, 0}, +{0x8863, 0x00, 0}, +{0x90d7, 0x19, 0}, + +// set black level +{0x3090, 1, 0}, +{0x3092, 0, 0}, +{0x3093, 0x38, 0}, + +// output size settings +{0x0112, 0x0a, 0}, {0x0113, 0x0a, 0}, // CS_DT_FMT_H = 0x0a0a (RAW10 output) +{0x034c, 0x09, 0}, {0x034d, 0x18, 0}, // X_OUT_SIZE = 2328 (1164*2) +{0x034e, 0x06, 0}, {0x034f, 0xd4, 0}, // Y_OUT_SIZE = 1748 (874*2) +{0x0401, 0x00, 0}, // SCALING_MODE +{0x0404, 0x00, 0}, {0x0405, 0x10, 0}, // SCALE_M +{0x0408, 0x00, 0}, {0x0409, 0x00, 0}, // DCROP_XOFS +{0x040a, 0x00, 0}, {0x040b, 0x00, 0}, // DCROP_YOFS +{0x040c, 0x09, 0}, {0x040d, 0x18, 0}, // DCROP_WIDTH +{0x040e, 0x06, 0}, {0x040f, 0xd4, 0}, // DCROP_HIGT + +// clock settings +// 299300000 +/* +{0x0301, 0x05, 0}, // VT_PIX_CLK_DIV +{0x0303, 0x02, 0}, // VT_SYS_CLK_DIV +{0x0305, 0x04, 0}, // PRE_PLL_CLK_DIV +{0x0306, 0x00, 0}, {0x0307, 0x7d, 0}, // PLL_MULTIPLIER . mode 1: 0xf6 +{0x0309, 0x0a, 0}, // OP_PIX_CLK_DIV +{0x030b, 0x01, 0}, // OP_SYS_CLK_DIV +{0x030d, 0x0f, 0}, // PREPLLCK_OP_DIV +{0x030e, 0x03, 0}, {0x030f, 0x41, 0}, // PLL_OP_MPY +{0x0310, 0x00, 0}, // PLL_MULT_DRIV +*/ +// 600000000 +{0x0301, 0x05, 0}, +{0x0303, 0x02, 0}, +{0x0305, 0x04, 0}, +{0x0306, 0x00, 0}, +{0x0307, 0xfa, 0}, +{0x0309, 0x0a, 0}, +{0x030b, 0x01, 0}, +{0x030d, 0x0f, 0}, +{0x030e, 0x03, 0}, {0x030f, 0x41, 0}, +{0x0310, 0x00, 0}, + +// data rate settings +/*{0x0820, 0x0b, 0}, // requested_link_bit_rate_mbps = 3000 +{0x0821, 0xb8, 0}, +{0x0822, 0x00, 0}, +{0x0823, 0x00, 0},*/ +{0x0820, 0x17, 0}, // requested_link_bit_rate_mbps = 6000 +{0x0821, 0x70, 0}, +{0x0822, 0x00, 0}, +{0x0823, 0x00, 0}, + +//integration time settings +{0x0202, 0x07, 0}, {0x0203, 0x00, 0}, // INTEG_TIME = 1792 +{0x0224, 0x01, 0}, {0x0225, 0xf4, 0}, // ST_COARSE_INTEG_TIME = 506 + +// gain settings +{0x0204, 0x00, 0}, {0x0205, 0x00, 0}, // ANA_GAIN_GLOBAL = 512 / (512 - X) +{0x0216, 0x00, 0}, {0x0217, 0x00, 0}, // ST_ANA_GAIN_GLOBAL[8] +{0x020e, 0x01, 0}, {0x020f, 0x00, 0}, // DIG_GAIN_GR +{0x0210, 0x01, 0}, {0x0211, 0x00, 0}, // DIG_GAIN_R +{0x0212, 0x01, 0}, {0x0213, 0x00, 0}, // DIG_GAIN_B +{0x0214, 0x01, 0}, {0x0215, 0x00, 0}, // DIG_GAIN_GB + +// HDR white balance settings (ABS_GAIN) +{0xb8e, 0x01, 0}, {0xb8f, 0x00, 0}, // GR +{0xb90, 0x02, 0}, {0xb91, 0x2b, 0}, // R +{0xb92, 0x01, 0}, {0xb93, 0xd4, 0}, // B +{0xb94, 0x01, 0}, {0xb95, 0x00, 0}, // GB + +// phase detection settings +{0x3058, 0x00, 0}, // NML_NR_EN +{0x3103, 0x01, 0}, // NML_PD_CAL_ENABLE = enable +{0x3108, 0x00, 0}, {0x3109, 0x2c, 0}, //PD_AREA_X_OFFSET +{0x310a, 0x00, 0}, {0x310b, 0x24, 0}, //PD_AREA_Y_OFFSET +{0x310c, 0x01, 0}, {0x310d, 0xa4, 0}, //PD_AREA_WIDTH +{0x310e, 0x01, 0}, {0x310f, 0xa4, 0}, //PD_AREA_HEIGHT +// whole size is 0x918 x 0x6d4 +{0x3110, 0x03, 0}, // PD_AREA_0 = 0x375-0x4d1, 0x258-0x3b6 +{0x3111, 0x75, 0}, +{0x3112, 0x02, 0}, +{0x3113, 0x58, 0}, +{0x3114, 0x04, 0}, +{0x3115, 0xd1, 0}, +{0x3116, 0x03, 0}, +{0x3117, 0xb6, 0}, +{0x3118, 0x04, 0}, // PD_AREA_1 = 0x446-0x5a2, 0x258-0x3b6 +{0x3119, 0x46, 0}, +{0x311a, 0x02, 0}, +{0x311b, 0x58, 0}, +{0x311c, 0x05, 0}, +{0x311d, 0xa2, 0}, +{0x311e, 0x03, 0}, +{0x311f, 0xb6, 0}, +{0x3120, 0x03, 0}, // PD_AREA_2 = 0x375-0x4d1, 0x32a-0x488 +{0x3121, 0x75, 0}, +{0x3122, 0x03, 0}, +{0x3123, 0x2a, 0}, +{0x3124, 0x04, 0}, +{0x3125, 0xd1, 0}, +{0x3126, 0x04, 0}, +{0x3127, 0x88, 0}, +{0x3128, 0x04, 0}, // PD_AREA_3 = 0x446-0x5a2, 0x32a-0x488 +{0x3129, 0x46, 0}, +{0x312a, 0x03, 0}, +{0x312b, 0x2a, 0}, +{0x312c, 0x05, 0}, +{0x312d, 0xa2, 0}, +{0x312e, 0x04, 0}, +{0x312f, 0x88, 0}, +{0x3130, 0x03, 0}, // PD_AREA_4 = 0x375-0x5a2, 0x258-0x488 +{0x3131, 0x75, 0}, +{0x3132, 0x02, 0}, +{0x3133, 0x58, 0}, +{0x3134, 0x05, 0}, +{0x3135, 0xa2, 0}, +{0x3136, 0x04, 0}, +{0x3137, 0x88, 0}, +{0x3138, 0x02, 0}, // PD_AREA_5 = 0x2ba-0x65d, 0x210-0x4d0 +{0x3139, 0xba, 0}, +{0x313a, 0x02, 0}, +{0x313b, 0x10, 0}, +{0x313c, 0x06, 0}, +{0x313d, 0x5d, 0}, +{0x313e, 0x04, 0}, +{0x313f, 0xd0, 0}, +{0x3140, 0x00, 0}, // PD_AREA_6 = 0xa1-0x876, 0x6b-0x676 +{0x3141, 0xa1, 0}, +{0x3142, 0x00, 0}, +{0x3143, 0x6b, 0}, +{0x3144, 0x08, 0}, +{0x3145, 0x76, 0}, +{0x3146, 0x06, 0}, +{0x3147, 0x76, 0}, +{0x3148, 0x00, 0}, // PD_AREA_7 = 0xa1-0x876, 0x5e-0x34c +{0x3149, 0xa1, 0}, +{0x314a, 0x00, 0}, +{0x314b, 0x5e, 0}, +{0x314c, 0x08, 0}, +{0x314d, 0x76, 0}, +{0x314e, 0x03, 0}, +{0x314f, 0x4c, 0}, +{0x3165, 0x02, 0}, // AREA_EN_0 = free area +}; + +// static struct msm_camera_i2c_reg_array reg_array3[] = { +// // REG_HOLD ON +// {0x104,0x1,0}, +// // from regression +// {0x3002,0x0,0}, +// // FRM_LENGTH, 1802 vs 3554 +// // {0x340,0x7,0}, {0x341,0xa,0}, // camera start {0x340,0xd,0}, {0x341,0xe2,0}, +// // INTEG_TIME aka coarse_int_time_addr aka shutter speed +// {0x202,0x03,0}, {0x203,0xda,0}, +// // global_gain_addr +// {0x204,0x0,0}, {0x205,0x0,0}, + +// //?? +// {0x20e,0x1,0}, {0x20f,0x0,0}, +// {0x210,0x1,0}, {0x211,0x0,0}, +// {0x212,0x1,0}, {0x213,0x0,0}, +// {0x214,0x1,0}, {0x215,0x0,0}, + +// // REG_HOLD: mode setting +// {0x104,0x0,0}, +// }; + +// start, remove standby mode +static struct msm_camera_i2c_reg_array start_reg_array[] = {{0x100,0x1,0}}; + +// stop, enable standby mode +static struct msm_camera_i2c_reg_array stop_reg_array[] = {{0x100,0x0,0}}; + +/* +// still mode settings: + {0x847f, 0x0c0c,}, //_M_EQCTL + + {0x8436, 0xfd7f,}, //_M_Kgxdr + {0x8440, 0xf07f,}, //_M_X_LMT + {0x8443, 0xb41e,}, //_M_X_TGT + {0x841b, 0x4001,}, //_M_Kgx10 + + {0x84b6, 0xfd7f,}, //_M_Kgydr + {0x84c0, 0xf07f,}, //_M_Y_LMT + {0x84c3, 0xb41e,}, //_M_Y_TGT + {0x849b, 0x4001,}, //_M_Kgy10 + + {0x8438, 0x2d0f,}, //_M_Kgx11 + {0x84b8, 0x2d0f,}, //_M_Kgy11 + {0x8447, 0x002b,}, //_M_KgxTG + {0x84c7, 0x002b,}, //_M_KgyTG + + {0x847f, 0x0d0d,}, //_M_EQCTL +*/ + +static struct msm_camera_i2c_reg_array init_array_ov8865[] = { +// round 1 +//{0x103,0x1,0}, // software reset +{0x100,0x0,0}, // standby on +{0x3638,0xff,0}, +{0x302,0x1e,0}, {0x303,0x0,0}, {0x304,0x3,0}, {0x30d,0x1e,0}, {0x30e,0x0,0}, {0x30f,0x9,0}, {0x312,0x1,0}, {0x31e,0xc,0}, // PLL control +{0x3015,0x1,0}, {0x3018,0x72,0}, {0x3020,0x93,0}, {0x3022,0x1,0}, +{0x3031,0xa,0}, // 10-bit mode +{0x3106,0x1,0}, {0x3305,0xf1,0}, {0x3308,0x0,0}, {0x3309,0x28,0}, {0x330a,0x0,0}, {0x330b,0x20,0}, {0x330c,0x0,0}, {0x330d,0x0,0}, {0x330e,0x0,0}, {0x330f,0x40,0}, {0x3307,0x4,0}, {0x3604,0x4,0}, {0x3602,0x30,0}, {0x3605,0x0,0}, {0x3607,0x20,0}, {0x3608,0x11,0}, {0x3609,0x68,0}, {0x360a,0x40,0}, {0x360c,0xdd,0}, {0x360e,0xc,0}, {0x3610,0x7,0}, {0x3612,0x86,0}, {0x3613,0x58,0}, {0x3614,0x28,0}, {0x3617,0x40,0}, {0x3618,0x5a,0}, {0x3619,0x9b,0}, {0x361c,0x0,0}, {0x361d,0x60,0}, {0x3631,0x60,0}, {0x3633,0x10,0}, {0x3634,0x10,0}, {0x3635,0x10,0}, {0x3636,0x10,0}, {0x3641,0x55,0}, {0x3646,0x86,0}, {0x3647,0x27,0}, {0x364a,0x1b,0}, {0x3500,0x0,0}, {0x3501,0x4c,0}, {0x3502,0x0,0}, {0x3503,0x0,0}, {0x3508,0x2,0}, +{0x3509,0x0,0}, // AEC GAIN +{0x3700,0x24,0}, {0x3701,0xc,0}, {0x3702,0x28,0}, {0x3703,0x19,0}, {0x3704,0x14,0}, {0x3705,0x0,0}, {0x3706,0x38,0}, {0x3707,0x4,0}, {0x3708,0x24,0}, {0x3709,0x40,0}, {0x370a,0x0,0}, {0x370b,0xb8,0}, {0x370c,0x4,0}, {0x3718,0x12,0}, {0x3719,0x31,0}, {0x3712,0x42,0}, {0x3714,0x12,0}, {0x371e,0x19,0}, {0x371f,0x40,0}, {0x3720,0x5,0}, {0x3721,0x5,0}, {0x3724,0x2,0}, {0x3725,0x2,0}, {0x3726,0x6,0}, {0x3728,0x5,0}, {0x3729,0x2,0}, {0x372a,0x3,0}, {0x372b,0x53,0}, {0x372c,0xa3,0}, {0x372d,0x53,0}, {0x372e,0x6,0}, {0x372f,0x10,0}, {0x3730,0x1,0}, {0x3731,0x6,0}, {0x3732,0x14,0}, {0x3733,0x10,0}, {0x3734,0x40,0}, {0x3736,0x20,0}, {0x373a,0x2,0}, {0x373b,0xc,0}, {0x373c,0xa,0}, {0x373e,0x3,0}, {0x3755,0x40,0}, {0x3758,0x0,0}, {0x3759,0x4c,0}, {0x375a,0x6,0}, {0x375b,0x13,0}, {0x375c,0x40,0}, {0x375d,0x2,0}, {0x375e,0x0,0}, {0x375f,0x14,0}, {0x3767,0x1c,0}, {0x3768,0x4,0}, {0x3769,0x20,0}, {0x376c,0xc0,0}, {0x376d,0xc0,0}, {0x376a,0x8,0}, {0x3761,0x0,0}, {0x3762,0x0,0}, {0x3763,0x0,0}, {0x3766,0xff,0}, {0x376b,0x42,0}, {0x3772,0x23,0}, {0x3773,0x2,0}, {0x3774,0x16,0}, {0x3775,0x12,0}, {0x3776,0x8,0}, {0x37a0,0x44,0}, {0x37a1,0x3d,0}, {0x37a2,0x3d,0}, {0x37a3,0x1,0}, {0x37a4,0x0,0}, {0x37a5,0x8,0}, {0x37a6,0x0,0}, {0x37a7,0x44,0}, {0x37a8,0x58,0}, {0x37a9,0x58,0}, {0x3760,0x0,0}, {0x376f,0x1,0}, {0x37aa,0x44,0}, {0x37ab,0x2e,0}, {0x37ac,0x2e,0}, {0x37ad,0x33,0}, {0x37ae,0xd,0}, {0x37af,0xd,0}, {0x37b0,0x0,0}, {0x37b1,0x0,0}, {0x37b2,0x0,0}, {0x37b3,0x42,0}, {0x37b4,0x42,0}, {0x37b5,0x33,0}, {0x37b6,0x0,0}, {0x37b7,0x0,0}, {0x37b8,0x0,0}, {0x37b9,0xff,0}, {0x3800,0x0,0}, {0x3801,0xc,0}, {0x3802,0x0,0}, {0x3803,0xc,0}, +{0x3804,0xc,0}, {0x3805,0xd3,0}, // 3283 +{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,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 +{0x3821,0x40,0}, // format2 +{0x382a,0x3,0}, {0x382b,0x1,0}, // V-binning +{0x382d,0x7f,0}, {0x3830,0x8,0}, {0x3836,0x2,0}, {0x3837,0x18,0}, +{0x3841,0xff,0}, +{0x3846,0x88,0}, {0x3d85,0x6,0}, {0x3d8c,0x75,0}, {0x3d8d,0xef,0}, {0x3f08,0xb,0}, {0x4000,0xf1,0}, {0x4001,0x14,0}, {0x4005,0x10,0}, {0x4006,0x1,0}, {0x4007,0x1,0}, {0x400b,0xc,0}, {0x400d,0x10,0}, {0x401b,0x0,0}, {0x401d,0x0,0}, {0x4020,0x0,0}, {0x4021,0x0,0}, {0x4022,0x4,0}, {0x4023,0x1f,0}, {0x4024,0x6,0}, {0x4025,0x20,0}, {0x4026,0x6,0}, {0x4027,0x4f,0}, {0x4028,0x0,0}, {0x4029,0x2,0}, {0x402a,0x4,0}, {0x402b,0x4,0}, {0x402c,0x2,0}, {0x402d,0x2,0}, {0x402e,0x8,0}, {0x402f,0x2,0}, {0x401f,0x0,0}, {0x4034,0x3f,0}, {0x4300,0xff,0}, {0x4301,0x0,0}, {0x4302,0xf,0}, {0x4500,0x40,0}, {0x4503,0x10,0}, {0x4601,0x74,0}, {0x481f,0x32,0}, {0x4837,0x15,0}, {0x4850,0x10,0}, {0x4851,0x32,0}, {0x4b00,0x2a,0}, {0x4b0d,0x0,0}, {0x4d00,0x4,0}, {0x4d01,0x18,0}, {0x4d02,0xc3,0}, {0x4d03,0xff,0}, {0x4d04,0xff,0}, {0x4d05,0xff,0}, {0x5000,0x96,0}, {0x5001,0x1,0}, {0x5002,0x8,0}, {0x5901,0x0,0}, +{0x5e00,0x0,0}, +//{0x5e00,0x80,0}, +{0x5e01,0x41,0}, {0x5b00,0x2,0}, {0x5b01,0xd0,0}, {0x5b02,0x3,0}, {0x5b03,0xff,0}, {0x5b05,0x6c,0}, {0x5780,0xfc,0}, {0x5781,0xdf,0}, {0x5782,0x3f,0}, {0x5783,0x8,0}, {0x5784,0xc,0}, {0x5786,0x20,0}, {0x5787,0x40,0}, {0x5788,0x8,0}, {0x5789,0x8,0}, {0x578a,0x2,0}, {0x578b,0x1,0}, {0x578c,0x1,0}, {0x578d,0xc,0}, {0x578e,0x2,0}, {0x578f,0x1,0}, {0x5790,0x1,0}, {0x5800,0x1d,0}, {0x5801,0xe,0}, {0x5802,0xc,0}, {0x5803,0xc,0}, {0x5804,0xf,0}, {0x5805,0x22,0}, {0x5806,0xa,0}, {0x5807,0x6,0}, {0x5808,0x5,0}, {0x5809,0x5,0}, {0x580a,0x7,0}, {0x580b,0xa,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x3,0}, {0x5811,0x7,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x3,0}, {0x5817,0x7,0}, {0x5818,0x9,0}, {0x5819,0x6,0}, {0x581a,0x4,0}, {0x581b,0x4,0}, {0x581c,0x6,0}, {0x581d,0xa,0}, {0x581e,0x19,0}, {0x581f,0xd,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xe,0}, {0x5823,0x22,0}, {0x5824,0x23,0}, {0x5825,0x28,0}, {0x5826,0x29,0}, {0x5827,0x27,0}, {0x5828,0x13,0}, {0x5829,0x26,0}, {0x582a,0x33,0}, {0x582b,0x32,0}, {0x582c,0x33,0}, {0x582d,0x16,0}, {0x582e,0x14,0}, {0x582f,0x30,0}, {0x5830,0x31,0}, {0x5831,0x30,0}, {0x5832,0x15,0}, {0x5833,0x26,0}, {0x5834,0x23,0}, {0x5835,0x21,0}, {0x5836,0x23,0}, {0x5837,0x5,0}, {0x5838,0x36,0}, {0x5839,0x27,0}, {0x583a,0x28,0}, {0x583b,0x26,0}, {0x583c,0x24,0}, {0x583d,0xdf,0}, +//{0x100,0x1,0}, +// round 2 (color calibration) +{0x7010,0x0,0}, {0x7011,0x0,0}, {0x7012,0x0,0}, {0x7013,0x0,0}, {0x7014,0x0,0}, {0x7015,0x0,0}, {0x7016,0x0,0}, {0x7017,0x0,0}, {0x7018,0x0,0}, {0x7019,0x0,0}, {0x701a,0x0,0}, {0x701b,0x0,0}, {0x701c,0x0,0}, {0x701d,0x0,0}, {0x701e,0x0,0}, {0x701f,0x0,0}, {0x7020,0x0,0}, {0x7021,0x0,0}, {0x7022,0x0,0}, {0x7023,0x0,0}, {0x7024,0x0,0}, {0x7025,0x0,0}, {0x7026,0x0,0}, {0x7027,0x0,0}, {0x7028,0x0,0}, {0x7029,0x0,0}, {0x702a,0x0,0}, {0x702b,0x0,0}, {0x702c,0x0,0}, {0x702d,0x0,0}, {0x702e,0x0,0}, {0x702f,0x0,0}, {0x7030,0x0,0}, {0x7031,0x0,0}, {0x7032,0x0,0}, {0x7033,0x0,0}, {0x7034,0x0,0}, {0x7035,0x0,0}, {0x7036,0x0,0}, {0x7037,0x0,0}, {0x7038,0x0,0}, {0x7039,0x0,0}, {0x703a,0x0,0}, {0x703b,0x0,0}, {0x703c,0x0,0}, {0x703d,0x0,0}, {0x703e,0x0,0}, {0x703f,0x0,0}, {0x7040,0x0,0}, {0x7041,0x0,0}, {0x7042,0x0,0}, {0x7043,0x0,0}, {0x7044,0x0,0}, {0x7045,0x0,0}, {0x7046,0x0,0}, {0x7047,0x0,0}, {0x7048,0x0,0}, {0x7049,0x0,0}, {0x704a,0x0,0}, {0x704b,0x0,0}, {0x704c,0x0,0}, {0x704d,0x0,0}, {0x704e,0x0,0}, {0x704f,0x0,0}, {0x7050,0x0,0}, {0x7051,0x0,0}, {0x7052,0x0,0}, {0x7053,0x0,0}, {0x7054,0x0,0}, {0x7055,0x0,0}, {0x7056,0x0,0}, {0x7057,0x0,0}, {0x7058,0x0,0}, {0x7059,0x0,0}, {0x705a,0x0,0}, {0x705b,0x0,0}, {0x705c,0x0,0}, {0x705d,0x0,0}, {0x705e,0x0,0}, {0x705f,0x0,0}, {0x7060,0x0,0}, {0x7061,0x0,0}, {0x7062,0x0,0}, {0x7063,0x0,0}, {0x7064,0x0,0}, {0x7065,0x0,0}, {0x7066,0x0,0}, {0x7067,0x0,0}, {0x7068,0x0,0}, {0x7069,0x0,0}, {0x706a,0x0,0}, {0x706b,0x0,0}, {0x706c,0x0,0}, {0x706d,0x0,0}, {0x706e,0x0,0}, {0x706f,0x0,0}, {0x7070,0x0,0}, {0x7071,0x0,0}, {0x7072,0x0,0}, {0x7073,0x0,0}, {0x7074,0x0,0}, {0x7075,0x0,0}, {0x7076,0x0,0}, {0x7077,0x0,0}, {0x7078,0x0,0}, {0x7079,0x0,0}, {0x707a,0x0,0}, {0x707b,0x0,0}, {0x707c,0x0,0}, {0x707d,0x0,0}, {0x707e,0x0,0}, {0x707f,0x0,0}, {0x7080,0x0,0}, {0x7081,0x0,0}, {0x7082,0x0,0}, {0x7083,0x0,0}, {0x7084,0x0,0}, {0x7085,0x0,0}, {0x7086,0x0,0}, {0x7087,0x0,0}, {0x7088,0x0,0}, {0x7089,0x0,0}, {0x708a,0x0,0}, {0x708b,0x0,0}, {0x708c,0x0,0}, {0x708d,0x0,0}, {0x708e,0x0,0}, {0x708f,0x0,0}, {0x7090,0x0,0}, {0x7091,0x0,0}, {0x7092,0x0,0}, {0x7093,0x0,0}, {0x7094,0x0,0}, {0x7095,0x0,0}, {0x7096,0x0,0}, {0x7097,0x0,0}, {0x7098,0x0,0}, {0x7099,0x0,0}, {0x709a,0x0,0}, {0x709b,0x0,0}, {0x709c,0x0,0}, {0x709d,0x0,0}, {0x709e,0x0,0}, {0x709f,0x0,0}, {0x70a0,0x0,0}, {0x70a1,0x0,0}, {0x70a2,0x0,0}, {0x70a3,0x0,0}, {0x70a4,0x0,0}, {0x70a5,0x0,0}, {0x70a6,0x0,0}, {0x70a7,0x0,0}, {0x70a8,0x0,0}, {0x70a9,0x0,0}, {0x70aa,0x0,0}, {0x70ab,0x0,0}, {0x70ac,0x0,0}, {0x70ad,0x0,0}, {0x70ae,0x0,0}, {0x70af,0x0,0}, {0x70b0,0x0,0}, {0x70b1,0x0,0}, {0x70b2,0x0,0}, {0x70b3,0x0,0}, {0x70b4,0x0,0}, {0x70b5,0x0,0}, {0x70b6,0x0,0}, {0x70b7,0x0,0}, {0x70b8,0x0,0}, {0x70b9,0x0,0}, {0x70ba,0x0,0}, {0x70bb,0x0,0}, {0x70bc,0x0,0}, {0x70bd,0x0,0}, {0x70be,0x0,0}, {0x70bf,0x0,0}, {0x70c0,0x0,0}, {0x70c1,0x0,0}, {0x70c2,0x0,0}, {0x70c3,0x0,0}, {0x70c4,0x0,0}, {0x70c5,0x0,0}, {0x70c6,0x0,0}, {0x70c7,0x0,0}, {0x70c8,0x0,0}, {0x70c9,0x0,0}, {0x70ca,0x0,0}, {0x70cb,0x0,0}, {0x70cc,0x0,0}, {0x70cd,0x0,0}, {0x70ce,0x0,0}, {0x70cf,0x0,0}, {0x70d0,0x0,0}, {0x70d1,0x0,0}, {0x70d2,0x0,0}, {0x70d3,0x0,0}, {0x70d4,0x0,0}, {0x70d5,0x0,0}, {0x70d6,0x0,0}, {0x70d7,0x0,0}, {0x70d8,0x0,0}, {0x70d9,0x0,0}, {0x70da,0x0,0}, {0x70db,0x0,0}, {0x70dc,0x0,0}, {0x70dd,0x0,0}, {0x70de,0x0,0}, {0x70df,0x0,0}, {0x70e0,0x0,0}, {0x70e1,0x0,0}, {0x70e2,0x0,0}, {0x70e3,0x0,0}, {0x70e4,0x0,0}, {0x70e5,0x0,0}, {0x70e6,0x0,0}, {0x70e7,0x0,0}, {0x70e8,0x0,0}, {0x70e9,0x0,0}, {0x70ea,0x0,0}, {0x70eb,0x0,0}, {0x70ec,0x0,0}, {0x70ed,0x0,0}, {0x70ee,0x0,0}, {0x70ef,0x0,0}, {0x70f0,0x0,0}, {0x70f1,0x0,0}, {0x70f2,0x0,0}, {0x70f3,0x0,0}, {0x70f4,0x0,0}, {0x70f5,0x0,0}, {0x70f6,0x0,0}, {0x70f7,0x0,0}, {0x70f8,0x0,0}, {0x70f9,0x0,0}, {0x70fa,0x0,0}, {0x70fb,0x0,0}, {0x70fc,0x0,0}, {0x70fd,0x0,0}, {0x70fe,0x0,0}, {0x70ff,0x0,0}, {0x7100,0x0,0}, {0x7101,0x0,0}, {0x7102,0x0,0}, {0x7103,0x0,0}, {0x7104,0x0,0}, {0x7105,0x0,0}, {0x7106,0x0,0}, {0x7107,0x0,0}, {0x7108,0x0,0}, {0x7109,0x0,0}, {0x710a,0x0,0}, {0x710b,0x0,0}, {0x710c,0x0,0}, {0x710d,0x0,0}, {0x710e,0x0,0}, {0x710f,0x0,0}, {0x7110,0x0,0}, {0x7111,0x0,0}, {0x7112,0x0,0}, {0x7113,0x0,0}, {0x7114,0x0,0}, {0x7115,0x0,0}, {0x7116,0x0,0}, {0x7117,0x0,0}, {0x7118,0x0,0}, {0x7119,0x0,0}, {0x711a,0x0,0}, {0x711b,0x0,0}, {0x711c,0x0,0}, {0x711d,0x0,0}, {0x711e,0x0,0}, {0x711f,0x0,0}, {0x7120,0x0,0}, {0x7121,0x0,0}, {0x7122,0x0,0}, {0x7123,0x0,0}, {0x7124,0x0,0}, {0x7125,0x0,0}, {0x7126,0x0,0}, {0x7127,0x0,0}, {0x7128,0x0,0}, {0x7129,0x0,0}, {0x712a,0x0,0}, {0x712b,0x0,0}, {0x712c,0x0,0}, {0x712d,0x0,0}, {0x712e,0x0,0}, {0x712f,0x0,0}, {0x7130,0x0,0}, {0x7131,0x0,0}, {0x7132,0x0,0}, {0x501a,0x10,0}, {0x501b,0xd,0}, {0x501c,0x10,0}, {0x501d,0x13,0}, {0x5000,0x96,0}, {0x5800,0x14,0}, {0x5801,0xd,0}, {0x5802,0xa,0}, {0x5803,0xa,0}, {0x5804,0xd,0}, {0x5805,0x13,0}, {0x5806,0xa,0}, {0x5807,0x5,0}, {0x5808,0x3,0}, {0x5809,0x3,0}, {0x580a,0x5,0}, {0x580b,0x9,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x2,0}, {0x5811,0x5,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x2,0}, {0x5817,0x5,0}, {0x5818,0xb,0}, {0x5819,0x6,0}, {0x581a,0x3,0}, {0x581b,0x3,0}, {0x581c,0x5,0}, {0x581d,0xa,0}, {0x581e,0x16,0}, {0x581f,0xf,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xf,0}, {0x5823,0x15,0}, {0x5824,0x32,0}, {0x5825,0x23,0}, {0x5826,0x23,0}, {0x5827,0x23,0}, {0x5828,0x22,0}, {0x5829,0x21,0}, {0x582a,0x21,0}, {0x582b,0x22,0}, {0x582c,0x21,0},{0x582d,0x11,0}, {0x582e,0x22,0}, {0x582f,0x31,0}, {0x5830,0x41,0}, {0x5831,0x31,0}, {0x5832,0x1,0}, {0x5833,0x21,0}, {0x5834,0x21,0}, {0x5835,0x21,0}, {0x5836,0x11,0}, {0x5837,0x11,0}, {0x5838,0x22,0}, {0x5839,0x22,0}, {0x583a,0x12,0}, {0x583b,0x22,0}, {0x583c,0x22,0}, {0x583d,0xdf,0}, +}; + 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..a88b8f4bb11d01 --- /dev/null +++ b/selfdrive/camerad/imgproc/utils.cc @@ -0,0 +1,106 @@ +#include "selfdrive/camerad/imgproc/utils.h" + +#include +#include +#include +#include +#include + +const int16_t lapl_conv_krnl[9] = {0, 1, 0, + 1, -4, 1, + 0, 1, 0}; + +// 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]; + 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] - 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); +} + +static 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); +} + +LapConv::LapConv(cl_device_id device_id, cl_context ctx, int rgb_width, int rgb_height, int rgb_stride, int filter_size) + : width(rgb_width / NUM_SEGMENTS_X), height(rgb_height / NUM_SEGMENTS_Y), rgb_stride(rgb_stride), + roi_buf(width * height * 3), result_buf(width * height) { + + prg = build_conv_program(device_id, ctx, width, height, filter_size); + krnl = CL_CHECK_ERR(clCreateKernel(prg, "rgb2gray_conv2d", &err)); + // TODO: Removed CL_MEM_SVM_FINE_GRAIN_BUFFER, confirm it doesn't matter + roi_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, roi_buf.size() * sizeof(roi_buf[0]), NULL, &err)); + result_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, result_buf.size() * sizeof(result_buf[0]), NULL, &err)); + 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)); +} + +LapConv::~LapConv() { + CL_CHECK(clReleaseMemObject(roi_cl)); + CL_CHECK(clReleaseMemObject(result_cl)); + CL_CHECK(clReleaseMemObject(filter_cl)); + CL_CHECK(clReleaseKernel(krnl)); + CL_CHECK(clReleaseProgram(prg)); +} + +uint16_t LapConv::Update(cl_command_queue q, const uint8_t *rgb_buf, const int roi_id) { + // sharpness scores + 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_offset = rgb_buf + y_offset * height * rgb_stride + x_offset * width * 3; + for (int i = 0; i < height; ++i) { + memcpy(&roi_buf[i * width * 3], &rgb_offset[i * rgb_stride], width * 3); + } + + constexpr int local_mem_size = (CONV_LOCAL_WORKSIZE + 2 * (3 / 2)) * (CONV_LOCAL_WORKSIZE + 2 * (3 / 2)) * (3 * sizeof(uint8_t)); + const size_t global_work_size[] = {(size_t)width, (size_t)height}; + const size_t local_work_size[] = {CONV_LOCAL_WORKSIZE, CONV_LOCAL_WORKSIZE}; + + CL_CHECK(clEnqueueWriteBuffer(q, roi_cl, CL_TRUE, 0, roi_buf.size() * sizeof(roi_buf[0]), roi_buf.data(), 0, 0, 0)); + CL_CHECK(clSetKernelArg(krnl, 0, sizeof(cl_mem), (void *)&roi_cl)); + CL_CHECK(clSetKernelArg(krnl, 1, sizeof(cl_mem), (void *)&result_cl)); + CL_CHECK(clSetKernelArg(krnl, 2, sizeof(cl_mem), (void *)&filter_cl)); + CL_CHECK(clSetKernelArg(krnl, 3, local_mem_size, 0)); + cl_event conv_event; + CL_CHECK(clEnqueueNDRangeKernel(q, krnl, 2, NULL, global_work_size, local_work_size, 0, 0, &conv_event)); + CL_CHECK(clWaitForEvents(1, &conv_event)); + CL_CHECK(clReleaseEvent(conv_event)); + CL_CHECK(clEnqueueReadBuffer(q, result_cl, CL_TRUE, 0, + result_buf.size() * sizeof(result_buf[0]), result_buf.data(), 0, 0, 0)); + + return get_lapmap_one(result_buf.data(), width, height); +} diff --git a/selfdrive/camerad/imgproc/utils.h b/selfdrive/camerad/imgproc/utils.h new file mode 100644 index 00000000000000..b735975b3e66f2 --- /dev/null +++ b/selfdrive/camerad/imgproc/utils.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include + +#include "selfdrive/common/clutil.h" + +#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 +#define CONV_LOCAL_WORKSIZE 16 + +class LapConv { +public: + LapConv(cl_device_id device_id, cl_context ctx, int rgb_width, int rgb_height, int rgb_stride, int filter_size); + ~LapConv(); + uint16_t Update(cl_command_queue q, const uint8_t *rgb_buf, const int roi_id); + +private: + cl_mem roi_cl, result_cl, filter_cl; + cl_program prg; + cl_kernel krnl; + const int width, height; + const int rgb_stride; + std::vector roi_buf; + std::vector result_buf; +}; + +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..f06bd341dfa74e --- /dev/null +++ b/selfdrive/camerad/main.cc @@ -0,0 +1,68 @@ +#include +#include +#include + +#include +#include +#include + +#include "libyuv.h" + +#include "cereal/visionipc/visionipc_server.h" +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" + +#ifdef QCOM +#include "selfdrive/camerad/cameras/camera_qcom.h" +#elif QCOM2 +#include "selfdrive/camerad/cameras/camera_qcom2.h" +#elif WEBCAM +#include "selfdrive/camerad/cameras/camera_webcam.h" +#else +#include "selfdrive/camerad/cameras/camera_replay.h" +#endif + +ExitHandler do_exit; + +void party(cl_device_id device_id, cl_context context) { + MultiCameraState cameras = {}; + VisionIpcServer vipc_server("camerad", device_id, context); + + cameras_init(&vipc_server, &cameras, device_id, context); + cameras_open(&cameras); + + vipc_server.start_listener(); + + cameras_run(&cameras); +} + +#ifdef QCOM +#include "CL/cl_ext_qcom.h" +#endif + +int main(int argc, char *argv[]) { + if (!Hardware::PC()) { + int ret; + ret = util::set_realtime_priority(53); + assert(ret == 0); + ret = util::set_core_affinity({Hardware::EON() ? 2 : 6}); + assert(ret == 0 || Params().getBool("IsOffroad")); // failure ok while offroad due to offlining cores + } + + 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/automated/__init__.py b/selfdrive/camerad/snapshot/__init__.py similarity index 100% rename from panda/tests/automated/__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..506064de3d83e9 --- /dev/null +++ b/selfdrive/camerad/snapshot/snapshot.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +import subprocess +import time + +import numpy as np +from PIL import Image +from typing import List + +import cereal.messaging as messaging +from cereal.visionipc.visionipc_pyx import VisionIpcClient, VisionStreamType # pylint: disable=no-name-in-module, import-error +from common.params import Params +from common.realtime import DT_MDL +from selfdrive.hardware import TICI, PC +from selfdrive.controls.lib.alertmanager import set_offroad_alert +from selfdrive.manager.process_config import managed_processes + +LM_THRESH = 120 # defined in selfdrive/camerad/imgproc/utils.h + +VISION_STREAMS = { + "roadCameraState": VisionStreamType.VISION_STREAM_RGB_BACK, + "driverCameraState": VisionStreamType.VISION_STREAM_RGB_FRONT, + "wideRoadCameraState": VisionStreamType.VISION_STREAM_RGB_WIDE, +} + + +def jpeg_write(fn, dat): + img = Image.fromarray(dat) + img.save(fn, "JPEG") + + +def extract_image(buf, w, h, stride): + img = np.hstack([buf[i * stride:i * stride + 3 * w] for i in range(h)]) + b = img[::3].reshape(h, w) + g = img[1::3].reshape(h, w) + r = img[2::3].reshape(h, w) + return np.dstack([r, g, b]) + + +def rois_in_focus(lapres: List[float]) -> float: + return sum(1. / len(lapres) for sharpness in lapres if sharpness >= LM_THRESH) + + +def get_snapshots(frame="roadCameraState", front_frame="driverCameraState", focus_perc_threshold=0.): + sockets = [s for s in (frame, front_frame) if s is not None] + sm = messaging.SubMaster(sockets) + vipc_clients = {s: VisionIpcClient("camerad", VISION_STREAMS[s], True) for s in sockets} + + # wait 4 sec from camerad startup for focus and exposure + while sm[sockets[0]].frameId < int(4. / DT_MDL): + sm.update() + + for client in vipc_clients.values(): + client.connect(True) + + # wait for focus + start_t = time.monotonic() + while time.monotonic() - start_t < 10: + sm.update(100) + if min(sm.rcv_frame.values()) > 1 and rois_in_focus(sm[frame].sharpnessScore) >= focus_perc_threshold: + break + + # grab images + rear, front = None, None + if frame is not None: + c = vipc_clients[frame] + rear = extract_image(c.recv(), c.width, c.height, c.stride) + if front_frame is not None: + c = vipc_clients[front_frame] + front = extract_image(c.recv(), c.width, c.height, c.stride) + return rear, front + + +def snapshot(): + params = Params() + + if (not params.get_bool("IsOffroad")) or params.get_bool("IsTakingSnapshot"): + print("Already taking snapshot") + return None, None + + front_camera_allowed = params.get_bool("RecordFront") + params.put_bool("IsTakingSnapshot", True) + 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 + try: + subprocess.check_call(["pgrep", "camerad"]) + print("Camerad already running") + params.put_bool("IsTakingSnapshot", False) + params.delete("Offroad_IsTakingSnapshot") + return None, None + except subprocess.CalledProcessError: + pass + + try: + # Allow testing on replay on PC + if not PC: + managed_processes['camerad'].start() + + frame = "wideRoadCameraState" if TICI else "roadCameraState" + front_frame = "driverCameraState" if front_camera_allowed else None + focus_perc_threshold = 0. if TICI else 10 / 12. + + rear, front = get_snapshots(frame, front_frame, focus_perc_threshold) + finally: + managed_processes['camerad'].stop() + params.put_bool("IsTakingSnapshot", False) + set_offroad_alert("Offroad_IsTakingSnapshot", False) + + if not front_camera_allowed: + front = None + + return rear, front + + +if __name__ == "__main__": + pic, fpic = snapshot() + if pic is not None: + print(pic.shape) + jpeg_write("/tmp/back.jpg", pic) + if fpic is not None: + jpeg_write("/tmp/front.jpg", fpic) + else: + print("Error taking snapshot") diff --git a/selfdrive/camerad/transforms/rgb_to_yuv.cc b/selfdrive/camerad/transforms/rgb_to_yuv.cc new file mode 100644 index 00000000000000..63e032e2dc15c7 --- /dev/null +++ b/selfdrive/camerad/transforms/rgb_to_yuv.cc @@ -0,0 +1,36 @@ +#include "selfdrive/camerad/transforms/rgb_to_yuv.h" + +#include +#include + +Rgb2Yuv::Rgb2Yuv(cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride) { + assert(width % 2 == 0 && height % 2 == 0); + 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); + krnl = CL_CHECK_ERR(clCreateKernel(prg, "rgb_to_yuv", &err)); + CL_CHECK(clReleaseProgram(prg)); + + work_size[0] = (width + (width % 4 == 0 ? 0 : (4 - width % 4))) / 4; + work_size[1] = (height + (height % 4 == 0 ? 0 : (4 - height % 4))) / 4; +} + +Rgb2Yuv::~Rgb2Yuv() { + CL_CHECK(clReleaseKernel(krnl)); +} + +void Rgb2Yuv::queue(cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl) { + CL_CHECK(clSetKernelArg(krnl, 0, sizeof(cl_mem), &rgb_cl)); + CL_CHECK(clSetKernelArg(krnl, 1, sizeof(cl_mem), &yuv_cl)); + cl_event event; + CL_CHECK(clEnqueueNDRangeKernel(q, 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/camerad/transforms/rgb_to_yuv.h b/selfdrive/camerad/transforms/rgb_to_yuv.h new file mode 100644 index 00000000000000..3bb50669ef0568 --- /dev/null +++ b/selfdrive/camerad/transforms/rgb_to_yuv.h @@ -0,0 +1,14 @@ +#pragma once + +#include "selfdrive/common/clutil.h" + +class Rgb2Yuv { +public: + Rgb2Yuv(cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride); + ~Rgb2Yuv(); + void queue(cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl); +private: + size_t work_size[2]; + cl_kernel krnl; +}; + diff --git a/selfdrive/visiond/transforms/rgb_to_yuv_test.cc b/selfdrive/camerad/transforms/rgb_to_yuv_test.cc similarity index 87% rename from selfdrive/visiond/transforms/rgb_to_yuv_test.cc rename to selfdrive/camerad/transforms/rgb_to_yuv_test.cc index c8b87510586d5e..74db2bc1c2b37c 100644 --- a/selfdrive/visiond/transforms/rgb_to_yuv_test.cc +++ b/selfdrive/camerad/transforms/rgb_to_yuv_test.cc @@ -1,18 +1,19 @@ -#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 #ifdef ANDROID @@ -26,13 +27,11 @@ #endif -#include - #include -#include "clutil.h" -#include "rgb_to_yuv.h" - +#include "libyuv.h" +#include "selfdrive/camerad/transforms/rgb_to_yuv.h" +#include "selfdrive/common/clutil.h" static inline double millis_since_boot() { struct timespec t; @@ -41,16 +40,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 +100,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,19 +134,19 @@ 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)); - for (int i = 0; i < 100; i++){ - for (int i = 0; i < width * height * 3; i++){ + for (int i = 0; i < 100; i++) { + for (int i = 0; i < width * height * 3; i++) { rgb_frame[i] = (uint8_t)rand(); } 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/dbc_out/.gitkeep b/selfdrive/can/dbc_out/.gitkeep deleted file mode 100644 index e69de29bb2d1d6..00000000000000 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 e3225181ba7004..00000000000000 --- a/selfdrive/can/parser.cc +++ /dev/null @@ -1,551 +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 - } - - 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(); - 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); - } - - 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; - } - } - } - - int update(uint64_t sec, bool wait) { - int err; - int result = 0; - - // recv from can - zmq_msg_t msg; - zmq_msg_init(&msg); - - // multiple recv is fine - bool first = wait; - while (1) { - 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; - - // 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); - } - - 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); -} - -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 9d8efa318c8af3..00000000000000 --- a/selfdrive/can/parser_pyx.pxd +++ /dev/null @@ -1,92 +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 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_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 65c6f5ab21bb58..00000000000000 --- a/selfdrive/can/parser_pyx.pyx +++ /dev/null @@ -1,105 +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="127.0.0.1", 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_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(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 e58906d7a0a04b..00000000000000 --- a/selfdrive/can/plant_can_parser.py +++ /dev/null @@ -1,131 +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 - -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) - - 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.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.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 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 87d62244e2b36b..00000000000000 --- a/selfdrive/can/tests/test_packer_honda.py +++ /dev/null @@ -1,57 +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): - 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) - chime = random.randint(0, 65536) - 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, chime, fcw, idx) - m = hondacan.create_brake_command(self.honda_cp, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, chime, fcw, idx) - self.assertEqual(m_old, m) - - apply_steer = (random.randint(0, 2) % 2 == 0) - lkas_active = (random.randint(0, 2) % 2 == 0) - car_fingerprint = HONDA_BOSCH[0] - idx = random.randint(0, 65536) - m_old = hondacan.create_steering_control(self.honda_cp_old, apply_steer, lkas_active, car_fingerprint, idx) - m = hondacan.create_steering_control(self.honda_cp, apply_steer, lkas_active, car_fingerprint, idx) - 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), random.randint(0, 65536), random.randint(0, 65536)) - car_fingerprint = HONDA_BOSCH[0] - 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) - m = hondacan.create_ui_commands(self.honda_cp, pcm_speed, hud, car_fingerprint, is_metric, idx) - 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) - m = hondacan.spam_buttons_command(self.honda_cp, button_val, idx) - 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 42e36f3171d5b5..00000000000000 --- a/selfdrive/can/tests/test_packer_toyota.py +++ /dev/null @@ -1,88 +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) - sound1 = random.randint(1, 65536) - sound2 = random.randint(1, 65536) - 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, sound1, sound2, left_line, right_line, left_lane_depart, right_lane_depart) - m = create_ui_command(self.cp, steer, sound1, sound2, 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) - sound1 = random.randint(1, 65536) - sound2 = random.randint(1, 65536) - 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, sound1, sound2, 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, sound1, sound2, 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 bb00d042fca80c..00000000000000 --- a/selfdrive/can/tests/test_parser.py +++ /dev/null @@ -1,96 +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) - parser_new = 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 - can.send(msg.as_builder().to_bytes()) - - _, updated_old = parser_old.update(t, True) - _, updated_new = parser_new.update(t, True) - - if updated_old != updated_new: - route_ok = False - print(t, "Diff in seen") - - if dicts_vals_differ(parser_old.vl, parser_new.vl): - print(t, "Diff in dict") - 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..408e0d075ff7b7 100644 --- a/selfdrive/car/__init__.py +++ b/selfdrive/car/__init__.py @@ -1,9 +1,15 @@ # functions common among cars +from cereal import car from common.numpy_fast import clip # 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 +21,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 +39,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 +57,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 +82,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: @@ -91,7 +99,7 @@ def crc8_pedal(data): return crc -def create_gas_command(packer, gas_amount, idx): +def create_gas_interceptor_command(packer, gas_amount, idx): # Common gas pedal msg generator enable = gas_amount > 0.001 @@ -106,8 +114,19 @@ 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 make_can_msg(addr, dat, bus): + return [addr, 0, dat, bus] + + +def get_safety_config(safety_model, safety_param = None): + ret = car.CarParams.SafetyConfig.new_message() + ret.safetyModel = safety_model + if safety_param is not None: + ret.safetyParam = safety_param + return ret diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index f7e8c53757a8a0..786b00fa2b6e94 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -1,19 +1,39 @@ import os -from common.vin import is_vin_response_valid +from common.params import Params from common.basedir import BASEDIR -from common.fingerprints import eliminate_incompatible_cars, all_known_cars -from selfdrive.boardd.boardd import can_list_to_can_capnp +from selfdrive.version import get_comma_remote, get_tested_branch +from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_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.swaglog import cloudlog -import selfdrive.messaging as messaging +import cereal.messaging as messaging +from selfdrive.car import gen_empty_fingerprint +from cereal import car +EventName = car.CarEvent.EventName + + +def get_startup_event(car_recognized, controller_available, fw_seen): + if get_comma_remote() and get_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' + if fw_seen: + event = EventName.startupNoCar + else: + event = EventName.startupNoFw elif car_recognized and not controller_available: - alert = 'startupNoControl' - return alert + event = EventName.startupNoControl + 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): @@ -21,12 +41,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 @@ -48,104 +75,109 @@ 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) -# 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): - if os.getenv("SIMULATOR2") is not None: - return ("simulator2", None, "") - elif os.getenv("SIMULATOR") is not None: - return ("simulator", None, "") - - finger = {} - cloudlog.warning("waiting for fingerprint...") - candidate_cars = all_known_cars() - can_seen_frame = None - can_seen = False - - # 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 - vin_query_msg = [[0x7df, 0, '\x02\x09\x02'.ljust(8, "\x00"), 0], - [0x7e0, 0, '\x30'.ljust(8, "\x00"), 0]] - - vin_cnts = [1, 2] # number of messages to wait for at each iteration - vin_step = 0 - vin_cnt = 0 - vin_responded = False - vin_never_responded = True - vin_dat = [] - vin = "" + 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 + 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) + + exact_fw_match, fw_candidates = match_fw_to_car(car_fw) + else: + vin = VIN_UNKNOWN + exact_fw_match, fw_candidates, car_fw = True, set(), [] + cloudlog.warning("VIN %s", vin) + Params().put("CarVin", vin) + + finger = gen_empty_fingerprint() + candidate_cars = {i: all_legacy_fingerprint_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1 frame = 0 - while True: - a = messaging.recv_one(logcan) + frame_fingerprint = 10 # 0.1s + car_fingerprint = None + done = False + + while not done: + a = get_one_can(logcan) for can in a.can: - can_seen = True - - # have we got a VIN query response? - if can.src == 0 and can.address == 0x7e8: - vin_never_responded = False - # basic sanity checks on ISO-TP response - if is_vin_response_valid(can.dat, vin_step, vin_cnt): - vin_dat += can.dat[2:] if vin_step == 0 else can.dat[1:] - vin_cnt += 1 - if vin_cnt == vin_cnts[vin_step]: - vin_responded = True - vin_step += 1 - - # ignore everything not on bus 0 and with more than 11 bits, - # which are ussually sporadic and hard to include in fingerprints. - # also exclude VIN query response on 0x7e8 - if can.src == 0 and can.address < 0x800 and can.address != 0x7e8: - finger[can.address] = len(can.dat) - candidate_cars = eliminate_incompatible_cars(can, candidate_cars) - - if can_seen_frame is None and can_seen: - can_seen_frame = frame - - # if we only have one car choice and the time_fingerprint since we got our first - # message has elapsed, exit. Toyota needs higher time_fingerprint, since DSU does not - # broadcast immediately - if len(candidate_cars) == 1 and can_seen_frame is not None: - time_fingerprint = 1.0 if ("TOYOTA" in candidate_cars[0] or "LEXUS" in candidate_cars[0]) else 0.1 - if (frame - can_seen_frame) > (time_fingerprint * 100): - break - - # bail if no cars left or we've been waiting for more than 2s since can_seen - elif len(candidate_cars) == 0 or (can_seen_frame is not None and (frame - can_seen_frame) > 200): - return None, finger, "" - - # keep sending VIN qury if ECU isn't responsing. - # sendcan is probably not ready due to the zmq slow joiner syndrome - # TODO: VIN query temporarily disabled until we have the harness - if False and can_seen and (vin_never_responded or (vin_responded and vin_step < len(vin_cnts))): - sendcan.send(can_list_to_can_capnp([vin_query_msg[vin_step]], msgtype='sendcan')) - vin_responded = False - vin_cnt = 0 + # The fingerprint dict is generated for all buses, this way the car interface + # can use it to detect a (valid) multipanda setup and initialize accordingly + if can.src < 128: + if can.src not in finger.keys(): + finger[can.src] = {} + finger[can.src][can.address] = len(can.dat) + + for b in candidate_cars: + # Ignore extended messages and VIN query response. + if can.src == b and can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]: + 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 + # message has elapsed, exit + for b in candidate_cars: + if len(candidate_cars[b]) == 1 and frame > frame_fingerprint: + # fingerprint done + car_fingerprint = candidate_cars[b][0] + + # bail if no cars left or we've been waiting for more than 2s + failed = (all(len(cc) == 0 for cc in candidate_cars.values()) and frame > frame_fingerprint) or frame > 200 + succeeded = car_fingerprint is not None + done = failed or succeeded frame += 1 - # only report vin if procedure is finished - if vin_step == len(vin_cnts) and vin_cnt == vin_cnts[-1]: - vin = "".join(vin_dat[3:]) + exact_match = True + source = car.CarParams.FingerprintSource.can - cloudlog.warning("fingerprinted %s", candidate_cars[0]) - cloudlog.warning("VIN %s", vin) - return candidate_cars[0], finger, vin + # 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 + exact_match = exact_fw_match + if fixed_fingerprint: + car_fingerprint = fixed_fingerprint + source = car.CarParams.FingerprintSource.fixed -def get_car(logcan, sendcan): + cloudlog.event("fingerprinted", car_fingerprint=car_fingerprint, + source=source, fuzzy=not exact_match, fw_count=len(car_fw)) + return car_fingerprint, finger, vin, car_fw, source, exact_match - candidate, fingerprints, vin = fingerprint(logcan, sendcan) + +def get_car(logcan, sendcan): + candidate, fingerprints, vin, car_fw, source, exact_match = fingerprint(logcan, sendcan) if candidate is None: cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints) candidate = "mock" - CarInterface, CarController = interfaces[candidate] - params = CarInterface.get_params(candidate, fingerprints, vin) + 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 + car_params.fuzzyFingerprint = not exact_match - return CarInterface(params, CarController), params + return CarInterface(car_params, CarController, CarState), car_params diff --git a/selfdrive/car/chrysler/carcontroller.py b/selfdrive/car/chrysler/carcontroller.py index eea51f8f674adc..46681b13e2db84 100644 --- a/selfdrive/car/chrysler/carcontroller.py +++ b/selfdrive/car/chrysler/carcontroller.py @@ -1,43 +1,22 @@ -from cereal import car from selfdrive.car import apply_toyota_steer_torque_limits from selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, \ - create_wheel_buttons, \ - create_chimes -from selfdrive.car.chrysler.values import ECU, CAR -from selfdrive.can.packer import CANPacker + create_wheel_buttons +from selfdrive.car.chrysler.values import CAR, CarControllerParams +from opendbc.can.packer import CANPacker -AudibleAlert = car.CarControl.HUDControl.AudibleAlert -LOUD_ALERTS = [AudibleAlert.chimeWarning1, AudibleAlert.chimeWarning2, AudibleAlert.chimeWarningRepeat] - -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.send_chime = 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, audible_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: @@ -45,15 +24,16 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert, audib # *** 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 = int(round(actuators.steer * CarControllerParams.STEER_MAX)) + apply_steer = apply_toyota_steer_torque_limits(new_steer, self.apply_steer_last, + CS.out.steeringTorqueEps, CarControllerParams) + 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): + elif self.car_fingerprint in (CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020, CAR.JEEP_CHEROKEE_2019): + 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,22 +42,13 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert, audib self.apply_steer_last = apply_steer - if audible_alert in LOUD_ALERTS: - self.send_chime = True - can_sends = [] #*** control msgs *** - if self.send_chime: - new_msg = create_chimes(AudibleAlert) - can_sends.append(new_msg) - if audible_alert not in LOUD_ALERTS: - self.send_chime = False - 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. @@ -85,7 +56,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert, audib 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 1d38b8cdab7eab..ab3125b011255b 100644 --- a/selfdrive/car/chrysler/carstate.py +++ b/selfdrive/car/chrysler/carstate.py @@ -1,157 +1,147 @@ -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_PEDAL", "ACCEL_PEDAL_MSG", 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, timeout=100) - -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, timeout=100) - - -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 - - 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_PEDAL_MSG"]['ACCEL_PEDAL'] - 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 = car.CarState.new_message() + + self.frame = int(cp.vl["EPS_STATUS"]["COUNTER"]) + + 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.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 = self.get_wheel_speeds( + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FR"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RL"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RR"], + unit=1, + ) + 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.steeringAngleDeg = cp.vl["STEERING"]["STEER_ANGLE"] + ret.steeringRateDeg = 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 + # CRUISE_STATE is a three bit msg, 0 is off, 1 and 2 are Non-ACC mode, 3 and 4 are ACC mode, find if there are other states too + ret.cruiseState.nonAdaptive = cp.vl["DASHBOARD"]["CRUISE_STATE"] in [1, 2] + + 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 - - self.generic_toggle = 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'] + ret.steerError = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed) + + ret.genericToggle = bool(cp.vl["STEERING_LEVERS"]["HIGH_BEAM_FLASH"]) + + if self.CP.enableBsm: + ret.leftBlindspot = cp.vl["BLIND_SPOT_WARNINGS"]["BLIND_SPOT_LEFT"] == 1 + ret.rightBlindspot = cp.vl["BLIND_SPOT_WARNINGS"]["BLIND_SPOT_RIGHT"] == 1 + + 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), + ("CRUISE_STATE", "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), + ] + + if CP.enableBsm: + signals += [ + ("BLIND_SPOT_RIGHT", "BLIND_SPOT_WARNINGS", 0), + ("BLIND_SPOT_LEFT", "BLIND_SPOT_WARNINGS", 0), + ] + checks += [("BLIND_SPOT_WARNINGS", 2)] + + 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 f803e6094cbeec..c72f155298c6a5 100644 --- a/selfdrive/car/chrysler/chryslercan.py +++ b/selfdrive/car/chrysler/chryslercan.py @@ -1,66 +1,26 @@ from cereal import car +from selfdrive.car import make_can_msg +GearShifter = car.CarState.GearShifter VisualAlert = car.CarControl.HUDControl.VisualAlert -AudibleAlert = car.CarControl.HUDControl.AudibleAlert - -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) + if hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw]: + 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 @@ -85,28 +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_chimes(audible_alert): - # '0050' nothing, chime '4f55' - if audible_alert == AudibleAlert.none: - msg = '0050'.decode('hex') - else: - msg = '4f55'.decode('hex') - return make_can_msg(0x339, msg) - - -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 4bcb346ba2da45..00000000000000 --- a/selfdrive/car/chrysler/chryslercan_test.py +++ /dev/null @@ -1,60 +0,0 @@ -from selfdrive.car.chrysler import chryslercan -from selfdrive.can.packer import CANPacker - -from cereal import car -VisualAlert = car.CarControl.HUDControl.VisualAlert -AudibleAlert = car.CarControl.HUDControl.AudibleAlert - -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 793f7320844148..1822d76a1af000 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -1,65 +1,27 @@ -#!/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, get_safety_config +from selfdrive.car.interfaces import 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 +class CarInterface(CarInterfaceBase): @staticmethod - def get_params(candidate, fingerprint, vin=""): - - 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 = "chrysler" - ret.carFingerprint = candidate - ret.carVin = vin - - ret.safetyModel = car.CarParams.SafetyModel.chrysler - - # pedal - ret.enableCruise = True + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.chrysler)] # Speed conversion: 20, 45 mph ret.wheelbase = 3.089 # in meters for Pacifica Hybrid 2017 - ret.steerRatio = 16.2 # Pacifica Hybrid 2017 - ret.mass = 2858. + STD_CARGO_KG # kg curb weight Pacifica Hybrid 2017 + ret.steerRatio = 16.2 # Pacifica Hybrid 2017 + ret.mass = 2242. + 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 @@ -68,178 +30,56 @@ def get_params(candidate, fingerprint, vin=""): 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) - 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.enableBsm = 720 in fingerprint[0] return ret # returns a car.CarState - def update(self, c): + def update(self, c, can_strings): # ******************* do can recv ******************* - canMonoTimes = [] - can_rcv_valid, _ = self.cp.update(int(sec_since_boot() * 1e9), True) - cam_rcv_valid, _ = self.cp_cam.update(int(sec_since_boot() * 1e9), False) - - 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 = can_rcv_valid and cam_rcv_valid and self.cp.can_valid and self.cp_cam.can_valid + 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 - ret.canMonoTimes = canMonoTimes - - 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, - c.hudControl.audibleAlert) + 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 b4970b2223706a..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,32 +45,27 @@ 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): - canMonoTimes = [] + def update(self, can_strings): + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - updated_messages = set() # set of message IDs (sig_addresses) we've seen - - while 1: - tm = int(sec_since_boot() * 1e9) - _, vls = self.rcp.update(tm, True) - updated_messages.update(vls) - if LAST_MSG in updated_messages: - break + 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 - ret.canMonoTimes = canMonoTimes - for ii in updated_messages: # ii should be the message ID as a number + for ii in self.updated_messages: # ii should be the message ID as a number cpt = self.rcp.vl[ii] trackId = _address_to_track(ii) @@ -92,11 +86,6 @@ def update(self): # We want a list, not a dictionary. Filter out LONG_DIST==0 because that means it's not valid. ret.points = [x for x in self.pts.values() if x.dRel != 0] - return ret -if __name__ == "__main__": - RI = RadarInterface(None) - while 1: - ret = RI.update() - print(chr(27) + "[2J") # clear screen - print(ret) + self.updated_messages.clear() + return ret diff --git a/selfdrive/car/chrysler/run_tests.sh b/selfdrive/car/chrysler/run_tests.sh deleted file mode 100755 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 188931a060e979..e32de195017261 100644 --- a/selfdrive/car/chrysler/values.py +++ b/selfdrive/car/chrysler/values.py @@ -1,14 +1,26 @@ +# flake8: noqa + from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu + +class CarControllerParams: + 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: +# Unique CAN messages: # Only the hybrids have 270: 8 # Only the gas have 55: 8, 416: 7 # For 564, All 2017 have length 4, whereas 2018-19 have length 8. @@ -20,75 +32,58 @@ class CAR: # For 924, Trailhawk 2017 has length 3, whereas 2018 V6 has length 8. FINGERPRINTS = { - CAR.PACIFICA_2017_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: 4, 564: 4, 571: 3, 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: 3, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 956: 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, 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, 1892: 8, 2016: 8, 2024: 8}, - ], - 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, 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, 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, 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}, - ], - 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}, + CAR.PACIFICA_2017_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: 4, 564: 4, 571: 3, 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, 788:3, 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: 3, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 956: 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, 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, 1892: 8, 2016: 8, 2024: 8 + }], + 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, 352: 8, 362: 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, 536: 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, 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, 711: 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, 776: 8, 779: 8, 782: 8, 784: 8, 792: 8, 793: 8, 794: 8, 795: 8, 799: 8, 800: 8, 801: 8, 802: 8, 803: 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, 886: 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, 1227: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1284: 8, 1543: 8, 1568: 8, 1570: 8, 1856: 8, 1858: 8, 1860: 8, 1863: 8, 1865: 8, 1867: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 1898: 8, 2015: 8, 2016: 8, 2017:8, 2024: 8, 2025: 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, 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: 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, 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 - }, + { + 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 + }, # 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 - } - ], - 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, 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, 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}, - ], - 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}, - ], + { + 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 + }, + # 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, 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, 640: 1, 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, 711: 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, 793: 8, 794: 8, 795: 8, 796: 8, 797: 8, 798: 8, 799: 8, 800: 8, 801: 8, 802: 8, 803: 8, 804: 8, 805: 8, 807: 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, 878: 8, 882: 8, 886: 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, 1863: 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, 2017: 8, 2018: 8, 2019: 8, 2020: 8, 2023: 8, 2024: 8, 2026: 8, 2027: 8, 2028: 8, 2031: 8 + }], + CAR.JEEP_CHEROKEE: [{ + 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, 840: 8, 844: 5, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 874: 2, 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, 975: 8, 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, 1543: 8, 1562: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + }], + CAR.JEEP_CHEROKEE_2019: [{ + # 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/disable_ecu.py b/selfdrive/car/disable_ecu.py new file mode 100644 index 00000000000000..3a06cc06f1a553 --- /dev/null +++ b/selfdrive/car/disable_ecu.py @@ -0,0 +1,34 @@ +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_RESPONSE = b'' + +def disable_ecu(logcan, sendcan, bus=0, addr=0x7d0, com_cont_req=b'\x28\x83\x01', timeout=0.1, retry=10, debug=False): + """Silence an ECU by disabling sending and receiving messages using UDS 0x28. + The ECU will stay silent as long as openpilot keeps sending Tester Present. + + This is used to disable the radar in some cars. Openpilot will emulate the radar. + WARNING: THIS DISABLES AEB!""" + cloudlog.warning(f"ecu disable {hex(addr)} ...") + + for i in range(retry): + try: + query = IsoTpParallelQuery(sendcan, logcan, bus, [addr], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug) + + for _, _ in query.get_data(timeout).items(): + cloudlog.warning("communication control disable tx/rx ...") + + query = IsoTpParallelQuery(sendcan, logcan, bus, [addr], [com_cont_req], [COM_CONT_RESPONSE], debug=debug) + query.get_data(0) + + cloudlog.warning("ecu disabled") + return True + except Exception: + cloudlog.exception("ecu disable exception") + + print(f"ecu disable retry ({i+1}) ...") + cloudlog.warning("ecu disable failed") + return False diff --git a/selfdrive/car/fingerprints.py b/selfdrive/car/fingerprints.py new file mode 100644 index 00000000000000..b09e14a429ffb9 --- /dev/null +++ b/selfdrive/car/fingerprints.py @@ -0,0 +1,80 @@ +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') + +_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({*FW_VERSIONS.keys(), *_FINGERPRINTS.keys()}) + + +def all_legacy_fingerprint_cars(): + """Returns a list of all known car strings, FPv1 only.""" + return list(_FINGERPRINTS.keys()) diff --git a/selfdrive/car/ford/carcontroller.py b/selfdrive/car/ford/carcontroller.py new file mode 100644 index 00000000000000..06c5f257976c86 --- /dev/null +++ b/selfdrive/car/ford/carcontroller.py @@ -0,0 +1,86 @@ +import math +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 + +VisualAlert = car.CarControl.HUDControl.VisualAlert + +MAX_STEER_DELTA = 1 +TOGGLE_DEBUG = False + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.packer = CANPacker(dbc_name) + 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 in [VisualAlert.steerRequired, VisualAlert.ldw] + + apply_steer = actuators.steer + + if pcm_cancel: + #print "CANCELING!!!!" + can_sends.append(spam_cancel_button(self.packer)) + + if (frame % 3) == 0: + + curvature = self.vehicle_model.calc_curvature(actuators.steeringAngleDeg*math.pi/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.steeringAngleDeg, 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 dc6d824ff5a4b7..a621ab16ab5c5c 100644 --- a/selfdrive/car/ford/carstate.py +++ b/selfdrive/car/ford/carstate.py @@ -1,87 +1,58 @@ -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, timeout=100) - - -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 - 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"]) + ret = car.CarState.new_message() + + ret.wheelSpeeds = self.get_wheel_speeds( + cp.vl["WheelSpeed_CG1"]["WhlFl_W_Meas"], + cp.vl["WheelSpeed_CG1"]["WhlFr_W_Meas"], + cp.vl["WheelSpeed_CG1"]["WhlRl_W_Meas"], + cp.vl["WheelSpeed_CG1"]["WhlRr_W_Meas"], + unit=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.steeringAngleDeg = 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.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"] + + 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.), + ] + checks = [] + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0, enforce_checks=False) 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 0f3bbc33cc2b84..8c0b1e1faaaceb 100755 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -1,55 +1,18 @@ -#!/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, get_safety_config +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) - - @staticmethod - def compute_gb(accel, speed): - return float(accel) / 3.0 - +class CarInterface(CarInterfaceBase): @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin=""): - - 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.safetyModel = car.CarParams.SafetyModel.ford - - # pedal - ret.enableCruise = True + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.ford)] + ret.dashcamOnly = True ret.wheelbase = 2.85 ret.steerRatio = 14.8 @@ -58,14 +21,11 @@ def get_params(candidate, fingerprint, vin=""): 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) @@ -75,105 +35,29 @@ def get_params(candidate, fingerprint, vin=""): 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) - 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] - return ret # returns a car.CarState - def update(self, c): + def update(self, c, can_strings): # ******************* do can recv ******************* - canMonoTimes = [] - - can_rcv_valid, _ = self.cp.update(int(sec_since_boot() * 1e9), True) - - self.CS.update(self.cp) - - # create message - ret = car.CarState.new_message() - - ret.canValid = can_rcv_valid and 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 + self.cp.update_strings(can_strings) - # 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 = self.CS.update(self.cp) - 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 + ret.canValid = self.cp.can_valid # 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 - ret.canMonoTimes = canMonoTimes + 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.steerTempUnavailable) - 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 08b54723d6801f..20a435b0821dff 100755 --- a/selfdrive/car/ford/radar_interface.py +++ b/selfdrive/car/ford/radar_interface.py @@ -1,55 +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 + self.rcp = _create_radar_can_parser(CP.carFingerprint) + self.trigger_msg = 0x53f + self.updated_messages = set() - # Nidec - self.rcp = _create_radar_can_parser() + def update(self, can_strings): + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - def update(self): - canMonoTimes = [] - - updated_messages = set() - while 1: - tm = int(sec_since_boot() * 1e9) - _, vls = self.rcp.update(tm, True) - updated_messages.update(vls) - - # TODO: do not hardcode last msg - if 0x53f in updated_messages: - break + 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 - ret.canMonoTimes = canMonoTimes - for ii in updated_messages: + for ii in sorted(self.updated_messages): cpt = self.rcp.vl[ii] if cpt['X_Rel'] > 0.00001: @@ -58,7 +48,7 @@ def update(self): 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 @@ -68,7 +58,7 @@ def update(self): 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') @@ -77,12 +67,6 @@ def update(self): 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 - -if __name__ == "__main__": - RI = RadarInterface(None) - while 1: - ret = RI.update() - print(chr(27) + "[2J") - print(ret) diff --git a/selfdrive/car/ford/values.py b/selfdrive/car/ford/values.py index 6ab0b3750bf52d..7c6cc6d2dff938 100644 --- a/selfdrive/car/ford/values.py +++ b/selfdrive/car/ford/values.py @@ -1,16 +1,14 @@ +# 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 class CAR: FUSION = "FORD FUSION 2018" -FINGERPRINTS = { - CAR.FUSION: [{ - 71: 8, 74: 8, 75: 8, 76: 8, 90: 8, 92: 8, 93: 8, 118: 8, 119: 8, 120: 8, 125: 8, 129: 8, 130: 8, 131: 8, 132: 8, 133: 8, 145: 8, 146: 8, 357: 8, 359: 8, 360: 8, 361: 8, 376: 8, 390: 8, 391: 8, 392: 8, 394: 8, 512: 8, 514: 8, 516: 8, 531: 8, 532: 8, 534: 8, 535: 8, 560: 8, 578: 8, 604: 8, 613: 8, 673: 8, 827: 8, 848: 8, 934: 8, 935: 8, 936: 8, 947: 8, 963: 8, 970: 8, 972: 8, 973: 8, 984: 8, 992: 8, 994: 8, 997: 8, 998: 8, 1003: 8, 1034: 8, 1045: 8, 1046: 8, 1053: 8, 1054: 8, 1058: 8, 1059: 8, 1068: 8, 1072: 8, 1073: 8, 1082: 8, 1107: 8, 1108: 8, 1109: 8, 1110: 8, 1200: 8, 1427: 8, 1430: 8, 1438: 8, 1459: 8 - }], -} - DBC = { CAR.FUSION: dbc_dict('ford_fusion_2018_pt', 'ford_fusion_2018_adas'), } diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py new file mode 100755 index 00000000000000..5d982d6a8df063 --- /dev/null +++ b/selfdrive/car/fw_versions.py @@ -0,0 +1,382 @@ +#!/usr/bin/env python3 +import struct +import traceback +from typing import Any +from collections import defaultdict + +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_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) +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' + +VOLKSWAGEN_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.VEHICLE_MANUFACTURER_ECU_SOFTWARE_VERSION_NUMBER) + \ + p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION) +VOLKSWAGEN_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + +OBD_VERSION_REQUEST = b'\x09\x04' +OBD_VERSION_RESPONSE = b'\x49\x04' + +DEFAULT_RX_OFFSET = 0x8 +VOLKSWAGEN_RX_OFFSET = 0x6a + +MAZDA_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ + p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER) +MAZDA_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \ + p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER) + +NISSAN_DIAGNOSTIC_REQUEST_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0xc0]) +NISSAN_DIAGNOSTIC_RESPONSE_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, 0xc0]) + +NISSAN_VERSION_REQUEST_KWP = b'\x21\x83' +NISSAN_VERSION_RESPONSE_KWP = b'\x61\x83' + +NISSAN_VERSION_REQUEST_STANDARD = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ + p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER) +NISSAN_VERSION_RESPONSE_STANDARD = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \ + p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER) + +NISSAN_RX_OFFSET = 0x20 + +# brand, request, response, response offset +REQUESTS = [ + # Hyundai + ( + "hyundai", + [HYUNDAI_VERSION_REQUEST_LONG], + [HYUNDAI_VERSION_RESPONSE], + DEFAULT_RX_OFFSET, + ), + ( + "hyundai", + [HYUNDAI_VERSION_REQUEST_MULTI], + [HYUNDAI_VERSION_RESPONSE], + DEFAULT_RX_OFFSET, + ), + # Honda + ( + "honda", + [UDS_VERSION_REQUEST], + [UDS_VERSION_RESPONSE], + DEFAULT_RX_OFFSET, + ), + # Toyota + ( + "toyota", + [SHORT_TESTER_PRESENT_REQUEST, TOYOTA_VERSION_REQUEST], + [SHORT_TESTER_PRESENT_RESPONSE, TOYOTA_VERSION_RESPONSE], + DEFAULT_RX_OFFSET, + ), + ( + "toyota", + [SHORT_TESTER_PRESENT_REQUEST, OBD_VERSION_REQUEST], + [SHORT_TESTER_PRESENT_RESPONSE, OBD_VERSION_RESPONSE], + DEFAULT_RX_OFFSET, + ), + ( + "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], + DEFAULT_RX_OFFSET, + ), + # Volkswagen + ( + "volkswagen", + [VOLKSWAGEN_VERSION_REQUEST_MULTI], + [VOLKSWAGEN_VERSION_RESPONSE], + VOLKSWAGEN_RX_OFFSET, + ), + ( + "volkswagen", + [VOLKSWAGEN_VERSION_REQUEST_MULTI], + [VOLKSWAGEN_VERSION_RESPONSE], + DEFAULT_RX_OFFSET, + ), + # Mazda + ( + "mazda", + [MAZDA_VERSION_REQUEST], + [MAZDA_VERSION_RESPONSE], + DEFAULT_RX_OFFSET, + ), + # Nissan + ( + "nissan", + [NISSAN_DIAGNOSTIC_REQUEST_KWP, NISSAN_VERSION_REQUEST_KWP], + [NISSAN_DIAGNOSTIC_RESPONSE_KWP, NISSAN_VERSION_RESPONSE_KWP], + DEFAULT_RX_OFFSET, + ), + ( + "nissan", + [NISSAN_DIAGNOSTIC_REQUEST_KWP, NISSAN_VERSION_REQUEST_KWP], + [NISSAN_DIAGNOSTIC_RESPONSE_KWP, NISSAN_VERSION_RESPONSE_KWP], + NISSAN_RX_OFFSET, + ), + ( + "nissan", + [NISSAN_VERSION_REQUEST_STANDARD], + [NISSAN_VERSION_RESPONSE_STANDARD], + NISSAN_RX_OFFSET, + ), +] + + +def chunks(l, n=128): + for i in range(0, len(l), n): + yield l[i:i + n] + + +def build_fw_dict(fw_versions): + 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 + return fw_versions_dict + + +def match_fw_to_car_fuzzy(fw_versions_dict, log=True, exclude=None): + """Do a fuzzy FW match. This function will return a match, and the number of firmware version + that were matched uniquely to that specific car. If multiple ECUs uniquely match to different cars + the match is rejected.""" + + # These ECUs are known to be shared between models (EPS only between hybrid/ICE version) + # Getting this exactly right isn't crucial, but excluding camera and radar makes it almost + # impossible to get 3 matching versions, even if two models with shared parts are released at the same + # time and only one is in our database. + exclude_types = [Ecu.fwdCamera, Ecu.fwdRadar, Ecu.eps] + + # Build lookup table from (addr, subaddr, fw) to list of candidate cars + all_fw_versions = defaultdict(list) + for candidate, fw_by_addr in FW_VERSIONS.items(): + if candidate == exclude: + continue + + for addr, fws in fw_by_addr.items(): + if addr[0] in exclude_types: + continue + for f in fws: + all_fw_versions[(addr[1], addr[2], f)].append(candidate) + + match_count = 0 + candidate = None + for addr, version in fw_versions_dict.items(): + # All cars that have this FW response on the specified address + candidates = all_fw_versions[(addr[0], addr[1], version)] + + if len(candidates) == 1: + match_count += 1 + if candidate is None: + candidate = candidates[0] + # We uniquely matched two different cars. No fuzzy match possible + elif candidate != candidates[0]: + return set() + + if match_count >= 2: + if log: + cloudlog.error(f"Fingerprinted {candidate} using fuzzy match. {match_count} matching ECUs") + return set([candidate]) + else: + return set() + + +def match_fw_to_car_exact(fw_versions_dict): + """Do an exact FW match. Returns all cars that match the given + FW versions for a list of "essential" ECUs. If an ECU is not considered + essential the FW version can be missing to get a fingerprint, but if it's present it + needs to match the database.""" + invalid = [] + candidates = FW_VERSIONS + + 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] + if ecu_type == Ecu.esp and candidate in [TOYOTA.RAV4, TOYOTA.COROLLA, TOYOTA.HIGHLANDER, TOYOTA.SIENNA, TOYOTA.LEXUS_IS] and found_version is None: + continue + + # On some Toyota models, the engine can show on two different addresses + if ecu_type == Ecu.engine and candidate in [TOYOTA.CAMRY, 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 match_fw_to_car(fw_versions, allow_fuzzy=True): + fw_versions_dict = build_fw_dict(fw_versions) + matches = match_fw_to_car_exact(fw_versions_dict) + + exact_match = True + if allow_fuzzy and len(matches) == 0: + matches = match_fw_to_car_fuzzy(fw_versions_dict) + + # Fuzzy match found + if len(matches) == 1: + exact_match = False + + return exact_match, matches + + +def get_fw_versions(logcan, sendcan, bus, extra=None, timeout=0.1, debug=False, progress=False): + ecu_types = {} + + # Extract ECU addresses 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, response_offset 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, response_offset, 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/carcontroller.py b/selfdrive/car/gm/carcontroller.py index a2ffac61f01a6a..8f4d0f27ca332d 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -4,200 +4,106 @@ 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, CarControllerParams +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. - - 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 - - # Takes case of "Service Adaptive Cruise" and "Service Front Camera" - # dashboard messages. - self.ADAS_KEEPALIVE_STEP = 100 - self.CAMERA_KEEPALIVE_STEP = 100 - - # pedal lookups, only for Volt - MAX_GAS = 3072 # Only a safety limit - ZERO_GAS = 2048 - MAX_BRAKE = 350 # Should be around 3.5m/s^2, including regen - self.MAX_ACC_REGEN = 1404 # ACC Regen braking is slightly less powerful than max regen paddle - self.GAS_LOOKUP_BP = [-0.25, 0., 0.5] - self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, ZERO_GAS, MAX_GAS] - self.BRAKE_LOOKUP_BP = [-1., -0.25] - 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.chime = 0 - self.steer_idx = 0 self.apply_steer_last = 0 - self.car_fingerprint = car_fingerprint + self.lka_steering_cmd_counter_last = -1 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, \ - hud_v_cruise, hud_show_lanes, hud_show_car, chime, chime_cnt, hud_alert): + 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 ### - if (frame % P.STEER_STEP) == 0: - lkas_enabled = enabled and not CS.steer_not_allowed and CS.v_ego > P.MIN_STEER_SPEED + # Steering (50Hz) + # Avoid GM EPS faults when transmitting messages too close together: skip this transmit if we just received the + # next Panda loopback confirmation in the current CS frame. + if CS.lka_steering_cmd_counter != self.lka_steering_cmd_counter_last: + self.lka_steering_cmd_counter_last = CS.lka_steering_cmd_counter + elif (frame % P.STEER_STEP) == 0: + lkas_enabled = enabled and not (CS.out.steerWarning or CS.out.steerError) 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 = 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 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)) + # GM EPS faults on any gap in received message counters. To handle transient OP/Panda safety sync issues at the + # moment of disengaging, increment the counter based on the last message known to pass Panda safety checks. + idx = (CS.lka_steering_cmd_counter + 1) % 4 - ### 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 - - # *** 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 - - # Send chimes - if self.chime != chime: - duration = 0x3c - - # There is no 'repeat forever' chime command - # TODO: Manage periodic re-issuing of chime command - # and chime cancellation - if chime_cnt == -1: - chime_cnt = 10 - - if chime != 0: - can_sends.append(gmcan.create_chime_command(canbus.sw_gmlan, chime, duration, chime_cnt)) - - # If canceling a repeated chime, cancel command must be - # issued for the same chime type and duration - self.chime = chime + 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(actuators.accel, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V))) + apply_brake = int(round(interp(actuators.accel, 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 in [VisualAlert.steerRequired, VisualAlert.ldw] + 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 174d11b46b53c2..e4d644834891ab 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -1,151 +1,148 @@ -import numpy as np from cereal import car -from common.kalman.simple_kalman import KF1D -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 common.numpy_fast import mean +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, timeout=100) +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"] + self.lka_steering_cmd_counter = 0 -class CarState(object): - def __init__(self, CP, canbus): - self.CP = CP - # initialize can parser + def update(self, pt_cp, loopback_cp): + ret = car.CarState.new_message() - 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. - - def update(self, pt_cp): 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])) + self.cruise_buttons = pt_cp.vl["ASCMSteeringButton"]["ACCButtons"] + + ret.wheelSpeeds = self.get_wheel_speeds( + pt_cp.vl["EBCMWheelSpdFront"]["FLWheelSpd"], + pt_cp.vl["EBCMWheelSpdFront"]["FRWheelSpd"], + pt_cp.vl["EBCMWheelSpdRear"]["RLWheelSpd"], + pt_cp.vl["EBCMWheelSpdRear"]["RRWheelSpd"], + ) + 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.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 + + ret.steeringAngleDeg = pt_cp.vl["PSCMSteeringAngle"]["SteeringWheelAngle"] + ret.steeringRateDeg = pt_cp.vl["PSCMSteeringAngle"]["SteeringWheelRate"] + ret.steeringTorque = pt_cp.vl["PSCMStatus"]["LKADriverAppldTrq"] + ret.steeringTorqueEps = pt_cp.vl["PSCMStatus"]["LKATorqueDelivered"] + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD + self.lka_steering_cmd_counter = loopback_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"] + + # 0 inactive, 1 active, 2 temporarily limited, 3 failed + self.lkas_status = pt_cp.vl["PSCMStatus"]["LKATorqueDeliveredStatus"] + ret.steerWarning = self.lkas_status == 2 + ret.steerError = self.lkas_status == 3 - 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]) + # 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"]) + + ret.cruiseState.enabled = self.pcm_acc_status != AccState.OFF + ret.cruiseState.standstill = self.pcm_acc_status == AccState.STANDSTILL + + 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), + ("SteeringWheelRate", "PSCMSteeringAngle", 0), + ("FLWheelSpd", "EBCMWheelSpdFront", 0), + ("FRWheelSpd", "EBCMWheelSpdFront", 0), + ("RLWheelSpd", "EBCMWheelSpdRear", 0), + ("RRWheelSpd", "EBCMWheelSpdRear", 0), + ("PRNDL", "ECMPRDNL", 0), + ("LKADriverAppldTrq", "PSCMStatus", 0), + ("LKATorqueDelivered", "PSCMStatus", 0), + ("LKATorqueDeliveredStatus", "PSCMStatus", 0), + ("TractionControlOn", "ESPStatus", 0), + ("EPBClosed", "EPBStatus", 0), + ("CruiseMainOn", "ECMEngineStatus", 0), + ] - self.steer_torque_driver = pt_cp.vl["PSCMStatus"]['LKADriverAppldTrq'] - self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD + checks = [ + ("BCMTurnSignals", 1), + ("ECMPRDNL", 10), + ("PSCMStatus", 10), + ("ESPStatus", 10), + ("BCMDoorBeltStatus", 10), + ("EPBStatus", 20), + ("EBCMWheelSpdFront", 20), + ("EBCMWheelSpdRear", 20), + ("AcceleratorPedal", 33), + ("AcceleratorPedal2", 33), + ("ASCMSteeringButton", 33), + ("ECMEngineStatus", 100), + ("PSCMSteeringAngle", 100), + ("EBCMBrakePedalPosition", 100), + ] - # 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) + if CP.carFingerprint == CAR.VOLT: + signals += [ + ("RegenPaddle", "EBCMRegenPaddle", 0), + ] + checks += [ + ("EBCMRegenPaddle", 50), + ] - # 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) + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus.POWERTRAIN) - # 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 + @staticmethod + def get_loopback_can_parser(CP): + signals = [ + ("RollingCounter", "ASCMLKASteeringCmd", 0), + ] - # Regen braking is braking - self.brake_pressed = self.user_brake > 10 or self.regen_pressed + checks = [ + ("ASCMLKASteeringCmd", 50), + ] - self.gear_shifter_valid = self.gear_shifter == car.CarState.GearShifter.drive + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus.LOOPBACK) diff --git a/selfdrive/car/gm/gmcan.py b/selfdrive/car/gm/gmcan.py index 64fd84f4aca186..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,71 +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] - -def create_adas_headlights_status(bus): - return [0x310, 0, "\x42\x04", bus] + return make_can_msg(0x308, bytes(dat), bus) -def create_chime_command(bus, chime_type, duration, repeat_cnt): - dat = [chime_type, duration, repeat_cnt, 0xff, 0] - return [0x10400060, 0, "".join(map(chr, dat)), 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" + dat = b"\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 - 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 c066a6523f2213..b06e5373aa1009 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -1,86 +1,88 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car -from common.realtime import sec_since_boot +from math import fabs 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, AUDIO_HUD, \ - 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, CarControllerParams +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config +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 + def get_pid_accel_limits(CP, current_speed, cruise_speed): + params = CarControllerParams() + return params.ACCEL_MIN, params.ACCEL_MAX + # Determined by iteratively plotting and minimizing error for f(angle, speed) = steer. @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 + def get_steer_feedforward_volt(desired_angle, v_ego): + desired_angle *= 0.02904609 + sigmoid = desired_angle / (1 + fabs(desired_angle)) + return 0.10006696 * sigmoid * (v_ego + 3.12485927) @staticmethod - def get_params(candidate, fingerprint, vin=""): - ret = car.CarParams.new_message() + def get_steer_feedforward_acadia(desired_angle, v_ego): + desired_angle *= 0.09760208 + sigmoid = desired_angle / (1 + fabs(desired_angle)) + return 0.04689655 * sigmoid * (v_ego + 10.028217) + + def get_steer_feedforward_function(self): + if self.CP.carFingerprint == CAR.VOLT: + return self.get_steer_feedforward_volt + elif self.CP.carFingerprint == CAR.ACADIA: + return self.get_steer_feedforward_acadia + else: + return CarInterfaceBase.get_steer_feedforward_default + @staticmethod + 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.enableCruise = False + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.gm)] + ret.pcmCruise = False # stock cruise control is kept off # 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) - ret.openpilotLongitudinalControl = ret.enableCamera + ret.openpilotLongitudinalControl = True 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.steerRatio = 17.7 # Stock 15.7, LiveParameters + tire_stiffness_factor = 0.469 # Stock Michelin Energy Saver A/S, LiveParameters ret.steerRatioRear = 0. - ret.centerToFront = ret.wheelbase * 0.4 # wild guess + ret.centerToFront = ret.wheelbase * 0.45 # Volt Gen 1, TODO corner weigh + + ret.lateralTuning.pid.kpBP = [0., 40.] + ret.lateralTuning.pid.kpV = [0., 0.17] + ret.lateralTuning.pid.kiBP = [0.] + ret.lateralTuning.pid.kiV = [0.] + ret.lateralTuning.pid.kf = 1. # get_steer_feedforward_volt() + ret.steerActuatorDelay = 0.2 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 @@ -88,47 +90,44 @@ def get_params(candidate, fingerprint, vin=""): # 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 + ret.lateralTuning.pid.kf = 1. # get_steer_feedforward_acadia() 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 - + elif candidate == CAR.ESCALADE_ESV: + ret.minEnableSpeed = -1. # engage speed is decided by pcm + ret.mass = 2739. + STD_CARGO_KG + ret.wheelbase = 3.302 + ret.steerRatio = 17.3 + ret.centerToFront = ret.wheelbase * 0.49 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[10., 41.0], [10., 41.0]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.13, 0.24], [0.01, 0.02]] + ret.lateralTuning.pid.kf = 0.000045 + tire_stiffness_factor = 1.0 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase @@ -139,104 +138,31 @@ def get_params(candidate, fingerprint, vin=""): 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_rcv_valid, _ = self.pt_cp.update(int(sec_since_boot() * 1e9), True) - - self.CS.update(self.pt_cp) - - # create message - ret = car.CarState.new_message() - - ret.canValid = can_rcv_valid and 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 + def update(self, c, can_strings): + self.cp.update_strings(can_strings) + self.cp_loopback.update_strings(can_strings) - buttonEvents = [] + ret = self.CS.update(self.cp, self.cp_loopback) - # 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 and self.cp_loopback.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 @@ -244,97 +170,60 @@ def update(self, c): 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])) + 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.accFaulted) + 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 - 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 def apply(self, c): hud_v_cruise = c.hudControl.setSpeed if hud_v_cruise > 70: hud_v_cruise = 0 - chime, chime_count = AUDIO_HUD[c.hudControl.audibleAlert.raw] - # 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, \ - c.hudControl.leadVisible, \ - chime, chime_count, c.hudControl.visualAlert) + hud_v_cruise, c.hudControl.lanesVisible, + c.hudControl.leadVisible, c.hudControl.visualAlert) self.frame += 1 return can_sends diff --git a/selfdrive/car/gm/radar_interface.py b/selfdrive/car/gm/radar_interface.py index 12fb7c23427380..4cb1e0781f26ea 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,57 +15,50 @@ # 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, CAR.ESCALADE_ESV): 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 = list({(s[1], 14) for s in signals}) + + 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 + self.rcp = create_radar_can_parser(CP.carFingerprint) - canbus = CanBus() - print "Using %d as obstacle CAN bus ID" % canbus.obstacle - self.rcp = create_radar_can_parser(canbus, CP.carFingerprint) + self.trigger_msg = LAST_RADAR_MSG + self.updated_messages = set() + self.radar_ts = CP.radarTimeStep - def update(self): - updated_messages = set() - ret = car.RadarData.new_message() - while 1: + def update(self, can_strings): + if self.rcp is None: + return super().update(None) - if self.rcp is None: - time.sleep(0.05) # nothing to do - return ret + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - tm = int(sec_since_boot() * 1e9) - _, vls = self.rcp.update(tm, True) - updated_messages.update(vls) - if LAST_RADAR_MSG in updated_messages: - break + 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 \ header['FLRRYawRtPlsblityFlt'] or header['FLRRHWFltPrsntInt'] or \ @@ -83,7 +75,7 @@ def update(self): # Not all radar messages describe targets, # no need to monitor all of the self.rcp.msgs_upd - for ii in updated_messages: + for ii in self.updated_messages: if ii == RADAR_HEADER_MSG: continue @@ -99,24 +91,17 @@ def update(self): 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 - -if __name__ == "__main__": - RI = RadarInterface(None) - while 1: - ret = RI.update() - print(chr(27) + "[2J") - print(ret) diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index b41919acb9426f..d475b4bd671839 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -1,80 +1,84 @@ +# flake8: noqa + from cereal import car from selfdrive.car import dbc_dict +Ecu = car.CarParams.Ecu + +class CarControllerParams(): + STEER_MAX = 300 # Safety limit, not LKA max. Trucks use 600. + STEER_STEP = 2 # control frames per command + STEER_DELTA_UP = 7 + STEER_DELTA_DOWN = 17 + MIN_STEER_SPEED = 3. # m/s + STEER_DRIVER_ALLOWANCE = 50 + STEER_DRIVER_MULTIPLIER = 4 + STEER_DRIVER_FACTOR = 100 + NEAR_STOP_BRAKE_PHASE = 0.5 # m/s + + # Heartbeat for dash "Service Adaptive Cruise" and "Service Front Camera" + ADAS_KEEPALIVE_STEP = 100 + CAMERA_KEEPALIVE_STEP = 100 + + # Volt gasbrake lookups + MAX_GAS = 3072 # Safety limit, not ACC max. Stock ACC >4096 from standstill. + ZERO_GAS = 2048 # Coasting + MAX_BRAKE = 350 # ~ -3.5 m/s^2 with regen + + # Allow small margin below -3.5 m/s^2 from ISO 15622:2018 since we + # perform the closed loop control, and might need some + # to apply some more braking if we're on a downhill slope. + # Our controller should still keep the 2 second average above + # -3.5 m/s^2 as per planner limits + ACCEL_MAX = 2. # m/s^2 + ACCEL_MIN = -4. # m/s^2 -AudibleAlert = car.CarControl.HUDControl.AudibleAlert + MAX_ACC_REGEN = 1404 # Max ACC regen is slightly less than max paddle regen + GAS_LOOKUP_BP = [-1., 0., ACCEL_MAX] + GAS_LOOKUP_V = [MAX_ACC_REGEN, ZERO_GAS, MAX_GAS] + BRAKE_LOOKUP_BP = [ACCEL_MIN, -1.] + BRAKE_LOOKUP_V = [MAX_BRAKE, 0.] + +STEER_THRESHOLD = 1.0 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] + ESCALADE_ESV = "CADILLAC ESCALADE ESV 2016" class CruiseButtons: - UNPRESS = 1 - RES_ACCEL = 2 - DECEL_SET = 3 - MAIN = 5 - CANCEL = 6 - -# Car chimes, beeps, blinker sounds etc -class CM: - TOCK = 0x81 - TICK = 0x82 - LOW_BEEP = 0x84 - HIGH_BEEP = 0x85 - LOW_CHIME = 0x86 - HIGH_CHIME = 0x87 + 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 -AUDIO_HUD = { - AudibleAlert.none: (0, 0), - AudibleAlert.chimeEngage: (CM.HIGH_CHIME, 1), - AudibleAlert.chimeDisengage: (CM.HIGH_CHIME, 1), - AudibleAlert.chimeError: (CM.LOW_CHIME, 2), - AudibleAlert.chimePrompt: (CM.LOW_CHIME, 1), - AudibleAlert.chimeWarning1: (CM.LOW_CHIME, 2), - AudibleAlert.chimeWarning2: (CM.LOW_CHIME, -1), - AudibleAlert.chimeWarningRepeat: (CM.LOW_CHIME, -1)} - -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 + LOOPBACK = 128 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 { @@ -90,31 +94,24 @@ 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 { 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, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 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, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 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, 753: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 2, 1225: 7, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1919: 7, 1930: 7, 2016: 8, 2024: 8, }], CAR.ACADIA: [ + # Acadia Denali w/ACC 2018 + { + 190: 6, 192: 5, 193: 8, 197: 8, 199: 4, 201: 6, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 1, 290: 1, 298: 8, 304: 8, 309: 8, 313: 8, 320: 8, 322: 7, 328: 1, 352: 7, 368: 8, 381: 8, 384: 8, 386: 8, 388: 8, 393: 8, 398: 8, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 458: 8, 460: 4, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 489: 5, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 512: 3, 530: 8, 532: 6, 534: 2, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 567: 5, 568: 2, 573: 1, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 789: 5, 800: 6, 801: 8, 803: 8, 804: 3, 805: 8, 832: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1003: 5, 1005: 6, 1009: 8, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1918: 7, 1919: 7, 1920: 7, 1930: 7 + }, # Acadia Denali w/ /ACC 2018 { 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 8, 298: 8, 304: 1, 309: 8, 313: 8, 320: 3, 322: 7, 328: 1, 338: 6, 340: 6, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 393: 8, 398: 8, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 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, 753: 5, 761: 7, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8 }], -} - -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 + CAR.ESCALADE_ESV: [ + { + 309: 1, 848: 8, 849: 8, 850: 8, 851: 8, 852: 8, 853: 8, 854: 3, 1056: 6, 1057: 8, 1058: 8, 1059: 8, 1060: 8, 1061: 8, 1062: 8, 1063: 8, 1064: 8, 1065: 8, 1066: 8, 1067: 8, 1068: 8, 1120: 8, 1121: 8, 1122: 8, 1123: 8, 1124: 8, 1125: 8, 1126: 8, 1127: 8, 1128: 8, 1129: 8, 1130: 8, 1131: 8, 1132: 8, 1133: 8, 1134: 8, 1135: 8, 1136: 8, 1137: 8, 1138: 8, 1139: 8, 1140: 8, 1141: 8, 1142: 8, 1143: 8, 1146: 8, 1147: 8, 1148: 8, 1149: 8, 1150: 8, 1151: 8, 1216: 8, 1217: 8, 1218: 8, 1219: 8, 1220: 8, 1221: 8, 1222: 8, 1223: 8, 1224: 8, 1225: 8, 1226: 8, 1232: 8, 1233: 8, 1234: 8, 1235: 8, 1236: 8, 1237: 8, 1238: 8, 1239: 8, 1240: 8, 1241: 8, 1242: 8, 1787: 8, 1788: 8 + }], } DBC = { @@ -124,5 +121,5 @@ 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'), + CAR.ESCALADE_ESV: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), } diff --git a/selfdrive/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py index 3a5703e117bd50..e1488eda2a79b2 100644 --- a/selfdrive/car/honda/carcontroller.py +++ b/selfdrive/car/honda/carcontroller.py @@ -1,18 +1,44 @@ 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 selfdrive.car import create_gas_command +from common.numpy_fast import clip, interp +from selfdrive.car import create_gas_interceptor_command from selfdrive.car.honda import hondacan -from selfdrive.car.honda.values import AH, CruiseButtons, CAR -from selfdrive.can.packer import CANPacker +from selfdrive.car.honda.values import CruiseButtons, VISUAL_HUD, HONDA_BOSCH, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams +from opendbc.can.packer import CANPacker +VisualAlert = car.CarControl.HUDControl.VisualAlert +LongCtrlState = car.CarControl.Actuators.LongControlState +def compute_gb_honda_bosch(accel, speed): + #TODO returns 0s, is unused + return 0.0, 0.0 + + +def compute_gb_honda_nidec(accel, speed): + creep_brake = 0.0 + creep_speed = 2.3 + creep_brake_value = 0.15 + if speed < creep_speed: + creep_brake = (creep_speed - speed) / creep_speed * creep_brake_value + gb = float(accel) / 4.8 - creep_brake + return clip(gb, 0.0, 1.0), clip(-gb, 0.0, 1.0) + + +def compute_gas_brake(accel, speed, fingerprint): + if fingerprint in HONDA_BOSCH: + return compute_gb_honda_bosch(accel, speed) + else: + return compute_gb_honda_nidec(accel, speed) + + +#TODO not clear this does anything useful def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint): # hyst params brake_hyst_on = 0.02 # to activate brakes exceed this value - brake_hyst_off = 0.005 # to deactivate brakes below this value - brake_hyst_gap = 0.01 # don't change brake command for small oscillations within this value + brake_hyst_off = 0.005 # to deactivate brakes below this value + brake_hyst_gap = 0.01 # don't change brake command for small oscillations within this value #*** hysteresis logic to avoid brake blinking. go above 0.1 to trigger if (brake < brake_hyst_on and not braking) or brake < brake_hyst_off: @@ -28,9 +54,6 @@ 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: - brake += 0.15 - return brake, braking, brake_steady @@ -56,48 +79,51 @@ 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 in [VisualAlert.steerRequired, VisualAlert.ldw]: + 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", "beep", "chime", "fcw", "acc_alert", "steer_required"]) + ["pcm_accel", "v_cruise", "car", + "lanes", "fcw", "acc_alert", "steer_required"]) -class CarController(object): - def __init__(self, dbc_name): +class CarController(): + def __init__(self, dbc_name, CP, VM): self.braking = False self.brake_steady = 0. self.brake_last = 0. self.apply_brake_last = 0 self.last_pump_ts = 0. 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, \ - hud_v_cruise, hud_show_lanes, hud_show_car, \ - hud_alert, snd_beep, snd_chime): + self.params = CarControllerParams(CP) - # *** apply brake hysteresis *** - brake, self.braking, self.brake_steady = actuator_hystereses(actuators.brake, self.braking, self.brake_steady, CS.v_ego, CS.CP.carFingerprint) + def update(self, enabled, active, CS, frame, actuators, pcm_cancel_cmd, + hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert): + + P = self.params + + if enabled: + accel = actuators.accel + gas, brake = compute_gas_brake(actuators.accel, CS.out.vEgo, CS.CP.carFingerprint) + else: + accel = 0.0 + gas, brake = 0.0, 0.0 - # *** no output if not enabled *** - 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 = True + # *** apply brake hysteresis *** + pre_limit_brake, self.braking, self.brake_steady = actuator_hystereses(brake, self.braking, self.brake_steady, CS.out.vEgo, CS.CP.carFingerprint) # *** rate limit after the enable check *** - self.brake_last = rate_limit(brake, self.brake_last, -2., 1./100) + self.brake_last = rate_limit(pre_limit_brake, self.brake_last, -2., DT_CTRL) # vehicle hud display, wait for one update from 10Hz 0x304 msg if hud_show_lanes: @@ -113,69 +139,111 @@ def update(self, enabled, CS, frame, actuators, \ else: hud_car = 0 - # For lateral control-only, send chimes as a beep since we don't send 0x1fa - if CS.CP.radarOffCan: - snd_beep = snd_beep if snd_beep != 0 else snd_chime - - #print("{0} {1} {2}".format(chime, alert_id, hud_alert)) 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, int(snd_beep), snd_chime, 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) - elif CS.CP.carFingerprint in (CAR.ODYSSEY_CHN): - STEER_MAX = 0x7FFF - else: - STEER_MAX = 0x1000 - # 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 = [] + # tester present - w/ no response (keeps radar disabled) + if CS.CP.carFingerprint in HONDA_BOSCH and CS.CP.openpilotLongitudinalControl: + if (frame % 10) == 0: + can_sends.append((0x18DAB0F1, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", 1)) + # Send steering command. idx = frame % 4 can_sends.append(hondacan.create_steering_control(self.packer, apply_steer, - lkas_active, CS.CP.carFingerprint, idx)) - - # 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)) - - if CS.CP.radarOffCan: + lkas_active, CS.CP.carFingerprint, idx, CS.CP.openpilotLongitudinalControl)) + + stopping = actuators.longControlState == LongCtrlState.stopping + starting = actuators.longControlState == LongCtrlState.starting + + # wind brake from air resistance decel at high speed + wind_brake = interp(CS.out.vEgo, [0.0, 2.3, 35.0], [0.001, 0.002, 0.15]) + # all of this is only relevant for HONDA NIDEC + max_accel = interp(CS.out.vEgo, P.NIDEC_MAX_ACCEL_BP, P.NIDEC_MAX_ACCEL_V) + # TODO this 1.44 is just to maintain previous behavior + pcm_speed_BP = [-wind_brake, + -wind_brake*(3/4), + 0.0, + 0.5] + # The Honda ODYSSEY seems to have different PCM_ACCEL + # msgs, is it other cars too? + if CS.CP.enableGasInterceptor: + pcm_speed = 0.0 + pcm_accel = int(0.0) + elif CS.CP.carFingerprint in HONDA_NIDEC_ALT_PCM_ACCEL: + pcm_speed_V = [0.0, + clip(CS.out.vEgo - 3.0, 0.0, 100.0), + clip(CS.out.vEgo + 0.0, 0.0, 100.0), + clip(CS.out.vEgo + 5.0, 0.0, 100.0)] + pcm_speed = interp(gas-brake, pcm_speed_BP, pcm_speed_V) + pcm_accel = int((1.0) * 0xc6) + else: + pcm_speed_V = [0.0, + clip(CS.out.vEgo - 2.0, 0.0, 100.0), + clip(CS.out.vEgo + 2.0, 0.0, 100.0), + clip(CS.out.vEgo + 5.0, 0.0, 100.0)] + pcm_speed = interp(gas-brake, pcm_speed_BP, pcm_speed_V) + pcm_accel = int(clip((accel/1.44)/max_accel, 0.0, 1.0) * 0xc6) + + 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)) - elif CS.stopped: - can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx)) + 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.chime, hud.fcw, idx)) - 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: + accel = clip(accel, P.BOSCH_ACCEL_MIN, P.BOSCH_ACCEL_MAX) + bosch_gas = interp(accel, P.BOSCH_GAS_LOOKUP_BP, P.BOSCH_GAS_LOOKUP_V) + can_sends.extend(hondacan.create_acc_commands(self.packer, enabled, active, accel, bosch_gas, idx, stopping, starting, CS.CP.carFingerprint)) + + else: + apply_brake = clip(self.brake_last - wind_brake, 0.0, 1.0) + apply_brake = int(clip(apply_brake * P.NIDEC_BRAKE_MAX, 0, P.NIDEC_BRAKE_MAX - 1)) + pump_on, self.last_pump_ts = brake_pump_hysteresis(apply_brake, self.apply_brake_last, self.last_pump_ts, ts) + + pcm_override = True + can_sends.append(hondacan.create_brake_command(self.packer, apply_brake, pump_on, + pcm_override, pcm_cancel_cmd, fcw_display, idx, CS.CP.carFingerprint, CS.stock_brake)) + self.apply_brake_last = apply_brake + + if CS.CP.enableGasInterceptor: + # way too aggressive at low speed without this + gas_mult = interp(CS.out.vEgo, [0., 10.], [0.4, 1.0]) + # 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 + # Sending non-zero gas when OP is not enabled will cause the PCM not to respond to throttle as expected + # when you do enable. + if active: + apply_gas = clip(gas_mult * (gas - brake + wind_brake*3/4), 0., 1.) + else: + apply_gas = 0.0 + can_sends.append(create_gas_interceptor_command(self.packer, apply_gas, idx)) + + hud = HUDData(int(pcm_accel), int(round(hud_v_cruise)), hud_car, + hud_lanes, fcw_display, acc_alert, steer_required) + + # Send dashboard UI commands. + if (frame % 10) == 0: + idx = (frame//10) % 4 + can_sends.extend(hondacan.create_ui_commands(self.packer, CS.CP, pcm_speed, hud, CS.is_metric, idx, CS.stock_hud)) return can_sends diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py index 6c0aec52a03a5f..12a4ae4c29bdeb 100644 --- a/selfdrive/car/honda/carstate.py +++ b/selfdrive/car/honda/carstate.py @@ -1,69 +1,56 @@ +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.honda.values import CAR, DBC, STEER_THRESHOLD, SPEED_FACTOR, HONDA_BOSCH +from selfdrive.car.interfaces import CarStateBase +from selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_ALT_BRAKE_SIGNAL -def parse_gear_shifter(gear, vals): +TransmissionType = car.CarParams.TransmissionType - 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 - # 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 +def get_can_signals(CP, gearbox_msg, main_on_sig_msg): + # this function generates lists for signal, messages and initial values signals = [ - ("XMISSION_SPEED", "ENGINE_DATA", 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), - ("STEER_ANGLE", "STEERING_SENSORS", 0), - ("STEER_ANGLE_RATE", "STEERING_SENSORS", 0), - ("STEER_TORQUE_SENSOR", "STEER_STATUS", 0), - ("LEFT_BLINKER", "SCM_FEEDBACK", 0), - ("RIGHT_BLINKER", "SCM_FEEDBACK", 0), - ("GEAR", "GEARBOX", 0), - ("SEATBELT_DRIVER_LAMP", "SEATBELT_STATUS", 1), - ("SEATBELT_DRIVER_LATCHED", "SEATBELT_STATUS", 0), - ("BRAKE_PRESSED", "POWERTRAIN_DATA", 0), - ("BRAKE_SWITCH", "POWERTRAIN_DATA", 0), - ("CRUISE_BUTTONS", "SCM_BUTTONS", 0), - ("ESP_DISABLED", "VSA_STATUS", 1), - ("USER_BRAKE", "VSA_STATUS", 0), - ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0), - ("STEER_STATUS", "STEER_STATUS", 5), - ("GEAR_SHIFTER", "GEARBOX", 0), - ("PEDAL_GAS", "POWERTRAIN_DATA", 0), - ("CRUISE_SETTING", "SCM_BUTTONS", 0), - ("ACC_STATUS", "POWERTRAIN_DATA", 0), + ("XMISSION_SPEED", "ENGINE_DATA", 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), + ("STEER_ANGLE", "STEERING_SENSORS", 0), + ("STEER_ANGLE_RATE", "STEERING_SENSORS", 0), + ("MOTOR_TORQUE", "STEER_MOTOR_TORQUE", 0), + ("STEER_TORQUE_SENSOR", "STEER_STATUS", 0), + ("LEFT_BLINKER", "SCM_FEEDBACK", 0), + ("RIGHT_BLINKER", "SCM_FEEDBACK", 0), + ("GEAR", gearbox_msg, 0), + ("SEATBELT_DRIVER_LAMP", "SEATBELT_STATUS", 1), + ("SEATBELT_DRIVER_LATCHED", "SEATBELT_STATUS", 0), + ("BRAKE_PRESSED", "POWERTRAIN_DATA", 0), + ("BRAKE_SWITCH", "POWERTRAIN_DATA", 0), + ("CRUISE_BUTTONS", "SCM_BUTTONS", 0), + ("ESP_DISABLED", "VSA_STATUS", 1), + ("USER_BRAKE", "VSA_STATUS", 0), + ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0), + ("STEER_STATUS", "STEER_STATUS", 5), + ("GEAR_SHIFTER", gearbox_msg, 0), + ("PEDAL_GAS", "POWERTRAIN_DATA", 0), + ("CRUISE_SETTING", "SCM_BUTTONS", 0), + ("ACC_STATUS", "POWERTRAIN_DATA", 0), + ("MAIN_ON", main_on_sig_msg, 0), ] checks = [ - ("ENGINE_DATA", 100), - ("WHEEL_SPEEDS", 50), - ("STEERING_SENSORS", 100), - ("SEATBELT_STATUS", 10), - ("CRUISE", 10), - ("POWERTRAIN_DATA", 100), - ("VSA_STATUS", 50), + ("ENGINE_DATA", 100), + ("WHEEL_SPEEDS", 50), + ("STEERING_SENSORS", 100), + ("SEATBELT_STATUS", 10), + ("CRUISE", 10), + ("POWERTRAIN_DATA", 100), + ("VSA_STATUS", 50), + ("STEER_STATUS", 100), + ("STEER_MOTOR_TORQUE", 0), # TODO: not on every car ] if CP.carFingerprint == CAR.ODYSSEY_CHN: @@ -77,128 +64,116 @@ def get_can_signals(CP): ("SCM_BUTTONS", 25), ] - if CP.carFingerprint == CAR.CRV_HYBRID: + if CP.carFingerprint in (CAR.CRV_HYBRID, CAR.CIVIC_BOSCH_DIESEL, CAR.ACURA_RDX_3G, CAR.HONDA_E): checks += [ - ("GEARBOX", 50), + (gearbox_msg, 50), ] else: checks += [ - ("GEARBOX", 100), + (gearbox_msg, 100), ] - if CP.radarOffCan: - # Civic is only bosch to use the same brake message as other hondas. - if CP.carFingerprint not in (CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CRV_HYBRID): - signals += [("BRAKE_PRESSED", "BRAKE_MODULE", 0)] - checks += [("BRAKE_MODULE", 50)] - signals += [("CAR_GAS", "GAS_PEDAL_2", 0), - ("MAIN_ON", "SCM_FEEDBACK", 0), - ("EPB_STATE", "EPB_STATUS", 0), - ("CRUISE_SPEED", "ACC_HUD", 0)] - checks += [("GAS_PEDAL_2", 100)] - else: - # Nidec signals. - signals += [("BRAKE_ERROR_1", "STANDSTILL", 1), - ("BRAKE_ERROR_2", "STANDSTILL", 1), - ("CRUISE_SPEED_PCM", "CRUISE", 0), + if CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL: + signals += [("BRAKE_PRESSED", "BRAKE_MODULE", 0)] + checks += [("BRAKE_MODULE", 50)] + + if CP.carFingerprint in HONDA_BOSCH: + signals += [ + ("EPB_STATE", "EPB_STATUS", 0), + ("IMPERIAL_UNIT", "CAR_SPEED", 1), + ] + checks += [ + ("EPB_STATUS", 50), + ("CAR_SPEED", 10), + ] + + if not CP.openpilotLongitudinalControl: + signals += [ + ("CRUISE_CONTROL_LABEL", "ACC_HUD", 0), + ("CRUISE_SPEED", "ACC_HUD", 0), + ("ACCEL_COMMAND", "ACC_CONTROL", 0), + ("AEB_STATUS", "ACC_CONTROL", 0), + ] + checks += [ + ("ACC_HUD", 10), + ("ACC_CONTROL", 50), + ] + else: # Nidec signals + signals += [("CRUISE_SPEED_PCM", "CRUISE", 0), ("CRUISE_SPEED_OFFSET", "CRUISE_PARAMS", 0)] - checks += [("STANDSTILL", 50)] 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.CRV_HYBRID): + if CP.carFingerprint in (CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E): signals += [("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1)] elif CP.carFingerprint == CAR.ODYSSEY_CHN: signals += [("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1)] + elif CP.carFingerprint in (CAR.FREED, 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), ("DOOR_OPEN_RL", "DOORS_STATUS", 1), ("DOOR_OPEN_RR", "DOORS_STATUS", 1), ("WHEELS_MOVING", "STANDSTILL", 1)] - checks += [("DOORS_STATUS", 3)] + checks += [ + ("DOORS_STATUS", 3), + ("STANDSTILL", 50), + ] if CP.carFingerprint == CAR.CIVIC: - signals += [("CAR_GAS", "GAS_PEDAL_2", 0), - ("MAIN_ON", "SCM_FEEDBACK", 0), - ("IMPERIAL_UNIT", "HUD_SETTING", 0), - ("EPB_STATE", "EPB_STATUS", 0)] - 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): - signals += [("MAIN_ON", "SCM_BUTTONS", 0)] - elif CP.carFingerprint == CAR.ODYSSEY: - signals += [("MAIN_ON", "SCM_FEEDBACK", 0), - ("EPB_STATE", "EPB_STATUS", 0)] - checks += [("EPB_STATUS", 50)] - 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), + signals += [("IMPERIAL_UNIT", "HUD_SETTING", 0), ("EPB_STATE", "EPB_STATUS", 0)] + checks += [ + ("HUD_SETTING", 50), + ("EPB_STATUS", 50), + ] + elif CP.carFingerprint in (CAR.ODYSSEY, CAR.ODYSSEY_CHN): + signals += [("EPB_STATE", "EPB_STATUS", 0)] checks += [("EPB_STATUS", 50)] # 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 signals, checks - - -def get_can_parser(CP): - signals, checks = get_can_signals(CP) - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=100) - + if CP.openpilotLongitudinalControl: + signals += [ + ("BRAKE_ERROR_1", "STANDSTILL", 1), + ("BRAKE_ERROR_2", "STANDSTILL", 1) + ] + checks += [("STANDSTILL", 50)] -def get_cam_can_parser(CP): - signals = [] + return signals, checks - # all hondas except CRV, RDX and 2019 Odyssey@China use 0xe4 for steering - checks = [(0xe4, 100)] - if CP.carFingerprint in [CAR.CRV, CAR.ACURA_RDX, CAR.ODYSSEY_CHN]: - checks = [(0x194, 100)] - cam_bus = 1 if CP.carFingerprint in HONDA_BOSCH else 2 +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) + self.gearbox_msg = "GEARBOX" + if CP.carFingerprint == CAR.ACCORD and CP.transmissionType == TransmissionType.cvt: + self.gearbox_msg = "GEARBOX_15T" - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, cam_bus, timeout=100) + self.main_on_sig_msg = "SCM_FEEDBACK" + if CP.carFingerprint in HONDA_NIDEC_ALT_SCM_MESSAGES: + self.main_on_sig_msg = "SCM_BUTTONS" -class CarState(object): - 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"] + self.shifter_values = can_define.dv[self.gearbox_msg]["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.brake_switch_prev_ts = 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.stopped = 0 - # 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 @@ -207,150 +182,183 @@ 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, CAR.CRV_HYBRID): # 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.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E): + 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: - self.standstill = cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] < 0.1 - self.door_all_closed = not cp.vl["SCM_BUTTONS"]['DRIVERS_DOOR_OPEN'] + ret.standstill = cp.vl["ENGINE_DATA"]["XMISSION_SPEED"] < 0.1 + ret.doorOpen = bool(cp.vl["SCM_BUTTONS"]["DRIVERS_DOOR_OPEN"]) + elif self.CP.carFingerprint in (CAR.FREED, CAR.HRV): + ret.standstill = not cp.vl["STANDSTILL"]["WHEELS_MOVING"] + 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 = significant steering wheel torque; 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'] not in [0, 4] # 4 can be caused by bump OR steering nudge from driver - self.steer_warning = cp.vl["STEER_STATUS"]['STEER_STATUS'] not in [0, 3, 4] # 3 is low speed lockout, not worth a warning - if self.CP.radarOffCan: + 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'] + self.brake_error = cp.vl["STANDSTILL"]["BRAKE_ERROR_1"] or cp.vl["STANDSTILL"]["BRAKE_ERROR_2"] + 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 = self.get_wheel_speeds( + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FR"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RL"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RR"], + ) + v_wheel = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4.0 # 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 * self.CP.wheelSpeedFactor + 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]] + ret.steeringAngleDeg = cp.vl["STEERING_SENSORS"]["STEER_ANGLE"] + ret.steeringRateDeg = cp.vl["STEERING_SENSORS"]["STEER_ANGLE_RATE"] - 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]) + self.cruise_setting = cp.vl["SCM_BUTTONS"]["CRUISE_SETTING"] + self.cruise_buttons = cp.vl["SCM_BUTTONS"]["CRUISE_BUTTONS"] - # 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'] - self.user_gas_pressed = self.user_gas > 0 # this works because interceptor read < 0 when pedal position is 0. Once calibrated, this will change + ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_stalk( + 250, cp.vl["SCM_FEEDBACK"]["LEFT_BLINKER"], cp.vl["SCM_FEEDBACK"]["RIGHT_BLINKER"]) + ret.brakeHoldActive = cp.vl["VSA_STATUS"]["BRAKE_HOLD_ACTIVE"] == 1 - 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'] + if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY, CAR.ODYSSEY_CHN, CAR.CRV_5G, CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, + CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E): + self.park_brake = cp.vl["EPB_STATUS"]["EPB_STATE"] != 0 + else: + self.park_brake = 0 # TODO - self.cruise_setting = cp.vl["SCM_BUTTONS"]['CRUISE_SETTING'] - self.cruise_buttons = cp.vl["SCM_BUTTONS"]['CRUISE_BUTTONS'] + gear = int(cp.vl[self.gearbox_msg]["GEAR_SHIFTER"]) + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear, None)) - 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'] - self.brake_hold = cp.vl["VSA_STATUS"]['BRAKE_HOLD_ACTIVE'] + ret.gas = cp.vl["POWERTRAIN_DATA"]["PEDAL_GAS"] - if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY, CAR.CRV_5G, CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CRV_HYBRID): - self.park_brake = cp.vl["EPB_STATUS"]['EPB_STATE'] != 0 - self.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 - self.main_on = cp.vl["SCM_BUTTONS"]['MAIN_ON'] + # 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: + user_gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2. + ret.gasPressed = user_gas > 1e-5 # this works because interceptor reads < 0 when pedal position is 0. Once calibrated, this will change else: - self.park_brake = 0 # TODO - self.main_on = cp.vl["SCM_BUTTONS"]['MAIN_ON'] + ret.gasPressed = ret.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.get(self.CP.carFingerprint, 1200) - can_gear_shifter = int(cp.vl["GEARBOX"]['GEAR_SHIFTER']) - self.gear_shifter = parse_gear_shifter(can_gear_shifter, self.shifter_values) + if self.CP.carFingerprint in HONDA_BOSCH: + if not self.CP.openpilotLongitudinalControl: + ret.cruiseState.nonAdaptive = cp.vl["ACC_HUD"]["CRUISE_CONTROL_LABEL"] != 0 + ret.cruiseState.standstill = cp.vl["ACC_HUD"]["CRUISE_SPEED"] == 252. - 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, CAR.ODYSSEY_CHN): - self.car_gas = self.pedal_gas + # On set, cruise set speed pulses between 254~255 and the set speed prev is set to avoid this. + 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.car_gas = cp.vl["GAS_PEDAL_2"]['CAR_GAS'] - - self.steer_torque_driver = cp.vl["STEER_STATUS"]['STEER_TORQUE_SENSOR'] - self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD[self.CP.carFingerprint] - - self.brake_switch = cp.vl["POWERTRAIN_DATA"]['BRAKE_SWITCH'] - - if self.CP.radarOffCan: - 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, CAR.CRV_HYBRID): - 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 \ - 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_pressed = cp.vl["BRAKE_MODULE"]['BRAKE_PRESSED'] - # 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 = cp.vl["CRUISE"]["CRUISE_SPEED_PCM"] * CV.KPH_TO_MS + + self.brake_switch = cp.vl["POWERTRAIN_DATA"]["BRAKE_SWITCH"] != 0 + if self.CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL: + ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0 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'] # 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) + # panda safety only checks BRAKE_PRESSED signal + 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_prev_ts)) + self.brake_switch_prev = self.brake_switch - self.brake_switch_ts = cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] + self.brake_switch_prev_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(cp.vl[self.main_on_sig_msg]["MAIN_ON"]) # 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 self.CP.carFingerprint in (CAR.PILOT, CAR.PILOT_2019, CAR.PASSPORT, CAR.RIDGELINE): + 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) + if self.CP.carFingerprint in (CAR.CIVIC, ): + self.is_metric = not cp.vl["HUD_SETTING"]["IMPERIAL_UNIT"] + elif self.CP.carFingerprint in HONDA_BOSCH: + self.is_metric = not cp.vl["CAR_SPEED"]["IMPERIAL_UNIT"] + else: + self.is_metric = False + + if self.CP.carFingerprint in HONDA_BOSCH: + ret.stockAeb = (not self.CP.openpilotLongitudinalControl) and bool(cp.vl["ACC_CONTROL"]["AEB_STATUS"] and cp.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.enableBsm and 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 + + def get_can_parser(self, CP): + signals, checks = get_can_signals(CP, self.gearbox_msg, self.main_on_sig_msg) + 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 = [] + checks = [ + ("STEERING_CONTROL", 100), + ] + + if CP.carFingerprint not in HONDA_BOSCH: + 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)] + checks += [ + ("ACC_HUD", 10), + ("BRAKE_COMMAND", 50), + ] + + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) + + @staticmethod + def get_body_can_parser(CP): + if CP.enableBsm and CP.carFingerprint == CAR.CRV_5G: + signals = [("BSM_ALERT", "BSM_STATUS_RIGHT", 0), + ("BSM_ALERT", "BSM_STATUS_LEFT", 0)] + + checks = [ + ("BSM_STATUS_LEFT", 3), + ("BSM_STATUS_RIGHT", 3), + ] + 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 3955bfdcdc90dc..7fcafe67f85adb 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -1,25 +1,24 @@ -import struct +from selfdrive.car.honda.values import HondaFlags, HONDA_BOSCH, CAR, CarControllerParams from selfdrive.config import Conversions as CV -from selfdrive.car.honda.values import CAR, 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 create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, chime, fcw, idx): +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 @@ -32,70 +31,144 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_ "CRUISE_FAULT_CMD": pcm_fault_cmd, "CRUISE_CANCEL_CMD": pcm_cancel_cmd, "COMPUTER_BRAKE_REQUEST": brake_rq, - "SET_ME_0X80": 0x80, + "SET_ME_1": 1, "BRAKE_LIGHTS": brakelights, - "CHIME": chime, - # 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_STATUS": 0, } - return packer.make_can_msg("BRAKE_COMMAND", 0, values, idx) + 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): +def create_acc_commands(packer, enabled, active, accel, gas, idx, stopping, starting, car_fingerprint): + commands = [] + bus = get_pt_bus(car_fingerprint) + min_gas_accel = CarControllerParams.BOSCH_GAS_LOOKUP_BP[0] + + control_on = 5 if enabled else 0 + gas_command = gas if active and accel > min_gas_accel else -30000 + accel_command = accel if active else 0 + braking = 1 if active and accel < min_gas_accel else 0 + standstill = 1 if active and stopping else 0 + standstill_release = 1 if active 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, } - # Set bus 2 for accord and new crv. - bus = 2 if car_fingerprint in HONDA_BOSCH else 0 + 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): - commands = [] - bus = 0 +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) - # Bosch sends commands to bus 2. - if car_fingerprint in HONDA_BOSCH: - bus = 2 - 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': 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, - } - commands.append(packer.make_can_msg("ACC_HUD", 0, acc_hud_values, idx)) + +def create_ui_commands(packer, CP, pcm_speed, hud, is_metric, idx, stock_hud): + commands = [] + bus_pt = get_pt_bus(CP.carFingerprint) + radar_disabled = CP.carFingerprint in HONDA_BOSCH and CP.openpilotLongitudinalControl + bus_lkas = get_lkas_cmd_bus(CP.carFingerprint, radar_disabled) + + if CP.openpilotLongitudinalControl: + if CP.carFingerprint 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), + 'FCM_OFF': 1, + } + 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 = { 'SET_ME_X41': 0x41, 'SET_ME_X48': 0x48, 'STEERING_REQUIRED': hud.steer_required, 'SOLID_LANES': hud.lanes, - 'BEEP': hud.beep, + 'BEEP': 0, } - commands.append(packer.make_can_msg('LKAS_HUD', bus, lkas_hud_values, idx)) - if car_fingerprint in (CAR.CIVIC, CAR.ODYSSEY): + if not (CP.flags & HondaFlags.BOSCH_EXT_HUD): + lkas_hud_values['SET_ME_X48'] = 0x48 + if CP.flags & HondaFlags.BOSCH_EXT_HUD and not CP.openpilotLongitudinalControl: + commands.append(packer.make_can_msg('LKAS_HUD_A', bus_lkas, lkas_hud_values, idx)) + commands.append(packer.make_can_msg('LKAS_HUD_B', bus_lkas, lkas_hud_values, idx)) + else: + commands.append(packer.make_can_msg('LKAS_HUD', bus_lkas, lkas_hud_values, idx)) + + if radar_disabled and CP.carFingerprint 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, + 'CMBS_OFF': 0x01, + 'SET_TO_1': 0x01, } - commands.append(packer.make_can_msg('RADAR_HUD', 0, radar_hud_values, idx)) + commands.append(packer.make_can_msg('RADAR_HUD', bus_pt, radar_hud_values, idx)) + + if CP.carFingerprint == CAR.CIVIC_BOSCH: + commands.append(packer.make_can_msg("LEGACY_BRAKE_COMMAND", bus_pt, {}, idx)) + return commands -def spam_buttons_command(packer, button_val, idx): +def spam_buttons_command(packer, button_val, idx, car_fingerprint): values = { 'CRUISE_BUTTONS': button_val, 'CRUISE_SETTING': 0, } - return packer.make_can_msg("SCM_BUTTONS", 0, values, idx) + 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 index 93aaf0182b7db6..03074b875c107a 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -1,199 +1,132 @@ -#!/usr/bin/env python -import os -import numpy as np +#!/usr/bin/env python3 from cereal import car -from common.numpy_fast import clip, interp -from common.realtime import sec_since_boot, DT_CTRL -from selfdrive.swaglog import cloudlog +from panda import Panda +from common.numpy_fast import interp +from common.params import Params +from selfdrive.car.honda.values import CarControllerParams, CruiseButtons, HondaFlags, CAR, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_ALT_BRAKE_SIGNAL +from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config +from selfdrive.car.interfaces import CarInterfaceBase +from selfdrive.car.disable_ecu import disable_ecu 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, AUDIO_HUD, VISUAL_HUD, CAMERA_MSGS -from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness -from selfdrive.controls.lib.planner import _A_CRUISE_MAX_V_FOLLOWING - -A_ACC_MAX = max(_A_CRUISE_MAX_V_FOLLOWING) - - -def compute_gb_honda(accel, speed): - creep_brake = 0.0 - creep_speed = 2.3 - creep_brake_value = 0.15 - if speed < creep_speed: - creep_brake = (creep_speed - speed) / creep_speed * creep_brake_value - return float(accel) / 4.8 - creep_brake - - -def get_compute_gb_acura(): - # generate a function that takes in [desired_accel, current_speed] -> [-1.0, 1.0] - # where -1.0 is max brake and 1.0 is max gas - # see debug/dump_accel_from_fiber.py to see how those parameters were generated - w0 = np.array([[ 1.22056961, -0.39625418, 0.67952657], - [ 1.03691769, 0.78210306, -0.41343188]]) - b0 = np.array([ 0.01536703, -0.14335321, -0.26932889]) - w2 = np.array([[-0.59124422, 0.42899439, 0.38660881], - [ 0.79973811, 0.13178682, 0.08550351], - [-0.15651935, -0.44360259, 0.76910877]]) - b2 = np.array([ 0.15624429, 0.02294923, -0.0341086 ]) - w4 = np.array([[-0.31521443], - [-0.38626176], - [ 0.52667892]]) - b4 = np.array([-0.02922216]) - - def compute_output(dat, w0, b0, w2, b2, w4, b4): - m0 = np.dot(dat, w0) + b0 - m0 = leakyrelu(m0, 0.1) - m2 = np.dot(m0, w2) + b2 - m2 = leakyrelu(m2, 0.1) - m4 = np.dot(m2, w4) + b4 - return m4 - - def leakyrelu(x, alpha): - return np.maximum(x, alpha * x) - - def _compute_gb_acura(accel, speed): - # linearly extrap below v1 using v1 and v2 data - v1 = 5. - v2 = 10. - dat = np.array([accel, speed]) - if speed > 5.: - m4 = compute_output(dat, w0, b0, w2, b2, w4, b4) - else: - dat[1] = v1 - m4v1 = compute_output(dat, w0, b0, w2, b2, w4, b4) - dat[1] = v2 - m4v2 = compute_output(dat, w0, b0, w2, b2, w4, b4) - m4 = (speed - v1) * (m4v2 - m4v1) / (v2 - v1) + m4v1 - return float(m4) - - return _compute_gb_acura - - -class CarInterface(object): - def __init__(self, CP, CarController): - self.CP = CP - - 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) +ButtonType = car.CarState.ButtonEvent.Type +EventName = car.CarEvent.EventName +TransmissionType = car.CarParams.TransmissionType - 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() +class CarInterface(CarInterfaceBase): + @staticmethod + def get_pid_accel_limits(CP, current_speed, cruise_speed): + if CP.carFingerprint in HONDA_BOSCH: + return CarControllerParams.BOSCH_ACCEL_MIN, CarControllerParams.BOSCH_ACCEL_MAX else: - self.compute_gb = compute_gb_honda + # NIDECs don't allow acceleration near cruise_speed, + # so limit limits of pid to prevent windup + ACCEL_MAX_VALS = [CarControllerParams.NIDEC_ACCEL_MAX, 0.2] + ACCEL_MAX_BP = [cruise_speed - 2., cruise_speed - .2] + return CarControllerParams.NIDEC_ACCEL_MIN, interp(current_speed, ACCEL_MAX_BP, ACCEL_MAX_VALS) @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 = interp(v_ego, max_accel_bp, max_accel_v) - - # limit the pcm accel cmd if: - # - v_ego exceeds v_target, or - # - a_ego exceeds a_target and v_ego is close to v_target + 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" - eA = a_ego - a_target - valuesA = [1.0, 0.1] - bpA = [0.3, 1.1] + if candidate in HONDA_BOSCH: + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hondaBosch)] + ret.radarOffCan = True - eV = v_ego - v_target - valuesV = [1.0, 0.1] - bpV = [0.0, 0.5] + # Disable the radar and let openpilot control longitudinal + # WARNING: THIS DISABLES AEB! + ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar") - valuesRangeV = [1., 0.] - bpRangeV = [-1., 0.] + ret.pcmCruise = not ret.openpilotLongitudinalControl + else: + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hondaNidec)] + ret.enableGasInterceptor = 0x201 in fingerprint[0] + ret.openpilotLongitudinalControl = True - # only limit if v_ego is close to v_target - speedLimiter = interp(eV, bpV, valuesV) - accelLimiter = max(interp(eA, bpA, valuesA), interp(eV, bpRangeV, valuesRangeV)) + ret.pcmCruise = not ret.enableGasInterceptor + ret.communityFeature = ret.enableGasInterceptor - # 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 + if candidate == CAR.CRV_5G: + ret.enableBsm = 0x12f8bfa7 in fingerprint[0] - return float(max(max_accel, a_target / A_ACC_MAX)) * min(speedLimiter, accelLimiter) + # Detect Bosch cars with new HUD msgs + if any(0x33DA in f for f in fingerprint.values()): + ret.flags |= HondaFlags.BOSCH_EXT_HUD.value - @staticmethod - def get_params(candidate, fingerprint, vin=""): + # Accord 1.5T CVT has different gearbox message + if candidate == CAR.ACCORD and 0x191 in fingerprint[1]: + ret.transmissionType = TransmissionType.cvt - ret = car.CarParams.new_message() - ret.carName = "honda" - ret.carFingerprint = candidate - ret.carVin = vin + # 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 if candidate in HONDA_BOSCH: - ret.safetyModel = car.CarParams.SafetyModel.hondaBosch - ret.enableCamera = True - ret.radarOffCan = True - ret.openpilotLongitudinalControl = False + ret.longitudinalTuning.kpV = [0.25] + ret.longitudinalTuning.kiV = [0.05] + ret.longitudinalActuatorDelayUpperBound = 0.5 # s else: - ret.safetyModel = car.CarParams.SafetyModel.honda - ret.enableCamera = not any(x for x in CAMERA_MSGS if x in fingerprint) - ret.enableGasInterceptor = 0x201 in fingerprint - ret.openpilotLongitudinalControl = ret.enableCamera - - cloudlog.warn("ECU Camera Simulated: %r", ret.enableCamera) - cloudlog.warn("ECU Gas Interceptor: %r", ret.enableGasInterceptor) - - ret.enableCruise = not 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. - # 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" + # default longitudinal tuning for all hondas + 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] - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward + eps_modified = False + for fw in car_fw: + if fw.ecu == "eps" and b"," in fw.fwVersion: + eps_modified = True - if candidate in [CAR.CIVIC, CAR.CIVIC_BOSCH]: + if candidate == CAR.CIVIC: stop_and_go = True ret.mass = CivicParams.MASS ret.wheelbase = CivicParams.WHEELBASE ret.centerToFront = CivicParams.CENTER_TO_FRONT - ret.steerRatio = 14.63 # 10.93 is end-to-end spec + 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 ['99c94dc769b5d96e'] - 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]] - elif candidate in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH): + elif candidate in (CAR.ACCORD, 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 ret.mass = 3279. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.83 ret.centerToFront = ret.wheelbase * 0.39 - ret.steerRatio = 15.96 # 11.82 is spec end-to-end + 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 @@ -201,123 +134,185 @@ def get_params(candidate, fingerprint, vin=""): 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.] - ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] - 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 = 15.3 # 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] - ret.longitudinalTuning.kiBP = [0., 35.] - ret.longitudinalTuning.kiV = [0.18, 0.12] + ret.wheelSpeedFactor = 1.025 elif candidate == CAR.CRV_5G: stop_and_go = True - ret.safetyParam = 1 # Accord and CRV 5G 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.] - ret.longitudinalTuning.kiV = [0.18, 0.12] + ret.wheelSpeedFactor = 1.025 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.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.] - ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] - ret.longitudinalTuning.kiBP = [0., 35.] - ret.longitudinalTuning.kiV = [0.18, 0.12] + ret.wheelSpeedFactor = 1.025 + + 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.2], [0.05]] + + elif candidate == CAR.FREED: + stop_and_go = False + ret.mass = 3086. * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.74 + # the remaining parameters were copied from FIT + ret.centerToFront = ret.wheelbase * 0.39 + ret.steerRatio = 13.06 + ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] + tire_stiffness_factor = 0.75 + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] + + 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.wheelSpeedFactor = 1.025 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.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 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.] - ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] - ret.longitudinalTuning.kiBP = [0., 35.] - ret.longitudinalTuning.kiV = [0.18, 0.12] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.28], [0.08]] 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.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] - ret.longitudinalTuning.kiBP = [0., 35.] - ret.longitudinalTuning.kiV = [0.18, 0.12] + 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.28], [0.08]] 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 = 16.0 # 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]] + + elif candidate == CAR.PASSPORT: + stop_and_go = False + ret.mass = 4204. * CV.LB_TO_KG + STD_CARGO_KG # average weight + ret.wheelbase = 2.82 + 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] - ret.longitudinalTuning.kiBP = [0., 35.] - ret.longitudinalTuning.kiV = [0.18, 0.12] elif candidate == CAR.RIDGELINE: stop_and_go = 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]] + + elif candidate == CAR.HONDA_E: + stop_and_go = True + ret.mass = 3338.8 * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.5 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 16.71 + 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]] # TODO: can probably use some tuning else: raise ValueError("unsupported car %s" % candidate) - ret.steerControlType = car.CarParams.SteerControlType.torque + # These cars use alternate user brake msg (0x1BE) + if candidate in HONDA_BOSCH_ALT_BRAKE_SIGNAL: + ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HONDA_ALT_BRAKE + + # These cars use alternate SCM messages (SCM_FEEDBACK AND SCM_BUTTON) + if candidate in HONDA_NIDEC_ALT_SCM_MESSAGES: + ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HONDA_NIDEC_ALT + + if ret.openpilotLongitudinalControl and candidate in HONDA_BOSCH: + ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HONDA_BOSCH_LONG # 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 @@ -333,110 +328,35 @@ def get_params(candidate, fingerprint, vin=""): 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 - 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 + @staticmethod + def init(CP, logcan, sendcan): + if CP.carFingerprint in HONDA_BOSCH and CP.openpilotLongitudinalControl: + disable_ecu(logcan, sendcan, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03') + # returns a car.CarState - def update(self, c): + def update(self, c, can_strings): # ******************* do can recv ******************* - canMonoTimes = [] - can_rcv_valid, _ = self.cp.update(int(sec_since_boot() * 1e9), True) - cam_rcv_valid, _ = self.cp_cam.update(int(sec_since_boot() * 1e9), False) - - self.CS.update(self.cp, self.cp_cam) - - # create message - ret = car.CarState.new_message() - - ret.canValid = can_rcv_valid and cam_rcv_valid and 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 - - # brake pedal - ret.brake = self.CS.user_brake - ret.brakePressed = self.CS.brake_pressed != 0 - # 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.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) - 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) + 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.doorOpen = not self.CS.door_all_closed - ret.seatbeltUnlatched = not self.CS.seatbelt + ret = self.CS.update(self.cp, self.cp_cam, self.cp_body) - 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) + 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.steeringAngleDeg * CV.DEG_TO_RAD, ret.vEgo) - 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) + buttonEvents = [] 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 @@ -444,18 +364,18 @@ def update(self, c): 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 @@ -463,98 +383,52 @@ def update(self, c): 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: - 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.brake_hold and self.CS.CP.carFingerprint not in HONDA_BOSCH: - events.append(create_event('brakeHold', [ET.NO_ENTRY, ET.USER_DISABLE])) + events.add(EventName.brakeUnavailable) if self.CS.park_brake: - events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE])) - - 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])) - - # 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])) - else: - events.append(create_event("cruiseDisabled", [ET.IMMEDIATE_DISABLE])) + events.add(EventName.parkBrake) + + if self.CP.pcmCruise and ret.vEgo < self.CP.minEnableSpeed: + events.add(EventName.belowEngageSpeed) + + if self.CP.pcmCruise: + # we engage when pcm is active (rising edge) + if ret.cruiseState.enabled and not self.CS.out.cruiseState.enabled: + events.add(EventName.pcmEnable) + elif not ret.cruiseState.enabled and (c.actuators.accel >= 0. or not self.CP.openpilotLongitudinalControl): + # 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 ret.vEgo < self.CP.minEnableSpeed + 2.: + # non loud alert if cruise disables below 25mph as expected (+ a little margin) + events.add(EventName.speedTooLow) + else: + 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 # 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: - self.last_enable_pressed = cur_time - enable_pressed = True + if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: + if not self.CP.pcmCruise: + events.add(EventName.buttonEnable) # do disable on button down - if b.type == "cancel" and b.pressed: - events.append(create_event('buttonCancel', [ET.USER_DISABLE])) - - 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 - (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])) - self.last_enable_sent = cur_time - elif enable_pressed: - events.append(create_event('buttonEnable', [ET.ENABLE])) - - ret.events = events - ret.canMonoTimes = canMonoTimes - - # 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() + if b.type == ButtonType.cancel and b.pressed: + events.add(EventName.buttonCancel) + + ret.events = events.to_msg() + + self.CS.out = ret.as_reader() + return self.CS.out # pass in a car.CarControl # to be called @ 100hz @@ -564,23 +438,13 @@ def apply(self, c): else: hud_v_cruise = 255 - hud_alert = VISUAL_HUD[c.hudControl.visualAlert.raw] - snd_beep, snd_chime = AUDIO_HUD[c.hudControl.audibleAlert.raw] - - pcm_accel = int(clip(c.cruiseControl.accelOverride, 0, 1) * 0xc6) - - can_sends = self.CC.update(c.enabled, self.CS, self.frame, + can_sends = self.CC.update(c.enabled, c.active, self.CS, self.frame, c.actuators, - c.cruiseControl.speedOverride, - c.cruiseControl.override, c.cruiseControl.cancel, - pcm_accel, hud_v_cruise, c.hudControl.lanesVisible, hud_show_car=c.hudControl.leadVisible, - hud_alert=hud_alert, - snd_beep=snd_beep, - snd_chime=snd_chime) + 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 94e98cf2cb3351..45e015af6e7f73 100755 --- a/selfdrive/car/honda/radar_interface.py +++ b/selfdrive/car/honda/radar_interface.py @@ -1,57 +1,59 @@ -#!/usr/bin/env python -import os -import time +#!/usr/bin/env python3 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])) + checks = [(s[1], 20) for s in signals] + return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) - return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1) - -class RadarInterface(object): +class RadarInterface(RadarInterfaceBase): def __init__(self, CP): - # radar - self.pts = {} + super().__init__(CP) self.track_id = 0 self.radar_fault = False self.radar_wrong_config = 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() - - def update(self): - canMonoTimes = [] - - updated_messages = set() - ret = car.RadarData.new_message() + 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() + 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 ret + return super().update(None) + + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - while 1: - tm = int(sec_since_boot() * 1e9) - _, vls = self.rcp.update(tm, True) - updated_messages.update(vls) - if 0x445 in updated_messages: - break + if self.trigger_msg not in self.updated_messages: + return None - for ii in updated_messages: + rr = self._update(self.updated_messages) + self.updated_messages.clear() + return rr + + def _update(self, updated_messages): + ret = car.RadarData.new_message() + + for ii in sorted(updated_messages): cpt = self.rcp.vl[ii] if ii == 0x400: # check for radar faults @@ -80,19 +82,7 @@ def update(self): if self.radar_wrong_config: errors.append("wrongConfig") ret.errors = errors - ret.canMonoTimes = canMonoTimes - ret.points = self.pts.values() + ret.points = list(self.pts.values()) return ret - - -if __name__ == "__main__": - class CarParams: - radarOffCan = False - - RI = RadarInterface(CarParams) - while 1: - ret = RI.update() - print(chr(27) + "[2J") - print(ret) diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py index 8b4d13bf75d5e5..083a52bb863d9c 100644 --- a/selfdrive/car/honda/values.py +++ b/selfdrive/car/honda/values.py @@ -1,201 +1,1393 @@ +from enum import IntFlag + from cereal import car from selfdrive.car import dbc_dict -AudibleAlert = car.CarControl.HUDControl.AudibleAlert +Ecu = car.CarParams.Ecu VisualAlert = car.CarControl.HUDControl.VisualAlert + +class CarControllerParams(): + # Allow small margin below -3.5 m/s^2 from ISO 15622:2018 since we + # perform the closed loop control, and might need some + # to apply some more braking if we're on a downhill slope. + # Our controller should still keep the 2 second average above + # -3.5 m/s^2 as per planner limits + NIDEC_ACCEL_MIN = -4.0 # m/s^2 + NIDEC_ACCEL_MAX = 1.6 # m/s^2, lower than 2.0 m/s^2 for tuning reasons + + NIDEC_ACCEL_LOOKUP_BP = [-1., 0., .6] + NIDEC_ACCEL_LOOKUP_V = [-4.8, 0., 2.0] + + NIDEC_MAX_ACCEL_V = [0.5, 2.4, 1.4, 0.6] + NIDEC_MAX_ACCEL_BP = [0.0, 4.0, 10., 20.] + + NIDEC_BRAKE_MAX = 1024 // 4 + + BOSCH_ACCEL_MIN = -3.5 # m/s^2 + BOSCH_ACCEL_MAX = 2.0 # m/s^2 + + BOSCH_GAS_LOOKUP_BP = [-0.2, 2.0] # 2m/s^2 + BOSCH_GAS_LOOKUP_V = [0, 1600] + + def __init__(self, CP): + 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 HondaFlags(IntFlag): + # Bosch models with alternate set of LKAS_HUD messages + BOSCH_EXT_HUD = 1 + + # Car button codes class CruiseButtons: - RES_ACCEL = 4 - DECEL_SET = 3 - CANCEL = 2 - MAIN = 1 - -#car chimes: enumeration from dbc file. Chimes are for alerts and warnings -class CM: - MUTE = 0 - SINGLE = 3 - DOUBLE = 4 - REPEATED = 1 - CONTINUOUS = 2 - -#car beeps: enumeration from dbc file. Beeps are for engage and disengage -class BP: - MUTE = 0 - SINGLE = 3 - TRIPLE = 2 - REPEATED = 1 - -AUDIO_HUD = { - AudibleAlert.none: (BP.MUTE, CM.MUTE), - AudibleAlert.chimeEngage: (BP.SINGLE, CM.MUTE), - AudibleAlert.chimeDisengage: (BP.SINGLE, CM.MUTE), - AudibleAlert.chimeError: (BP.MUTE, CM.DOUBLE), - AudibleAlert.chimePrompt: (BP.MUTE, CM.SINGLE), - AudibleAlert.chimeWarning1: (BP.MUTE, CM.DOUBLE), - AudibleAlert.chimeWarning2: (BP.MUTE, CM.REPEATED), - AudibleAlert.chimeWarningRepeat: (BP.MUTE, CM.REPEATED)} - -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.ldw: 1, + VisualAlert.brakePressed: 10, + VisualAlert.wrongGear: 6, + VisualAlert.seatbeltUnbuckled: 5, + VisualAlert.speedTooHigh: 8 +} class CAR: - ACCORD = "HONDA ACCORD 2018 SPORT 2T" - ACCORD_15 = "HONDA ACCORD 2018 LX 1.5T" - ACCORDH = "HONDA ACCORD 2018 HYBRID TOURING" - CIVIC = "HONDA CIVIC 2016 TOURING" - CIVIC_BOSCH = "HONDA CIVIC HATCHBACK 2017 SEDAN/COUPE 2019" - ACURA_ILX = "ACURA ILX 2016 ACURAWATCH PLUS" - CRV = "HONDA CR-V 2016 TOURING" - CRV_5G = "HONDA CR-V 2017 EX" - CRV_HYBRID = "HONDA CR-V 2019 HYBRID" - ODYSSEY = "HONDA ODYSSEY 2018 EX-L" - ODYSSEY_CHN = "HONDA ODYSSEY 2019 EXCLUSIVE CHN" - ACURA_RDX = "ACURA RDX 2018 ACURAWATCH PLUS" - PILOT = "HONDA PILOT 2017 TOURING" - PILOT_2019 = "HONDA PILOT 2019 ELITE" - RIDGELINE = "HONDA RIDGELINE 2017 BLACK EDITION" - -FINGERPRINTS = { - CAR.ACCORD: [{ - 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 419: 8, 420: 8, 427: 3, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8 - }], - CAR.ACCORD_15: [{ - 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8 - }], - CAR.ACCORDH: [{ - 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, 477: 8, 479: 8, 495: 8, 525: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8 - }], - CAR.ACURA_ILX: [{ - 57: 3, 145: 8, 228: 5, 304: 8, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 419: 8, 420: 8, 422: 8, 428: 8, 432: 7, 464: 8, 476: 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, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1030: 5, 1034: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1365: 5, - }], - # Acura RDX w/ Added Comma Pedal Support (512L & 513L) - 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.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, - }], - 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 - }], - 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 - }], - # 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 - }, - # 2018 Odyssey Elite w/ Added Comma Pedal Support (512L & 513L) - { - 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 - }], - # 2017 Pilot Touring AND 2016 Pilot EX-L w/ Added Comma Pedal Support (512L & 513L) - CAR.PILOT: [{ - 57: 3, 145: 8, 228: 5, 229: 4, 308: 5, 316: 8, 334: 8, 339: 7, 342: 6, 344: 8, 379: 8, 380: 8, 392: 6, 399: 7, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 507: 1, 512: 6, 513: 6, 538: 3, 542: 7, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 837: 5, 856: 7, 871: 8, 882: 2, 884: 7, 891: 8, 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, 1108: 8, 1125: 8, 1296: 8, 1424: 5, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1616: 5, 1618: 5, 1668: 5 - }], - # this fingerprint also includes the Passport 2019 - CAR.PILOT_2019: [{ - 57: 3, 145: 8, 228: 5, 308: 5, 316: 8, 334: 8, 342: 6, 344: 8, 379: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 538: 3, 542: 7, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 871: 8, 881: 8, 882: 2, 884: 7, 891: 8, 892: 8, 923: 2, 927: 8, 929: 8, 983: 8, 985: 3, 1029: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1424: 5, 1445: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1615: 8, 1616: 5, 1617: 8, 1618: 5, 1623: 5, 1668: 5 - }, - # 2019 Pilot EX-L - { - 57: 3, 145: 8, 228: 5, 229: 4, 308: 5, 316: 8, 339: 7, 342: 6, 344: 8, 380: 8, 392: 6, 399: 7, 411: 5, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 464: 8, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 542: 7, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 817: 4, 819: 7, 821: 5, 829: 5, 871: 8, 881: 8, 882: 2, 884: 7, 891: 8, 892: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1027: 5, 1029: 8, 1039: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1125: 8, 1296: 8, 1424: 5, 1445: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1616: 5, 1617: 8, 1618: 5, 1623: 5, 1668: 5 - }], - # Ridgeline w/ Added Comma Pedal Support (512L & 513L) - CAR.RIDGELINE: [{ - 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, 471: 3, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 871: 8, 882: 2, 884: 7, 892: 8, 923: 2, 927: 8, 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, 1108: 8, 1125: 8, 1296: 8, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1613: 5, 1616: 5, 1618: 5, 1668: 5, 2015: 3 - }, - # 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 - }] + ACCORD = "HONDA ACCORD 2018" + ACCORDH = "HONDA ACCORD HYBRID 2018" + CIVIC = "HONDA CIVIC 2016" + CIVIC_BOSCH = "HONDA CIVIC (BOSCH) 2019" + CIVIC_BOSCH_DIESEL = "HONDA CIVIC SEDAN 1.6 DIESEL 2019" + ACURA_ILX = "ACURA ILX 2016" + CRV = "HONDA CR-V 2016" + CRV_5G = "HONDA CR-V 2017" + CRV_EU = "HONDA CR-V EU 2016" + CRV_HYBRID = "HONDA CR-V HYBRID 2019" + FIT = "HONDA FIT 2018" + FREED = "HONDA FREED 2020" + HRV = "HONDA HRV 2019" + ODYSSEY = "HONDA ODYSSEY 2018" + ODYSSEY_CHN = "HONDA ODYSSEY CHN 2019" + ACURA_RDX = "ACURA RDX 2018" + ACURA_RDX_3G = "ACURA RDX 2020" + PILOT = "HONDA PILOT 2017" + PILOT_2019 = "HONDA PILOT 2019" + PASSPORT = "HONDA PASSPORT 2021" + RIDGELINE = "HONDA RIDGELINE 2017" + INSIGHT = "HONDA INSIGHT 2019" + HONDA_E = "HONDA E 2020" + +FW_VERSIONS = { + CAR.ACCORD: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-6A0-8720\x00\x00', + b'37805-6A0-9520\x00\x00', + b'37805-6A0-9620\x00\x00', + b'37805-6A0-9720\x00\x00', + b'37805-6A0-A540\x00\x00', + b'37805-6A0-A550\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-AF30\x00\x00', + b'37805-6A0-AG30\x00\x00', + b'37805-6B2-C520\x00\x00', + b'37805-6A0-C540\x00\x00', + b'37805-6A1-H650\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-A810\x00\x00', + b'37805-6B2-A820\x00\x00', + b'37805-6B2-A920\x00\x00', + b'37805-6B2-M520\x00\x00', + b'37805-6B2-Y810\x00\x00', + b'37805-6M4-B730\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TVC-A910\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-A410\x00\x00', + b'28101-6A7-A510\x00\x00', + b'28101-6A7-A610\x00\x00', + b'28101-6A7-A710\x00\x00', + b'28101-6A9-H140\x00\x00', + b'28101-6A9-H420\x00\x00', + b'28102-6B8-A560\x00\x00', + b'28102-6B8-A570\x00\x00', + b'28102-6B8-A700\x00\x00', + b'28102-6B8-A800\x00\x00', + b'28102-6B8-C560\x00\x00', + b'28102-6B8-C570\x00\x00', + b'28102-6B8-M520\x00\x00', + b'28102-6B8-R700\x00\x00', + ], + (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ + b'46114-TVA-A060\x00\x00', + b'46114-TVA-A080\x00\x00', + b'46114-TVA-A120\x00\x00', + b'46114-TVA-A320\x00\x00', + b'46114-TVA-A050\x00\x00', + b'46114-TVE-H550\x00\x00', + b'46114-TVE-H560\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TVA-B040\x00\x00', + b'57114-TVA-B050\x00\x00', + b'57114-TVA-B060\x00\x00', + b'57114-TVA-B530\x00\x00', + b'57114-TVA-C040\x00\x00', + b'57114-TVA-C050\x00\x00', + b'57114-TVA-C060\x00\x00', + b'57114-TVA-C530\x00\x00', + b'57114-TVA-E520\x00\x00', + b'57114-TVE-H250\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TBX-H120\x00\x00', + b'39990-TVA-A140\x00\x00', + b'39990-TVA-A150\x00\x00', + b'39990-TVA-A160\x00\x00', + b'39990-TVA-A340\x00\x00', + b'39990-TVA-X030\x00\x00', + b'39990-TVA-X040\x00\x00', + b'39990-TVA,A150\x00\x00', + b'39990-TVE-H130\x00\x00', + ], + (Ecu.unknown, 0x18da3af1, None): [ + b'39390-TVA-A020\x00\x00', + b'39390-TVA-A120\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TBX-H230\x00\x00', + b'77959-TVA-A460\x00\x00', + b'77959-TVA-F330\x00\x00', + b'77959-TVA-H230\x00\x00', + b'77959-TVA-L420\x00\x00', + b'77959-TVA-X330\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TBX-H310\x00\x00', + b'78109-TVA-A010\x00\x00', + b'78109-TVA-A020\x00\x00', + b'78109-TVA-A030\x00\x00', + b'78109-TVA-A110\x00\x00', + b'78109-TVA-A120\x00\x00', + b'78109-TVA-A210\x00\x00', + b'78109-TVA-A220\x00\x00', + b'78109-TVA-A230\x00\x00', + b'78109-TVA-A310\x00\x00', + b'78109-TVA-C010\x00\x00', + b'78109-TVA-L010\x00\x00', + b'78109-TVA-L210\x00\x00', + b'78109-TVA-R310\x00\x00', + b'78109-TVC-A010\x00\x00', + b'78109-TVC-A020\x00\x00', + b'78109-TVC-A030\x00\x00', + b'78109-TVC-A110\x00\x00', + b'78109-TVC-A130\x00\x00', + b'78109-TVC-A210\x00\x00', + b'78109-TVC-A220\x00\x00', + b'78109-TVC-A230\x00\x00', + b'78109-TVC-C010\x00\x00', + b'78109-TVC-C110\x00\x00', + b'78109-TVC-L010\x00\x00', + b'78109-TVC-L210\x00\x00', + b'78109-TVC-M510\x00\x00', + b'78109-TVC-YF10\x00\x00', + b'78109-TVE-H610\x00\x00', + b'78109-TWA-A210\x00\x00', + ], + (Ecu.hud, 0x18da61f1, None): [ + b'78209-TVA-A010\x00\x00', + b'78209-TVA-A110\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TBX-H140\x00\x00', + b'36802-TVA-A150\x00\x00', + b'36802-TVA-A160\x00\x00', + b'36802-TVA-A170\x00\x00', + b'36802-TVA-A330\x00\x00', + b'36802-TVC-A330\x00\x00', + b'36802-TVE-H070\x00\x00', + b'36802-TWA-A070\x00\x00', + b'36802-TWA-A080\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TBX-H130\x00\x00', + b'36161-TVA-A060\x00\x00', + b'36161-TVA-A330\x00\x00', + b'36161-TVC-A330\x00\x00', + b'36161-TVE-H050\x00\x00', + b'36161-TWA-A070\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TVA-A010\x00\x00', + b'38897-TVA-A020\x00\x00', + b'38897-TVA-A230\x00\x00', + b'38897-TVA-A240\x00\x00', + ], + }, + CAR.ACCORDH: { + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TWA-A120\x00\x00', + b'38897-TWD-J020\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TWA-A040\x00\x00', + b'57114-TWA-A050\x00\x00', + b'57114-TWA-A530\x00\x00', + b'57114-TWA-B520\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TWA-A440\x00\x00', + b'77959-TWA-L420\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TWA-A010\x00\x00', + b'78109-TWA-A020\x00\x00', + b'78109-TWA-A030\x00\x00', + b'78109-TWA-A110\x00\x00', + b'78109-TWA-A120\x00\x00', + b'78109-TWA-A130\x00\x00', + b'78109-TWA-A210\x00\x00', + b'78109-TWA-A220\x00\x00', + b'78109-TWA-A230\x00\x00', + b'78109-TWA-L010\x00\x00', + b'78109-TWA-L210\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TWA-A910\x00\x00', + ], + (Ecu.hud, 0x18da61f1, None): [ + b'78209-TVA-A010\x00\x00', + b'78209-TVA-A110\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TWA-A070\x00\x00', + b'36161-TWA-A330\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TWA-A070\x00\x00', + b'36802-TWA-A080\x00\x00', + b'36802-TWA-A330\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TVA-A160\x00\x00', + b'39990-TVA-A150\x00\x00', + b'39990-TVA-A340\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-C640\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-5AA-L810\000\000', + b'37805-5AG-Q710\x00\x00', + b'37805-5AJ-A610\x00\x00', + b'37805-5AJ-A620\x00\x00', + b'37805-5AJ-L610\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-A930\x00\x00', + b'37805-5BA-A960\x00\x00', + b'37805-5BA-C860\x00\x00', + b'37805-5BA-L410\x00\x00', + b'37805-5BA-L760\x00\x00', + b'37805-5BA-L930\x00\x00', + b'37805-5BA-L940\x00\x00', + b'37805-5BA-L960\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-A320\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', + ], + (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', # modified firmware + b'39990-TBA-A030\x00\x00', + b'39990-TBG-A030\x00\x00', + b'39990-TEA-T020\x00\x00', + b'39990-TEG-A010\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-TBA-C520\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-A510\x00\x00', + b'78109-TBH-A530\x00\x00', + b'78109-TED-Q510\x00\x00', + b'78109-TEG-A310\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-TED-Q320\x00\x00', + b'36161-TEG-A010\x00\x00', + b'36161-TEG-A020\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-C950\x00\x00', + b'37805-5AA-L940\x00\x00', + b'37805-5AA-L950\x00\x00', + b'37805-5AG-Z910\x00\x00', + b'37805-5AJ-A750\x00\x00', + b'37805-5AJ-L750\x00\x00', + b'37805-5AK-T530\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-AK10\x00\x00', + b'37805-5AN-AK20\x00\x00', + b'37805-5AN-AR10\x00\x00', + b'37805-5AN-AR20\x00\x00', + b'37805-5AN-CH20\x00\x00', + b'37805-5AN-E630\x00\x00', + b'37805-5AN-E720\x00\x00', + b'37805-5AN-E820\x00\x00', + b'37805-5AN-J820\x00\x00', + b'37805-5AN-L840\x00\x00', + b'37805-5AN-L930\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-5AZ-G540\x00\x00', + b'37805-5AZ-G740\x00\x00', + b'37805-5AZ-G840\x00\x00', + b'37805-5BB-A530\x00\x00', + b'37805-5BB-A540\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-C640\x00\x00', + b'37805-5BB-L540\x00\x00', + b'37805-5BB-L630\x00\x00', + b'37805-5BB-L640\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-5CG-L020\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-5CK-G210\x00\x00', + b'28101-5CK-J710\x00\x00', + b'28101-5CK-Q610\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', + b'28101-5DV-E820\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TBG-A330\x00\x00', + 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-G320\x00\x00', + b'57114-TGG-L320\x00\x00', + b'57114-TGG-L330\x00\x00', + b'57114-TGK-T320\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-TEA-T820\x00\x00', + b'39990-TEZ-T020\x00\x00', + b'39990-TGG-A020\x00\x00', + b'39990-TGG-A120\x00\x00', + b'39990-TGG-J510\x00\x00', + b'39990-TGL-E130\x00\x00', + b'39990-TGN-E120\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TBA-A060\x00\x00', + b'77959-TBG-A050\x00\x00', + b'77959-TEA-G020\x00\x00', + b'77959-TGG-A020\x00\x00', + b'77959-TGG-A030\x00\x00', + b'77959-TGG-E010\x00\x00', + b'77959-TGG-G010\x00\x00', + b'77959-TGG-G110\x00\x00', + b'77959-TGG-J320\x00\x00', + b'77959-TGG-Z820\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-TBC-C540\x00\x00', + b'78109-TBG-A110\x00\x00', + b'78109-TBH-A710\x00\x00', + b'78109-TEG-A720\x00\x00', + b'78109-TFJ-G020\x00\x00', + b'78109-TGG-9020\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-TGG-C220\x00\x00', + b'78109-TGG-E110\x00\x00', + b'78109-TGG-G030\x00\x00', + b'78109-TGG-G230\x00\x00', + b'78109-TGG-G410\x00\x00', + b'78109-TGK-Z410\x00\x00', + b'78109-TGL-G120\x00\x00', + b'78109-TGL-G130\x00\x00', + b'78109-TGL-G210\x00\x00', + b'78109-TGL-G230\x00\x00', + b'78109-TGL-GM10\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TBA-A150\x00\x00', + b'36802-TBA-A160\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-TGG-G040\x00\x00', + b'36802-TGG-G130\x00\x00', + b'36802-TGK-Q120\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-TGG-G050\x00\x00', + b'36161-TGG-G130\x00\x00', + b'36161-TGG-G140\x00\x00', + b'36161-TGK-Q120\x00\x00', + b'36161-TGL-G050\x00\x00', + b'36161-TGL-G070\x00\x00', + b'36161-TGG-G070\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TBA-A110\x00\x00', + b'38897-TBA-A020\x00\x00', + ], + (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ + b'39494-TGL-G030\x00\x00', + ], + }, + CAR.CIVIC_BOSCH_DIESEL: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-59N-G630\x00\x00', + b'37805-59N-G830\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-59Y-G220\x00\x00', + 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', + b'77959-TGN-G220\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TFK-G020\x00\x00', + b'78109-TGN-G120\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TFK-G130\x00\x00', + b'36802-TGN-G130\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TGN-E010\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TFK-G130\x00\x00', + b'36161-TGN-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', + b'57114-T1W-A240\x00\x00', + b'57114-TFF-A940\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-T0A-A230\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-T1W-A210\x00\x00', + b'78109-T1W-C210\x00\x00', + b'78109-T1X-A210\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36161-T1W-A830\x00\x00', + b'36161-T1W-C830\x00\x00', + b'36161-T1X-A830\x00\x00', + ], + }, + CAR.CRV_5G: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-5PA-AH20\x00\x00', + b'37805-5PA-3060\x00\x00', + b'37805-5PA-3080\x00\x00', + b'37805-5PA-3180\x00\x00', + b'37805-5PA-4050\x00\x00', + b'37805-5PA-4150\x00\x00', + b'37805-5PA-6520\x00\x00', + b'37805-5PA-6530\x00\x00', + b'37805-5PA-6630\x00\x00', + b'37805-5PA-6640\x00\x00', + b'37805-5PA-7630\x00\x00', + b'37805-5PA-9630\x00\x00', + b'37805-5PA-9640\x00\x00', + b'37805-5PA-9730\x00\x00', + b'37805-5PA-9830\x00\x00', + b'37805-5PA-9840\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-5PA-AB10\x00\x00', + b'37805-5PA-AD10\x00\x00', + b'37805-5PA-AF20\x00\x00', + b'37805-5PA-C680\x00\x00', + b'37805-5PD-Q630\x00\x00', + b'37805-5PF-F730\x00\x00', + b'37805-5PF-M630\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', + b'28101-5RM-F010\x00\x00', + b'28101-5RM-K010\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-Z040\x00\x00', + b'57114-TMC-Z050\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TLA-A040\x00\x00', + b'39990-TLA-A110\x00\x00', + b'39990-TLA-A220\x00\x00', + b'39990-TLA,A040\x00\x00', # modified firmware + b'39990-TME-T030\x00\x00', + b'39990-TME-T120\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-A120\x00\x00', + b'78109-TLA-A210\x00\x00', + b'78109-TLA-A220\x00\x00', + b'78109-TLA-C020\x00\x00', + b'78109-TLA-C110\x00\x00', + b'78109-TLA-C210\x00\x00', + b'78109-TLA-C310\x00\x00', + b'78109-TLB-A020\x00\x00', + b'78109-TLB-A110\x00\x00', + b'78109-TLB-A120\x00\x00', + b'78109-TLB-A210\x00\x00', + b'78109-TLB-A220\x00\x00', + b'78109-TMC-Q210\x00\x00', + b'78109-TMM-F210\x00\x00', + b'78109-TMM-M110\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-Q040\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-Q020\x00\x00', + b'36161-TMC-Q030\x00\x00', + b'36161-TMC-Q040\x00\x00', + b'36161-TNY-A020\x00\x00', + b'36161-TNY-A030\x00\x00', + b'36161-TNY-A040\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-A410\x00\x00', + b'77959-TLA-A420\x00\x00', + b'77959-TLA-Q040\x00\x00', + b'77959-TLA-Z040\x00\x00', + b'77959-TMM-F040\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', + b'38897-TPG-A210\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TMB-H510\x00\x00', + b'54008-TMB-H610\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'36161-TMB-H040\x00\x00', + b'36161-TPA-E050\x00\x00', + b'36161-TPG-A030\x00\x00', + b'36161-TPG-A040\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TMB-H220\x00\x00', + b'78109-TPA-G520\x00\x00', + b'78109-TPG-A110\x00\x00', + b'78109-TPG-A210\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-C320\x00\x00', + b'77959-TLA-C410\x00\x00', + b'77959-TLA-C420\x00\x00', + b'77959-TLA-G220\x00\x00', + b'77959-TLA-H240\x00\x00', + ], + }, + CAR.FIT: { + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-T5R-L020\x00\x00', + 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-A210\x00\x00', + b'78109-T5A-A410\x00\x00', + b'78109-T5A-A420\x00\x00', + b'78109-T5A-A910\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36161-T5R-A040\x00\x00', + b'36161-T5R-A240\x00\x00', + b'36161-T5R-A520\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-T5R-A230\x00\x00', + ], + }, + CAR.FREED: { + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TDK-J010\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TDK-J050\x00\x00', + b'39990-TDK-N020\x00\x00', + ], + # TODO: vsa is "essential" for fpv2 but doesn't appear on some models + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TDK-J120\x00\x00', + b'57114-TDK-J330\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TDK-J310\x00\x00', + b'78109-TDK-J320\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36161-TDK-J070\x00\x00', + b'36161-TDK-J080\x00\x00', + b'36161-TDK-J530\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-4080\x00\x00', + b'37805-5MR-A240\x00\x00', + b'37805-5MR-A250\x00\x00', + b'37805-5MR-A310\x00\x00', + b'37805-5MR-A740\x00\x00', + b'37805-5MR-A750\x00\x00', + b'37805-5MR-A840\x00\x00', + b'37805-5MR-C620\x00\x00', + b'37805-5MR-D530\x00\x00', + b'37805-5MR-K730\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', + b'77959-THR-X010\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-THR-A020\x00\x00', + 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', + b'36161-THR-D110\x00\x00', + b'36161-THR-K020\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5NZ-A110\x00\x00', + 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'28102-5MX-D001\x00\x00', + b'28102-5MX-D710\x00\x00', + b'28102-5MX-K610\x00\x00', + b'28103-5NZ-A100\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-A220\x00\x00', + b'78109-THR-A230\x00\x00', + b'78109-THR-A420\x00\x00', + b'78109-THR-A430\x00\x00', + b'78109-THR-A720\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-AC30\x00\x00', + b'78109-THR-AC40\x00\x00', + b'78109-THR-AC50\x00\x00', + b'78109-THR-AD30\x00\x00', + b'78109-THR-AE20\x00\x00', + b'78109-THR-AE30\x00\x00', + b'78109-THR-AE40\x00\x00', + b'78109-THR-AK10\x00\x00', + b'78109-THR-AL10\x00\x00', + b'78109-THR-AN10\x00\x00', + b'78109-THR-C220\x00\x00', + b'78109-THR-C330\x00\x00', + b'78109-THR-CE20\x00\x00', + b'78109-THR-DA20\x00\x00', + b'78109-THR-DA30\x00\x00', + b'78109-THR-DA40\x00\x00', + b'78109-THR-K120\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-THR-A020\x00\x00', + ], + }, + CAR.PILOT: { + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TG7-A520\x00\x00', + b'54008-TG7-A530\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5EY-A050\x00\x00', + b'28101-5EY-A100\x00\x00', + b'28101-5EZ-A050\x00\x00', + b'28101-5EZ-A060\x00\x00', + b'28101-5EZ-A100\x00\x00', + b'28101-5EZ-A210\x00\x00', + ], + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-RLV-4060\x00\x00', + b'37805-RLV-4070\x00\x00', + b'37805-RLV-A830\x00\x00', + b'37805-RLV-A840\x00\x00', + b'37805-RLV-C430\x00\x00', + b'37805-RLV-C510\x00\x00', + b'37805-RLV-C520\x00\x00', + b'37805-RLV-C530\x00\x00', + b'37805-RLV-C910\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TG7-A030\x00\x00', + b'39990-TG7-A040\x00\x00', + b'39990-TG7-A060\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-TG7-A520\x00\x00', + b'36161-TG7-A720\x00\x00', + b'36161-TG7-A820\x00\x00', + b'36161-TG7-C520\x00\x00', + b'36161-TG7-D520\x00\x00', + b'36161-TG8-A520\x00\x00', + b'36161-TG8-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-A040\x00\x00', + b'78109-TG7-A050\x00\x00', + b'78109-TG7-A420\x00\x00', + b'78109-TG7-A520\x00\x00', + b'78109-TG7-A720\x00\x00', + b'78109-TG7-D020\x00\x00', + b'78109-TG8-A420\x00\x00', + b'78109-TG8-A520\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TG7-A130\x00\x00', + b'57114-TG7-A140\x00\x00', + b'57114-TG7-A230\x00\x00', + b'57114-TG7-A240\x00\x00', + b'57114-TG8-A140\x00\x00', + b'57114-TG8-A240\x00\x00', + ], + + }, + CAR.PILOT_2019: { + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TG7-A060\x00\x00', + b'39990-TG7-A070\x00\x00', + b'39990-TGS-A230\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TG7-A030\x00\x00', + b'38897-TG7-A040\x00\x00', + b'38897-TG7-A110\x00\x00', + b'38897-TG7-A210\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-TG7-A310\x00\x00', + b'36161-TG7-A630\x00\x00', + b'36161-TG7-A930\x00\x00', + b'36161-TG7-D630\x00\x00', + b'36161-TG7-Y630\x00\x00', + b'36161-TG8-A630\x00\x00', + b'36161-TG8-A830\x00\x00', + b'36161-TGS-A130\x00\x00', + b'36161-TGT-A030\x00\x00', + b'36161-TGT-A130\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TG7-A210\x00\x00', + b'77959-TG7-Y210\x00\x00', + b'77959-TGS-A010\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TG7-AJ10\x00\x00', + b'78109-TG7-AJ20\x00\x00', + b'78109-TG7-AK10\x00\x00', + b'78109-TG7-AK20\x00\x00', + b'78109-TG7-AM20\x00\x00', + b'78109-TG7-AP10\x00\x00', + b'78109-TG7-AP20\x00\x00', + b'78109-TG7-AS20\x00\x00', + b'78109-TG7-AT20\x00\x00', + b'78109-TG7-AU20\x00\x00', + b'78109-TG7-AX20\x00\x00', + b'78109-TG7-DJ10\x00\x00', + b'78109-TG7-YK20\x00\x00', + b'78109-TG8-AJ10\x00\x00', + b'78109-TG8-AJ20\x00\x00', + b'78109-TG8-AK20\x00\x00', + b'78109-TGS-AK20\x00\x00', + b'78109-TGS-AP20\x00\x00', + b'78109-TGT-AJ20\x00\x00', + b'78109-TGT-AK30\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-TG8-A730\x00\x00', + b'57114-TGS-A530\x00\x00', + b'57114-TGT-A530\x00\x00', + ], + }, + CAR.PASSPORT: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-RLV-B220\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TGS-A230\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36161-TGS-A030\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TG7-A040\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TGS-A010\x00\x00', + ], + (Ecu.shiftByWire, 0x18da0bf1, None): [ + b'54008-TG7-A530\x00\x00', + ], + (Ecu.transmission, 0x18da1ef1, None): [ + b'28101-5EZ-A600\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TGS-AT20\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TGS-A530\x00\x00', + ], + }, + CAR.ACURA_RDX: { + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TX5-A220\x00\x00', + b'57114-TX4-A220\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab0f1, None): [ + b'36161-TX5-A030\x00\x00', + b'36161-TX4-A030\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TX4-C010\x00\x00', + b'77959-TX4-B010\x00\x00', + b'77959-TX4-C020\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TX5-A310\x00\x00', + b'78109-TX4-A210\x00\x00', + b'78109-TX4-A310\x00\x00', + ], + }, + CAR.ACURA_RDX_3G: { + (Ecu.programmedFuelInjection, 0x18da10f1, None): [ + b'37805-5YF-A130\x00\x00', + b'37805-5YF-A230\x00\x00', + b'37805-5YF-A320\x00\x00', + b'37805-5YF-A330\x00\x00', + b'37805-5YF-A420\x00\x00', + b'37805-5YF-A430\x00\x00', + b'37805-5YF-A750\x00\x00', + b'37805-5YF-A850\x00\x00', + b'37805-5YF-A870\x00\x00', + b'37805-5YF-C210\x00\x00', + b'37805-5YF-C220\x00\x00', + b'37805-5YF-C410\000\000', + b'37805-5YF-C420\x00\x00', + ], + (Ecu.vsa, 0x18da28f1, None): [ + b'57114-TJB-A030\x00\x00', + b'57114-TJB-A040\x00\x00', + ], + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'36802-TJB-A040\x00\x00', + b'36802-TJB-A050\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-A610\x00\x00', + b'28102-5YK-A620\x00\x00', + b'28102-5YK-A630\x00\x00', + b'28102-5YK-A700\x00\x00', + b'28102-5YK-A711\x00\x00', + b'28102-5YL-A620\x00\x00', + b'28102-5YL-A700\x00\x00', + b'28102-5YL-A711\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-TJB-A140\x00\x00', + b'78109-TJB-A240\x00\x00', + b'78109-TJB-A420\x00\x00', + b'78109-TJB-AB10\x00\x00', + b'78109-TJB-AD10\x00\x00', + b'78109-TJB-AF10\x00\x00', + b'78109-TJB-AR10\x00\x00', + b'78109-TJB-AS10\000\000', + b'78109-TJB-AU10\x00\x00', + b'78109-TJB-AW10\x00\x00', + b'78109-TJC-A420\x00\x00', + b'78109-TJC-AA10\x00\x00', + b'78109-TJC-AD10\x00\x00', + b'78109-TJC-AF10\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TJB-A040\x00\x00', + b'77959-TJB-A210\x00\x00', + ], + (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ + b'46114-TJB-A040\x00\x00', + b'46114-TJB-A050\x00\x00', + b'46114-TJB-A060\x00\x00', + ], + (Ecu.gateway, 0x18daeff1, None): [ + b'38897-TJB-A040\x00\x00', + b'38897-TJB-A110\x00\x00', + b'38897-TJB-A120\x00\x00', + ], + (Ecu.eps, 0x18da30f1, None): [ + b'39990-TJB-A030\x00\x00', + b'39990-TJB-A040\x00\x00', + b'39990-TJB-A130\x00\x00' + ], + }, + CAR.RIDGELINE: { + (Ecu.eps, 0x18da30f1, None): [ + b'39990-T6Z-A020\x00\x00', + b'39990-T6Z-A030\x00\x00', + b'39990-T6Z-A050\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-T6Z-A620\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-T6Z-A810\x00\x00', + b'78109-T6Z-A910\x00\x00', + b'78109-T6Z-AA10\x00\x00', + b'78109-T6Z-C620\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', + b'78109-TXM-C010\x00\x00', + b'78109-TXM-A030\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-A120\x00\x00', + b'78109-THX-A210\x00\x00', + b'78109-THX-A220\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-TV9-A140\x00\x00', + b'36161-TX6-A030\x00\x00', + ], + (Ecu.srs, 0x18da53f1, None): [ + b'77959-TX6-A230\x00\x00', + b'77959-TX6-C210\x00\x00', + ], + (Ecu.combinationMeter, 0x18da60f1, None): [ + b'78109-T3R-A120\x00\x00', + b'78109-T3R-A410\x00\x00', + b'78109-TV9-A510\x00\x00', + ], + }, + CAR.HONDA_E:{ + (Ecu.eps, 0x18DA30F1, None):[ + b'39990-TYF-N030\x00\x00' + ], + (Ecu.gateway, 0x18DAEFF1, None):[ + b'38897-TYF-E140\x00\x00' + ], + (Ecu.shiftByWire, 0x18DA0BF1, None):[ + b'54008-TYF-E010\x00\x00' + ], + (Ecu.srs, 0x18DA53F1, None):[ + b'77959-TYF-G430\x00\x00' + ], + (Ecu.combinationMeter, 0x18DA60F1, None):[ + b'78108-TYF-G610\x00\x00' + ], + (Ecu.fwdRadar, 0x18DAB0F1, None):[ + b'36802-TYF-E030\x00\x00' + ], + (Ecu.fwdCamera, 0x18DAB5F1, None):[ + b'36161-TYF-E020\x00\x00' + ], + (Ecu.vsa, 0x18DA28F1, None):[ + b'57114-TYF-E030\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.ACCORD: dbc_dict('honda_accord_2018_can_generated', None), + CAR.ACCORDH: dbc_dict('honda_accord_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.FREED: dbc_dict('honda_fit_ex_2018_can_generated', 'acura_ilx_2016_nidec'), + CAR.HRV: dbc_dict('honda_fit_ex_2018_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.PASSPORT: 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), + CAR.HONDA_E: dbc_dict('acura_rdx_2020_can_generated', None), } STEER_THRESHOLD = { - CAR.ACCORD: 1200, - CAR.ACCORD_15: 1200, - CAR.ACCORDH: 1200, - CAR.ACURA_ILX: 1200, + # default is 1200, overrides go here CAR.ACURA_RDX: 400, - CAR.CIVIC: 1200, - CAR.CIVIC_BOSCH: 1200, - CAR.CRV: 1200, - CAR.CRV_5G: 1200, - CAR.CRV_HYBRID: 1200, - CAR.ODYSSEY: 1200, - CAR.ODYSSEY_CHN: 1200, - CAR.PILOT: 1200, - CAR.PILOT_2019: 1200, - CAR.RIDGELINE: 1200, + CAR.CRV_EU: 400, } -SPEED_FACTOR = { - CAR.ACCORD: 1., - CAR.ACCORD_15: 1., - CAR.ACCORDH: 1., - CAR.ACURA_ILX: 1., - CAR.ACURA_RDX: 1., - CAR.CIVIC: 1., - CAR.CIVIC_BOSCH: 1., - CAR.CRV: 1.025, - CAR.CRV_5G: 1.025, - CAR.CRV_HYBRID: 1.025, - CAR.ODYSSEY: 1., - CAR.ODYSSEY_CHN: 1., - CAR.PILOT: 1., - CAR.PILOT_2019: 1., - CAR.RIDGELINE: 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_NIDEC_ALT_PCM_ACCEL = set([CAR.ODYSSEY]) +HONDA_NIDEC_ALT_SCM_MESSAGES = set([CAR.ACURA_ILX, CAR.ACURA_RDX, CAR.CRV, CAR.CRV_EU, CAR.FIT, CAR.FREED, CAR.HRV, CAR.ODYSSEY_CHN, + CAR.PILOT, CAR.PILOT_2019, CAR.PASSPORT, CAR.RIDGELINE]) +HONDA_BOSCH = set([CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_5G, + CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E]) +HONDA_BOSCH_ALT_BRAKE_SIGNAL = set([CAR.ACCORD, CAR.CRV_5G, CAR.ACURA_RDX_3G]) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index a1a688ff5ef7c8..a8b70fcf9021f9 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -1,70 +1,119 @@ +from cereal import car +from common.realtime import DT_CTRL +from common.numpy_fast import clip, interp +from selfdrive.config import Conversions as CV 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_lfahda_mfc, create_acc_commands, create_acc_opt, create_frt_radar_opt +from selfdrive.car.hyundai.values import Buttons, CarControllerParams, CAR +from opendbc.can.packer import CANPacker +VisualAlert = car.CarControl.HUDControl.VisualAlert +LongCtrlState = car.CarControl.Actuators.LongControlState -# 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 in [VisualAlert.steerRequired, VisualAlert.ldw]) -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 = CarControllerParams(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, hud_speed, + left_lane, right_lane, left_lane_depart, right_lane_depart): + # Steering Torque + new_steer = int(round(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 when temp fault is active, or below LKA minimum speed + lkas_active = enabled and not CS.out.steerWarning and CS.out.vEgo >= CS.CP.minSteerSpeed - can_sends = [] - - self.lkas11_cnt = self.cnt % 0x10 - self.clu11_cnt = self.cnt % 0x10 + if not lkas_active: + apply_steer = 0 - 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()) + self.apply_steer_last = apply_steer - 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))) + 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) - 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)) + can_sends = [] - self.cnt += 1 + # tester present - w/ no response (keeps radar disabled) + if CS.CP.openpilotLongitudinalControl: + if (frame % 100) == 0: + can_sends.append([0x7D0, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", 0]) + + 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 not CS.CP.openpilotLongitudinalControl: + if pcm_cancel_cmd: + 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: + # send 25 messages at a time to increases the likelihood of resume being accepted + can_sends.extend([create_clu11(self.packer, frame, CS.clu11, Buttons.RES_ACCEL)] * 25) + self.last_resume_frame = frame + + if frame % 2 == 0 and CS.CP.openpilotLongitudinalControl: + lead_visible = False + accel = actuators.accel if enabled else 0 + + jerk = clip(2.0 * (accel - CS.out.aEgo), -12.7, 12.7) + + if accel < 0: + accel = interp(accel - CS.out.aEgo, [-1.0, -0.5], [2 * accel, accel]) + + accel = clip(accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) + + stopping = (actuators.longControlState == LongCtrlState.stopping) + set_speed_in_units = hud_speed * (CV.MS_TO_MPH if CS.clu11["CF_Clu_SPEED_UNIT"] == 1 else CV.MS_TO_KPH) + can_sends.extend(create_acc_commands(self.packer, enabled, accel, jerk, int(frame / 2), lead_visible, set_speed_in_units, stopping)) + + # 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.KIA_NIRO_HEV_2021, + CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KIA_CEED, CAR.KIA_SELTOS, CAR.KONA_EV, + CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_HEV, CAR.SANTA_FE_2022, + CAR.KIA_K5_2021, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022, CAR.GENESIS_G70_2020]: + can_sends.append(create_lfahda_mfc(self.packer, enabled)) + + # 5 Hz ACC options + if frame % 20 == 0 and CS.CP.openpilotLongitudinalControl: + can_sends.extend(create_acc_opt(self.packer)) + + # 2 Hz front radar options + if frame % 50 == 0 and CS.CP.openpilotLongitudinalControl: + can_sends.append(create_frt_radar_opt(self.packer)) return can_sends diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 8c900d73f8285d..e889f24fc944bf 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -1,249 +1,298 @@ -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_CAR, HYBRID_CAR +from selfdrive.car.interfaces import CarStateBase +from opendbc.can.parser import CANParser +from opendbc.can.can_define import CANDefine 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, timeout=100) - - -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, timeout=100) - - -class CarState(object): + + +class CarState(CarStateBase): def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) + + if self.CP.carFingerprint in FEATURES["use_cluster_gears"]: + self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"] + elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]: + self.shifter_values = can_define.dv["TCU12"]["CUR_GR"] + else: # preferred and elect gear methods use same definition + self.shifter_values = can_define.dv["LVR12"]["CF_Lvr_Gear"] - 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 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 - - self.door_all_closed = True - self.seatbelt = cp.vl["CGW1"]['CF_Gway_DrvSeatBeltSw'] - - self.brake_pressed = cp.vl["TCS13"]['DriverBraking'] - self.esp_disabled = cp.vl["TCS15"]['ESC_Off_Step'] - - 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'] - self.angle_steers_rate = 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 + 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 = self.get_wheel_speeds( + cp.vl["WHL_SPD11"]["WHL_SPD_FL"], + cp.vl["WHL_SPD11"]["WHL_SPD_FR"], + cp.vl["WHL_SPD11"]["WHL_SPD_RL"], + cp.vl["WHL_SPD11"]["WHL_SPD_RR"], + ) + 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.steeringAngleDeg = cp.vl["SAS11"]["SAS_Angle"] + ret.steeringRateDeg = cp.vl["SAS11"]["SAS_Speed"] + ret.yawRate = cp.vl["ESP12"]["YAW_RATE"] + ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp( + 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 or cp.vl["MDPS12"]["CF_Mdps_ToiFlt"] != 0 + + # cruise state + if self.CP.openpilotLongitudinalControl: + # These are not used for engage/disengage since openpilot keeps track of state using the buttons + ret.cruiseState.available = cp.vl["TCS13"]["ACCEnable"] == 0 + ret.cruiseState.enabled = cp.vl["TCS13"]["ACC_REQ"] == 1 + ret.cruiseState.standstill = False else: - self.pedal_gas = cp.vl["EMS12"]['TPS'] - self.car_gas = cp.vl["EMS12"]['TPS'] - - # 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" + ret.cruiseState.available = cp.vl["SCC11"]["MainMode_ACC"] == 1 + 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 + + # TODO: Find brake pressure + ret.brake = 0 + ret.brakePressed = cp.vl["TCS13"]["DriverBraking"] != 0 + ret.brakeHoldActive = cp.vl["TCS15"]["AVH_LAMP"] == 2 # 0 OFF, 1 ERROR, 2 ACTIVE, 3 READY + + if self.CP.carFingerprint in (HYBRID_CAR | EV_CAR): + if self.CP.carFingerprint in HYBRID_CAR: + ret.gas = cp.vl["E_EMS11"]["CR_Vcu_AccPedDep_Pos"] / 254. + else: + ret.gas = cp.vl["E_EMS11"]["Accel_Pedal_Pos"] / 254. + ret.gasPressed = ret.gas > 0 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" + ret.gas = cp.vl["EMS12"]["PV_AV_CAN"] / 100. + ret.gasPressed = bool(cp.vl["EMS16"]["CF_Ems_AclAct"]) + + # 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"]: + gear = cp.vl["CLU15"]["CF_Clu_Gear"] + elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]: + gear = cp.vl["TCU12"]["CUR_GR"] + elif self.CP.carFingerprint in FEATURES["use_elect_gears"]: + gear = cp.vl["ELECT_GEAR"]["Elect_Gear_Shifter"] else: - self.gear_shifter_cluster = "unknown" - - # 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" + gear = cp.vl["LVR12"]["CF_Lvr_Gear"] + + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear)) + + if not self.CP.openpilotLongitudinalControl: + 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: + ret.stockAeb = cp.vl["SCC12"]["AEB_CmdAct"] != 0 + ret.stockFcw = cp.vl["SCC12"]["CF_VSM_Warn"] == 2 + + if self.CP.enableBsm: + 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["TCS13"]["PBRAKE_ACT"] == 1 + self.steer_state = cp.vl["MDPS12"]["CF_Mdps_ToiActive"] # 0 NOT ACTIVE, 1 ACTIVE + self.brake_error = cp.vl["TCS13"]["ACCEnable"] != 0 # 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED + self.prev_cruise_buttons = self.cruise_buttons + self.cruise_buttons = cp.vl["CLU11"]["CF_Clu_CruiseSwState"] + + 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), + ("ACC_REQ", "TCS13", 0), + ("DriverBraking", "TCS13", 0), + ("StandStill", "TCS13", 0), + ("PBRAKE_ACT", "TCS13", 0), + + ("ESC_Off_Step", "TCS15", 0), + ("AVH_LAMP", "TCS15", 0), + + ("CR_Mdps_StrColTq", "MDPS12", 0), + ("CF_Mdps_ToiActive", "MDPS12", 0), + ("CF_Mdps_ToiUnavail", "MDPS12", 0), + ("CF_Mdps_ToiFlt", "MDPS12", 0), + ("CR_Mdps_OutTq", "MDPS12", 0), + + ("SAS_Angle", "SAS11", 0), + ("SAS_Speed", "SAS11", 0), + ] + + checks = [ + # address, frequency + ("MDPS12", 50), + ("TCS13", 50), + ("TCS15", 10), + ("CLU11", 50), + ("ESP12", 100), + ("CGW1", 10), + ("CGW2", 5), + ("CGW4", 5), + ("WHL_SPD11", 50), + ("SAS11", 100), + ] + + if not CP.openpilotLongitudinalControl: + signals += [ + ("MainMode_ACC", "SCC11", 0), + ("VSetDis", "SCC11", 0), + ("SCCInfoDisplay", "SCC11", 0), + ("ACC_ObjDist", "SCC11", 0), + ("ACCMode", "SCC12", 1), + ] + + checks += [ + ("SCC11", 50), + ("SCC12", 50), + ] + + 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), + ] + + if CP.enableBsm: + signals += [ + ("CF_Lca_IndLeft", "LCA11", 0), + ("CF_Lca_IndRight", "LCA11", 0), + ] + checks += [("LCA11", 50)] + + if CP.carFingerprint in (HYBRID_CAR | EV_CAR): + if CP.carFingerprint in HYBRID_CAR: + signals += [ + ("CR_Vcu_AccPedDep_Pos", "E_EMS11", 0) + ] + else: + 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_Gear", "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) + ] + + 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 5a895497a1865f..50031231bcb062 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -1,79 +1,157 @@ 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, 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 -def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False): - values = { - "CF_Lkas_Icon": 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, - } + if car_fingerprint in [CAR.SONATA, CAR.PALISADE, CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV_2021, CAR.SANTA_FE, + CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KIA_SELTOS, CAR.ELANTRA_2021, CAR.GENESIS_G70_2020, + CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_EV, CAR.KONA_HEV, CAR.SANTA_FE_2022, + CAR.KIA_K5_2021, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022]: + 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_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_1191(): - return make_can_msg(1191, "\x01\x00", 0) +def create_lfahda_mfc(packer, enabled, hda_set_speed=0): + values = { + "LFA_Icon_State": 2 if enabled else 0, + "HDA_Active": 1 if hda_set_speed else 0, + "HDA_Icon_State": 2 if hda_set_speed else 0, + "HDA_VSetReq": hda_set_speed, + } + return packer.make_can_msg("LFAHDA_MFC", 0, values) -def create_1156(): - return make_can_msg(1156, "\x08\x20\xfe\x3f\x00\xe0\xfd\x3f", 0) +def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_speed, stopping): + commands = [] -def create_clu11(packer, clu11, button): - 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, + scc11_values = { + "MainMode_ACC": 1, + "TauGapSet": 4, + "VSetDis": set_speed if enabled else 0, + "AliveCounterACC": idx % 0x10, + "ObjValid": 1 if lead_visible else 0, + "ACC_ObjStatus": 1 if lead_visible else 0, + "ACC_ObjLatPos": 0, + "ACC_ObjRelSpd": 0, + "ACC_ObjDist": 0, } + commands.append(packer.make_can_msg("SCC11", 0, scc11_values)) - return packer.make_can_msg("CLU11", 0, values) + scc12_values = { + "ACCMode": 1 if enabled else 0, + "StopReq": 1 if enabled and stopping else 0, + "aReqRaw": accel if enabled else 0, + "aReqValue": accel if enabled else 0, # stock ramps up and down respecting jerk limit until it reaches aReqRaw + "CR_VSM_Alive": idx % 0xF, + } + scc12_dat = packer.make_can_msg("SCC12", 0, scc12_values)[2] + scc12_values["CR_VSM_ChkSum"] = 0x10 - sum(sum(divmod(i, 16)) for i in scc12_dat) % 0x10 + + commands.append(packer.make_can_msg("SCC12", 0, scc12_values)) + + scc14_values = { + "ComfortBandUpper": 0.0, # stock usually is 0 but sometimes uses higher values + "ComfortBandLower": 0.0, # stock usually is 0 but sometimes uses higher values + "JerkUpperLimit": max(jerk, 1.0) if (enabled and not stopping) else 0, # stock usually is 1.0 but sometimes uses higher values + "JerkLowerLimit": max(-jerk, 1.0) if enabled else 0, # stock usually is 0.5 but sometimes uses higher values + "ACCMode": 1 if enabled else 4, # stock will always be 4 instead of 0 after first disengage + "ObjGap": 2 if lead_visible else 0, # 5: >30, m, 4: 25-30 m, 3: 20-25 m, 2: < 20 m, 0: no lead + } + commands.append(packer.make_can_msg("SCC14", 0, scc14_values)) + + fca11_values = { + # seems to count 2,1,0,3,2,1,0,3,2,1,0,3,2,1,0,repeat... + # (where first value is aligned to Supplemental_Counter == 0) + # test: [(idx % 0xF, -((idx % 0xF) + 2) % 4) for idx in range(0x14)] + "CR_FCA_Alive": ((-((idx % 0xF) + 2) % 4) << 2) + 1, + "Supplemental_Counter": idx % 0xF, + "PAINT1_Status": 1, + "FCA_DrvSetStatus": 1, + "FCA_Status": 1, # AEB disabled + } + fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2] + fca11_values["CR_FCA_ChkSum"] = 0x10 - sum(sum(divmod(i, 16)) for i in fca11_dat) % 0x10 + commands.append(packer.make_can_msg("FCA11", 0, fca11_values)) + + return commands + +def create_acc_opt(packer): + commands = [] + + scc13_values = { + "SCCDrvModeRValue": 2, + "SCC_Equip": 1, + "Lead_Veh_Dep_Alert_USM": 2, + } + commands.append(packer.make_can_msg("SCC13", 0, scc13_values)) + + fca12_values = { + "FCA_DrvSetState": 2, + "FCA_USM": 1, # AEB disabled + } + commands.append(packer.make_can_msg("FCA12", 0, fca12_values)) + + return commands + +def create_frt_radar_opt(packer): + frt_radar11_values = { + "CF_FCA_Equip_Front_Radar": 1, + } + return packer.make_can_msg("FRT_RADAR11", 0, frt_radar11_values) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 67ca2261ff7f17..57b313e5344c6a 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -1,98 +1,182 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from cereal import car -from common.realtime import sec_since_boot +from panda import Panda +from common.params import Params 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 - - -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) +from selfdrive.car.hyundai.values import CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, Buttons, CarControllerParams +from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config +from selfdrive.car.interfaces import CarInterfaceBase +from selfdrive.car.disable_ecu import disable_ecu - @staticmethod - def compute_gb(accel, speed): - return float(accel) / 3.0 +ButtonType = car.CarState.ButtonEvent.Type +EventName = car.CarEvent.EventName +class CarInterface(CarInterfaceBase): @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 + def get_pid_accel_limits(CP, current_speed, cruise_speed): + return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX @staticmethod - def get_params(candidate, fingerprint, vin=""): - - 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.radarOffCan = True - ret.safetyModel = car.CarParams.SafetyModel.hyundai - ret.enableCruise = True # stock acc + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)] + ret.radarOffCan = RADAR_START_ADDR not in fingerprint[1] + + # WARNING: disabling radar also disables AEB (and we show the same warning on the instrument cluster as if you manually disabled AEB) + ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar") and (candidate not in LEGACY_SAFETY_MODE_CAR) + + ret.pcmCruise = not ret.openpilotLongitudinalControl ret.steerActuatorDelay = 0.1 # Default delay ret.steerRateCost = 0.5 + ret.steerLimitTimer = 0.4 tire_stiffness_factor = 1. - if candidate == CAR.SANTA_FE: + ret.stoppingControl = True + ret.vEgoStopping = 1.0 + + ret.longitudinalTuning.kpV = [0.1] + ret.longitudinalTuning.kiV = [0.0] + ret.stopAccel = 0.0 + ret.startAccel = 0.0 + + ret.longitudinalActuatorDelayUpperBound = 1.0 # s + + if candidate in [CAR.SANTA_FE, CAR.SANTA_FE_2022, CAR.SANTA_FE_HEV_2022]: 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 in [CAR.SONATA, CAR.SONATA_HYBRID]: 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_LF: + 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 = 15.6 * 1.15 + tire_stiffness_factor = 0.63 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [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.ELANTRA_2021: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = (2800. * CV.LB_TO_KG) + STD_CARGO_KG + ret.wheelbase = 2.72 + ret.steerRatio = 12.9 + 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.ELANTRA_HEV_2021: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = (3017. * CV.LB_TO_KG) + STD_CARGO_KG + ret.wheelbase = 2.72 + ret.steerRatio = 12.9 + 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.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.innerLoopGainBP = [0.] + ret.lateralTuning.indi.innerLoopGainV = [3.5] + ret.lateralTuning.indi.outerLoopGainBP = [0.] + ret.lateralTuning.indi.outerLoopGainV = [2.0] + ret.lateralTuning.indi.timeConstantBP = [0.] + ret.lateralTuning.indi.timeConstantV = [1.4] + ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] + ret.lateralTuning.indi.actuatorEffectivenessV = [2.3] + ret.minSteerSpeed = 60 * CV.KPH_TO_MS + elif candidate in [CAR.KONA, CAR.KONA_EV, CAR.KONA_HEV]: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = {CAR.KONA_EV: 1685., CAR.KONA_HEV: 1425.}.get(candidate, 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 in [CAR.IONIQ, CAR.IONIQ_EV_LTD, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.IONIQ_HEV_2022]: + 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 not in [CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.IONIQ_HEV_2022]: + 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 in [CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_HEV_2021]: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1737. + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 13.9 if CAR.KIA_NIRO_HEV_2021 else 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.KIA_NIRO_HEV: + ret.minSteerSpeed = 32 * CV.MPH_TO_MS + elif candidate == CAR.KIA_SELTOS: + ret.mass = 1337. + STD_CARGO_KG + ret.wheelbase = 2.63 + ret.steerRatio = 14.56 + tire_stiffness_factor = 1 + ret.lateralTuning.init('indi') + ret.lateralTuning.indi.innerLoopGainBP = [0.] + ret.lateralTuning.indi.innerLoopGainV = [4.] + ret.lateralTuning.indi.outerLoopGainBP = [0.] + ret.lateralTuning.indi.outerLoopGainV = [3.] + ret.lateralTuning.indi.timeConstantBP = [0.] + ret.lateralTuning.indi.timeConstantV = [1.4] + ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] + ret.lateralTuning.indi.actuatorEffectivenessV = [1.8] + 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 @@ -107,15 +191,77 @@ def get_params(candidate, fingerprint, vin=""): 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. + 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]] + elif candidate == CAR.KIA_CEED: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 1450. + STD_CARGO_KG + ret.wheelbase = 2.65 + ret.steerRatio = 13.75 + tire_stiffness_factor = 0.5 + ret.lateralTuning.pid.kf = 0.00005 + 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_K5_2021: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 3228. * CV.LB_TO_KG + ret.wheelbase = 2.85 + ret.steerRatio = 13.27 # 2021 Kia K5 Steering Ratio (all trims) + 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.innerLoopGainBP = [0.] + ret.lateralTuning.indi.innerLoopGainV = [2.5] + ret.lateralTuning.indi.outerLoopGainBP = [0.] + ret.lateralTuning.indi.outerLoopGainV = [3.5] + ret.lateralTuning.indi.timeConstantBP = [0.] + ret.lateralTuning.indi.timeConstantV = [1.4] + ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] + ret.lateralTuning.indi.actuatorEffectivenessV = [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_G70_2020: + ret.lateralTuning.pid.kf = 0. + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.112], [0.004]] + ret.mass = 3673.0 * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.83 + ret.steerRatio = 12.9 + 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 LEGACY_SAFETY_MODE_CAR: + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundaiLegacy)] - 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.] + # set appropriate safety param for gas signal + if candidate in HYBRID_CAR: + ret.safetyConfigs[0].safetyParam = 2 + elif candidate in EV_CAR: + ret.safetyConfigs[0].safetyParam = 1 ret.centerToFront = ret.wheelbase * 0.4 @@ -128,160 +274,81 @@ def get_params(candidate, fingerprint, vin=""): ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) + ret.enableBsm = 0x58b in fingerprint[0] - # 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) - ret.openpilotLongitudinalControl = False - - ret.steerLimitAlert = False - ret.stoppingControl = False - ret.startAccel = 0.0 + if ret.openpilotLongitudinalControl: + ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_LONG return ret - # returns a car.CarState - def update(self, c): - # ******************* do can recv ******************* - canMonoTimes = [] - can_rcv_valid, _ = self.cp.update(int(sec_since_boot() * 1e9), True) - cam_rcv_valid, _ = self.cp_cam.update(int(sec_since_boot() * 1e9), False) - - self.CS.update(self.cp, self.cp_cam) - # create message - ret = car.CarState.new_message() - - ret.canValid = can_rcv_valid and cam_rcv_valid and 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 - ret.steeringRate = self.CS.angle_steers_rate # it's unsigned - - 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 - - # 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 + @staticmethod + def init(CP, logcan, sendcan): + if CP.openpilotLongitudinalControl: + disable_ecu(logcan, sendcan, addr=0x7d0, com_cont_req=b'\x28\x83\x01') + + 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 + ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False + + events = self.create_common_events(ret, pcm_enable=self.CS.CP.pcmCruise) + + if self.CS.brake_error: + events.add(EventName.brakeUnavailable) + if self.CS.park_brake: + events.add(EventName.parkBrake) + + if self.CS.CP.openpilotLongitudinalControl: + buttonEvents = [] + + if self.CS.cruise_buttons != self.CS.prev_cruise_buttons: + be = car.CarState.ButtonEvent.new_message() + be.type = ButtonType.unknown + if self.CS.cruise_buttons != 0: + be.pressed = True + but = self.CS.cruise_buttons + else: + be.pressed = False + but = self.CS.prev_cruise_buttons + if but == Buttons.RES_ACCEL: + be.type = ButtonType.accelCruise + elif but == Buttons.SET_DECEL: + be.type = ButtonType.decelCruise + elif but == Buttons.GAP_DIST: + be.type = ButtonType.gapAdjustCruise + elif but == Buttons.CANCEL: + be.type = ButtonType.cancel + buttonEvents.append(be) + + ret.buttonEvents = buttonEvents + + 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) # 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 - ret.canMonoTimes = canMonoTimes + 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, c.hudControl.audibleAlert) - - 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.setSpeed, 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 75256683de3187..6022069a2d6661 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -1,24 +1,91 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +import math + 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 + +RADAR_START_ADDR = 0x500 +RADAR_MSG_COUNT = 32 + + +def get_radar_can_parser(CP): + if DBC[CP.carFingerprint]['radar'] is None: + return None + + signals = [] + checks = [] + for addr in range(RADAR_START_ADDR, RADAR_START_ADDR + RADAR_MSG_COUNT): + msg = f"RADAR_TRACK_{addr:x}" + signals += [ + ("STATE", msg, 0), + ("AZIMUTH", msg, 0), + ("LONG_DIST", msg, 0), + ("REL_ACCEL", msg, 0), + ("REL_SPEED", msg, 0), + ] + checks += [(msg, 50)] + return CANParser(DBC[CP.carFingerprint]['radar'], signals, checks, 1) -class RadarInterface(object): + +class RadarInterface(RadarInterfaceBase): def __init__(self, CP): - # radar - self.pts = {} - self.delay = 0.1 + super().__init__(CP) + self.updated_messages = set() + self.trigger_msg = RADAR_START_ADDR + RADAR_MSG_COUNT - 1 + self.track_id = 0 + + self.radar_off_can = CP.radarOffCan + self.rcp = get_radar_can_parser(CP) + + def update(self, can_strings): + if self.radar_off_can or (self.rcp is None): + return super().update(None) + + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - def update(self): + 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 + if self.rcp is None: + return ret - return ret + errors = [] + + if not self.rcp.can_valid: + errors.append("canError") + ret.errors = errors + + for addr in range(RADAR_START_ADDR, RADAR_START_ADDR + RADAR_MSG_COUNT): + msg = self.rcp.vl[f"RADAR_TRACK_{addr:x}"] -if __name__ == "__main__": - RI = RadarInterface(None) - while 1: - ret = RI.update() - print(chr(27) + "[2J") - print(ret) + if addr not in self.pts: + self.pts[addr] = car.RadarData.RadarPoint.new_message() + self.pts[addr].trackId = self.track_id + self.track_id += 1 + + valid = msg['STATE'] in [3, 4] + if valid: + azimuth = math.radians(msg['AZIMUTH']) + self.pts[addr].measured = True + self.pts[addr].dRel = math.cos(azimuth) * msg['LONG_DIST'] + self.pts[addr].yRel = 0.5 * -math.sin(azimuth) * msg['LONG_DIST'] + self.pts[addr].vRel = msg['REL_SPEED'] + self.pts[addr].aRel = msg['REL_ACCEL'] + self.pts[addr].yvRel = float('nan') + + else: + del self.pts[addr] + + ret.points = list(self.pts.values()) + return ret diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 1756976e94aa13..df2e10dbe75608 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1,77 +1,1045 @@ +# flake8: noqa + from cereal import car from selfdrive.car import dbc_dict +Ecu = car.CarParams.Ecu -VisualAlert = car.CarControl.HUDControl.VisualAlert -AudibleAlert = car.CarControl.HUDControl.AudibleAlert +# Steer torque limits +class CarControllerParams: + ACCEL_MIN = -3.5 # m/s + ACCEL_MAX = 2.0 # m/s -def get_hud_alerts(visual_alert, audible_alert): - if visual_alert == VisualAlert.steerRequired: - return 4 if audible_alert != AudibleAlert.none else 5 - else: - return 0 + def __init__(self, CP): + if CP.carFingerprint in [CAR.SONATA, CAR.PALISADE, CAR.SANTA_FE, CAR.VELOSTER, CAR.GENESIS_G70, CAR.GENESIS_G70_2020, + CAR.IONIQ_EV_2020, CAR.KIA_CEED, CAR.KIA_SELTOS, CAR.ELANTRA_2021, + CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_HEV, CAR.SANTA_FE_2022, + CAR.KIA_K5_2021, CAR.KONA_EV, CAR.KONA, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022]: + 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 class CAR: - ELANTRA = "HYUNDAI ELANTRA LIMITED ULTIMATE 2017" - GENESIS = "HYUNDAI GENESIS 2018" - KIA_OPTIMA = "KIA OPTIMA SX 2019" + # Hyundai + ELANTRA = "HYUNDAI ELANTRA 2017" + ELANTRA_2021 = "HYUNDAI ELANTRA 2021" + ELANTRA_HEV_2021 = "HYUNDAI ELANTRA HYBRID 2021" + ELANTRA_GT_I30 = "HYUNDAI I30 N LINE 2019 & GT 2018 DCT" + HYUNDAI_GENESIS = "HYUNDAI GENESIS 2015-2016" + IONIQ = "HYUNDAI IONIQ HYBRID 2017-2019" + IONIQ_HEV_2022 = "HYUNDAI IONIQ HYBRID 2020-2022" + IONIQ_EV_LTD = "HYUNDAI IONIQ ELECTRIC LIMITED 2019" + IONIQ_EV_2020 = "HYUNDAI IONIQ ELECTRIC 2020" + IONIQ_PHEV = "HYUNDAI IONIQ PHEV 2020" + KONA = "HYUNDAI KONA 2020" + KONA_EV = "HYUNDAI KONA ELECTRIC 2019" + KONA_HEV = "HYUNDAI KONA HYBRID 2020" + SANTA_FE = "HYUNDAI SANTA FE 2019" + SANTA_FE_2022 = "HYUNDAI SANTA FE 2022" + SANTA_FE_HEV_2022 = "HYUNDAI SANTA FE HYBRID 2022" + SONATA = "HYUNDAI SONATA 2020" + SONATA_LF = "HYUNDAI SONATA 2019" + PALISADE = "HYUNDAI PALISADE 2020" + VELOSTER = "HYUNDAI VELOSTER 2019" + SONATA_HYBRID = "HYUNDAI SONATA HYBRID 2021" + + # Kia + KIA_FORTE = "KIA FORTE E 2018 & GT 2021" + KIA_K5_2021 = "KIA K5 2021" + KIA_NIRO_EV = "KIA NIRO EV 2020" + KIA_NIRO_HEV = "KIA NIRO HYBRID 2019" + KIA_NIRO_HEV_2021 = "KIA NIRO HYBRID 2021" + KIA_OPTIMA = "KIA OPTIMA SX 2019 & 2016" + KIA_OPTIMA_H = "KIA OPTIMA HYBRID 2017 & SPORTS 2019" + KIA_SELTOS = "KIA SELTOS 2021" KIA_SORENTO = "KIA SORENTO GT LINE 2018" KIA_STINGER = "KIA STINGER GT2 2018" - SANTA_FE = "HYUNDAI SANTA FE LIMITED 2019" + KIA_CEED = "KIA CEED INTRO ED 2019" + + # Genesis + GENESIS_G70 = "GENESIS G70 2018" + GENESIS_G70_2020 = "GENESIS G70 2020" + GENESIS_G80 = "GENESIS G80 2017" + GENESIS_G90 = "GENESIS G90 2017" + class Buttons: NONE = 0 RES_ACCEL = 1 SET_DECEL = 2 + GAP_DIST = 3 CANCEL = 4 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_LF: [ + {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_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: [{ + 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_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_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 + }], } -CAMERA_MSGS = [832, 1156, 1191, 1342] + +FW_VERSIONS = { + CAR.IONIQ: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00AEhe SCC H-CUP 1.01 1.01 96400-G2000 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00AE MDPS C 1.00 1.07 56310/G2301 4AEHC107', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00AEH MFC AT EUR LHD 1.00 1.00 95740-G2400 180222', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x816H6F2051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x816U3H1051\x00\x00\xf1\x006U3H0_C2\x00\x006U3H1051\x00\x00HAE0G16US2\x00\x00\x00\x00', + ], + }, + CAR.IONIQ_PHEV: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\000AEhe SCC FHCUP 1.00 1.02 99110-G2100 ', + b'\xf1\x00AEhe SCC F-CUP 1.00 1.00 99110-G2200 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\000AE MDPS C 1.00 1.01 56310/G2510 4APHC101', + b'\xf1\x00AE MDPS C 1.00 1.01 56310/G2560 4APHC101', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\000AEP MFC AT USA LHD 1.00 1.01 95740-G2600 190819', + b'\xf1\x00AEP MFC AT EUR RHD 1.00 1.01 95740-G2600 190819', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x816H6F6051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x816U3J9051\000\000\xf1\0006U3H1_C2\000\0006U3J9051\000\000PAE0G16NL0\x82zT\xd2', + b'\xf1\x816U3J8051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J8051\x00\x00PAETG16UL0\x00\x00\x00\x00', + ], + }, + CAR.IONIQ_EV_2020: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00AEev SCC F-CUP 1.00 1.01 99110-G7000 ', + b'\xf1\x00AEev SCC F-CUP 1.00 1.00 99110-G7200 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00AE MDPS C 1.00 1.01 56310/G7310 4APEC101', + b'\xf1\x00AE MDPS C 1.00 1.01 56310/G7560 4APEC101', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.01 95740-G2600 190819', + b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.03 95740-G2500 190516', + b'\xf1\x00AEE MFC AT EUR RHD 1.00 1.01 95740-G2600 190819', + ], + }, + CAR.IONIQ_EV_LTD: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00AEev SCC F-CUP 1.00 1.00 96400-G7000 ', + b'\xf1\x00AEev SCC F-CUP 1.00 1.00 96400-G7100 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00AE MDPS C 1.00 1.02 56310G7300\x00 4AEEC102', + b'\xf1\x00AE MDPS C 1.00 1.04 56310/G7501 4AEEC104', + b'\xf1\x00AE MDPS C 1.00 1.03 56310/G7300 4AEEC103', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.00 95740-G7200 160418', + b'\xf1\x00AEE MFC AT USA LHD 1.00 1.00 95740-G2400 180222', + b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.00 95740-G2300 170703', + ], + }, + CAR.IONIQ_HEV_2022: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00AEhe SCC F-CUP 1.00 1.00 99110-G2600 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00AE MDPS C 1.00 1.01 56310G2510\x00 4APHC101', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00AEH MFC AT USA LHD 1.00 1.00 95740-G2700 201027', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x816H6G5051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x816U3J9051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J9051\x00\x00HAE0G16NL2\x00\x00\x00\x00', + ], + }, + CAR.SONATA: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00DN8 1.00 99110-L0000 \xaa\xaa\xaa\xaa\xaa\xaa\xaa ', + b'\xf1\x00DN8 1.00 99110-L0000 \xaa\xaa\xaa\xaa\xaa\xaa\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x00DN8_ SCC F-CU- 1.00 1.00 99110-L0000 ', + b'\xf1\x00DN8_ SCC F-CUP 1.00 1.00 99110-L0000 ', + b'\xf1\x00DN8_ SCC F-CUP 1.00 1.02 99110-L1000 ', + b'\xf1\x00DN8_ SCC FHCUP 1.00 1.00 99110-L0000 ', + b'\xf1\x00DN8_ SCC FHCUP 1.00 1.01 99110-L1000 ', + b'\xf1\x00DN89110-L0000 \xaa\xaa\xaa\xaa\xaa\xaa\xaa ', + b'\xf1\x8799110L0000\xf1\x00DN8_ SCC F-CUP 1.00 1.00 99110-L0000 ', + b'\xf1\x8799110L0000\xf1\x00DN8_ SCC FHCUP 1.00 1.00 99110-L0000 ', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00DN ESC \a 106 \a\x01 58910-L0100', + b'\xf1\x00DN ESC \x01 102\x19\x04\x13 58910-L1300', + b'\xf1\x00DN ESC \x03 100 \x08\x01 58910-L0300', + b'\xf1\x00DN ESC \x06 104\x19\x08\x01 58910-L0100', + b'\xf1\x00DN ESC \x07 104\x19\x08\x01 58910-L0100', + b'\xf1\x00DN ESC \x08 103\x19\x06\x01 58910-L1300', + b'\xf1\x8758910-L0100\xf1\x00DN ESC \a 106 \a\x01 58910-L0100', + b'\xf1\x8758910-L0100\xf1\x00DN ESC \x06 104\x19\x08\x01 58910-L0100', + b'\xf1\x8758910-L0100\xf1\x00DN ESC \x06 106 \x07\x01 58910-L0100', + b'\xf1\x8758910-L0100\xf1\x00DN ESC \x07 104\x19\x08\x01 58910-L0100', + b'\xf1\x8758910-L0300\xf1\x00DN ESC \x03 100 \x08\x01 58910-L0300', + b'\xf1\x00DN ESC \x06 106 \x07\x01 58910-L0100', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x81HM6M1_0a0_F00', + b'\xf1\x82DNBVN5GMCCXXXDCA', + b'\xf1\x82DNBVN5GMCCXXXG2F', + b'\xf1\x82DNBWN5TMDCXXXG2E', + b'\xf1\x82DNCVN5GMCCXXXF0A', + b'\xf1\x82DNCVN5GMCCXXXG2B', + b'\xf1\x870\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\x82DNDWN5TMDCXXXJ1A', + b'\xf1\x87391162M003', + b'\xf1\x87391162M013', + b'\xf1\x87391162M023', + b'HM6M1_0a0_F00', + b'HM6M1_0a0_G20', + b'HM6M2_0a0_BD0', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00DN8 MDPS C 1.00 1.01 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 4DNAC101', + b'\xf1\x00DN8 MDPS C 1.00 1.01 56310-L0010 4DNAC101', + b'\xf1\x00DN8 MDPS C 1.00 1.01 56310L0010\x00 4DNAC101', + b'\xf1\x00DN8 MDPS R 1.00 1.00 57700-L0000 4DNAP100', + b'\xf1\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\x00DN8 MDPS C 1.00 1.01 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 4DNAC101', + b'\xf1\x8756310-L0010\xf1\x00DN8 MDPS C 1.00 1.01 56310-L0010 4DNAC101', + b'\xf1\x8756310-L0210\xf1\x00DN8 MDPS C 1.00 1.01 56310-L0210 4DNAC101', + b'\xf1\x8756310-L1010\xf1\x00DN8 MDPS C 1.00 1.03 56310-L1010 4DNDC103', + b'\xf1\x8756310-L1030\xf1\x00DN8 MDPS C 1.00 1.03 56310-L1030 4DNDC103', + b'\xf1\x8756310L0010\x00\xf1\x00DN8 MDPS C 1.00 1.01 56310L0010\x00 4DNAC101', + b'\xf1\x8756310L0210\x00\xf1\x00DN8 MDPS C 1.00 1.01 56310L0210\x00 4DNAC101', + b'\xf1\x8757700-L0000\xf1\x00DN8 MDPS R 1.00 1.00 57700-L0000 4DNAP100', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00DN8 MFC AT KOR LHD 1.00 1.02 99211-L1000 190422', + b'\xf1\x00DN8 MFC AT RUS LHD 1.00 1.03 99211-L1000 190705', + 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', + b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.03 99211-L0000 210603', + b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.05 99211-L1000 201109', + b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.06 99211-L1000 210325', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB1\xe3\xc10\xa1', + b'\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', + b'\xf1\x00HT6TA260BLHT6TA800A1TDN8C20KS4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x00HT6TA260BLHT6TA810A1TDN8M25GS0\x00\x00\x00\x00\x00\x00\xaa\x8c\xd9p', + b'\xf1\x00HT6WA250BLHT6WA910A1SDN8G25NB1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x00HT6WA250BLHT6WA910A1SDN8G25NB1\x00\x00\x00\x00\x00\x00\x96\xa1\xf1\x92', + b'\xf1\x00HT6WA280BLHT6WAD10A1SDN8G25NB2\x00\x00\x00\x00\x00\x00\x08\xc9O:', + b'\xf1\x00T02601BL T02730A1 VDN8T25XXX730NS5\xf7_\x92\xf5', + b'\xf1\x87954A02N060\x00\x00\x00\x00\x00\xf1\x81T02730A1 \xf1\x00T02601BL T02730A1 VDN8T25XXX730NS5\xf7_\x92\xf5', + b'\xf1\x87SAKFBA2926554GJ2VefVww\x87xwwwww\x88\x87xww\x87wTo\xfb\xffvUo\xff\x8d\x16\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SAKFBA3030524GJ2UVugww\x97yx\x88\x87\x88vw\x87gww\x87wto\xf9\xfffUo\xff\xa2\x0c\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SAKFBA3356084GJ2\x86fvgUUuWgw\x86www\x87wffvf\xb6\xcf\xfc\xffeUO\xff\x12\x19\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SAKFBA3474944GJ2ffvgwwwwg\x88\x86x\x88\x88\x98\x88ffvfeo\xfa\xff\x86fo\xff\t\xae\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SAKFBA3475714GJ2Vfvgvg\x96yx\x88\x97\x88ww\x87ww\x88\x87xs_\xfb\xffvUO\xff\x0f\xff\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALDBA3510954GJ3ww\x87xUUuWx\x88\x87\x88\x87w\x88wvfwfc_\xf9\xff\x98wO\xffl\xe0\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA3573534GJ3\x89\x98\x89\x88EUuWgwvwwwwww\x88\x87xTo\xfa\xff\x86f\x7f\xffo\x0e\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA3601464GJ3\x88\x88\x88\x88ffvggwvwvw\x87gww\x87wvo\xfb\xff\x98\x88\x7f\xffjJ\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA3753044GJ3UUeVff\x86hwwwwvwwgvfgfvo\xf9\xfffU_\xffC\xae\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA3862294GJ3vfvgvefVxw\x87\x87w\x88\x87xwwwwc_\xf9\xff\x87w\x9f\xff\xd5\xdc\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA3873834GJ3fefVwuwWx\x88\x97\x88w\x88\x97xww\x87wU_\xfb\xff\x86f\x8f\xffN\x04\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA4525334GJ3\x89\x99\x99\x99fevWh\x88\x86\x88fwvgw\x88\x87xfo\xfa\xffuDo\xff\xd1>\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA4626804GJ3wwww\x88\x87\x88xx\x88\x87\x88wwgw\x88\x88\x98\x88\x95_\xf9\xffuDo\xff|\xe7\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA4803224GJ3wwwwwvwg\x88\x88\x98\x88wwww\x87\x88\x88xu\x9f\xfc\xff\x87f\x8f\xff\xea\xea\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA6212564GJ3\x87wwwUTuGg\x88\x86xx\x88\x87\x88\x87\x88\x98xu?\xf9\xff\x97f\x7f\xff\xb8\n\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA6347404GJ3wwwwff\x86hx\x88\x97\x88\x88\x88\x88\x88vfgf\x88?\xfc\xff\x86Uo\xff\xec/\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA6901634GJ3UUuWVeVUww\x87wwwwwvUge\x86/\xfb\xff\xbb\x99\x7f\xff]2\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALDBA7077724GJ3\x98\x88\x88\x88ww\x97ygwvwww\x87ww\x88\x87x\x87_\xfd\xff\xba\x99o\xff\x99\x01\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SALFBA3525114GJ2wvwgvfvggw\x86wffvffw\x86g\x85_\xf9\xff\xa8wo\xffv\xcd\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA3624024GJ2\x88\x88\x88\x88wv\x87hx\x88\x97\x88x\x88\x97\x88ww\x87w\x86o\xfa\xffvU\x7f\xff\xd1\xec\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA3960824GJ2wwwwff\x86hffvfffffvfwfg_\xf9\xff\xa9\x88\x8f\xffb\x99\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA4011074GJ2fgvwwv\x87hw\x88\x87xww\x87wwfgvu_\xfa\xffefo\xff\x87\xc0\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA4121304GJ2x\x87xwff\x86hwwwwww\x87wwwww\x84_\xfc\xff\x98\x88\x9f\xffi\xa6\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA4195874GJ2EVugvf\x86hgwvwww\x87wgw\x86wc_\xfb\xff\x98\x88\x8f\xff\xe23\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA4625294GJ2eVefeUeVx\x88\x97\x88wwwwwwww\xa7o\xfb\xffvw\x9f\xff\xee.\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA4728774GJ2vfvg\x87vwgww\x87ww\x88\x97xww\x87w\x86_\xfb\xffeD?\xffk0\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA5129064GJ2vfvgwv\x87hx\x88\x87\x88ww\x87www\x87wd_\xfa\xffvfo\xff\x1d\x00\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA5454914GJ2\x98\x88\x88\x88\x87vwgx\x88\x87\x88xww\x87ffvf\xa7\x7f\xf9\xff\xa8w\x7f\xff\x1b\x90\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA5987784GJ2UVugDDtGx\x88\x87\x88w\x88\x87xwwwwd/\xfb\xff\x97fO\xff\xb0h\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA5987864GJ2fgvwUUuWgwvw\x87wxwwwww\x84/\xfc\xff\x97w\x7f\xff\xdf\x1d\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA6337644GJ2vgvwwv\x87hgffvwwwwwwww\x85O\xfa\xff\xa7w\x7f\xff\xc5\xfc\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA6802004GJ2UUuWUUuWgw\x86www\x87www\x87w\x96?\xf9\xff\xa9\x88\x7f\xff\x9fK\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA6892284GJ233S5\x87w\x87xx\x88\x87\x88vwwgww\x87w\x84?\xfb\xff\x98\x88\x8f\xff*\x9e\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', + b'\xf1\x87SALFBA7005534GJ2eUuWfg\x86xxww\x87x\x88\x87\x88\x88w\x88\x87\x87O\xfc\xffuUO\xff\xa3k\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB1\xe3\xc10\xa1', + b'\xf1\x87SALFBA7152454GJ2gvwgFf\x86hx\x88\x87\x88vfWfffffd?\xfa\xff\xba\x88o\xff,\xcf\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB1\xe3\xc10\xa1', + b'\xf1\x87SALFBA7485034GJ2ww\x87xww\x87xfwvgwwwwvfgf\xa5/\xfc\xff\xa9w_\xff40\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', + b'\xf1\x87SAMDBA7743924GJ3wwwwww\x87xgwvw\x88\x88\x88\x88wwww\x85_\xfa\xff\x86f\x7f\xff0\x9d\xf1\x89HT6WAD10A1\xf1\x82SDN8G25NB2\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SAMDBA7817334GJ3Vgvwvfvgww\x87wwwwwwfgv\x97O\xfd\xff\x88\x88o\xff\x8e\xeb\xf1\x89HT6WAD10A1\xf1\x82SDN8G25NB2\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SAMDBA8054504GJ3gw\x87xffvgffffwwwweUVUf?\xfc\xffvU_\xff\xddl\xf1\x89HT6WAD10A1\xf1\x82SDN8G25NB2\x00\x00\x00\x00\x00\x00', + b'\xf1\x87SAMFB41553621GC7ww\x87xUU\x85Xvwwg\x88\x88\x88\x88wwgw\x86\xaf\xfb\xffuDo\xff\xaa\x8f\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', + b'\xf1\x87SAMFB42555421GC7\x88\x88\x88\x88wvwgx\x88\x87\x88wwgw\x87wxw3\x8f\xfc\xff\x98f\x8f\xffga\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', + b'\xf1\x87SAMFBA7978674GJ2gw\x87xgw\x97ywwwwvUGeUUeU\x87O\xfb\xff\x98w\x8f\xfffF\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', + b'\xf1\x87SAMFBA9283024GJ2wwwwEUuWwwgwwwwwwwww\x87/\xfb\xff\x98w\x8f\xff<\xd3\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', + b'\xf1\x87SAMFBA9708354GJ2wwwwVf\x86h\x88wx\x87xww\x87\x88\x88\x88\x88w/\xfa\xff\x97w\x8f\xff\x86\xa0\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', + ], + }, + CAR.SONATA_LF: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00LF__ SCC F-CUP 1.00 1.00 96401-C2200 ', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00LF ESC \f 11 \x17\x01\x13 58920-C2610', + b'\xf1\x00LF ESC \t 11 \x17\x01\x13 58920-C2610', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x81606D5051\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x81606D5K51\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x81606G1051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00LFF LKAS AT USA LHD 1.00 1.01 95740-C1000 E51', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x006T6H0_C2\x00\x006T6B4051\x00\x00TLF0G24NL1\xb0\x9f\xee\xf5', + b'\xf1\x87\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\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf1\x816T6B4051\x00\x00\xf1\x006T6H0_C2\x00\x006T6B4051\x00\x00TLF0G24NL1\x00\x00\x00\x00', + b'\xf1\x87\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\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf1\x816T6B4051\x00\x00\xf1\x006T6H0_C2\x00\x006T6B4051\x00\x00TLF0G24NL1\xb0\x9f\xee\xf5', + b'\xf1\x87\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\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf1\x816T6B4051\x00\x00\xf1\x006T6H0_C2\x00\x006T6B4051\x00\x00TLF0G24SL2n\x8d\xbe\xd8', + b'\xf1\x87LAHSGN012918KF10\x98\x88x\x87\x88\x88x\x87\x88\x88\x98\x88\x87w\x88w\x88\x88\x98\x886o\xf6\xff\x98w\x7f\xff3\x00\xf1\x816W3B1051\x00\x00\xf1\x006W351_C2\x00\x006W3B1051\x00\x00TLF0T20NL2\x00\x00\x00\x00', + b'\xf1\x87LAHSGN012918KF10\x98\x88x\x87\x88\x88x\x87\x88\x88\x98\x88\x87w\x88w\x88\x88\x98\x886o\xf6\xff\x98w\x7f\xff3\x00\xf1\x816W3B1051\x00\x00\xf1\x006W351_C2\x00\x006W3B1051\x00\x00TLF0T20NL2H\r\xbdm', + ], + }, + CAR.SANTA_FE: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00TM__ SCC F-CUP 1.00 1.01 99110-S2000 ', + b'\xf1\x00TM__ SCC F-CUP 1.00 1.02 99110-S2000 ', + b'\xf1\x00TM__ SCC F-CUP 1.00 1.03 99110-S2000 ', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00TM ESC \r 100\x18\x031 58910-S2650', + b'\xf1\x00TM ESC \r 103\x18\x11\x08 58910-S2650', + b'\xf1\x00TM ESC \r 104\x19\a\b 58910-S2650', + b'\xf1\x00TM ESC \x02 100\x18\x030 58910-S2600', + b'\xf1\x00TM ESC \x02 102\x18\x07\x01 58910-S2600', + b'\xf1\x00TM ESC \x02 103\x18\x11\x07 58910-S2600', + b'\xf1\x00TM ESC \x02 104\x19\x07\x07 58910-S2600', + b'\xf1\x00TM ESC \x03 103\x18\x11\x07 58910-S2600', + b'\xf1\x00TM ESC \x0c 103\x18\x11\x08 58910-S2650', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x81606EA051\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x81606G1051\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x81606G3051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00TM MDPS C 1.00 1.00 56340-S2000 8409', + b'\xf1\x00TM MDPS C 1.00 1.00 56340-S2000 8A12', + b'\xf1\x00TM MDPS C 1.00 1.01 56340-S2000 9129', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00TM MFC AT USA LHD 1.00 1.00 99211-S2000 180409', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x87LBJSGA7082574HG0\x87www\x98\x88\x88\x88\x99\xaa\xb9\x9afw\x86gx\x99\xa7\x89co\xf8\xffvU_\xffR\xaf\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2T20NS1\x00\xa6\xe0\x91', + b'\xf1\x87LBKSGA0458404HG0vfvg\x87www\x89\x99\xa8\x99y\xaa\xa7\x9ax\x88\xa7\x88t_\xf9\xff\x86w\x8f\xff\x15x\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2T20NS1\x00\x00\x00\x00', + b'\xf1\x87LDJUEA6010814HG1\x87w\x87x\x86gvw\x88\x88\x98\x88gw\x86wx\x88\x97\x88\x85o\xf8\xff\x86f_\xff\xd37\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4T20NS0\xf8\x19\x92g', + b'\xf1\x87LDJUEA6458264HG1ww\x87x\x97x\x87\x88\x88\x99\x98\x89g\x88\x86xw\x88\x97x\x86o\xf7\xffvw\x8f\xff3\x9a\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4T20NS0\xf8\x19\x92g', + b'\xf1\x87LDKUEA2045844HG1wwww\x98\x88x\x87\x88\x88\xa8\x88x\x99\x97\x89x\x88\xa7\x88U\x7f\xf8\xffvfO\xffC\x1e\xf1\x816W3E0051\x00\x00\xf1\x006W351_C2\x00\x006W3E0051\x00\x00TTM4T20NS3\x00\x00\x00\x00', + b'\xf1\x87LDKUEA9993304HG1\x87www\x97x\x87\x88\x99\x99\xa9\x99x\x99\xa7\x89w\x88\x97x\x86_\xf7\xffwwO\xffl#\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4T20NS1R\x7f\x90\n', + b'\xf1\x87LDLUEA6061564HG1\xa9\x99\x89\x98\x87wwwx\x88\x97\x88x\x99\xa7\x89x\x99\xa7\x89sO\xf9\xffvU_\xff<\xde\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS50\xcb\xc3\xed', + b'\xf1\x87LDLUEA6159884HG1\x88\x87hv\x99\x99y\x97\x89\xaa\xb8\x9ax\x99\x87\x89y\x99\xb7\x99\xa7?\xf7\xff\x97wo\xff\xf3\x05\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS5\x00\x00\x00\x00', + b'\xf1\x87LDLUEA6852664HG1\x97wWu\x97www\x89\xaa\xc8\x9ax\x99\x97\x89x\x99\xa7\x89SO\xf7\xff\xa8\x88\x7f\xff\x03z\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS50\xcb\xc3\xed', + b'\xf1\x87LDLUEA6898374HG1fevW\x87wwwx\x88\x97\x88h\x88\x96\x88x\x88\xa7\x88ao\xf9\xff\x98\x99\x7f\xffD\xe2\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS5\x00\x00\x00\x00', + b'\xf1\x87LDLUEA6898374HG1fevW\x87wwwx\x88\x97\x88h\x88\x96\x88x\x88\xa7\x88ao\xf9\xff\x98\x99\x7f\xffD\xe2\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS50\xcb\xc3\xed', + b'\xf1\x87SBJWAA5842214GG0\x88\x87\x88xww\x87x\x89\x99\xa8\x99\x88\x99\x98\x89w\x88\x87xw_\xfa\xfffU_\xff\xd1\x8d\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS1\x98{|\xe3', + b'\xf1\x87SBJWAA5890864GG0\xa9\x99\x89\x98\x98\x87\x98y\x89\x99\xa8\x99w\x88\x87xww\x87wvo\xfb\xffuD_\xff\x9f\xb5\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS1\x98{|\xe3', + 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', + 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\x98{|\xe3', + b'\xf1\x87SBJWAA7780564GG0wvwgUUeVwwwwx\x88\x87\x88wwwwd_\xfc\xff\x86f\x7f\xff\xd7*\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS2F\x84<\xc0', + b'\xf1\x87SBJWAA8278284GG0ffvgUU\x85Xx\x88\x87\x88x\x88w\x88ww\x87w\x96o\xfd\xff\xa7U_\xff\xf2\xa0\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS2F\x84<\xc0', + b'\xf1\x87SBLWAA4363244GG0wvwgwv\x87hgw\x86ww\x88\x87xww\x87wdo\xfb\xff\x86f\x7f\xff3$\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM2G24NS6\x00\x00\x00\x00', + b'\xf1\x87SBLWAA4363244GG0wvwgwv\x87hgw\x86ww\x88\x87xww\x87wdo\xfb\xff\x86f\x7f\xff3$\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM2G24NS6x0\x17\xfe', + b'\xf1\x87SBLWAA4899564GG0VfvgUU\x85Xx\x88\x87\x88vfgf\x87wxwvO\xfb\xff\x97f\xb1\xffSB\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM2G24NS7\x00\x00\x00\x00', + b'\xf1\x87SBLWAA6622844GG0wwwwff\x86hwwwwx\x88\x87\x88\x88\x88\x88\x88\x98?\xfd\xff\xa9\x88\x7f\xffn\xe5\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM2G24NS7u\x1e{\x1c', + b'\xf1\x87SDJXAA7656854GG1DEtWUU\x85X\x88\x88\x98\x88w\x88\x87xx\x88\x87\x88\x96o\xfb\xff\x86f\x7f\xff.\xca\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4G24NS2\x00\x00\x00\x00', + b'\xf1\x87SDJXAA7656854GG1DEtWUU\x85X\x88\x88\x98\x88w\x88\x87xx\x88\x87\x88\x96o\xfb\xff\x86f\x7f\xff.\xca\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4G24NS2K\xdaV0', + b'\xf1\x87SDKXAA2443414GG1vfvgwv\x87h\x88\x88\x88\x88ww\x87wwwww\x99_\xfc\xffvD?\xffl\xd2\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4G24NS6\x00\x00\x00\x00', + ], + }, + CAR.SANTA_FE_2022: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00TM__ SCC F-CUP 1.00 1.00 99110-S1500 ', + b'\xf1\x8799110S1500\xf1\x00TM__ SCC F-CUP 1.00 1.00 99110-S1500 ', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00TM ESC \x02 101 \x08\x04 58910-S2GA0', + b'\xf1\x00TM ESC \x03 101 \x08\x02 58910-S2DA0', + b'\xf1\x8758910-S2DA0\xf1\x00TM ESC \x03 101 \x08\x02 58910-S2DA0', + b'\xf1\x8758910-S2GA0\xf1\x00TM ESC \x02 101 \x08\x04 58910-S2GA0', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x82TMBZN5TMD3XXXG2E', + b'\xf1\x82TACVN5GSI3XXXH0A', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00TM MDPS C 1.00 1.02 56370-S2AA0 0B19', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00TMA MFC AT MEX LHD 1.00 1.01 99211-S2500 210205', + b'\xf1\x00TMA MFC AT USA LHD 1.00 1.00 99211-S2500 200720', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x00T02601BL T02730A1 VTMPT25XXX730NS2\xa6\x06\x88\xf7', + b'\xf1\x87SDMXCA8653204GN1EVugEUuWwwwwww\x87wwwwwv/\xfb\xff\xa8\x88\x9f\xff\xa5\x9c\xf1\x89HT6WAD00A1\xf1\x82STM4G25NH1\x00\x00\x00\x00\x00\x00', + b'\xf1\x87954A02N250\x00\x00\x00\x00\x00\xf1\x81T02730A1 \xf1\x00T02601BL T02730A1 VTMPT25XXX730NS2\xa6\x06\x88\xf7', + ], + }, + CAR.SANTA_FE_HEV_2022: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x8799110CL500\xf1\x00TMhe SCC FHCUP 1.00 1.00 99110-CL500 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00TM MDPS C 1.00 1.02 56310-CLAC0 4TSHC102', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00TMH MFC AT USA LHD 1.00 1.03 99211-S1500 210224', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x87959102T250\x00\x00\x00\x00\x00\xf1\x81E14\x00\x00\x00\x00\x00\x00\x00\xf1\x00PSBG2333 E14\x00\x00\x00\x00\x00\x00\x00TTM2H16SA2\x80\xd7l\xb2', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x87391312MTC1', + ], + }, + CAR.KIA_STINGER: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00CK__ SCC F_CUP 1.00 1.01 96400-J5100 ', + b'\xf1\x00CK__ SCC F_CUP 1.00 1.03 96400-J5100 ', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x81606DE051\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x81640E0051\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x82CKJN3TMSDE0B\x00\x00\x00\x00', + b'\xf1\x82CKKN3TMD_H0A\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5200 4C2CL104', + b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5220 4C2VL104', + b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5420 4C4VL104', + b'\xf1\x00CK MDPS R 1.00 1.06 57700-J5420 4C4VL106', + b'\xf1\x00CK MDPS R 1.00 1.07 57700-J5220 4C2VL107', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00CK MFC AT USA LHD 1.00 1.03 95740-J5000 170822', + b'\xf1\x00CK MFC AT USA LHD 1.00 1.04 95740-J5000 180504', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x87VCJLE17622572DK0vd6D\x99\x98y\x97vwVffUfvfC%CuT&Dx\x87o\xff{\x1c\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', + b'\xf1\x87VDHLG17000192DK2xdFffT\xa5VUD$DwT\x86wveVeeD&T\x99\xba\x8f\xff\xcc\x99\xf1\x89E21\x00\x00\x00\x00\x00\x00\x00\xf1\x82SCK0T33NB0', + b'\xf1\x87VDHLG17034412DK2vD6DfVvVTD$D\x99w\x88\x98EDEDeT6DgfO\xff\xc3=\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\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\x87VDKLJ18675252DK6\x89vhgwwwwveVU\x88w\x87w\x99vgf\x97vXfgw_\xff\xc2\xfb\xf1\x89E25\x00\x00\x00\x00\x00\x00\x00\xf1\x82TCK0T33NB2', + b'\xf1\x87WAJTE17552812CH4vfFffvfVeT5DwvvVVdFeegeg\x88\x88o\xff\x1a]\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00TCK2T20NB1\x19\xd2\x00\x94', + ], + }, + CAR.PALISADE: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\000LX2_ SCC F-CUP 1.00 1.05 99110-S8100 ', + b'\xf1\x00LX2 SCC FHCUP 1.00 1.04 99110-S8100 ', + b'\xf1\x00LX2_ SCC FHCU- 1.00 1.05 99110-S8100 ', + b'\xf1\x00LX2_ SCC FHCUP 1.00 1.00 99110-S8110 ', + b'\xf1\x00LX2_ SCC FHCUP 1.00 1.04 99110-S8100 ', + b'\xf1\x00LX2_ SCC FHCUP 1.00 1.05 99110-S8100 ', + b'\xf1\x00ON__ FCA FHCUP 1.00 1.02 99110-S9100 ', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00LX ESC \x01 103\x19\t\x10 58910-S8360', + b'\xf1\x00LX ESC \x01 103\x31\t\020 58910-S8360', + b'\xf1\x00LX ESC \x0b 101\x19\x03\x17 58910-S8330', + b'\xf1\x00LX ESC \x0b 102\x19\x05\x07 58910-S8330', + b'\xf1\x00LX ESC \x0b 103\x19\t\x07 58910-S8330', + b'\xf1\x00LX ESC \x0b 103\x19\t\x10 58910-S8360', + b'\xf1\x00LX ESC \x0b 104 \x10\x16 58910-S8360', + b'\xf1\x00ON ESC \x0b 100\x18\x12\x18 58910-S9360', + b'\xf1\x00ON ESC \x0b 101\x19\t\x08 58910-S9360', + ], + (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', + b'\xf1\x81640S1051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00LX2 MDPS C 1,00 1,03 56310-S8020 4LXDC103', # modified firmware + b'\xf1\x00LX2 MDPS C 1.00 1.03 56310-S8020 4LXDC103', + b'\xf1\x00LX2 MDPS C 1.00 1.04 56310-S8020 4LXDC104', + b'\xf1\x00ON MDPS C 1.00 1.00 56340-S9000 8B13', + b'\xf1\x00ON MDPS C 1.00 1.01 56340-S9000 9201', + ], + (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', + b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.07 99211-S8100 200422', + b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.08 99211-S8100 200903', + b'\xf1\x00ON MFC AT USA LHD 1.00 1.01 99211-S9100 181105', + b'\xf1\x00ON MFC AT USA LHD 1.00 1.03 99211-S9100 200720', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x00bcsh8p54 U872\x00\x00\x00\x00\x00\x00TON4G38NB1\x96z28', + b'\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00TON4G38NB2[v\\\xb6', + b'\xf1\x87LBLUFN591307KF25vgvw\x97wwwy\x99\xa7\x99\x99\xaa\xa9\x9af\x88\x96h\x95o\xf7\xff\x99f/\xff\xe4c\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB2\xd7\xc1/\xd1', + 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\x87LBLUFN655162KF36\x98\x88\x88\x88\x98\x88\x88\x88x\x99\xa7\x89x\x99\xa7\x89x\x99\x97\x89g\x7f\xf7\xffwU_\xff\xe9!\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8', + b'\xf1\x87LBLUFN731381KF36\xb9\x99\x89\x98\x98\x88\x88\x88\x89\x99\xa8\x99\x88\x99\xa8\x89\x88\x88\x98\x88V\177\xf6\xff\x99w\x8f\xff\xad\xd8\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\000bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8', + b'\xf1\x87LDKVAA0028604HH1\xa8\x88x\x87vgvw\x88\x99\xa8\x89gw\x86ww\x88\x97x\x97o\xf9\xff\x97w\x7f\xffo\x02\xf1\x81U872\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U872\x00\x00\x00\x00\x00\x00TON4G38NB1\x96z28', + b'\xf1\x87LDKVAA3068374HH1wwww\x87xw\x87y\x99\xa7\x99w\x88\x87xw\x88\x97x\x85\xaf\xfa\xffvU/\xffU\xdc\xf1\x81U872\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U872\x00\x00\x00\x00\x00\x00TON4G38NB1\x96z28', + b'\xf1\x87LDKVBN382172KF26\x98\x88\x88\x88\xa8\x88\x88\x88x\x99\xa7\x89\x87\x88\x98x\x98\x99\xa9\x89\xa5_\xf6\xffDDO\xff\xcd\x16\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', + 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\x87LDKVBN540766KF37\x87wgv\x87w\x87xx\x99\x97\x89v\x88\x97h\x88\x88\x88\x88x\x7f\xf6\xffvUo\xff\xd3\x01\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', + b'\xf1\x87LDLVAA4225634HH1\x98\x88\x88\x88eUeVx\x88\x87\x88g\x88\x86xx\x88\x87\x88\x86o\xf9\xff\x87w\x7f\xff\xf2\xf7\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00TON4G38NB2[v\\\xb6', + b'\xf1\x87LDLVAA4777834HH1\x98\x88x\x87\x87wwwx\x88\x87\x88x\x99\x97\x89x\x88\x97\x88\x86o\xfa\xff\x86fO\xff\x1d9\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00TON4G38NB2[v\\\xb6', + b'\xf1\x87LDLVAA5194534HH1ffvguUUUx\x88\xa7\x88h\x99\x96\x89x\x88\x97\x88ro\xf9\xff\x98wo\xff\xaaM\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00TON4G38NB2[v\\\xb6', + b'\xf1\x87LDLVAA5949924HH1\xa9\x99y\x97\x87wwwx\x99\x97\x89x\x99\xa7\x89x\x99\xa7\x89\x87_\xfa\xffeD?\xff\xf1\xfd\xf1\x81U903\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00TON4G38NB2[v\\\xb6', + 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', + b'\xf1\x87LDLVBN602045KF26\xb9\x99\x89\x98\x97vwgy\xaa\xb7\x9af\x88\x96hw\x99\xa7y\xa9\x7f\xf5\xff\x99w\x7f\xff,\xd3\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN628911KF26\xa9\x99\x89\x98\x98\x88\x88\x88y\x99\xa7\x99fw\x86gw\x88\x87x\x83\x7f\xf6\xff\x98wo\xff2\xda\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN645817KF37\x87www\x98\x87xwx\x99\x97\x89\x99\x99\x99\x99g\x88\x96x\xb6_\xf7\xff\x98fo\xff\xe2\x86\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN662115KF37\x98\x88\x88\x88\xa8\x88\x88\x88x\x99\x97\x89x\x99\xa7\x89\x88\x99\xa8\x89\x88\x7f\xf7\xfffD_\xff\xdc\x84\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN667933KF37\xb9\x99\x89\x98\xb9\x99\x99\x99x\x88\x87\x88w\x88\x87x\x88\x88\x98\x88\xcbo\xf7\xffe3/\xffQ!\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN673087KF37\x97www\x86fvgx\x99\x97\x89\x99\xaa\xa9\x9ag\x88\x86x\xe9_\xf8\xff\x98w\x7f\xff"\xad\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN673841KF37\x98\x88x\x87\x86g\x86xy\x99\xa7\x99\x88\x99\xa8\x89w\x88\x97xdo\xf5\xff\x98\x88\x8f\xffT\xec\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN681363KF37\x98\x88\x88\x88\x97x\x87\x88y\xaa\xa7\x9a\x88\x88\x98\x88\x88\x88\x88\x88vo\xf6\xffvD\x7f\xff%v\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN713782KF37\x99\x99y\x97\x98\x88\x88\x88x\x88\x97\x88\x88\x99\x98\x89\x88\x99\xa8\x89\x87o\xf7\xffeU?\xff7,\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN713890KF26\xb9\x99\x89\x98\xa9\x99\x99\x99x\x99\x97\x89\x88\x99\xa8\x89\x88\x99\xb8\x89Do\xf7\xff\xa9\x88o\xffs\r\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN733215KF37\x99\x98y\x87\x97wwwi\x99\xa6\x99x\x99\xa7\x89V\x88\x95h\x86o\xf7\xffeDO\xff\x12\xe7\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN750044KF37\xca\xa9\x8a\x98\xa7wwwy\xaa\xb7\x9ag\x88\x96x\x88\x99\xa8\x89\xb9\x7f\xf6\xff\xa8w\x7f\xff\xbe\xde\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN752612KF37\xba\xaa\x8a\xa8\x87w\x87xy\xaa\xa7\x9a\x88\x99\x98\x89x\x88\x97\x88\x96o\xf6\xffvU_\xffh\x1b\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN755553KF37\x87xw\x87\x97w\x87xy\x99\xa7\x99\x99\x99\xa9\x99Vw\x95gwo\xf6\xffwUO\xff\xb5T\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', + b'\xf1\x87LDLVBN757883KF37\x98\x87xw\x98\x87\x88xy\xaa\xb7\x9ag\x88\x96x\x89\x99\xa8\x99e\x7f\xf6\xff\xa9\x88o\xff5\x15\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', + b'\xf1\x87LDMVBN778156KF37\x87vWe\xa9\x99\x99\x99y\x99\xb7\x99\x99\x99\x99\x99x\x99\x97\x89\xa8\x7f\xf8\xffwf\x7f\xff\x82_\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', + b'\xf1\x87LDMVBN780576KF37\x98\x87hv\x97x\x97\x89x\x99\xa7\x89\x88\x99\x98\x89w\x88\x97x\x98\x7f\xf7\xff\xba\x88\x8f\xff\x1e0\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', + b'\xf1\x87LDMVBN783485KF37\x87www\x87vwgy\x99\xa7\x99\x99\x99\xa9\x99Vw\x95g\x89_\xf6\xff\xa9w_\xff\xc5\xd6\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', + b'\xf1\x87LDMVBN811844KF37\x87vwgvfffx\x99\xa7\x89Vw\x95gg\x88\xa6xe\x8f\xf6\xff\x97wO\xff\t\x80\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', + b'\xf1\x87LDMVBN830601KF37\xa7www\xa8\x87xwx\x99\xa7\x89Uw\x85Ww\x88\x97x\x88o\xf6\xff\x8a\xaa\x7f\xff\xe2:\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', + b'\xf1\x87LDMVBN848789KF37\x87w\x87x\x87w\x87xy\x99\xb7\x99\x87\x88\x98x\x88\x99\xa8\x89\x87\x7f\xf6\xfffUo\xff\xe3!\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN851595KF37\x97wgvvfffx\x99\xb7\x89\x88\x99\x98\x89\x87\x88\x98x\x99\x7f\xf7\xff\x97w\x7f\xff@\xf3\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN873175KF26\xa8\x88\x88\x88vfVex\x99\xb7\x89\x88\x99\x98\x89x\x88\x97\x88f\x7f\xf7\xff\xbb\xaa\x8f\xff,\x04\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN879401KF26veVU\xa8\x88\x88\x88g\x88\xa6xVw\x95gx\x88\xa7\x88v\x8f\xf9\xff\xdd\xbb\xbf\xff\xb3\x99\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN881314KF37\xa8\x88h\x86\x97www\x89\x99\xa8\x99w\x88\x97xx\x99\xa7\x89\xca\x7f\xf8\xff\xba\x99\x8f\xff\xd8v\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN888651KF37\xa9\x99\x89\x98vfff\x88\x99\x98\x89w\x99\xa7y\x88\x88\x98\x88D\x8f\xf9\xff\xcb\x99\x8f\xff\xa5\x1e\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN889419KF37\xa9\x99y\x97\x87w\x87xx\x88\x97\x88w\x88\x97x\x88\x99\x98\x89e\x9f\xf9\xffeUo\xff\x901\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN895969KF37vefV\x87vgfx\x99\xa7\x89\x99\x99\xb9\x99f\x88\x96he_\xf7\xffxwo\xff\x14\xf9\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b'\xf1\x87LDMVBN899222KF37\xa8\x88x\x87\x97www\x98\x99\x99\x89\x88\x99\x98\x89f\x88\x96hdo\xf7\xff\xbb\xaa\x9f\xff\xe2U\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB5\xb9\x94\xe8\x89', + b"\xf1\x87LBLUFN622950KF36\xa8\x88\x88\x88\x87w\x87xh\x99\x96\x89\x88\x99\x98\x89\x88\x99\x98\x89\x87o\xf6\xff\x98\x88o\xffx'\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8", + ], + }, + CAR.VELOSTER: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00JS__ SCC H-CUP 1.00 1.02 95650-J3200 ', + b'\xf1\x00JS__ SCC HNCUP 1.00 1.02 95650-J3100 ', + ], + (Ecu.esp, 0x7d1, None): [b'\xf1\x00\x00\x00\x00\x00\x00\x00', ], + (Ecu.engine, 0x7e0, None): [ + b'\x01TJS-JNU06F200H0A', + b'\x01TJS-JDK06F200H0A', + ], + (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', + b'\xf1\x00JS LKAS AT KOR LHD 1.00 1.03 95740-J3000 K33', + ], + (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', + b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJS0T16KS2\016\xba\036\xa2', + ], + }, + CAR.GENESIS_G70: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00IK__ SCC F-CUP 1.00 1.02 96400-G9100 ', ], + (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.GENESIS_G70_2020: { + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00IK MDPS R 1.00 1.07 57700-G9220 4I2VL107', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x87VCJLP18407832DN3\x88vXfvUVT\x97eFU\x87d7v\x88eVeveFU\x89\x98\x7f\xff\xb2\xb0\xf1\x81E25\x00\x00\x00' + b'\x00\x00\x00\x00\xf1\x00bcsh8p54 E25\x00\x00\x00\x00\x00\x00\x00SIK0T33NB4\xecE\xefL', + ], + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00IK__ SCC F-CUP 1.00 1.02 96400-G9100 ', + b'\xf1\x00IK__ SCC F-CUP 1.00 1.02 96400-G9100 \xf1\xa01.02', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00IK MFC AT USA LHD 1.00 1.01 95740-G9000 170920', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x81640J0051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + }, + CAR.KONA: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00OS__ SCC F-CUP 1.00 1.00 95655-J9200 ', ], + (Ecu.esp, 0x7d1, None): [b'\xf1\x816V5RAK00018.ELF\xf1\x00\x00\x00\x00\x00\x00\x00', ], + (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.KIA_CEED: { + (Ecu.fwdRadar, 0x7D0, None): [b'\xf1\000CD__ SCC F-CUP 1.00 1.02 99110-J7000 ', ], + (Ecu.esp, 0x7D4, None): [b'\xf1\000CD MDPS C 1.00 1.06 56310-XX000 4CDEC106', ], + (Ecu.fwdCamera, 0x7C4, None): [b'\xf1\000CD LKAS AT EUR LHD 1.00 1.01 99211-J7000 B40', ], + (Ecu.engine, 0x7E0, None): [b'\001TCD-JECU4F202H0K', ], + (Ecu.transmission, 0x7E1, None): [ + b'\xf1\x816U2V7051\000\000\xf1\0006U2V0_C2\000\0006U2V7051\000\000DCD0T14US1\000\000\000\000', + b'\xf1\x816U2V7051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V7051\x00\x00DCD0T14US1U\x867Z', + ], + (Ecu.esp, 0x7D1, None): [b'\xf1\000CD ESC \003 102\030\b\005 58920-J7350', ], + }, + CAR.KIA_FORTE: { + (Ecu.eps, 0x7D4, None): [ + b'\xf1\x00BD MDPS C 1.00 1.02 56310-XX000 4BD2C102', + b'\xf1\x00BD MDPS C 1.00 1.08 56310/M6300 4BDDC108', + b'\xf1\x00BD MDPS C 1.00 1.08 56310M6300\x00 4BDDC108', + ], + (Ecu.fwdCamera, 0x7C4, None): [ + b'\xf1\x00BD LKAS AT USA LHD 1.00 1.04 95740-M6000 J33', + ], + (Ecu.fwdRadar, 0x7D0, None): [ + b'\xf1\x00BD__ SCC H-CUP 1.00 1.02 99110-M6000 ', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x01TBDM1NU06F200H01', + b'391182B945\x00', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x816VGRAH00018.ELF\xf1\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x816U2VC051\x00\x00\xf1\x006U2V0_C2\x00\x006U2VC051\x00\x00DBD0T16SS0\x00\x00\x00\x00', + b"\xf1\x816U2VC051\x00\x00\xf1\x006U2V0_C2\x00\x006U2VC051\x00\x00DBD0T16SS0\xcf\x1e'\xc3", + ], + }, + CAR.KIA_K5_2021: { + (Ecu.fwdRadar, 0x7D0, None): [ + b'\xf1\000DL3_ SCC FHCUP 1.00 1.03 99110-L2000 ', + b'\xf1\x8799110L2000\xf1\000DL3_ SCC FHCUP 1.00 1.03 99110-L2000 ', + b'\xf1\x8799110L2100\xf1\x00DL3_ SCC F-CUP 1.00 1.03 99110-L2100 ', + b'\xf1\x8799110L2100\xf1\x00DL3_ SCC FHCUP 1.00 1.03 99110-L2100 ', + ], + (Ecu.eps, 0x7D4, None): [ + b'\xf1\x8756310-L3110\xf1\000DL3 MDPS C 1.00 1.01 56310-L3110 4DLAC101', + b'\xf1\x8756310-L3220\xf1\x00DL3 MDPS C 1.00 1.01 56310-L3220 4DLAC101', + b'\xf1\x8757700-L3000\xf1\x00DL3 MDPS R 1.00 1.02 57700-L3000 4DLAP102', + ], + (Ecu.fwdCamera, 0x7C4, None): [ + b'\xf1\x00DL3 MFC AT USA LHD 1.00 1.03 99210-L3000 200915', + b'\xf1\x00DL3 MFC AT USA LHD 1.00 1.04 99210-L3000 210208', + ], + (Ecu.esp, 0x7D1, None): [ + b'\xf1\000DL ESC \006 101 \004\002 58910-L3200', + b'\xf1\x8758910-L3200\xf1\000DL ESC \006 101 \004\002 58910-L3200', + b'\xf1\x8758910-L3800\xf1\x00DL ESC \t 101 \x07\x02 58910-L3800', + b'\xf1\x8758910-L3600\xf1\x00DL ESC \x03 100 \x08\x02 58910-L3600', + ], + (Ecu.engine, 0x7E0, None): [ + b'\xf1\x87391212MKT0', + b'\xf1\x87391212MKV0', + b'\xf1\x870\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\x82DLDWN5TMDCXXXJ1B', + ], + (Ecu.transmission, 0x7E1, None): [ + b'\xf1\000bcsh8p54 U913\000\000\000\000\000\000TDL2T16NB1ia\v\xb8', + b'\xf1\x87SALFEA5652514GK2UUeV\x88\x87\x88xxwg\x87ww\x87wwfwvd/\xfb\xffvU_\xff\x93\xd3\xf1\x81U913\000\000\000\000\000\000\xf1\000bcsh8p54 U913\000\000\000\000\000\000TDL2T16NB1ia\v\xb8', + b'\xf1\x87SALFEA6046104GK2wvwgeTeFg\x88\x96xwwwwffvfe?\xfd\xff\x86fo\xff\x97A\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00TDL2T16NB1ia\x0b\xb8', + b'\xf1\x87SCMSAA8572454GK1\x87x\x87\x88Vf\x86hgwvwvwwgvwwgT?\xfb\xff\x97fo\xffH\xb8\xf1\x81U913\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00TDL4T16NB05\x94t\x18', + b'\xf1\x87954A02N300\x00\x00\x00\x00\x00\xf1\x81T02730A1 \xf1\x00T02601BL T02730A1 WDL3T25XXX730NS2b\x1f\xb8%', + ], + }, + CAR.KONA_EV: { + (Ecu.esp, 0x7D1, None): [ + b'\xf1\x00OS IEB \r 105\x18\t\x18 58520-K4000', + b'\xf1\x00OS IEB \x01 212 \x11\x13 58520-K4000', + b'\xf1\x00OS IEB \x02 212 \x11\x13 58520-K4000', + b'\xf1\x00OS IEB \x03 210 \x02\x14 58520-K4000', + b'\xf1\x00OS IEB \x03 212 \x11\x13 58520-K4000', + ], + (Ecu.fwdCamera, 0x7C4, None): [ + b'\xf1\x00OE2 LKAS AT EUR LHD 1.00 1.00 95740-K4200 200', + b'\xf1\x00OSE LKAS AT EUR LHD 1.00 1.00 95740-K4100 W40', + b'\xf1\x00OSE LKAS AT EUR RHD 1.00 1.00 95740-K4100 W40', + b'\xf1\x00OSE LKAS AT KOR LHD 1.00 1.00 95740-K4100 W40', + b'\xf1\x00OSE LKAS AT USA LHD 1.00 1.00 95740-K4300 W50', + ], + (Ecu.eps, 0x7D4, None): [ + b'\xf1\x00OS MDPS C 1.00 1.03 56310/K4550 4OEDC103', + b'\xf1\x00OS MDPS C 1.00 1.04 56310K4000\x00 4OEDC104', + 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.00 99110-K4000 ', + b'\xf1\x00OSev SCC F-CUP 1.00 1.00 99110-K4100 ', + b'\xf1\x00OSev SCC F-CUP 1.00 1.01 99110-K4000 ', + b'\xf1\x00OSev SCC FNCUP 1.00 1.01 99110-K4000 ', + ], + }, + CAR.KIA_NIRO_EV: { + (Ecu.fwdRadar, 0x7D0, None): [ + b'\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4000 ', + b'\xf1\x00DEev SCC F-CUP 1.00 1.02 96400-Q4100 ', + b'\xf1\x00DEev SCC F-CUP 1.00 1.03 96400-Q4100 ', + b'\xf1\x00OSev SCC F-CUP 1.00 1.01 99110-K4000 ', + b'\xf1\x8799110Q4000\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4000 ', + b'\xf1\x8799110Q4100\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4100 ', + b'\xf1\x8799110Q4500\xf1\000DEev SCC F-CUP 1.00 1.00 99110-Q4500 ', + ], + (Ecu.esp, 0x7D1, None): [ + b'\xf1\x00OS IEB \r 212 \x11\x13 58520-K4000', + ], + (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', + b'\xf1\x00OS MDPS C 1.00 1.04 56310K4050\x00 4OEDC104', + ], + (Ecu.fwdCamera, 0x7C4, None): [ + b'\xf1\000DEE MFC AT EUR LHD 1.00 1.00 99211-Q4100 200706', + b'\xf1\x00DEE MFC AT EUR LHD 1.00 1.00 99211-Q4000 191211', + b'\xf1\x00DEE MFC AT USA LHD 1.00 1.00 99211-Q4000 191211', + b'\xf1\x00DEE MFC AT USA LHD 1.00 1.03 95740-Q4000 180821', + b'\xf1\x00OSE LKAS AT EUR LHD 1.00 1.00 95740-K4100 W40', + ], + }, + CAR.KIA_NIRO_HEV: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x816H6F4051\000\000\000\000\000\000\000\000', + ], + (Ecu.transmission, 0x7e1, None): [ + b"\xf1\x816U3J2051\000\000\xf1\0006U3H0_C2\000\0006U3J2051\000\000PDE0G16NS2\xf4\'\\\x91", + b'\xf1\x816U3J2051\000\000\xf1\0006U3H0_C2\000\0006U3J2051\000\000PDE0G16NS2\000\000\000\000', + ], + (Ecu.eps, 0x7D4, None): [ + b'\xf1\000DE MDPS C 1.00 1.09 56310G5301\000 4DEHC109', + ], + (Ecu.fwdCamera, 0x7C4, None): [ + b'\xf1\000DEP MFC AT USA LHD 1.00 1.01 95740-G5010 170424', + ], + (Ecu.fwdRadar, 0x7D0, None): [ + b'\xf1\000DEhe SCC H-CUP 1.01 1.02 96400-G5100 ', + ], + }, + CAR.KIA_NIRO_HEV_2021: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x816H6G5051\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x816U3J9051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J9051\x00\x00HDE0G16NL3\x00\x00\x00\x00', + b'\xf1\x816U3J9051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J9051\x00\x00HDE0G16NL3\xb9\xd3\xfaW', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00DE MDPS C 1.00 1.01 56310G5520\x00 4DEPC101', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00DEH MFC AT USA LHD 1.00 1.07 99211-G5000 201221', + ], + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00DEhe SCC FHCUP 1.00 1.00 99110-G5600 ', + ], + }, + CAR.KIA_SELTOS: { + (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x8799110Q5100\xf1\000SP2_ SCC FHCUP 1.01 1.05 99110-Q5100 ',], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x8758910-Q5450\xf1\000SP ESC \a 101\031\t\005 58910-Q5450', + b'\xf1\x8758910-Q5450\xf1\000SP ESC \t 101\031\t\005 58910-Q5450', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x81616D2051\000\000\000\000\000\000\000\000', + b'\xf1\x81616D5051\000\000\000\000\000\000\000\000', + b'\001TSP2KNL06F100J0K', + b'\001TSP2KNL06F200J0K', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\000SP2 MDPS C 1.00 1.04 56300Q5200 ', + b'\xf1\000SP2 MDPS C 1.01 1.05 56300Q5200 ', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\000SP2 MFC AT USA LHD 1.00 1.04 99210-Q5000 191114', + b'\xf1\000SP2 MFC AT USA LHD 1.00 1.05 99210-Q5000 201012', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x87CZLUB49370612JF7h\xa8y\x87\x99\xa7hv\x99\x97fv\x88\x87x\x89x\x96O\xff\x88\xff\xff\xff.@\xf1\x816V2C2051\000\000\xf1\0006V2B0_C2\000\0006V2C2051\000\000CSP4N20NS3\000\000\000\000', + b'\xf1\x87954A22D200\xf1\x81T01950A1 \xf1\000T0190XBL T01950A1 DSP2T16X4X950NS6\xd30\xa5\xb9', + b'\xf1\x87954A22D200\xf1\x81T01950A1 \xf1\000T0190XBL T01950A1 DSP2T16X4X950NS8\r\xfe\x9c\x8b', + ], + }, + 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', + b'\xf1\x89F1JF600AISEIU702\xf1\x82F1JF600AISEIU702', + ], + (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.00 95895-D5001 h32', + 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'], + }, + CAR.ELANTRA_2021: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00CN7_ SCC F-CUP 1.00 1.01 99110-AA000 ', + b'\xf1\x00CN7_ SCC FHCUP 1.00 1.01 99110-AA000 ', + b'\xf1\x8799110AA000\xf1\x00CN7_ SCC FHCUP 1.00 1.01 99110-AA000 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\x00CN7 MDPS C 1.00 1.06 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 4CNDC106', + b'\xf1\x8756310/AA070\xf1\x00CN7 MDPS C 1.00 1.06 56310/AA070 4CNDC106', + b'\xf1\x8756310AA050\x00\xf1\x00CN7 MDPS C 1.00 1.06 56310AA050\x00 4CNDC106', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00CN7 MFC AT USA LHD 1.00 1.00 99210-AB000 200819', + b'\xf1\x00CN7 MFC AT USA LHD 1.00 1.03 99210-AA000 200819', + ], + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00CN ESC \t 101 \x10\x03 58910-AB800', + b'\xf1\x8758910-AA800\xf1\x00CN ESC \t 104 \x08\x03 58910-AA800', + b'\xf1\x8758910-AB800\xf1\x00CN ESC \t 101 \x10\x03 58910-AB800', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x00HT6WA280BLHT6VA640A1CCN0N20NS5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x00HT6WA280BLHT6VA640A1CCN0N20NS5\x00\x00\x00\x00\x00\x00\xe8\xba\xce\xfa', + b'\xf1\x87CXMQFM2135005JB2E\xb9\x89\x98W\xa9y\x97h\xa9\x98\x99wxvwh\x87\177\xffx\xff\xff\xff,,\xf1\x89HT6VA640A1\xf1\x82CCN0N20NS5\x00\x00\x00\x00\x00\x00', + b'\xf1\x87CXMQFM1916035JB2\x88vvgg\x87Wuwgev\xa9\x98\x88\x98h\x99\x9f\xffh\xff\xff\xff\xa5\xee\xf1\x89HT6VA640A1\xf1\x82CCN0N20NS5\x00\x00\x00\x00\x00\x00', + b'\xf1\x87CXLQF40189012JL2f\x88\x86\x88\x88vUex\xb8\x88\x88\x88\x87\x88\x89fh?\xffz\xff\xff\xff\x08z\xf1\x89HT6VA640A1\xf1\x82CCN0N20NS5\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x82CNCWD0AMFCXCSFFA', + b'\xf1\x82CNCWD0AMFCXCSFFB', + b'\xf1\x82CNCVD0AMFCXCSFFB', + ], + }, + CAR.ELANTRA_HEV_2021: { + (Ecu.fwdCamera, 0x7c4, None) : [ + b'\xf1\000CN7HMFC AT USA LHD 1.00 1.03 99210-AA000 200819', + ], + (Ecu.fwdRadar, 0x7d0, None) : [ + b'\xf1\000CNhe SCC FHCUP 1.00 1.01 99110-BY000 ', + b'\xf1\x8799110BY000\xf1\x00CNhe SCC FHCUP 1.00 1.01 99110-BY000 ', + ], + (Ecu.eps, 0x7d4, None) :[ + b'\xf1\x8756310/BY050\xf1\000CN7 MDPS C 1.00 1.02 56310/BY050 4CNHC102', + ], + (Ecu.transmission, 0x7e1, None) :[ + b'\xf1\0006U3L0_C2\000\0006U3K3051\000\000HCN0G16NS0\xb9?A\xaa', + b'\xf1\0006U3L0_C2\000\0006U3K3051\000\000HCN0G16NS0\000\000\000\000', + b'\xf1\x816U3K3051\000\000\xf1\0006U3L0_C2\000\0006U3K3051\000\000HCN0G16NS0\xb9?A\xaa', + b'\xf1\x816U3K3051\x00\x00\xf1\x006U3L0_C2\x00\x006U3K3051\x00\x00HCN0G16NS0\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None) : [ + b'\xf1\x816H6G5051\x00\x00\x00\x00\x00\x00\x00\x00', + ] + }, + CAR.KONA_HEV: { + (Ecu.esp, 0x7d1, None): [ + b'\xf1\x00OS IEB \x01 104 \x11 58520-CM000', + ], + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00OShe SCC FNCUP 1.00 1.01 99110-CM000 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x00OS MDPS C 1.00 1.00 56310CM030\x00 4OHDC100', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00OSH LKAS AT KOR LHD 1.00 1.01 95740-CM000 l31', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x816U3J9051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J9051\x00\x00HOS0G16DS1\x16\xc7\xb0\xd9', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x816H6F6051\x00\x00\x00\x00\x00\x00\x00\x00', + ] + }, + CAR.SONATA_HYBRID: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\000DNhe SCC FHCUP 1.00 1.02 99110-L5000 ', + b'\xf1\x8799110L5000\xf1\000DNhe SCC FHCUP 1.00 1.02 99110-L5000 ', + b'\xf1\000DNhe SCC F-CUP 1.00 1.02 99110-L5000 ', + b'\xf1\x8799110L5000\xf1\000DNhe SCC F-CUP 1.00 1.02 99110-L5000 ', + ], + (Ecu.eps, 0x7d4, None): [ + b'\xf1\x8756310-L5500\xf1\x00DN8 MDPS C 1.00 1.02 56310-L5500 4DNHC102', + b'\xf1\x8756310-L5450\xf1\x00DN8 MDPS C 1.00 1.02 56310-L5450 4DNHC102', + b'\xf1\x8756310-L5450\xf1\000DN8 MDPS C 1.00 1.03 56310-L5450 4DNHC103', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00DN8HMFC AT USA LHD 1.00 1.04 99211-L1000 191016', + b'\xf1\x00DN8HMFC AT USA LHD 1.00 1.05 99211-L1000 201109', + b'\xf1\000DN8HMFC AT USA LHD 1.00 1.06 99211-L1000 210325', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\000PSBG2333 E14\x00\x00\x00\x00\x00\x00\x00TDN2H20SA6N\xc2\xeeW', + b'\xf1\x87959102T250\000\000\000\000\000\xf1\x81E09\000\000\000\000\000\000\000\xf1\000PSBG2323 E09\000\000\000\000\000\000\000TDN2H20SA5\x97R\x88\x9e', + b'\xf1\000PSBG2323 E09\000\000\000\000\000\000\000TDN2H20SA5\x97R\x88\x9e', + b'\xf1\000PSBG2333 E16\000\000\000\000\000\000\000TDN2H20SA7\0323\xf9\xab', + b'\xf1\x87PCU\000\000\000\000\000\000\000\000\000\xf1\x81E16\000\000\000\000\000\000\000\xf1\000PSBG2333 E16\000\000\000\000\000\000\000TDN2H20SA7\0323\xf9\xab', + b'\xf1\x87959102T250\x00\x00\x00\x00\x00\xf1\x81E14\x00\x00\x00\x00\x00\x00\x00\xf1\x00PSBG2333 E14\x00\x00\x00\x00\x00\x00\x00TDN2H20SA6N\xc2\xeeW', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x87391162J012', + b'\xf1\x87391162J013', + ], + }, +} 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, CAR.KIA_SELTOS, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID, CAR.SANTA_FE_2022, CAR.KIA_K5_2021, CAR.SANTA_FE_HEV_2022], + "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_LF, CAR.VELOSTER]), + "use_elect_gears": set([CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_HEV_2021, CAR.KIA_OPTIMA_H, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.IONIQ, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021,CAR.SONATA_HYBRID, CAR.KONA_HEV, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022]), + + # these cars use the FCA11 message for the AEB and FCW signals, all others use SCC12 + "use_fca": set([CAR.SONATA, CAR.SONATA_HYBRID, CAR.ELANTRA, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.ELANTRA_GT_I30, CAR.KIA_STINGER, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KONA_EV, CAR.KIA_FORTE, CAR.KIA_NIRO_EV, CAR.PALISADE, CAR.GENESIS_G70, CAR.GENESIS_G70_2020, CAR.KONA, CAR.SANTA_FE, CAR.KIA_SELTOS, CAR.KONA_HEV, CAR.SANTA_FE_2022, CAR.KIA_K5_2021, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022]), } +HYBRID_CAR = set([CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021, CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_HEV, CAR.IONIQ, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022]) # these cars use a different gas signal +EV_CAR = set([CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV]) + +# these cars require a special panda safety mode due to missing counters and checksums in the messages +LEGACY_SAFETY_MODE_CAR = set([CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_NIRO_EV, CAR.KIA_OPTIMA, CAR.VELOSTER, CAR.KIA_STINGER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022]) + +# If 0x500 is present on bus 1 it probably has a Mando radar outputting radar points. +# If no points are outputted by default it might be possible to turn it on using selfdrive/debug/hyundai_enable_radar_points.py DBC = { CAR.ELANTRA: dbc_dict('hyundai_kia_generic', None), - CAR.GENESIS: dbc_dict('hyundai_kia_generic', None), + CAR.ELANTRA_2021: dbc_dict('hyundai_kia_generic', None), + CAR.ELANTRA_HEV_2021: 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_G70_2020: dbc_dict('hyundai_kia_generic', 'hyundai_kia_mando_front_radar'), + 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_PHEV: 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', 'hyundai_kia_mando_front_radar'), + CAR.IONIQ: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ_HEV_2022: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_FORTE: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_K5_2021: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_NIRO_EV: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_NIRO_HEV: dbc_dict('hyundai_kia_generic', 'hyundai_kia_mando_front_radar'), + CAR.KIA_NIRO_HEV_2021: dbc_dict('hyundai_kia_generic', None), CAR.KIA_OPTIMA: dbc_dict('hyundai_kia_generic', None), - CAR.KIA_SORENTO: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_OPTIMA_H: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_SELTOS: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_SORENTO: dbc_dict('hyundai_kia_generic', None), # Has 0x5XX messages, but different format CAR.KIA_STINGER: dbc_dict('hyundai_kia_generic', None), - CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None), + CAR.KONA: dbc_dict('hyundai_kia_generic', None), + CAR.KONA_EV: dbc_dict('hyundai_kia_generic', None), + CAR.KONA_HEV: dbc_dict('hyundai_kia_generic', None), + CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', 'hyundai_kia_mando_front_radar'), + CAR.SANTA_FE_2022: dbc_dict('hyundai_kia_generic', None), + CAR.SANTA_FE_HEV_2022: dbc_dict('hyundai_kia_generic', None), + CAR.SONATA: dbc_dict('hyundai_kia_generic', 'hyundai_kia_mando_front_radar'), + CAR.SONATA_LF: dbc_dict('hyundai_kia_generic', None), # Has 0x5XX messages, but different format + CAR.PALISADE: dbc_dict('hyundai_kia_generic', 'hyundai_kia_mando_front_radar'), + CAR.VELOSTER: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_CEED: dbc_dict('hyundai_kia_generic', None), + CAR.SONATA_HYBRID: dbc_dict('hyundai_kia_generic', 'hyundai_kia_mando_front_radar'), } -STEER_THRESHOLD = 100 +STEER_THRESHOLD = 150 diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py new file mode 100644 index 00000000000000..bef3456a76395d --- /dev/null +++ b/selfdrive/car/interfaces.py @@ -0,0 +1,272 @@ +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 +ACCEL_MAX = 2.0 +ACCEL_MIN = -3.5 + + +# generic car and radar interfaces + + +class CarInterfaceBase(): + def __init__(self, CP, CarController, CarState): + self.CP = CP + self.VM = VehicleModel(CP) + + self.frame = 0 + self.steering_unpressed = 0 + self.low_speed_alert = False + self.silent_steer_warning = True + + 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.cp_loopback = self.CS.get_loopback_can_parser(CP) + + self.CC = None + if CarController is not None: + self.CC = CarController(self.cp.dbc_name, CP, self.VM) + + @staticmethod + def get_pid_accel_limits(CP, current_speed, cruise_speed): + return ACCEL_MIN, ACCEL_MAX + + @staticmethod + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + raise NotImplementedError + + @staticmethod + def init(CP, logcan, sendcan): + pass + + @staticmethod + def get_steer_feedforward_default(desired_angle, v_ego): + # Proportional to realigning tire momentum: lateral acceleration. + # TODO: something with lateralPlan.curvatureRates + return desired_angle * (v_ego**2) + + @classmethod + def get_steer_feedforward_function(cls): + return cls.get_steer_feedforward_default + + # 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 + + # standard ALC params + ret.steerControlType = car.CarParams.SteerControlType.torque + ret.steerMaxBP = [0.] + ret.steerMaxV = [1.] + ret.minSteerSpeed = 0. + ret.wheelSpeedFactor = 1.0 + + ret.pcmCruise = True # openpilot's state is tied to the PCM's cruise state on most cars + 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.openpilotLongitudinalControl = False + ret.minSpeedCan = 0.3 + ret.startAccel = -0.8 + ret.stopAccel = -2.0 + ret.startingAccelRate = 3.2 # brake_travel/s while releasing on restart + ret.stoppingDecelRate = 0.8 # brake_travel/s while trying to stop + ret.vEgoStopping = 0.5 + ret.vEgoStarting = 0.5 + ret.stoppingControl = True + ret.longitudinalTuning.deadzoneBP = [0.] + ret.longitudinalTuning.deadzoneV = [0.] + ret.longitudinalTuning.kpBP = [0.] + ret.longitudinalTuning.kpV = [1.] + ret.longitudinalTuning.kiBP = [0.] + ret.longitudinalTuning.kiV = [1.] + ret.longitudinalActuatorDelayLowerBound = 0.15 + ret.longitudinalActuatorDelayUpperBound = 0.15 + 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=None, gas_resume_speed=-1, pcm_enable=True): + 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 (extra_gears is None or + 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.brakeHoldActive and self.CP.openpilotLongitudinalControl: + events.add(EventName.brakeHold) + + + # Handle permanent and temporary steering faults + self.steering_unpressed = 0 if cs_out.steeringPressed else self.steering_unpressed + 1 + if cs_out.steerWarning: + # if the user overrode recently, show a less harsh alert + if self.silent_steer_warning or cs_out.standstill or self.steering_unpressed < int(1.5 / DT_CTRL): + self.silent_steer_warning = True + events.add(EventName.steerTempUnavailableSilent) + else: + events.add(EventName.steerTempUnavailable) + else: + self.silent_steer_warning = False + if cs_out.steerError: + events.add(EventName.steerUnavailable) + + # 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 + self.left_blinker_prev = False + self.right_blinker_prev = False + + # 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 get_wheel_speeds(self, fl, fr, rl, rr, unit=CV.KPH_TO_MS): + factor = unit * self.CP.wheelSpeedFactor + + wheelSpeeds = car.CarState.WheelSpeeds.new_message() + wheelSpeeds.fl = fl * factor + wheelSpeeds.fr = fr * factor + wheelSpeeds.rl = rl * factor + wheelSpeeds.rr = rr * factor + return wheelSpeeds + + def update_blinker_from_lamp(self, blinker_time: int, left_blinker_lamp: bool, right_blinker_lamp: bool): + """Update blinkers from lights. Enable output when light was seen within the last `blinker_time` + iterations""" + # TODO: Handle case when switching direction. Now both blinkers can be on at the same time + 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 + + def update_blinker_from_stalk(self, blinker_time: int, left_blinker_stalk: bool, right_blinker_stalk: bool): + """Update blinkers from stalk position. When stalk is seen the blinker will be on for at least blinker_time, + or until the stalk is turned off, whichever is longer. If the opposite stalk direction is seen the blinker + is forced to the other side. On a rising edge of the stalk the timeout is reset.""" + + if left_blinker_stalk: + self.right_blinker_cnt = 0 + if not self.left_blinker_prev: + self.left_blinker_cnt = blinker_time + + if right_blinker_stalk: + self.left_blinker_cnt = 0 + if not self.right_blinker_prev: + self.right_blinker_cnt = blinker_time + + self.left_blinker_cnt = max(self.left_blinker_cnt - 1, 0) + self.right_blinker_cnt = max(self.right_blinker_cnt - 1, 0) + + self.left_blinker_prev = left_blinker_stalk + self.right_blinker_prev = right_blinker_stalk + + return bool(left_blinker_stalk or self.left_blinker_cnt > 0), bool(right_blinker_stalk or 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 + + @staticmethod + def get_loopback_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..1209a8f1a1dc62 --- /dev/null +++ b/selfdrive/car/isotp_parallel_query.py @@ -0,0 +1,148 @@ +import time +from collections import defaultdict +from functools import partial +from typing import Optional + +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, response_offset=0x8, 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], rx_offset=response_offset) 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, total_timeout=None): + if total_timeout is None: + total_timeout = 10 * 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.monotonic() + last_response_time = start_time + while True: + self.rx() + + if all(request_done.values()): + break + + for tx_addr, msg in msgs.items(): + try: + dat: Optional[bytes] = msg.recv() + except Exception: + cloudlog.exception("Error processing UDS response") + request_done[tx_addr] = True + continue + + 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: + last_response_time = time.monotonic() + 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{dat.hex()}") + + cur_time = time.monotonic() + if cur_time - last_response_time > timeout: + for tx_addr in msgs: + if (request_counter[tx_addr] > 0) and (not request_done[tx_addr]): + cloudlog.warning(f"iso-tp query timeout after receiving response: {tx_addr}") + break + + if cur_time - start_time > total_timeout: + cloudlog.warning("iso-tp query timeout while receiving data") + break + + return results diff --git a/panda/tests/safety/__init__.py b/selfdrive/car/mazda/__init__.py similarity index 100% rename from panda/tests/safety/__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..06c5eb0948ae9a --- /dev/null +++ b/selfdrive/car/mazda/carcontroller.py @@ -0,0 +1,61 @@ +from cereal import car +from opendbc.can.packer import CANPacker +from selfdrive.car.mazda import mazdacan +from selfdrive.car.mazda.values import CarControllerParams, Buttons +from selfdrive.car import apply_std_steer_torque_limits + +VisualAlert = car.CarControl.HUDControl.VisualAlert + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.apply_steer_last = 0 + self.packer = CANPacker(dbc_name) + self.steer_rate_limited = False + self.brake_counter = 0 + + def update(self, c, CS, frame): + can_sends = [] + + apply_steer = 0 + self.steer_rate_limited = False + + if c.enabled: + # calculate steer and also set limits due to driver torque + new_steer = int(round(c.actuators.steer * CarControllerParams.STEER_MAX)) + apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, + CS.out.steeringTorque, CarControllerParams) + self.steer_rate_limited = new_steer != apply_steer + + if CS.out.standstill and frame % 5 == 0: + # Mazda Stop and Go requires a RES button (or gas) press if the car stops more than 3 seconds + # Send Resume button at 20hz 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, CS.crz_btns_counter, Buttons.RESUME)) + + if c.cruiseControl.cancel or (CS.out.cruiseState.enabled and not c.enabled): + # If brake is pressed, let us wait >70ms before trying to disable crz to avoid + # a race condition with the stock system, where the second cancel from openpilot + # will disable the crz 'main on'. crz ctrl msg runs at 50hz. 70ms allows us to + # read 3 messages and most likely sync state before we attempt cancel. + self.brake_counter = self.brake_counter + 1 + if frame % 10 == 0 and not (CS.out.brakePressed and self.brake_counter < 7): + # Cancel Stock ACC if it's enabled while OP is disengaged + # Send at a rate of 10hz until we sync with stock ACC state + can_sends.append(mazdacan.create_button_cmd(self.packer, CS.CP.carFingerprint, CS.crz_btns_counter, Buttons.CANCEL)) + else: + self.brake_counter = 0 + + self.apply_steer_last = apply_steer + + # send HUD alerts + if frame % 50 == 0: + ldw = c.hudControl.visualAlert == VisualAlert.ldw + steer_required = c.hudControl.visualAlert == VisualAlert.steerRequired + # TODO: find a way to silence audible warnings so we can add more hud alerts + steer_required = steer_required and CS.lkas_allowed_speed + can_sends.append(mazdacan.create_alert_command(self.packer, CS.cam_laneinfo, ldw, steer_required)) + + # send steering command + 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..7ebf60c96bd6ea --- /dev/null +++ b/selfdrive/car/mazda/carstate.py @@ -0,0 +1,202 @@ +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.crz_btns_counter = 0 + self.acc_active_last = False + self.low_speed_alert = False + self.lkas_allowed_speed = False + + def update(self, cp, cp_cam): + + ret = car.CarState.new_message() + ret.wheelSpeeds = self.get_wheel_speeds( + cp.vl["WHEEL_SPEEDS"]["FL"], + cp.vl["WHEEL_SPEEDS"]["FR"], + cp.vl["WHEEL_SPEEDS"]["RL"], + cp.vl["WHEEL_SPEEDS"]["RR"], + ) + 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.genericToggle = bool(cp.vl["BLINK_INFO"]["HIGH_BEAMS"]) + ret.leftBlindspot = cp.vl["BSM"]["LEFT_BS1"] == 1 + ret.rightBlindspot = cp.vl["BSM"]["RIGHT_BS1"] == 1 + ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp(40, cp.vl["BLINK_INFO"]["LEFT_BLINK"] == 1, + cp.vl["BLINK_INFO"]["RIGHT_BLINK"] == 1) + + ret.steeringAngleDeg = 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.steeringRateDeg = cp.vl["STEER_RATE"]["STEER_ANGLE_RATE"] + + # TODO: this should be from 0 - 1. + ret.brakePressed = cp.vl["PEDALS"]["BRAKE_ON"] == 1 + ret.brake = cp.vl["BRAKE"]["BRAKE_PRESSURE"] + + 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"]]) + + # TODO: this should be from 0 - 1. + ret.gas = cp.vl["ENGINE_DATA"]["PEDAL_GAS"] + ret.gasPressed = ret.gas > 0 + + # Either due to low speed or hands off + lkas_blocked = cp.vl["STEER_RATE"]["LKAS_BLOCK"] == 1 + + # LKAS is enabled at 52kph going up and disabled at 45kph going down + # wait for LKAS_BLOCK signal to clear when going up since it lags behind the speed sometimes + if speed_kph > LKAS_LIMITS.ENABLE_SPEED and not lkas_blocked: + self.lkas_allowed_speed = True + elif speed_kph < LKAS_LIMITS.DISABLE_SPEED: + self.lkas_allowed_speed = False + + # TODO: the signal used for available seems to be the adaptive cruise signal, instead of the main on + # it should be used for carState.cruiseState.nonAdaptive instead + ret.cruiseState.available = cp.vl["CRZ_CTRL"]["CRZ_AVAILABLE"] == 1 + ret.cruiseState.enabled = cp.vl["CRZ_CTRL"]["CRZ_ACTIVE"] == 1 + ret.cruiseState.speed = cp.vl["CRZ_EVENTS"]["CRZ_SPEED"] * CV.KPH_TO_MS + + if ret.cruiseState.enabled: + if not self.lkas_allowed_speed and self.acc_active_last: + self.low_speed_alert = True + else: + self.low_speed_alert = False + + # Check if LKAS is disabled due to lack of driver torque when all other states indicate + # it should be enabled (steer lockout). Don't warn until we actually get lkas active + # and lose it again, i.e, after initial lkas activation + + ret.steerWarning = self.lkas_allowed_speed and lkas_blocked + + self.acc_active_last = ret.cruiseState.enabled + + self.cam_lkas = cp_cam.vl["CAM_LKAS"] + self.cam_laneinfo = cp_cam.vl["CAM_LANEINFO"] + self.crz_btns_counter = cp.vl["CRZ_BTNS"]["CTR"] + 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), + ("HIGH_BEAMS", "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), + ("CRZ_AVAILABLE", "CRZ_CTRL", 0), + ("CRZ_SPEED", "CRZ_EVENTS", 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), + ("CTR", "CRZ_BTNS", 0), + ("LEFT_BS1", "BSM", 0), + ("RIGHT_BS1", "BSM", 0), + ] + + checks += [ + ("ENGINE_DATA", 100), + ("CRZ_CTRL", 50), + ("CRZ_EVENTS", 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), + ("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), + + ("LINE_VISIBLE", "CAM_LANEINFO", 0), + ("LINE_NOT_VISIBLE", "CAM_LANEINFO", 1), + ("LANE_LINES", "CAM_LANEINFO", 0), + ("BIT1", "CAM_LANEINFO", 0), + ("BIT2", "CAM_LANEINFO", 0), + ("BIT3", "CAM_LANEINFO", 0), + ("NO_ERR_BIT", "CAM_LANEINFO", 1), + ("S1", "CAM_LANEINFO", 0), + ("S1_HBEAM", "CAM_LANEINFO", 0), + ] + + checks += [ + # sig_address, frequency + ("CAM_LANEINFO", 2), + ("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..8364bf000c942b --- /dev/null +++ b/selfdrive/car/mazda/interface.py @@ -0,0 +1,100 @@ +#!/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, get_safety_config +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.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.mazda)] + ret.radarOffCan = True + + ret.dashcamOnly = candidate not in [CAR.CX9_2021] + + 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 in [CAR.CX9, CAR.CX9_2021]: + 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 + elif candidate == CAR.MAZDA6: + ret.mass = 3443 * CV.LB_TO_KG + STD_CARGO_KG + ret.wheelbase = 2.83 + 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 + + # 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) + + 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_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, self.CS, self.frame) + 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..e2ee93e022de90 --- /dev/null +++ b/selfdrive/car/mazda/mazdacan.py @@ -0,0 +1,119 @@ +import copy + +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 + + # copy values from camera + b1 = int(lkas["BIT_1"]) + er1 = int(lkas["ERR_BIT_1"]) + lnv = 0 + ldw = 0 + er2 = int(lkas["ERR_BIT_2"]) + + # Some older models do have these, newer models don't. + # Either way, they all work just fine if set to zero. + steering_angle = 0 + b2 = 0 + + 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_alert_command(packer, cam_msg: dict, ldw: bool, steer_required: bool): + values = copy.copy(cam_msg) + values.update({ + # TODO: what's the difference between all these? do we need to send all? + "HANDS_WARN_3_BITS": 0b111 if steer_required else 0, + "HANDS_ON_STEER_WARN": steer_required, + "HANDS_ON_STEER_WARN_2": steer_required, + + # TODO: right lane works, left doesn't + # TODO: need to do something about L/R + "LDW_WARN_LL": 0, + "LDW_WARN_RL": 0, + }) + return packer.make_can_msg("CAM_LANEINFO", 0, values) + + +def create_button_cmd(packer, car_fingerprint, counter, button): + + can = int(button == Buttons.CANCEL) + res = int(button == Buttons.RESUME) + + 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": (counter + 1) % 16, + } + + 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..58e1dd7033a89c --- /dev/null +++ b/selfdrive/car/mazda/values.py @@ -0,0 +1,242 @@ +# flake8: noqa + +from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu + + +# Steer torque limits + +class CarControllerParams: + STEER_MAX = 800 # theoretical max_steer 2047 + STEER_DELTA_UP = 10 # torque increase per refresh + STEER_DELTA_DOWN = 25 # 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 + STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor + +class CAR: + CX5 = "MAZDA CX-5" + CX9 = "MAZDA CX-9" + MAZDA3 = "MAZDA 3" + MAZDA6 = "MAZDA 6" + CX9_2021 = "MAZDA CX-9 2021" # No Steer Lockout + +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 + + +FW_VERSIONS = { + CAR.CX5: { + (Ecu.eps, 0x730, None): [ + b'KJ01-3210X-G-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KJ01-3210X-J-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KJ01-3210X-M-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K319-3210X-A-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'PA53-188K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYFA-188K2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYFC-188K2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYFD-188K2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYNF-188K2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX2G-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX2H-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX2H-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX2K-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX38-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX42-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX68-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'SHKT-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x764, None): [ + b'K123-67XK2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x760, None): [ + b'K123-437K2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KBJ5-437K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KL2K-437K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KN0W-437K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x706, None): [ + b'B61L-67XK2-R\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'B61L-67XK2-S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'B61L-67XK2-T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'B61L-67XK2-V\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GSH7-67XK2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GSH7-67XK2-N\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'PA66-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX39-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX39-21PS1-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX68-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYB1-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYB1-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYB2-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYB2-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYB2-21PS1-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYB2-21PS1-G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYNC-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'SH9T-21PS1-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + }, + + CAR.CX9 : { + (Ecu.eps, 0x730, None): [ + b'K070-3210X-C-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KJ01-3210X-G-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KJ01-3210X-L-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'PX23-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PX24-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PXN8-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PXN8-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYD7-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYD8-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYFM-188K2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x764, None): [ + b'K123-67XK2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'TK80-67XK2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x760, None): [ + b'TA0B-437K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'TK79-437K2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'TM53-437K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'TN40-437K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x706, None): [ + b'B61L-67XK2-P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'B61L-67XK2-V\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GSH7-67XK2-K\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'TK80-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'PXM7-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PXM7-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYFM-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYD5-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYD5-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYD6-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYD6-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + }, + + CAR.MAZDA3: { + (Ecu.eps, 0x730, None): [ + b'BHN1-3210X-J-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K070-3210X-C-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'KR11-3210X-K-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'P5JD-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PY2P-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYKC-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYKE-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x764, None): [ + b'B63C-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GHP9-67Y10---41\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x760, None): [ + b'B45A-437AS-0-08\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x706, None): [ + b'B61L-67XK2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'B61L-67XK2-P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'B61L-67XK2-T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'PY2S-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'P52G-21PS1-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYKE-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PYKE-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + }, + + CAR.MAZDA6: { + (Ecu.eps, 0x730, None): [ + b'GBEF-3210X-B-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GFBC-3210X-A-00\000\000\000\000\000\000\000\000\000', + ], + (Ecu.engine, 0x7e0, None): [ + b'PX4F-188K2-D\000\000\000\000\000\000\000\000\000\000\000\000', + b'PYH7-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x764, None): [ + b'K131-67XK2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-E\000\000\000\000\000\000\000\000\000\000\000\000', + ], + (Ecu.esp, 0x760, None): [ + b'GBVH-437K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GDDM-437K2-A\000\000\000\000\000\000\000\000\000\000\000\000', + ], + (Ecu.fwdCamera, 0x706, None): [ + b'B61L-67XK2-S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GSH7-67XK2-P\000\000\000\000\000\000\000\000\000\000\000\000', + ], + (Ecu.transmission, 0x7e1, None): [ + b'PYH3-21PS1-D\000\000\000\000\000\000\000\000\000\000\000\000', + b'PYH7-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + }, + + CAR.CX9_2021 : { + (Ecu.eps, 0x730, None): [ + b'TC3M-3210X-A-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'PXM4-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'PXM4-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x764, None): [ + b'K131-67XK2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'K131-67XK2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x760, None): [ + b'TA0B-437K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x706, None): [ + b'GSH7-67XK2-M\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GSH7-67XK2-N\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'GSH7-67XK2-P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.transmission, 0x7e1, None): [ + b'PXM4-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + ], + } +} + + +DBC = { + CAR.CX5: dbc_dict('mazda_2017', None), + CAR.CX9: dbc_dict('mazda_2017', None), + CAR.MAZDA3: dbc_dict('mazda_2017', None), + CAR.MAZDA6: dbc_dict('mazda_2017', None), + CAR.CX9_2021: dbc_dict('mazda_2017', None), +} + +# Gen 1 hardware: same CAN messages and same camera +GEN1 = set([CAR.CX5, CAR.CX9, CAR.CX9_2021, CAR.MAZDA3, CAR.MAZDA6]) + +# Cars with a steering lockout +STEER_LOCKOUT_CAR = set([CAR.CX5, CAR.CX9, CAR.MAZDA3, CAR.MAZDA6]) diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index a18d2bf244bde0..999e735c73dec9 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -1,88 +1,55 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +import math 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 -from common.realtime import Ratekeeper +import cereal.messaging as messaging +from selfdrive.car import gen_empty_fingerprint, get_safety_config +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) +LPG = 2 * math.pi * YAW_FR * TS / (1 + 2 * math.pi * 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('gpsLocationExternal') self.speed = 0. self.prev_speed = 0. self.yaw_rate = 0. self.yaw_rate_meas = 0. - self.rk = Ratekeeper(100, print_delay_threshold=2. / 1000) - @staticmethod 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=""): - - 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.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput)] 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. return ret # returns a car.CarState - def update(self, c): - self.rk.keep_time() - + def update(self, c, can_strings): # get basic data from phone and gps since CAN isn't connected sensors = messaging.recv_sock(self.sensor) if sensors is not None: @@ -93,10 +60,11 @@ def update(self, c): gps = messaging.recv_sock(self.gps) if gps is not None: self.prev_speed = self.speed - self.speed = gps.gpsLocation.speed + self.speed = gps.gpsLocationExternal.speed # create message ret = car.CarState.new_message() + ret.canValid = True # speeds ret.vEgo = self.speed @@ -106,18 +74,15 @@ def update(self, c): 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 - 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 + self.yawRate = LPG * self.yaw_rate_meas + (1. - LPG) * self.yaw_rate + curvature = self.yaw_rate / max(self.speed, 1.) + ret.steeringAngleDeg = curvature * self.CP.steerRatio * self.CP.wheelbase * CV.RAD_TO_DEG return ret.as_reader() diff --git a/selfdrive/car/mock/radar_interface.py b/selfdrive/car/mock/radar_interface.py index 437bb0538a8dd4..b2f76511360320 100755 --- a/selfdrive/car/mock/radar_interface.py +++ b/selfdrive/car/mock/radar_interface.py @@ -1,23 +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): - - ret = car.RadarData.new_message() - time.sleep(0.05) # radard runs on RI updates - return ret - -if __name__ == "__main__": - RI = RadarInterface(None) - while 1: - ret = RI.update() - print(chr(27) + "[2J") - print(ret) +class RadarInterface(RadarInterfaceBase): + pass diff --git a/panda/tests/safety_replay/__init__.py b/selfdrive/car/nissan/__init__.py similarity index 100% rename from panda/tests/safety_replay/__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..41ba9f6599cbdf --- /dev/null +++ b/selfdrive/car/nissan/carcontroller.py @@ -0,0 +1,90 @@ +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, CarControllerParams + + +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.steeringAngleDeg + + steer_hud_alert = 1 if hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw] 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, CarControllerParams.ANGLE_DELTA_BP, CarControllerParams.ANGLE_DELTA_V) + else: + angle_rate_lim = interp(CS.out.vEgo, CarControllerParams.ANGLE_DELTA_BP, CarControllerParams.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 = CarControllerParams.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 + CarControllerParams.LKAS_MAX_TORQUE * 0.5, + # Start scaling torque at STEER_THRESHOLD + CarControllerParams.LKAS_MAX_TORQUE - 0.6 * max(0, abs(CS.out.steeringTorque) - CarControllerParams.STEER_THRESHOLD) + ) + + else: + apply_angle = CS.out.steeringAngleDeg + 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, CAR.ALTIMA] and cruise_cancel: + can_sends.append(nissancan.create_acc_cancel_cmd(self.packer, self.car_fingerprint, 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 in [CAR.LEAF, CAR.LEAF_IC] 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, apply_angle, frame, enabled, self.lkas_max_torque)) + + if lkas_hud_msg and lkas_hud_info_msg: + 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..05191feedf9b99 --- /dev/null +++ b/selfdrive/car/nissan/carstate.py @@ -0,0 +1,364 @@ +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, CarControllerParams + +TORQUE_SAMPLES = 12 + +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) + + self.lkas_hud_msg = None + self.lkas_hud_info_msg = None + + 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, CAR.ALTIMA]: + ret.gas = cp.vl["GAS_PEDAL"]["GAS_PEDAL"] + elif self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: + ret.gas = cp.vl["CRUISE_THROTTLE"]["GAS_PEDAL"] + + ret.gasPressed = bool(ret.gas > 3) + + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA]: + ret.brakePressed = bool(cp.vl["DOORS_LIGHTS"]["USER_BRAKE_PRESSED"]) + elif self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: + ret.brakePressed = bool(cp.vl["CRUISE_THROTTLE"]["USER_BRAKE_PRESSED"]) + + ret.wheelSpeeds = self.get_wheel_speeds( + cp.vl["WHEEL_SPEEDS_FRONT"]["WHEEL_SPEED_FL"], + cp.vl["WHEEL_SPEEDS_FRONT"]["WHEEL_SPEED_FR"], + cp.vl["WHEEL_SPEEDS_REAR"]["WHEEL_SPEED_RL"], + cp.vl["WHEEL_SPEEDS_REAR"]["WHEEL_SPEED_RR"], + ) + 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 + + if self.CP.carFingerprint == CAR.ALTIMA: + ret.cruiseState.enabled = bool(cp.vl["CRUISE_STATE"]["CRUISE_ENABLED"]) + else: + 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 in [CAR.LEAF, CAR.LEAF_IC]: + if self.CP.carFingerprint == CAR.LEAF: + ret.seatbeltUnlatched = cp.vl["SEATBELT"]["SEATBELT_DRIVER_LATCHED"] == 0 + elif self.CP.carFingerprint == CAR.LEAF_IC: + ret.seatbeltUnlatched = cp.vl["CANCEL_MSG"]["CANCEL_SEATBELT"] == 1 + ret.cruiseState.available = bool(cp.vl["CRUISE_THROTTLE"]["CRUISE_AVAILABLE"]) + elif self.CP.carFingerprint == CAR.ALTIMA: + ret.seatbeltUnlatched = cp.vl["HUD"]["SEATBELT_DRIVER_LATCHED"] == 0 + ret.cruiseState.available = bool(cp_adas.vl["PRO_PILOT"]["CRUISE_ON"]) + + if self.CP.carFingerprint == CAR.ALTIMA: + speed = cp.vl["PROPILOT_HUD"]["SET_SPEED"] + else: + speed = cp_adas.vl["PROPILOT_HUD"]["SET_SPEED"] + + if speed != 255: + if self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: + 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 + + if self.CP.carFingerprint == CAR.ALTIMA: + ret.steeringTorque = cp_cam.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_DRIVER"] + else: + 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) > CarControllerParams.STEER_THRESHOLD) + + ret.steeringAngleDeg = 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)) + + if self.CP.carFingerprint == CAR.ALTIMA: + self.lkas_enabled = bool(cp.vl["LKAS_SETTINGS"]["LKAS_ENABLED"]) + else: + 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 in [CAR.LEAF, CAR.LEAF_IC]: + self.cancel_msg = copy.copy(cp.vl["CANCEL_MSG"]) + + if self.CP.carFingerprint != CAR.ALTIMA: + 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_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 + ("STEER_ANGLE_SENSOR", 100), + ("WHEEL_SPEEDS_REAR", 50), + ("WHEEL_SPEEDS_FRONT", 50), + ("ESP", 25), + ("GEARBOX", 25), + ("DOORS_LIGHTS", 10), + ("LIGHTS", 10), + ] + + if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA]: + signals += [ + ("USER_BRAKE_PRESSED", "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", 100), + ("CRUISE_THROTTLE", 50), + ("HUD", 25), + ] + + elif CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: + signals += [ + ("USER_BRAKE_PRESSED", "CRUISE_THROTTLE", 1), + ("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), + ("CANCEL_MSG", 50), + ("HUD_SETTINGS", 25), + ("SEATBELT", 10), + ] + + if CP.carFingerprint == CAR.ALTIMA: + signals += [ + ("LKAS_ENABLED", "LKAS_SETTINGS", 0), + ("CRUISE_ENABLED", "CRUISE_STATE", 0), + ("SET_SPEED", "PROPILOT_HUD", 0), + ] + checks += [ + ("CRUISE_STATE", 10), + ("LKAS_SETTINGS", 10), + ("PROPILOT_HUD", 50), + ] + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 1) + + signals += [ + ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), + ] + checks += [ + ("STEER_TORQUE_SENSOR", 100), + ] + + 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 + + if CP.carFingerprint == CAR.ALTIMA: + signals = [ + ("DESIRED_ANGLE", "LKAS", 0), + ("SET_0x80_2", "LKAS", 0), + ("MAX_TORQUE", "LKAS", 0), + ("SET_0x80", "LKAS", 0), + ("COUNTER", "LKAS", 0), + ("LKA_ACTIVE", "LKAS", 0), + + ("CRUISE_ON", "PRO_PILOT", 0), + ] + checks = [ + ("LKAS", 100), + ("PRO_PILOT", 100), + ] + else: + 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 = [ + ("PROPILOT_HUD_INFO_MSG", 2), + ("LKAS_SETTINGS", 10), + ("CRUISE_STATE", 50), + ("PROPILOT_HUD", 50), + ("LKAS", 100), + ] + + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) + + @staticmethod + def get_cam_can_parser(CP): + signals = [] + checks = [] + + if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: + signals += [ + ("CRUISE_ON", "PRO_PILOT", 0), + ] + checks += [ + ("PRO_PILOT", 100), + ] + elif CP.carFingerprint == CAR.ALTIMA: + signals += [ + ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), + ] + checks += [ + ("STEER_TORQUE_SENSOR", 100), + ] + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) + + + 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..18ae885f8379b0 --- /dev/null +++ b/selfdrive/car/nissan/interface.py @@ -0,0 +1,86 @@ +#!/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, get_safety_config +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 get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) + ret.carName = "nissan" + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.nissan)] + + ret.steerLimitAlert = False + ret.steerRateCost = 0.5 + + ret.steerActuatorDelay = 0.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 in [CAR.LEAF, CAR.LEAF_IC]: + ret.mass = 1610 + STD_CARGO_KG + ret.wheelbase = 2.705 + ret.centerToFront = ret.wheelbase * 0.44 + ret.steerRatio = 17 + elif candidate == CAR.ALTIMA: + # Altima has EPS on C-CAN unlike the others that have it on V-CAN + ret.safetyConfigs[0].safetyParam = 1 # EPS is on alternate bus + ret.mass = 1492 + STD_CARGO_KG + ret.wheelbase = 2.824 + 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..ceace5088ad8c8 --- /dev/null +++ b/selfdrive/car/nissan/nissancan.py @@ -0,0 +1,71 @@ +import copy +import crcmod +from selfdrive.car.nissan.values import CAR + +nissan_checksum = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff) + + +def create_steering_control(packer, 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, car_fingerprint, cruise_throttle_msg, frame): + values = copy.copy(cruise_throttle_msg) + can_bus = 2 + + if car_fingerprint == CAR.ALTIMA: + can_bus = 1 + + 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", can_bus, 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..22bd4a1295f094 --- /dev/null +++ b/selfdrive/car/nissan/values.py @@ -0,0 +1,123 @@ +# flake8: noqa + +from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu + + +class CarControllerParams: + 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 + STEER_THRESHOLD = 1.0 + +class CAR: + XTRAIL = "NISSAN X-TRAIL 2017" + LEAF = "NISSAN LEAF 2018" + # Leaf with ADAS ECU found behind instrument cluster instead of glovebox + # Currently the only known difference between them is the inverted seatbelt signal. + LEAF_IC = "NISSAN LEAF 2018 Instrument Cluster" + ROGUE = "NISSAN ROGUE 2019" + ALTIMA = "NISSAN ALTIMA 2020" + + +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.LEAF_IC: [ + { + 2: 5, 42: 6, 264: 3, 282: 8, 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, 756: 5, 758: 3, 761: 2, 783: 3, 830: 2, 852: 8, 853: 8, 856: 8, 861: 8, 943: 8, 944: 1, 1001: 6, 1057: 3, 1227: 8, 1228: 8, 1229: 8, 1342: 1, 1354: 8, 1361: 8, 1459: 8, 1477: 8, 1497: 3, 1514: 6, 1549: 8, 1573: 6, 1792: 8, 1821: 8, 1822: 8, 1837: 8, 1838: 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 + }, + ], + 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 + }, + ], + CAR.ALTIMA: [ + { + 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 438: 8, 451: 8, 517: 8, 520: 2, 522: 8, 523: 6, 539: 8, 541: 7, 542: 8, 543: 8, 544: 8, 545: 8, 546: 8, 547: 8, 548: 8, 570: 8, 576: 8, 577: 8, 582: 8, 583: 8, 584: 8, 586: 8, 587: 8, 588: 8, 589: 8, 590: 8, 591: 8, 592: 8, 600: 8, 601: 8, 610: 8, 611: 8, 612: 8, 614: 8, 615: 8, 616: 8, 617: 8, 622: 8, 623: 8, 634: 7, 638: 8, 645: 8, 648: 5, 654: 6, 658: 8, 659: 8, 660: 8, 661: 8, 665: 8, 666: 8, 674: 2, 675: 8, 676: 8, 682: 8, 683: 8, 684: 8, 685: 8, 686: 8, 687: 8, 689: 8, 690: 8, 703: 8, 708: 7, 709: 7, 711: 7, 712: 7, 713: 7, 714: 8, 715: 8, 716: 8, 717: 7, 718: 7, 719: 7, 720: 7, 723: 8, 726: 7, 727: 7, 728: 7, 735: 8, 746: 8, 748: 6, 749: 6, 750: 8, 758: 3, 772: 8, 773: 6, 774: 7, 775: 8, 776: 6, 777: 7, 778: 6, 779: 7, 781: 7, 782: 7, 783: 3, 851: 8, 855: 5, 1001: 6, 1041: 8, 1042: 8, 1055: 3, 1100: 7, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1110: 7, 1111: 7, 1144: 7, 1145: 7, 1227: 8, 1228: 8, 1229: 8, 1232: 8, 1247: 4, 1258: 8, 1259: 8, 1266: 8, 1273: 7, 1306: 1, 1314: 8, 1323: 8, 1324: 8, 1342: 1, 1376: 8, 1401: 8, 1454: 8, 1497: 3, 1514: 6, 1526: 8, 1527: 5, 1792: 8, 1821: 8, 1823: 8, 1837: 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 + }, + ] +} + +FW_VERSIONS = { + CAR.ALTIMA: { + (Ecu.fwdCamera, 0x707, None): [ + b'284N86CA1D', + ], + (Ecu.eps, 0x742, None): [ + b'6CA2B\xa9A\x02\x02G8A89P90D6A\x00\x00\x01\x80', + ], + (Ecu.engine, 0x7e0, None): [ + b'237109HE2B', + ], + (Ecu.gateway, 0x18dad0f1, None): [ + b'284U29HE0A', + ], + }, + CAR.LEAF_IC: { + (Ecu.fwdCamera, 0x707, None): [ + b'5SH1BDB\x04\x18\x00\x00\x00\x00\x00_-?\x04\x91\xf2\x00\x00\x00\x80', + b'5SK0ADB\x04\x18\x00\x00\x00\x00\x00_(5\x07\x9aQ\x00\x00\x00\x80', + ], + (Ecu.esp, 0x740, None): [ + b'476605SH1D', + b'476605SK2A', + ], + (Ecu.eps, 0x742, None): [ + b'5SH2A\x99A\x05\x02N123F\x15\x81\x00\x00\x00\x00\x00\x00\x00\x80', + b'5SK3A\x99A\x05\x02N123F\x15u\x00\x00\x00\x00\x00\x00\x00\x80', + ], + (Ecu.gateway, 0x18dad0f1, None): [ + b'284U25SH3A', + b'284U25SK2D', + ], + }, + CAR.XTRAIL: { + (Ecu.fwdCamera, 0x707, None): [ + b'284N86FR2A', + ], + (Ecu.esp, 0x740, None): [ + b'6FU1BD\x11\x02\x00\x02e\x95e\x80iX#\x01\x00\x00\x00\x00\x00\x80', + b'6FU0AD\x11\x02\x00\x02e\x95e\x80iQ#\x01\x00\x00\x00\x00\x00\x80', + ], + (Ecu.eps, 0x742, None): [ + b'6FP2A\x99A\x05\x02N123F\x18\x02\x00\x00\x00\x00\x00\x00\x00\x80', + ], + (Ecu.combinationMeter, 0x743, None): [ + b'6FR2A\x18B\x05\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80', + ], + (Ecu.engine, 0x7e0, None): [ + b'6FU9B\xa0A\x06\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80', + b'6FR9A\xa0A\x06\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80', + ], + (Ecu.gateway, 0x18dad0f1, None): [ + b'284U26FR0E', + ], + }, +} + +DBC = { + CAR.XTRAIL: dbc_dict('nissan_x_trail_2017', None), + CAR.LEAF: dbc_dict('nissan_leaf_2018', None), + CAR.LEAF_IC: dbc_dict('nissan_leaf_2018', None), + CAR.ROGUE: dbc_dict('nissan_x_trail_2017', None), + CAR.ALTIMA: 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..6163d7329c62c7 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -1,73 +1,75 @@ -#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, CarControllerParams +from opendbc.can.packer import CANPacker -class CarControllerParams(): - def __init__(self, car_fingerprint): - 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 - - - -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.cruise_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.packer = CANPacker(DBC[CP.carFingerprint]['pt']) - def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, left_line, right_line): - """ Controls thread """ + def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart): - P = self.params - - # Send CAN commands. can_sends = [] - ### STEER ### - - if (frame % P.STEER_STEP) == 0: + # *** steering *** + if (frame % CarControllerParams.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 * CarControllerParams.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, CarControllerParams) + 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, CarControllerParams.STEER_STEP)) + else: + can_sends.append(subarucan.create_steering_control(self.packer, apply_steer, frame, CarControllerParams.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: + cruise_button = 1 + # turn main on if off and past start-up state + elif not CS.out.cruiseState.available and CS.ready: + cruise_button = 1 + else: + cruise_button = CS.cruise_button + + # unstick previous mocked button press + if cruise_button == 1 and self.cruise_button_prev == 1: + cruise_button = 0 + self.cruise_button_prev = cruise_button + + can_sends.append(subarucan.create_es_throttle_control(self.packer, cruise_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, enabled, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart)) + 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 9a927775489335..1f56f09ff72bc5 100644 --- a/selfdrive/car/subaru/carstate.py +++ b/selfdrive/car/subaru/carstate.py @@ -1,153 +1,240 @@ 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, timeout=100) - - -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, timeout=100) - - -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_Status"]["Brake"] == 1 + + ret.wheelSpeeds = self.get_wheel_speeds( + cp.vl["Wheel_Speeds"]["FL"], + cp.vl["Wheel_Speeds"]["FR"], + cp.vl["Wheel_Speeds"]["RL"], + cp.vl["Wheel_Speeds"]["RR"], + ) + 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_from_lamp( + 50, cp.vl["Dashlights"]["LEFT_BLINKER"], cp.vl["Dashlights"]["RIGHT_BLINKER"]) + + if self.CP.enableBsm: + 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.steeringAngleDeg = 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 + + if (self.car_fingerprint in PREGLOBAL_CARS and cp.vl["Dash_State2"]["UNITS"] == 1) or \ + (self.car_fingerprint not in PREGLOBAL_CARS and cp.vl["Dashlights"]["UNITS"] == 1): + 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"]]) + ret.steerError = cp.vl["Steering_Torque"]["Steer_Error_1"] == 1 + + if self.car_fingerprint in PREGLOBAL_CARS: + self.cruise_button = cp_cam.vl["ES_CruiseThrottle"]["Cruise_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.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), + ("Steer_Error_1", "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), + ("Gear", "Transmission", 0), + ] + + checks = [ + # sig_address, frequency + ("Throttle", 100), + ("Dashlights", 10), + ("Brake_Pedal", 50), + ("Wheel_Speeds", 50), + ("Transmission", 100), + ("Steering_Torque", 50), + ("BodyInfo", 1), + ] + + if CP.enableBsm: + signals += [ + ("L_ADJACENT", "BSD_RCTA", 0), + ("R_ADJACENT", "BSD_RCTA", 0), + ("L_APPROACHING", "BSD_RCTA", 0), + ("R_APPROACHING", "BSD_RCTA", 0), + ] + checks += [ + ("BSD_RCTA", 17), + ] + + if CP.carFingerprint not in PREGLOBAL_CARS: + signals += [ + ("Steer_Warning", "Steering_Torque", 0), + ("Brake", "Brake_Status", 0), + ("UNITS", "Dashlights", 0), + ] + + checks += [ + ("Dashlights", 10), + ("BodyInfo", 10), + ("Brake_Status", 50), + ("CruiseControl", 20), + ] + else: + signals += [ + ("UNITS", "Dash_State2", 0), + ] + + checks += [ + ("Dash_State2", 1), + ] + + 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), + ("Distance_Swap", "ES_CruiseThrottle", 0), + ("Standstill", "ES_CruiseThrottle", 0), + ("Signal3", "ES_CruiseThrottle", 0), + ("Close_Distance", "ES_CruiseThrottle", 0), + ("Signal4", "ES_CruiseThrottle", 0), + ("Standstill_2", "ES_CruiseThrottle", 0), + ("Cruise_Fault", "ES_CruiseThrottle", 0), + ("Signal5", "ES_CruiseThrottle", 0), + ("Counter", "ES_CruiseThrottle", 0), + ("Signal6", "ES_CruiseThrottle", 0), + ("Cruise_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), + ("LKAS_Alert_Msg", "ES_LKAS_State", 0), + ("Signal1", "ES_LKAS_State", 0), + ("LKAS_ACTIVE", "ES_LKAS_State", 0), + ("LKAS_Dash_State", "ES_LKAS_State", 0), + ("Signal2", "ES_LKAS_State", 0), + ("Backward_Speed_Limit_Menu", "ES_LKAS_State", 0), + ("LKAS_Left_Line_Enable", "ES_LKAS_State", 0), + ("LKAS_Left_Line_Light_Blink", "ES_LKAS_State", 0), + ("LKAS_Right_Line_Enable", "ES_LKAS_State", 0), + ("LKAS_Right_Line_Light_Blink", "ES_LKAS_State", 0), + ("LKAS_Left_Line_Visible", "ES_LKAS_State", 0), + ("LKAS_Right_Line_Visible", "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 e9d9c117fc714c..86bba542cce108 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -1,59 +1,41 @@ -#!/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, get_safety_config +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=""): - 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.safetyModel = car.CarParams.SafetyModel.subaru + ret.radarOffCan = True - ret.enableCruise = True - ret.steerLimitAlert = True + if candidate in PREGLOBAL_CARS: + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.subaruLegacy)] + ret.enableBsm = 0x25c in fingerprint[0] + else: + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.subaru)] + ret.enableBsm = 0x228 in fingerprint[0] - ret.enableCamera = True + ret.dashcamOnly = candidate in PREGLOBAL_CARS 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 @@ -62,26 +44,47 @@ def get_params(candidate, fingerprint, vin=""): 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.safetyConfigs[0].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 @@ -94,101 +97,23 @@ def get_params(candidate, fingerprint, vin=""): return ret # returns a car.CarState - def update(self, c): - can_rcv_valid, _ = self.pt_cp.update(int(sec_since_boot() * 1e9), True) - cam_rcv_valid, _ = self.cam_cp.update(int(sec_since_boot() * 1e9), False) - - self.CS.update(self.pt_cp, self.cam_cp) - - # create message - ret = car.CarState.new_message() - - ret.canValid = can_rcv_valid and cam_rcv_valid and 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])) + def update(self, c, can_strings): + 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, c.cruiseControl.cancel, c.hudControl.visualAlert, - c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible) + c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart) self.frame += 1 return can_sends diff --git a/selfdrive/car/subaru/radar_interface.py b/selfdrive/car/subaru/radar_interface.py index 75256683de3187..b2f76511360320 100644 --- a/selfdrive/car/subaru/radar_interface.py +++ b/selfdrive/car/subaru/radar_interface.py @@ -1,24 +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): - - ret = car.RadarData.new_message() - time.sleep(0.05) # radard runs on RI updates - - return ret - -if __name__ == "__main__": - RI = RadarInterface(None) - while 1: - ret = RI.update() - print(chr(27) + "[2J") - print(ret) +class RadarInterface(RadarInterfaceBase): + pass diff --git a/selfdrive/car/subaru/subarucan.py b/selfdrive/car/subaru/subarucan.py index 922012f318dd42..6485de79016ed7 100644 --- a/selfdrive/car/subaru/subarucan.py +++ b/selfdrive/car/subaru/subarucan.py @@ -1,57 +1,90 @@ 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) -def create_es_lkas(packer, es_lkas_msg, visual_alert, left_line, right_line): +def create_es_lkas(packer, es_lkas_msg, enabled, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart): values = copy.copy(es_lkas_msg) + + # Filter the stock LKAS "Keep hands on wheel" alert + if values["LKAS_Alert_Msg"] == 1: + values["LKAS_Alert_Msg"] = 0 + + # Filter the stock LKAS sending an audible alert when it turns off LKAS + if values["LKAS_Alert"] == 27: + values["LKAS_Alert"] = 0 + + # Show Keep hands on wheel alert for openpilot steerRequired alert if visual_alert == VisualAlert.steerRequired: - values["Keep_Hands_On_Wheel"] = 1 + values["LKAS_Alert_Msg"] = 1 + + # Ensure we don't overwrite potentially more important alerts from stock (e.g. FCW) + if visual_alert == VisualAlert.ldw and values["LKAS_Alert"] == 0: + if left_lane_depart: + values["LKAS_Alert"] = 12 # Left lane departure dash alert + elif right_lane_depart: + values["LKAS_Alert"] = 11 # Right lane departure dash alert + + if enabled: + values["LKAS_ACTIVE"] = 1 # Show LKAS lane lines + values["LKAS_Dash_State"] = 2 # Green enabled indicator + else: + values["LKAS_Dash_State"] = 0 # LKAS Not enabled 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, cruise_button, es_accel_msg): + + values = copy.copy(es_accel_msg) + values["Cruise_Button"] = cruise_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..39f8e5e5989bf1 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -1,22 +1,91 @@ +# flake8: noqa + from selfdrive.car import dbc_dict +from cereal import car +Ecu = car.CarParams.Ecu + +class CarControllerParams: + STEER_MAX = 2047 # max_steer 4095 + STEER_STEP = 2 # how often we update the steer cmd + STEER_DELTA_UP = 50 # torque increase per refresh, 0.8s to max + STEER_DELTA_DOWN = 70 # torque decrease per refresh + STEER_DRIVER_ALLOWANCE = 60 # allowed driver torque before start limiting + STEER_DRIVER_MULTIPLIER = 10 # weight driver torque heavily + STEER_DRIVER_FACTOR = 1 # from dbc 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: [{ - 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 + 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, 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, 827: 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 + }], + 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 }, - # Crosstrek 2018 (same platform as Subaru) + # 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/boardd/tests/__init__.py b/selfdrive/car/tesla/__init__.py similarity index 100% rename from selfdrive/boardd/tests/__init__.py rename to selfdrive/car/tesla/__init__.py diff --git a/selfdrive/car/tesla/carcontroller.py b/selfdrive/car/tesla/carcontroller.py new file mode 100644 index 00000000000000..7e6a2f2e9a8e70 --- /dev/null +++ b/selfdrive/car/tesla/carcontroller.py @@ -0,0 +1,65 @@ +from common.numpy_fast import clip, interp +from opendbc.can.packer import CANPacker +from selfdrive.car.tesla.teslacan import TeslaCAN +from selfdrive.car.tesla.values import DBC, CANBUS, CarControllerParams + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.CP = CP + self.last_angle = 0 + self.long_control_counter = 0 + self.packer = CANPacker(dbc_name) + self.pt_packer = CANPacker(DBC[CP.carFingerprint]['pt']) + self.tesla_can = TeslaCAN(self.packer, self.pt_packer) + + def update(self, enabled, CS, frame, actuators, cruise_cancel): + can_sends = [] + + # Temp disable steering on a hands_on_fault, and allow for user override + hands_on_fault = (CS.steer_warning == "EAC_ERROR_HANDS_ON" and CS.hands_on_level >= 3) + lkas_enabled = enabled and (not hands_on_fault) + + if lkas_enabled: + apply_angle = actuators.steeringAngleDeg + + # Angular rate limit based on speed + steer_up = (self.last_angle * apply_angle > 0. and abs(apply_angle) > abs(self.last_angle)) + rate_limit = CarControllerParams.RATE_LIMIT_UP if steer_up else CarControllerParams.RATE_LIMIT_DOWN + max_angle_diff = interp(CS.out.vEgo, rate_limit.speed_points, rate_limit.max_angle_diff_points) + apply_angle = clip(apply_angle, (self.last_angle - max_angle_diff), (self.last_angle + max_angle_diff)) + + # To not fault the EPS + apply_angle = clip(apply_angle, (CS.out.steeringAngleDeg - 20), (CS.out.steeringAngleDeg + 20)) + else: + apply_angle = CS.out.steeringAngleDeg + + self.last_angle = apply_angle + can_sends.append(self.tesla_can.create_steering_control(apply_angle, lkas_enabled, frame)) + + # Longitudinal control (40Hz) + if self.CP.openpilotLongitudinalControl and ((frame % 5) in [0, 2]): + target_accel = actuators.accel + target_speed = max(CS.out.vEgo + (target_accel * CarControllerParams.ACCEL_TO_SPEED_MULTIPLIER), 0) + max_accel = 0 if target_accel < 0 else target_accel + min_accel = 0 if target_accel > 0 else target_accel + + can_sends.extend(self.tesla_can.create_longitudinal_commands(CS.acc_state, target_speed, min_accel, max_accel, self.long_control_counter)) + self.long_control_counter += 1 + + # Cancel on user steering override, since there is no steering torque blending + if hands_on_fault: + cruise_cancel = True + + # Cancel when openpilot is not enabled anymore + if not enabled and bool(CS.out.cruiseState.enabled): + cruise_cancel = True + + if ((frame % 10) == 0 and cruise_cancel): + # Spam every possible counter value, otherwise it might not be accepted + for counter in range(16): + can_sends.append(self.tesla_can.create_action_request(CS.msg_stw_actn_req, cruise_cancel, CANBUS.chassis, counter)) + can_sends.append(self.tesla_can.create_action_request(CS.msg_stw_actn_req, cruise_cancel, CANBUS.autopilot_chassis, counter)) + + # TODO: HUD control + + return can_sends diff --git a/selfdrive/car/tesla/carstate.py b/selfdrive/car/tesla/carstate.py new file mode 100644 index 00000000000000..0a45b6f2bb3712 --- /dev/null +++ b/selfdrive/car/tesla/carstate.py @@ -0,0 +1,185 @@ +import copy +from cereal import car +from selfdrive.car.tesla.values import DBC, CANBUS, GEAR_MAP, DOORS, BUTTONS +from selfdrive.car.interfaces import CarStateBase +from opendbc.can.parser import CANParser +from opendbc.can.can_define import CANDefine +from selfdrive.config import Conversions as CV + +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + self.button_states = {button.event_type: False for button in BUTTONS} + self.can_define = CANDefine(DBC[CP.carFingerprint]['chassis']) + + # Needed by carcontroller + self.msg_stw_actn_req = None + self.hands_on_level = 0 + self.steer_warning = None + self.acc_state = 0 + + def update(self, cp, cp_cam): + ret = car.CarState.new_message() + + # Vehicle speed + ret.vEgoRaw = cp.vl["ESP_B"]["ESP_vehicleSpeed"] * CV.KPH_TO_MS + ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) + ret.standstill = (ret.vEgo < 0.1) + + # Gas pedal + ret.gas = cp.vl["DI_torque1"]["DI_pedalPos"] / 100.0 + ret.gasPressed = (ret.gas > 0) + + # Brake pedal + ret.brake = 0 + ret.brakePressed = bool(cp.vl["BrakeMessage"]["driverBrakeStatus"] != 1) + + # Steering wheel + self.hands_on_level = cp.vl["EPAS_sysStatus"]["EPAS_handsOnLevel"] + self.steer_warning = self.can_define.dv["EPAS_sysStatus"]["EPAS_eacErrorCode"].get(int(cp.vl["EPAS_sysStatus"]["EPAS_eacErrorCode"]), None) + steer_status = self.can_define.dv["EPAS_sysStatus"]["EPAS_eacStatus"].get(int(cp.vl["EPAS_sysStatus"]["EPAS_eacStatus"]), None) + + ret.steeringAngleDeg = -cp.vl["EPAS_sysStatus"]["EPAS_internalSAS"] + ret.steeringRateDeg = -cp.vl["STW_ANGLHP_STAT"]["StW_AnglHP_Spd"] # This is from a different angle sensor, and at different rate + ret.steeringTorque = -cp.vl["EPAS_sysStatus"]["EPAS_torsionBarTorque"] + ret.steeringPressed = (self.hands_on_level > 0) + ret.steerError = steer_status == "EAC_FAULT" + ret.steerWarning = self.steer_warning != "EAC_ERROR_IDLE" + + # Cruise state + cruise_state = self.can_define.dv["DI_state"]["DI_cruiseState"].get(int(cp.vl["DI_state"]["DI_cruiseState"]), None) + speed_units = self.can_define.dv["DI_state"]["DI_speedUnits"].get(int(cp.vl["DI_state"]["DI_speedUnits"]), None) + + acc_enabled = (cruise_state in ["ENABLED", "STANDSTILL", "OVERRIDE", "PRE_FAULT", "PRE_CANCEL"]) + + ret.cruiseState.enabled = acc_enabled + if speed_units == "KPH": + ret.cruiseState.speed = cp.vl["DI_state"]["DI_digitalSpeed"] * CV.KPH_TO_MS + elif speed_units == "MPH": + ret.cruiseState.speed = cp.vl["DI_state"]["DI_digitalSpeed"] * CV.MPH_TO_MS + ret.cruiseState.available = ((cruise_state == "STANDBY") or ret.cruiseState.enabled) + ret.cruiseState.standstill = False # This needs to be false, since we can resume from stop without sending anything special + + # Gear + ret.gearShifter = GEAR_MAP[self.can_define.dv["DI_torque2"]["DI_gear"].get(int(cp.vl["DI_torque2"]["DI_gear"]), "DI_GEAR_INVALID")] + + # Buttons + buttonEvents = [] + for button in BUTTONS: + state = (cp.vl[button.can_addr][button.can_msg] in button.values) + if self.button_states[button.event_type] != state: + event = car.CarState.ButtonEvent.new_message() + event.type = button.event_type + event.pressed = state + buttonEvents.append(event) + self.button_states[button.event_type] = state + ret.buttonEvents = buttonEvents + + # Doors + ret.doorOpen = any([(self.can_define.dv["GTW_carState"][door].get(int(cp.vl["GTW_carState"][door]), "OPEN") == "OPEN") for door in DOORS]) + + # Blinkers + ret.leftBlinker = (cp.vl["GTW_carState"]["BC_indicatorLStatus"] == 1) + ret.rightBlinker = (cp.vl["GTW_carState"]["BC_indicatorRStatus"] == 1) + + # Seatbelt + ret.seatbeltUnlatched = (cp.vl["SDM1"]["SDM_bcklDrivStatus"] != 1) + + # TODO: blindspot + + # Messages needed by carcontroller + self.msg_stw_actn_req = copy.copy(cp.vl["STW_ACTN_RQ"]) + self.acc_state = cp_cam.vl["DAS_control"]["DAS_accState"] + + return ret + + @staticmethod + def get_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("ESP_vehicleSpeed", "ESP_B", 0), + ("DI_pedalPos", "DI_torque1", 0), + ("DI_brakePedal", "DI_torque2", 0), + ("StW_AnglHP", "STW_ANGLHP_STAT", 0), + ("StW_AnglHP_Spd", "STW_ANGLHP_STAT", 0), + ("EPAS_handsOnLevel", "EPAS_sysStatus", 0), + ("EPAS_torsionBarTorque", "EPAS_sysStatus", 0), + ("EPAS_internalSAS", "EPAS_sysStatus", 0), + ("EPAS_eacStatus", "EPAS_sysStatus", 1), + ("EPAS_eacErrorCode", "EPAS_sysStatus", 0), + ("DI_cruiseState", "DI_state", 0), + ("DI_digitalSpeed", "DI_state", 0), + ("DI_speedUnits", "DI_state", 0), + ("DI_gear", "DI_torque2", 0), + ("DOOR_STATE_FL", "GTW_carState", 1), + ("DOOR_STATE_FR", "GTW_carState", 1), + ("DOOR_STATE_RL", "GTW_carState", 1), + ("DOOR_STATE_RR", "GTW_carState", 1), + ("DOOR_STATE_FrontTrunk", "GTW_carState", 1), + ("BOOT_STATE", "GTW_carState", 1), + ("BC_indicatorLStatus", "GTW_carState", 1), + ("BC_indicatorRStatus", "GTW_carState", 1), + ("SDM_bcklDrivStatus", "SDM1", 0), + ("driverBrakeStatus", "BrakeMessage", 0), + + # We copy this whole message when spamming cancel + ("SpdCtrlLvr_Stat", "STW_ACTN_RQ", 0), + ("VSL_Enbl_Rq", "STW_ACTN_RQ", 0), + ("SpdCtrlLvrStat_Inv", "STW_ACTN_RQ", 0), + ("DTR_Dist_Rq", "STW_ACTN_RQ", 0), + ("TurnIndLvr_Stat", "STW_ACTN_RQ", 0), + ("HiBmLvr_Stat", "STW_ACTN_RQ", 0), + ("WprWashSw_Psd", "STW_ACTN_RQ", 0), + ("WprWash_R_Sw_Posn_V2", "STW_ACTN_RQ", 0), + ("StW_Lvr_Stat", "STW_ACTN_RQ", 0), + ("StW_Cond_Flt", "STW_ACTN_RQ", 0), + ("StW_Cond_Psd", "STW_ACTN_RQ", 0), + ("HrnSw_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw00_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw01_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw02_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw03_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw04_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw05_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw06_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw07_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw08_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw09_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw10_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw11_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw12_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw13_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw14_Psd", "STW_ACTN_RQ", 0), + ("StW_Sw15_Psd", "STW_ACTN_RQ", 0), + ("WprSw6Posn", "STW_ACTN_RQ", 0), + ("MC_STW_ACTN_RQ", "STW_ACTN_RQ", 0), + ("CRC_STW_ACTN_RQ", "STW_ACTN_RQ", 0), + ] + + checks = [ + # sig_address, frequency + ("ESP_B", 50), + ("DI_torque1", 100), + ("DI_torque2", 100), + ("STW_ANGLHP_STAT", 100), + ("EPAS_sysStatus", 25), + ("DI_state", 10), + ("STW_ACTN_RQ", 10), + ("GTW_carState", 10), + ("SDM1", 10), + ("BrakeMessage", 50), + ] + + return CANParser(DBC[CP.carFingerprint]['chassis'], signals, checks, CANBUS.chassis) + + @staticmethod + def get_cam_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("DAS_accState", "DAS_control", 0), + ] + checks = [ + # sig_address, frequency + ("DAS_control", 40), + ] + return CANParser(DBC[CP.carFingerprint]['chassis'], signals, checks, CANBUS.autopilot_chassis) diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py new file mode 100755 index 00000000000000..45dc0a72393db7 --- /dev/null +++ b/selfdrive/car/tesla/interface.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +from cereal import car +from panda import Panda +from selfdrive.car.tesla.values import CANBUS, CAR +from selfdrive.car import STD_CARGO_KG, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, get_safety_config +from selfdrive.car.interfaces import CarInterfaceBase + + +class CarInterface(CarInterfaceBase): + @staticmethod + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) + ret.carName = "tesla" + + # There is no safe way to do steer blending with user torque, + # so the steering behaves like autopilot. This is not + # how openpilot should be, hence dashcamOnly + ret.dashcamOnly = True + + ret.steerControlType = car.CarParams.SteerControlType.angle + + # Set kP and kI to 0 over the whole speed range to have the planner accel as actuator command + ret.longitudinalTuning.kpBP = [0] + ret.longitudinalTuning.kpV = [0] + ret.longitudinalTuning.kiBP = [0] + ret.longitudinalTuning.kiV = [0] + ret.stopAccel = 0.0 + ret.startAccel = 0.0 + ret.longitudinalActuatorDelayUpperBound = 0.5 # s + ret.radarTimeStep = (1.0 / 8) # 8Hz + + # Check if we have messages on an auxiliary panda, and that 0x2bf (DAS_control) is present on the AP powertrain bus + # If so, we assume that it is connected to the longitudinal harness. + if (CANBUS.autopilot_powertrain in fingerprint.keys()) and (0x2bf in fingerprint[CANBUS.autopilot_powertrain].keys()): + ret.openpilotLongitudinalControl = True + ret.safetyConfigs = [ + get_safety_config(car.CarParams.SafetyModel.tesla, Panda.FLAG_TESLA_LONG_CONTROL), + get_safety_config(car.CarParams.SafetyModel.tesla, Panda.FLAG_TESLA_LONG_CONTROL | Panda.FLAG_TESLA_POWERTRAIN), + ] + else: + ret.openpilotLongitudinalControl = False + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.tesla, 0)] + + ret.steerActuatorDelay = 0.1 + ret.steerRateCost = 0.5 + + if candidate in [CAR.AP2_MODELS, CAR.AP1_MODELS]: + ret.mass = 2100. + STD_CARGO_KG + ret.wheelbase = 2.959 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 13.5 + else: + raise ValueError(f"Unsupported car: {candidate}") + + ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) + ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront) + + return ret + + 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 = self.create_common_events(ret) + + 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) + self.frame += 1 + return can_sends diff --git a/selfdrive/car/tesla/radar_interface.py b/selfdrive/car/tesla/radar_interface.py new file mode 100755 index 00000000000000..f5ad12ba7e89df --- /dev/null +++ b/selfdrive/car/tesla/radar_interface.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3 +from cereal import car +from opendbc.can.parser import CANParser +from selfdrive.car.tesla.values import DBC, CANBUS +from selfdrive.car.interfaces import RadarInterfaceBase + +RADAR_MSGS_A = list(range(0x310, 0x36E, 3)) +RADAR_MSGS_B = list(range(0x311, 0x36F, 3)) +NUM_POINTS = len(RADAR_MSGS_A) + +def get_radar_can_parser(CP): + # Status messages + signals = [ + ('RADC_HWFail', 'TeslaRadarSguInfo', 0), + ('RADC_SGUFail', 'TeslaRadarSguInfo', 0), + ('RADC_SensorDirty', 'TeslaRadarSguInfo', 0), + ] + + checks = [ + ('TeslaRadarSguInfo', 10), + ] + + # Radar tracks. There are also raw point clouds available, + # we don't use those. + for i in range(NUM_POINTS): + msg_id_a = RADAR_MSGS_A[i] + msg_id_b = RADAR_MSGS_B[i] + + # There is a bunch more info in the messages, + # but these are the only things actually used in openpilot + signals.extend([ + ('LongDist', msg_id_a, 255), + ('LongSpeed', msg_id_a, 0), + ('LatDist', msg_id_a, 0), + ('LongAccel', msg_id_a, 0), + ('Meas', msg_id_a, 0), + ('Tracked', msg_id_a, 0), + ('Index', msg_id_a, 0), + + ('LatSpeed', msg_id_b, 0), + ('Index2', msg_id_b, 0), + ]) + + checks.extend([ + (msg_id_a, 8), + (msg_id_b, 8), + ]) + + return CANParser(DBC[CP.carFingerprint]['radar'], signals, checks, CANBUS.radar) + +class RadarInterface(RadarInterfaceBase): + def __init__(self, CP): + super().__init__(CP) + self.rcp = get_radar_can_parser(CP) + self.updated_messages = set() + self.track_id = 0 + self.trigger_msg = RADAR_MSGS_B[-1] + + def update(self, can_strings): + if self.rcp is None: + return super().update(None) + + values = self.rcp.update_strings(can_strings) + self.updated_messages.update(values) + + if self.trigger_msg not in self.updated_messages: + return None + + ret = car.RadarData.new_message() + + # Errors + errors = [] + sgu_info = self.rcp.vl['TeslaRadarSguInfo'] + if not self.rcp.can_valid: + errors.append('canError') + if sgu_info['RADC_HWFail'] or sgu_info['RADC_SGUFail'] or sgu_info['RADC_SensorDirty']: + errors.append('fault') + ret.errors = errors + + # Radar tracks + for i in range(NUM_POINTS): + msg_a = self.rcp.vl[RADAR_MSGS_A[i]] + msg_b = self.rcp.vl[RADAR_MSGS_B[i]] + + # Make sure msg A and B are together + if msg_a['Index'] != msg_b['Index2']: + continue + + # Check if it's a valid track + if not msg_a['Tracked']: + if i in self.pts: + del self.pts[i] + continue + + # New track! + if i not in self.pts: + self.pts[i] = car.RadarData.RadarPoint.new_message() + self.pts[i].trackId = self.track_id + self.track_id += 1 + + # Parse track data + self.pts[i].dRel = msg_a['LongDist'] + self.pts[i].yRel = msg_a['LatDist'] + self.pts[i].vRel = msg_a['LongSpeed'] + self.pts[i].aRel = msg_a['LongAccel'] + self.pts[i].yvRel = msg_b['LatSpeed'] + self.pts[i].measured = bool(msg_a['Meas']) + + ret.points = list(self.pts.values()) + self.updated_messages.clear() + return ret diff --git a/selfdrive/car/tesla/teslacan.py b/selfdrive/car/tesla/teslacan.py new file mode 100644 index 00000000000000..1301802860590d --- /dev/null +++ b/selfdrive/car/tesla/teslacan.py @@ -0,0 +1,61 @@ +import copy +import crcmod +from selfdrive.config import Conversions as CV +from selfdrive.car.tesla.values import CANBUS, CarControllerParams + + +class TeslaCAN: + def __init__(self, packer, pt_packer): + self.packer = packer + self.pt_packer = pt_packer + self.crc = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff) + + @staticmethod + def checksum(msg_id, dat): + # TODO: get message ID from name instead + ret = (msg_id & 0xFF) + ((msg_id >> 8) & 0xFF) + ret += sum(dat) + return ret & 0xFF + + def create_steering_control(self, angle, enabled, frame): + values = { + "DAS_steeringAngleRequest": -angle, + "DAS_steeringHapticRequest": 0, + "DAS_steeringControlType": 1 if enabled else 0, + "DAS_steeringControlCounter": (frame % 16), + } + + data = self.packer.make_can_msg("DAS_steeringControl", CANBUS.chassis, values)[2] + values["DAS_steeringControlChecksum"] = self.checksum(0x488, data[:3]) + return self.packer.make_can_msg("DAS_steeringControl", CANBUS.chassis, values) + + def create_action_request(self, msg_stw_actn_req, cancel, bus, counter): + values = copy.copy(msg_stw_actn_req) + + if cancel: + values["SpdCtrlLvr_Stat"] = 1 + values["MC_STW_ACTN_RQ"] = counter + + data = self.packer.make_can_msg("STW_ACTN_RQ", bus, values)[2] + values["CRC_STW_ACTN_RQ"] = self.crc(data[:7]) + return self.packer.make_can_msg("STW_ACTN_RQ", bus, values) + + def create_longitudinal_commands(self, acc_state, speed, min_accel, max_accel, cnt): + messages = [] + values = { + "DAS_setSpeed": speed * CV.MS_TO_KPH, + "DAS_accState": acc_state, + "DAS_aebEvent": 0, + "DAS_jerkMin": CarControllerParams.JERK_LIMIT_MIN, + "DAS_jerkMax": CarControllerParams.JERK_LIMIT_MAX, + "DAS_accelMin": min_accel, + "DAS_accelMax": max_accel, + "DAS_controlCounter": (cnt % 8), + "DAS_controlChecksum": 0, + } + + for packer, bus in [(self.packer, CANBUS.chassis), (self.pt_packer, CANBUS.powertrain)]: + data = packer.make_can_msg("DAS_control", bus, values)[2] + values["DAS_controlChecksum"] = self.checksum(0x2b9, data[:7]) + messages.append(packer.make_can_msg("DAS_control", bus, values)) + return messages diff --git a/selfdrive/car/tesla/values.py b/selfdrive/car/tesla/values.py new file mode 100644 index 00000000000000..90bc45c7a578db --- /dev/null +++ b/selfdrive/car/tesla/values.py @@ -0,0 +1,69 @@ +# flake8: noqa + +from collections import namedtuple +from selfdrive.car import dbc_dict +from cereal import car + +Button = namedtuple('Button', ['event_type', 'can_addr', 'can_msg', 'values']) +AngleRateLimit = namedtuple('AngleRateLimit', ['speed_points', 'max_angle_diff_points']) + +class CAR: + AP1_MODELS = 'TESLA AP1 MODEL S' + AP2_MODELS = 'TESLA AP2 MODEL S' + +FINGERPRINTS = { + CAR.AP2_MODELS: [ + { + 1: 8, 3: 8, 14: 8, 21: 4, 69: 8, 109: 4, 257: 3, 264: 8, 277: 6, 280: 6, 293: 4, 296: 4, 309: 5, 325: 8, 328: 5, 336: 8, 341: 8, 360: 7, 373: 8, 389: 8, 415: 8, 513: 5, 516: 8, 518: 8, 520: 4, 522: 8, 524: 8, 526: 8, 532: 3, 536: 8, 537: 3, 542: 8, 551: 5, 552: 2, 556: 8, 558: 8, 568: 8, 569: 8, 574: 8, 577: 8, 582: 5, 583: 8, 584: 4, 585: 8, 590: 8, 601: 8, 606: 8, 608: 1, 622: 8, 627: 6, 638: 8, 641: 8, 643: 8, 692: 8, 693: 8, 695: 8, 696: 8, 697: 8, 699: 8, 700: 8, 701: 8, 702: 8, 703: 8, 704: 8, 708: 8, 709: 8, 710: 8, 711: 8, 712: 8, 728: 8, 744: 8, 760: 8, 772: 8, 775: 8, 776: 8, 777: 8, 778: 8, 782: 8, 788: 8, 791: 8, 792: 8, 796: 2, 797: 8, 798: 6, 799: 8, 804: 8, 805: 8, 807: 8, 808: 1, 811: 8, 812: 8, 813: 8, 814: 5, 815: 8, 820: 8, 823: 8, 824: 8, 829: 8, 830: 5, 836: 8, 840: 8, 845: 8, 846: 5, 848: 8, 852: 8, 853: 8, 856: 4, 857: 6, 861: 8, 862: 5, 872: 8, 876: 8, 877: 8, 879: 8, 880: 8, 882: 8, 884: 8, 888: 8, 893: 8, 894: 8, 901: 6, 904: 3, 905: 8, 906: 8, 908: 2, 909: 8, 910: 8, 912: 8, 920: 8, 921: 8, 925: 4, 926: 6, 936: 8, 941: 8, 949: 8, 952: 8, 953: 6, 968: 8, 969: 6, 970: 8, 971: 8, 977: 8, 984: 8, 987: 8, 990: 8, 1000: 8, 1001: 8, 1006: 8, 1007: 8, 1008: 8, 1010: 6, 1014: 1, 1015: 8, 1016: 8, 1017: 8, 1018: 8, 1020: 8, 1026: 8, 1028: 8, 1029: 8, 1030: 8, 1032: 1, 1033: 1, 1034: 8, 1048: 1, 1049: 8, 1061: 8, 1064: 8, 1065: 8, 1070: 8, 1080: 8, 1081: 8, 1097: 8, 1113: 8, 1129: 8, 1145: 8, 1160: 4, 1177: 8, 1281: 8, 1328: 8, 1329: 8, 1332: 8, 1335: 8, 1337: 8, 1353: 8, 1368: 8, 1412: 8, 1436: 8, 1476: 8, 1481: 8, 1497: 8, 1513: 8, 1519: 8, 1601: 8, 1605: 8, 1617: 8, 1621: 8, 1800: 4, 1804: 8, 1812: 8, 1815: 8, 1816: 8, 1824: 8, 1828: 8, 1831: 8, 1832: 8, 1864: 8, 1880: 8, 1892: 8, 1896: 8, 1912: 8, 1960: 8, 1992: 8, 2008: 3, 2043: 5, 2045: 4 + }, + ], + CAR.AP1_MODELS: [ + { + 1: 8, 3: 8, 14: 8, 21: 4, 69: 8, 109: 4, 257: 3, 264: 8, 267: 5, 277: 6, 280: 6, 283: 5, 293: 4, 296: 4, 309: 5, 325: 8, 328: 5, 336: 8, 341: 8, 360: 7, 373: 8, 389: 8, 415: 8, 513: 5, 516: 8, 520: 4, 522: 8, 524: 8, 526: 8, 532: 3, 536: 8, 537: 3, 542: 8, 551: 5, 552: 2, 556: 8, 558: 8, 568: 8, 569: 8, 574: 8, 577: 8, 582: 5, 584: 4, 585: 8, 590: 8, 606: 8, 622: 8, 627: 6, 638: 8, 641: 8, 643: 8, 660: 5, 693: 8, 696: 8, 697: 8, 712: 8, 728: 8, 744: 8, 760: 8, 772: 8, 775: 8, 776: 8, 777: 8, 778: 8, 782: 8, 788: 8, 791: 8, 792: 8, 796: 2, 797: 8, 798: 6, 799: 8, 804: 8, 805: 8, 807: 8, 808: 1, 809: 8, 812: 8, 813: 8, 814: 5, 815: 8, 820: 8, 823: 8, 824: 8, 829: 8, 830: 5, 836: 8, 840: 8, 841: 8, 845: 8, 846: 5, 852: 8, 856: 4, 857: 6, 861: 8, 862: 5, 872: 8, 873: 8, 877: 8, 878: 8, 879: 8, 880: 8, 884: 8, 888: 8, 889: 8, 893: 8, 896: 8, 901: 6, 904: 3, 905: 8, 908: 2, 909: 8, 920: 8, 921: 8, 925: 4, 936: 8, 937: 8, 941: 8, 949: 8, 952: 8, 953: 6, 957: 8, 968: 8, 973: 8, 984: 8, 987: 8, 989: 8, 990: 8, 1000: 8, 1001: 8, 1006: 8, 1016: 8, 1026: 8, 1028: 8, 1029: 8, 1030: 8, 1032: 1, 1033: 1, 1034: 8, 1048: 1, 1064: 8, 1070: 8, 1080: 8, 1160: 4, 1281: 8, 1329: 8, 1332: 8, 1335: 8, 1337: 8, 1368: 8, 1412: 8, 1436: 8, 1465: 8, 1476: 8, 1497: 8, 1524: 8, 1527: 8, 1601: 8, 1605: 8, 1611: 8, 1614: 8, 1617: 8, 1621: 8, 1627: 8, 1630: 8, 1800: 4, 1804: 8, 1812: 8, 1815: 8, 1816: 8, 1828: 8, 1831: 8, 1832: 8, 1840: 8, 1848: 8, 1864: 8, 1880: 8, 1892: 8, 1896: 8, 1912: 8, 1960: 8, 1992: 8, 2008: 3, 2043: 5, 2045: 4 + }, + ], +} + +DBC = { + CAR.AP2_MODELS: dbc_dict('tesla_powertrain', 'tesla_radar', chassis_dbc='tesla_can'), + CAR.AP1_MODELS: dbc_dict('tesla_powertrain', 'tesla_radar', chassis_dbc='tesla_can'), +} + +class CANBUS: + # Lateral harness + chassis = 0 + radar = 1 + autopilot_chassis = 2 + + # Longitudinal harness + powertrain = 4 + private = 5 + autopilot_powertrain = 6 + +GEAR_MAP = { + "DI_GEAR_INVALID": car.CarState.GearShifter.unknown, + "DI_GEAR_P": car.CarState.GearShifter.park, + "DI_GEAR_R": car.CarState.GearShifter.reverse, + "DI_GEAR_N": car.CarState.GearShifter.neutral, + "DI_GEAR_D": car.CarState.GearShifter.drive, + "DI_GEAR_SNA": car.CarState.GearShifter.unknown, +} + +DOORS = ["DOOR_STATE_FL", "DOOR_STATE_FR", "DOOR_STATE_RL", "DOOR_STATE_RR", "DOOR_STATE_FrontTrunk", "BOOT_STATE"] + +# Make sure the message and addr is also in the CAN parser! +BUTTONS = [ + Button(car.CarState.ButtonEvent.Type.leftBlinker, "STW_ACTN_RQ", "TurnIndLvr_Stat", [1]), + Button(car.CarState.ButtonEvent.Type.rightBlinker, "STW_ACTN_RQ", "TurnIndLvr_Stat", [2]), + Button(car.CarState.ButtonEvent.Type.accelCruise, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [4, 16]), + Button(car.CarState.ButtonEvent.Type.decelCruise, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [8, 32]), + Button(car.CarState.ButtonEvent.Type.cancel, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [2]), + Button(car.CarState.ButtonEvent.Type.resumeCruise, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [1]), +] + +class CarControllerParams: + RATE_LIMIT_UP = AngleRateLimit(speed_points=[0., 5., 15.], max_angle_diff_points=[5., .8, .15]) + RATE_LIMIT_DOWN = AngleRateLimit(speed_points=[0., 5., 15.], max_angle_diff_points=[5., 3.5, 0.4]) + JERK_LIMIT_MAX = 8 + JERK_LIMIT_MIN = -8 + ACCEL_TO_SPEED_MULTIPLIER = 3 diff --git a/selfdrive/can/__init__.py b/selfdrive/car/tests/__init__.py similarity index 100% rename from selfdrive/can/__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..93dc05c8386561 --- /dev/null +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +import unittest +import importlib +from parameterized import parameterized + +from cereal import car +from selfdrive.car.fingerprints import all_known_cars +from selfdrive.car.car_helpers import interfaces +from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS + +class TestCarInterfaces(unittest.TestCase): + + @parameterized.expand([(car,) for car in all_known_cars()]) + def test_car_interfaces(self, car_name): + print(car_name) + if car_name in FINGERPRINTS: + fingerprint = FINGERPRINTS[car_name][0] + else: + fingerprint = {} + + 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) + + if car_params.steerControlType != car.CarParams.SteerControlType.angle: + 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.assertTrue(len(car_params.lateralTuning.indi.outerLoopGainV)) + + # 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/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index c6ffe0ea1e2cf0..1997e6c1113fa2 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -1,199 +1,74 @@ 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, \ - create_fcw_command -from selfdrive.car.toyota.values import ECU, STATIC_MSGS, TSS2_CAR -from selfdrive.can.packer import CANPacker - +from selfdrive.car import apply_toyota_steer_torque_limits, create_gas_interceptor_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, create_lta_steer_command +from selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \ + MIN_ACC_SPEED, PEDAL_TRANSITION, CarControllerParams +from opendbc.can.packer import CANPacker VisualAlert = car.CarControl.HUDControl.VisualAlert -AudibleAlert = car.CarControl.HUDControl.AudibleAlert - -# 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_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 - if not enabled: - # send 0 when disabled, otherwise acc faults - accel_steady = 0. - elif accel > accel_steady + ACCEL_HYST_GAP: - accel_steady = accel - ACCEL_HYST_GAP - elif accel < accel_steady - ACCEL_HYST_GAP: - accel_steady = accel + ACCEL_HYST_GAP - accel = accel_steady - - return accel, accel_steady - - -def process_hud_alert(hud_alert, audible_alert): - # initialize to no alert - steer = 0 - fcw = 0 - sound1 = 0 - sound2 = 0 - if hud_alert == VisualAlert.fcw: - fcw = 1 - elif hud_alert == VisualAlert.steerRequired: - steer = 1 - if audible_alert == AudibleAlert.chimeWarningRepeat: - sound1 = 1 - elif audible_alert != AudibleAlert.none: - # TODO: find a way to send single chimes - sound2 = 1 - - return steer, fcw, sound1, sound2 - - -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.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.steer_rate_limited = False self.packer = CANPacker(dbc_name) - def update(self, enabled, CS, frame, actuators, - pcm_cancel_cmd, hud_alert, audible_alert, forwarding_camera, + def update(self, enabled, active, CS, frame, actuators, pcm_cancel_cmd, hud_alert, left_line, right_line, lead, left_lane_depart, right_lane_depart): # *** compute control surfaces *** # gas and brake - - apply_gas = clip(actuators.gas, 0., 1.) - - if CS.CP.enableGasInterceptor: - # send only negative accel if interceptor is detected. otherwise, send the regular value - # +0.06 offset to reduce ABS pump usage when OP is engaged - apply_accel = 0.06 - actuators.brake + if CS.CP.enableGasInterceptor and enabled: + MAX_INTERCEPTOR_GAS = 0.5 + # RAV4 has very sensitive gas pedal + if CS.CP.carFingerprint in [CAR.RAV4, CAR.RAV4H, CAR.HIGHLANDER, CAR.HIGHLANDERH]: + PEDAL_SCALE = interp(CS.out.vEgo, [0.0, MIN_ACC_SPEED, MIN_ACC_SPEED + PEDAL_TRANSITION], [0.15, 0.3, 0.0]) + elif CS.CP.carFingerprint in [CAR.COROLLA]: + PEDAL_SCALE = interp(CS.out.vEgo, [0.0, MIN_ACC_SPEED, MIN_ACC_SPEED + PEDAL_TRANSITION], [0.3, 0.4, 0.0]) + else: + PEDAL_SCALE = interp(CS.out.vEgo, [0.0, MIN_ACC_SPEED, MIN_ACC_SPEED + PEDAL_TRANSITION], [0.4, 0.5, 0.0]) + # offset for creep and windbrake + pedal_offset = interp(CS.out.vEgo, [0.0, 2.3, MIN_ACC_SPEED + PEDAL_TRANSITION], [-.4, 0.0, 0.2]) + pedal_command = PEDAL_SCALE * (actuators.accel + pedal_offset) + interceptor_gas_cmd = clip(pedal_command, 0., MAX_INTERCEPTOR_GAS) else: - 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) + interceptor_gas_cmd = 0. + pcm_accel_cmd = clip(actuators.accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) # steer torque - apply_steer = int(round(actuators.steer * SteerLimitParams.STEER_MAX)) + new_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX)) + apply_steer = apply_toyota_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, CarControllerParams) + self.steer_rate_limited = new_steer != apply_steer - 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 - - # 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 = actuators.steerAngle - 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 - + # TODO: probably can delete this. CS.pcm_acc_status uses a different signal + # than CS.cruiseState.enabled. confirm they're not meaningfully different 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 = [] @@ -203,70 +78,57 @@ 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: - can_sends.append(create_accel_command(self.packer, apply_accel, pcm_cancel_cmd, self.standstill_req, lead)) + can_sends.append(create_steer_command(self.packer, apply_steer, apply_steer_req, frame)) + if frame % 2 == 0 and CS.CP.carFingerprint in TSS2_CAR: + can_sends.append(create_lta_steer_command(self.packer, 0, 0, frame // 2)) + + # 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.steeringAngleDeg, 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: + 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 in [CAR.LEXUS_IS, CAR.LEXUS_RC]: + can_sends.append(create_acc_cancel_command(self.packer)) + elif CS.CP.openpilotLongitudinalControl: + can_sends.append(create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type)) 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)) + can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead, CS.acc_type)) - 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)) + if frame % 2 == 0 and CS.CP.enableGasInterceptor: + # send exactly zero if gas cmd is zero. Interceptor will send the max between read value and gas cmd. + # This prevents unexpected pedal range rescaling + can_sends.append(create_gas_interceptor_command(self.packer, interceptor_gas_cmd, 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, audible_alert) - steer, fcw, sound1, sound2 = alert_out + fcw_alert = hud_alert == VisualAlert.fcw + steer_alert = hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw] - 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, sound1, sound2, left_line, right_line, left_lane_depart, right_lane_depart)) + if (frame % 100 == 0 or send_ui): + 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 CS.CP.enableDsu: + 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)) + for (addr, cars, bus, fr_step, vl) in STATIC_DSU_MSGS: + if frame % fr_step == 0 and CS.CP.enableDsu 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 d964f8c4328b92..7ce5907b9b0a70 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -1,174 +1,220 @@ -import numpy as np -from common.kalman.simple_kalman import KF1D -from selfdrive.can.parser import CANParser -from selfdrive.can.can_define import CANDefine +from cereal import car +from common.numpy_fast import mean +from common.filter_simple import FirstOrderFilter +from common.realtime import DT_CTRL +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, 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 - ("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)] - else: - signals += [("STEER_ANGLE", "STEER_ANGLE_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)) - checks.append(("GAS_SENSOR", 50)) - - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=100) - - -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, timeout=100) - - -class CarState(object): +from selfdrive.car.toyota.values import CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, TSS2_CAR + + +class CarState(CarStateBase): def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) + self.shifter_values = can_define.dv["GEAR_PACKET"]["GEAR"] + + # On cars with cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"] + # the signal 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 = True + self.accurate_steer_angle_seen = False + self.angle_offset = FirstOrderFilter(None, 60.0, DT_CTRL, initialized=False) + + self.low_speed_lockout = False + self.acc_type = 1 + + def update(self, cp, cp_cam): + ret = car.CarState.new_message() - 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 - - # 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'] + 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.brakeHoldActive = cp.vl["ESP_CONTROL"]["BRAKE_HOLD_ACTIVE"] == 1 if self.CP.enableGasInterceptor: - self.pedal_gas = cp.vl["GAS_SENSOR"]['INTERCEPTOR_GAS'] + ret.gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2. + ret.gasPressed = ret.gas > 15 + else: + ret.gas = cp.vl["GAS_PEDAL"]["GAS_PEDAL"] + ret.gasPressed = cp.vl["PCM_CRUISE"]["GAS_RELEASED"] == 0 + + ret.wheelSpeeds = self.get_wheel_speeds( + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FR"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RL"], + cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RR"], + ) + 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 + + ret.steeringAngleDeg = cp.vl["STEER_ANGLE_SENSOR"]["STEER_ANGLE"] + cp.vl["STEER_ANGLE_SENSOR"]["STEER_FRACTION"] + torque_sensor_angle_deg = cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"] + + # Some newer models have a more accurate angle measurement in the TORQUE_SENSOR message. Use if non-zero + if abs(torque_sensor_angle_deg) > 1e-3: + self.accurate_steer_angle_seen = True + + if self.accurate_steer_angle_seen: + # Offset seems to be invalid for large steering angles + if abs(ret.steeringAngleDeg) < 90: + self.angle_offset.update(torque_sensor_angle_deg - ret.steeringAngleDeg) + + if self.angle_offset.initialized: + ret.steeringAngleOffsetDeg = self.angle_offset.x + ret.steeringAngleDeg = torque_sensor_angle_deg - self.angle_offset.x + + ret.steeringRateDeg = cp.vl["STEER_ANGLE_SENSOR"]["STEER_RATE"] + + can_gear = int(cp.vl["GEAR_PACKET"]["GEAR"]) + 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 + + 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 + ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD + ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] not in [1, 5] + + if self.CP.carFingerprint in [CAR.LEXUS_IS, CAR.LEXUS_RC]: + ret.cruiseState.available = cp.vl["DSU_CRUISE"]["MAIN_ON"] != 0 + ret.cruiseState.speed = cp.vl["DSU_CRUISE"]["SET_SPEED"] * CV.KPH_TO_MS 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 NO_DSU_CAR: - self.angle_steers = cp.vl["STEER_TORQUE_SENSOR"]['STEER_ANGLE'] + 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 + + if self.CP.carFingerprint in TSS2_CAR: + self.acc_type = cp_cam.vl["ACC_CONTROL"]["ACC_TYPE"] + + # some TSS2 cars have low speed lockout permanently set, so ignore on those cars + # these cars are identified by an ACC_TYPE value of 2. + # TODO: it is possible to avoid the lockout and gain stop and go if you + # send your own ACC_CONTROL msg on startup with ACC_TYPE set to 1 + if (self.CP.carFingerprint not in TSS2_CAR and self.CP.carFingerprint not in [CAR.LEXUS_IS, CAR.LEXUS_RC]) or \ + (self.CP.carFingerprint in TSS2_CAR and self.acc_type == 1): + self.low_speed_lockout = cp.vl["PCM_CRUISE_2"]["LOW_SPEED_LOCKOUT"] == 2 + + self.pcm_acc_status = cp.vl["PCM_CRUISE"]["CRUISE_STATE"] + 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: - 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'] - 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.cruiseState.standstill = self.pcm_acc_status == 7 + ret.cruiseState.enabled = bool(cp.vl["PCM_CRUISE"]["CRUISE_ACTIVE"]) + ret.cruiseState.nonAdaptive = cp.vl["PCM_CRUISE"]["CRUISE_STATE"] in [1, 2, 3, 4, 5, 6] + 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'] - 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'] - # 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 - - self.user_brake = 0 - self.v_cruise_pcm = cp.vl["PCM_CRUISE_2"]['SET_SPEED'] - 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 == CAR.PRIUS: - self.generic_toggle = cp.vl["AUTOPARK_STATUS"]['STATE'] != 0 + self.steer_state = cp.vl["EPS_STATUS"]["LKA_STATE"] + + if self.CP.enableBsm: + 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), + ("BRAKE_HOLD_ACTIVE", "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), + ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0), + ] + + checks = [ + ("GEAR_PACKET", 1), + ("LIGHT_STALK", 1), + ("STEERING_LEVERS", 0.15), + ("SEATS_DOORS", 3), + ("ESP_CONTROL", 3), + ("EPS_STATUS", 25), + ("BRAKE_MODULE", 40), + ("GAS_PEDAL", 33), + ("WHEEL_SPEEDS", 80), + ("STEER_ANGLE_SENSOR", 80), + ("PCM_CRUISE", 33), + ("STEER_TORQUE_SENSOR", 50), + ] + + if CP.carFingerprint in [CAR.LEXUS_IS, CAR.LEXUS_RC]: + 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)) + + # 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.enableBsm: + signals += [ + ("L_ADJACENT", "BSM", 0), + ("L_APPROACHING", "BSM", 0), + ("R_ADJACENT", "BSM", 0), + ("R_APPROACHING", "BSM", 0), + ] + checks += [ + ("BSM", 1) + ] + + 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), + ("PRE_COLLISION", 0), # TODO: figure out why freq is inconsistent + ] + + if CP.carFingerprint in TSS2_CAR: + signals.append(("ACC_TYPE", "ACC_CONTROL", 0)) + checks.append(("ACC_CONTROL", 33)) + + return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 29abfeb8464db6..f9d6b586fddb45 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -1,189 +1,244 @@ -#!/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.swaglog import cloudlog +from selfdrive.car.toyota.tunes import LatTunes, LongTunes, set_long_tune, set_lat_tune +from selfdrive.car.toyota.values import Ecu, CAR, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, CarControllerParams +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config +from selfdrive.car.interfaces import CarInterfaceBase +EventName = car.CarEvent.EventName -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.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 + def get_pid_accel_limits(CP, current_speed, cruise_speed): + return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX @staticmethod - def calc_accel_override(a_ego, a_target, v_ego, v_target): - return 1.0 - - @staticmethod - def get_params(candidate, fingerprint, vin=""): - - 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.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.toyota)] - ret.safetyModel = car.CarParams.SafetyModel.toyota + ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay + ret.steerLimitTimer = 0.4 - # pedal - ret.enableCruise = not ret.enableGasInterceptor + ret.stoppingControl = False # Toyota starts braking more when it thinks you want to stop - ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay - if candidate != CAR.PRIUS: - ret.lateralTuning.init('pid') - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + # Most cars use this default safety param + ret.safetyConfigs[0].safetyParam = 73 if candidate == CAR.PRIUS: + ret.safetyConfigs[0].safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file stop_and_go = True - ret.safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file ret.wheelbase = 2.70 - ret.steerRatio = 15.00 # unknown end-to-end spec + ret.steerRatio = 15.74 # unknown end-to-end spec tire_stiffness_factor = 0.6371 # hand-tune ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG - ret.lateralTuning.init('indi') - ret.lateralTuning.indi.innerLoopGain = 4.0 - ret.lateralTuning.indi.outerLoopGain = 3.0 - ret.lateralTuning.indi.timeConstant = 1.0 - ret.lateralTuning.indi.actuatorEffectiveness = 1.0 - - ret.steerActuatorDelay = 0.5 + set_lat_tune(ret.lateralTuning, LatTunes.INDI_PRIUS) + ret.steerActuatorDelay = 0.3 elif candidate in [CAR.RAV4, CAR.RAV4H]: stop_and_go = True if (candidate in CAR.RAV4H) else False - ret.safetyParam = 73 ret.wheelbase = 2.65 - ret.steerRatio = 16.30 # 14.5 is spec end-to-end + ret.steerRatio = 16.88 # 14.5 is spec end-to-end tire_stiffness_factor = 0.5533 ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.05]] - ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 + set_lat_tune(ret.lateralTuning, LatTunes.LQR_RAV4) elif candidate == CAR.COROLLA: + ret.safetyConfigs[0].safetyParam = 88 stop_and_go = False - ret.safetyParam = 100 ret.wheelbase = 2.70 - ret.steerRatio = 17.8 + ret.steerRatio = 18.27 tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid - 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_A) + + elif candidate == CAR.LEXUS_RX: + stop_and_go = True + ret.wheelbase = 2.79 + ret.steerRatio = 14.8 + tire_stiffness_factor = 0.5533 + ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_B) elif candidate == CAR.LEXUS_RXH: stop_and_go = True - ret.safetyParam = 73 ret.wheelbase = 2.79 ret.steerRatio = 16. # 14.8 is spec end-to-end tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max - 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_C) + + elif candidate == CAR.LEXUS_RX_TSS2: + stop_and_go = True + 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_D) + ret.wheelSpeedFactor = 1.035 + + elif candidate == CAR.LEXUS_RXH_TSS2: + stop_and_go = True + 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_E) + ret.wheelSpeedFactor = 1.035 elif candidate in [CAR.CHR, CAR.CHRH]: stop_and_go = True - ret.safetyParam = 73 ret.wheelbase = 2.63906 ret.steerRatio = 13.6 tire_stiffness_factor = 0.7933 ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.723], [0.0428]] - ret.lateralTuning.pid.kf = 0.00006 + set_lat_tune(ret.lateralTuning, LatTunes.PID_F) - elif candidate in [CAR.CAMRY, CAR.CAMRYH]: + elif candidate in [CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2, CAR.CAMRYH_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.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] - ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid + set_lat_tune(ret.lateralTuning, LatTunes.PID_C) + + elif candidate in [CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2]: + stop_and_go = True + 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_G) 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.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning - ret.lateralTuning.pid.kf = 0.00012 # community tuning + ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid limited + set_lat_tune(ret.lateralTuning, LatTunes.PID_G) - elif candidate == CAR.AVALON: + elif candidate in [CAR.AVALON, CAR.AVALON_2019, CAR.AVALONH_2019]: 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]] - ret.lateralTuning.pid.kf = 0.00006 + set_lat_tune(ret.lateralTuning, LatTunes.PID_H) - elif candidate == CAR.RAV4_TSS2: + elif candidate in [CAR.RAV4_TSS2, 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.6], [0.1]] - ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG - ret.lateralTuning.pid.kf = 0.00007818594 + ret.mass = 3585. * CV.LB_TO_KG + STD_CARGO_KG # Average between ICE and Hybrid + set_lat_tune(ret.lateralTuning, LatTunes.PID_D) - elif candidate == CAR.COROLLA_TSS2: + # 2019+ Rav4 TSS2 uses two different steering racks and specific tuning seems to be necessary. + # See https://github.com/commaai/openpilot/pull/21429#issuecomment-873652891 + for fw in car_fw: + if fw.ecu == "eps" and (fw.fwVersion.startswith(b'\x02') or fw.fwVersion in [b'8965B42181\x00\x00\x00\x00\x00\x00']): + set_lat_tune(ret.lateralTuning, LatTunes.PID_I) + break + + elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]: stop_and_go = True - ret.safetyParam = 73 - ret.wheelbase = 2.63906 + ret.wheelbase = 2.67 # Average between 2.70 for sedan and 2.64 for hatchback ret.steerRatio = 13.9 tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 3060. * 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_D) - 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]] - ret.lateralTuning.pid.kf = 0.00007818594 + set_lat_tune(ret.lateralTuning, LatTunes.PID_D) - ret.steerRateCost = 1. - ret.centerToFront = ret.wheelbase * 0.44 + elif candidate == CAR.LEXUS_ESH: + stop_and_go = True + ret.wheelbase = 2.8190 + ret.steerRatio = 16.06 + tire_stiffness_factor = 0.444 # not optimized yet + ret.mass = 3682. * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_D) - #detect the Pedal address - ret.enableGasInterceptor = 0x201 in fingerprint + elif candidate == CAR.SIENNA: + stop_and_go = True + ret.wheelbase = 3.03 + ret.steerRatio = 15.5 + tire_stiffness_factor = 0.444 + ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_J) + + elif candidate == CAR.LEXUS_IS: + ret.safetyConfigs[0].safetyParam = 77 + stop_and_go = False + ret.wheelbase = 2.79908 + ret.steerRatio = 13.3 + tire_stiffness_factor = 0.444 + ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_L) + + elif candidate == CAR.LEXUS_RC: + ret.safetyConfigs[0].safetyParam = 77 + stop_and_go = False + ret.wheelbase = 2.73050 + ret.steerRatio = 13.3 + tire_stiffness_factor = 0.444 + ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_L) + + elif candidate == CAR.LEXUS_CTH: + ret.safetyConfigs[0].safetyParam = 100 + stop_and_go = True + 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_M) - # 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 + elif candidate in [CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.LEXUS_NX_TSS2]: + stop_and_go = True + 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 + set_lat_tune(ret.lateralTuning, LatTunes.PID_C) + + elif candidate == CAR.PRIUS_TSS2: + stop_and_go = True + ret.wheelbase = 2.70002 # from toyota online sepc. + ret.steerRatio = 13.4 # True steerRatio from older prius + tire_stiffness_factor = 0.6371 # hand-tune + ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_N) + + elif candidate == CAR.MIRAI: + stop_and_go = True + ret.wheelbase = 2.91 + ret.steerRatio = 14.8 + tire_stiffness_factor = 0.8 + ret.mass = 4300. * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_C) + + elif candidate == CAR.ALPHARD_TSS2: + stop_and_go = True + ret.wheelbase = 3.00 + ret.steerRatio = 14.2 + tire_stiffness_factor = 0.444 + ret.mass = 4305. * CV.LB_TO_KG + STD_CARGO_KG + set_lat_tune(ret.lateralTuning, LatTunes.PID_J) + + ret.steerRateCost = 1. + ret.centerToFront = ret.wheelbase * 0.44 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase @@ -194,196 +249,74 @@ def get_params(candidate, fingerprint, vin=""): 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 = [5., 20.] - ret.brakeMaxV = [1., 0.8] - - ret.enableCamera = not check_ecu_msgs(fingerprint, ECU.CAM) - 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) - - ret.steerLimitAlert = False - - 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 + ret.enableBsm = 0x3F6 in fingerprint[0] and candidate in TSS2_CAR + # 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 + found_ecus = [fw.ecu for fw in car_fw] + ret.enableDsu = (len(found_ecus) > 0) and (Ecu.dsu not in found_ecus) and (candidate not in NO_DSU_CAR) and (not smartDsu) + 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 = smartDsu or ret.enableDsu or candidate in TSS2_CAR + + # 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 MIN_ACC_SPEED + + # 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 if ret.enableGasInterceptor: - ret.gasMaxBP = [0., 9., 35] - ret.gasMaxV = [0.2, 0.5, 0.7] - ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] - ret.longitudinalTuning.kiV = [0.18, 0.12] + set_long_tune(ret.longitudinalTuning, LongTunes.PEDAL) + elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.RAV4_TSS2, CAR.RAV4H_TSS2, CAR.LEXUS_NX_TSS2, + CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2, CAR.PRIUS_TSS2]: + set_long_tune(ret.longitudinalTuning, LongTunes.TSS2) + ret.stoppingDecelRate = 0.3 # reach stopping target smoothly + ret.startingAccelRate = 6.0 # release brakes fast else: - ret.gasMaxBP = [0.] - ret.gasMaxV = [0.5] - ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5] - ret.longitudinalTuning.kiV = [0.54, 0.36] + set_long_tune(ret.longitudinalTuning, LongTunes.TSS) return ret # returns a car.CarState - def update(self, c): + def update(self, c, can_strings): # ******************* do can recv ******************* - canMonoTimes = [] + self.cp.update_strings(can_strings) + self.cp_cam.update_strings(can_strings) - can_rcv_valid, _ = self.cp.update(int(sec_since_boot() * 1e9), True) + ret = self.CS.update(self.cp, self.cp_cam) - # 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(int(sec_since_boot() * 1e9), False) - - self.CS.update(self.cp) - - # create message - ret = car.CarState.new_message() - - ret.canValid = can_rcv_valid and 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 - - # 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 - 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_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])) - if c.actuators.gas > 0.1: + 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.accel > 0.3: # 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 - ret.canMonoTimes = canMonoTimes + 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, - c.hudControl.audibleAlert, self.forwarding_camera, - c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leadVisible, + can_sends = self.CC.update(c.enabled, c.active, self.CS, self.frame, + c.actuators, c.cruiseControl.cancel, + c.hudControl.visualAlert, c.hudControl.leftLaneVisible, + c.hudControl.rightLaneVisible, c.hudControl.leadVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart) self.frame += 1 diff --git a/selfdrive/car/toyota/radar_interface.py b/selfdrive/car/toyota/radar_interface.py index c160e751aa06bc..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)) @@ -46,43 +40,45 @@ def __init__(self, CP): self.valid_cnt = {key: 0 for key in self.RADAR_A_MSGS} self.rcp = _create_radar_can_parser(CP.carFingerprint) + self.trigger_msg = self.RADAR_B_MSGS[-1] + self.updated_messages = set() + # No radar dbc for cars without DSU which are not TSS 2.0 # TODO: make a adas dbc file for dsu-less models self.no_radar = CP.carFingerprint in NO_DSU_CAR and CP.carFingerprint not in TSS2_CAR - def update(self): + def update(self, can_strings): + if self.no_radar: + return super().update(None) - ret = car.RadarData.new_message() + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - if self.no_radar: - 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 self.RADAR_B_MSGS[-1] in updated_messages: - break + 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() errors = [] if not self.rcp.can_valid: errors.append("canError") ret.errors = errors - ret.canMonoTimes = canMonoTimes - 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'] @@ -103,12 +99,5 @@ def update(self): if ii in self.pts: del self.pts[ii] - ret.points = self.pts.values() + ret.points = list(self.pts.values()) return ret - -if __name__ == "__main__": - RI = RadarInterface(None) - while 1: - ret = RI.update() - print(chr(27) + "[2J") - print(ret) diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py index 7de38c891428f7..5a78e3c7b6d849 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,60 +10,76 @@ 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) -def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead): +def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead, acc_type): # TODO: find the exact canceling bit that does not create a chime values = { "ACCEL_CMD": accel, - "SET_ME_X01": 1, + "ACC_TYPE": acc_type, "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, + "ALLOW_LONG_PRESS": 1, } 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 = { + "PCS_INDICATOR": 1, "FCW": fcw, "SET_ME_X20": 0x20, "SET_ME_X10": 0x10, - "SET_ME_X80": 0x80, + "PCS_OFF": 1, + "PCS_SENSITIVITY": 0, } return packer.make_can_msg("ACC_HUD", 0, values) -def create_ui_command(packer, steer, sound1, sound2, 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, "SET_ME_X02": 0x02, "SET_ME_X01": 1, "SET_ME_X01_2": 1, - "REPEATED_BEEPS": sound1, - "TWO_BEEPS": sound2, + "REPEATED_BEEPS": 0, + "TWO_BEEPS": chime, "LDA_ALERT": steer, } return packer.make_can_msg("LKAS_HUD", 0, values) diff --git a/selfdrive/car/toyota/tunes.py b/selfdrive/car/toyota/tunes.py new file mode 100644 index 00000000000000..15c8bbfcc69dd3 --- /dev/null +++ b/selfdrive/car/toyota/tunes.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python3 +from enum import Enum + + +class LongTunes(Enum): + PEDAL = 0 + TSS2 = 1 + TSS = 2 + +class LatTunes(Enum): + INDI_PRIUS = 0 + LQR_RAV4 = 1 + PID_A = 2 + PID_B = 3 + PID_C = 4 + PID_D = 5 + PID_E = 6 + PID_F = 7 + PID_G = 8 + PID_I = 9 + PID_H = 10 + PID_J = 11 + PID_K = 12 + PID_L = 13 + PID_M = 14 + PID_N = 15 + + +###### LONG ###### +def set_long_tune(tune, name): + # Improved longitudinal tune + if name == LongTunes.TSS2 or name == LongTunes.PEDAL: + tune.deadzoneBP = [0., 8.05] + tune.deadzoneV = [.0, .14] + tune.kpBP = [0., 5., 20.] + tune.kpV = [1.3, 1.0, 0.7] + tune.kiBP = [0., 5., 12., 20., 27.] + tune.kiV = [.35, .23, .20, .17, .1] + # Default longitudinal tune + elif name == LongTunes.TSS: + tune.deadzoneBP = [0., 9.] + tune.deadzoneV = [0., .15] + tune.kpBP = [0., 5., 35.] + tune.kiBP = [0., 35.] + tune.kpV = [3.6, 2.4, 1.5] + tune.kiV = [0.54, 0.36] + else: + raise NotImplementedError('This longitudinal tune does not exist') + + +###### LAT ###### +def set_lat_tune(tune, name): + if name == LatTunes.INDI_PRIUS: + tune.init('indi') + tune.indi.innerLoopGainBP = [0.] + tune.indi.innerLoopGainV = [4.0] + tune.indi.outerLoopGainBP = [0.] + tune.indi.outerLoopGainV = [3.0] + tune.indi.timeConstantBP = [0.] + tune.indi.timeConstantV = [1.0] + tune.indi.actuatorEffectivenessBP = [0.] + tune.indi.actuatorEffectivenessV = [1.0] + + elif name == LatTunes.LQR_RAV4: + tune.init('lqr') + tune.lqr.scale = 1500.0 + tune.lqr.ki = 0.05 + tune.lqr.a = [0., 1., -0.22619643, 1.21822268] + tune.lqr.b = [-1.92006585e-04, 3.95603032e-05] + tune.lqr.c = [1., 0.] + tune.lqr.k = [-110.73572306, 451.22718255] + tune.lqr.l = [0.3233671, 0.3185757] + tune.lqr.dcGain = 0.002237852961363602 + + elif 'PID' in str(name): + tune.init('pid') + tune.pid.kiBP = [0.0] + tune.pid.kpBP = [0.0] + if name == LatTunes.PID_A: + tune.pid.kpV = [0.2] + tune.pid.kiV = [0.05] + tune.pid.kf = 0.00003 + elif name == LatTunes.PID_B: + tune.pid.kpV = [0.6] + tune.pid.kiV = [0.05] + tune.pid.kf = 0.00006 + elif name == LatTunes.PID_C: + tune.pid.kpV = [0.6] + tune.pid.kiV = [0.1] + tune.pid.kf = 0.00006 + elif name == LatTunes.PID_D: + tune.pid.kpV = [0.6] + tune.pid.kiV = [0.1] + tune.pid.kf = 0.00007818594 + elif name == LatTunes.PID_E: + tune.pid.kpV = [0.6] + tune.pid.kiV = [0.15] + tune.pid.kf = 0.00007818594 + elif name == LatTunes.PID_F: + tune.pid.kpV = [0.723] + tune.pid.kiV = [0.0428] + tune.pid.kf = 0.00006 + elif name == LatTunes.PID_G: + tune.pid.kpV = [0.18] + tune.pid.kiV = [0.015] + tune.pid.kf = 0.00012 + elif name == LatTunes.PID_H: + tune.pid.kpV = [0.17] + tune.pid.kiV = [0.03] + tune.pid.kf = 0.00006 + elif name == LatTunes.PID_I: + tune.pid.kpV = [0.15] + tune.pid.kiV = [0.05] + tune.pid.kf = 0.00004 + elif name == LatTunes.PID_J: + tune.pid.kpV = [0.19] + tune.pid.kiV = [0.02] + tune.pid.kf = 0.00007818594 + elif name == LatTunes.PID_L: + tune.pid.kpV = [0.3] + tune.pid.kiV = [0.05] + tune.pid.kf = 0.00006 + elif name == LatTunes.PID_M: + tune.pid.kpV = [0.3] + tune.pid.kiV = [0.05] + tune.pid.kf = 0.00007 + elif name == LatTunes.PID_N: + tune.pid.kpV = [0.35] + tune.pid.kiV = [0.15] + tune.pid.kf = 0.00007818594 + else: + raise NotImplementedError('This PID tune does not exist') + else: + raise NotImplementedError('This lateral tune does not exist') diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index da8b02dcd7212c..692de379b5d82d 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -1,183 +1,1594 @@ +# flake8: noqa + +from cereal import car from selfdrive.car import dbc_dict +from selfdrive.config import Conversions as CV + +Ecu = car.CarParams.Ecu +MIN_ACC_SPEED = 19. * CV.MPH_TO_MS +PEDAL_TRANSITION = 10. * CV.MPH_TO_MS + + +class CarControllerParams: + ACCEL_MAX = 1.5 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons + ACCEL_MIN = -3.5 # m/s2 + + 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" - RAV4H = "TOYOTA RAV4 HYBRID 2017" - RAV4 = "TOYOTA RAV4 2017" - COROLLA = "TOYOTA COROLLA 2017" - LEXUS_RXH = "LEXUS RX HYBRID 2017" - CHR = "TOYOTA C-HR 2018" - CHRH = "TOYOTA C-HR HYBRID 2018" + # Toyota + ALPHARD_TSS2 = "TOYOTA ALPHARD 2020" + AVALON = "TOYOTA AVALON 2016" + AVALON_2019 = "TOYOTA AVALON 2019" + AVALONH_2019 = "TOYOTA AVALON HYBRID 2019" CAMRY = "TOYOTA CAMRY 2018" CAMRYH = "TOYOTA CAMRY HYBRID 2018" + CAMRY_TSS2 = "TOYOTA CAMRY 2021" # TSS 2.5 + CAMRYH_TSS2 = "TOYOTA CAMRY HYBRID 2021" + CHR = "TOYOTA C-HR 2018" + CHRH = "TOYOTA C-HR HYBRID 2018" + COROLLA = "TOYOTA COROLLA 2017" + COROLLA_TSS2 = "TOYOTA COROLLA TSS2 2019" + # LSS2 Lexus UX Hybrid is same as a TSS2 Corolla Hybrid + COROLLAH_TSS2 = "TOYOTA COROLLA HYBRID TSS2 2019" HIGHLANDER = "TOYOTA HIGHLANDER 2017" + HIGHLANDER_TSS2 = "TOYOTA HIGHLANDER 2020" HIGHLANDERH = "TOYOTA HIGHLANDER HYBRID 2018" - AVALON = "TOYOTA AVALON 2016" + HIGHLANDERH_TSS2 = "TOYOTA HIGHLANDER HYBRID 2020" + PRIUS = "TOYOTA PRIUS 2017" + PRIUS_TSS2 = "TOYOTA PRIUS TSS2 2021" + RAV4 = "TOYOTA RAV4 2017" + RAV4H = "TOYOTA RAV4 HYBRID 2017" RAV4_TSS2 = "TOYOTA RAV4 2019" - COROLLA_TSS2 = "TOYOTA COROLLA TSS2 2019" - LEXUS_ESH_TSS2 = "LEXUS ES 300H 2019" - - -class ECU: - CAM = 0 # camera - DSU = 1 # driving support unit - APGS = 2 # advanced parking guidance system - - -# 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), 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), 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), 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), 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), 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), 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), 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), 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), 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), 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'), -] + RAV4H_TSS2 = "TOYOTA RAV4 HYBRID 2019" + MIRAI = "TOYOTA MIRAI 2021" # TSS 2.5 + SIENNA = "TOYOTA SIENNA 2018" -ECU_FINGERPRINT = { - ECU.CAM: 0x2e4, # steer torque cmd - ECU.DSU: 0x343, # accel cmd - ECU.APGS: 0x835, # angle cmd -} + # Lexus + LEXUS_CTH = "LEXUS CT HYBRID 2018" + LEXUS_ESH = "LEXUS ES HYBRID 2018" + LEXUS_ES_TSS2 = "LEXUS ES 2019" + LEXUS_ESH_TSS2 = "LEXUS ES HYBRID 2019" + LEXUS_IS = "LEXUS IS 2018" + LEXUS_NX = "LEXUS NX 2018" + LEXUS_NXH = "LEXUS NX HYBRID 2018" + LEXUS_NX_TSS2 = "LEXUS NX 2020" + LEXUS_RC = "LEXUS RC 2020" + LEXUS_RX = "LEXUS RX 2016" + LEXUS_RXH = "LEXUS RX HYBRID 2017" + LEXUS_RX_TSS2 = "LEXUS RX 2020" + LEXUS_RXH_TSS2 = "LEXUS RX HYBRID 2020" +# (addr, cars, bus, 1/freq*100, vl) +STATIC_DSU_MSGS = [ + (0x128, (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, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH), 1, 3, b'\x03\x00\x20\x00\x00\x52'), + (0x141, (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_ESH, CAR.LEXUS_RX), 1, 2, b'\x00\x00\x00\x46'), + (0x160, (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_ESH, CAR.LEXUS_RX), 1, 7, b'\x00\x00\x08\x12\x01\x31\x9c\x51'), + (0x161, (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, (CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH), 1, 7, b'\x00\x1e\x00\xd4\x00\x00\x5b'), + (0x283, (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_ESH, CAR.LEXUS_RX), 0, 3, b'\x00\x00\x00\x00\x00\x00\x8c'), + (0x2E6, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, b'\xff\xf8\x00\x08\x7f\xe0\x00\x4e'), + (0x2E7, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, b'\xa8\x9c\x31\x9c\x00\x00\x00\x02'), + (0x33E, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 20, b'\x0f\xff\x26\x40\x00\x1f\x00'), + (0x344, (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_ESH, CAR.LEXUS_RX), 0, 5, b'\x00\x00\x01\x00\x00\x00\x00\x50'), + (0x365, (CAR.PRIUS, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.HIGHLANDERH), 0, 20, b'\x00\x00\x00\x80\x03\x00\x08'), + (0x365, (CAR.RAV4, CAR.RAV4H, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 0, 20, b'\x00\x00\x00\x80\xfc\x00\x08'), + (0x366, (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, (CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 0, 20, b'\x00\x72\x07\xff\x09\xfe\x00'), + (0x470, (CAR.PRIUS, CAR.LEXUS_RXH), 1, 100, b'\x00\x00\x02\x7a'), + (0x470, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.RAV4H, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH), 1, 100, b'\x00\x00\x01\x79'), + (0x4CB, (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_ESH, CAR.LEXUS_RX), 0, 100, b'\x0c\x00\x00\x00\x00\x00\x00\x00'), +] -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 - }], - 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 - }, - # 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 - }], - 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 - }, - #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 - }], - #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 - }], - 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 - }, - # RX450HL - { - 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 - }, - # 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 - }], - 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 - }], - 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 - }], - 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 - }, - #XSE and SE - { - 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 - }], - 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 - }, - #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 - }, - #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 - }], - 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 - }, - # 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 - }, - # 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 - }], - 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 - }], - 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 - }], - 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 - }, - # 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 - }], - 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 - }], - 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 - }], + +FW_VERSIONS = { + CAR.AVALON: { + (Ecu.esp, 0x7b0, None): [ + b'F152607060\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881510701300\x00\x00\x00\x00', + b'881510705100\x00\x00\x00\x00', + b'881510705200\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.AVALON_2019: { + (Ecu.esp, 0x7b0, None): [ + b'F152607140\x00\x00\x00\x00\x00\x00', + b'F152607171\x00\x00\x00\x00\x00\x00', + b'F152607110\x00\x00\x00\x00\x00\x00', + b'F152607180\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881510703200\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B41080\x00\x00\x00\x00\x00\x00', + b'8965B07010\x00\x00\x00\x00\x00\x00', + b'8965B41090\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x01896630725200\x00\x00\x00\x00', + b'\x01896630725300\x00\x00\x00\x00', + b'\x01896630735100\x00\x00\x00\x00', + b'\x01896630738000\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0702100\x00\x00\x00\x00', + ], + }, + CAR.AVALONH_2019: { + (Ecu.esp, 0x7b0, None): [ + b'F152641040\x00\x00\x00\x00\x00\x00', + b'F152641061\x00\x00\x00\x00\x00\x00', + b'F152641050\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881510704200\x00\x00\x00\x00', + b'881514107100\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B07010\x00\x00\x00\x00\x00\x00', + b'8965B41090\x00\x00\x00\x00\x00\x00', + b'8965B41070\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x02896630724000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x02896630737000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x02896630728000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0702100\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'\x018966306P8000\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'\x018966333Q9200\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'\x018966333P4900\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.engine, 0x7e0, None): [ + b'\x02333P1100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821F0601200 ', + b'8821F0601300 ', + b'8821F0602000 ', + b'8821F0603300 ', + b'8821F0604100 ', + b'8821F0605200 ', + 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'F152606270\x00\x00\x00\x00\x00\x00', + b'F152606290\x00\x00\x00\x00\x00\x00', + b'F152606410\x00\x00\x00\x00\x00\x00', + b'F152633540\x00\x00\x00\x00\x00\x00', + b'F152633A10\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'8821F0602000 ', + b'8821F0603300 ', + b'8821F0604100 ', + b'8821F0605200 ', + b'8821F0607200 ', + b'8821F0608000 ', + b'8821F0608200 ', + b'8821F0609100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0601200 ', + b'8646F0601300 ', + b'8646F0601400 ', + b'8646F0603400 ', + b'8646F0604100 ', + b'8646F0605000 ', + b'8646F0606000 ', + b'8646F0606100 ', + b'8646F0607100 ', + ], + }, + CAR.CAMRYH: { + (Ecu.engine, 0x700, None): [ + b'\x018966306Q6000\x00\x00\x00\x00', + b'\x018966333N1100\x00\x00\x00\x00', + b'\x018966333N4300\x00\x00\x00\x00', + b'\x018966333X0000\x00\x00\x00\x00', + b'\x018966333X4000\x00\x00\x00\x00', + b'\x01896633T16000\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'\x028966306B2500\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'8821F0604000 ', + b'8821F0604100 ', + b'8821F0604200 ', + b'8821F0605200 ', + b'8821F0606200 ', + b'8821F0607200 ', + b'8821F0608000 ', + b'8821F0608200 ', + 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'8821F0604000 ', + b'8821F0604100 ', + b'8821F0604200 ', + b'8821F0605200 ', + b'8821F0606200 ', + b'8821F0607200 ', + b'8821F0608000 ', + b'8821F0608200 ', + b'8821F0609000 ', + b'8821F0609100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F0601200 ', + b'8646F0601300 ', + b'8646F0601400 ', + b'8646F0603400 ', + 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'\x01F152606370\x00\x00\x00\x00\x00\x00', + b'\x01F152606390\x00\x00\x00\x00\x00\x00', + b'\x01F152606400\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x018966306Q5000\x00\x00\x00\x00', + b'\x018966306T3100\x00\x00\x00\x00', + b'\x018966306T3200\x00\x00\x00\x00', + b'\x018966306T4100\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F6201200\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F0602200\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', + b'\x028646F3305200\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', + b'\x028646F3305300\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', + ], + }, + CAR.CAMRYH_TSS2: { + (Ecu.eps, 0x7a1, None): [ + b'8965B33630\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152633D00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x018966306Q6000\x00\x00\x00\x00', + b'\x018966306Q7000\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', + b'\x028646F3305300\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'8821F0W01100 ', + b'8821FF401600 ', + b'8821FF404000 ', + b'8821FF404100 ', + b'8821FF405100 ', + b'8821FF406000 ', + b'8821FF407100 ', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152610020\x00\x00\x00\x00\x00\x00', + b'F152610153\x00\x00\x00\x00\x00\x00', + b'F152610210\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', + b'8965B10070\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x0331024000\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', + b'\x0331036000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', + b'\x033F401100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203102\x00\x00\x00\x00', + b'\x033F401200\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\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', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F0W01000 ', + b'8821FF401600 ', + b'8821FF404000 ', + b'8821FF404100 ', + b'8821FF405100 ', + b'8821FF406000 ', + b'8821FF407100 ', + b'8821F0W01100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646FF401700 ', + b'8646FF401800 ', + b'8646FF404000 ', + b'8646FF406000 ', + b'8646FF407000 ', + ], + }, + CAR.CHRH: { + (Ecu.engine, 0x700, None): [ + b'\x0289663F405100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896631013200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x0289663F405000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x0289663F418000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + 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'F152610012\x00\x00\x00\x00\x00\x00', + b'F152610013\x00\x00\x00\x00\x00\x00', + b'F152610014\x00\x00\x00\x00\x00\x00', + b'F152610040\x00\x00\x00\x00\x00\x00', + b'F152610190\x00\x00\x00\x00\x00\x00', + b'F152610200\x00\x00\x00\x00\x00\x00', + b'F152610230\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'8821F0W01000 ', + b'8821FF402300 ', + b'8821FF402400 ', + b'8821FF404000 ', + b'8821FF404100 ', + b'8821FF405000 ', + b'8821FF406000 ', + b'8821FF407100 ', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B10011\x00\x00\x00\x00\x00\x00', + b'8965B10020\x00\x00\x00\x00\x00\x00', + b'8965B10040\x00\x00\x00\x00\x00\x00', + b'8965B10050\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F0W01000 ', + b'8821FF402300 ', + b'8821FF402400 ', + b'8821FF404000 ', + b'8821FF404100 ', + b'8821FF405000 ', + b'8821FF406000 ', + b'8821FF407100 ', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646FF401700 ', + b'8646FF402100 ', + b'8646FF404000 ', + b'8646FF406000 ', + b'8646FF407000 ', + ], + }, + CAR.COROLLA: { + (Ecu.engine, 0x7e0, None): [ + 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'\x0230ZC3100\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', + ], + }, + CAR.COROLLA_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896630ZG2000\x00\x00\x00\x00', + 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'\x01896630ZP2000\x00\x00\x00\x00', + b'\x01896630ZQ5000\x00\x00\x00\x00', + b'\x018966312L8000\x00\x00\x00\x00', + b'\x018966312M0000\x00\x00\x00\x00', + b'\x018966312M9000\x00\x00\x00\x00', + b'\x018966312P9000\x00\x00\x00\x00', + b'\x018966312P9100\x00\x00\x00\x00', + b'\x018966312P9200\x00\x00\x00\x00', + b'\x018966312P9300\x00\x00\x00\x00', + b'\x018966312Q2300\x00\x00\x00\x00', + b'\x018966312R0000\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', + b'\x018966312S5000\x00\x00\x00\x00', + b'\x018966312S7000\x00\x00\x00\x00', + b'\x018966312W3000\x00\x00\x00\x00', + b'\x018966312W9000\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x0230A10000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230A11000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0230ZN4000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x03312K7000\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', + 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'\x03312N6000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203402\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', + ], + (Ecu.eps, 0x7a1, None): [ + b'\x018965B12350\x00\x00\x00\x00\x00\x00', + b'\x018965B12470\x00\x00\x00\x00\x00\x00', + b'\x018965B12490\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', + b'\x018965B1255000\x00\x00\x00\x00', + b'8965B12361\x00\x00\x00\x00\x00\x00', + b'8965B16011\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F152602280\x00\x00\x00\x00\x00\x00', + b'\x01F152602560\x00\x00\x00\x00\x00\x00', + b'\x01F152602590\x00\x00\x00\x00\x00\x00', + b'\x01F152602650\x00\x00\x00\x00\x00\x00', + b"\x01F15260A010\x00\x00\x00\x00\x00\x00", + b'\x01F15260A050\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'\x01F152612B51\x00\x00\x00\x00\x00\x00', + b'\x01F152612B60\x00\x00\x00\x00\x00\x00', + b'\x01F152612B61\x00\x00\x00\x00\x00\x00', + b'\x01F152612B71\x00\x00\x00\x00\x00\x00', + b'\x01F152612B90\x00\x00\x00\x00\x00\x00', + b'\x01F152612C00\x00\x00\x00\x00\x00\x00', + b'F152602191\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'\x028646F1201400\x00\x00\x00\x008646G2601500\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'\x028646F1202200\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', + b'\x028646F1601100\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + ], + }, + CAR.COROLLAH_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896630ZJ1000\x00\x00\x00\x00', + b'\x01896630ZU8000\x00\x00\x00\x00', + b'\x01896637621000\x00\x00\x00\x00', + b'\x01896637624000\x00\x00\x00\x00', + b'\x01896637626000\x00\x00\x00\x00', + b'\x01896637648000\x00\x00\x00\x00', + b'\x02896630ZJ5000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896630ZN8000\x00\x00\x00\x008966A4703000\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'\x02896630ZT8000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896630ZT9000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x028966312K6000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x028966312L0000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x028966312Q3000\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', + b'\x038966312T3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF1205001\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'8965B76012\x00\x00\x00\x00\x00\x00', + b'8965B76050\x00\x00\x00\x00\x00\x00', + b'\x018965B12350\x00\x00\x00\x00\x00\x00', + b'\x018965B12470\x00\x00\x00\x00\x00\x00', + b'\x018965B12490\x00\x00\x00\x00\x00\x00', + b'\x018965B12500\x00\x00\x00\x00\x00\x00', + b'\x018965B12510\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'F152612710\x00\x00\x00\x00\x00\x00', + b'F152612790\x00\x00\x00\x00\x00\x00', + b'F152612800\x00\x00\x00\x00\x00\x00', + b'F152612820\x00\x00\x00\x00\x00\x00', + b'F152612840\x00\x00\x00\x00\x00\x00', + b'F152612890\x00\x00\x00\x00\x00\x00', + b'F152612A00\x00\x00\x00\x00\x00\x00', + b'F152612A10\x00\x00\x00\x00\x00\x00', + b'F152642540\x00\x00\x00\x00\x00\x00', + b'F152676293\x00\x00\x00\x00\x00\x00', + b'F152676303\x00\x00\x00\x00\x00\x00', + b'F152676304\x00\x00\x00\x00\x00\x00', + b'F152612D00\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'\x028646F1201300\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F1201400\x00\x00\x00\x008646G2601500\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'\x028646F1202200\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', + b"\x028646F1601300\x00\x00\x00\x008646G2601400\x00\x00\x00\x00", + b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F76020C0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F7603100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F7603200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + ], + }, + CAR.HIGHLANDER: { + (Ecu.engine, 0x700, None): [ + b'\x01896630E09000\x00\x00\x00\x00', + b'\x01896630E43000\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'\x01896630E46000\x00\x00\x00\x00', + b'\x01896630E46200\x00\x00\x00\x00', + b'\x01896630E74000\x00\x00\x00\x00', + b'\x01896630E75000\x00\x00\x00\x00', + b'\x01896630E76000\x00\x00\x00\x00', + b'\x01896630E77000\x00\x00\x00\x00', + b'\x01896630E83000\x00\x00\x00\x00', + b'\x01896630E84000\x00\x00\x00\x00', + b'\x01896630E85000\x00\x00\x00\x00', + b'\x01896630E86000\x00\x00\x00\x00', + b'\x01896630E88000\x00\x00\x00\x00', + b'\x01896630EA0000\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'\x0230E40100\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', + b'8965B48320\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F15260E051\x00\x00\x00\x00\x00\x00', + b'\x01F15260E061\x00\x00\x00\x00\x00\x00', + b'\x01F15260E110\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x01896630E62100\x00\x00\x00\x00', + b'\x01896630E62200\x00\x00\x00\x00', + b'\x01896630E64100\x00\x00\x00\x00', + b'\x01896630E64200\x00\x00\x00\x00', + b'\x01896630EB1000\x00\x00\x00\x00', + b'\x01896630EB1100\x00\x00\x00\x00', + b'\x01896630EB1200\x00\x00\x00\x00', + b'\x01896630EB2000\x00\x00\x00\x00', + b'\x01896630EB2100\x00\x00\x00\x00', + b'\x01896630EB2200\x00\x00\x00\x00', + b'\x01896630EC4000\x00\x00\x00\x00', + b'\x01896630EE1000\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', + b'\x01F15264872500\x00\x00\x00\x00', + b'\x01F152648C6300\x00\x00\x00\x00', + ], + (Ecu.engine, 0x700, None): [ + b'\x01896630EA1000\x00\x00\x00\x00', + b'\x01896630EE4000\x00\x00\x00\x00', + b'\x01896630EA1000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896630E66000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896630EB3000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896630EB3100\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'\x018966353M7000\x00\x00\x00\x00', + b'\x018966353M7100\x00\x00\x00\x00', + b'\x018966353Q2000\x00\x00\x00\x00', + b'\x018966353Q2300\x00\x00\x00\x00', + b'\x018966353Q4000\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'\x0232480000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02353P7000\x00\x00\x00\x00\x00\x00\x00\x00530J5000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02353P9000\x00\x00\x00\x00\x00\x00\x00\x00553C1000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152653300\x00\x00\x00\x00\x00\x00', + b'F152653301\x00\x00\x00\x00\x00\x00', + b'F152653310\x00\x00\x00\x00\x00\x00', + b'F152653330\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881515306200\x00\x00\x00\x00', + b'881515306400\x00\x00\x00\x00', + b'881515306500\x00\x00\x00\x00', + b'881515307400\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B53270\x00\x00\x00\x00\x00\x00', + b'8965B53271\x00\x00\x00\x00\x00\x00', + b'8965B53280\x00\x00\x00\x00\x00\x00', + b'8965B53281\x00\x00\x00\x00\x00\x00', + b'8965B53311\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'8646F5301101\x00\x00\x00\x00', + b'8646F5301200\x00\x00\x00\x00', + b'8646F5301300\x00\x00\x00\x00', + b'8646F5301400\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'\x02896634762000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634763000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634763100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634765000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634765100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634769000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634769100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634769200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x02896634770000\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'\x028966347A0000\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'\x028966347B0000\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'\x03896634760000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\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'\x03896634785000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\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\x00897CF4701003\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'F152647682\x00\x00\x00\x00\x00\x00', + b'F152647683\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'881514702400\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'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'8965B42063\x00\x00\x00\x00\x00\x00', + b'8965B42073\x00\x00\x00\x00\x00\x00', + b'8965B42082\x00\x00\x00\x00\x00\x00', + b'8965B42083\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'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.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', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B42102\x00\x00\x00\x00\x00\x00', + b'8965B42103\x00\x00\x00\x00\x00\x00', + b'8965B42112\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'F152642110\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'\x01896630R58100\x00\x00\x00\x00', + b'\x018966342E2000\x00\x00\x00\x00', + b'\x018966342M8000\x00\x00\x00\x00', + b'\x018966342S9000\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'\x018966342U5100\x00\x00\x00\x00', + b'\x018966342V0000\x00\x00\x00\x00', + b'\x018966342V3000\x00\x00\x00\x00', + b'\x018966342V3100\x00\x00\x00\x00', + b'\x018966342V3200\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'\x01896634A20100\x00\x00\x00\x00', + b'\x01896634A22000\x00\x00\x00\x00', + b'\x01896634A22100\x00\x00\x00\x00', + b'\x01896634A30000\x00\x00\x00\x00', + b'\x01896634A44000\x00\x00\x00\x00', + b'\x01896634A45000\x00\x00\x00\x00', + b'\x01896634A46000\x00\x00\x00\x00', + b'\x028966342M7000\x00\x00\x00\x00897CF1201001\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'\x02896634A18100\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', + b'\x02896634A43000\x00\x00\x00\x00897CF4201001\x00\x00\x00\x00', + b'\x02896634A47000\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'\x01F15260R290\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'\x01F152642701\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', + b'\x01F152642751\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', + b'\x028965B0R01400\x00\x00\x00\x008965B0R02400\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'\x018966342X5000\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'\x02896634A13000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02896634A13001\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896634A13101\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896634A14001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + b'\x02896634A23000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x02896634A23001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', + b'\x02896634A14001\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + b'\x02896634A14101\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152642291\x00\x00\x00\x00\x00\x00', + b'F152642290\x00\x00\x00\x00\x00\x00', + b'F152642322\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', + b'\x028965B0R01400\x00\x00\x00\x008965B0R02400\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.SIENNA: { + (Ecu.engine, 0x700, None): [ + b'\x01896630832100\x00\x00\x00\x00', + b'\x01896630832200\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'\x01896630851200\x00\x00\x00\x00', + b'\x01896630852000\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'8965B45080\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_CTH: { + (Ecu.dsu, 0x791, None): [ + b'881517601100\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152676144\x00\x00\x00\x00\x00\x00', + ], + (Ecu.engine, 0x7e0, None): [ + b'\x0237635000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F7601100\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_ES_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896630EC9100\x00\x00\x00\x00', + b'\x018966333T5000\x00\x00\x00\x00', + b'\x018966333T5100\x00\x00\x00\x00', + b'\x018966333X6000\x00\x00\x00\x00', + b'\x01896633T07000\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F152606281\x00\x00\x00\x00\x00\x00', + b'\x01F152606340\x00\x00\x00\x00\x00\x00', + b'\x01F152606461\x00\x00\x00\x00\x00\x00', + b'\x01F15260E031\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', + b'8965B33690\x00\x00\x00\x00\x00\x00', + b'8965B48271\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F3301100\x00\x00\x00\x00', + b'\x018821F3301200\x00\x00\x00\x00', + b'\x018821F3301400\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F33030D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F3303200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F3304100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F3304300\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', + b'\x028646F4810200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_ESH_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x028966333S8000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', + b'\x028966333S8000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x028966333T0100\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x028966333V4000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', + b'\x02896633T09000\x00\x00\x00\x00897CF3307001\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152633423\x00\x00\x00\x00\x00\x00', + b'F152633680\x00\x00\x00\x00\x00\x00', + b'F152633681\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', + b'8965B33690\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'\x028646F33030D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F3303100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F3303200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', + b'\x028646F3304100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F3304200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F3304300\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_ESH: { + (Ecu.engine, 0x7e0, None): [ + b'\x02333M4200\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152633171\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881513310400\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B33512\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4701100\x00\x00\x00\x00', + b'8821F4701300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F3302001\x00\x00\x00\x00', + b'8646F3302200\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_NX: { + (Ecu.engine, 0x700, None): [ + b'\x01896637850000\x00\x00\x00\x00', + b'\x01896637851000\x00\x00\x00\x00', + b'\x01896637852000\x00\x00\x00\x00', + b'\x01896637854000\x00\x00\x00\x00', + b'\x01896637878000\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152678130\x00\x00\x00\x00\x00\x00', + b'F152678140\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881517803100\x00\x00\x00\x00', + b'881517803300\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B78060\x00\x00\x00\x00\x00\x00', + b'8965B78080\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'8646F7801100\x00\x00\x00\x00', + b'8646F7801300\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_NX_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x018966378B2100\x00\x00\x00\x00', + b'\x018966378G3000\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'\x01F152678221\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B78120\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b"\x018821F3301400\x00\x00\x00\x00", + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F78030A0\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + b'\x028646F7803100\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_NXH: { + (Ecu.engine, 0x7e0, None): [ + b'\x0237841000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0237842000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0237880000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0237882000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0237886000\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', + b'F152678171\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'8965B78060\x00\x00\x00\x00\x00\x00', + b'8965B78080\x00\x00\x00\x00\x00\x00', + b'8965B78100\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_RC: { + (Ecu.engine, 0x7e0, None): [ + b'\x0232484000\x00\x00\x00\x00\x00\x00\x00\x0052422000\x00\x00\x00\x00\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152624221\x00\x00\x00\x00\x00\x00', + ], + (Ecu.dsu, 0x791, None): [ + b'881512409100\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B24081\x00\x00\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'8821F4702300\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'8646F2402200\x00\x00\x00\x00', + ], + }, + CAR.LEXUS_RX: { + (Ecu.engine, 0x700, None): [ + b'\x01896630E36200\x00\x00\x00\x00', + b'\x01896630E36300\x00\x00\x00\x00', + b'\x01896630E37200\x00\x00\x00\x00', + b'\x01896630E37300\x00\x00\x00\x00', + b'\x01896630E41000\x00\x00\x00\x00', + b'\x01896630E41100\x00\x00\x00\x00', + b'\x01896630E41200\x00\x00\x00\x00', + b'\x01896630E41500\x00\x00\x00\x00', + b'\x01896630EA3100\x00\x00\x00\x00', + b'\x01896630EA3400\x00\x00\x00\x00', + b'\x01896630EA4100\x00\x00\x00\x00', + b'\x01896630EA4300\x00\x00\x00\x00', + b'\x01896630EA4400\x00\x00\x00\x00', + b'\x01896630EA6300\x00\x00\x00\x00', + b'\x018966348R1300\x00\x00\x00\x00', + b'\x018966348R8500\x00\x00\x00\x00', + b'\x018966348W1300\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', + b'F152648494\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'8965B48111\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'\x02348J7000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + 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'\x02348Q4100\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'\x02348T3000\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'F152648740\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'8965B48111\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'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_RX_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x01896630EC9000\x00\x00\x00\x00', + b'\x01896634D12000\x00\x00\x00\x00', + b'\x01896630EB0000\x00\x00\x00\x00', + b'\x01896630EA9000\x00\x00\x00\x00', + b'\x01896630ED0000\x00\x00\x00\x00', + b'\x018966348W5100\x00\x00\x00\x00', + b'\x018966348W9000\x00\x00\x00\x00', + b'\x01896634D12100\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', + b'\x01F152648781\x00\x00\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'8965B48261\x00\x00\x00\x00\x00\x00', + 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', + b'\x0234D14000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', + b'\x0234D16000\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', + b'F152648D00\x00\x00\x00\x00\x00\x00', + b'F152648D60\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'\x028646F4810200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', + b'\x028646F4810100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', + ], + }, + CAR.PRIUS_TSS2: { + (Ecu.engine, 0x700, None): [ + b'\x028966347C6000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x028966347C8000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', + b'\x038966347C0000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710101\x00\x00\x00\x00', + b'\x038966347C1000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710101\x00\x00\x00\x00', + b'\x038966347C5000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4707101\x00\x00\x00\x00', + b'\x038966347C5100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4707101\x00\x00\x00\x00', + ], + (Ecu.esp, 0x7b0, None): [ + b'F152647500\x00\x00\x00\x00\x00\x00', + b'F152647510\x00\x00\x00\x00\x00\x00', + b'F152647520\x00\x00\x00\x00\x00\x00', + b'F152647521\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', + b'\x028646F4710000\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', + ], + }, + CAR.MIRAI: { + (Ecu.esp, 0x7D1, None): [b'\x01898A36203000\x00\x00\x00\x00',], + (Ecu.esp, 0x7B0, None): [b'\x01F15266203200\x00\x00\x00\x00',], # a second ESP ECU + (Ecu.eps, 0x7A1, None): [b'\x028965B6204100\x00\x00\x00\x008965B6203100\x00\x00\x00\x00',], + (Ecu.fwdRadar, 0x750, 0xf): [b'\x018821F6201200\x00\x00\x00\x00',], + (Ecu.fwdCamera, 0x750, 0x6d): [b'\x028646F6201400\x00\x00\x00\x008646G5301200\x00\x00\x00\x00',], + }, + CAR.ALPHARD_TSS2: { + (Ecu.engine, 0x7e0, None): [b'\x0235883000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00',], + (Ecu.eps, 0x7a1, None): [b'8965B58040\x00\x00\x00\x00\x00\x00',], + (Ecu.fwdRadar, 0x750, 0xf): [b'\x018821F3301400\x00\x00\x00\x00',], + (Ecu.fwdCamera, 0x750, 0x6d): [b'\x028646F5803200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00',], + }, } STEER_THRESHOLD = 100 @@ -187,19 +1598,49 @@ 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_RC: dbc_dict('lexus_is_2018_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.CAMRYH_TSS2: dbc_dict('toyota_nodsu_hybrid_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.AVALON_2019: dbc_dict('toyota_nodsu_pt_generated', 'toyota_adas'), + CAR.AVALONH_2019: dbc_dict('toyota_nodsu_hybrid_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.LEXUS_ESH: dbc_dict('lexus_ct200h_2018_pt_generated', 'toyota_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.LEXUS_NX_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), + CAR.PRIUS_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), + CAR.MIRAI: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), + CAR.ALPHARD_TSS2: dbc_dict('toyota_nodsu_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] # 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, CAR.CAMRYH_TSS2, + CAR.MIRAI, CAR.LEXUS_NX_TSS2, CAR.ALPHARD_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, CAR.LEXUS_ESH]) 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/tests/__init__.py b/selfdrive/car/volkswagen/__init__.py similarity index 100% rename from selfdrive/can/tests/__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..977818dbd5dc9e --- /dev/null +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -0,0 +1,113 @@ +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_FILES, CANBUS, MQB_LDW_MESSAGES, BUTTON_STATES, CarControllerParams as P +from opendbc.can.packer import CANPacker + +VisualAlert = car.CarControl.HUDControl.VisualAlert + +class CarController(): + def __init__(self, dbc_name, CP, VM): + self.apply_steer_last = 0 + + self.packer_pt = CANPacker(DBC_FILES.mqb) + + 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, ext_bus, actuators, visual_alert, left_lane_visible, right_lane_visible, left_lane_depart, right_lane_depart): + """ Controls thread """ + + can_sends = [] + + # **** Steering Controls ************************************************ # + + if frame % P.HCA_STEP == 0: + # Logic to avoid HCA state 4 "refused": + # * Don't steer unless HCA is in state 3 "ready" or 5 "active" + # * Don't steer at standstill + # * Don't send > 3.00 Newton-meters torque + # * Don't send the same torque for > 6 seconds + # * Don't send uninterrupted steering for > 360 seconds + # One frame of HCA disabled is enough to reset the timer, without zeroing the + # torque value. Do that anytime we happen to have 0 torque, or failing that, + # when exceeding ~1/3 the 360 second timer. + + if enabled and CS.out.vEgo > CS.CP.minSteerSpeed and not (CS.out.standstill or CS.out.steerError or CS.out.steerWarning): + 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 + if apply_steer == 0: + hcaEnabled = False + self.hcaEnabledFrameCount = 0 + else: + self.hcaEnabledFrameCount += 1 + if self.hcaEnabledFrameCount >= 118 * (100 / P.HCA_STEP): # 118s + hcaEnabled = False + self.hcaEnabledFrameCount = 0 + else: + hcaEnabled = True + 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: + 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)) + + # **** HUD Controls ***************************************************** # + + if frame % P.LDW_STEP == 0: + if visual_alert in [VisualAlert.steerRequired, VisualAlert.ldw]: + 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, enabled, + CS.out.steeringPressed, hud_alert, left_lane_visible, + right_lane_visible, CS.ldw_stock_values, + left_lane_depart, right_lane_depart)) + + # **** ACC Button Controls ********************************************** # + + # FIXME: this entire section is in desperate need of refactoring + + if CS.CP.pcmCruise: + 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.esp_hold_confirmation: + # Blip the Resume button if we're engaged at standstill. + # FIXME: This is a naive implementation, improve with visiond or radar input. + self.graButtonStatesToSend = BUTTON_STATES.copy() + self.graButtonStatesToSend["resumeCruise"] = True + + 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, ext_bus, 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..97e3094fa509e2 --- /dev/null +++ b/selfdrive/car/volkswagen/carstate.py @@ -0,0 +1,284 @@ +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_FILES, CANBUS, NetworkLocation, TransmissionType, GearShifter, BUTTON_STATES, CarControllerParams + +class CarState(CarStateBase): + def __init__(self, CP): + super().__init__(CP) + can_define = CANDefine(DBC_FILES.mqb) + if CP.transmissionType == TransmissionType.automatic: + self.shifter_values = can_define.dv["Getriebe_11"]["GE_Fahrstufe"] + elif CP.transmissionType == TransmissionType.direct: + self.shifter_values = can_define.dv["EV_Gearshift"]["GearPosition"] + self.hca_status_values = can_define.dv["LH_EPS_03"]["EPS_HCA_Status"] + self.buttonStates = BUTTON_STATES.copy() + + def update(self, pt_cp, cam_cp, ext_cp, trans_type): + ret = car.CarState.new_message() + # Update vehicle speed and acceleration from ABS wheel speeds. + ret.wheelSpeeds = self.get_wheel_speeds( + pt_cp.vl["ESP_19"]["ESP_VL_Radgeschw_02"], + pt_cp.vl["ESP_19"]["ESP_VR_Radgeschw_02"], + pt_cp.vl["ESP_19"]["ESP_HL_Radgeschw_02"], + pt_cp.vl["ESP_19"]["ESP_HR_Radgeschw_02"], + ) + + 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.vEgo < 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.steeringAngleDeg = pt_cp.vl["LH_EPS_03"]["EPS_Berechneter_LW"] * (1, -1)[int(pt_cp.vl["LH_EPS_03"]["EPS_VZ_BLW"])] + ret.steeringRateDeg = pt_cp.vl["LWI_01"]["LWI_Lenkradw_Geschw"] * (1, -1)[int(pt_cp.vl["LWI_01"]["LWI_VZ_Lenkradw_Geschw"])] + ret.steeringTorque = pt_cp.vl["LH_EPS_03"]["EPS_Lenkmoment"] * (1, -1)[int(pt_cp.vl["LH_EPS_03"]["EPS_VZ_Lenkmoment"])] + 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 + + # Verify EPS readiness to accept steering commands + hca_status = self.hca_status_values.get(pt_cp.vl["LH_EPS_03"]["EPS_HCA_Status"]) + ret.steerError = hca_status in ["DISABLED", "FAULT"] + ret.steerWarning = hca_status in ["INITIALIZING", "REJECTED"] + + # 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"]) + self.esp_hold_confirmation = pt_cp.vl["ESP_21"]["ESP_Haltebestaetigung"] + + # Update gear and/or clutch position data. + if trans_type == TransmissionType.automatic: + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["Getriebe_11"]["GE_Fahrstufe"], None)) + elif trans_type == TransmissionType.direct: + ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["EV_Gearshift"]["GearPosition"], None)) + elif trans_type == TransmissionType.manual: + ret.clutchPressed = not pt_cp.vl["Motor_14"]["MO_Kuppl_schalter"] + if bool(pt_cp.vl["Gateway_72"]["BCM1_Rueckfahrlicht_Schalter"]): + ret.gearShifter = GearShifter.reverse + else: + ret.gearShifter = GearShifter.drive + + # 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"] + + # Consume blind-spot monitoring info/warning LED states, if available. + # Infostufe: BSM LED on, Warnung: BSM LED flashing + if self.CP.enableBsm: + ret.leftBlindspot = bool(ext_cp.vl["SWA_01"]["SWA_Infostufe_SWA_li"]) or bool(ext_cp.vl["SWA_01"]["SWA_Warnung_SWA_li"]) + ret.rightBlindspot = bool(ext_cp.vl["SWA_01"]["SWA_Infostufe_SWA_re"]) or bool(ext_cp.vl["SWA_01"]["SWA_Warnung_SWA_re"]) + + # Consume factory LDW data relevant for factory SWA (Lane Change Assist) + # and capture it for forwarding to the blind spot radar controller + self.ldw_stock_values = cam_cp.vl["LDW_02"] if self.CP.networkLocation == NetworkLocation.fwdCamera else {} + + # Stock FCW is considered active if the release bit for brake-jerk warning + # is set. Stock AEB considered active if the partial braking or target + # braking release bits are set. + # Refer to VW Self Study Program 890253: Volkswagen Driver Assistance + # Systems, chapter on Front Assist with Braking: Golf Family for all MQB + ret.stockFcw = bool(ext_cp.vl["ACC_10"]["AWV2_Freigabe"]) + ret.stockAeb = bool(ext_cp.vl["ACC_10"]["ANB_Teilbremsung_Freigabe"]) or bool(ext_cp.vl["ACC_10"]["ANB_Zielbremsung_Freigabe"]) + + # Update ACC radar status. + self.tsk_status = pt_cp.vl["TSK_06"]["TSK_Status"] + if self.tsk_status == 2: + # ACC okay and enabled, but not currently engaged + ret.cruiseState.available = True + ret.cruiseState.enabled = False + elif self.tsk_status in [3, 4, 5]: + # ACC okay and enabled, currently regulating speed (3) or driver accel override (4) or overrun coast-down (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. + if self.CP.pcmCruise: + ret.cruiseState.speed = ext_cp.vl["ACC_02"]["ACC_Wunschgeschw"] * CV.KPH_TO_MS + 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["Blinkmodi_02"]["Comfort_Signal_Left"]) + ret.rightBlinker = bool(pt_cp.vl["Blinkmodi_02"]["Comfort_Signal_Right"]) + + # 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"] + + # 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 + ("EPS_Berechneter_LW", "LH_EPS_03", 0), # Absolute steering angle + ("EPS_VZ_BLW", "LH_EPS_03", 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 + ("Comfort_Signal_Left", "Blinkmodi_02", 0), # Left turn signal including comfort blink interval + ("Comfort_Signal_Right", "Blinkmodi_02", 0), # Right turn signal including comfort blink interval + ("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_Bremsdruck", "ESP_05", 0), # Brake pressure applied + ("MO_Fahrpedalrohwert_01", "Motor_20", 0), # Accelerator pedal value + ("EPS_Lenkmoment", "LH_EPS_03", 0), # Absolute driver torque input + ("EPS_VZ_Lenkmoment", "LH_EPS_03", 0), # Driver torque input sign + ("EPS_HCA_Status", "LH_EPS_03", 3), # EPS HCA control status + ("ESP_Tastung_passiv", "ESP_21", 0), # Stability control disabled + ("ESP_Haltebestaetigung", "ESP_21", 0), # ESP hold confirmation + ("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 + ("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 + ("LH_EPS_03", 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 + ("Motor_20", 50), # From J623 Engine control module + ("TSK_06", 50), # From J623 Engine control module + ("ESP_02", 50), # From J104 ABS/ESP controller + ("GRA_ACC_01", 33), # From J533 CAN gateway (via LIN from steering wheel controls) + ("Gateway_72", 10), # From J533 CAN gateway (aggregated data) + ("Airbag_02", 5), # From J234 Airbag control module + ("Kombi_01", 2), # From J285 Instrument cluster + ("Blinkmodi_02", 1), # From J519 BCM (sent at 1Hz when no lights active, 50Hz when active) + ("Einheiten_01", 1), # From J??? not known if gateway, cluster, or BCM + ] + + if CP.transmissionType == TransmissionType.automatic: + signals += [("GE_Fahrstufe", "Getriebe_11", 0)] # Auto trans gear selector position + checks += [("Getriebe_11", 20)] # From J743 Auto transmission control module + elif CP.transmissionType == TransmissionType.direct: + signals += [("GearPosition", "EV_Gearshift", 0)] # EV gear selector position + checks += [("EV_Gearshift", 10)] # From J??? unknown EV control module + elif CP.transmissionType == TransmissionType.manual: + signals += [("MO_Kuppl_schalter", "Motor_14", 0), # Clutch switch + ("BCM1_Rueckfahrlicht_Schalter", "Gateway_72", 0)] # Reverse light from BCM + checks += [("Motor_14", 10)] # From J623 Engine control module + + if CP.networkLocation == NetworkLocation.fwdCamera: + # Radars are here on CANBUS.pt + signals += MqbExtraSignals.fwd_radar_signals + checks += MqbExtraSignals.fwd_radar_checks + if CP.enableBsm: + signals += MqbExtraSignals.bsm_radar_signals + checks += MqbExtraSignals.bsm_radar_checks + + return CANParser(DBC_FILES.mqb, signals, checks, CANBUS.pt) + + @staticmethod + def get_cam_can_parser(CP): + + signals = [] + checks = [] + + if CP.networkLocation == NetworkLocation.fwdCamera: + signals += [ + # sig_name, sig_address, default + ("LDW_SW_Warnung_links", "LDW_02", 0), # Blind spot in warning mode on left side due to lane departure + ("LDW_SW_Warnung_rechts", "LDW_02", 0), # Blind spot in warning mode on right side due to lane departure + ("LDW_Seite_DLCTLC", "LDW_02", 0), # Direction of most likely lane departure (left or right) + ("LDW_DLC", "LDW_02", 0), # Lane departure, distance to line crossing + ("LDW_TLC", "LDW_02", 0), # Lane departure, time to line crossing + ] + checks += [ + # sig_address, frequency + ("LDW_02", 10) # From R242 Driver assistance camera + ] + else: + # Radars are here on CANBUS.cam + signals += MqbExtraSignals.fwd_radar_signals + checks += MqbExtraSignals.fwd_radar_checks + if CP.enableBsm: + signals += MqbExtraSignals.bsm_radar_signals + checks += MqbExtraSignals.bsm_radar_checks + + return CANParser(DBC_FILES.mqb, signals, checks, CANBUS.cam) + +class MqbExtraSignals: + # Additional signal and message lists for optional or bus-portable controllers + fwd_radar_signals = [ + ("ACC_Wunschgeschw", "ACC_02", 0), # ACC set speed + ("AWV2_Freigabe", "ACC_10", 0), # FCW brake jerk release + ("ANB_Teilbremsung_Freigabe", "ACC_10", 0), # AEB partial braking release + ("ANB_Zielbremsung_Freigabe", "ACC_10", 0), # AEB target braking release + ] + fwd_radar_checks = [ + ("ACC_10", 50), # From J428 ACC radar control module + ("ACC_02", 17), # From J428 ACC radar control module + ] + bsm_radar_signals = [ + ("SWA_Infostufe_SWA_li", "SWA_01", 0), # Blind spot object info, left + ("SWA_Warnung_SWA_li", "SWA_01", 0), # Blind spot object warning, left + ("SWA_Infostufe_SWA_re", "SWA_01", 0), # Blind spot object info, right + ("SWA_Warnung_SWA_re", "SWA_01", 0), # Blind spot object warning, right + ] + bsm_radar_checks = [ + ("SWA_01", 20), # From J1086 Lane Change Assist + ] diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py new file mode 100644 index 00000000000000..560e64ce2d143f --- /dev/null +++ b/selfdrive/car/volkswagen/interface.py @@ -0,0 +1,226 @@ +from cereal import car +from selfdrive.car.volkswagen.values import CAR, BUTTON_STATES, CANBUS, NetworkLocation, TransmissionType, GearShifter +from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config +from selfdrive.car.interfaces import CarInterfaceBase + +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() + + if CP.networkLocation == NetworkLocation.fwdCamera: + self.ext_bus = CANBUS.pt + self.cp_ext = self.cp + else: + self.ext_bus = CANBUS.cam + self.cp_ext = self.cp_cam + + @staticmethod + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + ret = CarInterfaceBase.get_std_params(candidate, fingerprint) + ret.carName = "volkswagen" + ret.radarOffCan = True + + if True: # pylint: disable=using-constant-test + # Set global MQB parameters + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.volkswagen)] + ret.enableBsm = 0x30F in fingerprint[0] # SWA_01 + + if 0xAD in fingerprint[0]: # Getriebe_11 + ret.transmissionType = TransmissionType.automatic + elif 0x187 in fingerprint[0]: # EV_Gearshift + ret.transmissionType = TransmissionType.direct + else: + ret.transmissionType = TransmissionType.manual + + if any(msg in fingerprint[1] for msg in [0x40, 0x86, 0xB2, 0xFD]): # Airbag_01, LWI_01, ESP_19, ESP_21 + ret.networkLocation = NetworkLocation.gateway + else: + ret.networkLocation = NetworkLocation.fwdCamera + + # Global lateral tuning defaults, can be overridden per-vehicle + + ret.steerActuatorDelay = 0.05 + ret.steerRateCost = 1.0 + ret.steerLimitTimer = 0.4 + ret.steerRatio = 15.6 # Let the params learner figure this out + tire_stiffness_factor = 1.0 # Let the params learner figure this out + ret.lateralTuning.pid.kpBP = [0.] + ret.lateralTuning.pid.kiBP = [0.] + ret.lateralTuning.pid.kf = 0.00006 + ret.lateralTuning.pid.kpV = [0.6] + ret.lateralTuning.pid.kiV = [0.2] + + # Per-chassis tuning values, override tuning defaults here if desired + + if candidate == CAR.ARTEON_MK1: + ret.mass = 1733 + STD_CARGO_KG + ret.wheelbase = 2.84 + + elif candidate == CAR.ATLAS_MK1: + ret.mass = 2011 + STD_CARGO_KG + ret.wheelbase = 2.98 + + elif candidate == CAR.GOLF_MK7: + ret.mass = 1397 + STD_CARGO_KG + ret.wheelbase = 2.62 + + elif candidate == CAR.JETTA_MK7: + ret.mass = 1328 + STD_CARGO_KG + ret.wheelbase = 2.71 + + elif candidate == CAR.PASSAT_MK8: + ret.mass = 1551 + STD_CARGO_KG + ret.wheelbase = 2.79 + + elif candidate == CAR.POLO_MK6: + ret.mass = 1230 + STD_CARGO_KG + ret.wheelbase = 2.55 + + elif candidate == CAR.TAOS_MK1: + ret.mass = 1498 + STD_CARGO_KG + ret.wheelbase = 2.69 + + elif candidate == CAR.TCROSS_MK1: + ret.mass = 1150 + STD_CARGO_KG + ret.wheelbase = 2.60 + + elif candidate == CAR.TIGUAN_MK2: + ret.mass = 1715 + STD_CARGO_KG + ret.wheelbase = 2.74 + + elif candidate == CAR.TOURAN_MK2: + ret.mass = 1516 + STD_CARGO_KG + ret.wheelbase = 2.79 + + elif candidate == CAR.TRANSPORTER_T61: + ret.mass = 1926 + STD_CARGO_KG + ret.wheelbase = 3.00 # SWB, LWB is 3.40, TBD how to detect difference + ret.minSteerSpeed = 14.0 + + elif candidate == CAR.TROC_MK1: + ret.mass = 1413 + STD_CARGO_KG + ret.wheelbase = 2.63 + + elif candidate == CAR.AUDI_A3_MK3: + ret.mass = 1335 + STD_CARGO_KG + ret.wheelbase = 2.61 + + elif candidate == CAR.AUDI_Q2_MK1: + ret.mass = 1205 + STD_CARGO_KG + ret.wheelbase = 2.61 + + elif candidate == CAR.AUDI_Q3_MK2: + ret.mass = 1623 + STD_CARGO_KG + ret.wheelbase = 2.68 + + elif candidate == CAR.SEAT_ATECA_MK1: + ret.mass = 1900 + STD_CARGO_KG + ret.wheelbase = 2.64 + + elif candidate == CAR.SEAT_LEON_MK3: + ret.mass = 1227 + STD_CARGO_KG + ret.wheelbase = 2.64 + + elif candidate == CAR.SKODA_KAMIQ_MK1: + ret.mass = 1265 + STD_CARGO_KG + ret.wheelbase = 2.66 + + elif candidate == CAR.SKODA_KAROQ_MK1: + ret.mass = 1278 + STD_CARGO_KG + ret.wheelbase = 2.66 + + elif candidate == CAR.SKODA_KODIAQ_MK1: + ret.mass = 1569 + STD_CARGO_KG + ret.wheelbase = 2.79 + + elif candidate == CAR.SKODA_OCTAVIA_MK3: + ret.mass = 1388 + STD_CARGO_KG + ret.wheelbase = 2.68 + + elif candidate == CAR.SKODA_SCALA_MK1: + ret.mass = 1192 + STD_CARGO_KG + ret.wheelbase = 2.65 + + elif candidate == CAR.SKODA_SUPERB_MK3: + ret.mass = 1505 + STD_CARGO_KG + ret.wheelbase = 2.84 + + else: + raise ValueError("unsupported car %s" % candidate) + + ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) + ret.centerToFront = ret.wheelbase * 0.45 + 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, self.cp_cam, self.cp_ext, self.CP.transmissionType) + 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=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic]) + + # Vehicle health and operation safety checks + if self.CS.parkingBrakeSet: + events.add(EventName.parkBrake) + if self.CS.tsk_status in [6, 7]: + events.add(EventName.accFaulted) + + # Low speed steer alert hysteresis logic + if self.CP.minSteerSpeed > 0. and ret.vEgo < (self.CP.minSteerSpeed + 1.): + self.low_speed_alert = True + elif ret.vEgo > (self.CP.minSteerSpeed + 2.): + self.low_speed_alert = False + if self.low_speed_alert: + events.add(EventName.belowSteerSpeed) + + 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, self.ext_bus, c.actuators, + 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/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 100755 index 00000000000000..822326acda975c --- /dev/null +++ b/selfdrive/car/volkswagen/values.py @@ -0,0 +1,769 @@ +# flake8: noqa + +from collections import defaultdict +from typing import Dict + +from cereal import car +from selfdrive.car import dbc_dict + +Ecu = car.CarParams.Ecu +NetworkLocation = car.CarParams.NetworkLocation +TransmissionType = car.CarParams.TransmissionType +GearShifter = car.CarState.GearShifter + +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 + +class DBC_FILES: + mqb = "vw_mqb_2010" # Used for all cars with MQB-style CAN messaging + +DBC = defaultdict(lambda: dbc_dict(DBC_FILES.mqb, None)) # type: Dict[str, Dict[str, str]] + +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 +} + +# Check the 7th and 8th characters of the VIN before adding a new CAR. If the +# chassis code is already listed below, don't add a new CAR, just add to the +# FW_VERSIONS for that existing CAR. +# Exception: SEAT Leon and SEAT Ateca share a chassis code + +class CAR: + ARTEON_MK1 = "VOLKSWAGEN ARTEON 1ST GEN" # Chassis AN, Mk1 VW Arteon and variants + ATLAS_MK1 = "VOLKSWAGEN ATLAS 1ST GEN" # Chassis CA, Mk1 VW Atlas and Atlas Cross Sport + GOLF_MK7 = "VOLKSWAGEN GOLF 7TH GEN" # Chassis 5G/AU/BA/BE, Mk7 VW Golf and variants + JETTA_MK7 = "VOLKSWAGEN JETTA 7TH GEN" # Chassis BU, Mk7 VW Jetta + PASSAT_MK8 = "VOLKSWAGEN PASSAT 8TH GEN" # Chassis 3G, Mk8 VW Passat and variants + POLO_MK6 = "VOLKSWAGEN POLO 6TH GEN" # Chassis AW, Mk6 VW Polo + TAOS_MK1 = "VOLKSWAGEN TAOS 1ST GEN" # Chassis B2, Mk1 VW Taos and Tharu + TCROSS_MK1 = "VOLKSWAGEN T-CROSS 1ST GEN" # Chassis C1, Mk1 VW T-Cross SWB and LWB variants + TIGUAN_MK2 = "VOLKSWAGEN TIGUAN 2ND GEN" # Chassis AD/BW, Mk2 VW Tiguan and variants + TOURAN_MK2 = "VOLKSWAGEN TOURAN 2ND GEN" # Chassis 1T, Mk2 VW Touran and variants + TRANSPORTER_T61 = "VOLKSWAGEN TRANSPORTER T6.1" # Chassis 7H/7L, T6-facelift Transporter/Multivan/Caravelle/California + TROC_MK1 = "VOLKSWAGEN T-ROC 1ST GEN" # Chassis A1, Mk1 VW VW T-Roc and variants + AUDI_A3_MK3 = "AUDI A3 3RD GEN" # Chassis 8V/FF, Mk3 Audi A3 and variants + AUDI_Q2_MK1 = "AUDI Q2 1ST GEN" # Chassis GA, Mk1 Audi Q2 (RoW) and Q2L (China only) + AUDI_Q3_MK2 = "AUDI Q3 2ND GEN" # Chassis 8U/F3/FS, Mk2 Audi Q3 and variants + SEAT_ATECA_MK1 = "SEAT ATECA 1ST GEN" # Chassis 5F, Mk1 SEAT Ateca and CUPRA Ateca + SEAT_LEON_MK3 = "SEAT LEON 3RD GEN" # Chassis 5F, Mk3 SEAT Leon and variants + SKODA_KAMIQ_MK1 = "SKODA KAMIQ 1ST GEN" # Chassis NW, Mk1 Skoda Kamiq + SKODA_KAROQ_MK1 = "SKODA KAROQ 1ST GEN" # Chassis NU, Mk1 Skoda Karoq + SKODA_KODIAQ_MK1 = "SKODA KODIAQ 1ST GEN" # Chassis NS, Mk1 Skoda Kodiaq + SKODA_SCALA_MK1 = "SKODA SCALA 1ST GEN" # Chassis NW, Mk1 Skoda Scala and Skoda Kamiq + SKODA_SUPERB_MK3 = "SKODA SUPERB 3RD GEN" # Chassis 3V/NP, Mk3 Skoda Superb and variants + SKODA_OCTAVIA_MK3 = "SKODA OCTAVIA 3RD GEN" # Chassis NE, Mk3 Skoda Octavia and variants + +# All supported cars should return FW from the engine, srs, eps, and fwdRadar. Cars +# with a manual trans won't return transmission firmware, but all other cars will. +# +# The 0xF187 SW part number query should return in the form of N[NX][NX] NNN NNN [X[X]], +# where N=number, X=letter, and the trailing two letters are optional. Performance +# tuners sometimes tamper with that field (e.g. 8V0 9C0 BB0 1 from COBB/EQT). Tampered +# ECU SW part numbers are invalid for vehicle ID and compatibility checks. Try to have +# them repaired by the tuner before including them in openpilot. + +FW_VERSIONS = { + CAR.ARTEON_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x873G0906259P \xf1\x890001', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x8709G927158L \xf1\x893611', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655DL\xf1\x890732\xf1\x82\0161812141812171105141123052J00', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0910143C \xf1\x892211\xf1\x82\00567B0020800', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572T \xf1\x890383', + ], + }, + CAR.ATLAS_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8703H906026AA\xf1\x899970', + b'\xf1\x8703H906026F \xf1\x896696', + b'\xf1\x8703H906026F \xf1\x899970', + b'\xf1\x8703H906026J \xf1\x896026', + b'\xf1\x8703H906026J \xf1\x899971', + b'\xf1\x8703H906026S \xf1\x896693', + b'\xf1\x8703H906026S \xf1\x899970', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x8709G927158A \xf1\x893387', + b'\xf1\x8709G927158DR\xf1\x893536', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655BC\xf1\x890503\xf1\x82\0161914151912001103111122031200', + b'\xf1\x873Q0959655BN\xf1\x890713\xf1\x82\0162214152212001105141122052900', + b'\xf1\x873Q0959655DB\xf1\x890720\xf1\x82\0162214152212001105141122052900', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x873QF909144B \xf1\x891582\xf1\x82\00571B60924A1', + b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820528B6090105', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x875Q0907572H \xf1\x890620', + b'\xf1\x875Q0907572J \xf1\x890654', + b'\xf1\x875Q0907572P \xf1\x890682', + ], + }, + CAR.GOLF_MK7: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906016A \xf1\x897697', + b'\xf1\x8704E906016AD\xf1\x895758', + b'\xf1\x8704E906016CE\xf1\x899096', + b'\xf1\x8704E906023AG\xf1\x891726', + b'\xf1\x8704E906023BN\xf1\x894518', + b'\xf1\x8704E906024K \xf1\x896811', + b'\xf1\x8704E906027GR\xf1\x892394', + b'\xf1\x8704E906027HD\xf1\x893742', + b'\xf1\x8704E906027MA\xf1\x894958', + b'\xf1\x8704L906021DT\xf1\x895520', + b'\xf1\x8704L906021N \xf1\x895518', + b'\xf1\x8704L906026BP\xf1\x897608', + b'\xf1\x8704L906026NF\xf1\x899528', + b'\xf1\x8704L906056CL\xf1\x893823', + b'\xf1\x8704L906056CR\xf1\x895813', + b'\xf1\x8704L906056HE\xf1\x893758', + b'\xf1\x870EA906016A \xf1\x898343', + b'\xf1\x870EA906016E \xf1\x894219', + b'\xf1\x870EA906016F \xf1\x895002', + b'\xf1\x870EA906016S \xf1\x897207', + b'\xf1\x875G0906259 \xf1\x890007', + b'\xf1\x875G0906259J \xf1\x890002', + b'\xf1\x875G0906259L \xf1\x890002', + b'\xf1\x875G0906259N \xf1\x890003', + b'\xf1\x875G0906259Q \xf1\x890002', + b'\xf1\x875G0906259Q \xf1\x892313', + b'\xf1\x878V0906259H \xf1\x890002', + b'\xf1\x878V0906259J \xf1\x890003', + b'\xf1\x878V0906259K \xf1\x890001', + b'\xf1\x878V0906259P \xf1\x890001', + b'\xf1\x878V0906259Q \xf1\x890002', + b'\xf1\x878V0906264F \xf1\x890003', + b'\xf1\x878V0906264L \xf1\x890002', + b'\xf1\x878V0906264M \xf1\x890001', + b'\xf1\x878V09C0BB01 \xf1\x890001', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x8709G927749AP\xf1\x892943', + b'\xf1\x8709S927158A \xf1\x893585', + b'\xf1\x870CW300041H \xf1\x891010', + b'\xf1\x870CW300042F \xf1\x891604', + b'\xf1\x870CW300043B \xf1\x891601', + b'\xf1\x870CW300044S \xf1\x894530', + b'\xf1\x870CW300044T \xf1\x895245', + b'\xf1\x870CW300045 \xf1\x894531', + b'\xf1\x870CW300047D \xf1\x895261', + b'\xf1\x870CW300048J \xf1\x890611', + b'\xf1\x870D9300012 \xf1\x894904', + b'\xf1\x870D9300012 \xf1\x894913', + b'\xf1\x870D9300012 \xf1\x894937', + b'\xf1\x870D9300012 \xf1\x895045', + b'\xf1\x870D9300014M \xf1\x895004', + b'\xf1\x870D9300020S \xf1\x895201', + b'\xf1\x870D9300040A \xf1\x893613', + b'\xf1\x870D9300040S \xf1\x894311', + b'\xf1\x870D9300041H \xf1\x895220', + b'\xf1\x870DD300045K \xf1\x891120', + b'\xf1\x870DD300046F \xf1\x891601', + b'\xf1\x870GC300012A \xf1\x891403', + b'\xf1\x870GC300014B \xf1\x892401', + b'\xf1\x870GC300014B \xf1\x892405', + b'\xf1\x870GC300020G \xf1\x892401', + b'\xf1\x870GC300020G \xf1\x892403', + b'\xf1\x870GC300020G \xf1\x892404', + b'\xf1\x870GC300043T \xf1\x899999', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655AA\xf1\x890386\xf1\x82\0211413001113120043114317121C111C9113', + b'\xf1\x875Q0959655AA\xf1\x890386\xf1\x82\0211413001113120053114317121C111C9113', + b'\xf1\x875Q0959655AA\xf1\x890388\xf1\x82\0211413001113120043114317121C111C9113', + b'\xf1\x875Q0959655AA\xf1\x890388\xf1\x82\0211413001113120043114417121411149113', + b'\xf1\x875Q0959655AA\xf1\x890388\xf1\x82\0211413001113120053114317121C111C9113', + b'\xf1\x875Q0959655BH\xf1\x890336\xf1\x82\02314160011123300314211012230229333463100', + b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\023141600111233003142404A2252229333463100', + b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\023141600111233003142405A2252229333463100', + b'\xf1\x875Q0959655C \xf1\x890361\xf1\x82\0211413001112120004110415121610169112', + b'\xf1\x875Q0959655D \xf1\x890388\xf1\x82\0211413001113120006110417121A101A9113', + b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023271112111312--071104171825102591131211', + b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023271212111312--071104171838103891131211', + b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023341512112212--071104172328102891131211', + b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\x13272512111312--07110417182C102C91131211', + b'\xf1\x875Q0959655M \xf1\x890361\xf1\x82\0211413001112120041114115121611169112', + b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02315120011211200621143171717111791132111', + b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02324230011211200061104171724102491132111', + b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02324230011211200621143171724112491132111', + b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\x1315120011211200061104171717101791132111', + b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\x1324230011211200631143171724122491132111', + b'\xf1\x875Q0959655T \xf1\x890825\xf1\x82\023271200111312--071104171837103791132111', + b'\xf1\x875Q0959655T \xf1\x890830\xf1\x82\x13271100111312--071104171826102691131211', + b'\xf1\x875QD959655 \xf1\x890388\xf1\x82\x111413001113120006110417121D101D9112', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x873Q0909144F \xf1\x895043\xf1\x82\00561A01612A0', + b'\xf1\x873Q0909144H \xf1\x895061\xf1\x82\00566A0J612A1', + b'\xf1\x873Q0909144J \xf1\x895063\xf1\x82\00566A00514A1', + b'\xf1\x873Q0909144J \xf1\x895063\xf1\x82\00566A0J712A1', + b'\xf1\x873Q0909144K \xf1\x895072\xf1\x82\00571A0J714A1', + b'\xf1\x873Q0909144L \xf1\x895081\xf1\x82\x0571A0JA15A1', + b'\xf1\x873Q0909144M \xf1\x895082\xf1\x82\00571A01A18A1', + b'\xf1\x873Q0909144M \xf1\x895082\xf1\x82\00571A0JA16A1', + b'\xf1\x875Q0909143K \xf1\x892033\xf1\x820519A9040203', + b'\xf1\x875Q0909144AA\xf1\x891081\xf1\x82\00521A00441A1', + b'\xf1\x875Q0909144AA\xf1\x891081\xf1\x82\x0521A00641A1', + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521A00442A1', + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521A00642A1', + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521A07B05A1', + b'\xf1\x875Q0909144L \xf1\x891021\xf1\x82\00521A00602A0', + b'\xf1\x875Q0909144L \xf1\x891021\xf1\x82\00522A00402A0', + b'\xf1\x875Q0909144L \xf1\x891021\xf1\x82\x0521A00502A0', + b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00511A00403A0', + b'\xf1\x875Q0909144R \xf1\x891061\xf1\x82\00516A00604A1', + b'\xf1\x875Q0909144S \xf1\x891063\xf1\x82\00516A00604A1', + b'\xf1\x875Q0909144S \xf1\x891063\xf1\x82\00516A07A02A1', + b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521A00507A1', + b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\x0521A07B04A1', + b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521A20B03A1', + b'\xf1\x875QD909144B \xf1\x891072\xf1\x82\x0521A00507A1', + b'\xf1\x875QM909144A \xf1\x891072\xf1\x82\x0521A20B03A1', + b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\00521A00442A1', + b'\xf1\x875QN909144A \xf1\x895081\xf1\x82\00571A01A16A1', + b'\xf1\x875QN909144A \xf1\x895081\xf1\x82\00571A01A18A1', + b'\xf1\x875QN909144A \xf1\x895081\xf1\x82\x0571A01A17A1', + b'\xf1\x875QN909144B \xf1\x895082\xf1\x82\00571A01A18A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x875Q0907567G \xf1\x890390\xf1\x82\00101', + b'\xf1\x875Q0907567J \xf1\x890396\xf1\x82\x0101', + b'\xf1\x875Q0907572A \xf1\x890141\xf1\x82\00101', + b'\xf1\x875Q0907572B \xf1\x890200\xf1\x82\00101', + b'\xf1\x875Q0907572C \xf1\x890210\xf1\x82\00101', + b'\xf1\x875Q0907572D \xf1\x890304\xf1\x82\00101', + b'\xf1\x875Q0907572E \xf1\x89X310\xf1\x82\00101', + b'\xf1\x875Q0907572F \xf1\x890400\xf1\x82\00101', + b'\xf1\x875Q0907572G \xf1\x890571', + b'\xf1\x875Q0907572H \xf1\x890620', + b'\xf1\x875Q0907572J \xf1\x890654', + b'\xf1\x875Q0907572P \xf1\x890682', + b'\xf1\x875Q0907572R \xf1\x890771', + ], + }, + CAR.JETTA_MK7: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906024AK\xf1\x899937', + b'\xf1\x8704E906024AS\xf1\x899912', + b'\xf1\x8704E906024B \xf1\x895594', + b'\xf1\x8704E906024L \xf1\x895595', + b'\xf1\x8704E906024L \xf1\x899970', + b'\xf1\x8704E906027MS\xf1\x896223', + b'\xf1\x875G0906259T \xf1\x890003', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x8709G927158BQ\xf1\x893545', + b'\xf1\x8709S927158BS\xf1\x893642', + b'\xf1\x8709S927158R \xf1\x893552', + b'\xf1\x8709S927158R \xf1\x893587', + b'\xf1\x870GC300020N \xf1\x892803', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655AG\xf1\x890336\xf1\x82\02314171231313500314611011630169333463100', + b'\xf1\x875Q0959655BM\xf1\x890403\xf1\x82\02314171231313500314642011650169333463100', + b'\xf1\x875Q0959655BM\xf1\x890403\xf1\x82\02314171231313500314643011650169333463100', + b'\xf1\x875Q0959655BR\xf1\x890403\xf1\x82\02311170031313300314240011150119333433100', + b'\xf1\x875Q0959655BR\xf1\x890403\xf1\x82\02319170031313300314240011550159333463100', + b'\xf1\x875Q0959655CB\xf1\x890421\xf1\x82\x1314171231313500314643021650169333613100', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x873Q0909144M \xf1\x895082\xf1\x82\x0571A10A11A1', + b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\00521A10A01A1', + b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\x0521B00404A1', + b'\xf1\x875QM909144C \xf1\x891082\xf1\x82\00521A00642A1', + b'\xf1\x875QM909144C \xf1\x891082\xf1\x82\00521A10A01A1', + b'\xf1\x875QN909144B \xf1\x895082\xf1\x82\00571A10A11A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x875Q0907572N \xf1\x890681', + b'\xf1\x875Q0907572R \xf1\x890771', + ], + }, + CAR.PASSAT_MK8: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906023AH\xf1\x893379', + b'\xf1\x8704L906026GA\xf1\x892013', + b'\xf1\x8704L906026KD\xf1\x894798', + b'\xf1\x873G0906264 \xf1\x890004', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300048R \xf1\x890610', + b'\xf1\x870D9300014L \xf1\x895002', + b'\xf1\x870DD300045T \xf1\x891601', + b'\xf1\x870GC300042H \xf1\x891404', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655AN\xf1\x890306\xf1\x82\r58160058140013036914110311', + b'\xf1\x873Q0959655BB\xf1\x890195\xf1\x82\r56140056130012026612120211', + b'\xf1\x873Q0959655BK\xf1\x890703\xf1\x82\0165915005914001344701311442900', + b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02315120011111200631145171716121691132111', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820522B0080803', + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521B00606A1', + b'\xf1\x875Q0909144S \xf1\x891063\xf1\x82\00516B00501A1', + b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521B00703A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x873Q0907572B \xf1\x890192', + b'\xf1\x873Q0907572C \xf1\x890195', + b'\xf1\x875Q0907572R \xf1\x890771', + ], + }, + CAR.POLO_MK6: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704C906025H \xf1\x895177', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300050D \xf1\x891908', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x872Q0959655AJ\xf1\x890250\xf1\x82\x1248130411110416--04040404784811152H14', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x872Q1909144M \xf1\x896041', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572R \xf1\x890372', + ], + }, + CAR.TAOS_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8705E906013E \xf1\x891624', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x8709S927158BL\xf1\x893791', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572T \xf1\x890383', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875QM909144C \xf1\x891082\xf1\x82\x0521060605A1', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655CB\xf1\x890421\xf1\x82\x1311111111333500314646021450149333613100', + ], + }, + CAR.TCROSS_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704C906025AK\xf1\x897053', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300050E \xf1\x891903', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x872Q0959655AJ\xf1\x890250\xf1\x82\02212130411110411--04041104141311152H14', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x872Q1909144M \xf1\x896041', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572T \xf1\x890383', + ], + }, + CAR.TIGUAN_MK2: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704L906026EJ\xf1\x893661', + b'\xf1\x8704L906027G \xf1\x899893', + b'\xf1\x875N0906259 \xf1\x890002', + b'\xf1\x8783A907115B \xf1\x890005', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x8709G927158DT\xf1\x893698', + b'\xf1\x870DL300011N \xf1\x892001', + b'\xf1\x870DL300011N \xf1\x892012', + b'\xf1\x870DL300013A \xf1\x893005', + b'\xf1\x870DL300013G \xf1\x892120', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655AR\xf1\x890317\xf1\x82\02331310031333334313132573732379333313100', + b'\xf1\x875Q0959655BM\xf1\x890403\xf1\x82\02316143231313500314641011750179333423100', + b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\02312110031333300314240583752379333423100', + b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\02331310031333336313140013950399333423100', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820529A6060603', + b'\xf1\x875QF909144B \xf1\x895582\xf1\x82\00571A60634A1', + b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\x0521A60604A1', + b'\xf1\x875QM909144C \xf1\x891082\xf1\x82\00521A60804A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572J \xf1\x890156', + b'\xf1\x872Q0907572Q \xf1\x890342', + b'\xf1\x872Q0907572R \xf1\x890372', + ], + }, + CAR.TOURAN_MK2: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704L906026HM\xf1\x893017', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300041E \xf1\x891005', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655AS\xf1\x890318\xf1\x82\023363500213533353141324C4732479333313100', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820531B0062105', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x873Q0907572C \xf1\x890195', + ], + }, + CAR.TRANSPORTER_T61: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704L906057N \xf1\x890413', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870BT300012G \xf1\x893102', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x872Q0959655AE\xf1\x890506\xf1\x82\02316170411110411--04041704161611152S1411', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x877LA909144F \xf1\x897150\xf1\x82\005323A5519A2', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572R \xf1\x890372', + ], + }, + CAR.TROC_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8705E906018AT\xf1\x899640', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300051M \xf1\x891925', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655CG\xf1\x890421\xf1\x82\x13111100123333003142404M1152119333613100', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\x0521060405A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572T \xf1\x890383', + ], + }, + CAR.AUDI_A3_MK3: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906023AN\xf1\x893695', + b'\xf1\x8704E906023AR\xf1\x893440', + b'\xf1\x8704E906023BL\xf1\x895190', + b'\xf1\x8704E906027CJ\xf1\x897798', + b'\xf1\x8704L997022N \xf1\x899459', + b'\xf1\x875G0906259L \xf1\x890002', + b'\xf1\x875G0906259Q \xf1\x890002', + b'\xf1\x878V0906259F \xf1\x890002', + b'\xf1\x878V0906264B \xf1\x890003', + b'\xf1\x878V0907115B \xf1\x890007', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300044T \xf1\x895245', + b'\xf1\x870CW300048 \xf1\x895201', + b'\xf1\x870D9300012 \xf1\x894912', + b'\xf1\x870D9300013B \xf1\x894931', + b'\xf1\x870D9300041N \xf1\x894512', + b'\xf1\x870DD300046A \xf1\x891602', + b'\xf1\x870DD300046F \xf1\x891602', + b'\xf1\x870DD300046G \xf1\x891601', + b'\xf1\x870GC300013M \xf1\x892402', + b'\xf1\x870GC300042J \xf1\x891402', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655AB\xf1\x890388\xf1\x82\0211111001111111206110412111321139114', + b'\xf1\x875Q0959655AM\xf1\x890315\xf1\x82\x1311111111111111311411011231129321212100', + b'\xf1\x875Q0959655J \xf1\x890825\xf1\x82\023111112111111--171115141112221291163221', + b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023121111111211--261117141112231291163221', + b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\x13121111111111--341117141212231291163221', + b'\xf1\x875Q0959655N \xf1\x890361\xf1\x82\0211212001112110004110411111421149114', + b'\xf1\x875Q0959655N \xf1\x890361\xf1\x82\0211212001112111104110411111521159114', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x873Q0909144H \xf1\x895061\xf1\x82\00566G0HA14A1', + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521G0G809A1', + b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00503G00303A0', + b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00503G00803A0', + b'\xf1\x875Q0909144R \xf1\x891061\xf1\x82\00516G00804A1', + b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521G00807A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x875Q0907567N \xf1\x890400\xf1\x82\00101', + b'\xf1\x875Q0907572D \xf1\x890304\xf1\x82\00101', + b'\xf1\x875Q0907572G \xf1\x890571', + b'\xf1\x875Q0907572H \xf1\x890620', + b'\xf1\x875Q0907572P \xf1\x890682', + ], + }, + CAR.AUDI_Q2_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906027JT\xf1\x894145', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300041F \xf1\x891006', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655BD\xf1\x890336\xf1\x82\x1311111111111100311211011231129321312111', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x873Q0909144K \xf1\x895072\xf1\x82\x0571F60511A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572M \xf1\x890233', + ], + }, + CAR.AUDI_Q3_MK2: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8705E906018N \xf1\x899970', + b'\xf1\x8783A906259 \xf1\x890001', + b'\xf1\x8783A906259 \xf1\x890005', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x8709G927158CN\xf1\x893608', + b'\xf1\x870GC300046F \xf1\x892701', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655BF\xf1\x890403\xf1\x82\x1321211111211200311121232152219321422111', + b'\xf1\x875Q0959655CC\xf1\x890421\xf1\x82\x131111111111120031111237116A119321532111', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0910143C \xf1\x892211\xf1\x82\x0567G6000300', + b'\xf1\x875Q0910143C \xf1\x892211\xf1\x82\x0567G6000800', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572R \xf1\x890372', + b'\xf1\x872Q0907572T \xf1\x890383', + ], + }, + CAR.SEAT_ATECA_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906027KA\xf1\x893749', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870D9300014S \xf1\x895202', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655BH\xf1\x890703\xf1\x82\0161212001211001305121211052900', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x873Q0909144L \xf1\x895081\xf1\x82\00571N60511A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572M \xf1\x890233', + ], + }, + CAR.SEAT_LEON_MK3: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704L906021EL\xf1\x897542', + b'\xf1\x8704L906026BP\xf1\x891198', + b'\xf1\x8704L906026BP\xf1\x897608', + b'\xf1\x8705E906018AS\xf1\x899596', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300050J \xf1\x891908', + b'\xf1\x870D9300042M \xf1\x895016', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655AC\xf1\x890189\xf1\x82\r11110011110011021511110200', + b'\xf1\x873Q0959655AS\xf1\x890200\xf1\x82\r12110012120012021612110200', + b'\xf1\x873Q0959655CM\xf1\x890720\xf1\x82\0161312001313001305171311052900', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521N01342A1', + b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00511N01805A0', + b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521N05808A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x875Q0907572B \xf1\x890200\xf1\x82\00101', + b'\xf1\x875Q0907572H \xf1\x890620', + b'\xf1\x875Q0907572P \xf1\x890682', + ], + }, + CAR.SKODA_KAMIQ_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8705C906032M \xf1\x891333', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300020 \xf1\x891906', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x872Q0959655AM\xf1\x890351\xf1\x82\0222221042111042121040404042E2711152H14', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x872Q1909144M \xf1\x896041', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572T \xf1\x890383', + ], + }, + CAR.SKODA_KAROQ_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8705E906018P \xf1\x896020', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300041S \xf1\x891615', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655BH\xf1\x890712\xf1\x82\0161213001211001101131122012100', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0910143C \xf1\x892211\xf1\x82\00567T6100500', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572M \xf1\x890233', + ], + }, + CAR.SKODA_KODIAQ_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906027DD\xf1\x893123', + b'\xf1\x8704L906026DE\xf1\x895418', + b'\xf1\x875NA907115E \xf1\x890003', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870D9300043 \xf1\x895202', + b'\xf1\x870DL300012M \xf1\x892107', + b'\xf1\x870DL300012N \xf1\x892110', + b'\xf1\x870DL300013G \xf1\x892119', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655BJ\xf1\x890703\xf1\x82\0161213001211001205212111052100', + b'\xf1\x873Q0959655CN\xf1\x890720\xf1\x82\0161213001211001205212112052100', + b'\xf1\x873Q0959655CQ\xf1\x890720\xf1\x82\x0e1213111211001205212112052111', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820527T6050405', + b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820527T6060405', + b'\xf1\x875Q0910143C \xf1\x892211\xf1\x82\x0567T600G600', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572Q \xf1\x890342', + b'\xf1\x872Q0907572R \xf1\x890372', + ], + }, + CAR.SKODA_OCTAVIA_MK3: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704E906016ER\xf1\x895823', + b'\xf1\x8704E906027HD\xf1\x893742', + b'\xf1\x8704L906021DT\xf1\x898127', + b'\xf1\x8704L906026BS\xf1\x891541', + b'\xf1\x875G0906259C \xf1\x890002', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300041N \xf1\x891605', + b'\xf1\x870CW300043B \xf1\x891601', + b'\xf1\x870D9300041C \xf1\x894936', + b'\xf1\x870D9300041J \xf1\x894902', + b'\xf1\x870D9300041P \xf1\x894507', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x873Q0959655AC\xf1\x890200\xf1\x82\r11120011100010022212110200', + b'\xf1\x873Q0959655AQ\xf1\x890200\xf1\x82\r11120011100010312212113100', + b'\xf1\x873Q0959655AS\xf1\x890200\xf1\x82\r11120011100010022212110200', + b'\xf1\x873Q0959655BH\xf1\x890703\xf1\x82\0163221003221002105755331052100', + b'\xf1\x873Q0959655CN\xf1\x890720\xf1\x82\x0e3221003221002105755331052100', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x873Q0909144J \xf1\x895063\xf1\x82\00566A01513A1', + b'\xf1\x875Q0909144AA\xf1\x891081\xf1\x82\00521T00403A1', + b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\x0521T00403A1', + b'\xf1\x875Q0909144R \xf1\x891061\xf1\x82\x0516A00604A1', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x875Q0907572D \xf1\x890304\xf1\x82\x0101', + b'\xf1\x875Q0907572F \xf1\x890400\xf1\x82\00101', + b'\xf1\x875Q0907572J \xf1\x890654', + b'\xf1\x875Q0907572P \xf1\x890682', + ], + }, + CAR.SKODA_SCALA_MK1: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704C906025AK\xf1\x897053', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300050 \xf1\x891709', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x872Q0959655AM\xf1\x890351\xf1\x82\022111104111104112104040404111111112H14', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x872Q1909144M \xf1\x896041', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x872Q0907572R \xf1\x890372', + ], + }, + CAR.SKODA_SUPERB_MK3: { + (Ecu.engine, 0x7e0, None): [ + b'\xf1\x8704L906026FP\xf1\x891196', + b'\xf1\x8704L906026KB\xf1\x894071', + b'\xf1\x873G0906259B \xf1\x890002', + b'\xf1\x873G0906264A \xf1\x890002', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\xf1\x870CW300042H \xf1\x891601', + b'\xf1\x870D9300011T \xf1\x894801', + b'\xf1\x870D9300012 \xf1\x894940', + ], + (Ecu.srs, 0x715, None): [ + b'\xf1\x875Q0959655AE\xf1\x890130\xf1\x82\022111200111121001121118112231292221111', + b'\xf1\x875Q0959655AK\xf1\x890130\xf1\x82\022111200111121001121110012211292221111', + b'\xf1\x875Q0959655BH\xf1\x890336\xf1\x82\02331310031313100313131013141319331413100', + ], + (Ecu.eps, 0x712, None): [ + b'\xf1\x875Q0909143K \xf1\x892033\xf1\x820514UZ070203', + b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820522UZ070303', + b'\xf1\x875Q0910143B \xf1\x892201\xf1\x82\00563UZ060700', + b'\xf1\x875Q0910143B \xf1\x892201\xf1\x82\x0563UZ060600', + ], + (Ecu.fwdRadar, 0x757, None): [ + b'\xf1\x873Q0907572B \xf1\x890192', + b'\xf1\x873Q0907572B \xf1\x890194', + b'\xf1\x873Q0907572C \xf1\x890195', + ], + }, +} diff --git a/selfdrive/car/volkswagen/volkswagencan.py b/selfdrive/car/volkswagen/volkswagencan.py new file mode 100644 index 00000000000000..10e0054c79472c --- /dev/null +++ b/selfdrive/car/volkswagen/volkswagencan.py @@ -0,0 +1,49 @@ +# 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, enabled, steering_pressed, hud_alert, left_lane_visible, right_lane_visible, + ldw_stock_values, left_lane_depart, right_lane_depart): + # Lane color reference: + # 0 (LKAS disabled) - off + # 1 (LKAS enabled, no lane detected) - dark gray + # 2 (LKAS enabled, lane detected) - light gray on VW, green or white on Audi depending on year or virtual cockpit. On a color MFD on a 2015 A3 TDI it is white, virtual cockpit on a 2018 A3 e-Tron its green. + # 3 (LKAS enabled, lane departure detected) - white on VW, red on Audi + values = ldw_stock_values.copy() + values.update({ + "LDW_Status_LED_gelb": 1 if enabled and steering_pressed else 0, + "LDW_Status_LED_gruen": 1 if enabled and not steering_pressed else 0, + "LDW_Lernmodus_links": 3 if left_lane_depart else 1 + left_lane_visible, + "LDW_Lernmodus_rechts": 3 if right_lane_depart else 1 + right_lane_visible, + "LDW_Texte": 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..c24ffa41d94763 --- /dev/null +++ b/selfdrive/clocksd/clocksd.cc @@ -0,0 +1,90 @@ +#include +#include +#include + +#include +#include + +// Apple doesn't have timerfd +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" + +ExitHandler do_exit; + +#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 (!do_exit && (err = read(timerfd, &expirations, sizeof(expirations)))) { + if (err < 0) { + if (errno == EINTR) continue; + break; + } +#else + // Just run at 1Hz on apple + while (!do_exit) { + util::sleep_for(1000); +#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..9b496fef72d872 --- /dev/null +++ b/selfdrive/common/SConscript @@ -0,0 +1,35 @@ +Import('env', 'arch', 'SHARED') + +if SHARED: + fxn = env.SharedLibrary +else: + fxn = env.Library + +common_libs = [ + 'params.cc', + 'swaglog.cc', + 'util.cc', + 'gpio.cc', + 'i2c.cc', + 'watchdog.cc', +] + +_common = fxn('common', common_libs, LIBS="json11") + +files = [ + 'clutil.cc', + 'visionimg.cc', +] + +if arch == "aarch64": + _gpu_libs = ['gui', 'adreno_utils'] +elif arch == "larch64": + _gpu_libs = ["GLESv2"] +else: + _gpu_libs = ["GL"] + +_gpucommon = fxn('gpucommon', files, LIBS=_gpu_libs) +Export('_common', '_gpucommon', '_gpu_libs') + +if GetOption('test'): + env.Program('tests/test_util', ['tests/test_util.cc'], LIBS=[_common]) diff --git a/selfdrive/common/buffering.c b/selfdrive/common/buffering.c deleted file mode 100644 index 9cbb1b86e0df11..00000000000000 --- a/selfdrive/common/buffering.c +++ /dev/null @@ -1,438 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "common/efd.h" - -#include "buffering.h" - -void tbuffer_init(TBuffer *tb, int num_bufs, const char* name) { - assert(num_bufs >= 3); - - memset(tb, 0, sizeof(TBuffer)); - tb->reading = (bool*)calloc(num_bufs, sizeof(bool)); - assert(tb->reading); - tb->pending_idx = -1; - tb->num_bufs = num_bufs; - tb->name = name; - - pthread_mutex_init(&tb->lock, NULL); - pthread_cond_init(&tb->cv, NULL); - tb->efd = efd_init(); - assert(tb->efd >= 0); -} - -void tbuffer_init2(TBuffer *tb, int num_bufs, const char* name, - void (*release_cb)(void* c, int idx), - void* cb_cookie) { - - tbuffer_init(tb, num_bufs, name); - - tb->release_cb = release_cb; - tb->cb_cookie = cb_cookie; -} - -int tbuffer_efd(TBuffer *tb) { - return tb->efd; -} - -int tbuffer_select(TBuffer *tb) { - pthread_mutex_lock(&tb->lock); - - int i; - for (i=0; inum_bufs; i++) { - if (!tb->reading[i] && i != tb->pending_idx) { - break; - } - } - assert(i < tb->num_bufs); - - pthread_mutex_unlock(&tb->lock); - return i; -} - -void tbuffer_dispatch(TBuffer *tb, int idx) { - pthread_mutex_lock(&tb->lock); - - if (tb->pending_idx != -1) { - //printf("tbuffer (%s) dropped!\n", tb->name ? tb->name : "?"); - if (tb->release_cb) { - tb->release_cb(tb->cb_cookie, tb->pending_idx); - } - tb->pending_idx = -1; - } - - tb->pending_idx = idx; - - efd_write(tb->efd); - pthread_cond_signal(&tb->cv); - - pthread_mutex_unlock(&tb->lock); -} - -int tbuffer_acquire(TBuffer *tb) { - pthread_mutex_lock(&tb->lock); - - if (tb->stopped) { - pthread_mutex_unlock(&tb->lock); - return -1; - } - - while (tb->pending_idx == -1) { - pthread_cond_wait(&tb->cv, &tb->lock); - - if (tb->stopped) { - pthread_mutex_unlock(&tb->lock); - return -1; - } - } - - efd_clear(tb->efd); - - int ret = tb->pending_idx; - assert(ret < tb->num_bufs); - - tb->reading[ret] = true; - tb->pending_idx = -1; - - pthread_mutex_unlock(&tb->lock); - - return ret; -} - -static void tbuffer_release_locked(TBuffer *tb, int idx) { - assert(idx < tb->num_bufs); - if (!tb->reading[idx]) { - printf("!! releasing tbuffer we aren't reading %d\n", idx); - } - - if (tb->release_cb) { - tb->release_cb(tb->cb_cookie, idx); - } - - tb->reading[idx] = false; -} - -void tbuffer_release(TBuffer *tb, int idx) { - pthread_mutex_lock(&tb->lock); - tbuffer_release_locked(tb, idx); - pthread_mutex_unlock(&tb->lock); -} - -void tbuffer_release_all(TBuffer *tb) { - pthread_mutex_lock(&tb->lock); - for (int i=0; inum_bufs; i++) { - if (tb->reading[i]) { - tbuffer_release_locked(tb, i); - } - } - pthread_mutex_unlock(&tb->lock); -} - -void tbuffer_stop(TBuffer *tb) { - pthread_mutex_lock(&tb->lock); - tb->stopped = true; - efd_write(tb->efd); - pthread_cond_signal(&tb->cv); - pthread_mutex_unlock(&tb->lock); -} - - - - - - - - - - - -void pool_init(Pool *s, int num_bufs) { - assert(num_bufs > 3); - - memset(s, 0, sizeof(*s)); - s->num_bufs = num_bufs; - - s->refcnt = (int*)calloc(num_bufs, sizeof(int)); - s->ts = (int*)calloc(num_bufs, sizeof(int)); - - s->counter = 1; - - pthread_mutex_init(&s->lock, NULL); -} - -void pool_init2(Pool *s, int num_bufs, - void (*release_cb)(void* c, int idx), void* cb_cookie) { - - pool_init(s, num_bufs); - s->cb_cookie = cb_cookie; - s->release_cb = release_cb; - -} - - -void pool_acquire(Pool *s, int idx) { - pthread_mutex_lock(&s->lock); - - assert(idx >= 0 && idx < s->num_bufs); - - s->refcnt[idx]++; - - pthread_mutex_unlock(&s->lock); -} - -static void pool_release_locked(Pool *s, int idx) { - // printf("release %d refcnt %d\n", idx, s->refcnt[idx]); - - assert(idx >= 0 && idx < s->num_bufs); - - assert(s->refcnt[idx] > 0); - s->refcnt[idx]--; - - // printf("release %d -> %d, %p\n", idx, s->refcnt[idx], s->release_cb); - if (s->refcnt[idx] == 0 && s->release_cb) { - // printf("call %p\b", s->release_cb); - s->release_cb(s->cb_cookie, idx); - } -} - -void pool_release(Pool *s, int idx) { - pthread_mutex_lock(&s->lock); - pool_release_locked(s, idx); - pthread_mutex_unlock(&s->lock); -} - -TBuffer* pool_get_tbuffer(Pool *s) { - pthread_mutex_lock(&s->lock); - - assert(s->num_tbufs < POOL_MAX_TBUFS); - TBuffer* tbuf = &s->tbufs[s->num_tbufs]; - s->num_tbufs++; - tbuffer_init2(tbuf, s->num_bufs, - "pool", (void (*)(void *, int))pool_release, s); - - bool stopped = s->stopped; - pthread_mutex_unlock(&s->lock); - - // Stop the tbuffer so we can return a valid object. - // We must stop here because the pool_stop may have already been called, - // in which case tbuffer_stop may never be called again. - if (stopped) { - tbuffer_stop(tbuf); - } - return tbuf; -} - -PoolQueue* pool_get_queue(Pool *s) { - pthread_mutex_lock(&s->lock); - - int i; - for (i = 0; i < POOL_MAX_QUEUES; i++) { - if (!s->queues[i].inited) { - break; - } - } - assert(i < POOL_MAX_QUEUES); - - PoolQueue *c = &s->queues[i]; - memset(c, 0, sizeof(*c)); - - c->pool = s; - c->inited = true; - - c->efd = efd_init(); - assert(c->efd >= 0); - - c->num_bufs = s->num_bufs; - c->num = c->num_bufs+1; - c->idx = (int*)malloc(sizeof(int)*c->num); - memset(c->idx, -1, sizeof(int)*c->num); - - pthread_mutex_init(&c->lock, NULL); - pthread_cond_init(&c->cv, NULL); - - pthread_mutex_unlock(&s->lock); - return c; -} - -void pool_release_queue(PoolQueue *c) { - Pool *s = c->pool; - - pthread_mutex_lock(&s->lock); - pthread_mutex_lock(&c->lock); - - for (int i=0; inum; i++) { - if (c->idx[i] != -1) { - pool_release_locked(s, c->idx[i]); - } - } - - close(c->efd); - free(c->idx); - - c->inited = false; - - pthread_mutex_unlock(&c->lock); - - pthread_mutex_destroy(&c->lock); - pthread_cond_destroy(&c->cv); - - pthread_mutex_unlock(&s->lock); -} - -int pool_select(Pool *s) { - pthread_mutex_lock(&s->lock); - - int i; - for (i=0; inum_bufs; i++) { - if (s->refcnt[i] == 0) { - break; - } - } - - if (i >= s->num_bufs) { - // overwrite the oldest - // still being using in a queue or tbuffer :/ - - int min_k = 0; - int min_ts = s->ts[0]; - for (int k=1; knum_bufs; k++) { - if (s->ts[k] < min_ts) { - min_ts = s->ts[k]; - min_k = k; - } - } - i = min_k; - printf("pool is full! evicted %d\n", min_k); - - // might be really bad if the user is doing pointery stuff - if (s->release_cb) { - s->release_cb(s->cb_cookie, min_k); - } - } - - s->refcnt[i]++; - - s->ts[i] = s->counter; - s->counter++; - - pthread_mutex_unlock(&s->lock); - - return i; -} - -void pool_push(Pool *s, int idx) { - pthread_mutex_lock(&s->lock); - - // printf("push %d head %d tail %d\n", idx, s->head, s->tail); - - assert(idx >= 0 && idx < s->num_bufs); - - s->ts[idx] = s->counter; - s->counter++; - - assert(s->refcnt[idx] > 0); - s->refcnt[idx]--; //push is a implcit release - - int num_tbufs = s->num_tbufs; - s->refcnt[idx] += num_tbufs; - - // dispatch pool queues - 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 - pthread_mutex_unlock(&c->lock); - continue; - } - - s->refcnt[idx]++; - - c->idx[c->head] = idx; - c->head = (c->head+1) % c->num; - assert(c->head != c->tail); - pthread_mutex_unlock(&c->lock); - - efd_write(c->efd); - pthread_cond_signal(&c->cv); - } - - pthread_mutex_unlock(&s->lock); - - for (int i=0; itbufs[i], idx); - } -} - -int poolq_pop(PoolQueue *c) { - pthread_mutex_lock(&c->lock); - - if (c->stopped) { - pthread_mutex_unlock(&c->lock); - return -1; - } - - while (c->head == c->tail) { - pthread_cond_wait(&c->cv, &c->lock); - - if (c->stopped) { - pthread_mutex_unlock(&c->lock); - return -1; - } - } - - // printf("pop head %d tail %d\n", s->head, s->tail); - - assert(c->head != c->tail); - - int r = c->idx[c->tail]; - c->idx[c->tail] = -1; - c->tail = (c->tail+1) % c->num; - - // queue event is level triggered - if (c->head == c->tail) { - efd_clear(c->efd); - } - - // printf("pop %d head %d tail %d\n", r, s->head, s->tail); - - assert(r >= 0 && r < c->num_bufs); - - pthread_mutex_unlock(&c->lock); - - return r; -} - -int poolq_efd(PoolQueue *c) { - return c->efd; -} - -void poolq_release(PoolQueue *c, int idx) { - pool_release(c->pool, idx); -} - -void pool_stop(Pool *s) { - for (int i=0; inum_tbufs; i++) { - tbuffer_stop(&s->tbufs[i]); - } - - pthread_mutex_lock(&s->lock); - s->stopped = true; - for (int i=0; iqueues[i]; - if (!c->inited) continue; - - pthread_mutex_lock(&c->lock); - c->stopped = true; - pthread_mutex_unlock(&c->lock); - efd_write(c->efd); - pthread_cond_signal(&c->cv); - } - pthread_mutex_unlock(&s->lock); -} diff --git a/selfdrive/common/buffering.h b/selfdrive/common/buffering.h deleted file mode 100644 index fda4c644928423..00000000000000 --- a/selfdrive/common/buffering.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef BUFFERING_H -#define BUFFERING_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// Tripple buffering helper - -typedef struct TBuffer { - pthread_mutex_t lock; - pthread_cond_t cv; - int efd; - - bool* reading; - int pending_idx; - - int num_bufs; - const char* name; - - void (*release_cb)(void* c, int idx); - void *cb_cookie; - - bool stopped; -} TBuffer; - -// num_bufs must be at least the number of buffers that can be acquired simultaniously plus two -void tbuffer_init(TBuffer *tb, int num_bufs, const char* name); - -void tbuffer_init2(TBuffer *tb, int num_bufs, const char* name, - void (*release_cb)(void* c, int idx), - void* cb_cookie); - -// returns an eventfd that signals if a buffer is ready and tbuffer_acquire shouldn't to block. -// useful to polling on multiple tbuffers. -int tbuffer_efd(TBuffer *tb); - -// Chooses a buffer that's not reading or pending -int tbuffer_select(TBuffer *tb); - -// Called when the writer is done with their buffer -// - Wakes up the reader if it's waiting -// - releases the pending buffer if the reader's too slow -void tbuffer_dispatch(TBuffer *tb, int idx); - -// Called when the reader wants a new buffer, will return -1 when stopped -int tbuffer_acquire(TBuffer *tb); - -// Called when the reader is done with their buffer -void tbuffer_release(TBuffer *tb, int idx); - -void tbuffer_release_all(TBuffer *tb); - -void tbuffer_stop(TBuffer *tb); - - - - -// pool: buffer pool + queue thing... - -#define POOL_MAX_TBUFS 8 -#define POOL_MAX_QUEUES 8 - -typedef struct Pool Pool; - -typedef struct PoolQueue { - pthread_mutex_t lock; - pthread_cond_t cv; - Pool* pool; - bool inited; - bool stopped; - int efd; - int num_bufs; - int num; - int head, tail; - int* idx; -} PoolQueue; - -int poolq_pop(PoolQueue *s); -int poolq_efd(PoolQueue *s); -void poolq_release(PoolQueue *c, int idx); - -typedef struct Pool { - pthread_mutex_t lock; - bool stopped; - int num_bufs; - int counter; - - int* ts; - int* refcnt; - - void (*release_cb)(void* c, int idx); - void *cb_cookie; - - int num_tbufs; - TBuffer tbufs[POOL_MAX_TBUFS]; - PoolQueue queues[POOL_MAX_QUEUES]; -} Pool; - -void pool_init(Pool *s, int num_bufs); -void pool_init2(Pool *s, int num_bufs, - void (*release_cb)(void* c, int idx), void* cb_cookie); - -TBuffer* pool_get_tbuffer(Pool *s); - -PoolQueue* pool_get_queue(Pool *s); -void pool_release_queue(PoolQueue *q); - -int pool_select(Pool *s); -void pool_push(Pool *s, int idx); -void pool_acquire(Pool *s, int idx); -void pool_release(Pool *s, int idx); -void pool_stop(Pool *s); - - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif 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..313978525e067a --- /dev/null +++ b/selfdrive/common/clutil.cc @@ -0,0 +1,193 @@ +#include "selfdrive/common/clutil.h" + +#include +#include +#include + +#include "selfdrive/common/util.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) { + return cl_program_from_source(ctx, device_id, util::read_file(path), args); +} + +cl_program cl_program_from_source(cl_context ctx, cl_device_id device_id, const std::string& src, const char* args) { + 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; +} + +cl_program cl_program_from_binary(cl_context ctx, cl_device_id device_id, const uint8_t* binary, size_t length, const char* args) { + cl_program prg = CL_CHECK_ERR(clCreateProgramWithBinary(ctx, 1, &device_id, &length, (const uint8_t*[]){binary}, 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 representation +#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..be1a07c332a68a --- /dev/null +++ b/selfdrive/common/clutil.h @@ -0,0 +1,28 @@ +#pragma once + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include + +#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_source(cl_context ctx, cl_device_id device_id, const std::string& src, const char* args = nullptr); +cl_program cl_program_from_binary(cl_context ctx, cl_device_id device_id, const uint8_t* binary, size_t length, const char* args = nullptr); +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); diff --git a/selfdrive/common/cqueue.c b/selfdrive/common/cqueue.c deleted file mode 100644 index fe2c6f4ebff1ae..00000000000000 --- a/selfdrive/common/cqueue.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -#include "cqueue.h" - -void queue_init(Queue *q) { - memset(q, 0, sizeof(*q)); - TAILQ_INIT(&q->q); - pthread_mutex_init(&q->lock, NULL); - pthread_cond_init(&q->cv, NULL); -} - -void* queue_pop(Queue *q) { - pthread_mutex_lock(&q->lock); - while (TAILQ_EMPTY(&q->q)) { - pthread_cond_wait(&q->cv, &q->lock); - } - QueueEntry *entry = TAILQ_FIRST(&q->q); - TAILQ_REMOVE(&q->q, entry, entries); - pthread_mutex_unlock(&q->lock); - - void* r = entry->data; - free(entry); - return r; -} - -void* queue_try_pop(Queue *q) { - pthread_mutex_lock(&q->lock); - - void* r = NULL; - if (!TAILQ_EMPTY(&q->q)) { - QueueEntry *entry = TAILQ_FIRST(&q->q); - TAILQ_REMOVE(&q->q, entry, entries); - r = entry->data; - free(entry); - } - - pthread_mutex_unlock(&q->lock); - return r; -} - -void queue_push(Queue *q, void *data) { - QueueEntry *entry = calloc(1, sizeof(QueueEntry)); - assert(entry); - entry->data = data; - - pthread_mutex_lock(&q->lock); - TAILQ_INSERT_TAIL(&q->q, entry, entries); - pthread_cond_signal(&q->cv); - pthread_mutex_unlock(&q->lock); -} diff --git a/selfdrive/common/cqueue.h b/selfdrive/common/cqueue.h deleted file mode 100644 index f2613660b21405..00000000000000 --- a/selfdrive/common/cqueue.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef COMMON_CQUEUE_H -#define COMMON_CQUEUE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// a blocking queue - -typedef struct QueueEntry { - TAILQ_ENTRY(QueueEntry) entries; - void *data; -} QueueEntry; - -typedef struct Queue { - TAILQ_HEAD(queue, QueueEntry) q; - pthread_mutex_t lock; - pthread_cond_t cv; -} Queue; - -void queue_init(Queue *q); -void* queue_pop(Queue *q); -void* queue_try_pop(Queue *q); -void queue_push(Queue *q, void *data); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/selfdrive/common/efd.c b/selfdrive/common/efd.c deleted file mode 100644 index 78a7c098949b56..00000000000000 --- a/selfdrive/common/efd.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include - -#ifdef __linux__ -#include -#else -#include -#include -#define EVENT_IDENT 42 -#endif - -#include "efd.h" - - -int efd_init() { -#ifdef __linux__ - return eventfd(0, EFD_CLOEXEC); -#else - int fd = kqueue(); - assert(fd >= 0); - - struct kevent kev; - EV_SET(&kev, EVENT_IDENT, EVFILT_USER, EV_ADD | EV_CLEAR, 0, 0, NULL); - - struct timespec timeout = {0, 0}; - int err = kevent(fd, &kev, 1, NULL, 0, &timeout); - assert(err != -1); - - return fd; -#endif -} - -void efd_write(int fd) { -#ifdef __linux__ - eventfd_write(fd, 1); -#else - struct kevent kev; - EV_SET(&kev, EVENT_IDENT, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL); - - struct timespec timeout = {0, 0}; - int err = kevent(fd, &kev, 1, NULL, 0, &timeout); - assert(err != -1); -#endif -} - -void efd_clear(int fd) { -#ifdef __linux__ - eventfd_t efd_cnt; - eventfd_read(fd, &efd_cnt); -#else - struct kevent kev; - struct timespec timeout = {0, 0}; - int nfds = kevent(fd, NULL, 0, &kev, 1, &timeout); - assert(nfds != -1); -#endif -} diff --git a/selfdrive/common/efd.h b/selfdrive/common/efd.h deleted file mode 100644 index 056482ffa51f3e..00000000000000 --- a/selfdrive/common/efd.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef EFD_H -#define EFD_H - -#ifdef __cplusplus -extern "C" { -#endif - -// event fd: a semaphore that can be poll()'d -int efd_init(); -void efd_write(int fd); -void efd_clear(int fd); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/selfdrive/common/framebuffer.cc b/selfdrive/common/framebuffer.cc deleted file mode 100644 index 757c2a1ead46f0..00000000000000 --- a/selfdrive/common/framebuffer.cc +++ /dev/null @@ -1,141 +0,0 @@ - -#include -#include -#include - -#include - -#include -#include -#include - - -#include -#include - -#define BACKLIGHT_CONTROL "/sys/class/leds/lcd-backlight/brightness" -#define BACKLIGHT_LEVEL "205" - -using namespace android; - -struct FramebufferState { - sp session; - sp dtoken; - DisplayInfo dinfo; - sp control; - - sp s; - EGLDisplay display; - - EGLint egl_major, egl_minor; - EGLConfig config; - EGLSurface surface; - EGLContext context; -}; - -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; - - FramebufferState *s = new FramebufferState; - - s->session = new SurfaceComposerClient(); - assert(s->session != NULL); - - s->dtoken = SurfaceComposerClient::getBuiltInDisplay( - ISurfaceComposer::eDisplayIdMain); - assert(s->dtoken != NULL); - - status = SurfaceComposerClient::getDisplayInfo(s->dtoken, &s->dinfo); - assert(status == 0); - - //int orientation = 3; // rotate framebuffer 270 degrees - int orientation = 1; // rotate framebuffer 90 degrees - if(orientation == 1 || orientation == 3) { - int temp = s->dinfo.h; - s->dinfo.h = s->dinfo.w; - s->dinfo.w = temp; - } - - printf("dinfo %dx%d\n", s->dinfo.w, s->dinfo.h); - - Rect destRect(s->dinfo.w, s->dinfo.h); - s->session->setDisplayProjection(s->dtoken, orientation, destRect, destRect); - - s->control = s->session->createSurface(String8(name), - s->dinfo.w, s->dinfo.h, PIXEL_FORMAT_RGBX_8888); - assert(s->control != NULL); - - SurfaceComposerClient::openGlobalTransaction(); - status = s->control->setLayer(layer); - SurfaceComposerClient::closeGlobalTransaction(); - assert(status == 0); - - s->s = s->control->getSurface(); - assert(s->s != NULL); - - // init opengl and egl - const EGLint attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, alpha ? 8 : 0, - EGL_DEPTH_SIZE, 0, - EGL_STENCIL_SIZE, 8, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR, - EGL_NONE, - }; - - s->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - assert(s->display != EGL_NO_DISPLAY); - - success = eglInitialize(s->display, &s->egl_major, &s->egl_minor); - 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); - - s->surface = eglCreateWindowSurface(s->display, s->config, s->s.get(), NULL); - assert(s->surface != EGL_NO_SURFACE); - - const EGLint context_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 3, - EGL_NONE, - }; - s->context = eglCreateContext(s->display, s->config, NULL, context_attribs); - assert(s->context != EGL_NO_CONTEXT); - - EGLint w, h; - eglQuerySurface(s->display, s->surface, EGL_WIDTH, &w); - eglQuerySurface(s->display, s->surface, EGL_HEIGHT, &h); - printf("egl w %d h %d\n", w, h); - - success = eglMakeCurrent(s->display, s->surface, s->surface, s->context); - assert(success); - - printf("gl version %s\n", glGetString(GL_VERSION)); - - - // 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; - - return s; -} diff --git a/selfdrive/common/framebuffer.h b/selfdrive/common/framebuffer.h deleted file mode 100644 index 6091eebce50780..00000000000000 --- a/selfdrive/common/framebuffer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef FRAMEBUFFER_H -#define FRAMEBUFFER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -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); - -/* Display power modes */ -enum { - /* The display is turned off (blanked). */ - HWC_POWER_MODE_OFF = 0, - /* The display is turned on and configured in a low power state - * that is suitable for presenting ambient information to the user, - * possibly with lower fidelity than normal but greater efficiency. */ - HWC_POWER_MODE_DOZE = 1, - /* The display is turned on normally. */ - HWC_POWER_MODE_NORMAL = 2, - /* The display is configured as in HWC_POWER_MODE_DOZE but may - * stop applying frame buffer updates from the graphics subsystem. - * This power mode is effectively a hint from the doze dream to - * tell the hardware that it is done drawing to the display for the - * time being and that the display should remain on in a low power - * state and continue showing its current contents indefinitely - * until the mode changes. - * - * This mode may also be used as a signal to enable hardware-based doze - * functionality. In this case, the doze dream is effectively - * indicating that the hardware is free to take over the display - * and manage it autonomously to implement low power always-on display - * functionality. */ - HWC_POWER_MODE_DOZE_SUSPEND = 3, -}; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/selfdrive/common/glutil.c b/selfdrive/common/glutil.c deleted file mode 100644 index d118dd8af68451..00000000000000 --- a/selfdrive/common/glutil.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include - -#include - -#include "glutil.h" - -GLuint load_shader(GLenum shaderType, const char *src) { - GLint status = 0, len = 0; - GLuint shader; - - if (!(shader = glCreateShader(shaderType))) - return 0; - - glShaderSource(shader, 1, &src, NULL); - glCompileShader(shader); - glGetShaderiv(shader, GL_COMPILE_STATUS, &status); - - if (status) - return shader; - - glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); - if (len) { - char *msg = (char*)malloc(len); - if (msg) { - glGetShaderInfoLog(shader, len, NULL, msg); - msg[len-1] = 0; - fprintf(stderr, "error compiling shader:\n%s\n", msg); - free(msg); - } - } - glDeleteShader(shader); - return 0; -} - -GLuint load_program(const char *vert_src, const char *frag_src) { - GLuint vert, frag, prog; - GLint status = 0, len = 0; - - if (!(vert = load_shader(GL_VERTEX_SHADER, vert_src))) - return 0; - if (!(frag = load_shader(GL_FRAGMENT_SHADER, frag_src))) - goto fail_frag; - if (!(prog = glCreateProgram())) - goto fail_prog; - - glAttachShader(prog, vert); - glAttachShader(prog, frag); - glLinkProgram(prog); - - glGetProgramiv(prog, GL_LINK_STATUS, &status); - if (status) - return prog; - - glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len); - if (len) { - char *buf = (char*) malloc(len); - if (buf) { - glGetProgramInfoLog(prog, len, NULL, buf); - buf[len-1] = 0; - fprintf(stderr, "error linking program:\n%s\n", buf); - free(buf); - } - } - glDeleteProgram(prog); -fail_prog: - glDeleteShader(frag); -fail_frag: - glDeleteShader(vert); - return 0; -} diff --git a/selfdrive/common/glutil.h b/selfdrive/common/glutil.h deleted file mode 100644 index 68d6cfa630d3c1..00000000000000 --- a/selfdrive/common/glutil.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef COMMON_GLUTIL_H -#define COMMON_GLUTIL_H - -#include -GLuint load_shader(GLenum shaderType, const char *src); -GLuint load_program(const char *vert_src, const char *frag_src); - -#endif diff --git a/selfdrive/common/gpio.cc b/selfdrive/common/gpio.cc new file mode 100644 index 00000000000000..033d6da4f76ebb --- /dev/null +++ b/selfdrive/common/gpio.cc @@ -0,0 +1,32 @@ +#include "selfdrive/common/gpio.h" + +#include +#include + +#include + +#include "selfdrive/common/util.h" + +// 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 util::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 util::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..e030019875fb4a --- /dev/null +++ b/selfdrive/common/gpio.h @@ -0,0 +1,21 @@ +#pragma once + +// 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 + +int gpio_init(int pin_nr, bool output); +int gpio_set(int pin_nr, bool high); diff --git a/selfdrive/common/i2c.cc b/selfdrive/common/i2c.cc new file mode 100644 index 00000000000000..5e6488fabfbc3d --- /dev/null +++ b/selfdrive/common/i2c.cc @@ -0,0 +1,87 @@ +#include "selfdrive/common/i2c.h" + +#include +#include +#include + +#include +#include +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.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 = HANDLE_EINTR(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 = HANDLE_EINTR(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 = HANDLE_EINTR(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..0669116bb86733 --- /dev/null +++ b/selfdrive/common/i2c.h @@ -0,0 +1,17 @@ +#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 deleted file mode 100644 index 8d391074786815..00000000000000 --- a/selfdrive/common/ipc.c +++ /dev/null @@ -1,119 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "ipc.h" - -int ipc_connect(const char* socket_path) { - int err; - - int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0); - assert(sock >= 0); - struct sockaddr_un addr = { - .sun_family = AF_UNIX, - }; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); - err = connect(sock, (struct sockaddr*)&addr, sizeof(addr)); - if (err != 0) { - close(sock); - return -1; - } - - return sock; -} - -int ipc_bind(const char* socket_path) { - int err; - - unlink(socket_path); - - int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0); - struct sockaddr_un addr = { - .sun_family = AF_UNIX, - }; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); - err = bind(sock, (struct sockaddr *)&addr, sizeof(addr)); - assert(err == 0); - - err = listen(sock, 3); - assert(err == 0); - - return sock; -} - - -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)); - - struct iovec iov = { - .iov_base = buf, - .iov_len = buf_size, - }; - struct msghdr msg = { - .msg_iov = &iov, - .msg_iovlen = 1, - }; - - if (num_fds > 0) { - assert(fds); - - msg.msg_control = control_buf; - msg.msg_controllen = CMSG_SPACE(sizeof(int) * num_fds); - } - - if (send) { - if (num_fds) { - struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); - assert(cmsg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds); - memcpy(CMSG_DATA(cmsg), fds, sizeof(int) * num_fds); - // printf("send clen %d -> %d\n", num_fds, cmsg->cmsg_len); - } - return sendmsg(fd, &msg, 0); - } else { - int r = recvmsg(fd, &msg, 0); - if (r < 0) return r; - - int recv_fds = 0; - if (msg.msg_controllen > 0) { - struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); - assert(cmsg); - assert(cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS); - recv_fds = (cmsg->cmsg_len - CMSG_LEN(0)); - assert(recv_fds > 0 && (recv_fds % sizeof(int)) == 0); - recv_fds /= sizeof(int); - // printf("recv clen %d -> %d\n", cmsg->cmsg_len, recv_fds); - // assert(cmsg->cmsg_len == CMSG_LEN(sizeof(int) * num_fds)); - - assert(fds && recv_fds <= num_fds); - memcpy(fds, CMSG_DATA(cmsg), sizeof(int) * recv_fds); - } - - if (msg.msg_flags) { - for (int i=0; i - -#ifdef __cplusplus -extern "C" { -#endif - -int ipc_connect(const char* socket_path); -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); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif \ No newline at end of file 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 b5b38bafd8b14e..9a9414cfa31f12 100644 --- a/selfdrive/common/modeldata.h +++ b/selfdrive/common/modeldata.h @@ -1,30 +1,70 @@ -#ifndef MODELDATA_H -#define MODELDATA_H - -#define MODEL_PATH_DISTANCE 100 -#define POLYFIT_DEGREE 4 - -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_v; - float rel_v_std; -} LeadData; - -typedef struct ModelData { - PathData path; - PathData left_lane; - PathData right_lane; - LeadData lead; -} ModelData; - -#endif +#pragma once + +#include +#include "selfdrive/common/mat.h" +#include "selfdrive/hardware/hw.h" + +const int TRAJECTORY_SIZE = 33; +const int LAT_MPC_N = 16; +const int LON_MPC_N = 32; +const float MIN_DRAW_DISTANCE = 10.0; +const float MAX_DRAW_DISTANCE = 100.0; + +template +const std::array convert_array_to_type(const std::array &src) { + std::array dst = {}; + for (int i=0; i T_IDXS = { + 0. , 0.00976562, 0.0390625 , 0.08789062, 0.15625 , + 0.24414062, 0.3515625 , 0.47851562, 0.625 , 0.79101562, + 0.9765625 , 1.18164062, 1.40625 , 1.65039062, 1.9140625 , + 2.19726562, 2.5 , 2.82226562, 3.1640625 , 3.52539062, + 3.90625 , 4.30664062, 4.7265625 , 5.16601562, 5.625 , + 6.10351562, 6.6015625 , 7.11914062, 7.65625 , 8.21289062, + 8.7890625 , 9.38476562, 10.}; +const auto T_IDXS_FLOAT = convert_array_to_type(T_IDXS); + +const std::array X_IDXS = { + 0. , 0.1875, 0.75 , 1.6875, 3. , 4.6875, + 6.75 , 9.1875, 12. , 15.1875, 18.75 , 22.6875, + 27. , 31.6875, 36.75 , 42.1875, 48. , 54.1875, + 60.75 , 67.6875, 75. , 82.6875, 90.75 , 99.1875, + 108. , 117.1875, 126.75 , 136.6875, 147. , 157.6875, + 168.75 , 180.1875, 192.}; +const auto X_IDXS_FLOAT = convert_array_to_type(X_IDXS); + +const int TICI_CAM_WIDTH = 1928; + +namespace tici_dm_crop { + const int x_offset = -72; + const int y_offset = -144; + const int width = 954; +}; + +const mat3 fcam_intrinsic_matrix = + Hardware::EON() ? (mat3){{910., 0., 1164.0 / 2, + 0., 910., 874.0 / 2, + 0., 0., 1.}} + : (mat3){{2648.0, 0.0, 1928.0 / 2, + 0.0, 2648.0, 1208.0 / 2, + 0.0, 0.0, 1.0}}; + +// without unwarp, focal length is for center portion only +const mat3 ecam_intrinsic_matrix = (mat3){{620.0, 0.0, 1928.0 / 2, + 0.0, 620.0, 1208.0 / 2, + 0.0, 0.0, 1.0}}; + +static inline mat3 get_model_yuv_transform(bool bayer = true) { + float db_s = Hardware::EON() ? 0.5 : 1.0; // debayering does a 2x downscale on EON + const mat3 transform = (mat3){{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 + }}; + return bayer ? transform_scale_buffer(transform, db_s) : transform; +} diff --git a/selfdrive/common/mutex.h b/selfdrive/common/mutex.h deleted file mode 100644 index ef0135935736f4..00000000000000 --- a/selfdrive/common/mutex.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef COMMON_MUTEX_H -#define COMMON_MUTEX_H - -#include - -static inline void mutex_init_reentrant(pthread_mutex_t *mutex) { - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(mutex, &attr); -} - -#endif diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 7bbcf5fad11c60..a405d21609db89 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -1,196 +1,276 @@ -#include "common/params.h" +#include "selfdrive/common/params.h" -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif // _GNU_SOURCE - -#include -#include -#include #include #include -#include -#include +#include +#include -#include "common/util.h" -#include "common/utilpp.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" namespace { -template -T* null_coalesce(T* a, T* b) { - return a != NULL ? a : b; +volatile sig_atomic_t params_do_exit = 0; +void params_sig_handler(int signal) { + params_do_exit = 1; } -static const char* default_params_path = null_coalesce( - const_cast(getenv("PARAMS_PATH")), "/data/params"); - -} // namespace - -int write_db_value(const char* params_path, const char* key, const char* value, - size_t value_size) { - int lock_fd = -1; - int tmp_fd = -1; - int result; - char tmp_path[1024]; - char path[1024]; - ssize_t bytes_written; - - if (params_path == NULL) { - params_path = default_params_path; +int fsync_dir(const std::string &path) { + int result = -1; + int fd = HANDLE_EINTR(open(path.c_str(), O_RDONLY, 0755)); + if (fd >= 0) { + result = fsync(fd); + close(fd); } + return result; +} - // Write value to temp. - result = - snprintf(tmp_path, sizeof(tmp_path), "%s/.tmp_value_XXXXXX", params_path); - if (result < 0) { - goto cleanup; +bool create_params_path(const std::string ¶m_path, const std::string &key_path) { + // Make sure params path exists + if (!util::file_exists(param_path) && !util::create_directories(param_path, 0775)) { + return false; } - tmp_fd = mkstemp(tmp_path); - bytes_written = write(tmp_fd, value, value_size); - if (bytes_written != value_size) { - result = -20; - goto cleanup; - } + // See if the symlink exists, otherwise create it + if (!util::file_exists(key_path)) { + // 1) Create temp folder + // 2) Symlink it to temp link + // 3) Move symlink to /d + + std::string tmp_path = param_path + "/.tmp_XXXXXX"; + // this should be OK since mkdtemp just replaces characters in place + char *tmp_dir = mkdtemp((char *)tmp_path.c_str()); + if (tmp_dir == NULL) { + return false; + } - result = snprintf(path, sizeof(path), "%s/.lock", params_path); - if (result < 0) { - goto cleanup; - } - lock_fd = open(path, 0); + std::string link_path = std::string(tmp_dir) + ".link"; + if (symlink(tmp_dir, link_path.c_str()) != 0) { + return false; + } - result = snprintf(path, sizeof(path), "%s/d/%s", params_path, key); - if (result < 0) { - goto cleanup; + // don't return false if it has been created by other + if (rename(link_path.c_str(), key_path.c_str()) != 0 && errno != EEXIST) { + return false; + } } - // Take lock. - result = flock(lock_fd, LOCK_EX); - if (result < 0) { - goto cleanup; - } + return true; +} - // fsync to force persist the changes. - result = fsync(tmp_fd); - if (result < 0) { - goto cleanup; +std::string ensure_params_path(const std::string &path = {}) { + std::string params_path = path.empty() ? Path::params() : path; + if (!create_params_path(params_path, params_path + "/d")) { + throw std::runtime_error(util::string_format("Failed to ensure params path, errno=%d", errno)); } + return params_path; +} - // Move temp into place. - result = rename(tmp_path, path); - -cleanup: - // Release lock. - if (lock_fd >= 0) { - close(lock_fd); - } - if (tmp_fd >= 0) { - if (result < 0) { - remove(tmp_path); +class FileLock { +public: + FileLock(const std::string &fn) { + fd_ = HANDLE_EINTR(open(fn.c_str(), O_CREAT, 0775)); + if (fd_ < 0 || HANDLE_EINTR(flock(fd_, LOCK_EX)) < 0) { + LOGE("Failed to lock file %s, errno=%d", fn.c_str(), errno); } - close(tmp_fd); } - return result; + ~FileLock() { close(fd_); } + +private: + int fd_ = -1; +}; + +std::unordered_map keys = { + {"AccessToken", CLEAR_ON_MANAGER_START | DONT_LOG}, + {"AthenadPid", PERSISTENT}, + {"BootedOnroad", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, + {"CalibrationParams", PERSISTENT}, + {"CarBatteryCapacity", PERSISTENT}, + {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, + {"CarParamsCache", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, + {"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, + {"CommunityFeaturesToggle", PERSISTENT}, + {"CompletedTrainingVersion", PERSISTENT}, + {"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, + {"CurrentRoute", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, + {"DisablePowerDown", PERSISTENT}, + {"DisableRadar_Allow", PERSISTENT}, + {"DisableRadar", PERSISTENT}, // WARNING: THIS DISABLES AEB + {"DisableUpdates", PERSISTENT}, + {"DongleId", PERSISTENT}, + {"DoReboot", CLEAR_ON_MANAGER_START}, + {"DoShutdown", CLEAR_ON_MANAGER_START}, + {"DoUninstall", CLEAR_ON_MANAGER_START}, + {"EnableWideCamera", CLEAR_ON_MANAGER_START}, + {"EndToEndToggle", PERSISTENT}, + {"ForcePowerDown", CLEAR_ON_MANAGER_START}, + {"GitBranch", PERSISTENT}, + {"GitCommit", PERSISTENT}, + {"GitDiff", PERSISTENT}, + {"GithubSshKeys", PERSISTENT}, + {"GithubUsername", PERSISTENT}, + {"GitRemote", PERSISTENT}, + {"GsmApn", PERSISTENT}, + {"GsmRoaming", PERSISTENT}, + {"HardwareSerial", PERSISTENT}, + {"HasAcceptedTerms", PERSISTENT}, + {"HasPrime", PERSISTENT}, + {"IMEI", PERSISTENT}, + {"InstallDate", PERSISTENT}, + {"IsDriverViewEnabled", CLEAR_ON_MANAGER_START}, + {"IsLdwEnabled", PERSISTENT}, + {"IsMetric", PERSISTENT}, + {"IsOffroad", CLEAR_ON_MANAGER_START}, + {"IsOnroad", PERSISTENT}, + {"IsRHD", PERSISTENT}, + {"IsTakingSnapshot", CLEAR_ON_MANAGER_START}, + {"IsUpdateAvailable", CLEAR_ON_MANAGER_START}, + {"JoystickDebugMode", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, + {"LastAthenaPingTime", CLEAR_ON_MANAGER_START}, + {"LastGPSPosition", PERSISTENT}, + {"LastPowerDropDetected", CLEAR_ON_MANAGER_START}, + {"LastUpdateException", PERSISTENT}, + {"LastUpdateTime", PERSISTENT}, + {"LiveParameters", PERSISTENT}, + {"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, + {"NavSettingTime24h", PERSISTENT}, + {"NavdRender", PERSISTENT}, + {"OpenpilotEnabledToggle", PERSISTENT}, + {"PandaHeartbeatLost", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, + {"Passive", PERSISTENT}, + {"PrimeRedirected", PERSISTENT}, + {"RecordFront", PERSISTENT}, + {"RecordFrontLock", PERSISTENT}, // for the internal fleet + {"ReleaseNotes", PERSISTENT}, + {"ShouldDoUpdate", CLEAR_ON_MANAGER_START}, + {"SnoozeUpdate", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, + {"SshEnabled", PERSISTENT}, + {"SubscriberInfo", PERSISTENT}, + {"TermsVersion", PERSISTENT}, + {"Timezone", PERSISTENT}, + {"TrainingVersion", PERSISTENT}, + {"UpdateAvailable", CLEAR_ON_MANAGER_START}, + {"UpdateFailedCount", CLEAR_ON_MANAGER_START}, + {"Version", PERSISTENT}, + {"VisionRadarToggle", PERSISTENT}, + {"ApiCache_Device", PERSISTENT}, + {"ApiCache_DriveStats", PERSISTENT}, + {"ApiCache_NavDestinations", PERSISTENT}, + {"ApiCache_Owner", PERSISTENT}, + {"Offroad_CarUnrecognized", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, + {"Offroad_ChargeDisabled", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, + {"Offroad_ConnectivityNeeded", CLEAR_ON_MANAGER_START}, + {"Offroad_ConnectivityNeededPrompt", CLEAR_ON_MANAGER_START}, + {"Offroad_InvalidTime", CLEAR_ON_MANAGER_START}, + {"Offroad_IsTakingSnapshot", CLEAR_ON_MANAGER_START}, + {"Offroad_NeosUpdate", CLEAR_ON_MANAGER_START}, + {"Offroad_NoFirmware", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, + {"Offroad_StorageMissing", CLEAR_ON_MANAGER_START}, + {"Offroad_TemperatureTooHigh", CLEAR_ON_MANAGER_START}, + {"Offroad_UnofficialHardware", CLEAR_ON_MANAGER_START}, + {"Offroad_UpdateFailed", CLEAR_ON_MANAGER_START}, +}; + +} // namespace + +Params::Params(const std::string &path) { + static std::string default_param_path = ensure_params_path(); + params_path = path.empty() ? default_param_path : ensure_params_path(path); } -int read_db_value(const char* params_path, const char* key, char** value, - size_t* value_sz) { - int lock_fd = -1; - int result; - char path[1024]; +bool Params::checkKey(const std::string &key) { + return keys.find(key) != keys.end(); +} - if (params_path == NULL) { - params_path = default_params_path; - } +ParamKeyType Params::getKeyType(const std::string &key) { + return static_cast(keys[key]); +} - result = snprintf(path, sizeof(path), "%s/.lock", params_path); - if (result < 0) { - goto cleanup; - } - lock_fd = open(path, 0); +int Params::put(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 + std::string tmp_path = params_path + "/.tmp_value_XXXXXX"; + int tmp_fd = mkstemp((char*)tmp_path.c_str()); + if (tmp_fd < 0) return -1; + + int result = -1; + do { + // Write value to temp. + ssize_t bytes_written = HANDLE_EINTR(write(tmp_fd, value, value_size)); + if (bytes_written < 0 || (size_t)bytes_written != value_size) { + result = -20; + break; + } - result = snprintf(path, sizeof(path), "%s/d/%s", params_path, key); - if (result < 0) { - goto cleanup; - } + // fsync to force persist the changes. + if ((result = fsync(tmp_fd)) < 0) break; - // Take lock. - result = flock(lock_fd, LOCK_EX); - if (result < 0) { - goto cleanup; - } + FileLock file_lock(params_path + "/.lock"); - // 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; - goto cleanup; - } + // Move temp into place. + if ((result = rename(tmp_path.c_str(), getParamPath(key).c_str())) < 0) break; - // Remove one for null byte. - if (value_sz != NULL) { - *value_sz -= 1; - } - result = 0; + // fsync parent directory + result = fsync_dir(getParamPath()); + } while (false); -cleanup: - // Release lock. - if (lock_fd >= 0) { - close(lock_fd); - } + close(tmp_fd); + ::unlink(tmp_path.c_str()); 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); - if (result == 0) { - return; - } else { - // Sleep for 0.1 seconds. - usleep(100000); - } +int Params::remove(const std::string &key) { + FileLock file_lock(params_path + "/.lock"); + int result = unlink(getParamPath(key).c_str()); + if (result != 0) { + return result; } + return fsync_dir(getParamPath()); } -int read_db_all(const char* params_path, std::map *params) { - int err = 0; +std::string Params::get(const std::string &key, bool block) { + if (!block) { + return util::read_file(getParamPath(key)); + } else { + // blocking read until successful + 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); + + std::string value; + while (!params_do_exit) { + if (value = util::read_file(getParamPath(key)); !value.empty()) { + break; + } + util::sleep_for(100); // 0.1 s + } - if (params_path == NULL) { - params_path = default_params_path; + std::signal(SIGINT, prev_handler_sigint); + std::signal(SIGTERM, prev_handler_sigterm); + return value; } +} - std::string lock_path = util::string_format("%s/.lock", params_path); - - 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; - - std::string key_path = util::string_format("%s/d", params_path); - DIR *d = opendir(key_path.c_str()); - if (!d) { - close(lock_fd); - return -1; - } +std::map Params::readAll() { + FileLock file_lock(params_path + "/.lock"); + return util::read_files_in_dir(getParamPath()); +} - struct dirent *de = NULL; - while ((de = readdir(d))) { - if (!isalnum(de->d_name[0])) continue; - std::string key = std::string(de->d_name); - std::string value = util::read_file(util::string_format("%s/%s", key_path.c_str(), key.c_str())); +void Params::clearAll(ParamKeyType key_type) { + FileLock file_lock(params_path + "/.lock"); - (*params)[key] = value; + std::string path; + for (auto &[key, type] : keys) { + if (type & key_type) { + unlink(getParamPath(key).c_str()); + } } - closedir(d); - - close(lock_fd); - return 0; + fsync_dir(getParamPath()); } diff --git a/selfdrive/common/params.h b/selfdrive/common/params.h index 299dcccd0a412d..c4bdde0012f1a8 100644 --- a/selfdrive/common/params.h +++ b/selfdrive/common/params.h @@ -1,41 +1,47 @@ -#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_ +enum ParamKeyType { + PERSISTENT = 0x02, + CLEAR_ON_MANAGER_START = 0x04, + CLEAR_ON_PANDA_DISCONNECT = 0x08, + CLEAR_ON_IGNITION_ON = 0x10, + CLEAR_ON_IGNITION_OFF = 0x20, + DONT_LOG = 0x40, + ALL = 0xFFFFFFFF +}; + +class Params { +public: + Params(const std::string &path = {}); + bool checkKey(const std::string &key); + ParamKeyType getKeyType(const std::string &key); + inline std::string getParamPath(const std::string &key = {}) { + return key.empty() ? params_path + "/d" : params_path + "/d/" + key; + } + + // Delete a value + int remove(const std::string &key); + void clearAll(ParamKeyType type); + + // helpers for reading values + std::string get(const std::string &key, bool block = false); + inline bool getBool(const std::string &key) { + return get(key) == "1"; + } + std::map readAll(); + + // helpers for writing values + int put(const char *key, const char *val, size_t value_size); + inline int put(const std::string &key, const std::string &val) { + return put(key.c_str(), val.data(), val.size()); + } + inline int putBool(const std::string &key, bool val) { + return put(key.c_str(), val ? "1" : "0", 1); + } + +private: + std::string params_path; +}; diff --git a/selfdrive/common/queue.h b/selfdrive/common/queue.h new file mode 100644 index 00000000000000..b3558b11a47f49 --- /dev/null +++ b/selfdrive/common/queue.h @@ -0,0 +1,52 @@ +#pragma once + +#include +#include +#include + +template +class SafeQueue { +public: + SafeQueue() = default; + + void push(const T& v) { + { + std::unique_lock lk(m); + q.push(v); + } + cv.notify_one(); + } + + T pop() { + std::unique_lock lk(m); + cv.wait(lk, [this] { return !q.empty(); }); + T v = q.front(); + q.pop(); + return v; + } + + bool try_pop(T& v, int timeout_ms = 0) { + std::unique_lock lk(m); + if (!cv.wait_for(lk, std::chrono::milliseconds(timeout_ms), [this] { return !q.empty(); })) { + return false; + } + v = q.front(); + q.pop(); + return true; + } + + bool empty() const { + std::scoped_lock lk(m); + return q.empty(); + } + + size_t size() const { + std::scoped_lock lk(m); + return q.size(); + } + +private: + mutable std::mutex m; + std::condition_variable cv; + std::queue q; +}; 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..74488e2201e153 --- /dev/null +++ b/selfdrive/common/swaglog.cc @@ -0,0 +1,123 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include "selfdrive/common/swaglog.h" + +#include +#include +#include +#include + +#include +#include "json11.hpp" + +#include "selfdrive/common/util.h" +#include "selfdrive/common/version.h" +#include "selfdrive/hardware/hw.h" + +class LogState { + public: + LogState() = default; + ~LogState(); + std::mutex lock; + bool inited; + json11::Json::object ctx_j; + void *zctx; + void *sock; + int print_level; +}; + +LogState::~LogState() { + zmq_close(sock); + zmq_ctx_destroy(zctx); +} + +static LogState s = {}; + +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); + + int timeout = 100; // 100 ms timeout on shutdown for messages to be received by logmessaged + zmq_setsockopt(s.sock, ZMQ_LINGER, &timeout, sizeof(timeout)); + + 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"); + + // device type + if (Hardware::EON()) { + cloudlog_bind_locked("device", "eon"); + } else if (Hardware::TICI()) { + cloudlog_bind_locked("device", "tici"); + } else { + cloudlog_bind_locked("device", "pc"); + } + + s.inited = true; +} + +void log(int levelnum, const char* filename, int lineno, const char* func, const char* msg, const std::string& log_s) { + std::lock_guard lk(s.lock); + cloudlog_init(); + if (levelnum >= s.print_level) { + printf("%s: %s\n", filename, msg); + } + char levelnum_c = levelnum; + zmq_send(s.sock, (levelnum_c + log_s).c_str(), log_s.length() + 1, ZMQ_NOBLOCK); +} + +void cloudlog_e(int levelnum, const char* filename, int lineno, const char* func, + const char* fmt, ...) { + char* msg_buf = nullptr; + va_list args; + va_start(args, fmt); + vasprintf(&msg_buf, fmt, args); + va_end(args); + + if (!msg_buf) return; + + 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(); + log(levelnum, filename, lineno, func, msg_buf, log_s); + free(msg_buf); +} + +void cloudlog_bind(const char* k, const char* v) { + std::lock_guard lk(s.lock); + cloudlog_init(); + cloudlog_bind_locked(k, v); +} diff --git a/selfdrive/common/swaglog.h b/selfdrive/common/swaglog.h index 33e77f618aef59..9a1d3c0a6758a1 100644 --- a/selfdrive/common/swaglog.h +++ b/selfdrive/common/swaglog.h @@ -1,7 +1,6 @@ -#ifndef SWAGLOG_H -#define SWAGLOG_H +#pragma once -#include "common/timing.h" +#include "selfdrive/common/timing.h" #define CLOUDLOG_DEBUG 10 #define CLOUDLOG_INFO 20 @@ -9,19 +8,11 @@ #define CLOUDLOG_ERROR 40 #define CLOUDLOG_CRITICAL 50 -#ifdef __cplusplus -extern "C" { -#endif - void cloudlog_e(int levelnum, const char* filename, int lineno, const char* func, const char* fmt, ...) /*__attribute__ ((format (printf, 6, 7)))*/; void cloudlog_bind(const char* k, const char* v); -#ifdef __cplusplus -} -#endif - #define cloudlog(lvl, fmt, ...) cloudlog_e(lvl, __FILE__, __LINE__, \ __func__, \ fmt, ## __VA_ARGS__) @@ -40,7 +31,7 @@ void cloudlog_bind(const char* k, const char* v); \ if (__begin + __millis*1000000ULL < __ts) { \ if (__missed) { \ - cloudlog(CLOUDLOG_WARNING, "cloudlog: %d messages supressed", __missed); \ + cloudlog(CLOUDLOG_WARNING, "cloudlog: %d messages suppressed", __missed); \ } \ __begin = 0; \ __printed = 0; \ @@ -64,5 +55,3 @@ void cloudlog_bind(const char* k, const char* v); #define LOG_100(fmt, ...) cloudlog_rl(2, 100, CLOUDLOG_INFO, fmt, ## __VA_ARGS__) #define LOGW_100(fmt, ...) cloudlog_rl(2, 100, CLOUDLOG_WARNING, fmt, ## __VA_ARGS__) #define LOGE_100(fmt, ...) cloudlog_rl(2, 100, CLOUDLOG_ERROR, fmt, ## __VA_ARGS__) - -#endif diff --git a/selfdrive/common/timing.h b/selfdrive/common/timing.h index 1a30ad6e1e4d7b..83f55e0c4009f5 100644 --- a/selfdrive/common/timing.h +++ b/selfdrive/common/timing.h @@ -1,8 +1,7 @@ -#ifndef COMMON_TIMING_H -#define COMMON_TIMING_H +#pragma once -#include -#include +#include +#include #ifdef __APPLE__ #define CLOCK_BOOTTIME CLOCK_MONOTONIC @@ -23,7 +22,7 @@ static inline double millis_since_boot() { static inline double seconds_since_boot() { struct timespec t; clock_gettime(CLOCK_BOOTTIME, &t); - return (double)t.tv_sec + t.tv_nsec * 1e-9;; + return (double)t.tv_sec + t.tv_nsec * 1e-9; } static inline uint64_t nanos_since_epoch() { @@ -50,5 +49,3 @@ static inline uint64_t nanos_monotonic_raw() { clock_gettime(CLOCK_MONOTONIC_RAW, &t); return t.tv_sec * 1000000000ULL + t.tv_nsec; } - -#endif diff --git a/selfdrive/common/touch.c b/selfdrive/common/touch.c deleted file mode 100644 index 9117154b0c630a..00000000000000 --- a/selfdrive/common/touch.c +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "touch.h" - -static int find_dev() { - int err; - - int ret = -1; - - DIR *dir = opendir("/dev/input"); - assert(dir); - struct dirent* de = NULL; - while ((de = readdir(dir))) { - if (strncmp(de->d_name, "event", 5)) continue; - - int fd = openat(dirfd(dir), de->d_name, O_RDONLY); - assert(fd >= 0); - - unsigned char ev_bits[KEY_MAX / 8 + 1]; - 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))) { - ret = fd; - break; - } - close(fd); - } - closedir(dir); - - return ret; -} - -void touch_init(TouchState *s) { - s->fd = find_dev(); - assert(s->fd >= 0); -} - -int touch_poll(TouchState *s, int* out_x, int* out_y, int timeout) { - assert(out_x && out_y); - bool up = false; - while (true) { - struct pollfd polls[] = {{ - .fd = s->fd, - .events = POLLIN, - }}; - int err = poll(polls, 1, timeout); - if (err < 0) { - return -1; - } - if (!(polls[0].revents & POLLIN)) { - break; - } - - struct input_event event; - err = read(polls[0].fd, &event, sizeof(event)); - if (err < sizeof(event)) { - return -1; - } - - 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; -} - -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 -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 deleted file mode 100644 index c48f66b9827214..00000000000000 --- a/selfdrive/common/touch.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef TOUCH_H -#define TOUCH_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct TouchState { - int fd; - int last_x, last_y; -} 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 deleted file mode 100644 index 01b8a0b6d92c80..00000000000000 --- a/selfdrive/common/util.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include -#include - -#ifdef __linux__ -#include -#include -#include -#endif - -void* read_file(const char* path, size_t* out_len) { - FILE* f = fopen(path, "r"); - if (!f) { - return NULL; - } - fseek(f, 0, SEEK_END); - long f_len = ftell(f); - rewind(f); - - char* buf = calloc(f_len + 1, 1); - assert(buf); - - size_t num_read = fread(buf, f_len, 1, f); - fclose(f); - - if (num_read != 1) { - free(buf); - return NULL; - } - - if (out_len) { - *out_len = f_len + 1; - } - - return buf; -} - -void set_thread_name(const char* name) { -#ifdef __linux__ - // pthread_setname_np is dumb (fails instead of truncates) - prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0); -#endif -} - -int set_realtime_priority(int level) { -#ifdef __linux__ - - long tid = syscall(SYS_gettid); - - // should match python using chrt - struct sched_param sa; - memset(&sa, 0, sizeof(sa)); - sa.sched_priority = level; - return sched_setscheduler(tid, SCHED_FIFO, &sa); -#endif -} - diff --git a/selfdrive/common/util.cc b/selfdrive/common/util.cc new file mode 100644 index 00000000000000..534a7f44562de7 --- /dev/null +++ b/selfdrive/common/util.cc @@ -0,0 +1,244 @@ +#include "selfdrive/common/util.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __linux__ +#include +#include +#ifndef __USE_GNU +#define __USE_GNU +#endif +#include +#endif // __linux__ + +namespace util { + +void set_thread_name(const char* name) { +#ifdef __linux__ + // pthread_setname_np is dumb (fails instead of truncates) + prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0); +#endif +} + +int set_realtime_priority(int level) { +#ifdef __linux__ + long tid = syscall(SYS_gettid); + + // should match python using chrt + struct sched_param sa; + memset(&sa, 0, sizeof(sa)); + sa.sched_priority = level; + return sched_setscheduler(tid, SCHED_FIFO, &sa); +#else + return -1; +#endif +} + +int set_core_affinity(std::vector cores) { +#ifdef __linux__ + long tid = syscall(SYS_gettid); + cpu_set_t cpu; + + CPU_ZERO(&cpu); + for (const int n : cores) { + CPU_SET(n, &cpu); + } + return sched_setaffinity(tid, sizeof(cpu), &cpu); +#else + return -1; +#endif +} + +std::string read_file(const std::string& fn) { + std::ifstream f(fn, std::ios::binary | std::ios::in); + if (f.is_open()) { + f.seekg(0, std::ios::end); + int size = f.tellg(); + if (f.good() && size > 0) { + std::string result(size, '\0'); + f.seekg(0, std::ios::beg); + f.read(result.data(), size); + // return either good() or has reached end-of-file (e.g. /sys/power/wakeup_count) + if (f.good() || f.eof()) { + result.resize(f.gcount()); + return result; + } + } + // fallback for files created on read, e.g. procfs + std::stringstream buffer; + buffer << f.rdbuf(); + return buffer.str(); + } + return std::string(); +} + +std::map read_files_in_dir(const std::string &path) { + std::map ret; + DIR *d = opendir(path.c_str()); + if (!d) return ret; + + struct dirent *de = NULL; + while ((de = readdir(d))) { + if (de->d_type != DT_DIR) { + ret[de->d_name] = util::read_file(path + "/" + de->d_name); + } + } + + closedir(d); + return ret; +} + +int write_file(const char* path, const void* data, size_t size, int flags, mode_t mode) { + int fd = HANDLE_EINTR(open(path, flags, mode)); + if (fd == -1) { + return -1; + } + ssize_t n = HANDLE_EINTR(write(fd, data, size)); + close(fd); + return (n >= 0 && (size_t)n == size) ? 0 : -1; +} + +FILE* safe_fopen(const char* filename, const char* mode) { + FILE* fp = NULL; + do { + fp = fopen(filename, mode); + } while ((nullptr == fp) && (errno == EINTR)); + return fp; +} + +size_t safe_fwrite(const void* ptr, size_t size, size_t count, FILE* stream) { + size_t written = 0; + do { + size_t ret = ::fwrite((void*)((char *)ptr + written * size), size, count - written, stream); + if (ret == 0 && errno != EINTR) break; + written += ret; + } while (written != count); + return written; +} + +int safe_fflush(FILE *stream) { + int ret = EOF; + do { + ret = fflush(stream); + } while ((EOF == ret) && (errno == EINTR)); + return ret; +} + +std::string readlink(const std::string &path) { + char buff[4096]; + ssize_t len = ::readlink(path.c_str(), buff, sizeof(buff)-1); + if (len != -1) { + buff[len] = '\0'; + return std::string(buff); + } + return ""; +} + +bool file_exists(const std::string& fn) { + struct stat st = {}; + return stat(fn.c_str(), &st) != -1; +} + +static bool createDirectory(std::string dir, mode_t mode) { + auto verify_dir = [](const std::string& dir) -> bool { + struct stat st = {}; + return (stat(dir.c_str(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR); + }; + // remove trailing /'s + while (dir.size() > 1 && dir.back() == '/') { + dir.pop_back(); + } + // try to mkdir this directory + if (mkdir(dir.c_str(), mode) == 0) return true; + if (errno == EEXIST) return verify_dir(dir); + if (errno != ENOENT) return false; + + // mkdir failed because the parent dir doesn't exist, so try to create it + size_t slash = dir.rfind('/'); + if ((slash == std::string::npos || slash < 1) || + !createDirectory(dir.substr(0, slash), mode)) { + return false; + } + + // try again + if (mkdir(dir.c_str(), mode) == 0) return true; + return errno == EEXIST && verify_dir(dir); +} + +bool create_directories(const std::string& dir, mode_t mode) { + if (dir.empty()) return false; + return createDirectory(dir, mode); +} + +std::string getenv(const char* key, const char* default_val) { + const char* val = ::getenv(key); + return val ? val : default_val; +} + +int getenv(const char* key, int default_val) { + const char* val = ::getenv(key); + return val ? atoi(val) : default_val; +} + +float getenv(const char* key, float default_val) { + const char* val = ::getenv(key); + return val ? atof(val) : default_val; +} + +std::string hexdump(const uint8_t* in, const size_t size) { + std::stringstream ss; + ss << std::hex << std::setfill('0'); + for (size_t i = 0; i < size; i++) { + ss << std::setw(2) << static_cast(in[i]); + } + return ss.str(); +} + +std::string dir_name(std::string const &path) { + size_t pos = path.find_last_of("/"); + if (pos == std::string::npos) return ""; + return path.substr(0, pos); +} + +std::string check_output(const std::string& command) { + char buffer[128]; + std::string result; + std::unique_ptr pipe(popen(command.c_str(), "r"), pclose); + + if (!pipe) { + return ""; + } + + while (fgets(buffer, std::size(buffer), pipe.get()) != nullptr) { + result += std::string(buffer); + } + + return result; +} + +struct tm get_time() { + time_t rawtime; + time(&rawtime); + + struct tm sys_time; + gmtime_r(&rawtime, &sys_time); + + return sys_time; +} + +bool time_valid(struct tm sys_time) { + int year = 1900 + sys_time.tm_year; + int month = 1 + sys_time.tm_mon; + return (year > 2021) || (year == 2021 && month >= 6); +} + +} // namespace util diff --git a/selfdrive/common/util.h b/selfdrive/common/util.h index b3ca916941654d..9a6a4d9bdb72ab 100644 --- a/selfdrive/common/util.h +++ b/selfdrive/common/util.h @@ -1,48 +1,163 @@ -#ifndef COMMON_UTIL_H -#define COMMON_UTIL_H +#pragma once -#include +#include +#include +#include -#ifndef __cplusplus +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#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; }) +// keep trying if x gets interrupted by a signal +#define HANDLE_EINTR(x) \ + ({ \ + decltype(x) ret_; \ + int try_cnt = 0; \ + do { \ + ret_ = (x); \ + } while (ret_ == -1 && errno == EINTR && try_cnt++ < 100); \ + ret_; \ + }) +#ifndef sighandler_t +typedef void (*sighandler_t)(int sig); #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); }) +const double MILE_TO_KM = 1.609344; +const double KM_TO_MILE = 1. / MILE_TO_KM; +const double MS_TO_KPH = 3.6; +const double MS_TO_MPH = MS_TO_KPH * KM_TO_MILE; +const double METER_TO_MILE = KM_TO_MILE / 1000.0; +const double METER_TO_FOOT = 3.28084; -#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) +namespace util { -#define ALIGN(x, align) (((x) + (align)-1) & ~((align)-1)) +void set_thread_name(const char* name); +int set_realtime_priority(int level); +int set_core_affinity(std::vector cores); -#ifdef __cplusplus -extern "C" { -#endif +// ***** Time helpers ***** +struct tm get_time(); +bool time_valid(struct tm sys_time); -// Reads a file into a newly allocated buffer. -// -// 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); +// ***** math helpers ***** -void set_thread_name(const char* name); +// map x from [a1, a2] to [b1, b2] +template +T map_val(T x, T a1, T a2, T b1, T b2) { + x = std::clamp(x, a1, a2); + T ra = a2 - a1; + T rb = b2 - b1; + return (x - a1) * rb / ra + b1; +} -int set_realtime_priority(int level); +// ***** string helpers ***** -#ifdef __cplusplus +template +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]); + snprintf(buf.get(), size, format.c_str(), args...); + return std::string(buf.get(), buf.get() + size - 1); } -#endif +std::string getenv(const char* key, const char* default_val = ""); +int getenv(const char* key, int default_val); +float getenv(const char* key, float default_val); + +std::string hexdump(const uint8_t* in, const size_t size); +std::string dir_name(std::string const& path); + +// **** file fhelpers ***** +std::string read_file(const std::string& fn); +std::map read_files_in_dir(const std::string& path); +int write_file(const char* path, const void* data, size_t size, int flags = O_WRONLY, mode_t mode = 0664); + +FILE* safe_fopen(const char* filename, const char* mode); +size_t safe_fwrite(const void * ptr, size_t size, size_t count, FILE * stream); +int safe_fflush(FILE *stream); + +std::string readlink(const std::string& path); +bool file_exists(const std::string& fn); +bool create_directories(const std::string &dir, mode_t mode); + +std::string check_output(const std::string& command); + +inline void sleep_for(const int milliseconds) { + std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); +} + +} // namespace util + +class ExitHandler { +public: + ExitHandler() { + std::signal(SIGINT, (sighandler_t)set_do_exit); + std::signal(SIGTERM, (sighandler_t)set_do_exit); + +#ifndef __APPLE__ + std::signal(SIGPWR, (sighandler_t)set_do_exit); #endif + }; + inline static std::atomic power_failure = false; + inline static std::atomic signal = 0; + inline operator bool() { return do_exit; } + inline ExitHandler& operator=(bool v) { + signal = 0; + do_exit = v; + return *this; + } +private: + static void set_do_exit(int sig) { +#ifndef __APPLE__ + power_failure = (sig == SIGPWR); +#endif + signal = sig; + do_exit = true; + } + inline static std::atomic do_exit = false; +}; + +struct unique_fd { + unique_fd(int fd = -1) : fd_(fd) {} + unique_fd& operator=(unique_fd&& uf) { + fd_ = uf.fd_; + uf.fd_ = -1; + return *this; + } + ~unique_fd() { + if (fd_ != -1) close(fd_); + } + operator int() const { return fd_; } + int fd_; +}; + +class FirstOrderFilter { +public: + FirstOrderFilter(float x0, float ts, float dt) { + k_ = (dt / ts) / (1.0 + dt / ts); + x_ = x0; + } + inline float update(float x) { + x_ = (1. - k_) * x_ + k_ * x; + return x_; + } + inline void reset(float x) { x_ = x; } + inline float x(){ return x_; } + +private: + float x_, k_; +}; + +template +void update_max_atomic(std::atomic& max, T const& value) { + T prev = max; + while(prev < value && !max.compare_exchange_weak(prev, value)) {} +} diff --git a/selfdrive/common/utilpp.h b/selfdrive/common/utilpp.h deleted file mode 100644 index e374c5c256f772..00000000000000 --- a/selfdrive/common/utilpp.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef UTILPP_H -#define UTILPP_H - -#include -#include - -#include -#include -#include -#include - -namespace util { - -inline bool starts_with(std::string s, std::string prefix) { - return s.compare(0, prefix.size(), prefix) == 0; -} - -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 ] ); - snprintf( buf.get(), size, format.c_str(), args ... ); - return std::string( buf.get(), buf.get() + size - 1 ); -} - -inline std::string read_file(std::string fn) { - std::ifstream t(fn); - std::stringstream buffer; - buffer << t.rdbuf(); - return buffer.str(); -} - -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 -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct VisionBuf { - size_t len; - void* addr; - int handle; - int fd; - - cl_context ctx; - cl_device_id device_id; - cl_mem buf_cl; - cl_command_queue copy_q; -} VisionBuf; - -#define VISIONBUF_SYNC_FROM_DEVICE 0 -#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); -void visionbuf_sync(const VisionBuf* buf, int dir); -void visionbuf_free(const VisionBuf* buf); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/selfdrive/common/visionbuf_ion.c b/selfdrive/common/visionbuf_ion.c deleted file mode 100644 index 724e75e9b0c0d5..00000000000000 --- a/selfdrive/common/visionbuf_ion.c +++ /dev/null @@ -1,141 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "visionbuf.h" - - -// just hard-code these for convenience -// size_t device_page_size = 0; -// clGetDeviceInfo(device_id, CL_DEVICE_PAGE_SIZE_QCOM, -// sizeof(device_page_size), &device_page_size, -// NULL); - -// size_t padding_cl = 0; -// clGetDeviceInfo(device_id, CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM, -// sizeof(padding_cl), &padding_cl, -// NULL); -#define DEVICE_PAGE_SIZE_CL 4096 -#define PADDING_CL 0 - -static int ion_fd = -1; -static void ion_init() { - if (ion_fd == -1) { - ion_fd = open("/dev/ion", O_RDWR | O_NONBLOCK); - } -} - -VisionBuf visionbuf_allocate(size_t len) { - int err; - - ion_init(); - - struct ion_allocation_data ion_alloc = {0}; - ion_alloc.len = len + PADDING_CL; - ion_alloc.align = 4096; - ion_alloc.heap_id_mask = 1 << ION_IOMMU_HEAP_ID; - ion_alloc.flags = ION_FLAG_CACHED; - - err = ioctl(ion_fd, ION_IOC_ALLOC, &ion_alloc); - assert(err == 0); - - struct ion_fd_data ion_fd_data = {0}; - ion_fd_data.handle = ion_alloc.handle; - err = ioctl(ion_fd, ION_IOC_SHARE, &ion_fd_data); - assert(err == 0); - - void *addr = mmap(NULL, ion_alloc.len, - PROT_READ | PROT_WRITE, - MAP_SHARED, ion_fd_data.fd, 0); - assert(addr != MAP_FAILED); - - memset(addr, 0, ion_alloc.len); - - return (VisionBuf){ - .len = 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; - - 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; - - cl_mem mem = clCreateBuffer(ctx, - CL_MEM_USE_HOST_PTR | CL_MEM_EXT_HOST_PTR_QCOM, - buf->len, &ion_cl, &err); - assert(err == 0); - - return mem; -} - -void visionbuf_sync(const VisionBuf* buf, int dir) { - int err; - - struct ion_fd_data fd_data = {0}; - fd_data.fd = buf->fd; - err = ioctl(ion_fd, ION_IOC_IMPORT, &fd_data); - assert(err == 0); - - struct ion_flush_data flush_data = {0}; - flush_data.handle = fd_data.handle; - flush_data.vaddr = buf->addr; - flush_data.offset = 0; - flush_data.length = buf->len; - - // ION_IOC_INV_CACHES ~= DMA_FROM_DEVICE - // ION_IOC_CLEAN_CACHES ~= DMA_TO_DEVICE - // ION_IOC_CLEAN_INV_CACHES ~= DMA_BIDIRECTIONAL - - struct ion_custom_data custom_data = {0}; - - switch (dir) { - case VISIONBUF_SYNC_FROM_DEVICE: - custom_data.cmd = ION_IOC_INV_CACHES; - break; - case VISIONBUF_SYNC_TO_DEVICE: - custom_data.cmd = ION_IOC_CLEAN_CACHES; - break; - default: - assert(0); - } - - custom_data.arg = (unsigned long)&flush_data; - err = ioctl(ion_fd, ION_IOC_CUSTOM, &custom_data); - assert(err == 0); - - struct ion_handle_data handle_data = {0}; - handle_data.handle = fd_data.handle; - err = ioctl(ion_fd, ION_IOC_FREE, &handle_data); - assert(err == 0); -} - -void visionbuf_free(const VisionBuf* buf) { - struct ion_handle_data handle_data = { - .handle = buf->handle, - }; - int ret = ioctl(ion_fd, ION_IOC_FREE, &handle_data); - assert(ret == 0); -} diff --git a/selfdrive/common/visionimg.cc b/selfdrive/common/visionimg.cc index a533acb597ac4c..a98aabc36c4ace 100644 --- a/selfdrive/common/visionimg.cc +++ b/selfdrive/common/visionimg.cc @@ -1,122 +1,63 @@ +#include "selfdrive/common/visionimg.h" + #include #ifdef QCOM +#include #include #include #include -#include - -#include #define GL_GLEXT_PROTOTYPES #include - -#include -#define EGL_EGLEXT_PROTOTYPES -#include - -#endif - -#include "common/util.h" -#include "common/visionbuf.h" - -#include "common/visionimg.h" - -#ifdef QCOM - using namespace android; -// from libadreno_utils.so -extern "C" void compute_aligned_width_and_height(int width, - int height, - int bpp, - int tile_mode, - int raster_mode, - int padding_threshold, - int *aligned_w, - int *aligned_h); -#endif - -void visionimg_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h) { -#ifdef QCOM - 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) { - 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; +EGLImageTexture::EGLImageTexture(const VisionBuf *buf) { + const int bpp = 3; + assert((buf->len % buf->stride) == 0); + assert((buf->stride % bpp) == 0); - VisionBuf buf = visionbuf_allocate(size); - - *out_buf = buf; - - return (VisionImg){ - .fd = buf.fd, - .format = VISIONIMG_FORMAT_RGB24, - .width = width, - .height = height, - .stride = stride, - .size = size, - .bpp = 3, - }; -} - -#ifdef QCOM - -EGLClientBuffer visionimg_to_egl(const VisionImg *img, void **pph) { - assert((img->size % img->stride) == 0); - assert((img->stride % img->bpp) == 0); - - int format = 0; - if (img->format == VISIONIMG_FORMAT_RGB24) { - format = HAL_PIXEL_FORMAT_RGB_888; - } else { - assert(false); - } - - private_handle_t* hnd = new private_handle_t(img->fd, img->size, + const int format = HAL_PIXEL_FORMAT_RGB_888; + private_handle = new private_handle_t(buf->fd, buf->len, private_handle_t::PRIV_FLAGS_USES_ION|private_handle_t::PRIV_FLAGS_FRAMEBUFFER, 0, format, - img->stride/img->bpp, img->size/img->stride, - img->width, img->height); + buf->stride/bpp, buf->len/buf->stride, + buf->width, buf->height); - GraphicBuffer* gb = new GraphicBuffer(img->width, img->height, (PixelFormat)format, - GraphicBuffer::USAGE_HW_TEXTURE, img->stride/img->bpp, hnd, false); - // GraphicBuffer is ref counted by EGLClientBuffer(ANativeWindowBuffer), no need and not possible to release. - *pph = hnd; - return (EGLClientBuffer) gb->getNativeBuffer(); -} - -GLuint visionimg_to_gl(const VisionImg *img, EGLImageKHR *pkhr, void **pph) { - - EGLClientBuffer buf = visionimg_to_egl(img, pph); + // GraphicBuffer is ref counted by EGLClientBuffer(ANativeWindowBuffer), no need and not possible to release. + GraphicBuffer* gb = new GraphicBuffer(buf->width, buf->height, (PixelFormat)format, + GraphicBuffer::USAGE_HW_TEXTURE, buf->stride/bpp, (private_handle_t*)private_handle, false); EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(display != EGL_NO_DISPLAY); - EGLint img_attrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; - EGLImageKHR image = eglCreateImageKHR(display, EGL_NO_CONTEXT, - EGL_NATIVE_BUFFER_ANDROID, buf, img_attrs); - assert(image != EGL_NO_IMAGE_KHR); + EGLint img_attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; + img_khr = eglCreateImageKHR(display, EGL_NO_CONTEXT, + EGL_NATIVE_BUFFER_ANDROID, gb->getNativeBuffer(), img_attrs); + assert(img_khr != EGL_NO_IMAGE_KHR); - GLuint tex = 0; - glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_2D, tex); - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); - *pkhr = image; - return tex; + glGenTextures(1, &frame_tex); + glBindTexture(GL_TEXTURE_2D, frame_tex); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, img_khr); } -void visionimg_destroy_gl(EGLImageKHR khr, void *ph) { +EGLImageTexture::~EGLImageTexture() { + glDeleteTextures(1, &frame_tex); EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(display != EGL_NO_DISPLAY); - eglDestroyImageKHR(display, khr); - delete (private_handle_t*)ph; + eglDestroyImageKHR(display, img_khr); + delete (private_handle_t*)private_handle; } -#endif +#else // ifdef QCOM + +EGLImageTexture::EGLImageTexture(const VisionBuf *buf) { + glGenTextures(1, &frame_tex); + glBindTexture(GL_TEXTURE_2D, frame_tex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, buf->width, buf->height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); + glGenerateMipmap(GL_TEXTURE_2D); +} + +EGLImageTexture::~EGLImageTexture() { + glDeleteTextures(1, &frame_tex); +} +#endif // ifdef QCOM diff --git a/selfdrive/common/visionimg.h b/selfdrive/common/visionimg.h index 74b0f3137d1b8c..e8917f3bd618ca 100644 --- a/selfdrive/common/visionimg.h +++ b/selfdrive/common/visionimg.h @@ -1,39 +1,27 @@ -#ifndef VISIONIMG_H -#define VISIONIMG_H +#pragma once -#ifdef QCOM -#include -#include -#include -#endif - -#include "common/visionbuf.h" +#include "cereal/visionipc/visionbuf.h" -#ifdef __cplusplus -extern "C" { +#ifdef __APPLE__ +#include +#else +#include #endif -#define VISIONIMG_FORMAT_RGB24 1 - -typedef struct VisionImg { - int fd; - int format; - int width, height, stride; - int bpp; - size_t size; -} 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); - #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" +#include +#define EGL_EGLEXT_PROTOTYPES +#include +#undef Status #endif +class EGLImageTexture { + public: + EGLImageTexture(const VisionBuf *buf); + ~EGLImageTexture(); + GLuint frame_tex = 0; +#ifdef QCOM + void *private_handle = nullptr; + EGLImageKHR img_khr = 0; #endif +}; diff --git a/selfdrive/common/visionipc.c b/selfdrive/common/visionipc.c deleted file mode 100644 index 314f7d0a55c712..00000000000000 --- a/selfdrive/common/visionipc.c +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "ipc.h" - -#include "visionipc.h" - -typedef struct VisionPacketWire { - int type; - VisionPacketData d; -} VisionPacketWire; - -int vipc_connect() { - return ipc_connect(VIPC_SOCKET_PATH); -} - - -int vipc_recv(int fd, VisionPacket *out_p) { - VisionPacketWire p = {0}; - VisionPacket p2 = {0}; - int ret = ipc_sendrecv_with_fds(false, fd, &p, sizeof(p), (int*)p2.fds, VIPC_MAX_FDS, &p2.num_fds); - if (ret < 0) { - printf("vipc_recv err: %s\n", strerror(errno)); - } else { - p2.type = p.type; - p2.d = p.d; - *out_p = p2; - } - return ret; -} - -int vipc_send(int fd, const VisionPacket *p2) { - assert(p2->num_fds <= VIPC_MAX_FDS); - - VisionPacketWire p = { - .type = p2->type, - .d = p2->d, - }; - return ipc_sendrecv_with_fds(true, fd, (void*)&p, sizeof(p), (int*)p2->fds, p2->num_fds, NULL); -} - -void vipc_bufs_load(VIPCBuf *bufs, const VisionStreamBufs *stream_bufs, - int num_fds, const int* fds) { - for (int i=0; ibuf_len; - bufs[i].addr = mmap(NULL, bufs[i].len, - PROT_READ | PROT_WRITE, - MAP_SHARED, bufs[i].fd, 0); - // printf("b %d %zu -> %p\n", bufs[i].fd, bufs[i].len, bufs[i].addr); - assert(bufs[i].addr != MAP_FAILED); - } -} - - -int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, VisionStreamBufs *out_bufs_info) { - int err; - - memset(s, 0, sizeof(*s)); - - s->last_idx = -1; - - s->ipc_fd = vipc_connect(); - if (s->ipc_fd < 0) return -1; - - VisionPacket p = { - .type = VIPC_STREAM_SUBSCRIBE, - .d = { .stream_sub = { - .type = type, - .tbuffer = tbuffer, - }, }, - }; - err = vipc_send(s->ipc_fd, &p); - if (err < 0) { - close(s->ipc_fd); - return -1; - } - - VisionPacket rp; - err = vipc_recv(s->ipc_fd, &rp); - if (err <= 0) { - close(s->ipc_fd); - return -1; - } - assert(rp.type = VIPC_STREAM_BUFS); - assert(rp.d.stream_bufs.type == type); - - s->bufs_info = rp.d.stream_bufs; - - s->num_bufs = rp.num_fds; - s->bufs = calloc(s->num_bufs, sizeof(VIPCBuf)); - assert(s->bufs); - - vipc_bufs_load(s->bufs, &rp.d.stream_bufs, s->num_bufs, rp.fds); - - if (out_bufs_info) { - *out_bufs_info = s->bufs_info; - } - - return 0; -} - -void visionstream_release(VisionStream *s) { - int err; - if (s->last_idx >= 0) { - VisionPacket rep = { - .type = VIPC_STREAM_RELEASE, - .d = { .stream_rel = { - .type = s->last_type, - .idx = s->last_idx, - }} - }; - err = vipc_send(s->ipc_fd, &rep); - s->last_idx = -1; - } -} - -VIPCBuf* visionstream_get(VisionStream *s, VIPCBufExtra *out_extra) { - int err; - - VisionPacket rp; - err = vipc_recv(s->ipc_fd, &rp); - if (err <= 0) { - return NULL; - } - assert(rp.type == VIPC_STREAM_ACQUIRE); - - if (s->last_idx >= 0) { - VisionPacket rep = { - .type = VIPC_STREAM_RELEASE, - .d = { .stream_rel = { - .type = s->last_type, - .idx = s->last_idx, - }} - }; - err = vipc_send(s->ipc_fd, &rep); - if (err <= 0) { - return NULL; - } - } - - s->last_type = rp.d.stream_acq.type; - s->last_idx = rp.d.stream_acq.idx; - assert(s->last_idx < s->num_bufs); - - if (out_extra) { - *out_extra = rp.d.stream_acq.extra; - } - - return &s->bufs[s->last_idx]; -} - -void visionstream_destroy(VisionStream *s) { - int err; - - if (s->last_idx >= 0) { - VisionPacket rep = { - .type = VIPC_STREAM_RELEASE, - .d = { .stream_rel = { - .type = s->last_type, - .idx = s->last_idx, - }} - }; - err = vipc_send(s->ipc_fd, &rep); - s->last_idx = -1; - } - - for (int i=0; inum_bufs; i++) { - if (s->bufs[i].addr) { - munmap(s->bufs[i].addr, s->bufs[i].len); - s->bufs[i].addr = NULL; - close(s->bufs[i].fd); - } - } - if (s->bufs) free(s->bufs); - close(s->ipc_fd); -} diff --git a/selfdrive/common/visionipc.h b/selfdrive/common/visionipc.h deleted file mode 100644 index 4844a71b1d756b..00000000000000 --- a/selfdrive/common/visionipc.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef VISIONIPC_H -#define VISIONIPC_H - -#include -#include -#include - -#define VIPC_SOCKET_PATH "/tmp/vision_socket" -#define VIPC_MAX_FDS 64 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum VisionIPCPacketType { - VIPC_INVALID = 0, - VIPC_STREAM_SUBSCRIBE, - VIPC_STREAM_BUFS, - VIPC_STREAM_ACQUIRE, - VIPC_STREAM_RELEASE, -} VisionIPCPacketType; - -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 VIPCBufExtra { - // only for yuv - uint32_t frame_id; - uint64_t timestamp_eof; -} VIPCBufExtra; - -typedef union VisionPacketData { - struct { - VisionStreamType type; - bool tbuffer; - } stream_sub; - VisionStreamBufs stream_bufs; - struct { - VisionStreamType type; - int idx; - VIPCBufExtra extra; - } stream_acq; - struct { - VisionStreamType type; - int idx; - } stream_rel; -} VisionPacketData; - -typedef struct VisionPacket { - int type; - VisionPacketData d; - int num_fds; - int fds[VIPC_MAX_FDS]; -} VisionPacket; - -int vipc_connect(void); -int vipc_recv(int fd, VisionPacket *out_p); -int vipc_send(int fd, const VisionPacket *p); - -typedef struct VIPCBuf { - int fd; - size_t len; - void* addr; -} VIPCBuf; -void vipc_bufs_load(VIPCBuf *bufs, const VisionStreamBufs *stream_bufs, - int num_fds, const int* fds); - - - -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); -void visionstream_release(VisionStream *s); -VIPCBuf* visionstream_get(VisionStream *s, VIPCBufExtra *out_extra); -void visionstream_destroy(VisionStream *s); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/selfdrive/common/watchdog.cc b/selfdrive/common/watchdog.cc new file mode 100644 index 00000000000000..c937103a5d1880 --- /dev/null +++ b/selfdrive/common/watchdog.cc @@ -0,0 +1,12 @@ +#include "selfdrive/common/watchdog.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" + +const std::string watchdog_fn_prefix = "/dev/shm/wd_"; // + + +bool watchdog_kick() { + static std::string fn = watchdog_fn_prefix + std::to_string(getpid()); + + uint64_t ts = nanos_since_boot(); + return util::write_file(fn.c_str(), &ts, sizeof(ts), O_WRONLY | O_CREAT) > 0; +} diff --git a/selfdrive/common/watchdog.h b/selfdrive/common/watchdog.h new file mode 100644 index 00000000000000..7ed23aa0d9ca4e --- /dev/null +++ b/selfdrive/common/watchdog.h @@ -0,0 +1,3 @@ +#pragma once + +bool watchdog_kick(); diff --git a/selfdrive/config.py b/selfdrive/config.py index 751a84e285f52c..511f6126c4f778 100644 --- a/selfdrive/config.py +++ b/selfdrive/config.py @@ -11,19 +11,19 @@ class Conversions: MS_TO_KNOTS = 1.9438 KNOTS_TO_MS = 1. / MS_TO_KNOTS #Angle - DEG_TO_RAD = np.pi/180. + DEG_TO_RAD = np.pi / 180. RAD_TO_DEG = 1. / DEG_TO_RAD #Mass 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 + 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 f1c556ba12e2e0..19fe328dbf8712 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -1,522 +1,744 @@ -#!/usr/bin/env python -import gc -import capnp +#!/usr/bin/env python3 +import os +import math +from numbers import Number + 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.swaglog import cloudlog from selfdrive.boardd.boardd import can_list_to_can_capnp -from selfdrive.car.car_helpers import get_car, get_startup_alert -from selfdrive.controls.lib.model_parser 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.longcontrol import LongControl, STARTING_TARGET_SPEED +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 update_v_cruise, initialize_v_cruise +from selfdrive.controls.lib.drive_helpers import get_lag_adjusted_curvature +from selfdrive.controls.lib.longcontrol import LongControl from selfdrive.controls.lib.latcontrol_pid import LatControlPID from selfdrive.controls.lib.latcontrol_indi import LatControlINDI -from selfdrive.controls.lib.alertmanager import AlertManager +from selfdrive.controls.lib.latcontrol_lqr import LatControlLQR +from selfdrive.controls.lib.latcontrol_angle import LatControlAngle +from selfdrive.controls.lib.events import Events, ET +from selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.controls.lib.driver_monitor import DriverStatus -from selfdrive.controls.lib.planner import LON_MPC_STEP -from selfdrive.locationd.calibration_helpers import Calibration, Filter - -ThermalStatus = log.ThermalData.ThermalStatus +from selfdrive.locationd.calibrationd import Calibration +from selfdrive.hardware import HARDWARE, TICI, EON +from selfdrive.manager.process_config import managed_processes + +SOFT_DISABLE_TIME = 3 # seconds +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 = 2.5 # Degrees + +REPLAY = "REPLAY" in os.environ +SIMULATION = "SIMULATION" in os.environ +NOSENSOR = "NOSENSOR" in os.environ +IGNORE_PROCESSES = {"rtshield", "uploader", "deleter", "loggerd", "logmessaged", "tombstoned", + "logcatd", "proclogd", "clocksd", "updated", "timezoned", "manage_athenad"} | \ + {k for k, v in managed_processes.items() if not v.enabled} + +ACTUATOR_FIELDS = set(car.CarControl.Actuators.schema.fields.keys()) + +ThermalStatus = log.DeviceState.ThermalStatus State = log.ControlsState.OpenpilotState +PandaType = log.PandaState.PandaType +Desire = log.LateralPlan.Desire +LaneChangeState = log.LateralPlan.LaneChangeState +LaneChangeDirection = log.LateralPlan.LaneChangeDirection +EventName = car.CarEvent.EventName +ButtonEvent = car.CarState.ButtonEvent +SafetyModel = car.CarParams.SafetyModel + +IGNORED_SAFETY_MODES = [SafetyModel.silent, SafetyModel.noOutput] + + +class Controls: + def __init__(self, sm=None, pm=None, can_sock=None): + config_realtime_process(4 if TICI else 3, Priority.CTRL_HIGH) + + # Setup sockets + self.pm = pm + if self.pm is None: + self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState', + 'carControl', 'carEvents', 'carParams']) + + self.camera_packets = ["roadCameraState", "driverCameraState"] + if TICI: + self.camera_packets.append("wideRoadCameraState") + + params = Params() + self.joystick_mode = params.get_bool("JoystickDebugMode") + joystick_packet = ['testJoystick'] if self.joystick_mode else [] + + self.sm = sm + if self.sm is None: + ignore = ['driverCameraState', 'managerState'] if SIMULATION else None + self.sm = messaging.SubMaster(['deviceState', 'pandaStates', 'peripheralState', 'modelV2', 'liveCalibration', + 'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman', + 'managerState', 'liveParameters', 'radarState'] + self.camera_packets + joystick_packet, + ignore_alive=ignore, ignore_avg_freq=['radarState', 'longitudinalPlan']) + + 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) + + if TICI: + self.log_sock = messaging.sub_sock('androidLog') + + # wait for one pandaState 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 + self.is_metric = params.get_bool("IsMetric") + self.is_ldw_enabled = params.get_bool("IsLdwEnabled") + community_feature_toggle = params.get_bool("CommunityFeaturesToggle") + openpilot_enabled_toggle = params.get_bool("OpenpilotEnabledToggle") + passive = params.get_bool("Passive") 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' + + controller_available = self.CI.CC is not None and not passive and not self.CP.dashcamOnly + community_feature = self.CP.communityFeature or \ + self.CP.fingerprintSource == car.CarParams.FingerprintSource.can + community_feature_disallowed = community_feature 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: + safety_config = car.CarParams.SafetyConfig.new_message() + safety_config.safetyModel = car.CarParams.SafetyModel.noOutput + self.CP.safetyConfigs = [safety_config] + + # Write CarParams for radard + 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.VM = VehicleModel(self.CP) + + if self.CP.steerControlType == car.CarParams.SteerControlType.angle: + self.LaC = LatControlAngle(self.CP) + elif self.CP.lateralTuning.which() == 'pid': + self.LaC = LatControlPID(self.CP, self.CI) + elif self.CP.lateralTuning.which() == 'indi': + self.LaC = LatControlINDI(self.CP) + elif self.CP.lateralTuning.which() == 'lqr': + self.LaC = LatControlLQR(self.CP) + + self.initialized = False + 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.cruise_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.logged_comm_issue = False + self.button_timers = {ButtonEvent.Type.decelCruise: 0, ButtonEvent.Type.accelCruise: 0} + + # TODO: no longer necessary, aside from process replay + self.sm['liveParameters'].valid = True + + self.startup_event = get_startup_event(car_recognized, controller_available, len(self.CP.carFw) > 0) + + if not sounds_available: + self.events.add(EventName.soundsUnavailable, static=True) + if community_feature_disallowed and car_recognized and not self.CP.dashcamOnly: + self.events.add(EventName.communityFeatureDisallowed, static=True) + if not car_recognized: + self.events.add(EventName.carUnrecognized, static=True) + if len(self.CP.carFw) > 0: + set_offroad_alert("Offroad_CarUnrecognized", True) + else: + set_offroad_alert("Offroad_NoFirmware", True) + elif self.read_only: + self.events.add(EventName.dashcamMode, static=True) + elif self.joystick_mode: + self.events.add(EventName.joystickDebug, static=True) + self.startup_event = None + + # 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['driverMonitoringState'].events) + + # Handle startup event + if self.startup_event is not None: + self.events.add(self.startup_event) + self.startup_event = None + + # Don't add any more events if not initialized + if not self.initialized: + self.events.add(EventName.controlsInitializing) + return + + # Create events for battery, temperature, disk space, and memory + if EON and (self.sm['peripheralState'].pandaType != PandaType.uno) and \ + self.sm['deviceState'].batteryPercent < 1 and self.sm['deviceState'].chargingError: + # at zero percent battery, while discharging, OP should not allowed + self.events.add(EventName.lowBattery) + if self.sm['deviceState'].thermalStatus >= ThermalStatus.red: + self.events.add(EventName.overheat) + if self.sm['deviceState'].freeSpacePercent < 7 and not SIMULATION: + # under 7% of space free no enable allowed + self.events.add(EventName.outOfSpace) + # TODO: make tici threshold the same + if self.sm['deviceState'].memoryUsagePercent > (90 if TICI else 65) and not SIMULATION: + self.events.add(EventName.lowMemory) + + # TODO: enable this once loggerd CPU usage is more reasonable + #cpus = list(self.sm['deviceState'].cpuUsagePercent)[:(-1 if EON else None)] + #if max(cpus, default=0) > 95 and not SIMULATION: + # self.events.add(EventName.highCpuUsage) + + # Alert if fan isn't spinning for 5 seconds + if self.sm['peripheralState'].pandaType in [PandaType.uno, PandaType.dos]: + if self.sm['peripheralState'].fanSpeedRpm == 0 and self.sm['deviceState'].fanSpeedPercentDesired > 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 + # 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['lateralPlan'].laneChangeState == LaneChangeState.preLaneChange: + direction = self.sm['lateralPlan'].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['lateralPlan'].laneChangeState in [LaneChangeState.laneChangeStarting, + LaneChangeState.laneChangeFinishing]: + self.events.add(EventName.laneChange) + + if self.can_rcv_error or not CS.canValid: + self.events.add(EventName.canError) + + for i, pandaState in enumerate(self.sm['pandaStates']): + # All pandas must match the list of safetyConfigs, and if outside this list, must be silent or noOutput + if i < len(self.CP.safetyConfigs): + safety_mismatch = pandaState.safetyModel != self.CP.safetyConfigs[i].safetyModel or pandaState.safetyParam != self.CP.safetyConfigs[i].safetyParam + else: + safety_mismatch = pandaState.safetyModel not in IGNORED_SAFETY_MODES + if safety_mismatch or self.mismatch_counter >= 200: + self.events.add(EventName.controlsMismatch) + + if log.PandaState.FaultType.relayMalfunction in pandaState.faults: + self.events.add(EventName.relayMalfunction) + + # Check for HW or system issues + if len(self.sm['radarState'].radarErrors): + self.events.add(EventName.radarFault) + elif not self.sm.valid["pandaStates"]: + self.events.add(EventName.usbError) + elif not self.sm.all_alive_and_valid(): + self.events.add(EventName.commIssue) + if not self.logged_comm_issue: + invalid = [s for s, valid in self.sm.valid.items() if not valid] + not_alive = [s for s, alive in self.sm.alive.items() if not alive] + cloudlog.event("commIssue", invalid=invalid, not_alive=not_alive) + self.logged_comm_issue = True + else: + self.logged_comm_issue = False + + if not self.sm['liveParameters'].valid: + self.events.add(EventName.vehicleModelInvalid) + if not self.sm['lateralPlan'].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'].posenetOK: + self.events.add(EventName.posenetInvalid) + if not self.sm['liveLocationKalman'].deviceStable: + self.events.add(EventName.deviceFalling) + for pandaState in self.sm['pandaStates']: + if log.PandaState.FaultType.relayMalfunction in pandaState.faults: + self.events.add(EventName.relayMalfunction) + + if not REPLAY: + # Check for mismatch between openpilot and car's PCM + cruise_mismatch = CS.cruiseState.enabled and (not self.enabled or not self.CP.pcmCruise) + self.cruise_mismatch_counter = self.cruise_mismatch_counter + 1 if cruise_mismatch else 0 + if self.cruise_mismatch_counter > int(3. / DT_CTRL): + self.events.add(EventName.cruiseMismatch) + + # Check for FCW + stock_long_is_braking = self.enabled and not self.CP.openpilotLongitudinalControl and CS.aEgo < -1.5 + model_fcw = self.sm['modelV2'].meta.hardBrakePredicted and not CS.brakePressed and not stock_long_is_braking + planner_fcw = self.sm['longitudinalPlan'].fcw and self.enabled + if planner_fcw or model_fcw: + self.events.add(EventName.fcw) + + if TICI: + logs = messaging.drain_sock(self.log_sock, wait_for_one=False) + messages = [] + for m in logs: + try: + messages.append(m.androidLog.message) + except UnicodeDecodeError: + pass + + for err in ["ERROR_CRC", "ERROR_ECC", "ERROR_STREAM_UNDERFLOW", "APPLY FAILED"]: + for m in messages: + if err not in m: + continue + + csid = m.split("CSID:")[-1].split(" ")[0] + evt = {"0": EventName.roadCameraError, "1": EventName.wideRoadCameraError, + "2": EventName.driverCameraError}.get(csid, None) + if evt is not None: + self.events.add(evt) + + # TODO: fix simulator + if not SIMULATION: + if not NOSENSOR: + 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 + self.events.add(EventName.noGps) + if not self.sm.all_alive(self.camera_packets): + self.events.add(EventName.cameraMalfunction) + if self.sm['modelV2'].frameDropPerc > 20: + self.events.add(EventName.modeldLagging) + if self.sm['liveLocationKalman'].excessiveResets: + self.events.add(EventName.localizerMalfunction) + + # Check if all manager processes are running + not_running = set(p.name for p in self.sm['managerState'].processes if not p.running) + if self.sm.rcv_frame['managerState'] and (not_running - IGNORE_PROCESSES): + self.events.add(EventName.processNotRunning) -def isActive(state): - """Check if the actuators are enabled""" - return state in [State.enabled, State.softDisabling] - - -def isEnabled(state): - """Check if openpilot is engaged""" - return (isActive(state) or state == State.preEnabled) - -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 - - -def data_sample(CI, CC, sm, 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""" + # Only allow engagement with brake pressed when stopped behind another stopped car + speeds = self.sm['longitudinalPlan'].speeds + if len(speeds) > 1: + v_future = speeds[-1] + else: + v_future = 100.0 + if CS.brakePressed and v_future >= self.CP.vEgoStarting \ + and self.CP.openpilotLongitudinalControl and CS.vEgo < 0.3: + self.events.add(EventName.noTarget) + + def data_sample(self): + """Receive data from sockets and update carState""" + + # 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) + + self.sm.update(0) + + all_valid = CS.canValid and self.sm.all_alive_and_valid() + if not self.initialized and (all_valid or self.sm.frame * DT_CTRL > 3.5 or SIMULATION): + if not self.read_only: + self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan']) + self.initialized = True + Params().put_bool("ControlsReady", True) + + # 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 - CS = CI.update(CC) - events = list(CS.events) - enabled = isEnabled(state) + # 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) + # All pandas not in silent mode must have controlsAllowed when openpilot is enabled + if any(not ps.controlsAllowed and self.enabled for ps in self.sm['pandaStates'] + if ps.safetyModel not in IGNORED_SAFETY_MODES): + self.mismatch_counter += 1 - 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 + self.distance_traveled += CS.vEgo * DT_CTRL - # 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])) + return CS - # Handle calibration - if sm.updated['liveCalibration']: - cal_status = sm['liveCalibration'].calStatus - cal_perc = sm['liveCalibration'].calPerc + def state_transition(self, CS): + """Compute conditional state transitions and execute actions on state transitions""" - 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])) + self.v_cruise_kph_last = self.v_cruise_kph - # 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 stock cruise is completely disabled, then we can use our own set speed logic + if not self.CP.pcmCruise: + self.v_cruise_kph = update_v_cruise(self.v_cruise_kph, CS.buttonEvents, self.button_timers, self.enabled, self.is_metric) + elif self.CP.pcmCruise and CS.cruiseState.enabled: + self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH - 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])) + # decrement 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) - # Driver monitoring - if sm.updated['driverMonitoring']: - driver_status.get_pose(sm['driverMonitoring'], params) + self.current_alert_types = [ET.PERMANENT] - return CS, events, cal_status, cal_perc, overtemp, free_space, low_battery, mismatch_counter + # 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) -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) + else: + # ENABLED + if self.state == State.enabled: + if self.events.any(ET.SOFT_DISABLE): + self.state = State.softDisabling + self.soft_disable_timer = int(SOFT_DISABLE_TIME / DT_CTRL) + 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) - v_cruise_kph_last = v_cruise_kph + else: + 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) + + # 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) + + # Check if openpilot is engaged + self.enabled = self.active or self.state == State.preEnabled + + def state_control(self, CS): + """Given the state, this function returns an actuators packet""" + + # Update VehicleModel + params = self.sm['liveParameters'] + x = max(params.stiffnessFactor, 0.1) + sr = max(params.steerRatio, 0.1) + self.VM.update_params(x, sr) + + lat_plan = self.sm['lateralPlan'] + long_plan = self.sm['longitudinalPlan'] + + actuators = car.CarControl.Actuators.new_message() + actuators.longControlState = self.LoC.long_control_state + + if CS.leftBlinker or CS.rightBlinker: + self.last_blinker_frame = self.sm.frame + + # State specific actions + + if not self.active: + self.LaC.reset() + self.LoC.reset(v_pid=CS.vEgo) + + if not self.joystick_mode: + # accel PID loop + pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, self.v_cruise_kph * CV.KPH_TO_MS) + actuators.accel = self.LoC.update(self.active, CS, self.CP, long_plan, pid_accel_limits) + + # Steering PID loop and lateral MPC + lat_active = self.active and not CS.steerWarning and not CS.steerError and CS.vEgo > self.CP.minSteerSpeed + desired_curvature, desired_curvature_rate = get_lag_adjusted_curvature(self.CP, CS.vEgo, + lat_plan.psis, + lat_plan.curvatures, + lat_plan.curvatureRates) + actuators.steer, actuators.steeringAngleDeg, lac_log = self.LaC.update(lat_active, CS, self.CP, self.VM, params, + desired_curvature, desired_curvature_rate) + else: + lac_log = log.ControlsState.LateralDebugState.new_message() + if self.sm.rcv_frame['testJoystick'] > 0 and self.active: + actuators.accel = 4.0*clip(self.sm['testJoystick'].axes[0], -1, 1) - # 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 + steer = clip(self.sm['testJoystick'].axes[1], -1, 1) + # max angle is 45 for angle-based cars + actuators.steer, actuators.steeringAngleDeg = steer, steer * 45. - # 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) + lac_log.active = True + lac_log.steeringAngleDeg = CS.steeringAngleDeg + lac_log.output = steer + lac_log.saturated = abs(steer) >= 0.9 - # 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) + # 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.steeringAngleDeg - CS.steeringAngleDeg) > STEER_ANGLE_SATURATION_THRESHOLD - 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, 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" - 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.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 + 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 - CAMERA_OFFSET) and left_lane_visible) - - CC.hudControl.visualAlert = AM.visual_alert - CC.hudControl.audibleAlert = AM.audible_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": "", # no EON sounds yet - "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 * 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, - "decelForTurn": sm['plan'].decelForTurn, - "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 - else: - 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']) - logcan = messaging.sub_sock(service_list['can'].port) - - CC = car.CarControl.new_message() - CI, CP = get_car(logcan, sendcan) - AM = AlertManager() - - 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 - - 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) - else: - LaC = LatControlINDI(CP) - - driver_status = DriverStatus() - - # Write CarParams for radard and boardd safety mode - params.put("CarParams", CP.to_bytes()) - params.put("LongitudinalControl", "1" if CP.openpilotLongitudinalControl else "0") - - 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 - - # controlsd is driven by can recv, expected at 100Hz - rk = Ratekeeper(100, print_delay_threshold=None) - - prof = Profiler(False) # off by default - - while True: + 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): + + if len(lat_plan.dPathPoints): + # Check if we deviated from the path + # TODO use desired vs actual curvature + left_deviation = actuators.steer > 0 and lat_plan.dPathPoints[0] < -0.20 + right_deviation = actuators.steer < 0 and lat_plan.dPathPoints[0] > 0.20 + + if left_deviation or right_deviation: + self.events.add(EventName.steerSaturated) + + # Ensure no NaNs/Infs + for p in ACTUATOR_FIELDS: + attr = getattr(actuators, p) + if not isinstance(attr, Number): + continue + + if not math.isfinite(attr): + cloudlog.error(f"actuators.{p} not finite {actuators.to_dict()}") + setattr(actuators, p, 0.0) + + return actuators, lac_log + + def update_button_timers(self, buttonEvents): + # increment timer for buttons still pressed + for k in self.button_timers.keys(): + if self.button_timers[k] > 0: + self.button_timers[k] += 1 + + for b in buttonEvents: + if b.type.raw in self.button_timers: + self.button_timers[b.type.raw] = 1 if b.pressed else 0 + + def publish_logs(self, CS, start_time, actuators, 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.active = self.active + CC.actuators = actuators + + if len(self.sm['liveLocationKalman'].orientationNED.value) > 2: + CC.roll = self.sm['liveLocationKalman'].orientationNED.value[0] + CC.pitch = self.sm['liveLocationKalman'].orientationNED.value[1] + + CC.cruiseControl.cancel = CS.cruiseState.enabled and (not self.enabled or not self.CP.pcmCruise) + if self.joystick_mode and self.sm.rcv_frame['testJoystick'] > 0 and self.sm['testJoystick'].buttons[0]: + CC.cruiseControl.cancel = True + + 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['longitudinalPlan'].hasLead + + CC.hudControl.rightLaneVisible = True + CC.hudControl.leftLaneVisible = True + + 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['modelV2'].meta + if len(meta.desirePrediction) and ldw_allowed: + right_lane_visible = self.sm['lateralPlan'].rProb > 0.5 + left_lane_visible = self.sm['lateralPlan'].lProb > 0.5 + 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['modelV2'].laneLines[1].y[0] > -(1.08 + CAMERA_OFFSET)) + r_lane_close = right_lane_visible and (self.sm['modelV2'].laneLines[2].y[0] < (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.soft_disable_timer]) + self.AM.add_many(self.sm.frame, alerts) + self.AM.process_alerts(self.sm.frame, clear_event) + CC.hudControl.visualAlert = self.AM.visual_alert + + if not self.read_only and self.initialized: + # 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['driverMonitoringState'].awarenessStatus < 0.) or \ + (self.state == State.softDisabling) + + # Curvature & Steering angle + params = self.sm['liveParameters'] + steer_angle_without_offset = math.radians(CS.steeringAngleDeg - params.angleOffsetAverageDeg) + curvature = -self.VM.calc_curvature(steer_angle_without_offset, CS.vEgo) + + # 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.canMonoTimes = list(CS.canMonoTimes) + controlsState.longitudinalPlanMonoTime = self.sm.logMonoTime['longitudinalPlan'] + controlsState.lateralPlanMonoTime = self.sm.logMonoTime['lateralPlan'] + controlsState.enabled = self.enabled + controlsState.active = self.active + controlsState.curvature = curvature + 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.cumLagMs = -self.rk.remaining * 1000. + controlsState.startMonoTime = int(start_time * 1e9) + controlsState.forceDecel = bool(force_decel) + controlsState.canErrorCounter = self.can_error_counter + + if self.joystick_mode: + controlsState.lateralControlState.debugState = lac_log + elif self.CP.steerControlType == car.CarParams.SteerControlType.angle: + controlsState.lateralControlState.angleState = lac_log + elif 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() - 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, 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['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])) + self.prof.checkpoint("Ratekeeper", ignore=True) - # 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])) + # Sample data from sockets and get a carState + CS = self.data_sample() + self.prof.checkpoint("Sample") + + self.update_events(CS) - 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 not self.read_only and self.initialized: + # Update control state + self.state_transition(CS) + self.prof.checkpoint("State transition") # 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'], CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, AM, rk, - driver_status, LaC, LoC, VM, read_only, is_metric, cal_perc) + actuators, lac_log = self.state_control(CS) - prof.checkpoint("State Control") + self.prof.checkpoint("State Control") # 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") + self.publish_logs(CS, start_time, actuators, lac_log) + self.prof.checkpoint("Sent") - rk.monitor_time() - prof.display() + self.update_button_timers(CS.buttonEvents) + def controlsd_thread(self): + while True: + self.step() + self.rk.monitor_time() + self.prof.display() -def main(gctx=None): - controlsd_thread(gctx) +def main(sm=None, pm=None, logcan=None): + controls = Controls(sm, pm, logcan) + controls.controlsd_thread() if __name__ == "__main__": diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py index df2727e6e759c2..c8e702c5c7c1d0 100644 --- a/selfdrive/controls/lib/alertmanager.py +++ b/selfdrive/controls/lib/alertmanager.py @@ -1,70 +1,90 @@ -from cereal import log -from common.realtime import DT_CTRL -from selfdrive.swaglog import cloudlog -from selfdrive.controls.lib.alerts import ALERTS import copy +import os +import json +from collections import defaultdict +from dataclasses import dataclass +from typing import List, Dict, Optional +from cereal import car, log +from common.basedir import BASEDIR +from common.params import Params +from selfdrive.controls.lib.events import Alert -AlertSize = log.ControlsState.AlertSize -AlertStatus = log.ControlsState.AlertStatus +with open(os.path.join(BASEDIR, "selfdrive/controls/lib/alerts_offroad.json")) as f: + OFFROAD_ALERTS = json.load(f) -class AlertManager(object): + +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) + + +@dataclass +class AlertEntry: + alert: Optional[Alert] = None + start_frame: int = -1 + end_frame: int = -1 + + def active(self, frame: int) -> bool: + return frame <= self.end_frame + +class AlertManager: def __init__(self): - self.activealerts = [] - self.alerts = {alert.alert_type: alert for alert in ALERTS} - - 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 - - # 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) - - self.activealerts.append(added_alert) - - # 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] - - current_alert = self.activealerts[0] if self.alertPresent() else None - - # 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 = "none" - self.audible_alert = "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: - self.audible_alert = current_alert.audible_alert - - if current_alert.start_time + current_alert.duration_hud_alert > cur_time: - self.visual_alert = current_alert.visual_alert - - if current_alert.start_time + current_alert.duration_text > cur_time: - self.alert_text_1 = current_alert.alert_text_1 - self.alert_text_2 = current_alert.alert_text_2 - self.alert_status = current_alert.alert_status - self.alert_size = current_alert.alert_size - self.alert_rate = current_alert.alert_rate + self.reset() + self.alerts: Dict[str, AlertEntry] = defaultdict(AlertEntry) + + def reset(self) -> None: + self.alert: Optional[Alert] = 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]) -> None: + for alert in alerts: + key = alert.alert_type + self.alerts[key].alert = alert + if not self.alerts[key].active(frame): + self.alerts[key].start_frame = frame + min_end_frame = self.alerts[key].start_frame + alert.duration + self.alerts[key].end_frame = max(frame + 1, min_end_frame) + + def process_alerts(self, frame: int, clear_event_type=None) -> None: + current_alert = AlertEntry() + for k, v in self.alerts.items(): + if v.alert is None: + continue + + if clear_event_type is not None and v.alert.event_type == clear_event_type: + self.alerts[k].end_frame = -1 + + # sort by priority first and then by start_frame + greater = current_alert.alert is None or (v.alert.priority, v.start_frame) > (current_alert.alert.priority, current_alert.start_frame) + if v.active(frame) and greater: + current_alert = v + + # clear current alert + self.reset() + + self.alert = current_alert.alert + if self.alert is not None: + self.alert_type = self.alert.alert_type + self.audible_alert = self.alert.audible_alert + self.visual_alert = self.alert.visual_alert + self.alert_text_1 = self.alert.alert_text_1 + self.alert_text_2 = self.alert.alert_text_2 + self.alert_status = self.alert.alert_status + self.alert_size = self.alert.alert_size + self.alert_rate = self.alert.alert_rate diff --git a/selfdrive/controls/lib/alerts.py b/selfdrive/controls/lib/alerts.py deleted file mode 100644 index da7e88acbd46dd..00000000000000 --- a/selfdrive/controls/lib/alerts.py +++ /dev/null @@ -1,662 +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", - "Always keep hands on wheel and eyes on road", - 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.), - - # Cancellation alerts causing soft disabling - Alert( - "overheat", - "TAKE CONTROL IMMEDIATELY", - "System Overheated", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "wrongGear", - "TAKE CONTROL IMMEDIATELY", - "Gear not D", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "calibrationInvalid", - "TAKE CONTROL IMMEDIATELY", - "Calibration Invalid: Reposition EON and Recalibrate", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "calibrationIncomplete", - "TAKE CONTROL IMMEDIATELY", - "Calibration in Progress", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "doorOpen", - "TAKE CONTROL IMMEDIATELY", - "Door Open", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "seatbeltNotLatched", - "TAKE CONTROL IMMEDIATELY", - "Seatbelt Unlatched", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "espDisabled", - "TAKE CONTROL IMMEDIATELY", - "ESP Off", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "lowBattery", - "TAKE CONTROL IMMEDIATELY", - "Low Battery", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "commIssue", - "TAKE CONTROL IMMEDIATELY", - "Communication Issue between Processes", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "radarCanError", - "TAKE CONTROL IMMEDIATELY", - "Radar Error: Restart the Car", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .1, 2., 2.), - - Alert( - "radarFault", - "TAKE CONTROL IMMEDIATELY", - "Radar Error: Restart the Car", - AlertStatus.critical, AlertSize.full, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2, .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", - "Invalid Giraffe Configuration", - "Set 0111 for openpilot. 1011 for stock", - 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( - "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", - "Invalid Giraffe Configuration", - "Set 0111 for openpilot. 1011 for stock", - 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( - "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..4affe0cfe30af5 --- /dev/null +++ b/selfdrive/controls/lib/alerts_offroad.json @@ -0,0 +1,52 @@ +{ + "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 automatically start 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_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_UnofficialHardware": { + "text": "Device failed to register. It will not connect to or upload to comma.ai servers, and receives no support from comma.ai. If this is an official device, contact support@comma.ai.", + "severity": 1 + }, + "Offroad_StorageMissing": { + "text": "Storage drive not mounted.", + "severity": 1 + }, + "Offroad_CarUnrecognized": { + "text": "openpilot was unable to identify your car. Your car is either unsupported or its ECUs are not recognized. Please submit a pull request to add the firmware versions to the proper vehicle. Need help? Join discord.comma.ai.", + "severity": 0 + }, + "Offroad_NoFirmware": { + "text": "openpilot was unable to identify your car. Check integrity of cables and ensure all connections are secure, particularly that the comma power is fully inserted in the OBD-II port of the vehicle. Need help? Join discord.comma.ai.", + "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.cpp b/selfdrive/controls/lib/cluster/fastcluster.cpp index 6b0af725cef289..d2b557d6f5be20 100644 --- a/selfdrive/controls/lib/cluster/fastcluster.cpp +++ b/selfdrive/controls/lib/cluster/fastcluster.cpp @@ -188,11 +188,11 @@ extern "C" { // out = allocated integer array of size n * (n - 1) / 2 for result void hclust_pdist(int n, int m, double* pts, double* out) { int ii = 0; - for (int i = 0; i < n; i++){ - for (int j = i + 1; j < n; j++){ + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { // Compute euclidian distance double d = 0; - for (int k = 0; k < m; k ++){ + for (int k = 0; k < m; k ++) { double error = pts[i * m + k] - pts[j * m + k]; d += (error * error); } 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/cluster/test.cpp b/selfdrive/controls/lib/cluster/test.cpp index 208867775d7d6d..d4e4fa5361c3ce 100644 --- a/selfdrive/controls/lib/cluster/test.cpp +++ b/selfdrive/controls/lib/cluster/test.cpp @@ -5,7 +5,7 @@ extern "C" { } -int main(int argc, const char* argv[]){ +int main(int argc, const char* argv[]) { const int n = 11; const int m = 3; double* pts = new double[n*m]{59.26000137, -9.35999966, -5.42500019, @@ -25,7 +25,7 @@ int main(int argc, const char* argv[]){ cluster_points_centroid(n, m, pts, 2.5 * 2.5, idx); - for (int i = 0; i < n; i++){ + for (int i = 0; i < n; i++) { assert(idx[i] == correct_idx[i]); } diff --git a/selfdrive/controls/lib/drive_helpers.py b/selfdrive/controls/lib/drive_helpers.py index 9c1144b966abdc..f173f5fd98e09e 100644 --- a/selfdrive/controls/lib/drive_helpers.py +++ b/selfdrive/controls/lib/drive_helpers.py @@ -1,17 +1,38 @@ +import math from cereal import car from common.numpy_fast import clip, interp +from common.realtime import DT_MDL from selfdrive.config import Conversions as CV - -# kph -V_CRUISE_MAX = 144 -V_CRUISE_MIN = 8 -V_CRUISE_DELTA = 8 -V_CRUISE_ENABLE_MIN = 40 +from selfdrive.modeld.constants import T_IDXS + +# WARNING: this value was determined based on the model's training distribution, +# model predictions above this speed can be unpredictable +V_CRUISE_MAX = 145 # kph +V_CRUISE_MIN = 8 # kph +V_CRUISE_ENABLE_MIN = 40 # kph + +LAT_MPC_N = 16 +LON_MPC_N = 32 +CONTROL_N = 17 +CAR_ROTATION_RADIUS = 0.0 + +# this corresponds to 80deg/s and 20deg/s steering angle in a toyota corolla +MAX_CURVATURE_RATES = [0.03762194918267951, 0.003441203371932992] +MAX_CURVATURE_RATE_SPEEDS = [0, 35] + +CRUISE_LONG_PRESS = 50 +CRUISE_NEAREST_FUNC = { + car.CarState.ButtonEvent.Type.accelCruise: math.ceil, + car.CarState.ButtonEvent.Type.decelCruise: math.floor, +} +CRUISE_INTERVAL_SIGN = { + car.CarState.ButtonEvent.Type.accelCruise: +1, + car.CarState.ButtonEvent.Type.decelCruise: -1, +} class MPC_COST_LAT: PATH = 1.0 - LANE = 3.0 HEADING = 1.0 STEER_RATE = 1.0 @@ -23,34 +44,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,36 +52,37 @@ 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) +def update_v_cruise(v_cruise_kph, buttonEvents, button_timers, enabled, metric): + # 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 + if not enabled: + return v_cruise_kph - return angle_model_bias + long_press = False + button_type = None + v_cruise_delta = 1 if metric else 1.6 -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": - v_cruise_kph += V_CRUISE_DELTA - (v_cruise_kph % V_CRUISE_DELTA) - elif b.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) + if b.type.raw in button_timers and not b.pressed: + if button_timers[b.type.raw] > CRUISE_LONG_PRESS: + return v_cruise_kph # end long press + button_type = b.type.raw + break + else: + for k in button_timers.keys(): + if button_timers[k] and button_timers[k] % CRUISE_LONG_PRESS == 0: + button_type = k + long_press = True + break + + if button_type: + v_cruise_delta = v_cruise_delta * (5 if long_press else 1) + if long_press and v_cruise_kph % v_cruise_delta != 0: # partial interval + v_cruise_kph = CRUISE_NEAREST_FUNC[button_type](v_cruise_kph / v_cruise_delta) * v_cruise_delta + else: + v_cruise_kph += v_cruise_delta * CRUISE_INTERVAL_SIGN[button_type] + v_cruise_kph = clip(round(v_cruise_kph, 1), V_CRUISE_MIN, V_CRUISE_MAX) return v_cruise_kph @@ -96,7 +90,35 @@ 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))) + + +def get_lag_adjusted_curvature(CP, v_ego, psis, curvatures, curvature_rates): + if len(psis) != CONTROL_N: + psis = [0.0 for i in range(CONTROL_N)] + curvatures = [0.0 for i in range(CONTROL_N)] + curvature_rates = [0.0 for i in range(CONTROL_N)] + + # TODO this needs more thought, use .2s extra for now to estimate other delays + delay = CP.steerActuatorDelay + .2 + current_curvature = curvatures[0] + psi = interp(delay, T_IDXS[:CONTROL_N], psis) + desired_curvature_rate = curvature_rates[0] + + # MPC can plan to turn the wheel and turn back before t_delay. This means + # in high delay cases some corrections never even get commanded. So just use + # psi to calculate a simple linearization of desired curvature + curvature_diff_from_psi = psi / (max(v_ego, 1e-1) * delay) - current_curvature + desired_curvature = current_curvature + 2 * curvature_diff_from_psi + + max_curvature_rate = interp(v_ego, MAX_CURVATURE_RATE_SPEEDS, MAX_CURVATURE_RATES) + safe_desired_curvature_rate = clip(desired_curvature_rate, + -max_curvature_rate, + max_curvature_rate) + safe_desired_curvature = clip(desired_curvature, + current_curvature - max_curvature_rate/DT_MDL, + current_curvature + max_curvature_rate/DT_MDL) + return safe_desired_curvature, safe_desired_curvature_rate diff --git a/selfdrive/controls/lib/driver_monitor.py b/selfdrive/controls/lib/driver_monitor.py deleted file mode 100644 index e813d0b176c81e..00000000000000 --- a/selfdrive/controls/lib/driver_monitor.py +++ /dev/null @@ -1,170 +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 = 180 # 3 minutes limit without user touching steering wheels make the car enter a terminal status -_AWARENESS_PRE_TIME = 20. # a first alert is issued 20s before expiration -_AWARENESS_PROMPT_TIME = 5. # a second alert is issued 5s before start decelerating the car -_DISTRACTED_TIME = 7. -_DISTRACTED_PRE_TIME = 4. -_DISTRACTED_PROMPT_TIME = 2. -# model output refers to center of cropped image, so need to apply the x displacement offset -_PITCH_WEIGHT = 1.5 # pitch matters a lot more -_METRIC_THRESHOLD = 0.4 -_PITCH_POS_ALLOWANCE = 0.08 # rad, to not be too sensitive on positive pitch -_PITCH_NATURAL_OFFSET = 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) -_STD_THRESHOLD = 0.1 # above this standard deviation consider the measurement invalid -_DISTRACTED_FILTER_TS = 0.25 # 0.6Hz -_VARIANCE_FILTER_TS = 20. # 0.008Hz - -RESIZED_FOCAL = 320.0 -H, W, FULL_W = 320, 160, 426 - - -def head_orientation_from_descriptor(desc): - # the output of these angles are in device frame - # so from driver's perspective, pitch is up and yaw is right - # TODO this should be calibrated - pitch_prnet = desc[0] - yaw_prnet = desc[1] - roll_prnet = desc[2] - - face_pixel_position = ((desc[3] + .5)*W - W + FULL_W, (desc[4]+.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 - 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. - - -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.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._set_timers() - - def _reset_filters(self): - self.driver_distraction_filter.x = 0. - self.variance_filter.x = 0. - self.monitor_valid = True - - def _set_timers(self): - if self.monitor_on: - self.threshold_pre = _DISTRACTED_PRE_TIME / _DISTRACTED_TIME - self.threshold_prompt = _DISTRACTED_PROMPT_TIME / _DISTRACTED_TIME - self.step_change = DT_CTRL / _DISTRACTED_TIME - else: - self.threshold_pre = _AWARENESS_PRE_TIME / _AWARENESS_TIME - self.threshold_prompt = _AWARENESS_PROMPT_TIME / _AWARENESS_TIME - self.step_change = DT_CTRL / _AWARENESS_TIME - - def _is_driver_distracted(self, pose): - # to be tuned and to learn the driver's normal pose - 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 - metric = np.sqrt(yaw_error**2 + pitch_error**2) - #print "%02.4f" % np.degrees(pose.pitch), "%02.4f" % np.degrees(pitch_error), "%03.4f" % np.degrees(pose.pitch_offset), metric - return 1 if metric > _METRIC_THRESHOLD else 0 - - - def get_pose(self, driver_monitoring, params): - - self.pose.roll, self.pose.pitch, self.pose.yaw = head_orientation_from_descriptor(driver_monitoring.descriptor) - - # TODO: DM data should not be in a list if they are not homogeneous - if len(driver_monitoring.descriptor) > 6: - self.face_detected = driver_monitoring.descriptor[6] > 0. - else: - self.face_detected = True - - self.driver_distracted = self._is_driver_distracted(self.pose) - # first order filters - self.driver_distraction_filter.update(self.driver_distracted) - self.variance_high = driver_monitoring.std > _STD_THRESHOLD - self.variance_filter.update(self.variance_high) - - monitor_param_on_prev = self.monitor_param_on - monitor_valid_prev = self.monitor_valid - - # 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_valid = _monitor_hysteresis(self.variance_filter.x, monitor_valid_prev) - 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() - - - def update(self, events, driver_engaged, ctrl_active, standstill): - - driver_engaged |= (self.driver_distraction_filter.x < 0.37 and self.monitor_on) - - 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 = 1. - - # only update if face is detected, driver is distracted and distraction filter is high - if (not self.monitor_on 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' - 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..0048ca661c333d --- /dev/null +++ b/selfdrive/controls/lib/events.py @@ -0,0 +1,835 @@ +from enum import IntEnum +from typing import Dict, Union, Callable + +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: + 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, + priority: Priority, + visual_alert: car.CarControl.HUDControl.VisualAlert, + audible_alert: car.CarControl.HUDControl.AudibleAlert, + duration: 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.priority = priority + self.visual_alert = visual_alert + self.audible_alert = audible_alert + + self.duration = int(duration / DT_CTRL) + + self.alert_rate = alert_rate + self.creation_delay = creation_delay + + self.alert_type = "" + self.event_type = None + + def __str__(self) -> str: + return f"{self.alert_text_1}/{self.alert_text_2} {self.priority} {self.visual_alert} {self.audible_alert}" + + def __gt__(self, alert2) -> bool: + return self.priority > alert2.priority + + +class NoEntryAlert(Alert): + def __init__(self, alert_text_2, visual_alert=VisualAlert.none): + super().__init__("openpilot Unavailable", alert_text_2, AlertStatus.normal, + AlertSize.mid, Priority.LOW, visual_alert, + AudibleAlert.refuse, 3.) + + +class SoftDisableAlert(Alert): + def __init__(self, alert_text_2): + super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2, + AlertStatus.userPrompt, AlertSize.full, + Priority.MID, VisualAlert.steerRequired, + AudibleAlert.warningSoft, 2.), + + +# less harsh version of SoftDisable, where the condition is user-triggered +class UserSoftDisableAlert(SoftDisableAlert): + def __init__(self, alert_text_2): + super().__init__(alert_text_2), + self.alert_text_1 = "openpilot will disengage" + + +class ImmediateDisableAlert(Alert): + def __init__(self, alert_text_2): + super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2, + AlertStatus.critical, AlertSize.full, + Priority.HIGHEST, VisualAlert.steerRequired, + AudibleAlert.warningImmediate, 4.), + + +class EngagementAlert(Alert): + def __init__(self, audible_alert: car.CarControl.HUDControl.AudibleAlert): + super().__init__("", "", + AlertStatus.normal, AlertSize.none, + Priority.MID, VisualAlert.none, + audible_alert, .2), + + +class NormalPermanentAlert(Alert): + def __init__(self, alert_text_1: str, alert_text_2: str = "", duration: float = 0.2, priority: Priority = Priority.LOWER, creation_delay: float = 0.): + super().__init__(alert_text_1, alert_text_2, + AlertStatus.normal, AlertSize.mid if len(alert_text_2) else AlertSize.small, + priority, VisualAlert.none, AudibleAlert.none, duration, creation_delay=creation_delay), + + +class StartupAlert(Alert): + def __init__(self, alert_text_1: str, alert_text_2: str = "Always keep hands on wheel and eyes on road", alert_status=AlertStatus.normal): + super().__init__(alert_text_1, alert_text_2, + alert_status, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.), + + +# ********** helper functions ********** +def get_display_speed(speed_ms: float, metric: bool) -> str: + speed = int(round(speed_ms * (CV.MS_TO_KPH if metric else CV.MS_TO_MPH))) + unit = 'km/h' if metric else 'mph' + return f"{speed} {unit}" + + +# ********** alert callback functions ********** + +AlertCallbackType = Callable[[car.CarParams, messaging.SubMaster, bool, int], Alert] + + +def soft_disable_alert(alert_text_2: str) -> AlertCallbackType: + def func(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + if soft_disable_time < int(0.5 / DT_CTRL): + return ImmediateDisableAlert(alert_text_2) + return SoftDisableAlert(alert_text_2) + return func + + +def user_soft_disable_alert(alert_text_2: str) -> AlertCallbackType: + def func(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + if soft_disable_time < int(0.5 / DT_CTRL): + return ImmediateDisableAlert(alert_text_2) + return UserSoftDisableAlert(alert_text_2) + return func + + +def below_engage_speed_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + return NoEntryAlert(f"Speed Below {get_display_speed(CP.minEnableSpeed, metric)}") + + +def below_steer_speed_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + return Alert( + f"Steer Unavailable Below {get_display_speed(CP.minSteerSpeed, metric)}", + "", + AlertStatus.userPrompt, AlertSize.small, + Priority.MID, VisualAlert.steerRequired, AudibleAlert.prompt, 0.4) + + +def calibration_incomplete_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + return Alert( + "Calibration in Progress: %d%%" % sm['liveCalibration'].calPerc, + f"Drive Above {get_display_speed(MIN_SPEED_FILTER, metric)}", + AlertStatus.normal, AlertSize.mid, + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2) + + +def no_gps_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + gps_integrated = sm['peripheralState'].pandaType in [log.PandaState.PandaType.uno, log.PandaState.PandaType.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, .2, creation_delay=300.) + + +def wrong_car_mode_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + text = "Cruise Mode Disabled" + if CP.carName == "honda": + text = "Main Switch Off" + return NoEntryAlert(text) + + +def joystick_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: + axes = sm['testJoystick'].axes + gb, steer = list(axes)[:2] if len(axes) else (0., 0.) + vals = f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%" + return NormalPermanentAlert("Joystick Mode", vals) + + + +EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = { + # ********** events with no alerts ********** + + EventName.stockFcw: {}, + + # ********** events only containing alerts displayed in all states ********** + + EventName.joystickDebug: { + ET.WARNING: joystick_alert, + ET.PERMANENT: NormalPermanentAlert("Joystick Mode"), + }, + + EventName.controlsInitializing: { + ET.NO_ENTRY: NoEntryAlert("System Initializing"), + }, + + EventName.startup: { + ET.PERMANENT: StartupAlert("Be ready to take over at any time") + }, + + EventName.startupMaster: { + ET.PERMANENT: StartupAlert("WARNING: This branch is not tested", + alert_status=AlertStatus.userPrompt), + }, + + # Car is recognized, but marked as dashcam only + EventName.startupNoControl: { + ET.PERMANENT: StartupAlert("Dashcam mode"), + }, + + # Car is not recognized + EventName.startupNoCar: { + ET.PERMANENT: StartupAlert("Dashcam mode for unsupported car"), + }, + + EventName.startupNoFw: { + ET.PERMANENT: StartupAlert("Car Unrecognized", + "Check comma power connections", + alert_status=AlertStatus.userPrompt), + }, + + EventName.dashcamMode: { + ET.PERMANENT: NormalPermanentAlert("Dashcam Mode", + priority=Priority.LOWEST), + }, + + EventName.invalidLkasSetting: { + ET.PERMANENT: NormalPermanentAlert("Stock LKAS is on", + "Turn off stock LKAS to engage"), + }, + + EventName.cruiseMismatch: { + #ET.PERMANENT: ImmediateDisableAlert("openpilot failed to cancel cruise"), + }, + + # Some features or cars are marked as community features. If openpilot + # detects the use of a community feature it switches to dashcam mode + # until these features are allowed using a toggle in settings. + EventName.communityFeatureDisallowed: { + ET.PERMANENT: NormalPermanentAlert("openpilot Unavailable", + "Enable Community Features in Settings"), + }, + + # openpilot doesn't recognize the car. This switches openpilot into a + # read-only mode. This can be solved by adding your fingerprint. + # See https://github.com/commaai/openpilot/wiki/Fingerprinting for more information + EventName.carUnrecognized: { + ET.PERMANENT: NormalPermanentAlert("Dashcam Mode", + "Car Unrecognized", + priority=Priority.LOWEST), + }, + + EventName.stockAeb: { + ET.PERMANENT: Alert( + "BRAKE!", + "Stock AEB: Risk of Collision", + AlertStatus.critical, AlertSize.full, + Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.none, 2.), + ET.NO_ENTRY: NoEntryAlert("Stock AEB: Risk of Collision"), + }, + + EventName.fcw: { + ET.PERMANENT: Alert( + "BRAKE!", + "Risk of Collision", + AlertStatus.critical, AlertSize.full, + Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.warningSoft, 2.), + }, + + EventName.ldw: { + ET.PERMANENT: Alert( + "Lane Departure Detected", + "", + AlertStatus.userPrompt, AlertSize.small, + Priority.LOW, VisualAlert.ldw, AudibleAlert.prompt, 3.), + }, + + # ********** events only containing alerts that display while engaged ********** + + EventName.gasPressed: { + ET.PRE_ENABLE: Alert( + "Release Gas Pedal to Engage", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .1, creation_delay=1.), + }, + + # openpilot tries to learn certain parameters about your car by observing + # how the car behaves to steering inputs from both human and openpilot driving. + # This includes: + # - steer ratio: gear ratio of the steering rack. Steering angle divided by tire angle + # - tire stiffness: how much grip your tires have + # - angle offset: most steering angle sensors are offset and measure a non zero angle when driving straight + # This alert is thrown when any of these values exceed a sanity check. This can be caused by + # bad alignment or bad sensor data. If this happens consistently consider creating an issue on GitHub + EventName.vehicleModelInvalid: { + ET.NO_ENTRY: NoEntryAlert("Vehicle Parameter Identification Failed"), + ET.SOFT_DISABLE: soft_disable_alert("Vehicle Parameter Identification Failed"), + }, + + EventName.steerTempUnavailableSilent: { + ET.WARNING: Alert( + "Steering Temporarily Unavailable", + "", + AlertStatus.userPrompt, AlertSize.small, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.prompt, 1.), + }, + + EventName.preDriverDistracted: { + ET.WARNING: Alert( + "Pay Attention", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .1), + }, + + EventName.promptDriverDistracted: { + ET.WARNING: Alert( + "Pay Attention", + "Driver Distracted", + AlertStatus.userPrompt, AlertSize.mid, + Priority.MID, VisualAlert.steerRequired, AudibleAlert.promptDistracted, .1), + }, + + EventName.driverDistracted: { + ET.WARNING: Alert( + "DISENGAGE IMMEDIATELY", + "Driver Distracted", + AlertStatus.critical, AlertSize.full, + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.warningImmediate, .1), + }, + + EventName.preDriverUnresponsive: { + ET.WARNING: Alert( + "Touch Steering Wheel: No Face Detected", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .1, alert_rate=0.75), + }, + + EventName.promptDriverUnresponsive: { + ET.WARNING: Alert( + "Touch Steering Wheel", + "Driver Unresponsive", + AlertStatus.userPrompt, AlertSize.mid, + Priority.MID, VisualAlert.steerRequired, AudibleAlert.promptDistracted, .1), + }, + + EventName.driverUnresponsive: { + ET.WARNING: Alert( + "DISENGAGE IMMEDIATELY", + "Driver Unresponsive", + AlertStatus.critical, AlertSize.full, + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.warningImmediate, .1), + }, + + EventName.manualRestart: { + ET.WARNING: Alert( + "TAKE CONTROL", + "Resume Driving Manually", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .2), + }, + + EventName.resumeRequired: { + ET.WARNING: Alert( + "STOPPED", + "Press Resume to Go", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .2), + }, + + EventName.belowSteerSpeed: { + ET.WARNING: below_steer_speed_alert, + }, + + EventName.preLaneChangeLeft: { + ET.WARNING: Alert( + "Steer Left to Start Lane Change Once Safe", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, alert_rate=0.75), + }, + + EventName.preLaneChangeRight: { + ET.WARNING: Alert( + "Steer Right to Start Lane Change Once Safe", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, alert_rate=0.75), + }, + + EventName.laneChangeBlocked: { + ET.WARNING: Alert( + "Car Detected in Blindspot", + "", + AlertStatus.userPrompt, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.prompt, .1), + }, + + EventName.laneChange: { + ET.WARNING: Alert( + "Changing Lanes", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.none, .1), + }, + + EventName.steerSaturated: { + ET.WARNING: Alert( + "Take Control", + "Turn Exceeds Steering Limit", + AlertStatus.userPrompt, AlertSize.mid, + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.promptRepeat, 1.), + }, + + # Thrown when the fan is driven at >50% but is not rotating + EventName.fanMalfunction: { + ET.PERMANENT: NormalPermanentAlert("Fan Malfunction", "Contact Support"), + }, + + # Camera is not outputting frames at a constant framerate + EventName.cameraMalfunction: { + ET.PERMANENT: NormalPermanentAlert("Camera Malfunction", "Contact Support"), + }, + + # Unused + EventName.gpsMalfunction: { + ET.PERMANENT: NormalPermanentAlert("GPS Malfunction", "Contact Support"), + }, + + # When the GPS position and localizer diverge the localizer is reset to the + # current GPS position. This alert is thrown when the localizer is reset + # more often than expected. + EventName.localizerMalfunction: { + ET.PERMANENT: NormalPermanentAlert("Sensor Malfunction", "Contact Support"), + }, + + # ********** events that affect controls state transitions ********** + + EventName.pcmEnable: { + ET.ENABLE: EngagementAlert(AudibleAlert.engage), + }, + + EventName.buttonEnable: { + ET.ENABLE: EngagementAlert(AudibleAlert.engage), + }, + + EventName.pcmDisable: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage), + }, + + EventName.buttonCancel: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage), + }, + + EventName.brakeHold: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage), + ET.NO_ENTRY: NoEntryAlert("Brake Hold Active"), + }, + + EventName.parkBrake: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage), + ET.NO_ENTRY: NoEntryAlert("Parking Brake Engaged"), + }, + + EventName.pedalPressed: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage), + ET.NO_ENTRY: NoEntryAlert("Pedal Pressed", + visual_alert=VisualAlert.brakePressed), + }, + + EventName.wrongCarMode: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage), + ET.NO_ENTRY: wrong_car_mode_alert, + }, + + EventName.wrongCruiseMode: { + ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage), + ET.NO_ENTRY: NoEntryAlert("Adaptive Cruise Disabled"), + }, + + EventName.steerTempUnavailable: { + ET.SOFT_DISABLE: soft_disable_alert("Steering Temporarily Unavailable"), + ET.NO_ENTRY: NoEntryAlert("Steering Temporarily Unavailable"), + }, + + EventName.outOfSpace: { + ET.PERMANENT: NormalPermanentAlert("Out of Storage"), + ET.NO_ENTRY: NoEntryAlert("Out of Storage"), + }, + + EventName.belowEngageSpeed: { + ET.NO_ENTRY: below_engage_speed_alert, + }, + + EventName.sensorDataInvalid: { + ET.PERMANENT: Alert( + "No Data from Device Sensors", + "Reboot your Device", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, .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: NormalPermanentAlert("System Overheated"), + ET.SOFT_DISABLE: soft_disable_alert("System Overheated"), + ET.NO_ENTRY: NoEntryAlert("System Overheated"), + }, + + EventName.wrongGear: { + ET.SOFT_DISABLE: user_soft_disable_alert("Gear not D"), + ET.NO_ENTRY: NoEntryAlert("Gear not D"), + }, + + # This alert is thrown when the calibration angles are outside of the acceptable range. + # For example if the device is pointed too much to the left or the right. + # Usually this can only be solved by removing the mount from the windshield completely, + # and attaching while making sure the device is pointed straight forward and is level. + # See https://comma.ai/setup for more information + EventName.calibrationInvalid: { + ET.PERMANENT: NormalPermanentAlert("Calibration Invalid", "Remount Device and Recalibrate"), + ET.SOFT_DISABLE: soft_disable_alert("Calibration Invalid: Remount Device & Recalibrate"), + ET.NO_ENTRY: NoEntryAlert("Calibration Invalid: Remount Device & Recalibrate"), + }, + + EventName.calibrationIncomplete: { + ET.PERMANENT: calibration_incomplete_alert, + ET.SOFT_DISABLE: soft_disable_alert("Calibration in Progress"), + ET.NO_ENTRY: NoEntryAlert("Calibration in Progress"), + }, + + EventName.doorOpen: { + ET.SOFT_DISABLE: user_soft_disable_alert("Door Open"), + ET.NO_ENTRY: NoEntryAlert("Door Open"), + }, + + EventName.seatbeltNotLatched: { + ET.SOFT_DISABLE: user_soft_disable_alert("Seatbelt Unlatched"), + ET.NO_ENTRY: NoEntryAlert("Seatbelt Unlatched"), + }, + + EventName.espDisabled: { + ET.SOFT_DISABLE: soft_disable_alert("ESP Off"), + ET.NO_ENTRY: NoEntryAlert("ESP Off"), + }, + + EventName.lowBattery: { + ET.SOFT_DISABLE: soft_disable_alert("Low Battery"), + ET.NO_ENTRY: NoEntryAlert("Low Battery"), + }, + + # Different openpilot services communicate between each other at a certain + # interval. If communication does not follow the regular schedule this alert + # is thrown. This can mean a service crashed, did not broadcast a message for + # ten times the regular interval, or the average interval is more than 10% too high. + EventName.commIssue: { + ET.SOFT_DISABLE: soft_disable_alert("Communication Issue between Processes"), + ET.NO_ENTRY: NoEntryAlert("Communication Issue between Processes"), + }, + + # Thrown when manager detects a service exited unexpectedly while driving + EventName.processNotRunning: { + ET.NO_ENTRY: NoEntryAlert("System Malfunction: Reboot Your Device"), + }, + + EventName.radarFault: { + ET.SOFT_DISABLE: soft_disable_alert("Radar Error: Restart the Car"), + ET.NO_ENTRY: NoEntryAlert("Radar Error: Restart the Car"), + }, + + # Every frame from the camera should be processed by the model. If modeld + # is not processing frames fast enough they have to be dropped. This alert is + # thrown when over 20% of frames are dropped. + EventName.modeldLagging: { + ET.SOFT_DISABLE: soft_disable_alert("Driving model lagging"), + ET.NO_ENTRY: NoEntryAlert("Driving model lagging"), + }, + + # Besides predicting the path, lane lines and lead car data the model also + # predicts the current velocity and rotation speed of the car. If the model is + # very uncertain about the current velocity while the car is moving, this + # usually means the model has trouble understanding the scene. This is used + # as a heuristic to warn the driver. + EventName.posenetInvalid: { + ET.SOFT_DISABLE: soft_disable_alert("Model Output Uncertain"), + ET.NO_ENTRY: NoEntryAlert("Model Output Uncertain"), + }, + + # When the localizer detects an acceleration of more than 40 m/s^2 (~4G) we + # alert the driver the device might have fallen from the windshield. + EventName.deviceFalling: { + ET.SOFT_DISABLE: soft_disable_alert("Device Fell Off Mount"), + ET.NO_ENTRY: NoEntryAlert("Device Fell Off Mount"), + }, + + EventName.lowMemory: { + ET.SOFT_DISABLE: soft_disable_alert("Low Memory: Reboot Your Device"), + ET.PERMANENT: NormalPermanentAlert("Low Memory", "Reboot your Device"), + ET.NO_ENTRY: NoEntryAlert("Low Memory: Reboot Your Device"), + }, + + EventName.highCpuUsage: { + #ET.SOFT_DISABLE: soft_disable_alert("System Malfunction: Reboot Your Device"), + #ET.PERMANENT: NormalPermanentAlert("System Malfunction", "Reboot your Device"), + ET.NO_ENTRY: NoEntryAlert("System Malfunction: Reboot Your Device"), + }, + + EventName.accFaulted: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Cruise Faulted"), + ET.PERMANENT: NormalPermanentAlert("Cruise Faulted", ""), + ET.NO_ENTRY: NoEntryAlert("Cruise Faulted"), + }, + + EventName.controlsMismatch: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Controls Mismatch"), + }, + + EventName.roadCameraError: { + ET.PERMANENT: NormalPermanentAlert("Camera Error", + duration=1., + creation_delay=30.), + }, + + EventName.driverCameraError: { + ET.PERMANENT: NormalPermanentAlert("Camera Error", + duration=1., + creation_delay=30.), + }, + + EventName.wideRoadCameraError: { + ET.PERMANENT: NormalPermanentAlert("Camera Error", + duration=1., + creation_delay=30.), + }, + + # Sometimes the USB stack on the device can get into a bad state + # causing the connection to the panda to be lost + EventName.usbError: { + ET.SOFT_DISABLE: soft_disable_alert("USB Error: Reboot Your Device"), + ET.PERMANENT: NormalPermanentAlert("USB Error: Reboot Your Device", ""), + ET.NO_ENTRY: NoEntryAlert("USB Error: Reboot Your Device"), + }, + + # This alert can be thrown for the following reasons: + # - No CAN data received at all + # - CAN data is received, but some message are not received at the right frequency + # If you're not writing a new car port, this is usually cause by faulty wiring + 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, 1., creation_delay=1.), + ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"), + }, + + EventName.steerUnavailable: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("LKAS Fault: Restart the Car"), + ET.PERMANENT: NormalPermanentAlert("LKAS Fault: Restart the car to engage"), + ET.NO_ENTRY: NoEntryAlert("LKAS Fault: Restart the Car"), + }, + + EventName.brakeUnavailable: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Cruise Fault: Restart the Car"), + ET.PERMANENT: NormalPermanentAlert("Cruise Fault: Restart the car to engage"), + 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, .2, creation_delay=0.5), + ET.USER_DISABLE: ImmediateDisableAlert("Reverse Gear"), + ET.NO_ENTRY: NoEntryAlert("Reverse Gear"), + }, + + # On cars that use stock ACC the car can decide to cancel ACC for various reasons. + # When this happens we can no long control the car so the user needs to be warned immediately. + EventName.cruiseDisabled: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Cruise Is Off"), + }, + + # For planning the trajectory Model Predictive Control (MPC) is used. This is + # an optimization algorithm that is not guaranteed to find a feasible solution. + # If no solution is found or the solution has a very high cost this alert is thrown. + EventName.plannerError: { + ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Planner Solution Error"), + ET.NO_ENTRY: NoEntryAlert("Planner Solution Error"), + }, + + # When the relay in the harness box opens the CAN bus between the LKAS camera + # and the rest of the car is separated. When messages from the LKAS camera + # are received on the car side this usually means the relay hasn't opened correctly + # and this alert is thrown. + 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.disengage, 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.disengage, 3.), + }, + + # When the car is driving faster than most cars in the training data, the model outputs can be unpredictable. + EventName.speedTooHigh: { + ET.WARNING: Alert( + "Speed Too High", + "Model uncertain at this speed", + AlertStatus.userPrompt, AlertSize.mid, + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.promptRepeat, 4.), + ET.NO_ENTRY: NoEntryAlert("Slow down to engage"), + }, + + EventName.lowSpeedLockout: { + ET.PERMANENT: NormalPermanentAlert("Cruise Fault: Restart the car to engage"), + ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"), + }, + +} diff --git a/selfdrive/controls/lib/fcw.py b/selfdrive/controls/lib/fcw.py deleted file mode 100644 index f93a72cfcce321..00000000000000 --- a/selfdrive/controls/lib/fcw.py +++ /dev/null @@ -1,71 +0,0 @@ -import numpy as np -from collections import defaultdict - -from common.numpy_fast import interp - -_FCW_A_ACT_V = [-3., -2.] -_FCW_A_ACT_BP = [0., 30.] - - -class FCWChecker(object): - def __init__(self): - self.reset_lead(0.0) - - def reset_lead(self, cur_time): - self.last_fcw_a = 0.0 - self.v_lead_max = 0.0 - self.lead_seen_t = cur_time - self.last_fcw_time = 0.0 - self.last_min_a = 0.0 - - self.counters = defaultdict(lambda: 0) - - @staticmethod - def calc_ttc(v_ego, a_ego, x_lead, v_lead, a_lead): - max_ttc = 5.0 - - v_rel = v_ego - v_lead - a_rel = a_ego - a_lead - - # assuming that closing gap ARel comes from lead vehicle decel, - # 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) - - # 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): - ttc = max_ttc - else: - ttc = np.minimum(2 * x_lead / (np.sqrt(delta) + v_rel), max_ttc) - return ttc - - def update(self, mpc_solution, cur_time, 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) - self.last_min_a = min(mpc_solution_a) - self.v_lead_max = max(self.v_lead_max, v_lead) - - 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) - - fcw_allowed = all(c >= 10 for c in self.counters.values()) - if (self.last_min_a < -3.0 or a_delta < a_thr) and fcw_allowed 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 - - return False diff --git a/selfdrive/controls/lib/lane_planner.py b/selfdrive/controls/lib/lane_planner.py new file mode 100644 index 00000000000000..88a1f6a672960b --- /dev/null +++ b/selfdrive/controls/lib/lane_planner.py @@ -0,0 +1,103 @@ +import numpy as np +from cereal import log +from common.filter_simple import FirstOrderFilter +from common.numpy_fast import interp +from common.realtime import DT_MDL +from selfdrive.hardware import EON, TICI +from selfdrive.swaglog import cloudlog + + +TRAJECTORY_SIZE = 33 +# camera offset is meters from center car to camera +if EON: + CAMERA_OFFSET = 0.06 + PATH_OFFSET = 0.0 +elif TICI: + CAMERA_OFFSET = -0.04 + PATH_OFFSET = -0.04 +else: + CAMERA_OFFSET = 0.0 + PATH_OFFSET = 0.0 + + +class LanePlanner: + def __init__(self, wide_camera=False): + self.ll_t = np.zeros((TRAJECTORY_SIZE,)) + self.ll_x = np.zeros((TRAJECTORY_SIZE,)) + self.lll_y = np.zeros((TRAJECTORY_SIZE,)) + self.rll_y = np.zeros((TRAJECTORY_SIZE,)) + self.lane_width_estimate = FirstOrderFilter(3.7, 9.95, DT_MDL) + self.lane_width_certainty = FirstOrderFilter(1.0, 0.95, DT_MDL) + self.lane_width = 3.7 + + self.lll_prob = 0. + self.rll_prob = 0. + self.d_prob = 0. + + self.lll_std = 0. + self.rll_std = 0. + + self.l_lane_change_prob = 0. + self.r_lane_change_prob = 0. + + self.camera_offset = -CAMERA_OFFSET if wide_camera else CAMERA_OFFSET + self.path_offset = -PATH_OFFSET if wide_camera else PATH_OFFSET + + def parse_model(self, md): + if len(md.laneLines) == 4 and len(md.laneLines[0].t) == TRAJECTORY_SIZE: + self.ll_t = (np.array(md.laneLines[1].t) + np.array(md.laneLines[2].t))/2 + # left and right ll x is the same + self.ll_x = md.laneLines[1].x + # only offset left and right lane lines; offsetting path does not make sense + self.lll_y = np.array(md.laneLines[1].y) - self.camera_offset + self.rll_y = np.array(md.laneLines[2].y) - self.camera_offset + self.lll_prob = md.laneLineProbs[1] + self.rll_prob = md.laneLineProbs[2] + self.lll_std = md.laneLineStds[1] + self.rll_std = md.laneLineStds[2] + + if len(md.meta.desireState): + self.l_lane_change_prob = md.meta.desireState[log.LateralPlan.Desire.laneChangeLeft] + self.r_lane_change_prob = md.meta.desireState[log.LateralPlan.Desire.laneChangeRight] + + def get_d_path(self, v_ego, path_t, path_xyz): + # Reduce reliance on lanelines that are too far apart or + # will be in a few seconds + path_xyz[:, 1] -= self.path_offset + l_prob, r_prob = self.lll_prob, self.rll_prob + width_pts = self.rll_y - self.lll_y + prob_mods = [] + for t_check in [0.0, 1.5, 3.0]: + width_at_t = interp(t_check * (v_ego + 7), self.ll_x, width_pts) + 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.lll_std, [.15, .3], [1.0, 0.0]) + r_std_mod = interp(self.rll_std, [.15, .3], [1.0, 0.0]) + l_prob *= l_std_mod + r_prob *= r_std_mod + + # Find current lanewidth + self.lane_width_certainty.update(l_prob * r_prob) + current_lane_width = abs(self.rll_y[0] - self.lll_y[0]) + self.lane_width_estimate.update(current_lane_width) + speed_lane_width = interp(v_ego, [0., 31.], [2.8, 3.5]) + self.lane_width = self.lane_width_certainty.x * self.lane_width_estimate.x + \ + (1 - self.lane_width_certainty.x) * speed_lane_width + + clipped_lane_width = min(4.0, self.lane_width) + path_from_left_lane = self.lll_y + clipped_lane_width / 2.0 + path_from_right_lane = self.rll_y - clipped_lane_width / 2.0 + + self.d_prob = l_prob + r_prob - l_prob * r_prob + lane_path_y = (l_prob * path_from_left_lane + r_prob * path_from_right_lane) / (l_prob + r_prob + 0.0001) + safe_idxs = np.isfinite(self.ll_t) + if safe_idxs[0]: + lane_path_y_interp = np.interp(path_t, self.ll_t[safe_idxs], lane_path_y[safe_idxs]) + path_xyz[:,1] = self.d_prob * lane_path_y_interp + (1.0 - self.d_prob) * path_xyz[:,1] + else: + cloudlog.warning("Lateral mpc - NaNs in laneline times, ignoring") + return path_xyz diff --git a/selfdrive/controls/lib/latcontrol_angle.py b/selfdrive/controls/lib/latcontrol_angle.py new file mode 100644 index 00000000000000..8fcb9ae7bfd066 --- /dev/null +++ b/selfdrive/controls/lib/latcontrol_angle.py @@ -0,0 +1,28 @@ +import math + +from cereal import log + + +class LatControlAngle(): + def __init__(self, CP): + pass + + def reset(self): + pass + + def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvature_rate): + angle_log = log.ControlsState.LateralAngleState.new_message() + + if CS.vEgo < 0.3 or not active: + angle_log.active = False + angle_steers_des = float(CS.steeringAngleDeg) + else: + angle_log.active = True + angle_steers_des = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo)) + angle_steers_des += params.angleOffsetDeg + + angle_log.saturated = False + angle_log.steeringAngleDeg = float(CS.steeringAngleDeg) + angle_log.steeringAngleDesiredDeg = angle_steers_des + + return 0, float(angle_steers_des), angle_log diff --git a/selfdrive/controls/lib/latcontrol_helpers.py b/selfdrive/controls/lib/latcontrol_helpers.py deleted file mode 100644 index c04d820bbee5e6..00000000000000 --- a/selfdrive/controls/lib/latcontrol_helpers.py +++ /dev/null @@ -1,89 +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]) - - -def calc_desired_path(l_poly, - r_poly, - p_poly, - l_prob, - r_prob, - p_prob, - speed, - lane_width=None): - # this function computes the poly for the center of the lane, averaging left and right polys - if lane_width is None: - lane_width = interp(speed, _LANE_WIDTH_BP, _LANE_WIDTH_V) - - # lanes in US are ~3.6m wide - half_lane_poly = np.array([0., 0., 0., lane_width / 2.]) - if l_prob + r_prob > 0.01: - c_poly = ((l_poly - half_lane_poly) * l_prob + - (r_poly + half_lane_poly) * r_prob) / (l_prob + r_prob) - c_prob = l_prob + r_prob - l_prob * r_prob - else: - c_poly = np.zeros(4) - c_prob = 0. - - p_weight = 1. # predicted path weight relatively to the center of the lane - d_poly = list((c_poly * c_prob + p_poly * p_prob * p_weight) / (c_prob + p_prob * p_weight)) - return d_poly, c_poly, c_prob diff --git a/selfdrive/controls/lib/latcontrol_indi.py b/selfdrive/controls/lib/latcontrol_indi.py index 31ff6dd3dcbe8a..50a8e22b3cfa02 100644 --- a/selfdrive/controls/lib/latcontrol_indi.py +++ b/selfdrive/controls/lib/latcontrol_indi.py @@ -2,74 +2,112 @@ import numpy as np from cereal import log +from common.filter_simple import FirstOrderFilter +from common.numpy_fast import clip, interp from common.realtime import DT_CTRL -from common.numpy_fast import clip -from selfdrive.car.toyota.carcontroller import SteerLimitParams from selfdrive.car import apply_toyota_steer_torque_limits +from selfdrive.car.toyota.values import CarControllerParams 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.speed = 0. 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.enforce_rate_limit = CP.carName == "toyota" - self.enfore_rate_limit = CP.carName == "toyota" + self._RC = (CP.lateralTuning.indi.timeConstantBP, CP.lateralTuning.indi.timeConstantV) + self._G = (CP.lateralTuning.indi.actuatorEffectivenessBP, CP.lateralTuning.indi.actuatorEffectivenessV) + self._outer_loop_gain = (CP.lateralTuning.indi.outerLoopGainBP, CP.lateralTuning.indi.outerLoopGainV) + self._inner_loop_gain = (CP.lateralTuning.indi.innerLoopGainBP, CP.lateralTuning.indi.innerLoopGainV) - self.RC = CP.lateralTuning.indi.timeConstant - self.G = CP.lateralTuning.indi.actuatorEffectiveness - self.outer_loop_gain = CP.lateralTuning.indi.outerLoopGain - 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.steer_filter = FirstOrderFilter(0., self.RC, DT_CTRL) self.reset() + @property + def RC(self): + return interp(self.speed, self._RC[0], self._RC[1]) + + @property + def G(self): + return interp(self.speed, self._G[0], self._G[1]) + + @property + def outer_loop_gain(self): + return interp(self.speed, self._outer_loop_gain[0], self._outer_loop_gain[1]) + + @property + def inner_loop_gain(self): + return interp(self.speed, self._inner_loop_gain[0], self._inner_loop_gain[1]) + def reset(self): - self.delayed_output = 0. + self.steer_filter.x = 0. self.output_steer = 0. - self.counter = 0 + self.sat_count = 0. + self.speed = 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, 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, VM, params, curvature, curvature_rate): + self.speed = CS.vEgo # Update Kalman filter - y = np.matrix([[math.radians(angle_steers)], [math.radians(angle_steers_rate)]]) + y = np.array([[math.radians(CS.steeringAngleDeg)], [math.radians(CS.steeringRateDeg)]]) self.x = np.dot(self.A_K, self.x) + np.dot(self.K, y) indi_log = log.ControlsState.LateralINDIState.new_message() - indi_log.steerAngle = math.degrees(self.x[0]) - indi_log.steerRate = math.degrees(self.x[1]) - indi_log.steerAccel = math.degrees(self.x[2]) + indi_log.steeringAngleDeg = math.degrees(self.x[0]) + indi_log.steeringRateDeg = math.degrees(self.x[1]) + indi_log.steeringAccelDeg = math.degrees(self.x[2]) + + steers_des = VM.get_steer_from_curvature(-curvature, CS.vEgo) + steers_des += math.radians(params.angleOffsetDeg) + indi_log.steeringAngleDesiredDeg = math.degrees(steers_des) + + rate_des = VM.get_steer_from_curvature(-curvature_rate, CS.vEgo) + indi_log.steeringRateDesiredDeg = math.degrees(rate_des) - 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 + self.steer_filter.x = 0.0 else: - self.angle_steers_des = path_plan.angleSteers - self.rate_steers_des = path_plan.rateSteers - - steers_des = math.radians(self.angle_steers_des) - rate_des = math.radians(self.rate_steers_des) - # Expected actuator value - self.delayed_output = self.delayed_output * self.alpha + self.output_steer * (1. - self.alpha) + self.steer_filter.update_alpha(self.RC) + self.steer_filter.update(self.output_steer) # Compute acceleration error rate_sp = self.outer_loop_gain * (steers_des - self.x[0]) + rate_des @@ -80,26 +118,32 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, steer_override, g_inv = 1. / self.G delta_u = g_inv * accel_error + # If steering pressed, only allow wind down + if CS.steeringPressed and (delta_u * self.output_steer > 0): + delta_u = 0 + # Enforce rate limit - if self.enfore_rate_limit: - steer_max = float(SteerLimitParams.STEER_MAX) - new_output_steer_cmd = steer_max * (self.delayed_output + delta_u) + if self.enforce_rate_limit: + steer_max = float(CarControllerParams.STEER_MAX) + new_output_steer_cmd = steer_max * (self.steer_filter.x + delta_u) prev_output_steer_cmd = steer_max * self.output_steer - new_output_steer_cmd = apply_toyota_steer_torque_limits(new_output_steer_cmd, prev_output_steer_cmd, prev_output_steer_cmd, SteerLimitParams) + new_output_steer_cmd = apply_toyota_steer_torque_limits(new_output_steer_cmd, prev_output_steer_cmd, prev_output_steer_cmd, CarControllerParams) self.output_steer = new_output_steer_cmd / steer_max else: - self.output_steer = self.delayed_output + delta_u + self.output_steer = self.steer_filter.x + 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 indi_log.rateSetPoint = float(rate_sp) indi_log.accelSetPoint = float(accel_sp) indi_log.accelError = float(accel_error) - indi_log.delayedOutput = float(self.delayed_output) + indi_log.delayedOutput = float(self.steer_filter.x) indi_log.delta = float(delta_u) indi_log.output = float(self.output_steer) - self.sat_flag = False - return float(self.output_steer), float(self.angle_steers_des), indi_log + 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(steers_des), indi_log diff --git a/selfdrive/controls/lib/latcontrol_lqr.py b/selfdrive/controls/lib/latcontrol_lqr.py new file mode 100644 index 00000000000000..16fffac2791b1c --- /dev/null +++ b/selfdrive/controls/lib/latcontrol_lqr.py @@ -0,0 +1,102 @@ +import math +import numpy as np + +from common.numpy_fast import clip +from common.realtime import DT_CTRL +from cereal import log +from selfdrive.controls.lib.drive_helpers import get_steer_max + + +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.dc_gain = CP.lateralTuning.lqr.dcGain + + self.x_hat = np.array([[0], [0]]) + 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.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) + + return self.sat_count > self.sat_limit + + def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvature_rate): + lqr_log = log.ControlsState.LateralLQRState.new_message() + + steers_max = get_steer_max(CP, CS.vEgo) + torque_scale = (0.45 + CS.vEgo / 60.0)**2 # Scale actuator model with speed + + # Subtract offset. Zero angle should correspond to zero torque + steering_angle_no_offset = CS.steeringAngleDeg - params.angleOffsetAverageDeg + + desired_angle = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo)) + + instant_offset = params.angleOffsetDeg - params.angleOffsetAverageDeg + desired_angle += instant_offset # Only add offset that originates from vehicle model errors + lqr_log.steeringAngleDesiredDeg = desired_angle + + # Update Kalman filter + angle_steers_k = float(self.C.dot(self.x_hat)) + e = steering_angle_no_offset - angle_steers_k + self.x_hat = self.A.dot(self.x_hat) + self.B.dot(CS.steeringTorqueEps / torque_scale) + self.L.dot(e) + + if CS.vEgo < 0.3 or not active: + lqr_log.active = False + lqr_output = 0. + output_steer = 0. + self.reset() + else: + lqr_log.active = True + + # LQR + u_lqr = float(desired_angle / self.dc_gain - self.K.dot(self.x_hat)) + lqr_output = torque_scale * u_lqr / self.scale + + # Integrator + if CS.steeringPressed: + self.i_lqr -= self.i_unwind_rate * float(np.sign(self.i_lqr)) + else: + error = desired_angle - angle_steers_k + i = self.i_lqr + self.ki * self.i_rate * error + control = lqr_output + i + + 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 + + output_steer = lqr_output + self.i_lqr + output_steer = clip(output_steer, -steers_max, steers_max) + + check_saturation = (CS.vEgo > 10) and not CS.steeringRateLimited and not CS.steeringPressed + saturated = self._check_saturation(output_steer, check_saturation, steers_max) + + lqr_log.steeringAngleDeg = angle_steers_k + lqr_log.i = self.i_lqr + lqr_log.output = output_steer + lqr_log.lqrOutput = lqr_output + lqr_log.saturated = saturated + return output_steer, desired_angle, lqr_log diff --git a/selfdrive/controls/lib/latcontrol_pid.py b/selfdrive/controls/lib/latcontrol_pid.py index 65a5a8b6d9daa9..c7730d011cea79 100644 --- a/selfdrive/controls/lib/latcontrol_pid.py +++ b/selfdrive/controls/lib/latcontrol_pid.py @@ -1,42 +1,48 @@ +import math + from selfdrive.controls.lib.pid import PIController from selfdrive.controls.lib.drive_helpers import get_steer_max -from cereal import car from cereal import log -class LatControlPID(object): - def __init__(self, CP): +class LatControlPID(): + def __init__(self, CP, CI): 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) - self.angle_steers_des = 0. + k_f=CP.lateralTuning.pid.kf, pos_limit=1.0, neg_limit=-1.0, + sat_limit=CP.steerLimitTimer) + self.get_steer_feedforward = CI.get_steer_feedforward_function() def reset(self): self.pid.reset() - def update(self, active, v_ego, angle_steers, angle_steers_rate, steer_override, CP, VM, path_plan): + def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvature_rate): pid_log = log.ControlsState.LateralPIDState.new_message() - pid_log.steerAngle = float(angle_steers) - pid_log.steerRate = float(angle_steers_rate) + pid_log.steeringAngleDeg = float(CS.steeringAngleDeg) + pid_log.steeringRateDeg = float(CS.steeringRateDeg) + + angle_steers_des_no_offset = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo)) + angle_steers_des = angle_steers_des_no_offset + params.angleOffsetDeg - if v_ego < 0.3 or not active: + pid_log.steeringAngleDesiredDeg = angle_steers_des + pid_log.angleError = angle_steers_des - CS.steeringAngleDeg + 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 - - 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) + + # offset does not contribute to resistive torque + steer_feedforward = self.get_steer_feedforward(angle_steers_des_no_offset, CS.vEgo) + 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(angle_steers_des, CS.steeringAngleDeg, 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,5 +50,4 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, steer_override, pid_log.output = output_steer pid_log.saturated = bool(self.pid.saturated) - self.sat_flag = self.pid.saturated - return output_steer, float(self.angle_steers_des), pid_log + return output_steer, angle_steers_des, pid_log 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/generator.cpp b/selfdrive/controls/lib/lateral_mpc/generator.cpp deleted file mode 100644 index 523ed8ac8452ea..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/generator.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include - -#define PI 3.1415926536 -#define deg2rad(d) (d/180.0*PI) - -const int controlHorizon = 50; - -using namespace std; - -int main( ) -{ - USING_NAMESPACE_ACADO - - - DifferentialEquation f; - - DifferentialState xx; // x position - DifferentialState yy; // y position - DifferentialState psi; // vehicle heading - DifferentialState delta; - - OnlineData curvature_factor; - OnlineData v_ref; // m/s - OnlineData l_poly_r0, l_poly_r1, l_poly_r2, l_poly_r3; - OnlineData r_poly_r0, r_poly_r1, r_poly_r2, r_poly_r3; - OnlineData p_poly_r0, p_poly_r1, p_poly_r2, p_poly_r3; - OnlineData l_prob, r_prob, p_prob; - OnlineData lane_width; - - Control t; - - // Equations of motion - f << dot(xx) == v_ref * cos(psi); - f << dot(yy) == v_ref * sin(psi); - f << dot(psi) == v_ref * delta * curvature_factor; - f << dot(delta) == t; - - auto lr_prob = l_prob + r_prob - l_prob * r_prob; - - auto poly_l = l_poly_r0*(xx*xx*xx) + l_poly_r1*(xx*xx) + l_poly_r2*xx + l_poly_r3; - auto poly_r = r_poly_r0*(xx*xx*xx) + r_poly_r1*(xx*xx) + r_poly_r2*xx + r_poly_r3; - auto poly_p = p_poly_r0*(xx*xx*xx) + p_poly_r1*(xx*xx) + p_poly_r2*xx + p_poly_r3; - - auto angle_l = atan(3*l_poly_r0*xx*xx + 2*l_poly_r1*xx + l_poly_r2); - auto angle_r = atan(3*r_poly_r0*xx*xx + 2*r_poly_r1*xx + r_poly_r2); - auto angle_p = atan(3*p_poly_r0*xx*xx + 2*p_poly_r1*xx + p_poly_r2); - - // given the lane width estimate, this is where we estimate the path given lane lines - auto path_from_left_lane = poly_l - lane_width/2.0; - auto path_from_right_lane = poly_r + lane_width/2.0; - - // if the lanes are visible, drive in the center, otherwise follow the path - auto path = lr_prob * (l_prob * path_from_left_lane + r_prob * path_from_right_lane) / (l_prob + r_prob + 0.0001) - + (1-lr_prob) * poly_p; - - auto angle = lr_prob * (l_prob * angle_l + r_prob * angle_r) / (l_prob + r_prob + 0.0001) - + (1-lr_prob) * angle_p; - - // When the lane is not visible, use an estimate of its position - auto weighted_left_lane = l_prob * poly_l + (1 - l_prob) * (path + lane_width/2.0); - auto weighted_right_lane = r_prob * poly_r + (1 - r_prob) * (path - lane_width/2.0); - - auto c_left_lane = exp(-(weighted_left_lane - yy)); - auto c_right_lane = exp(weighted_right_lane - yy); - - // Running cost - Function h; - - // Distance errors - h << path - yy; - h << lr_prob * c_left_lane; - h << lr_prob * c_right_lane; - - // Heading error - h << (v_ref + 1.0 ) * (angle - psi); - - // Angular rate error - h << (v_ref + 1.0 ) * t; - - BMatrix Q(5,5); Q.setAll(true); - // Q(0,0) = 1.0; - // Q(1,1) = 1.0; - // Q(2,2) = 1.0; - // Q(3,3) = 1.0; - // Q(4,4) = 2.0; - - // Terminal cost - Function hN; - - // Distance errors - hN << path - yy; - hN << l_prob * c_left_lane; - hN << r_prob * c_right_lane; - - // Heading errors - hN << (2.0 * v_ref + 1.0 ) * (angle - psi); - - BMatrix QN(4,4); QN.setAll(true); - // QN(0,0) = 1.0; - // QN(1,1) = 1.0; - // QN(2,2) = 1.0; - // QN(3,3) = 1.0; - - // Non uniform time grid - // First 5 timesteps are 0.05, after that it's 0.15 - 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 = 2.5; - - OCP ocp( tStart, tEnd, numSteps); - ocp.subjectTo(f); - - ocp.minimizeLSQ(Q, h); - ocp.minimizeLSQEndTerm(QN, hN); - - // car can't go backward to avoid "circles" - ocp.subjectTo( deg2rad(-90) <= psi <= deg2rad(90)); - // more than absolute max steer angle - ocp.subjectTo( deg2rad(-50) <= delta <= deg2rad(50)); - ocp.setNOD(18); - - 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, 1 * 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/lateral_mpc/lateral_mpc.c b/selfdrive/controls/lib/lateral_mpc/lateral_mpc.c deleted file mode 100644 index ea6f85b304e3e5..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lateral_mpc.c +++ /dev/null @@ -1,129 +0,0 @@ -#include "acado_common.h" -#include "acado_auxiliary_functions.h" - -#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, y, psi, delta, t; -} state_t; - - -typedef struct { - double x[N+1]; - double y[N+1]; - double psi[N+1]; - double delta[N+1]; - double rate[N]; - double cost; -} log_t; - -void init(double pathCost, double laneCost, double headingCost, double steerRateCost){ - 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.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){ - f = STEP_MULTIPLIER; - } - // Setup diagonal entries - acadoVariables.W[NY*NY*i + (NY+1)*0] = pathCost * f; - acadoVariables.W[NY*NY*i + (NY+1)*1] = laneCost * f; - acadoVariables.W[NY*NY*i + (NY+1)*2] = laneCost * f; - acadoVariables.W[NY*NY*i + (NY+1)*3] = headingCost * f; - acadoVariables.W[NY*NY*i + (NY+1)*4] = steerRateCost * f; - } - acadoVariables.WN[(NYN+1)*0] = pathCost * STEP_MULTIPLIER; - acadoVariables.WN[(NYN+1)*1] = laneCost * STEP_MULTIPLIER; - acadoVariables.WN[(NYN+1)*2] = laneCost * STEP_MULTIPLIER; - acadoVariables.WN[(NYN+1)*3] = headingCost * STEP_MULTIPLIER; -} - -int run_mpc(state_t * x0, log_t * solution, - double l_poly[4], double r_poly[4], double p_poly[4], - double l_prob, double r_prob, double p_prob, double curvature_factor, double v_ref, double lane_width){ - - int i; - - for (i = 0; i <= NOD * N; i+= NOD){ - acadoVariables.od[i] = curvature_factor; - acadoVariables.od[i+1] = v_ref; - - acadoVariables.od[i+2] = l_poly[0]; - acadoVariables.od[i+3] = l_poly[1]; - acadoVariables.od[i+4] = l_poly[2]; - acadoVariables.od[i+5] = l_poly[3]; - - acadoVariables.od[i+6] = r_poly[0]; - acadoVariables.od[i+7] = r_poly[1]; - acadoVariables.od[i+8] = r_poly[2]; - acadoVariables.od[i+9] = r_poly[3]; - - acadoVariables.od[i+10] = p_poly[0]; - acadoVariables.od[i+11] = p_poly[1]; - acadoVariables.od[i+12] = p_poly[2]; - acadoVariables.od[i+13] = p_poly[3]; - - - acadoVariables.od[i+14] = l_prob; - acadoVariables.od[i+15] = r_prob; - acadoVariables.od[i+16] = p_prob; - acadoVariables.od[i+17] = lane_width; - - } - - acadoVariables.x0[0] = x0->x; - acadoVariables.x0[1] = x0->y; - acadoVariables.x0[2] = x0->psi; - acadoVariables.x0[3] = x0->delta; - - - acado_preparationStep(); - acado_feedbackStep(); - - /* printf("lat its: %d\n", acado_getNWSR()); // n iterations - printf("Objective: %.6f\n", acado_getObjective()); // solution cost */ - - for (i = 0; i <= N; i++){ - solution->x[i] = acadoVariables.x[i*NX]; - solution->y[i] = acadoVariables.x[i*NX+1]; - solution->psi[i] = acadoVariables.x[i*NX+2]; - solution->delta[i] = acadoVariables.x[i*NX+3]; - if (i < N){ - solution->rate[i] = acadoVariables.u[i]; - } - } - solution->cost = acado_getObjective(); - - // Dont shift states here. Current solution is closer to next timestep than if - // we use the old solution as a starting point - //acado_shiftStates(2, 0, 0); - //acado_shiftControls( 0 ); - - return acado_getNWSR(); -} diff --git a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.c b/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.c deleted file mode 100644 index 6f0bb705c8a897..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * 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/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.h b/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.h deleted file mode 100644 index b1be0a661c0125..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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/lateral_mpc/lib_mpc_export/acado_common.h b/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_common.h deleted file mode 100644 index d5b56727707ff0..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_common.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - * 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 18 -/** 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 18 (row major format) - * - * Matrix containing 21 online data vectors. - */ -real_t od[ 378 ]; - -/** 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_ -{ -/** Column vector of size: 14 */ -real_t rhs_aux[ 14 ]; - -real_t rk_ttt; - -/** Row vector of size: 43 */ -real_t rk_xxx[ 43 ]; - -/** Matrix of size: 4 x 24 (row major format) */ -real_t rk_kkk[ 96 ]; - -/** Row vector of size: 43 */ -real_t state[ 43 ]; - -/** 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 ]; - -/** Column vector of size: 21 */ -real_t objAuxVar[ 21 ]; - -/** Row vector of size: 23 */ -real_t objValueIn[ 23 ]; - -/** 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 ]; - -/** Matrix of size: 40 x 24 (row major format) */ -real_t A[ 960 ]; - -/** 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: 40 */ -real_t lbA[ 40 ]; - -/** Column vector of size: 40 */ -real_t ubA[ 40 ]; - -/** Column vector of size: 24 */ -real_t x[ 24 ]; - -/** Column vector of size: 64 */ -real_t y[ 64 ]; - - -} 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/lateral_mpc/lib_mpc_export/acado_integrator.c b/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_integrator.c deleted file mode 100644 index b931088991a33d..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_integrator.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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; -const real_t* od = in + 25; -/* Vector of auxiliary variables; number of elements: 14. */ -real_t* a = acadoWorkspace.rhs_aux; - -/* Compute intermediate quantities: */ -a[0] = (cos(xd[2])); -a[1] = (sin(xd[2])); -a[2] = ((real_t)(-1.0000000000000000e+00)*(sin(xd[2]))); -a[3] = (xd[12]*a[2]); -a[4] = (xd[13]*a[2]); -a[5] = (xd[14]*a[2]); -a[6] = (xd[15]*a[2]); -a[7] = (cos(xd[2])); -a[8] = (xd[12]*a[7]); -a[9] = (xd[13]*a[7]); -a[10] = (xd[14]*a[7]); -a[11] = (xd[15]*a[7]); -a[12] = (xd[22]*a[2]); -a[13] = (xd[22]*a[7]); - -/* Compute outputs: */ -out[0] = (od[1]*a[0]); -out[1] = (od[1]*a[1]); -out[2] = ((od[1]*xd[3])*od[0]); -out[3] = u[0]; -out[4] = (od[1]*a[3]); -out[5] = (od[1]*a[4]); -out[6] = (od[1]*a[5]); -out[7] = (od[1]*a[6]); -out[8] = (od[1]*a[8]); -out[9] = (od[1]*a[9]); -out[10] = (od[1]*a[10]); -out[11] = (od[1]*a[11]); -out[12] = ((od[1]*xd[16])*od[0]); -out[13] = ((od[1]*xd[17])*od[0]); -out[14] = ((od[1]*xd[18])*od[0]); -out[15] = ((od[1]*xd[19])*od[0]); -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] = (od[1]*a[12]); -out[21] = (od[1]*a[13]); -out[22] = ((od[1]*xd[23])*od[0]); -out[23] = (real_t)(1.0000000000000000e+00); -} - -/* Fixed step size:0.05 */ -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]; -acadoWorkspace.rk_xxx[37] = rk_eta[37]; -acadoWorkspace.rk_xxx[38] = rk_eta[38]; -acadoWorkspace.rk_xxx[39] = rk_eta[39]; -acadoWorkspace.rk_xxx[40] = rk_eta[40]; -acadoWorkspace.rk_xxx[41] = rk_eta[41]; -acadoWorkspace.rk_xxx[42] = rk_eta[42]; - -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)2.4999999999999991e-02*acadoWorkspace.rk_kkk[0] + rk_eta[0]; -acadoWorkspace.rk_xxx[1] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[1] + rk_eta[1]; -acadoWorkspace.rk_xxx[2] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[2] + rk_eta[2]; -acadoWorkspace.rk_xxx[3] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[3] + rk_eta[3]; -acadoWorkspace.rk_xxx[4] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[4] + rk_eta[4]; -acadoWorkspace.rk_xxx[5] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[5] + rk_eta[5]; -acadoWorkspace.rk_xxx[6] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[6] + rk_eta[6]; -acadoWorkspace.rk_xxx[7] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[7] + rk_eta[7]; -acadoWorkspace.rk_xxx[8] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[8] + rk_eta[8]; -acadoWorkspace.rk_xxx[9] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[9] + rk_eta[9]; -acadoWorkspace.rk_xxx[10] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[10] + rk_eta[10]; -acadoWorkspace.rk_xxx[11] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[11] + rk_eta[11]; -acadoWorkspace.rk_xxx[12] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[12] + rk_eta[12]; -acadoWorkspace.rk_xxx[13] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[13] + rk_eta[13]; -acadoWorkspace.rk_xxx[14] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[14] + rk_eta[14]; -acadoWorkspace.rk_xxx[15] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[15] + rk_eta[15]; -acadoWorkspace.rk_xxx[16] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[16] + rk_eta[16]; -acadoWorkspace.rk_xxx[17] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[17] + rk_eta[17]; -acadoWorkspace.rk_xxx[18] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[18] + rk_eta[18]; -acadoWorkspace.rk_xxx[19] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[19] + rk_eta[19]; -acadoWorkspace.rk_xxx[20] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[20] + rk_eta[20]; -acadoWorkspace.rk_xxx[21] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[21] + rk_eta[21]; -acadoWorkspace.rk_xxx[22] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[22] + rk_eta[22]; -acadoWorkspace.rk_xxx[23] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[23] + rk_eta[23]; -acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 24 ]) ); -acadoWorkspace.rk_xxx[0] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[24] + rk_eta[0]; -acadoWorkspace.rk_xxx[1] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[25] + rk_eta[1]; -acadoWorkspace.rk_xxx[2] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[26] + rk_eta[2]; -acadoWorkspace.rk_xxx[3] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[27] + rk_eta[3]; -acadoWorkspace.rk_xxx[4] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[28] + rk_eta[4]; -acadoWorkspace.rk_xxx[5] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[29] + rk_eta[5]; -acadoWorkspace.rk_xxx[6] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[30] + rk_eta[6]; -acadoWorkspace.rk_xxx[7] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[31] + rk_eta[7]; -acadoWorkspace.rk_xxx[8] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[32] + rk_eta[8]; -acadoWorkspace.rk_xxx[9] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[33] + rk_eta[9]; -acadoWorkspace.rk_xxx[10] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[34] + rk_eta[10]; -acadoWorkspace.rk_xxx[11] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[35] + rk_eta[11]; -acadoWorkspace.rk_xxx[12] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[36] + rk_eta[12]; -acadoWorkspace.rk_xxx[13] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[37] + rk_eta[13]; -acadoWorkspace.rk_xxx[14] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[38] + rk_eta[14]; -acadoWorkspace.rk_xxx[15] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[39] + rk_eta[15]; -acadoWorkspace.rk_xxx[16] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[40] + rk_eta[16]; -acadoWorkspace.rk_xxx[17] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[41] + rk_eta[17]; -acadoWorkspace.rk_xxx[18] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[42] + rk_eta[18]; -acadoWorkspace.rk_xxx[19] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[43] + rk_eta[19]; -acadoWorkspace.rk_xxx[20] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[44] + rk_eta[20]; -acadoWorkspace.rk_xxx[21] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[45] + rk_eta[21]; -acadoWorkspace.rk_xxx[22] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[46] + rk_eta[22]; -acadoWorkspace.rk_xxx[23] = + (real_t)2.4999999999999991e-02*acadoWorkspace.rk_kkk[47] + rk_eta[23]; -acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 48 ]) ); -acadoWorkspace.rk_xxx[0] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[48] + rk_eta[0]; -acadoWorkspace.rk_xxx[1] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[49] + rk_eta[1]; -acadoWorkspace.rk_xxx[2] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[50] + rk_eta[2]; -acadoWorkspace.rk_xxx[3] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[51] + rk_eta[3]; -acadoWorkspace.rk_xxx[4] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[52] + rk_eta[4]; -acadoWorkspace.rk_xxx[5] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[53] + rk_eta[5]; -acadoWorkspace.rk_xxx[6] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[54] + rk_eta[6]; -acadoWorkspace.rk_xxx[7] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[55] + rk_eta[7]; -acadoWorkspace.rk_xxx[8] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[56] + rk_eta[8]; -acadoWorkspace.rk_xxx[9] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[57] + rk_eta[9]; -acadoWorkspace.rk_xxx[10] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[58] + rk_eta[10]; -acadoWorkspace.rk_xxx[11] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[59] + rk_eta[11]; -acadoWorkspace.rk_xxx[12] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[60] + rk_eta[12]; -acadoWorkspace.rk_xxx[13] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[61] + rk_eta[13]; -acadoWorkspace.rk_xxx[14] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[62] + rk_eta[14]; -acadoWorkspace.rk_xxx[15] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[63] + rk_eta[15]; -acadoWorkspace.rk_xxx[16] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[64] + rk_eta[16]; -acadoWorkspace.rk_xxx[17] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[65] + rk_eta[17]; -acadoWorkspace.rk_xxx[18] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[66] + rk_eta[18]; -acadoWorkspace.rk_xxx[19] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[67] + rk_eta[19]; -acadoWorkspace.rk_xxx[20] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[68] + rk_eta[20]; -acadoWorkspace.rk_xxx[21] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[69] + rk_eta[21]; -acadoWorkspace.rk_xxx[22] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[70] + rk_eta[22]; -acadoWorkspace.rk_xxx[23] = + (real_t)4.9999999999999982e-02*acadoWorkspace.rk_kkk[71] + rk_eta[23]; -acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 72 ]) ); -rk_eta[0] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[0] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[24] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[48] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[72]; -rk_eta[1] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[1] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[25] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[49] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[73]; -rk_eta[2] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[2] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[26] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[50] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[74]; -rk_eta[3] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[3] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[27] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[51] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[75]; -rk_eta[4] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[4] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[28] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[52] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[76]; -rk_eta[5] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[5] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[29] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[53] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[77]; -rk_eta[6] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[6] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[30] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[54] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[78]; -rk_eta[7] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[7] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[31] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[55] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[79]; -rk_eta[8] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[8] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[32] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[56] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[80]; -rk_eta[9] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[9] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[33] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[57] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[81]; -rk_eta[10] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[10] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[34] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[58] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[82]; -rk_eta[11] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[11] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[35] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[59] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[83]; -rk_eta[12] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[12] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[36] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[60] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[84]; -rk_eta[13] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[13] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[37] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[61] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[85]; -rk_eta[14] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[14] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[38] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[62] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[86]; -rk_eta[15] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[15] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[39] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[63] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[87]; -rk_eta[16] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[16] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[40] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[64] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[88]; -rk_eta[17] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[17] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[41] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[65] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[89]; -rk_eta[18] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[18] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[42] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[66] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[90]; -rk_eta[19] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[19] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[43] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[67] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[91]; -rk_eta[20] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[20] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[44] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[68] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[92]; -rk_eta[21] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[21] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[45] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[69] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[93]; -rk_eta[22] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[22] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[46] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[70] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[94]; -rk_eta[23] += + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[23] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[47] + (real_t)1.6666666666666659e-02*acadoWorkspace.rk_kkk[71] + (real_t)8.3333333333333297e-03*acadoWorkspace.rk_kkk[95]; -acadoWorkspace.rk_ttt += 1.0000000000000000e+00; -} -} -error = 0; -return error; -} - diff --git a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_qpoases_interface.cpp b/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_qpoases_interface.cpp deleted file mode 100644 index f2665a45c09b39..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_qpoases_interface.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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/QProblem.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; - - QProblem qp(24, 40); - - returnValue retVal = qp.init(acadoWorkspace.H, acadoWorkspace.g, acadoWorkspace.A, acadoWorkspace.lb, acadoWorkspace.ub, acadoWorkspace.lbA, acadoWorkspace.ubA, 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/lateral_mpc/lib_mpc_export/acado_qpoases_interface.hpp b/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_qpoases_interface.hpp deleted file mode 100644 index 47d41855e6fe89..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_qpoases_interface.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 40 -/** 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/lateral_mpc/lib_mpc_export/acado_solver.c b/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_solver.c deleted file mode 100644 index 014c19a01ab450..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_solver.c +++ /dev/null @@ -1,5190 +0,0 @@ -/* - * 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 * 18]; -acadoWorkspace.state[26] = acadoVariables.od[lRun1 * 18 + 1]; -acadoWorkspace.state[27] = acadoVariables.od[lRun1 * 18 + 2]; -acadoWorkspace.state[28] = acadoVariables.od[lRun1 * 18 + 3]; -acadoWorkspace.state[29] = acadoVariables.od[lRun1 * 18 + 4]; -acadoWorkspace.state[30] = acadoVariables.od[lRun1 * 18 + 5]; -acadoWorkspace.state[31] = acadoVariables.od[lRun1 * 18 + 6]; -acadoWorkspace.state[32] = acadoVariables.od[lRun1 * 18 + 7]; -acadoWorkspace.state[33] = acadoVariables.od[lRun1 * 18 + 8]; -acadoWorkspace.state[34] = acadoVariables.od[lRun1 * 18 + 9]; -acadoWorkspace.state[35] = acadoVariables.od[lRun1 * 18 + 10]; -acadoWorkspace.state[36] = acadoVariables.od[lRun1 * 18 + 11]; -acadoWorkspace.state[37] = acadoVariables.od[lRun1 * 18 + 12]; -acadoWorkspace.state[38] = acadoVariables.od[lRun1 * 18 + 13]; -acadoWorkspace.state[39] = acadoVariables.od[lRun1 * 18 + 14]; -acadoWorkspace.state[40] = acadoVariables.od[lRun1 * 18 + 15]; -acadoWorkspace.state[41] = acadoVariables.od[lRun1 * 18 + 16]; -acadoWorkspace.state[42] = acadoVariables.od[lRun1 * 18 + 17]; - -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; -/* Vector of auxiliary variables; number of elements: 21. */ -real_t* a = acadoWorkspace.objAuxVar; - -/* Compute intermediate quantities: */ -a[0] = (exp(((real_t)(0.0000000000000000e+00)-(((od[14]*((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5]))+(((real_t)(1.0000000000000000e+00)-od[14])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))+(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1])))); -a[1] = (exp((((od[15]*((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9]))+(((real_t)(1.0000000000000000e+00)-od[15])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))-(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1]))); -a[2] = (atan(((((((real_t)(3.0000000000000000e+00)*od[2])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[3])*xd[0]))+od[4]))); -a[3] = (atan(((((((real_t)(3.0000000000000000e+00)*od[6])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[7])*xd[0]))+od[8]))); -a[4] = (atan(((((((real_t)(3.0000000000000000e+00)*od[10])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[11])*xd[0]))+od[12]))); -a[5] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[6] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[7] = (exp(((real_t)(0.0000000000000000e+00)-(((od[14]*((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5]))+(((real_t)(1.0000000000000000e+00)-od[14])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))+(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1])))); -a[8] = (((real_t)(0.0000000000000000e+00)-((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(((real_t)(1.0000000000000000e+00)-od[14])*(((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))))*a[6])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*(((od[10]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[11]*(xd[0]+xd[0])))+od[12]))))))*a[7]); -a[9] = (((real_t)(0.0000000000000000e+00)-((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)))*a[7]); -a[10] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[11] = (exp((((od[15]*((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9]))+(((real_t)(1.0000000000000000e+00)-od[15])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))-(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1]))); -a[12] = (((od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))+(((real_t)(1.0000000000000000e+00)-od[15])*(((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))))*a[10])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*(((od[10]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[11]*(xd[0]+xd[0])))+od[12])))))*a[11]); -a[13] = (((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00))*a[11]); -a[14] = ((real_t)(1.0000000000000000e+00)/((real_t)(1.0000000000000000e+00)+(pow(((((((real_t)(3.0000000000000000e+00)*od[2])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[3])*xd[0]))+od[4]),2)))); -a[15] = ((((((real_t)(3.0000000000000000e+00)*od[2])*xd[0])+(((real_t)(3.0000000000000000e+00)*od[2])*xd[0]))+((real_t)(2.0000000000000000e+00)*od[3]))*a[14]); -a[16] = ((real_t)(1.0000000000000000e+00)/((real_t)(1.0000000000000000e+00)+(pow(((((((real_t)(3.0000000000000000e+00)*od[6])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[7])*xd[0]))+od[8]),2)))); -a[17] = ((((((real_t)(3.0000000000000000e+00)*od[6])*xd[0])+(((real_t)(3.0000000000000000e+00)*od[6])*xd[0]))+((real_t)(2.0000000000000000e+00)*od[7]))*a[16]); -a[18] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[19] = ((real_t)(1.0000000000000000e+00)/((real_t)(1.0000000000000000e+00)+(pow(((((((real_t)(3.0000000000000000e+00)*od[10])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[11])*xd[0]))+od[12]),2)))); -a[20] = ((((((real_t)(3.0000000000000000e+00)*od[10])*xd[0])+(((real_t)(3.0000000000000000e+00)*od[10])*xd[0]))+((real_t)(2.0000000000000000e+00)*od[11]))*a[19]); - -/* Compute outputs: */ -out[0] = ((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))-xd[1]); -out[1] = (((od[14]+od[15])-(od[14]*od[15]))*a[0]); -out[2] = (((od[14]+od[15])-(od[14]*od[15]))*a[1]); -out[3] = ((od[1]+(real_t)(1.0000000000000000e+00))*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*a[2])+(od[15]*a[3])))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*a[4]))-xd[2])); -out[4] = ((od[1]+(real_t)(1.0000000000000000e+00))*u[0]); -out[5] = (((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))))*a[5])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*(((od[10]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[11]*(xd[0]+xd[0])))+od[12]))); -out[6] = ((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)); -out[7] = (real_t)(0.0000000000000000e+00); -out[8] = (real_t)(0.0000000000000000e+00); -out[9] = (((od[14]+od[15])-(od[14]*od[15]))*a[8]); -out[10] = (((od[14]+od[15])-(od[14]*od[15]))*a[9]); -out[11] = (real_t)(0.0000000000000000e+00); -out[12] = (real_t)(0.0000000000000000e+00); -out[13] = (((od[14]+od[15])-(od[14]*od[15]))*a[12]); -out[14] = (((od[14]+od[15])-(od[14]*od[15]))*a[13]); -out[15] = (real_t)(0.0000000000000000e+00); -out[16] = (real_t)(0.0000000000000000e+00); -out[17] = ((od[1]+(real_t)(1.0000000000000000e+00))*(((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*a[15])+(od[15]*a[17])))*a[18])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*a[20]))); -out[18] = (real_t)(0.0000000000000000e+00); -out[19] = ((od[1]+(real_t)(1.0000000000000000e+00))*((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00))); -out[20] = (real_t)(0.0000000000000000e+00); -out[21] = (real_t)(0.0000000000000000e+00); -out[22] = (real_t)(0.0000000000000000e+00); -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] = (od[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; -/* Vector of auxiliary variables; number of elements: 21. */ -real_t* a = acadoWorkspace.objAuxVar; - -/* Compute intermediate quantities: */ -a[0] = (exp(((real_t)(0.0000000000000000e+00)-(((od[14]*((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5]))+(((real_t)(1.0000000000000000e+00)-od[14])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))+(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1])))); -a[1] = (exp((((od[15]*((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9]))+(((real_t)(1.0000000000000000e+00)-od[15])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))-(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1]))); -a[2] = (atan(((((((real_t)(3.0000000000000000e+00)*od[2])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[3])*xd[0]))+od[4]))); -a[3] = (atan(((((((real_t)(3.0000000000000000e+00)*od[6])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[7])*xd[0]))+od[8]))); -a[4] = (atan(((((((real_t)(3.0000000000000000e+00)*od[10])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[11])*xd[0]))+od[12]))); -a[5] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[6] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[7] = (exp(((real_t)(0.0000000000000000e+00)-(((od[14]*((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5]))+(((real_t)(1.0000000000000000e+00)-od[14])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))+(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1])))); -a[8] = (((real_t)(0.0000000000000000e+00)-((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(((real_t)(1.0000000000000000e+00)-od[14])*(((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))))*a[6])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*(((od[10]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[11]*(xd[0]+xd[0])))+od[12]))))))*a[7]); -a[9] = (((real_t)(0.0000000000000000e+00)-((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)))*a[7]); -a[10] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[11] = (exp((((od[15]*((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9]))+(((real_t)(1.0000000000000000e+00)-od[15])*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))-(od[17]/(real_t)(2.0000000000000000e+00)))))-xd[1]))); -a[12] = (((od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))+(((real_t)(1.0000000000000000e+00)-od[15])*(((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))))*a[10])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*(((od[10]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[11]*(xd[0]+xd[0])))+od[12])))))*a[11]); -a[13] = (((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00))*a[11]); -a[14] = ((real_t)(1.0000000000000000e+00)/((real_t)(1.0000000000000000e+00)+(pow(((((((real_t)(3.0000000000000000e+00)*od[2])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[3])*xd[0]))+od[4]),2)))); -a[15] = ((((((real_t)(3.0000000000000000e+00)*od[2])*xd[0])+(((real_t)(3.0000000000000000e+00)*od[2])*xd[0]))+((real_t)(2.0000000000000000e+00)*od[3]))*a[14]); -a[16] = ((real_t)(1.0000000000000000e+00)/((real_t)(1.0000000000000000e+00)+(pow(((((((real_t)(3.0000000000000000e+00)*od[6])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[7])*xd[0]))+od[8]),2)))); -a[17] = ((((((real_t)(3.0000000000000000e+00)*od[6])*xd[0])+(((real_t)(3.0000000000000000e+00)*od[6])*xd[0]))+((real_t)(2.0000000000000000e+00)*od[7]))*a[16]); -a[18] = ((real_t)(1.0000000000000000e+00)/((od[14]+od[15])+(real_t)(1.0000000000000000e-04))); -a[19] = ((real_t)(1.0000000000000000e+00)/((real_t)(1.0000000000000000e+00)+(pow(((((((real_t)(3.0000000000000000e+00)*od[10])*xd[0])*xd[0])+(((real_t)(2.0000000000000000e+00)*od[11])*xd[0]))+od[12]),2)))); -a[20] = ((((((real_t)(3.0000000000000000e+00)*od[10])*xd[0])+(((real_t)(3.0000000000000000e+00)*od[10])*xd[0]))+((real_t)(2.0000000000000000e+00)*od[11]))*a[19]); - -/* Compute outputs: */ -out[0] = ((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((((od[2]*((xd[0]*xd[0])*xd[0]))+(od[3]*(xd[0]*xd[0])))+(od[4]*xd[0]))+od[5])-(od[17]/(real_t)(2.0000000000000000e+00))))+(od[15]*(((((od[6]*((xd[0]*xd[0])*xd[0]))+(od[7]*(xd[0]*xd[0])))+(od[8]*xd[0]))+od[9])+(od[17]/(real_t)(2.0000000000000000e+00))))))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*((((od[10]*((xd[0]*xd[0])*xd[0]))+(od[11]*(xd[0]*xd[0])))+(od[12]*xd[0]))+od[13])))-xd[1]); -out[1] = (od[14]*a[0]); -out[2] = (od[15]*a[1]); -out[3] = ((((real_t)(2.0000000000000000e+00)*od[1])+(real_t)(1.0000000000000000e+00))*((((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*a[2])+(od[15]*a[3])))/((od[14]+od[15])+(real_t)(1.0000000000000000e-04)))+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*a[4]))-xd[2])); -out[4] = (((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*(((od[2]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[3]*(xd[0]+xd[0])))+od[4]))+(od[15]*(((od[6]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[7]*(xd[0]+xd[0])))+od[8]))))*a[5])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*(((od[10]*(((xd[0]+xd[0])*xd[0])+(xd[0]*xd[0])))+(od[11]*(xd[0]+xd[0])))+od[12]))); -out[5] = ((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)); -out[6] = (real_t)(0.0000000000000000e+00); -out[7] = (real_t)(0.0000000000000000e+00); -out[8] = (od[14]*a[8]); -out[9] = (od[14]*a[9]); -out[10] = (real_t)(0.0000000000000000e+00); -out[11] = (real_t)(0.0000000000000000e+00); -out[12] = (od[15]*a[12]); -out[13] = (od[15]*a[13]); -out[14] = (real_t)(0.0000000000000000e+00); -out[15] = (real_t)(0.0000000000000000e+00); -out[16] = ((((real_t)(2.0000000000000000e+00)*od[1])+(real_t)(1.0000000000000000e+00))*(((((od[14]+od[15])-(od[14]*od[15]))*((od[14]*a[15])+(od[15]*a[17])))*a[18])+(((real_t)(1.0000000000000000e+00)-((od[14]+od[15])-(od[14]*od[15])))*a[20]))); -out[17] = (real_t)(0.0000000000000000e+00); -out[18] = ((((real_t)(2.0000000000000000e+00)*od[1])+(real_t)(1.0000000000000000e+00))*((real_t)(0.0000000000000000e+00)-(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 * 18]; -acadoWorkspace.objValueIn[6] = acadoVariables.od[runObj * 18 + 1]; -acadoWorkspace.objValueIn[7] = acadoVariables.od[runObj * 18 + 2]; -acadoWorkspace.objValueIn[8] = acadoVariables.od[runObj * 18 + 3]; -acadoWorkspace.objValueIn[9] = acadoVariables.od[runObj * 18 + 4]; -acadoWorkspace.objValueIn[10] = acadoVariables.od[runObj * 18 + 5]; -acadoWorkspace.objValueIn[11] = acadoVariables.od[runObj * 18 + 6]; -acadoWorkspace.objValueIn[12] = acadoVariables.od[runObj * 18 + 7]; -acadoWorkspace.objValueIn[13] = acadoVariables.od[runObj * 18 + 8]; -acadoWorkspace.objValueIn[14] = acadoVariables.od[runObj * 18 + 9]; -acadoWorkspace.objValueIn[15] = acadoVariables.od[runObj * 18 + 10]; -acadoWorkspace.objValueIn[16] = acadoVariables.od[runObj * 18 + 11]; -acadoWorkspace.objValueIn[17] = acadoVariables.od[runObj * 18 + 12]; -acadoWorkspace.objValueIn[18] = acadoVariables.od[runObj * 18 + 13]; -acadoWorkspace.objValueIn[19] = acadoVariables.od[runObj * 18 + 14]; -acadoWorkspace.objValueIn[20] = acadoVariables.od[runObj * 18 + 15]; -acadoWorkspace.objValueIn[21] = acadoVariables.od[runObj * 18 + 16]; -acadoWorkspace.objValueIn[22] = acadoVariables.od[runObj * 18 + 17]; - -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[360]; -acadoWorkspace.objValueIn[5] = acadoVariables.od[361]; -acadoWorkspace.objValueIn[6] = acadoVariables.od[362]; -acadoWorkspace.objValueIn[7] = acadoVariables.od[363]; -acadoWorkspace.objValueIn[8] = acadoVariables.od[364]; -acadoWorkspace.objValueIn[9] = acadoVariables.od[365]; -acadoWorkspace.objValueIn[10] = acadoVariables.od[366]; -acadoWorkspace.objValueIn[11] = acadoVariables.od[367]; -acadoWorkspace.objValueIn[12] = acadoVariables.od[368]; -acadoWorkspace.objValueIn[13] = acadoVariables.od[369]; -acadoWorkspace.objValueIn[14] = acadoVariables.od[370]; -acadoWorkspace.objValueIn[15] = acadoVariables.od[371]; -acadoWorkspace.objValueIn[16] = acadoVariables.od[372]; -acadoWorkspace.objValueIn[17] = acadoVariables.od[373]; -acadoWorkspace.objValueIn[18] = acadoVariables.od[374]; -acadoWorkspace.objValueIn[19] = acadoVariables.od[375]; -acadoWorkspace.objValueIn[20] = acadoVariables.od[376]; -acadoWorkspace.objValueIn[21] = acadoVariables.od[377]; -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( ) -{ -int lRun1; -int lRun2; -int lRun3; -int lRun4; -int lRun5; -/** Row vector of size: 40 */ -static const int xBoundIndices[ 40 ] = -{ 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31, 34, 35, 38, 39, 42, 43, 46, 47, 50, 51, 54, 55, 58, 59, 62, 63, 66, 67, 70, 71, 74, 75, 78, 79, 82, 83 }; -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]; - -for (lRun1 = 0; lRun1 < 40; ++lRun1) -{ -lRun3 = xBoundIndices[ lRun1 ] - 4; -lRun4 = ((lRun3) / (4)) + (1); -acadoWorkspace.A[lRun1 * 24] = acadoWorkspace.evGx[lRun3 * 4]; -acadoWorkspace.A[lRun1 * 24 + 1] = acadoWorkspace.evGx[lRun3 * 4 + 1]; -acadoWorkspace.A[lRun1 * 24 + 2] = acadoWorkspace.evGx[lRun3 * 4 + 2]; -acadoWorkspace.A[lRun1 * 24 + 3] = acadoWorkspace.evGx[lRun3 * 4 + 3]; -for (lRun2 = 0; lRun2 < lRun4; ++lRun2) -{ -lRun5 = (((((lRun4) * (lRun4-1)) / (2)) + (lRun2)) * (4)) + ((lRun3) % (4)); -acadoWorkspace.A[(lRun1 * 24) + (lRun2 + 4)] = acadoWorkspace.E[lRun5]; -} -} - -} - -void acado_condenseFdb( ) -{ -real_t tmp; - -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]; -tmp = acadoVariables.x[6] + acadoWorkspace.d[2]; -acadoWorkspace.lbA[0] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[0] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[7] + acadoWorkspace.d[3]; -acadoWorkspace.lbA[1] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[1] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[10] + acadoWorkspace.d[6]; -acadoWorkspace.lbA[2] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[2] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[11] + acadoWorkspace.d[7]; -acadoWorkspace.lbA[3] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[3] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[14] + acadoWorkspace.d[10]; -acadoWorkspace.lbA[4] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[4] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[15] + acadoWorkspace.d[11]; -acadoWorkspace.lbA[5] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[5] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[18] + acadoWorkspace.d[14]; -acadoWorkspace.lbA[6] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[6] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[19] + acadoWorkspace.d[15]; -acadoWorkspace.lbA[7] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[7] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[22] + acadoWorkspace.d[18]; -acadoWorkspace.lbA[8] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[8] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[23] + acadoWorkspace.d[19]; -acadoWorkspace.lbA[9] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[9] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[26] + acadoWorkspace.d[22]; -acadoWorkspace.lbA[10] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[10] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[27] + acadoWorkspace.d[23]; -acadoWorkspace.lbA[11] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[11] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[30] + acadoWorkspace.d[26]; -acadoWorkspace.lbA[12] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[12] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[31] + acadoWorkspace.d[27]; -acadoWorkspace.lbA[13] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[13] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[34] + acadoWorkspace.d[30]; -acadoWorkspace.lbA[14] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[14] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[35] + acadoWorkspace.d[31]; -acadoWorkspace.lbA[15] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[15] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[38] + acadoWorkspace.d[34]; -acadoWorkspace.lbA[16] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[16] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[39] + acadoWorkspace.d[35]; -acadoWorkspace.lbA[17] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[17] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[42] + acadoWorkspace.d[38]; -acadoWorkspace.lbA[18] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[18] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[43] + acadoWorkspace.d[39]; -acadoWorkspace.lbA[19] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[19] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[46] + acadoWorkspace.d[42]; -acadoWorkspace.lbA[20] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[20] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[47] + acadoWorkspace.d[43]; -acadoWorkspace.lbA[21] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[21] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[50] + acadoWorkspace.d[46]; -acadoWorkspace.lbA[22] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[22] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[51] + acadoWorkspace.d[47]; -acadoWorkspace.lbA[23] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[23] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[54] + acadoWorkspace.d[50]; -acadoWorkspace.lbA[24] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[24] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[55] + acadoWorkspace.d[51]; -acadoWorkspace.lbA[25] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[25] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[58] + acadoWorkspace.d[54]; -acadoWorkspace.lbA[26] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[26] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[59] + acadoWorkspace.d[55]; -acadoWorkspace.lbA[27] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[27] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[62] + acadoWorkspace.d[58]; -acadoWorkspace.lbA[28] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[28] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[63] + acadoWorkspace.d[59]; -acadoWorkspace.lbA[29] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[29] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[66] + acadoWorkspace.d[62]; -acadoWorkspace.lbA[30] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[30] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[67] + acadoWorkspace.d[63]; -acadoWorkspace.lbA[31] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[31] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[70] + acadoWorkspace.d[66]; -acadoWorkspace.lbA[32] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[32] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[71] + acadoWorkspace.d[67]; -acadoWorkspace.lbA[33] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[33] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[74] + acadoWorkspace.d[70]; -acadoWorkspace.lbA[34] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[34] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[75] + acadoWorkspace.d[71]; -acadoWorkspace.lbA[35] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[35] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[78] + acadoWorkspace.d[74]; -acadoWorkspace.lbA[36] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[36] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[79] + acadoWorkspace.d[75]; -acadoWorkspace.lbA[37] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[37] = (real_t)8.7266462600000005e-01 - tmp; -tmp = acadoVariables.x[82] + acadoWorkspace.d[78]; -acadoWorkspace.lbA[38] = (real_t)-1.5707963268000000e+00 - tmp; -acadoWorkspace.ubA[38] = (real_t)1.5707963268000000e+00 - tmp; -tmp = acadoVariables.x[83] + acadoWorkspace.d[79]; -acadoWorkspace.lbA[39] = (real_t)-8.7266462600000005e-01 - tmp; -acadoWorkspace.ubA[39] = (real_t)8.7266462600000005e-01 - tmp; - -} - -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 * 18]; -acadoWorkspace.state[26] = acadoVariables.od[index * 18 + 1]; -acadoWorkspace.state[27] = acadoVariables.od[index * 18 + 2]; -acadoWorkspace.state[28] = acadoVariables.od[index * 18 + 3]; -acadoWorkspace.state[29] = acadoVariables.od[index * 18 + 4]; -acadoWorkspace.state[30] = acadoVariables.od[index * 18 + 5]; -acadoWorkspace.state[31] = acadoVariables.od[index * 18 + 6]; -acadoWorkspace.state[32] = acadoVariables.od[index * 18 + 7]; -acadoWorkspace.state[33] = acadoVariables.od[index * 18 + 8]; -acadoWorkspace.state[34] = acadoVariables.od[index * 18 + 9]; -acadoWorkspace.state[35] = acadoVariables.od[index * 18 + 10]; -acadoWorkspace.state[36] = acadoVariables.od[index * 18 + 11]; -acadoWorkspace.state[37] = acadoVariables.od[index * 18 + 12]; -acadoWorkspace.state[38] = acadoVariables.od[index * 18 + 13]; -acadoWorkspace.state[39] = acadoVariables.od[index * 18 + 14]; -acadoWorkspace.state[40] = acadoVariables.od[index * 18 + 15]; -acadoWorkspace.state[41] = acadoVariables.od[index * 18 + 16]; -acadoWorkspace.state[42] = acadoVariables.od[index * 18 + 17]; - -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[360]; -acadoWorkspace.state[26] = acadoVariables.od[361]; -acadoWorkspace.state[27] = acadoVariables.od[362]; -acadoWorkspace.state[28] = acadoVariables.od[363]; -acadoWorkspace.state[29] = acadoVariables.od[364]; -acadoWorkspace.state[30] = acadoVariables.od[365]; -acadoWorkspace.state[31] = acadoVariables.od[366]; -acadoWorkspace.state[32] = acadoVariables.od[367]; -acadoWorkspace.state[33] = acadoVariables.od[368]; -acadoWorkspace.state[34] = acadoVariables.od[369]; -acadoWorkspace.state[35] = acadoVariables.od[370]; -acadoWorkspace.state[36] = acadoVariables.od[371]; -acadoWorkspace.state[37] = acadoVariables.od[372]; -acadoWorkspace.state[38] = acadoVariables.od[373]; -acadoWorkspace.state[39] = acadoVariables.od[374]; -acadoWorkspace.state[40] = acadoVariables.od[375]; -acadoWorkspace.state[41] = acadoVariables.od[376]; -acadoWorkspace.state[42] = acadoVariables.od[377]; - -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); -} -for (index = 0; index < 40; ++index) -{ -prd = acadoWorkspace.y[index + 24]; -if (prd > 1e-12) -kkt += fabs(acadoWorkspace.lbA[index] * prd); -else if (prd < -1e-12) -kkt += fabs(acadoWorkspace.ubA[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 * 18]; -acadoWorkspace.objValueIn[6] = acadoVariables.od[lRun1 * 18 + 1]; -acadoWorkspace.objValueIn[7] = acadoVariables.od[lRun1 * 18 + 2]; -acadoWorkspace.objValueIn[8] = acadoVariables.od[lRun1 * 18 + 3]; -acadoWorkspace.objValueIn[9] = acadoVariables.od[lRun1 * 18 + 4]; -acadoWorkspace.objValueIn[10] = acadoVariables.od[lRun1 * 18 + 5]; -acadoWorkspace.objValueIn[11] = acadoVariables.od[lRun1 * 18 + 6]; -acadoWorkspace.objValueIn[12] = acadoVariables.od[lRun1 * 18 + 7]; -acadoWorkspace.objValueIn[13] = acadoVariables.od[lRun1 * 18 + 8]; -acadoWorkspace.objValueIn[14] = acadoVariables.od[lRun1 * 18 + 9]; -acadoWorkspace.objValueIn[15] = acadoVariables.od[lRun1 * 18 + 10]; -acadoWorkspace.objValueIn[16] = acadoVariables.od[lRun1 * 18 + 11]; -acadoWorkspace.objValueIn[17] = acadoVariables.od[lRun1 * 18 + 12]; -acadoWorkspace.objValueIn[18] = acadoVariables.od[lRun1 * 18 + 13]; -acadoWorkspace.objValueIn[19] = acadoVariables.od[lRun1 * 18 + 14]; -acadoWorkspace.objValueIn[20] = acadoVariables.od[lRun1 * 18 + 15]; -acadoWorkspace.objValueIn[21] = acadoVariables.od[lRun1 * 18 + 16]; -acadoWorkspace.objValueIn[22] = acadoVariables.od[lRun1 * 18 + 17]; - -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[360]; -acadoWorkspace.objValueIn[5] = acadoVariables.od[361]; -acadoWorkspace.objValueIn[6] = acadoVariables.od[362]; -acadoWorkspace.objValueIn[7] = acadoVariables.od[363]; -acadoWorkspace.objValueIn[8] = acadoVariables.od[364]; -acadoWorkspace.objValueIn[9] = acadoVariables.od[365]; -acadoWorkspace.objValueIn[10] = acadoVariables.od[366]; -acadoWorkspace.objValueIn[11] = acadoVariables.od[367]; -acadoWorkspace.objValueIn[12] = acadoVariables.od[368]; -acadoWorkspace.objValueIn[13] = acadoVariables.od[369]; -acadoWorkspace.objValueIn[14] = acadoVariables.od[370]; -acadoWorkspace.objValueIn[15] = acadoVariables.od[371]; -acadoWorkspace.objValueIn[16] = acadoVariables.od[372]; -acadoWorkspace.objValueIn[17] = acadoVariables.od[373]; -acadoWorkspace.objValueIn[18] = acadoVariables.od[374]; -acadoWorkspace.objValueIn[19] = acadoVariables.od[375]; -acadoWorkspace.objValueIn[20] = acadoVariables.od[376]; -acadoWorkspace.objValueIn[21] = acadoVariables.od[377]; -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/lateral_mpc/libmpc_py.py b/selfdrive/controls/lib/lateral_mpc/libmpc_py.py deleted file mode 100644 index 6b86d9565a526f..00000000000000 --- a/selfdrive/controls/lib/lateral_mpc/libmpc_py.py +++ /dev/null @@ -1,31 +0,0 @@ -import os -import subprocess - -from cffi import FFI - -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) - -ffi = FFI() -ffi.cdef(""" -typedef struct { - double x, y, psi, delta, t; -} state_t; - -typedef struct { - double x[21]; - double y[21]; - double psi[21]; - double delta[21]; - double rate[20]; - double cost; -} log_t; - -void init(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 p_poly[4], - double l_prob, double r_prob, double p_prob, double curvature_factor, double v_ref, double lane_width); -""") - -libmpc = ffi.dlopen(libmpc_fn) diff --git a/selfdrive/controls/lib/lateral_mpc_lib/.gitignore b/selfdrive/controls/lib/lateral_mpc_lib/.gitignore new file mode 100644 index 00000000000000..aff2eb082b6b8b --- /dev/null +++ b/selfdrive/controls/lib/lateral_mpc_lib/.gitignore @@ -0,0 +1,2 @@ +acados_ocp_lat.json +c_generated_code/ diff --git a/selfdrive/controls/lib/lateral_mpc_lib/SConscript b/selfdrive/controls/lib/lateral_mpc_lib/SConscript new file mode 100644 index 00000000000000..148e4e123d320a --- /dev/null +++ b/selfdrive/controls/lib/lateral_mpc_lib/SConscript @@ -0,0 +1,77 @@ +Import('env', 'envCython', 'arch', 'common') + +gen = "c_generated_code" + +casadi_model = [ + f'{gen}/lat_model/lat_expl_ode_fun.c', + f'{gen}/lat_model/lat_expl_vde_forw.c', +] + +casadi_cost_y = [ + f'{gen}/lat_cost/lat_cost_y_fun.c', + f'{gen}/lat_cost/lat_cost_y_fun_jac_ut_xt.c', + f'{gen}/lat_cost/lat_cost_y_hess.c', +] + +casadi_cost_e = [ + f'{gen}/lat_cost/lat_cost_y_e_fun.c', + f'{gen}/lat_cost/lat_cost_y_e_fun_jac_ut_xt.c', + f'{gen}/lat_cost/lat_cost_y_e_hess.c', +] + +casadi_cost_0 = [ + f'{gen}/lat_cost/lat_cost_y_0_fun.c', + f'{gen}/lat_cost/lat_cost_y_0_fun_jac_ut_xt.c', + f'{gen}/lat_cost/lat_cost_y_0_hess.c', +] + +build_files = [f'{gen}/acados_solver_lat.c'] + casadi_model + casadi_cost_y + casadi_cost_e + casadi_cost_0 + +# extra generated files used to trigger a rebuild +generated_files = [ + f'{gen}/Makefile', + + f'{gen}/main_lat.c', + f'{gen}/acados_solver_lat.h', + f'{gen}/acados_solver.pxd', + + f'{gen}/lat_model/lat_expl_vde_adj.c', + + f'{gen}/lat_model/lat_model.h', + f'{gen}/lat_cost/lat_cost_y_fun.h', + f'{gen}/lat_cost/lat_cost_y_e_fun.h', + f'{gen}/lat_cost/lat_cost_y_0_fun.h', +] + build_files + +lenv = env.Clone() +lenv.Clean(generated_files, Dir(gen)) + +lenv.Command(generated_files, + ["lat_mpc.py"], + f"cd {Dir('.').abspath} && python lat_mpc.py") + +lenv["CFLAGS"].append("-DACADOS_WITH_QPOASES") +lenv["CXXFLAGS"].append("-DACADOS_WITH_QPOASES") +lenv["CCFLAGS"].append("-Wno-unused") +lenv["LINKFLAGS"].append("-Wl,--disable-new-dtags") +lib_solver = lenv.SharedLibrary(f"{gen}/acados_ocp_solver_lat", + build_files, + LIBS=['m', 'acados', 'hpipm', 'blasfeo', 'qpOASES_e']) + +# generate cython stuff +acados_ocp_solver_pyx = File("#pyextra/acados_template/acados_ocp_solver_pyx.pyx") +acados_ocp_solver_common = File("#pyextra/acados_template/acados_solver_common.pxd") +libacados_ocp_solver_pxd = File(f'{gen}/acados_solver.pxd') +libacados_ocp_solver_c = File(f'{gen}/acados_ocp_solver_pyx.c') + +lenv2 = envCython.Clone() +lenv2["LINKFLAGS"] += [lib_solver[0].get_labspath()] +lenv2.Command(libacados_ocp_solver_c, + [acados_ocp_solver_pyx, acados_ocp_solver_common, libacados_ocp_solver_pxd], + f'cython' + \ + f' -o {libacados_ocp_solver_c.get_labspath()}' + \ + f' -I {libacados_ocp_solver_pxd.get_dir().get_labspath()}' + \ + f' -I {acados_ocp_solver_common.get_dir().get_labspath()}' + \ + f' {acados_ocp_solver_pyx.get_labspath()}') +lib_cython = lenv2.Program(f'{gen}/acados_ocp_solver_pyx.so', [libacados_ocp_solver_c]) +lenv2.Depends(lib_cython, lib_solver) diff --git a/selfdrive/controls/lib/lateral_mpc/__init__.py b/selfdrive/controls/lib/lateral_mpc_lib/__init__.py similarity index 100% rename from selfdrive/controls/lib/lateral_mpc/__init__.py rename to selfdrive/controls/lib/lateral_mpc_lib/__init__.py diff --git a/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py b/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py new file mode 100755 index 00000000000000..6162cf68a51ae3 --- /dev/null +++ b/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python3 +import os +import numpy as np + +from casadi import SX, vertcat, sin, cos +from selfdrive.controls.lib.drive_helpers import LAT_MPC_N as N +from selfdrive.controls.lib.drive_helpers import T_IDXS + +if __name__ == '__main__': # generating code + from pyextra.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver +else: + # from pyextra.acados_template import AcadosOcpSolverFast + from selfdrive.controls.lib.lateral_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverFast # pylint: disable=no-name-in-module, import-error + +LAT_MPC_DIR = os.path.dirname(os.path.abspath(__file__)) +EXPORT_DIR = os.path.join(LAT_MPC_DIR, "c_generated_code") +JSON_FILE = "acados_ocp_lat.json" +X_DIM = 6 + +def gen_lat_model(): + model = AcadosModel() + model.name = 'lat' + + # set up states & controls + x_ego = SX.sym('x_ego') + y_ego = SX.sym('y_ego') + psi_ego = SX.sym('psi_ego') + curv_ego = SX.sym('curv_ego') + v_ego = SX.sym('v_ego') + rotation_radius = SX.sym('rotation_radius') + model.x = vertcat(x_ego, y_ego, psi_ego, curv_ego, v_ego, rotation_radius) + + # controls + curv_rate = SX.sym('curv_rate') + model.u = vertcat(curv_rate) + + # xdot + x_ego_dot = SX.sym('x_ego_dot') + y_ego_dot = SX.sym('y_ego_dot') + psi_ego_dot = SX.sym('psi_ego_dot') + curv_ego_dot = SX.sym('curv_ego_dot') + v_ego_dot = SX.sym('v_ego_dot') + rotation_radius_dot = SX.sym('rotation_radius_dot') + model.xdot = vertcat(x_ego_dot, y_ego_dot, psi_ego_dot, curv_ego_dot, + v_ego_dot, rotation_radius_dot) + + # dynamics model + f_expl = vertcat(v_ego * cos(psi_ego) - rotation_radius * sin(psi_ego) * (v_ego * curv_ego), + v_ego * sin(psi_ego) + rotation_radius * cos(psi_ego) * (v_ego * curv_ego), + v_ego * curv_ego, + curv_rate, + 0.0, + 0.0) + model.f_impl_expr = model.xdot - f_expl + model.f_expl_expr = f_expl + return model + + +def gen_lat_mpc_solver(): + ocp = AcadosOcp() + ocp.model = gen_lat_model() + + Tf = np.array(T_IDXS)[N] + + # set dimensions + ocp.dims.N = N + + # set cost module + ocp.cost.cost_type = 'NONLINEAR_LS' + ocp.cost.cost_type_e = 'NONLINEAR_LS' + + Q = np.diag([0.0, 0.0]) + QR = np.diag([0.0, 0.0, 0.0]) + + ocp.cost.W = QR + ocp.cost.W_e = Q + + y_ego, psi_ego = ocp.model.x[1], ocp.model.x[2] + curv_rate = ocp.model.u[0] + v_ego = ocp.model.x[4] + + + ocp.cost.yref = np.zeros((3, )) + ocp.cost.yref_e = np.zeros((2, )) + # TODO hacky weights to keep behavior the same + ocp.model.cost_y_expr = vertcat(y_ego, + ((v_ego +5.0) * psi_ego), + ((v_ego +5.0) * 4 * curv_rate)) + ocp.model.cost_y_expr_e = vertcat(y_ego, + ((v_ego +5.0) * psi_ego)) + + # set constraints + ocp.constraints.constr_type = 'BGH' + ocp.constraints.idxbx = np.array([2,3]) + ocp.constraints.ubx = np.array([np.radians(90), np.radians(50)]) + ocp.constraints.lbx = np.array([-np.radians(90), -np.radians(50)]) + x0 = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) + ocp.constraints.x0 = x0 + + ocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM' + ocp.solver_options.hessian_approx = 'GAUSS_NEWTON' + ocp.solver_options.integrator_type = 'ERK' + ocp.solver_options.nlp_solver_type = 'SQP_RTI' + ocp.solver_options.qp_solver_iter_max = 1 + ocp.solver_options.qp_solver_cond_N = N//4 + + # set prediction horizon + ocp.solver_options.tf = Tf + ocp.solver_options.shooting_nodes = np.array(T_IDXS)[:N+1] + + ocp.code_export_directory = EXPORT_DIR + return ocp + + +class LateralMpc(): + def __init__(self, x0=np.zeros(X_DIM)): + self.solver = AcadosOcpSolverFast('lat', N, EXPORT_DIR) + self.reset(x0) + + def reset(self, x0=np.zeros(X_DIM)): + self.x_sol = np.zeros((N+1, X_DIM)) + self.u_sol = np.zeros((N, 1)) + self.yref = np.zeros((N+1, 3)) + for i in range(N): + self.solver.cost_set(i, "yref", self.yref[i]) + self.solver.cost_set(N, "yref", self.yref[N][:2]) + + # Somehow needed for stable init + for i in range(N+1): + self.solver.set(i, 'x', np.zeros(X_DIM)) + self.solver.constraints_set(0, "lbx", x0) + self.solver.constraints_set(0, "ubx", x0) + self.solver.solve() + self.solution_status = 0 + self.cost = 0 + + def set_weights(self, path_weight, heading_weight, steer_rate_weight): + W = np.asfortranarray(np.diag([path_weight, heading_weight, steer_rate_weight])) + for i in range(N): + self.solver.cost_set(i, 'W', W) + #TODO hacky weights to keep behavior the same + self.solver.cost_set(N, 'W', (3/20.)*W[:2,:2]) + + def run(self, x0, v_ego, car_rotation_radius, y_pts, heading_pts): + x0_cp = np.copy(x0) + self.solver.constraints_set(0, "lbx", x0_cp) + self.solver.constraints_set(0, "ubx", x0_cp) + self.yref[:,0] = y_pts + self.yref[:,1] = heading_pts*(v_ego+5.0) + for i in range(N): + self.solver.cost_set(i, "yref", self.yref[i]) + self.solver.cost_set(N, "yref", self.yref[N][:2]) + + self.solution_status = self.solver.solve() + for i in range(N+1): + self.x_sol[i] = self.solver.get(i, 'x') + for i in range(N): + self.u_sol[i] = self.solver.get(i, 'u') + self.cost = self.solver.get_cost() + + +if __name__ == "__main__": + ocp = gen_lat_mpc_solver() + AcadosOcpSolver.generate(ocp, json_file=JSON_FILE, build=False) diff --git a/selfdrive/controls/lib/lateral_planner.py b/selfdrive/controls/lib/lateral_planner.py new file mode 100644 index 00000000000000..0aa2359ae7956e --- /dev/null +++ b/selfdrive/controls/lib/lateral_planner.py @@ -0,0 +1,223 @@ +import math +import numpy as np +from common.realtime import sec_since_boot, DT_MDL +from common.numpy_fast import interp +from selfdrive.swaglog import cloudlog +from selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import LateralMpc +from selfdrive.controls.lib.drive_helpers import CONTROL_N, MPC_COST_LAT, LAT_MPC_N, CAR_ROTATION_RADIUS +from selfdrive.controls.lib.lane_planner import LanePlanner, TRAJECTORY_SIZE +from selfdrive.config import Conversions as CV +import cereal.messaging as messaging +from cereal import log + +LaneChangeState = log.LateralPlan.LaneChangeState +LaneChangeDirection = log.LateralPlan.LaneChangeDirection + +LANE_CHANGE_SPEED_MIN = 30 * CV.MPH_TO_MS +LANE_CHANGE_TIME_MAX = 10. + +DESIRES = { + LaneChangeDirection.none: { + LaneChangeState.off: log.LateralPlan.Desire.none, + LaneChangeState.preLaneChange: log.LateralPlan.Desire.none, + LaneChangeState.laneChangeStarting: log.LateralPlan.Desire.none, + LaneChangeState.laneChangeFinishing: log.LateralPlan.Desire.none, + }, + LaneChangeDirection.left: { + LaneChangeState.off: log.LateralPlan.Desire.none, + LaneChangeState.preLaneChange: log.LateralPlan.Desire.none, + LaneChangeState.laneChangeStarting: log.LateralPlan.Desire.laneChangeLeft, + LaneChangeState.laneChangeFinishing: log.LateralPlan.Desire.laneChangeLeft, + }, + LaneChangeDirection.right: { + LaneChangeState.off: log.LateralPlan.Desire.none, + LaneChangeState.preLaneChange: log.LateralPlan.Desire.none, + LaneChangeState.laneChangeStarting: log.LateralPlan.Desire.laneChangeRight, + LaneChangeState.laneChangeFinishing: log.LateralPlan.Desire.laneChangeRight, + }, +} + + +class LateralPlanner: + def __init__(self, CP, use_lanelines=True, wide_camera=False): + self.use_lanelines = use_lanelines + self.LP = LanePlanner(wide_camera) + + self.last_cloudlog_t = 0 + self.steer_rate_cost = CP.steerRateCost + + self.solution_invalid_cnt = 0 + 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.keep_pulse_timer = 0.0 + self.prev_one_blinker = False + self.desire = log.LateralPlan.Desire.none + + self.path_xyz = np.zeros((TRAJECTORY_SIZE, 3)) + self.path_xyz_stds = np.ones((TRAJECTORY_SIZE, 3)) + self.plan_yaw = np.zeros((TRAJECTORY_SIZE,)) + self.t_idxs = np.arange(TRAJECTORY_SIZE) + self.y_pts = np.zeros(TRAJECTORY_SIZE) + + self.lat_mpc = LateralMpc() + self.reset_mpc(np.zeros(6)) + + def reset_mpc(self, x0=np.zeros(6)): + self.x0 = x0 + self.lat_mpc.reset(x0=self.x0) + + def update(self, sm): + v_ego = sm['carState'].vEgo + active = sm['controlsState'].active + measured_curvature = sm['controlsState'].curvature + + md = sm['modelV2'] + self.LP.parse_model(sm['modelV2']) + if len(md.position.x) == TRAJECTORY_SIZE and len(md.orientation.x) == TRAJECTORY_SIZE: + self.path_xyz = np.column_stack([md.position.x, md.position.y, md.position.z]) + self.t_idxs = np.array(md.position.t) + self.plan_yaw = list(md.orientation.z) + if len(md.position.xStd) == TRAJECTORY_SIZE: + self.path_xyz_stds = np.column_stack([md.position.xStd, md.position.yStd, md.position.zStd]) + + # Lane change logic + one_blinker = sm['carState'].leftBlinker != sm['carState'].rightBlinker + below_lane_change_speed = v_ego < LANE_CHANGE_SPEED_MIN + + if (not active) or (self.lane_change_timer > LANE_CHANGE_TIME_MAX): + self.lane_change_state = LaneChangeState.off + self.lane_change_direction = LaneChangeDirection.none + else: + # LaneChangeState.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 + + # LaneChangeState.preLaneChange + elif self.lane_change_state == LaneChangeState.preLaneChange: + # Set lane change direction + if sm['carState'].leftBlinker: + self.lane_change_direction = LaneChangeDirection.left + elif sm['carState'].rightBlinker: + self.lane_change_direction = LaneChangeDirection.right + else: # If there are no blinkers we will go back to LaneChangeState.off + self.lane_change_direction = LaneChangeDirection.none + + 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)) + + 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 + + # LaneChangeState.laneChangeStarting + 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 + lane_change_prob = self.LP.l_lane_change_prob + self.LP.r_lane_change_prob + if lane_change_prob < 0.02 and self.lane_change_ll_prob < 0.01: + self.lane_change_state = LaneChangeState.laneChangeFinishing + + # LaneChangeState.laneChangeFinishing + 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 self.lane_change_ll_prob > 0.99: + self.lane_change_direction = LaneChangeDirection.none + if one_blinker: + self.lane_change_state = LaneChangeState.preLaneChange + else: + 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 + + self.desire = DESIRES[self.lane_change_direction][self.lane_change_state] + + # Send keep pulse once per second during LaneChangeStart.preLaneChange + if self.lane_change_state in [LaneChangeState.off, LaneChangeState.laneChangeStarting]: + self.keep_pulse_timer = 0.0 + elif self.lane_change_state == LaneChangeState.preLaneChange: + self.keep_pulse_timer += DT_MDL + if self.keep_pulse_timer > 1.0: + self.keep_pulse_timer = 0.0 + elif self.desire in [log.LateralPlan.Desire.keepLeft, log.LateralPlan.Desire.keepRight]: + self.desire = log.LateralPlan.Desire.none + + # Turn off lanes during lane change + if self.desire == log.LateralPlan.Desire.laneChangeRight or self.desire == log.LateralPlan.Desire.laneChangeLeft: + self.LP.lll_prob *= self.lane_change_ll_prob + self.LP.rll_prob *= self.lane_change_ll_prob + if self.use_lanelines: + d_path_xyz = self.LP.get_d_path(v_ego, self.t_idxs, self.path_xyz) + self.lat_mpc.set_weights(MPC_COST_LAT.PATH, MPC_COST_LAT.HEADING, self.steer_rate_cost) + else: + d_path_xyz = self.path_xyz + path_cost = np.clip(abs(self.path_xyz[0, 1] / self.path_xyz_stds[0, 1]), 0.5, 1.5) * MPC_COST_LAT.PATH + # Heading cost is useful at low speed, otherwise end of plan can be off-heading + heading_cost = interp(v_ego, [5.0, 10.0], [MPC_COST_LAT.HEADING, 0.0]) + self.lat_mpc.set_weights(path_cost, heading_cost, self.steer_rate_cost) + y_pts = np.interp(v_ego * self.t_idxs[:LAT_MPC_N + 1], np.linalg.norm(d_path_xyz, axis=1), d_path_xyz[:, 1]) + heading_pts = np.interp(v_ego * self.t_idxs[:LAT_MPC_N + 1], np.linalg.norm(self.path_xyz, axis=1), self.plan_yaw) + self.y_pts = y_pts + + assert len(y_pts) == LAT_MPC_N + 1 + assert len(heading_pts) == LAT_MPC_N + 1 + self.x0[4] = v_ego + self.lat_mpc.run(self.x0, + v_ego, + CAR_ROTATION_RADIUS, + y_pts, + heading_pts) + # init state for next + self.x0[3] = interp(DT_MDL, self.t_idxs[:LAT_MPC_N + 1], self.lat_mpc.x_sol[:, 3]) + + # Check for infeasible MPC solution + mpc_nans = any(math.isnan(x) for x in self.lat_mpc.x_sol[:, 3]) + t = sec_since_boot() + if mpc_nans or self.lat_mpc.solution_status != 0: + self.reset_mpc() + self.x0[3] = measured_curvature + if t > self.last_cloudlog_t + 5.0: + self.last_cloudlog_t = t + cloudlog.warning("Lateral mpc - nan: True") + + if self.lat_mpc.cost > 20000. or mpc_nans: + self.solution_invalid_cnt += 1 + else: + self.solution_invalid_cnt = 0 + + def publish(self, sm, pm): + plan_solution_valid = self.solution_invalid_cnt < 2 + plan_send = messaging.new_message('lateralPlan') + plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState', 'modelV2']) + plan_send.lateralPlan.laneWidth = float(self.LP.lane_width) + plan_send.lateralPlan.dPathPoints = [float(x) for x in self.y_pts] + plan_send.lateralPlan.psis = [float(x) for x in self.lat_mpc.x_sol[0:CONTROL_N, 2]] + plan_send.lateralPlan.curvatures = [float(x) for x in self.lat_mpc.x_sol[0:CONTROL_N, 3]] + plan_send.lateralPlan.curvatureRates = [float(x) for x in self.lat_mpc.u_sol[0:CONTROL_N - 1]] + [0.0] + plan_send.lateralPlan.lProb = float(self.LP.lll_prob) + plan_send.lateralPlan.rProb = float(self.LP.rll_prob) + plan_send.lateralPlan.dProb = float(self.LP.d_prob) + + plan_send.lateralPlan.mpcSolutionValid = bool(plan_solution_valid) + + plan_send.lateralPlan.desire = self.desire + plan_send.lateralPlan.useLaneLines = self.use_lanelines + plan_send.lateralPlan.laneChangeState = self.lane_change_state + plan_send.lateralPlan.laneChangeDirection = self.lane_change_direction + + pm.send('lateralPlan', plan_send) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py deleted file mode 100644 index 9d43e97f26b5fd..00000000000000 --- a/selfdrive/controls/lib/long_mpc.py +++ /dev/null @@ -1,125 +0,0 @@ -import os -import numpy as np - -import selfdrive.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 -from selfdrive.controls.lib.longitudinal_mpc import libmpc_py -from selfdrive.controls.lib.drive_helpers import MPC_COST_LONG - -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 - self.mpc_id = mpc_id - - self.setup_mpc() - self.v_mpc = 0.0 - self.v_mpc_future = 0.0 - self.a_mpc = 0.0 - self.v_cruise = 0.0 - self.prev_lead_status = False - self.prev_lead_x = 0.0 - self.new_lead = False - - self.last_cloudlog_t = 0.0 - - def send_mpc_solution(self, qp_iterations, calculation_time): - qp_iterations = max(0, qp_iterations) - dat = messaging.new_message() - dat.init('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) - dat.liveLongitudinalMpc.xLead = list(self.mpc_solution[0].x_l) - dat.liveLongitudinalMpc.vLead = list(self.mpc_solution[0].v_l) - dat.liveLongitudinalMpc.cost = self.mpc_solution[0].cost - dat.liveLongitudinalMpc.aLeadTau = self.a_lead_tau - dat.liveLongitudinalMpc.qpIterations = qp_iterations - dat.liveLongitudinalMpc.mpcId = self.mpc_id - dat.liveLongitudinalMpc.calculationTime = calculation_time - self.live_longitudinal_mpc.send(dat.to_bytes()) - - def setup_mpc(self): - ffi, self.libmpc = libmpc_py.get_libmpc(self.mpc_id) - self.libmpc.init(MPC_COST_LONG.TTC, MPC_COST_LONG.DISTANCE, - MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK) - - self.mpc_solution = ffi.new("log_t *") - self.cur_state = ffi.new("state_t *") - self.cur_state[0].v_ego = 0 - self.cur_state[0].a_ego = 0 - self.a_lead_tau = _LEAD_ACCEL_TAU - - 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): - v_ego = CS.vEgo - - # Setup current mpc state - self.cur_state[0].x_ego = 0.0 - - if lead is not None and lead.status: - x_lead = lead.dRel - v_lead = max(0.0, lead.vLead) - a_lead = lead.aLeadK - - if (v_lead < 0.1 or -a_lead / 2.0 > v_lead): - v_lead = 0.0 - a_lead = 0.0 - - self.a_lead_tau = lead.aLeadTau - self.new_lead = False - if not self.prev_lead_status or abs(x_lead - self.prev_lead_x) > 2.5: - self.libmpc.init_with_simulation(self.v_mpc, x_lead, v_lead, a_lead, self.a_lead_tau) - self.new_lead = True - - self.prev_lead_status = True - self.prev_lead_x = x_lead - self.cur_state[0].x_l = x_lead - self.cur_state[0].v_l = v_lead - else: - self.prev_lead_status = False - # Fake a fast lead car, so mpc keeps running - self.cur_state[0].x_l = 50.0 - self.cur_state[0].v_l = v_ego + 10.0 - a_lead = 0.0 - self.a_lead_tau = _LEAD_ACCEL_TAU - - # Calculate mpc - t = sec_since_boot() - n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead) - duration = int((sec_since_boot() - t) * 1e9) - - if LOG_MPC: - self.send_mpc_solution(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] - self.a_mpc = self.mpc_solution[0].a_ego[1] - 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 - - if ((backwards or crashing) and self.prev_lead_status) or nans: - if t > self.last_cloudlog_t + 5.0: - self.last_cloudlog_t = t - cloudlog.warning("Longitudinal mpc %d reset - backwards: %s crashing: %s nan: %s" % ( - self.mpc_id, backwards, crashing, nans)) - - self.libmpc.init(MPC_COST_LONG.TTC, MPC_COST_LONG.DISTANCE, - MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK) - self.cur_state[0].v_ego = v_ego - self.cur_state[0].a_ego = 0.0 - self.v_mpc = v_ego - self.a_mpc = CS.aEgo - self.prev_lead_status = False diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 84c17ef374380f..beacc518d0dea8 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -1,34 +1,29 @@ -from cereal import log +from cereal import car from common.numpy_fast import clip, interp +from common.realtime import DT_CTRL from selfdrive.controls.lib.pid import PIController +from selfdrive.controls.lib.drive_helpers import CONTROL_N +from selfdrive.modeld.constants import T_IDXS -LongCtrlState = log.ControlsState.LongControlState +LongCtrlState = car.CarControl.Actuators.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 -STARTING_TARGET_SPEED = 0.5 -BRAKE_THRESHOLD_TO_PID = 0.2 +STOPPING_TARGET_SPEED_OFFSET = 0.01 -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 +# As per ISO 15622:2018 for all speeds +ACCEL_MIN_ISO = -3.5 # m/s^2 +ACCEL_MAX_ISO = 2.0 # m/s^2 -_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): +def long_control_state_trans(CP, active, long_control_state, v_ego, v_target_future, v_pid, + output_accel, 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 < CP.vEgoStopping and + ((v_pid < stopping_target_speed and v_target_future < stopping_target_speed) or + brake_pressed)) - starting_condition = v_target > STARTING_TARGET_SPEED and not cruise_standstill + starting_condition = v_target_future > CP.vEgoStarting and not cruise_standstill if not active: long_control_state = LongCtrlState.off @@ -49,82 +44,91 @@ def long_control_state_trans(active, long_control_state, v_ego, v_target, v_pid, elif long_control_state == LongCtrlState.starting: if stopping_condition: long_control_state = LongCtrlState.stopping - elif output_gb >= -BRAKE_THRESHOLD_TO_PID: + elif output_accel >= CP.startAccel: long_control_state = LongCtrlState.pid return long_control_state -class LongControl(object): - def __init__(self, CP, compute_gb): +class LongControl(): + def __init__(self, CP): self.long_control_state = LongCtrlState.off # initialized to off self.pid = PIController((CP.longitudinalTuning.kpBP, CP.longitudinalTuning.kpV), (CP.longitudinalTuning.kiBP, CP.longitudinalTuning.kiV), - rate=RATE, - sat_limit=0.8, - convert=compute_gb) + rate=1/DT_CTRL, + sat_limit=0.8) self.v_pid = 0.0 - self.last_output_gb = 0.0 + self.last_output_accel = 0.0 def reset(self, v_pid): """Reset PID controller and change setpoint""" 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, CP, long_plan, accel_limits): """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) + # Interp control trajectory + # TODO estimate car specific lag, use .15s for now + if len(long_plan.speeds) == CONTROL_N: + v_target_lower = interp(CP.longitudinalActuatorDelayLowerBound, T_IDXS[:CONTROL_N], long_plan.speeds) + a_target_lower = 2 * (v_target_lower - long_plan.speeds[0])/CP.longitudinalActuatorDelayLowerBound - long_plan.accels[0] - # Update state machine - output_gb = self.last_output_gb - self.long_control_state = long_control_state_trans(active, self.long_control_state, v_ego, - v_target_future, self.v_pid, output_gb, - brake_pressed, cruise_standstill) + v_target_upper = interp(CP.longitudinalActuatorDelayUpperBound, T_IDXS[:CONTROL_N], long_plan.speeds) + a_target_upper = 2 * (v_target_upper - long_plan.speeds[0])/CP.longitudinalActuatorDelayUpperBound - long_plan.accels[0] + a_target = min(a_target_lower, a_target_upper) + + v_target_future = long_plan.speeds[-1] + else: + v_target_future = 0.0 + a_target = 0.0 - v_ego_pid = max(v_ego, MIN_CAN_SPEED) # Without this we get jumps, CAN bus reports 0 when speed < 0.3 + # TODO: This check is not complete and needs to be enforced by MPC + a_target = clip(a_target, ACCEL_MIN_ISO, ACCEL_MAX_ISO) + + self.pid.neg_limit = accel_limits[0] + self.pid.pos_limit = accel_limits[1] + + # Update state machine + output_accel = self.last_output_accel + self.long_control_state = long_control_state_trans(CP, active, self.long_control_state, CS.vEgo, + v_target_future, self.v_pid, output_accel, + CS.brakePressed, CS.cruiseState.standstill, CP.minSpeedCan) - if self.long_control_state == LongCtrlState.off: - self.v_pid = v_ego_pid - self.pid.reset() - output_gb = 0. + if self.long_control_state == LongCtrlState.off or CS.gasPressed: + self.reset(CS.vEgo) + output_accel = 0. # tracking objects and driving elif self.long_control_state == LongCtrlState.pid: - self.v_pid = v_target - self.pid.pos_limit = gas_max - self.pid.neg_limit = - brake_max + self.v_pid = long_plan.speeds[0] # 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 - deadzone = interp(v_ego_pid, CP.longitudinalTuning.deadzoneBP, CP.longitudinalTuning.deadzoneV) + prevent_overshoot = not CP.stoppingControl and CS.vEgo < 1.5 and v_target_future < 0.7 and v_target_future < self.v_pid + deadzone = interp(CS.vEgo, CP.longitudinalTuning.deadzoneBP, CP.longitudinalTuning.deadzoneV) + freeze_integrator = prevent_overshoot - output_gb = self.pid.update(self.v_pid, v_ego_pid, speed=v_ego_pid, deadzone=deadzone, feedforward=a_target, freeze_integrator=prevent_overshoot) + output_accel = self.pid.update(self.v_pid, CS.vEgo, speed=CS.vEgo, deadzone=deadzone, feedforward=a_target, freeze_integrator=freeze_integrator) if prevent_overshoot: - output_gb = min(output_gb, 0.0) + output_accel = min(output_accel, 0.0) # 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 - output_gb = clip(output_gb, -brake_max, gas_max) + if not CS.standstill or output_accel > CP.stopAccel: + output_accel -= CP.stoppingDecelRate * DT_CTRL + output_accel = clip(output_accel, accel_limits[0], accel_limits[1]) - 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() + if output_accel < CP.startAccel: + output_accel += CP.startingAccelRate * DT_CTRL + 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.) + self.last_output_accel = output_accel + final_accel = clip(output_accel, accel_limits[0], accel_limits[1]) - return final_gas, final_brake + return final_accel 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/generator.cpp b/selfdrive/controls/lib/longitudinal_mpc/generator.cpp deleted file mode 100644 index a34fbc3510b6ed..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/generator.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include - -const int controlHorizon = 50; - -using namespace std; - -#define G 9.81 -#define TR 1.8 - -#define RW(v_ego, v_l) (v_ego * TR - (v_l - v_ego) * TR + v_ego*v_ego/(2*G) - v_l*v_l / (2*G)) -#define NORM_RW_ERROR(v_ego, v_l, p) ((RW(v_ego, v_l) + 4.0 - p)/(sqrt(v_ego + 0.5) + 0.1)) - -int main( ) -{ - USING_NAMESPACE_ACADO - - - DifferentialEquation f; - - DifferentialState x_ego, v_ego, a_ego; - OnlineData x_l, v_l; - - Control j_ego; - - auto desired = 4.0 + RW(v_ego, v_l); - auto d_l = x_l - x_ego; - - // Equations of motion - f << dot(x_ego) == v_ego; - f << dot(v_ego) == a_ego; - f << dot(a_ego) == j_ego; - - // Running cost - Function h; - h << exp(0.3 * NORM_RW_ERROR(v_ego, v_l, d_l)) - 1; - h << (d_l - desired) / (0.05 * v_ego + 0.5); - 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(4,4); Q.setAll(true); - - // Terminal cost - Function hN; - hN << exp(0.3 * NORM_RW_ERROR(v_ego, v_l, d_l)) - 1; - hN << (d_l - desired) / (0.05 * v_ego + 0.5); - hN << a_ego * (0.1 * v_ego + 1.0); - - // Weights are defined in mpc. - BMatrix QN(3,3); 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(2); - - 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/lib_mpc_export/acado_auxiliary_functions.c b/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_auxiliary_functions.c deleted file mode 100644 index 6f0bb705c8a897..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_auxiliary_functions.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * 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/lib_mpc_export/acado_auxiliary_functions.h b/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_auxiliary_functions.h deleted file mode 100644 index b1be0a661c0125..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_auxiliary_functions.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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/lib_mpc_export/acado_common.h b/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_common.h deleted file mode 100644 index c0eb83bced374f..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_common.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * 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 2 -/** Number of path constraints. */ -#define ACADO_NPAC 0 -/** Number of control variables. */ -#define ACADO_NU 1 -/** Number of differential variables. */ -#define ACADO_NX 3 -/** 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 4 -/** Number of references/measurements on the last (N + 1)st node. */ -#define ACADO_NYN 3 -/** Total number of QP optimization variables. */ -#define ACADO_QP_NV 23 -/** 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 3 (row major format) - * - * Matrix containing 21 differential variable vectors. - */ -real_t x[ 63 ]; - -/** Column vector of size: 20 - * - * Matrix containing 20 control variable vectors. - */ -real_t u[ 20 ]; - -/** Matrix of size: 21 x 2 (row major format) - * - * Matrix containing 21 online data vectors. - */ -real_t od[ 42 ]; - -/** Column vector of size: 80 - * - * Matrix containing 20 reference/measurement vectors of size 4 for first 20 nodes. - */ -real_t y[ 80 ]; - -/** Column vector of size: 3 - * - * Reference/measurement vector for the 21. node. - */ -real_t yN[ 3 ]; - -/** Matrix of size: 80 x 4 (row major format) */ -real_t W[ 320 ]; - -/** Matrix of size: 3 x 3 (row major format) */ -real_t WN[ 9 ]; - -/** Column vector of size: 3 - * - * Current state feedback vector. - */ -real_t x0[ 3 ]; - - -} 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: 18 */ -real_t rk_xxx[ 18 ]; - -/** Matrix of size: 4 x 15 (row major format) */ -real_t rk_kkk[ 60 ]; - -/** Row vector of size: 18 */ -real_t state[ 18 ]; - -/** Column vector of size: 60 */ -real_t d[ 60 ]; - -/** Column vector of size: 80 */ -real_t Dy[ 80 ]; - -/** Column vector of size: 3 */ -real_t DyN[ 3 ]; - -/** Matrix of size: 60 x 3 (row major format) */ -real_t evGx[ 180 ]; - -/** Column vector of size: 60 */ -real_t evGu[ 60 ]; - -/** Column vector of size: 13 */ -real_t objAuxVar[ 13 ]; - -/** Row vector of size: 6 */ -real_t objValueIn[ 6 ]; - -/** Row vector of size: 20 */ -real_t objValueOut[ 20 ]; - -/** Matrix of size: 60 x 3 (row major format) */ -real_t Q1[ 180 ]; - -/** Matrix of size: 60 x 4 (row major format) */ -real_t Q2[ 240 ]; - -/** Column vector of size: 20 */ -real_t R1[ 20 ]; - -/** Matrix of size: 20 x 4 (row major format) */ -real_t R2[ 80 ]; - -/** Column vector of size: 60 */ -real_t S1[ 60 ]; - -/** Matrix of size: 3 x 3 (row major format) */ -real_t QN1[ 9 ]; - -/** Matrix of size: 3 x 3 (row major format) */ -real_t QN2[ 9 ]; - -/** Column vector of size: 3 */ -real_t Dx0[ 3 ]; - -/** Matrix of size: 3 x 3 (row major format) */ -real_t T[ 9 ]; - -/** Column vector of size: 630 */ -real_t E[ 630 ]; - -/** Column vector of size: 630 */ -real_t QE[ 630 ]; - -/** Matrix of size: 60 x 3 (row major format) */ -real_t QGx[ 180 ]; - -/** Column vector of size: 60 */ -real_t Qd[ 60 ]; - -/** Column vector of size: 63 */ -real_t QDy[ 63 ]; - -/** Matrix of size: 20 x 3 (row major format) */ -real_t H10[ 60 ]; - -/** Matrix of size: 23 x 23 (row major format) */ -real_t H[ 529 ]; - -/** Matrix of size: 20 x 23 (row major format) */ -real_t A[ 460 ]; - -/** Column vector of size: 23 */ -real_t g[ 23 ]; - -/** Column vector of size: 23 */ -real_t lb[ 23 ]; - -/** Column vector of size: 23 */ -real_t ub[ 23 ]; - -/** Column vector of size: 20 */ -real_t lbA[ 20 ]; - -/** Column vector of size: 20 */ -real_t ubA[ 20 ]; - -/** Column vector of size: 23 */ -real_t x[ 23 ]; - -/** Column vector of size: 43 */ -real_t y[ 43 ]; - - -} 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/lib_mpc_export/acado_integrator.c b/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_integrator.c deleted file mode 100644 index a0bac9681c5293..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_integrator.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 + 15; - -/* Compute outputs: */ -out[0] = xd[1]; -out[1] = xd[2]; -out[2] = u[0]; -out[3] = xd[6]; -out[4] = xd[7]; -out[5] = xd[8]; -out[6] = xd[9]; -out[7] = xd[10]; -out[8] = xd[11]; -out[9] = (real_t)(0.0000000000000000e+00); -out[10] = (real_t)(0.0000000000000000e+00); -out[11] = (real_t)(0.0000000000000000e+00); -out[12] = xd[13]; -out[13] = xd[14]; -out[14] = (real_t)(1.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[3] = 1.0000000000000000e+00; -rk_eta[4] = 0.0000000000000000e+00; -rk_eta[5] = 0.0000000000000000e+00; -rk_eta[6] = 0.0000000000000000e+00; -rk_eta[7] = 1.0000000000000000e+00; -rk_eta[8] = 0.0000000000000000e+00; -rk_eta[9] = 0.0000000000000000e+00; -rk_eta[10] = 0.0000000000000000e+00; -rk_eta[11] = 1.0000000000000000e+00; -rk_eta[12] = 0.0000000000000000e+00; -rk_eta[13] = 0.0000000000000000e+00; -rk_eta[14] = 0.0000000000000000e+00; -acadoWorkspace.rk_xxx[15] = rk_eta[15]; -acadoWorkspace.rk_xxx[16] = rk_eta[16]; -acadoWorkspace.rk_xxx[17] = rk_eta[17]; - -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]; -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]; -acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 15 ]) ); -acadoWorkspace.rk_xxx[0] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[15] + rk_eta[0]; -acadoWorkspace.rk_xxx[1] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[16] + rk_eta[1]; -acadoWorkspace.rk_xxx[2] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[17] + rk_eta[2]; -acadoWorkspace.rk_xxx[3] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[18] + rk_eta[3]; -acadoWorkspace.rk_xxx[4] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[19] + rk_eta[4]; -acadoWorkspace.rk_xxx[5] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[20] + rk_eta[5]; -acadoWorkspace.rk_xxx[6] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[21] + rk_eta[6]; -acadoWorkspace.rk_xxx[7] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[22] + rk_eta[7]; -acadoWorkspace.rk_xxx[8] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[23] + rk_eta[8]; -acadoWorkspace.rk_xxx[9] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[24] + rk_eta[9]; -acadoWorkspace.rk_xxx[10] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[25] + rk_eta[10]; -acadoWorkspace.rk_xxx[11] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[26] + rk_eta[11]; -acadoWorkspace.rk_xxx[12] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[27] + rk_eta[12]; -acadoWorkspace.rk_xxx[13] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[28] + rk_eta[13]; -acadoWorkspace.rk_xxx[14] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[29] + rk_eta[14]; -acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 30 ]) ); -acadoWorkspace.rk_xxx[0] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[30] + rk_eta[0]; -acadoWorkspace.rk_xxx[1] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[31] + rk_eta[1]; -acadoWorkspace.rk_xxx[2] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[32] + rk_eta[2]; -acadoWorkspace.rk_xxx[3] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[33] + rk_eta[3]; -acadoWorkspace.rk_xxx[4] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[34] + rk_eta[4]; -acadoWorkspace.rk_xxx[5] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[35] + rk_eta[5]; -acadoWorkspace.rk_xxx[6] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[36] + rk_eta[6]; -acadoWorkspace.rk_xxx[7] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[37] + rk_eta[7]; -acadoWorkspace.rk_xxx[8] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[38] + rk_eta[8]; -acadoWorkspace.rk_xxx[9] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[39] + rk_eta[9]; -acadoWorkspace.rk_xxx[10] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[40] + rk_eta[10]; -acadoWorkspace.rk_xxx[11] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[41] + rk_eta[11]; -acadoWorkspace.rk_xxx[12] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[42] + rk_eta[12]; -acadoWorkspace.rk_xxx[13] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[43] + rk_eta[13]; -acadoWorkspace.rk_xxx[14] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[44] + rk_eta[14]; -acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 45 ]) ); -rk_eta[0] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[0] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[15] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[30] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[45]; -rk_eta[1] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[1] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[16] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[31] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[46]; -rk_eta[2] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[2] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[17] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[32] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[47]; -rk_eta[3] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[3] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[18] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[33] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[48]; -rk_eta[4] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[4] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[19] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[34] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[49]; -rk_eta[5] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[5] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[20] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[35] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[50]; -rk_eta[6] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[6] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[21] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[36] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[51]; -rk_eta[7] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[7] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[22] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[37] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[52]; -rk_eta[8] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[8] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[23] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[38] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[53]; -rk_eta[9] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[9] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[24] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[39] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[54]; -rk_eta[10] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[10] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[25] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[40] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[55]; -rk_eta[11] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[11] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[26] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[41] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[56]; -rk_eta[12] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[12] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[27] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[42] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[57]; -rk_eta[13] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[13] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[28] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[43] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[58]; -rk_eta[14] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[14] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[29] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[44] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[59]; -acadoWorkspace.rk_ttt += 1.0000000000000000e+00; -} -} -error = 0; -return error; -} - diff --git a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_qpoases_interface.cpp b/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_qpoases_interface.cpp deleted file mode 100644 index 36e675e03aa07c..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_qpoases_interface.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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/QProblem.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; - - QProblem qp(23, 20); - - returnValue retVal = qp.init(acadoWorkspace.H, acadoWorkspace.g, acadoWorkspace.A, acadoWorkspace.lb, acadoWorkspace.ub, acadoWorkspace.lbA, acadoWorkspace.ubA, 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/lib_mpc_export/acado_qpoases_interface.hpp b/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_qpoases_interface.hpp deleted file mode 100644 index 8a58805f8e6d29..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_qpoases_interface.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 23 -/** Maximum number of constraints. */ -#define QPOASES_NCMAX 20 -/** 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/lib_mpc_export/acado_solver.c b/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_solver.c deleted file mode 100644 index 8cfc06f3b8ef70..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/acado_solver.c +++ /dev/null @@ -1,4782 +0,0 @@ -/* - * 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 * 3]; -acadoWorkspace.state[1] = acadoVariables.x[lRun1 * 3 + 1]; -acadoWorkspace.state[2] = acadoVariables.x[lRun1 * 3 + 2]; - -acadoWorkspace.state[15] = acadoVariables.u[lRun1]; -acadoWorkspace.state[16] = acadoVariables.od[lRun1 * 2]; -acadoWorkspace.state[17] = acadoVariables.od[lRun1 * 2 + 1]; - -ret = acado_integrate(acadoWorkspace.state, 1, lRun1); - -acadoWorkspace.d[lRun1 * 3] = acadoWorkspace.state[0] - acadoVariables.x[lRun1 * 3 + 3]; -acadoWorkspace.d[lRun1 * 3 + 1] = acadoWorkspace.state[1] - acadoVariables.x[lRun1 * 3 + 4]; -acadoWorkspace.d[lRun1 * 3 + 2] = acadoWorkspace.state[2] - acadoVariables.x[lRun1 * 3 + 5]; - -acadoWorkspace.evGx[lRun1 * 9] = acadoWorkspace.state[3]; -acadoWorkspace.evGx[lRun1 * 9 + 1] = acadoWorkspace.state[4]; -acadoWorkspace.evGx[lRun1 * 9 + 2] = acadoWorkspace.state[5]; -acadoWorkspace.evGx[lRun1 * 9 + 3] = acadoWorkspace.state[6]; -acadoWorkspace.evGx[lRun1 * 9 + 4] = acadoWorkspace.state[7]; -acadoWorkspace.evGx[lRun1 * 9 + 5] = acadoWorkspace.state[8]; -acadoWorkspace.evGx[lRun1 * 9 + 6] = acadoWorkspace.state[9]; -acadoWorkspace.evGx[lRun1 * 9 + 7] = acadoWorkspace.state[10]; -acadoWorkspace.evGx[lRun1 * 9 + 8] = acadoWorkspace.state[11]; - -acadoWorkspace.evGu[lRun1 * 3] = acadoWorkspace.state[12]; -acadoWorkspace.evGu[lRun1 * 3 + 1] = acadoWorkspace.state[13]; -acadoWorkspace.evGu[lRun1 * 3 + 2] = acadoWorkspace.state[14]; -} -return ret; -} - -void acado_evaluateLSQ(const real_t* in, real_t* out) -{ -const real_t* xd = in; -const real_t* u = in + 3; -const real_t* od = in + 4; -/* Vector of auxiliary variables; number of elements: 13. */ -real_t* a = acadoWorkspace.objAuxVar; - -/* Compute intermediate quantities: */ -a[0] = (sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); -a[1] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); -a[2] = ((real_t)(1.0000000000000000e+00)/(a[0]+(real_t)(1.0000000000000001e-01))); -a[3] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); -a[4] = (((real_t)(2.9999999999999999e-01)*(((real_t)(0.0000000000000000e+00)-((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)))*a[2]))*a[3]); -a[5] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); -a[6] = (1.0/sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); -a[7] = (a[6]*(real_t)(5.0000000000000000e-01)); -a[8] = (a[2]*a[2]); -a[9] = (((real_t)(2.9999999999999999e-01)*(((((real_t)(1.8000000000000000e+00)-((real_t)(-1.8000000000000000e+00)))+((xd[1]+xd[1])*a[5]))*a[2])-((((((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))*a[7])*a[8])))*a[3]); -a[10] = ((real_t)(1.0000000000000000e+00)/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); -a[11] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); -a[12] = (a[10]*a[10]); - -/* Compute outputs: */ -out[0] = (a[1]-(real_t)(1.0000000000000000e+00)); -out[1] = (((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); -out[2] = (xd[2]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); -out[3] = (u[0]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); -out[4] = a[4]; -out[5] = a[9]; -out[6] = (real_t)(0.0000000000000000e+00); -out[7] = (((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00))*a[10]); -out[8] = ((((real_t)(0.0000000000000000e+00)-(((real_t)(1.8000000000000000e+00)-((real_t)(-1.8000000000000000e+00)))+((xd[1]+xd[1])*a[11])))*a[10])-((((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))*(real_t)(5.0000000000000003e-02))*a[12])); -out[9] = (real_t)(0.0000000000000000e+00); -out[10] = (real_t)(0.0000000000000000e+00); -out[11] = (xd[2]*(real_t)(1.0000000000000001e-01)); -out[12] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00)); -out[13] = (real_t)(0.0000000000000000e+00); -out[14] = (u[0]*(real_t)(1.0000000000000001e-01)); -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)(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 + 3; -/* Vector of auxiliary variables; number of elements: 13. */ -real_t* a = acadoWorkspace.objAuxVar; - -/* Compute intermediate quantities: */ -a[0] = (sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); -a[1] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); -a[2] = ((real_t)(1.0000000000000000e+00)/(a[0]+(real_t)(1.0000000000000001e-01))); -a[3] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); -a[4] = (((real_t)(2.9999999999999999e-01)*(((real_t)(0.0000000000000000e+00)-((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)))*a[2]))*a[3]); -a[5] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); -a[6] = (1.0/sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); -a[7] = (a[6]*(real_t)(5.0000000000000000e-01)); -a[8] = (a[2]*a[2]); -a[9] = (((real_t)(2.9999999999999999e-01)*(((((real_t)(1.8000000000000000e+00)-((real_t)(-1.8000000000000000e+00)))+((xd[1]+xd[1])*a[5]))*a[2])-((((((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))*a[7])*a[8])))*a[3]); -a[10] = ((real_t)(1.0000000000000000e+00)/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); -a[11] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); -a[12] = (a[10]*a[10]); - -/* Compute outputs: */ -out[0] = (a[1]-(real_t)(1.0000000000000000e+00)); -out[1] = (((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); -out[2] = (xd[2]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); -out[3] = a[4]; -out[4] = a[9]; -out[5] = (real_t)(0.0000000000000000e+00); -out[6] = (((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00))*a[10]); -out[7] = ((((real_t)(0.0000000000000000e+00)-(((real_t)(1.8000000000000000e+00)-((real_t)(-1.8000000000000000e+00)))+((xd[1]+xd[1])*a[11])))*a[10])-((((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(1.8000000000000000e+00))-((od[1]-xd[1])*(real_t)(1.8000000000000000e+00)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))*(real_t)(5.0000000000000003e-02))*a[12])); -out[8] = (real_t)(0.0000000000000000e+00); -out[9] = (real_t)(0.0000000000000000e+00); -out[10] = (xd[2]*(real_t)(1.0000000000000001e-01)); -out[11] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.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[3]*tmpObjS[4] + tmpFx[6]*tmpObjS[8] + tmpFx[9]*tmpObjS[12]; -tmpQ2[1] = + tmpFx[0]*tmpObjS[1] + tmpFx[3]*tmpObjS[5] + tmpFx[6]*tmpObjS[9] + tmpFx[9]*tmpObjS[13]; -tmpQ2[2] = + tmpFx[0]*tmpObjS[2] + tmpFx[3]*tmpObjS[6] + tmpFx[6]*tmpObjS[10] + tmpFx[9]*tmpObjS[14]; -tmpQ2[3] = + tmpFx[0]*tmpObjS[3] + tmpFx[3]*tmpObjS[7] + tmpFx[6]*tmpObjS[11] + tmpFx[9]*tmpObjS[15]; -tmpQ2[4] = + tmpFx[1]*tmpObjS[0] + tmpFx[4]*tmpObjS[4] + tmpFx[7]*tmpObjS[8] + tmpFx[10]*tmpObjS[12]; -tmpQ2[5] = + tmpFx[1]*tmpObjS[1] + tmpFx[4]*tmpObjS[5] + tmpFx[7]*tmpObjS[9] + tmpFx[10]*tmpObjS[13]; -tmpQ2[6] = + tmpFx[1]*tmpObjS[2] + tmpFx[4]*tmpObjS[6] + tmpFx[7]*tmpObjS[10] + tmpFx[10]*tmpObjS[14]; -tmpQ2[7] = + tmpFx[1]*tmpObjS[3] + tmpFx[4]*tmpObjS[7] + tmpFx[7]*tmpObjS[11] + tmpFx[10]*tmpObjS[15]; -tmpQ2[8] = + tmpFx[2]*tmpObjS[0] + tmpFx[5]*tmpObjS[4] + tmpFx[8]*tmpObjS[8] + tmpFx[11]*tmpObjS[12]; -tmpQ2[9] = + tmpFx[2]*tmpObjS[1] + tmpFx[5]*tmpObjS[5] + tmpFx[8]*tmpObjS[9] + tmpFx[11]*tmpObjS[13]; -tmpQ2[10] = + tmpFx[2]*tmpObjS[2] + tmpFx[5]*tmpObjS[6] + tmpFx[8]*tmpObjS[10] + tmpFx[11]*tmpObjS[14]; -tmpQ2[11] = + tmpFx[2]*tmpObjS[3] + tmpFx[5]*tmpObjS[7] + tmpFx[8]*tmpObjS[11] + tmpFx[11]*tmpObjS[15]; -tmpQ1[0] = + tmpQ2[0]*tmpFx[0] + tmpQ2[1]*tmpFx[3] + tmpQ2[2]*tmpFx[6] + tmpQ2[3]*tmpFx[9]; -tmpQ1[1] = + tmpQ2[0]*tmpFx[1] + tmpQ2[1]*tmpFx[4] + tmpQ2[2]*tmpFx[7] + tmpQ2[3]*tmpFx[10]; -tmpQ1[2] = + tmpQ2[0]*tmpFx[2] + tmpQ2[1]*tmpFx[5] + tmpQ2[2]*tmpFx[8] + tmpQ2[3]*tmpFx[11]; -tmpQ1[3] = + tmpQ2[4]*tmpFx[0] + tmpQ2[5]*tmpFx[3] + tmpQ2[6]*tmpFx[6] + tmpQ2[7]*tmpFx[9]; -tmpQ1[4] = + tmpQ2[4]*tmpFx[1] + tmpQ2[5]*tmpFx[4] + tmpQ2[6]*tmpFx[7] + tmpQ2[7]*tmpFx[10]; -tmpQ1[5] = + tmpQ2[4]*tmpFx[2] + tmpQ2[5]*tmpFx[5] + tmpQ2[6]*tmpFx[8] + tmpQ2[7]*tmpFx[11]; -tmpQ1[6] = + tmpQ2[8]*tmpFx[0] + tmpQ2[9]*tmpFx[3] + tmpQ2[10]*tmpFx[6] + tmpQ2[11]*tmpFx[9]; -tmpQ1[7] = + tmpQ2[8]*tmpFx[1] + tmpQ2[9]*tmpFx[4] + tmpQ2[10]*tmpFx[7] + tmpQ2[11]*tmpFx[10]; -tmpQ1[8] = + tmpQ2[8]*tmpFx[2] + tmpQ2[9]*tmpFx[5] + tmpQ2[10]*tmpFx[8] + tmpQ2[11]*tmpFx[11]; -} - -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[4] + tmpFu[2]*tmpObjS[8] + tmpFu[3]*tmpObjS[12]; -tmpR2[1] = + tmpFu[0]*tmpObjS[1] + tmpFu[1]*tmpObjS[5] + tmpFu[2]*tmpObjS[9] + tmpFu[3]*tmpObjS[13]; -tmpR2[2] = + tmpFu[0]*tmpObjS[2] + tmpFu[1]*tmpObjS[6] + tmpFu[2]*tmpObjS[10] + tmpFu[3]*tmpObjS[14]; -tmpR2[3] = + tmpFu[0]*tmpObjS[3] + tmpFu[1]*tmpObjS[7] + tmpFu[2]*tmpObjS[11] + tmpFu[3]*tmpObjS[15]; -tmpR1[0] = + tmpR2[0]*tmpFu[0] + tmpR2[1]*tmpFu[1] + tmpR2[2]*tmpFu[2] + tmpR2[3]*tmpFu[3]; -} - -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[3]*tmpObjSEndTerm[3] + tmpFx[6]*tmpObjSEndTerm[6]; -tmpQN2[1] = + tmpFx[0]*tmpObjSEndTerm[1] + tmpFx[3]*tmpObjSEndTerm[4] + tmpFx[6]*tmpObjSEndTerm[7]; -tmpQN2[2] = + tmpFx[0]*tmpObjSEndTerm[2] + tmpFx[3]*tmpObjSEndTerm[5] + tmpFx[6]*tmpObjSEndTerm[8]; -tmpQN2[3] = + tmpFx[1]*tmpObjSEndTerm[0] + tmpFx[4]*tmpObjSEndTerm[3] + tmpFx[7]*tmpObjSEndTerm[6]; -tmpQN2[4] = + tmpFx[1]*tmpObjSEndTerm[1] + tmpFx[4]*tmpObjSEndTerm[4] + tmpFx[7]*tmpObjSEndTerm[7]; -tmpQN2[5] = + tmpFx[1]*tmpObjSEndTerm[2] + tmpFx[4]*tmpObjSEndTerm[5] + tmpFx[7]*tmpObjSEndTerm[8]; -tmpQN2[6] = + tmpFx[2]*tmpObjSEndTerm[0] + tmpFx[5]*tmpObjSEndTerm[3] + tmpFx[8]*tmpObjSEndTerm[6]; -tmpQN2[7] = + tmpFx[2]*tmpObjSEndTerm[1] + tmpFx[5]*tmpObjSEndTerm[4] + tmpFx[8]*tmpObjSEndTerm[7]; -tmpQN2[8] = + tmpFx[2]*tmpObjSEndTerm[2] + tmpFx[5]*tmpObjSEndTerm[5] + tmpFx[8]*tmpObjSEndTerm[8]; -tmpQN1[0] = + tmpQN2[0]*tmpFx[0] + tmpQN2[1]*tmpFx[3] + tmpQN2[2]*tmpFx[6]; -tmpQN1[1] = + tmpQN2[0]*tmpFx[1] + tmpQN2[1]*tmpFx[4] + tmpQN2[2]*tmpFx[7]; -tmpQN1[2] = + tmpQN2[0]*tmpFx[2] + tmpQN2[1]*tmpFx[5] + tmpQN2[2]*tmpFx[8]; -tmpQN1[3] = + tmpQN2[3]*tmpFx[0] + tmpQN2[4]*tmpFx[3] + tmpQN2[5]*tmpFx[6]; -tmpQN1[4] = + tmpQN2[3]*tmpFx[1] + tmpQN2[4]*tmpFx[4] + tmpQN2[5]*tmpFx[7]; -tmpQN1[5] = + tmpQN2[3]*tmpFx[2] + tmpQN2[4]*tmpFx[5] + tmpQN2[5]*tmpFx[8]; -tmpQN1[6] = + tmpQN2[6]*tmpFx[0] + tmpQN2[7]*tmpFx[3] + tmpQN2[8]*tmpFx[6]; -tmpQN1[7] = + tmpQN2[6]*tmpFx[1] + tmpQN2[7]*tmpFx[4] + tmpQN2[8]*tmpFx[7]; -tmpQN1[8] = + tmpQN2[6]*tmpFx[2] + tmpQN2[7]*tmpFx[5] + tmpQN2[8]*tmpFx[8]; -} - -void acado_evaluateObjective( ) -{ -int runObj; -for (runObj = 0; runObj < 20; ++runObj) -{ -acadoWorkspace.objValueIn[0] = acadoVariables.x[runObj * 3]; -acadoWorkspace.objValueIn[1] = acadoVariables.x[runObj * 3 + 1]; -acadoWorkspace.objValueIn[2] = acadoVariables.x[runObj * 3 + 2]; -acadoWorkspace.objValueIn[3] = acadoVariables.u[runObj]; -acadoWorkspace.objValueIn[4] = acadoVariables.od[runObj * 2]; -acadoWorkspace.objValueIn[5] = acadoVariables.od[runObj * 2 + 1]; - -acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); -acadoWorkspace.Dy[runObj * 4] = acadoWorkspace.objValueOut[0]; -acadoWorkspace.Dy[runObj * 4 + 1] = acadoWorkspace.objValueOut[1]; -acadoWorkspace.Dy[runObj * 4 + 2] = acadoWorkspace.objValueOut[2]; -acadoWorkspace.Dy[runObj * 4 + 3] = acadoWorkspace.objValueOut[3]; - -acado_setObjQ1Q2( &(acadoWorkspace.objValueOut[ 4 ]), &(acadoVariables.W[ runObj * 16 ]), &(acadoWorkspace.Q1[ runObj * 9 ]), &(acadoWorkspace.Q2[ runObj * 12 ]) ); - -acado_setObjR1R2( &(acadoWorkspace.objValueOut[ 16 ]), &(acadoVariables.W[ runObj * 16 ]), &(acadoWorkspace.R1[ runObj ]), &(acadoWorkspace.R2[ runObj * 4 ]) ); - -} -acadoWorkspace.objValueIn[0] = acadoVariables.x[60]; -acadoWorkspace.objValueIn[1] = acadoVariables.x[61]; -acadoWorkspace.objValueIn[2] = acadoVariables.x[62]; -acadoWorkspace.objValueIn[3] = acadoVariables.od[40]; -acadoWorkspace.objValueIn[4] = acadoVariables.od[41]; -acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); - -acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0]; -acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1]; -acadoWorkspace.DyN[2] = acadoWorkspace.objValueOut[2]; - -acado_setObjQN1QN2( &(acadoWorkspace.objValueOut[ 3 ]), 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]; -dNew[1] += + Gx1[3]*dOld[0] + Gx1[4]*dOld[1] + Gx1[5]*dOld[2]; -dNew[2] += + Gx1[6]*dOld[0] + Gx1[7]*dOld[1] + Gx1[8]*dOld[2]; -} - -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]; -} - -void acado_multGxGx( real_t* const Gx1, real_t* const Gx2, real_t* const Gx3 ) -{ -Gx3[0] = + Gx1[0]*Gx2[0] + Gx1[1]*Gx2[3] + Gx1[2]*Gx2[6]; -Gx3[1] = + Gx1[0]*Gx2[1] + Gx1[1]*Gx2[4] + Gx1[2]*Gx2[7]; -Gx3[2] = + Gx1[0]*Gx2[2] + Gx1[1]*Gx2[5] + Gx1[2]*Gx2[8]; -Gx3[3] = + Gx1[3]*Gx2[0] + Gx1[4]*Gx2[3] + Gx1[5]*Gx2[6]; -Gx3[4] = + Gx1[3]*Gx2[1] + Gx1[4]*Gx2[4] + Gx1[5]*Gx2[7]; -Gx3[5] = + Gx1[3]*Gx2[2] + Gx1[4]*Gx2[5] + Gx1[5]*Gx2[8]; -Gx3[6] = + Gx1[6]*Gx2[0] + Gx1[7]*Gx2[3] + Gx1[8]*Gx2[6]; -Gx3[7] = + Gx1[6]*Gx2[1] + Gx1[7]*Gx2[4] + Gx1[8]*Gx2[7]; -Gx3[8] = + Gx1[6]*Gx2[2] + Gx1[7]*Gx2[5] + Gx1[8]*Gx2[8]; -} - -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]; -Gu2[1] = + Gx1[3]*Gu1[0] + Gx1[4]*Gu1[1] + Gx1[5]*Gu1[2]; -Gu2[2] = + Gx1[6]*Gu1[0] + Gx1[7]*Gu1[1] + Gx1[8]*Gu1[2]; -} - -void acado_moveGuE( real_t* const Gu1, real_t* const Gu2 ) -{ -Gu2[0] = Gu1[0]; -Gu2[1] = Gu1[1]; -Gu2[2] = Gu1[2]; -} - -void acado_setBlockH11( int iRow, int iCol, real_t* const Gu1, real_t* const Gu2 ) -{ -acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] += + Gu1[0]*Gu2[0] + Gu1[1]*Gu2[1] + Gu1[2]*Gu2[2]; -} - -void acado_setBlockH11_R1( int iRow, int iCol, real_t* const R11 ) -{ -acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] = R11[0]; -} - -void acado_zeroBlockH11( int iRow, int iCol ) -{ -acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] = 0.0000000000000000e+00; -} - -void acado_copyHTH( int iRow, int iCol ) -{ -acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] = acadoWorkspace.H[(iCol * 23 + 69) + (iRow + 3)]; -} - -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]; -dNew[1] = + Gx1[3]*dOld[0] + Gx1[4]*dOld[1] + Gx1[5]*dOld[2]; -dNew[2] = + Gx1[6]*dOld[0] + Gx1[7]*dOld[1] + Gx1[8]*dOld[2]; -} - -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]; -dNew[1] = + acadoWorkspace.QN1[3]*dOld[0] + acadoWorkspace.QN1[4]*dOld[1] + acadoWorkspace.QN1[5]*dOld[2]; -dNew[2] = + acadoWorkspace.QN1[6]*dOld[0] + acadoWorkspace.QN1[7]*dOld[1] + acadoWorkspace.QN1[8]*dOld[2]; -} - -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]; -} - -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]; -QDy1[1] = + Q2[4]*Dy1[0] + Q2[5]*Dy1[1] + Q2[6]*Dy1[2] + Q2[7]*Dy1[3]; -QDy1[2] = + Q2[8]*Dy1[0] + Q2[9]*Dy1[1] + Q2[10]*Dy1[2] + Q2[11]*Dy1[3]; -} - -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]; -} - -void acado_multQETGx( real_t* const E1, real_t* const Gx1, real_t* const H101 ) -{ -H101[0] += + E1[0]*Gx1[0] + E1[1]*Gx1[3] + E1[2]*Gx1[6]; -H101[1] += + E1[0]*Gx1[1] + E1[1]*Gx1[4] + E1[2]*Gx1[7]; -H101[2] += + E1[0]*Gx1[2] + E1[1]*Gx1[5] + E1[2]*Gx1[8]; -} - -void acado_zeroBlockH10( real_t* const H101 ) -{ -{ int lCopy; for (lCopy = 0; lCopy < 3; 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]; -} - -void acado_zeroBlockH00( ) -{ -acadoWorkspace.H[0] = 0.0000000000000000e+00; -acadoWorkspace.H[1] = 0.0000000000000000e+00; -acadoWorkspace.H[2] = 0.0000000000000000e+00; -acadoWorkspace.H[23] = 0.0000000000000000e+00; -acadoWorkspace.H[24] = 0.0000000000000000e+00; -acadoWorkspace.H[25] = 0.0000000000000000e+00; -acadoWorkspace.H[46] = 0.0000000000000000e+00; -acadoWorkspace.H[47] = 0.0000000000000000e+00; -acadoWorkspace.H[48] = 0.0000000000000000e+00; -} - -void acado_multCTQC( real_t* const Gx1, real_t* const Gx2 ) -{ -acadoWorkspace.H[0] += + Gx1[0]*Gx2[0] + Gx1[3]*Gx2[3] + Gx1[6]*Gx2[6]; -acadoWorkspace.H[1] += + Gx1[0]*Gx2[1] + Gx1[3]*Gx2[4] + Gx1[6]*Gx2[7]; -acadoWorkspace.H[2] += + Gx1[0]*Gx2[2] + Gx1[3]*Gx2[5] + Gx1[6]*Gx2[8]; -acadoWorkspace.H[23] += + Gx1[1]*Gx2[0] + Gx1[4]*Gx2[3] + Gx1[7]*Gx2[6]; -acadoWorkspace.H[24] += + Gx1[1]*Gx2[1] + Gx1[4]*Gx2[4] + Gx1[7]*Gx2[7]; -acadoWorkspace.H[25] += + Gx1[1]*Gx2[2] + Gx1[4]*Gx2[5] + Gx1[7]*Gx2[8]; -acadoWorkspace.H[46] += + Gx1[2]*Gx2[0] + Gx1[5]*Gx2[3] + Gx1[8]*Gx2[6]; -acadoWorkspace.H[47] += + Gx1[2]*Gx2[1] + Gx1[5]*Gx2[4] + Gx1[8]*Gx2[7]; -acadoWorkspace.H[48] += + Gx1[2]*Gx2[2] + Gx1[5]*Gx2[5] + Gx1[8]*Gx2[8]; -} - -void acado_macCTSlx( real_t* const C0, real_t* const g0 ) -{ -g0[0] += 0.0; -; -g0[1] += 0.0; -; -g0[2] += 0.0; -; -} - -void acado_macETSlu( real_t* const E0, real_t* const g1 ) -{ -g1[0] += 0.0; -; -} - -void acado_condensePrep( ) -{ -int lRun1; -int lRun2; -int lRun3; -int lRun4; -int lRun5; -/** Row vector of size: 20 */ -static const int xBoundIndices[ 20 ] = -{ 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61 }; -acado_moveGuE( acadoWorkspace.evGu, acadoWorkspace.E ); -acado_moveGxT( &(acadoWorkspace.evGx[ 9 ]), acadoWorkspace.T ); -acado_multGxd( acadoWorkspace.d, &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.d[ 3 ]) ); -acado_multGxGx( acadoWorkspace.T, acadoWorkspace.evGx, &(acadoWorkspace.evGx[ 9 ]) ); - -acado_multGxGu( acadoWorkspace.T, acadoWorkspace.E, &(acadoWorkspace.E[ 3 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 3 ]), &(acadoWorkspace.E[ 6 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 18 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 3 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.d[ 6 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.evGx[ 18 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.E[ 9 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.E[ 12 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 6 ]), &(acadoWorkspace.E[ 15 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 27 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 6 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.d[ 9 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.evGx[ 27 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.E[ 18 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.E[ 21 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.E[ 24 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 9 ]), &(acadoWorkspace.E[ 27 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 36 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 9 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.d[ 12 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.evGx[ 36 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.E[ 30 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.E[ 33 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.E[ 36 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.E[ 39 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 12 ]), &(acadoWorkspace.E[ 42 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 45 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.d[ 15 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.evGx[ 45 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.E[ 45 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.E[ 48 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.E[ 51 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.E[ 54 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.E[ 57 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 15 ]), &(acadoWorkspace.E[ 60 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 54 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 15 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.d[ 18 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.evGx[ 54 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.E[ 63 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.E[ 66 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.E[ 69 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.E[ 72 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.E[ 75 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.E[ 78 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 18 ]), &(acadoWorkspace.E[ 81 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 63 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 18 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.d[ 21 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.evGx[ 63 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.E[ 84 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.E[ 87 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.E[ 90 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.E[ 93 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.E[ 96 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.E[ 99 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.E[ 102 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 21 ]), &(acadoWorkspace.E[ 105 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 72 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 21 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.d[ 24 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.evGx[ 72 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.E[ 108 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.E[ 111 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.E[ 114 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.E[ 117 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.E[ 120 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.E[ 123 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.E[ 126 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.E[ 129 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 24 ]), &(acadoWorkspace.E[ 132 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 81 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.d[ 27 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.evGx[ 81 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.E[ 135 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.E[ 138 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.E[ 141 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.E[ 144 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.E[ 147 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.E[ 150 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.E[ 153 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.E[ 156 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.E[ 159 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 27 ]), &(acadoWorkspace.E[ 162 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 90 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 27 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.d[ 30 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.evGx[ 90 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.E[ 165 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.E[ 168 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.E[ 171 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.E[ 174 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.E[ 177 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.E[ 180 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.E[ 183 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.E[ 186 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.E[ 189 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.E[ 192 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 30 ]), &(acadoWorkspace.E[ 195 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 99 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 30 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.d[ 33 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.evGx[ 99 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.E[ 198 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.E[ 201 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.E[ 204 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.E[ 207 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.E[ 210 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.E[ 213 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.E[ 216 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.E[ 219 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.E[ 222 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.E[ 225 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.E[ 228 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 33 ]), &(acadoWorkspace.E[ 231 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 108 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 33 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.d[ 36 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.evGx[ 108 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.E[ 234 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.E[ 237 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.E[ 240 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.E[ 243 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.E[ 246 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.E[ 249 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.E[ 252 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.E[ 255 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.E[ 258 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.E[ 261 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.E[ 264 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.E[ 267 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 36 ]), &(acadoWorkspace.E[ 270 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 117 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.d[ 39 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.evGx[ 117 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.E[ 273 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.E[ 276 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.E[ 279 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.E[ 282 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.E[ 285 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.E[ 288 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.E[ 291 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.E[ 294 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.E[ 297 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.E[ 300 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.E[ 303 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.E[ 306 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.E[ 309 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 39 ]), &(acadoWorkspace.E[ 312 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 126 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 39 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.d[ 42 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.evGx[ 126 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.E[ 315 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.E[ 318 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.E[ 321 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.E[ 324 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.E[ 327 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.E[ 330 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.E[ 333 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.E[ 336 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.E[ 339 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.E[ 342 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.E[ 345 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.E[ 348 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.E[ 351 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.E[ 354 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 42 ]), &(acadoWorkspace.E[ 357 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 135 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 42 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.d[ 45 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.evGx[ 135 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.E[ 360 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.E[ 363 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.E[ 366 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.E[ 369 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.E[ 372 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.E[ 375 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.E[ 378 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.E[ 381 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.E[ 384 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.E[ 387 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.E[ 390 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.E[ 393 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.E[ 396 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.E[ 399 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.E[ 402 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 45 ]), &(acadoWorkspace.E[ 405 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 45 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.d[ 48 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.evGx[ 144 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.E[ 408 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.E[ 411 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.E[ 414 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.E[ 417 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.E[ 420 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.E[ 423 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.E[ 426 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.E[ 429 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.E[ 432 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.E[ 435 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.E[ 438 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.E[ 441 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.E[ 444 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.E[ 447 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.E[ 450 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.E[ 453 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 48 ]), &(acadoWorkspace.E[ 456 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 153 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.d[ 51 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.evGx[ 153 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.E[ 459 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.E[ 462 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.E[ 465 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.E[ 468 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.E[ 471 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.E[ 474 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.E[ 477 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.E[ 480 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.E[ 483 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.E[ 486 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.E[ 489 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.E[ 492 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.E[ 495 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.E[ 498 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.E[ 501 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.E[ 504 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.E[ 507 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 51 ]), &(acadoWorkspace.E[ 510 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 162 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 51 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.d[ 54 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.evGx[ 162 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.E[ 513 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.E[ 516 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.E[ 519 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.E[ 522 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.E[ 525 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.E[ 528 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.E[ 531 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.E[ 534 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.E[ 537 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.E[ 540 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.E[ 543 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.E[ 546 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.E[ 549 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.E[ 552 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.E[ 555 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.E[ 558 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.E[ 561 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.E[ 564 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 54 ]), &(acadoWorkspace.E[ 567 ]) ); - -acado_moveGxT( &(acadoWorkspace.evGx[ 171 ]), acadoWorkspace.T ); -acado_multGxd( &(acadoWorkspace.d[ 54 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.d[ 57 ]) ); -acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.evGx[ 171 ]) ); - -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.E[ 570 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.E[ 573 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.E[ 576 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.E[ 579 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.E[ 582 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.E[ 585 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.E[ 588 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.E[ 591 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.E[ 594 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.E[ 597 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.E[ 600 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.E[ 603 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.E[ 606 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.E[ 609 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.E[ 612 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.E[ 615 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.E[ 618 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.E[ 621 ]) ); -acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.E[ 624 ]) ); - -acado_moveGuE( &(acadoWorkspace.evGu[ 57 ]), &(acadoWorkspace.E[ 627 ]) ); - -acado_multGxGx( &(acadoWorkspace.Q1[ 9 ]), acadoWorkspace.evGx, acadoWorkspace.QGx ); -acado_multGxGx( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.QGx[ 9 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.QGx[ 18 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.QGx[ 27 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.QGx[ 36 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.QGx[ 45 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.QGx[ 54 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.QGx[ 63 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.QGx[ 72 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.QGx[ 81 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.QGx[ 90 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.QGx[ 99 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.QGx[ 108 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.QGx[ 117 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.QGx[ 126 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.QGx[ 135 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.QGx[ 153 ]) ); -acado_multGxGx( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.QGx[ 162 ]) ); -acado_multGxGx( acadoWorkspace.QN1, &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.QGx[ 171 ]) ); - -acado_multGxGu( &(acadoWorkspace.Q1[ 9 ]), acadoWorkspace.E, acadoWorkspace.QE ); -acado_multGxGu( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QE[ 3 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.QE[ 6 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 9 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.QE[ 15 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 18 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 21 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.QE[ 27 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 30 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 33 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QE[ 39 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.QE[ 42 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 45 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 51 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 54 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QE[ 57 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 63 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 66 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 69 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 75 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QE[ 78 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 87 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 90 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 93 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 99 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 111 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 114 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 117 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 123 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 135 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 138 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 141 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 147 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 150 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 165 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 171 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 174 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 177 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 198 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 201 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 207 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 210 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 213 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 234 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 237 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 243 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 246 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 249 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 273 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 279 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 282 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 285 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 315 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 318 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 321 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 327 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 330 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 363 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 366 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 369 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 375 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 411 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 414 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 417 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 423 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 459 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 462 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 465 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 471 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 474 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 513 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 519 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 522 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 525 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 570 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 573 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 576 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 579 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 582 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 585 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 588 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 591 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 594 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 597 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 600 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 603 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 606 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 609 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 612 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 615 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 618 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 621 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 624 ]) ); -acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_zeroBlockH00( ); -acado_multCTQC( acadoWorkspace.evGx, acadoWorkspace.QGx ); -acado_multCTQC( &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.QGx[ 9 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.QGx[ 18 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.QGx[ 27 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.QGx[ 36 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.QGx[ 45 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.QGx[ 54 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.QGx[ 63 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.QGx[ 72 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.QGx[ 81 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.QGx[ 90 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.QGx[ 99 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.QGx[ 108 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.QGx[ 117 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.QGx[ 126 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.QGx[ 135 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.QGx[ 153 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.QGx[ 162 ]) ); -acado_multCTQC( &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.QGx[ 171 ]) ); - -acado_zeroBlockH10( acadoWorkspace.H10 ); -acado_multQETGx( acadoWorkspace.QE, acadoWorkspace.evGx, acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 3 ]), &(acadoWorkspace.evGx[ 9 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 9 ]), &(acadoWorkspace.evGx[ 18 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 18 ]), &(acadoWorkspace.evGx[ 27 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 30 ]), &(acadoWorkspace.evGx[ 36 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 45 ]), &(acadoWorkspace.evGx[ 45 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 63 ]), &(acadoWorkspace.evGx[ 54 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.evGx[ 63 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.evGx[ 72 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 135 ]), &(acadoWorkspace.evGx[ 81 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 165 ]), &(acadoWorkspace.evGx[ 90 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 198 ]), &(acadoWorkspace.evGx[ 99 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 234 ]), &(acadoWorkspace.evGx[ 108 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 273 ]), &(acadoWorkspace.evGx[ 117 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 315 ]), &(acadoWorkspace.evGx[ 126 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.evGx[ 135 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 459 ]), &(acadoWorkspace.evGx[ 153 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 513 ]), &(acadoWorkspace.evGx[ 162 ]), acadoWorkspace.H10 ); -acado_multQETGx( &(acadoWorkspace.QE[ 570 ]), &(acadoWorkspace.evGx[ 171 ]), acadoWorkspace.H10 ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 6 ]), &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 21 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 33 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 66 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 87 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 111 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 138 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 201 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 237 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 318 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 363 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 411 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 462 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 573 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 3 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 15 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 51 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 69 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 90 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 114 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 141 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 171 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 279 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 321 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 366 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 414 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 465 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 519 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 576 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 6 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 27 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 39 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 54 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 93 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 117 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 174 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 207 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 243 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 282 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 369 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 417 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 522 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 579 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 9 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 42 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 57 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 75 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 147 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 177 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 210 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 246 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 285 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 327 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 471 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 525 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 582 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 12 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 78 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 99 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 123 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 150 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 213 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 249 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 330 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 375 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 423 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 474 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 585 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 15 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 81 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 102 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 126 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 153 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 183 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 291 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 333 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 378 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 426 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 477 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 531 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 588 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 18 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 105 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 129 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 186 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 219 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 255 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 294 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 381 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 429 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 534 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 591 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 21 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 159 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 189 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 222 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 258 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 297 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 339 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 483 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 537 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 594 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 24 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 162 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 225 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 261 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 342 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 387 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 435 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 486 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 597 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 27 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 195 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 303 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 345 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 390 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 438 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 489 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 543 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 600 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 30 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 231 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 267 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 306 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 393 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 441 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 546 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 603 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 33 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 270 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 309 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 351 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 495 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 549 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 606 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 36 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 39 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 39 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 354 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 39 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 399 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 39 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 447 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 39 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 498 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 39 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 552 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 39 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 609 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 39 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 42 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 357 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 42 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 402 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 42 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 450 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 42 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 501 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 42 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 555 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 42 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 612 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 42 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 45 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 405 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 45 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 453 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 45 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 45 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 558 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 45 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 615 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 45 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 48 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 48 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 507 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 48 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 561 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 48 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 618 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 48 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 51 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 510 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 51 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 564 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 51 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 621 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 51 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 54 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 567 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 54 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 624 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 54 ]) ); -acado_zeroBlockH10( &(acadoWorkspace.H10[ 57 ]) ); -acado_multQETGx( &(acadoWorkspace.QE[ 627 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 57 ]) ); - -acadoWorkspace.H[3] = acadoWorkspace.H10[0]; -acadoWorkspace.H[4] = acadoWorkspace.H10[3]; -acadoWorkspace.H[5] = acadoWorkspace.H10[6]; -acadoWorkspace.H[6] = acadoWorkspace.H10[9]; -acadoWorkspace.H[7] = acadoWorkspace.H10[12]; -acadoWorkspace.H[8] = acadoWorkspace.H10[15]; -acadoWorkspace.H[9] = acadoWorkspace.H10[18]; -acadoWorkspace.H[10] = acadoWorkspace.H10[21]; -acadoWorkspace.H[11] = acadoWorkspace.H10[24]; -acadoWorkspace.H[12] = acadoWorkspace.H10[27]; -acadoWorkspace.H[13] = acadoWorkspace.H10[30]; -acadoWorkspace.H[14] = acadoWorkspace.H10[33]; -acadoWorkspace.H[15] = acadoWorkspace.H10[36]; -acadoWorkspace.H[16] = acadoWorkspace.H10[39]; -acadoWorkspace.H[17] = acadoWorkspace.H10[42]; -acadoWorkspace.H[18] = acadoWorkspace.H10[45]; -acadoWorkspace.H[19] = acadoWorkspace.H10[48]; -acadoWorkspace.H[20] = acadoWorkspace.H10[51]; -acadoWorkspace.H[21] = acadoWorkspace.H10[54]; -acadoWorkspace.H[22] = acadoWorkspace.H10[57]; -acadoWorkspace.H[26] = acadoWorkspace.H10[1]; -acadoWorkspace.H[27] = acadoWorkspace.H10[4]; -acadoWorkspace.H[28] = acadoWorkspace.H10[7]; -acadoWorkspace.H[29] = acadoWorkspace.H10[10]; -acadoWorkspace.H[30] = acadoWorkspace.H10[13]; -acadoWorkspace.H[31] = acadoWorkspace.H10[16]; -acadoWorkspace.H[32] = acadoWorkspace.H10[19]; -acadoWorkspace.H[33] = acadoWorkspace.H10[22]; -acadoWorkspace.H[34] = acadoWorkspace.H10[25]; -acadoWorkspace.H[35] = acadoWorkspace.H10[28]; -acadoWorkspace.H[36] = acadoWorkspace.H10[31]; -acadoWorkspace.H[37] = acadoWorkspace.H10[34]; -acadoWorkspace.H[38] = acadoWorkspace.H10[37]; -acadoWorkspace.H[39] = acadoWorkspace.H10[40]; -acadoWorkspace.H[40] = acadoWorkspace.H10[43]; -acadoWorkspace.H[41] = acadoWorkspace.H10[46]; -acadoWorkspace.H[42] = acadoWorkspace.H10[49]; -acadoWorkspace.H[43] = acadoWorkspace.H10[52]; -acadoWorkspace.H[44] = acadoWorkspace.H10[55]; -acadoWorkspace.H[45] = acadoWorkspace.H10[58]; -acadoWorkspace.H[49] = acadoWorkspace.H10[2]; -acadoWorkspace.H[50] = acadoWorkspace.H10[5]; -acadoWorkspace.H[51] = acadoWorkspace.H10[8]; -acadoWorkspace.H[52] = acadoWorkspace.H10[11]; -acadoWorkspace.H[53] = acadoWorkspace.H10[14]; -acadoWorkspace.H[54] = acadoWorkspace.H10[17]; -acadoWorkspace.H[55] = acadoWorkspace.H10[20]; -acadoWorkspace.H[56] = acadoWorkspace.H10[23]; -acadoWorkspace.H[57] = acadoWorkspace.H10[26]; -acadoWorkspace.H[58] = acadoWorkspace.H10[29]; -acadoWorkspace.H[59] = acadoWorkspace.H10[32]; -acadoWorkspace.H[60] = acadoWorkspace.H10[35]; -acadoWorkspace.H[61] = acadoWorkspace.H10[38]; -acadoWorkspace.H[62] = acadoWorkspace.H10[41]; -acadoWorkspace.H[63] = acadoWorkspace.H10[44]; -acadoWorkspace.H[64] = acadoWorkspace.H10[47]; -acadoWorkspace.H[65] = acadoWorkspace.H10[50]; -acadoWorkspace.H[66] = acadoWorkspace.H10[53]; -acadoWorkspace.H[67] = acadoWorkspace.H10[56]; -acadoWorkspace.H[68] = acadoWorkspace.H10[59]; - -acado_setBlockH11_R1( 0, 0, acadoWorkspace.R1 ); -acado_setBlockH11( 0, 0, acadoWorkspace.E, acadoWorkspace.QE ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QE[ 3 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 9 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 18 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 30 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 45 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 63 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 135 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 165 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 198 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 234 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 273 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 315 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 459 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 513 ]) ); -acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 570 ]) ); - -acado_zeroBlockH11( 0, 1 ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QE[ 6 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 12 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 21 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 33 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 48 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 66 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 87 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 111 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 138 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 168 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 201 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 237 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 276 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 318 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 363 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 411 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 462 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 516 ]) ); -acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 573 ]) ); - -acado_zeroBlockH11( 0, 2 ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 15 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 24 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 36 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 51 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 69 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 90 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 114 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 141 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 171 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 204 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 240 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 279 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 321 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 366 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 414 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 465 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 519 ]) ); -acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 576 ]) ); - -acado_zeroBlockH11( 0, 3 ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 27 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 39 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 54 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 72 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 93 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 117 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 144 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 174 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 207 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 243 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 282 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 324 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 369 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 417 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 468 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 522 ]) ); -acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 579 ]) ); - -acado_zeroBlockH11( 0, 4 ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 42 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 57 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 75 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 96 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 120 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 147 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 177 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 210 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 246 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 285 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 327 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 372 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 420 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 471 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 525 ]) ); -acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 582 ]) ); - -acado_zeroBlockH11( 0, 5 ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 60 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 78 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 99 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 123 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 150 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 180 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 213 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 249 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 288 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 330 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 375 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 423 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 474 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 528 ]) ); -acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 585 ]) ); - -acado_zeroBlockH11( 0, 6 ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 588 ]) ); - -acado_zeroBlockH11( 0, 7 ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 0, 8 ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 0, 9 ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 0, 10 ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 0, 11 ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 0, 12 ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 0, 13 ); -acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 0, 14 ); -acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 0, 15 ); -acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 0, 16 ); -acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 0, 17 ); -acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 0, 18 ); -acado_setBlockH11( 0, 18, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 0, 18, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 0, 19 ); -acado_setBlockH11( 0, 19, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 1, 1, &(acadoWorkspace.R1[ 1 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.QE[ 6 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 21 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 33 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 66 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 87 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 111 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 138 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 201 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 237 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 318 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 363 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 411 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 462 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); -acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 573 ]) ); - -acado_zeroBlockH11( 1, 2 ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 15 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 24 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 36 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 51 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 69 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 90 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 114 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 141 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 171 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 204 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 240 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 279 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 321 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 366 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 414 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 465 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 519 ]) ); -acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 576 ]) ); - -acado_zeroBlockH11( 1, 3 ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 27 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 39 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 54 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 72 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 93 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 117 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 144 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 174 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 207 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 243 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 282 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 324 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 369 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 417 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 468 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 522 ]) ); -acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 579 ]) ); - -acado_zeroBlockH11( 1, 4 ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 42 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 57 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 75 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 96 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 120 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 147 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 177 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 210 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 246 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 285 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 327 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 372 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 420 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 471 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 525 ]) ); -acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 582 ]) ); - -acado_zeroBlockH11( 1, 5 ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 60 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 78 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 99 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 123 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 150 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 180 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 213 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 249 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 288 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 330 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 375 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 423 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 474 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 528 ]) ); -acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 585 ]) ); - -acado_zeroBlockH11( 1, 6 ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 588 ]) ); - -acado_zeroBlockH11( 1, 7 ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 1, 8 ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 1, 9 ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 1, 10 ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 1, 11 ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 1, 12 ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 1, 13 ); -acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 1, 14 ); -acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 1, 15 ); -acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 1, 16 ); -acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 1, 17 ); -acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 1, 18 ); -acado_setBlockH11( 1, 18, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 1, 18, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 1, 19 ); -acado_setBlockH11( 1, 19, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 2, 2, &(acadoWorkspace.R1[ 2 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.QE[ 15 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 51 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 69 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 90 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 114 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 141 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 171 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 279 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 321 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 366 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 414 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 465 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 519 ]) ); -acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 576 ]) ); - -acado_zeroBlockH11( 2, 3 ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 27 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 39 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 54 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 72 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 93 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 117 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 144 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 174 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 207 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 243 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 282 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 324 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 369 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 417 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 468 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 522 ]) ); -acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 579 ]) ); - -acado_zeroBlockH11( 2, 4 ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 42 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 57 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 75 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 96 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 120 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 147 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 177 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 210 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 246 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 285 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 327 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 372 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 420 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 471 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 525 ]) ); -acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 582 ]) ); - -acado_zeroBlockH11( 2, 5 ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 60 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 78 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 99 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 123 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 150 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 180 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 213 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 249 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 288 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 330 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 375 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 423 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 474 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 528 ]) ); -acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 585 ]) ); - -acado_zeroBlockH11( 2, 6 ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 588 ]) ); - -acado_zeroBlockH11( 2, 7 ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 2, 8 ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 2, 9 ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 2, 10 ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 2, 11 ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 2, 12 ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 2, 13 ); -acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 2, 14 ); -acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 2, 15 ); -acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 2, 16 ); -acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 2, 17 ); -acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 2, 18 ); -acado_setBlockH11( 2, 18, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 2, 18, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 2, 19 ); -acado_setBlockH11( 2, 19, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 3, 3, &(acadoWorkspace.R1[ 3 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.QE[ 27 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QE[ 39 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 54 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 93 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 117 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 174 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 207 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 243 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 282 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 369 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 417 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 522 ]) ); -acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 579 ]) ); - -acado_zeroBlockH11( 3, 4 ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QE[ 42 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 57 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 75 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 96 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 120 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 147 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 177 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 210 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 246 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 285 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 327 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 372 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 420 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 471 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 525 ]) ); -acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 582 ]) ); - -acado_zeroBlockH11( 3, 5 ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 60 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 78 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 99 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 123 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 150 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 180 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 213 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 249 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 288 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 330 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 375 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 423 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 474 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 528 ]) ); -acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 585 ]) ); - -acado_zeroBlockH11( 3, 6 ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 588 ]) ); - -acado_zeroBlockH11( 3, 7 ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 3, 8 ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 3, 9 ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 3, 10 ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 3, 11 ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 3, 12 ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 3, 13 ); -acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 3, 14 ); -acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 3, 15 ); -acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 3, 16 ); -acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 3, 17 ); -acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 3, 18 ); -acado_setBlockH11( 3, 18, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 3, 18, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 3, 19 ); -acado_setBlockH11( 3, 19, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 4, 4, &(acadoWorkspace.R1[ 4 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.QE[ 42 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QE[ 57 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 75 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 147 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 177 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 210 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 246 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 285 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 327 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 471 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 525 ]) ); -acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 582 ]) ); - -acado_zeroBlockH11( 4, 5 ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QE[ 60 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 78 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 99 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 123 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 150 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 180 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 213 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 249 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 288 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 330 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 375 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 423 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 474 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 528 ]) ); -acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 585 ]) ); - -acado_zeroBlockH11( 4, 6 ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 588 ]) ); - -acado_zeroBlockH11( 4, 7 ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 4, 8 ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 4, 9 ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 4, 10 ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 4, 11 ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 4, 12 ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 4, 13 ); -acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 4, 14 ); -acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 4, 15 ); -acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 4, 16 ); -acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 4, 17 ); -acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 4, 18 ); -acado_setBlockH11( 4, 18, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 4, 18, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 4, 19 ); -acado_setBlockH11( 4, 19, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 5, 5, &(acadoWorkspace.R1[ 5 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QE[ 78 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 99 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 123 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 150 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 213 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 249 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 330 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 375 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 423 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 474 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); -acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 585 ]) ); - -acado_zeroBlockH11( 5, 6 ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 588 ]) ); - -acado_zeroBlockH11( 5, 7 ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 5, 8 ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 5, 9 ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 5, 10 ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 5, 11 ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 5, 12 ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 5, 13 ); -acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 5, 14 ); -acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 5, 15 ); -acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 5, 16 ); -acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 5, 17 ); -acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 5, 18 ); -acado_setBlockH11( 5, 18, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 5, 18, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 5, 19 ); -acado_setBlockH11( 5, 19, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 6, 6, &(acadoWorkspace.R1[ 6 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.QE[ 81 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QE[ 102 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 126 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 153 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 183 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 291 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 333 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 378 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 426 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 477 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 531 ]) ); -acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 588 ]) ); - -acado_zeroBlockH11( 6, 7 ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 6, 8 ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 6, 9 ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 6, 10 ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 6, 11 ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 6, 12 ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 6, 13 ); -acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 6, 14 ); -acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 6, 15 ); -acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 6, 16 ); -acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 6, 17 ); -acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 6, 18 ); -acado_setBlockH11( 6, 18, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 6, 18, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 6, 19 ); -acado_setBlockH11( 6, 19, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 7, 7, &(acadoWorkspace.R1[ 7 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.QE[ 105 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QE[ 129 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 186 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 219 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 255 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 294 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 381 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 429 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 534 ]) ); -acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 591 ]) ); - -acado_zeroBlockH11( 7, 8 ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 7, 9 ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 7, 10 ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 7, 11 ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 7, 12 ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 7, 13 ); -acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 7, 14 ); -acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 7, 15 ); -acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 7, 16 ); -acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 7, 17 ); -acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 7, 18 ); -acado_setBlockH11( 7, 18, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 7, 18, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 7, 19 ); -acado_setBlockH11( 7, 19, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 8, 8, &(acadoWorkspace.R1[ 8 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QE[ 159 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 189 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 222 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 258 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 297 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 339 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 483 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 537 ]) ); -acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 594 ]) ); - -acado_zeroBlockH11( 8, 9 ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 8, 10 ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 8, 11 ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 8, 12 ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 8, 13 ); -acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 8, 14 ); -acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 8, 15 ); -acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 8, 16 ); -acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 8, 17 ); -acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 8, 18 ); -acado_setBlockH11( 8, 18, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 8, 18, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 8, 19 ); -acado_setBlockH11( 8, 19, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 9, 9, &(acadoWorkspace.R1[ 9 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.QE[ 162 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 225 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 261 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 342 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 387 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 435 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 486 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); -acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 597 ]) ); - -acado_zeroBlockH11( 9, 10 ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 9, 11 ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 9, 12 ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 9, 13 ); -acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 9, 14 ); -acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 9, 15 ); -acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 9, 16 ); -acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 9, 17 ); -acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 9, 18 ); -acado_setBlockH11( 9, 18, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 9, 18, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 9, 19 ); -acado_setBlockH11( 9, 19, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 10, 10, &(acadoWorkspace.R1[ 10 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.QE[ 195 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 303 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 345 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 390 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 438 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 489 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 543 ]) ); -acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 600 ]) ); - -acado_zeroBlockH11( 10, 11 ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 10, 12 ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 10, 13 ); -acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 10, 14 ); -acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 10, 15 ); -acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 10, 16 ); -acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 10, 17 ); -acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 10, 18 ); -acado_setBlockH11( 10, 18, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 10, 18, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 10, 19 ); -acado_setBlockH11( 10, 19, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 11, 11, &(acadoWorkspace.R1[ 11 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.QE[ 231 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QE[ 267 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 306 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 393 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 441 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 546 ]) ); -acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 603 ]) ); - -acado_zeroBlockH11( 11, 12 ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 11, 13 ); -acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 11, 14 ); -acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 11, 15 ); -acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 11, 16 ); -acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 11, 17 ); -acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 11, 18 ); -acado_setBlockH11( 11, 18, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 11, 18, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 11, 19 ); -acado_setBlockH11( 11, 19, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 12, 12, &(acadoWorkspace.R1[ 12 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.QE[ 270 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QE[ 309 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 351 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 495 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 549 ]) ); -acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 606 ]) ); - -acado_zeroBlockH11( 12, 13 ); -acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 12, 14 ); -acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 12, 15 ); -acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 12, 16 ); -acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 12, 17 ); -acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 12, 18 ); -acado_setBlockH11( 12, 18, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 12, 18, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 12, 19 ); -acado_setBlockH11( 12, 19, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 13, 13, &(acadoWorkspace.R1[ 13 ]) ); -acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); -acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QE[ 354 ]) ); -acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 399 ]) ); -acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 447 ]) ); -acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 498 ]) ); -acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 552 ]) ); -acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 609 ]) ); - -acado_zeroBlockH11( 13, 14 ); -acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 13, 15 ); -acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 13, 16 ); -acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 13, 17 ); -acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 13, 18 ); -acado_setBlockH11( 13, 18, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 13, 18, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 13, 19 ); -acado_setBlockH11( 13, 19, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 14, 14, &(acadoWorkspace.R1[ 14 ]) ); -acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.QE[ 357 ]) ); -acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QE[ 402 ]) ); -acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 450 ]) ); -acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 501 ]) ); -acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 555 ]) ); -acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 612 ]) ); - -acado_zeroBlockH11( 14, 15 ); -acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 14, 16 ); -acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 14, 17 ); -acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 14, 18 ); -acado_setBlockH11( 14, 18, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 14, 18, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 14, 19 ); -acado_setBlockH11( 14, 19, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 15, 15, &(acadoWorkspace.R1[ 15 ]) ); -acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.QE[ 405 ]) ); -acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QE[ 453 ]) ); -acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); -acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 558 ]) ); -acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 615 ]) ); - -acado_zeroBlockH11( 15, 16 ); -acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 15, 17 ); -acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 15, 18 ); -acado_setBlockH11( 15, 18, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 15, 18, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 15, 19 ); -acado_setBlockH11( 15, 19, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 16, 16, &(acadoWorkspace.R1[ 16 ]) ); -acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); -acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QE[ 507 ]) ); -acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 561 ]) ); -acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 618 ]) ); - -acado_zeroBlockH11( 16, 17 ); -acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 16, 18 ); -acado_setBlockH11( 16, 18, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 16, 18, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 16, 19 ); -acado_setBlockH11( 16, 19, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 17, 17, &(acadoWorkspace.R1[ 17 ]) ); -acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.QE[ 510 ]) ); -acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 564 ]) ); -acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 621 ]) ); - -acado_zeroBlockH11( 17, 18 ); -acado_setBlockH11( 17, 18, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 17, 18, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 17, 19 ); -acado_setBlockH11( 17, 19, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 18, 18, &(acadoWorkspace.R1[ 18 ]) ); -acado_setBlockH11( 18, 18, &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.QE[ 567 ]) ); -acado_setBlockH11( 18, 18, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 624 ]) ); - -acado_zeroBlockH11( 18, 19 ); -acado_setBlockH11( 18, 19, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 627 ]) ); - -acado_setBlockH11_R1( 19, 19, &(acadoWorkspace.R1[ 19 ]) ); -acado_setBlockH11( 19, 19, &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.QE[ 627 ]) ); - - -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[69] = acadoWorkspace.H10[0]; -acadoWorkspace.H[70] = acadoWorkspace.H10[1]; -acadoWorkspace.H[71] = acadoWorkspace.H10[2]; -acadoWorkspace.H[92] = acadoWorkspace.H10[3]; -acadoWorkspace.H[93] = acadoWorkspace.H10[4]; -acadoWorkspace.H[94] = acadoWorkspace.H10[5]; -acadoWorkspace.H[115] = acadoWorkspace.H10[6]; -acadoWorkspace.H[116] = acadoWorkspace.H10[7]; -acadoWorkspace.H[117] = acadoWorkspace.H10[8]; -acadoWorkspace.H[138] = acadoWorkspace.H10[9]; -acadoWorkspace.H[139] = acadoWorkspace.H10[10]; -acadoWorkspace.H[140] = acadoWorkspace.H10[11]; -acadoWorkspace.H[161] = acadoWorkspace.H10[12]; -acadoWorkspace.H[162] = acadoWorkspace.H10[13]; -acadoWorkspace.H[163] = acadoWorkspace.H10[14]; -acadoWorkspace.H[184] = acadoWorkspace.H10[15]; -acadoWorkspace.H[185] = acadoWorkspace.H10[16]; -acadoWorkspace.H[186] = acadoWorkspace.H10[17]; -acadoWorkspace.H[207] = acadoWorkspace.H10[18]; -acadoWorkspace.H[208] = acadoWorkspace.H10[19]; -acadoWorkspace.H[209] = acadoWorkspace.H10[20]; -acadoWorkspace.H[230] = acadoWorkspace.H10[21]; -acadoWorkspace.H[231] = acadoWorkspace.H10[22]; -acadoWorkspace.H[232] = acadoWorkspace.H10[23]; -acadoWorkspace.H[253] = acadoWorkspace.H10[24]; -acadoWorkspace.H[254] = acadoWorkspace.H10[25]; -acadoWorkspace.H[255] = acadoWorkspace.H10[26]; -acadoWorkspace.H[276] = acadoWorkspace.H10[27]; -acadoWorkspace.H[277] = acadoWorkspace.H10[28]; -acadoWorkspace.H[278] = acadoWorkspace.H10[29]; -acadoWorkspace.H[299] = acadoWorkspace.H10[30]; -acadoWorkspace.H[300] = acadoWorkspace.H10[31]; -acadoWorkspace.H[301] = acadoWorkspace.H10[32]; -acadoWorkspace.H[322] = acadoWorkspace.H10[33]; -acadoWorkspace.H[323] = acadoWorkspace.H10[34]; -acadoWorkspace.H[324] = acadoWorkspace.H10[35]; -acadoWorkspace.H[345] = acadoWorkspace.H10[36]; -acadoWorkspace.H[346] = acadoWorkspace.H10[37]; -acadoWorkspace.H[347] = acadoWorkspace.H10[38]; -acadoWorkspace.H[368] = acadoWorkspace.H10[39]; -acadoWorkspace.H[369] = acadoWorkspace.H10[40]; -acadoWorkspace.H[370] = acadoWorkspace.H10[41]; -acadoWorkspace.H[391] = acadoWorkspace.H10[42]; -acadoWorkspace.H[392] = acadoWorkspace.H10[43]; -acadoWorkspace.H[393] = acadoWorkspace.H10[44]; -acadoWorkspace.H[414] = acadoWorkspace.H10[45]; -acadoWorkspace.H[415] = acadoWorkspace.H10[46]; -acadoWorkspace.H[416] = acadoWorkspace.H10[47]; -acadoWorkspace.H[437] = acadoWorkspace.H10[48]; -acadoWorkspace.H[438] = acadoWorkspace.H10[49]; -acadoWorkspace.H[439] = acadoWorkspace.H10[50]; -acadoWorkspace.H[460] = acadoWorkspace.H10[51]; -acadoWorkspace.H[461] = acadoWorkspace.H10[52]; -acadoWorkspace.H[462] = acadoWorkspace.H10[53]; -acadoWorkspace.H[483] = acadoWorkspace.H10[54]; -acadoWorkspace.H[484] = acadoWorkspace.H10[55]; -acadoWorkspace.H[485] = acadoWorkspace.H10[56]; -acadoWorkspace.H[506] = acadoWorkspace.H10[57]; -acadoWorkspace.H[507] = acadoWorkspace.H10[58]; -acadoWorkspace.H[508] = acadoWorkspace.H10[59]; - -acado_multQ1d( &(acadoWorkspace.Q1[ 9 ]), acadoWorkspace.d, acadoWorkspace.Qd ); -acado_multQ1d( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.d[ 3 ]), &(acadoWorkspace.Qd[ 3 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.d[ 6 ]), &(acadoWorkspace.Qd[ 6 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.d[ 9 ]), &(acadoWorkspace.Qd[ 9 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.Qd[ 12 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.d[ 15 ]), &(acadoWorkspace.Qd[ 15 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.d[ 18 ]), &(acadoWorkspace.Qd[ 18 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.d[ 21 ]), &(acadoWorkspace.Qd[ 21 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.Qd[ 24 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.d[ 27 ]), &(acadoWorkspace.Qd[ 27 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.d[ 30 ]), &(acadoWorkspace.Qd[ 30 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.d[ 33 ]), &(acadoWorkspace.Qd[ 33 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.Qd[ 36 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.d[ 39 ]), &(acadoWorkspace.Qd[ 39 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.d[ 42 ]), &(acadoWorkspace.Qd[ 42 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.d[ 45 ]), &(acadoWorkspace.Qd[ 45 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.Qd[ 48 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.d[ 51 ]), &(acadoWorkspace.Qd[ 51 ]) ); -acado_multQ1d( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.d[ 54 ]), &(acadoWorkspace.Qd[ 54 ]) ); -acado_multQN1d( acadoWorkspace.QN1, &(acadoWorkspace.d[ 57 ]), &(acadoWorkspace.Qd[ 57 ]) ); - -acado_macCTSlx( acadoWorkspace.evGx, acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 9 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 18 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 27 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 36 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 45 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 54 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 63 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 72 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 81 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 90 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 99 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 108 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 117 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 126 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 135 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 153 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 162 ]), acadoWorkspace.g ); -acado_macCTSlx( &(acadoWorkspace.evGx[ 171 ]), acadoWorkspace.g ); -acado_macETSlu( acadoWorkspace.QE, &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 3 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 9 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 18 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 30 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 45 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 63 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 135 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 165 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 198 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 234 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 273 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 315 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 459 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 513 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 570 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 6 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 21 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 33 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 66 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 87 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 111 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 138 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 201 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 237 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 318 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 363 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 411 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 462 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 573 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 15 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 51 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 69 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 90 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 114 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 141 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 171 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 279 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 321 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 366 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 414 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 465 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 519 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 576 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 27 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 39 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 54 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 93 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 117 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 174 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 207 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 243 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 282 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 369 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 417 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 522 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 579 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 42 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 57 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 75 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 147 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 177 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 210 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 246 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 285 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 327 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 471 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 525 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 582 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 78 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 99 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 123 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 150 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 213 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 249 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 330 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 375 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 423 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 474 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 585 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 81 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 102 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 126 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 153 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 183 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 291 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 333 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 378 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 426 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 477 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 531 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 588 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 105 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 129 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 186 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 219 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 255 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 294 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 381 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 429 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 534 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 591 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 159 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 189 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 222 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 258 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 297 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 339 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 483 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 537 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 594 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 162 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 225 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 261 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 342 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 387 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 435 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 486 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 597 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 195 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 303 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 345 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 390 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 438 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 489 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 543 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 600 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 231 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 267 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 306 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 393 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 441 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 546 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 603 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 270 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 309 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 351 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 495 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 549 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 606 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 354 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 399 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 447 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 498 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 552 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 609 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 357 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 402 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 450 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 501 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 555 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 612 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 405 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 453 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 558 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 615 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 507 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 561 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 618 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 510 ]), &(acadoWorkspace.g[ 20 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 564 ]), &(acadoWorkspace.g[ 20 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 621 ]), &(acadoWorkspace.g[ 20 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 567 ]), &(acadoWorkspace.g[ 21 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 624 ]), &(acadoWorkspace.g[ 21 ]) ); -acado_macETSlu( &(acadoWorkspace.QE[ 627 ]), &(acadoWorkspace.g[ 22 ]) ); -acadoWorkspace.lb[3] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[0]; -acadoWorkspace.lb[4] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[1]; -acadoWorkspace.lb[5] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[2]; -acadoWorkspace.lb[6] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[3]; -acadoWorkspace.lb[7] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[4]; -acadoWorkspace.lb[8] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[5]; -acadoWorkspace.lb[9] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[6]; -acadoWorkspace.lb[10] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[7]; -acadoWorkspace.lb[11] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[8]; -acadoWorkspace.lb[12] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[9]; -acadoWorkspace.lb[13] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[10]; -acadoWorkspace.lb[14] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[11]; -acadoWorkspace.lb[15] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[12]; -acadoWorkspace.lb[16] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[13]; -acadoWorkspace.lb[17] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[14]; -acadoWorkspace.lb[18] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[15]; -acadoWorkspace.lb[19] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[16]; -acadoWorkspace.lb[20] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[17]; -acadoWorkspace.lb[21] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[18]; -acadoWorkspace.lb[22] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[19]; -acadoWorkspace.ub[3] = (real_t)1.0000000000000000e+12 - acadoVariables.u[0]; -acadoWorkspace.ub[4] = (real_t)1.0000000000000000e+12 - acadoVariables.u[1]; -acadoWorkspace.ub[5] = (real_t)1.0000000000000000e+12 - acadoVariables.u[2]; -acadoWorkspace.ub[6] = (real_t)1.0000000000000000e+12 - acadoVariables.u[3]; -acadoWorkspace.ub[7] = (real_t)1.0000000000000000e+12 - acadoVariables.u[4]; -acadoWorkspace.ub[8] = (real_t)1.0000000000000000e+12 - acadoVariables.u[5]; -acadoWorkspace.ub[9] = (real_t)1.0000000000000000e+12 - acadoVariables.u[6]; -acadoWorkspace.ub[10] = (real_t)1.0000000000000000e+12 - acadoVariables.u[7]; -acadoWorkspace.ub[11] = (real_t)1.0000000000000000e+12 - acadoVariables.u[8]; -acadoWorkspace.ub[12] = (real_t)1.0000000000000000e+12 - acadoVariables.u[9]; -acadoWorkspace.ub[13] = (real_t)1.0000000000000000e+12 - acadoVariables.u[10]; -acadoWorkspace.ub[14] = (real_t)1.0000000000000000e+12 - acadoVariables.u[11]; -acadoWorkspace.ub[15] = (real_t)1.0000000000000000e+12 - acadoVariables.u[12]; -acadoWorkspace.ub[16] = (real_t)1.0000000000000000e+12 - acadoVariables.u[13]; -acadoWorkspace.ub[17] = (real_t)1.0000000000000000e+12 - acadoVariables.u[14]; -acadoWorkspace.ub[18] = (real_t)1.0000000000000000e+12 - acadoVariables.u[15]; -acadoWorkspace.ub[19] = (real_t)1.0000000000000000e+12 - acadoVariables.u[16]; -acadoWorkspace.ub[20] = (real_t)1.0000000000000000e+12 - acadoVariables.u[17]; -acadoWorkspace.ub[21] = (real_t)1.0000000000000000e+12 - acadoVariables.u[18]; -acadoWorkspace.ub[22] = (real_t)1.0000000000000000e+12 - acadoVariables.u[19]; - -for (lRun1 = 0; lRun1 < 20; ++lRun1) -{ -lRun3 = xBoundIndices[ lRun1 ] - 3; -lRun4 = ((lRun3) / (3)) + (1); -acadoWorkspace.A[lRun1 * 23] = acadoWorkspace.evGx[lRun3 * 3]; -acadoWorkspace.A[lRun1 * 23 + 1] = acadoWorkspace.evGx[lRun3 * 3 + 1]; -acadoWorkspace.A[lRun1 * 23 + 2] = acadoWorkspace.evGx[lRun3 * 3 + 2]; -for (lRun2 = 0; lRun2 < lRun4; ++lRun2) -{ -lRun5 = (((((lRun4) * (lRun4-1)) / (2)) + (lRun2)) * (3)) + ((lRun3) % (3)); -acadoWorkspace.A[(lRun1 * 23) + (lRun2 + 3)] = acadoWorkspace.E[lRun5]; -} -} - -} - -void acado_condenseFdb( ) -{ -real_t tmp; - -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.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.DyN[0] -= acadoVariables.yN[0]; -acadoWorkspace.DyN[1] -= acadoVariables.yN[1]; -acadoWorkspace.DyN[2] -= acadoVariables.yN[2]; - -acado_multRDy( acadoWorkspace.R2, acadoWorkspace.Dy, &(acadoWorkspace.g[ 3 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 4 ]), &(acadoWorkspace.Dy[ 4 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 8 ]), &(acadoWorkspace.Dy[ 8 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 12 ]), &(acadoWorkspace.Dy[ 12 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 16 ]), &(acadoWorkspace.Dy[ 16 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 20 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 24 ]), &(acadoWorkspace.Dy[ 24 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 28 ]), &(acadoWorkspace.Dy[ 28 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 32 ]), &(acadoWorkspace.Dy[ 32 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 36 ]), &(acadoWorkspace.Dy[ 36 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 40 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 44 ]), &(acadoWorkspace.Dy[ 44 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 48 ]), &(acadoWorkspace.Dy[ 48 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 52 ]), &(acadoWorkspace.Dy[ 52 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 56 ]), &(acadoWorkspace.Dy[ 56 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 60 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 64 ]), &(acadoWorkspace.Dy[ 64 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 68 ]), &(acadoWorkspace.Dy[ 68 ]), &(acadoWorkspace.g[ 20 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 72 ]), &(acadoWorkspace.Dy[ 72 ]), &(acadoWorkspace.g[ 21 ]) ); -acado_multRDy( &(acadoWorkspace.R2[ 76 ]), &(acadoWorkspace.Dy[ 76 ]), &(acadoWorkspace.g[ 22 ]) ); - -acado_multQDy( acadoWorkspace.Q2, acadoWorkspace.Dy, acadoWorkspace.QDy ); -acado_multQDy( &(acadoWorkspace.Q2[ 12 ]), &(acadoWorkspace.Dy[ 4 ]), &(acadoWorkspace.QDy[ 3 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 24 ]), &(acadoWorkspace.Dy[ 8 ]), &(acadoWorkspace.QDy[ 6 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 36 ]), &(acadoWorkspace.Dy[ 12 ]), &(acadoWorkspace.QDy[ 9 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 48 ]), &(acadoWorkspace.Dy[ 16 ]), &(acadoWorkspace.QDy[ 12 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 60 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.QDy[ 15 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 72 ]), &(acadoWorkspace.Dy[ 24 ]), &(acadoWorkspace.QDy[ 18 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 84 ]), &(acadoWorkspace.Dy[ 28 ]), &(acadoWorkspace.QDy[ 21 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 96 ]), &(acadoWorkspace.Dy[ 32 ]), &(acadoWorkspace.QDy[ 24 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 108 ]), &(acadoWorkspace.Dy[ 36 ]), &(acadoWorkspace.QDy[ 27 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 120 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.QDy[ 30 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 132 ]), &(acadoWorkspace.Dy[ 44 ]), &(acadoWorkspace.QDy[ 33 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 144 ]), &(acadoWorkspace.Dy[ 48 ]), &(acadoWorkspace.QDy[ 36 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 156 ]), &(acadoWorkspace.Dy[ 52 ]), &(acadoWorkspace.QDy[ 39 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 168 ]), &(acadoWorkspace.Dy[ 56 ]), &(acadoWorkspace.QDy[ 42 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 180 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.QDy[ 45 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 192 ]), &(acadoWorkspace.Dy[ 64 ]), &(acadoWorkspace.QDy[ 48 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 204 ]), &(acadoWorkspace.Dy[ 68 ]), &(acadoWorkspace.QDy[ 51 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 216 ]), &(acadoWorkspace.Dy[ 72 ]), &(acadoWorkspace.QDy[ 54 ]) ); -acado_multQDy( &(acadoWorkspace.Q2[ 228 ]), &(acadoWorkspace.Dy[ 76 ]), &(acadoWorkspace.QDy[ 57 ]) ); - -acadoWorkspace.QDy[60] = + acadoWorkspace.QN2[0]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[1]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[2]*acadoWorkspace.DyN[2]; -acadoWorkspace.QDy[61] = + acadoWorkspace.QN2[3]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[4]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[5]*acadoWorkspace.DyN[2]; -acadoWorkspace.QDy[62] = + acadoWorkspace.QN2[6]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[7]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[8]*acadoWorkspace.DyN[2]; - -acadoWorkspace.QDy[3] += acadoWorkspace.Qd[0]; -acadoWorkspace.QDy[4] += acadoWorkspace.Qd[1]; -acadoWorkspace.QDy[5] += acadoWorkspace.Qd[2]; -acadoWorkspace.QDy[6] += acadoWorkspace.Qd[3]; -acadoWorkspace.QDy[7] += acadoWorkspace.Qd[4]; -acadoWorkspace.QDy[8] += acadoWorkspace.Qd[5]; -acadoWorkspace.QDy[9] += acadoWorkspace.Qd[6]; -acadoWorkspace.QDy[10] += acadoWorkspace.Qd[7]; -acadoWorkspace.QDy[11] += acadoWorkspace.Qd[8]; -acadoWorkspace.QDy[12] += acadoWorkspace.Qd[9]; -acadoWorkspace.QDy[13] += acadoWorkspace.Qd[10]; -acadoWorkspace.QDy[14] += acadoWorkspace.Qd[11]; -acadoWorkspace.QDy[15] += acadoWorkspace.Qd[12]; -acadoWorkspace.QDy[16] += acadoWorkspace.Qd[13]; -acadoWorkspace.QDy[17] += acadoWorkspace.Qd[14]; -acadoWorkspace.QDy[18] += acadoWorkspace.Qd[15]; -acadoWorkspace.QDy[19] += acadoWorkspace.Qd[16]; -acadoWorkspace.QDy[20] += acadoWorkspace.Qd[17]; -acadoWorkspace.QDy[21] += acadoWorkspace.Qd[18]; -acadoWorkspace.QDy[22] += acadoWorkspace.Qd[19]; -acadoWorkspace.QDy[23] += acadoWorkspace.Qd[20]; -acadoWorkspace.QDy[24] += acadoWorkspace.Qd[21]; -acadoWorkspace.QDy[25] += acadoWorkspace.Qd[22]; -acadoWorkspace.QDy[26] += acadoWorkspace.Qd[23]; -acadoWorkspace.QDy[27] += acadoWorkspace.Qd[24]; -acadoWorkspace.QDy[28] += acadoWorkspace.Qd[25]; -acadoWorkspace.QDy[29] += acadoWorkspace.Qd[26]; -acadoWorkspace.QDy[30] += acadoWorkspace.Qd[27]; -acadoWorkspace.QDy[31] += acadoWorkspace.Qd[28]; -acadoWorkspace.QDy[32] += acadoWorkspace.Qd[29]; -acadoWorkspace.QDy[33] += acadoWorkspace.Qd[30]; -acadoWorkspace.QDy[34] += acadoWorkspace.Qd[31]; -acadoWorkspace.QDy[35] += acadoWorkspace.Qd[32]; -acadoWorkspace.QDy[36] += acadoWorkspace.Qd[33]; -acadoWorkspace.QDy[37] += acadoWorkspace.Qd[34]; -acadoWorkspace.QDy[38] += acadoWorkspace.Qd[35]; -acadoWorkspace.QDy[39] += acadoWorkspace.Qd[36]; -acadoWorkspace.QDy[40] += acadoWorkspace.Qd[37]; -acadoWorkspace.QDy[41] += acadoWorkspace.Qd[38]; -acadoWorkspace.QDy[42] += acadoWorkspace.Qd[39]; -acadoWorkspace.QDy[43] += acadoWorkspace.Qd[40]; -acadoWorkspace.QDy[44] += acadoWorkspace.Qd[41]; -acadoWorkspace.QDy[45] += acadoWorkspace.Qd[42]; -acadoWorkspace.QDy[46] += acadoWorkspace.Qd[43]; -acadoWorkspace.QDy[47] += acadoWorkspace.Qd[44]; -acadoWorkspace.QDy[48] += acadoWorkspace.Qd[45]; -acadoWorkspace.QDy[49] += acadoWorkspace.Qd[46]; -acadoWorkspace.QDy[50] += acadoWorkspace.Qd[47]; -acadoWorkspace.QDy[51] += acadoWorkspace.Qd[48]; -acadoWorkspace.QDy[52] += acadoWorkspace.Qd[49]; -acadoWorkspace.QDy[53] += acadoWorkspace.Qd[50]; -acadoWorkspace.QDy[54] += acadoWorkspace.Qd[51]; -acadoWorkspace.QDy[55] += acadoWorkspace.Qd[52]; -acadoWorkspace.QDy[56] += acadoWorkspace.Qd[53]; -acadoWorkspace.QDy[57] += acadoWorkspace.Qd[54]; -acadoWorkspace.QDy[58] += acadoWorkspace.Qd[55]; -acadoWorkspace.QDy[59] += acadoWorkspace.Qd[56]; -acadoWorkspace.QDy[60] += acadoWorkspace.Qd[57]; -acadoWorkspace.QDy[61] += acadoWorkspace.Qd[58]; -acadoWorkspace.QDy[62] += acadoWorkspace.Qd[59]; - -acadoWorkspace.g[0] = + acadoWorkspace.evGx[0]*acadoWorkspace.QDy[3] + acadoWorkspace.evGx[3]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[6]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[9]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[12]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[15]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[18]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[21]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[24]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[27]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[30]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[33]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[36]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[39]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[42]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[45]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[48]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[51]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[54]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[57]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[60]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[63]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[66]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[69]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[72]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[75]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[78]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[81]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[84]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[87]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[90]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[93]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[96]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[99]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[102]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[105]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[108]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[111]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[114]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[117]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[120]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[123]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[126]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[129]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[132]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[135]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[138]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[141]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[144]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[147]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[150]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[153]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[156]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[159]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[162]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[165]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[168]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[171]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[174]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[177]*acadoWorkspace.QDy[62]; -acadoWorkspace.g[1] = + acadoWorkspace.evGx[1]*acadoWorkspace.QDy[3] + acadoWorkspace.evGx[4]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[7]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[10]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[13]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[16]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[19]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[22]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[25]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[28]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[31]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[34]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[37]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[40]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[43]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[46]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[49]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[52]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[55]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[58]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[61]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[64]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[67]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[70]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[73]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[76]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[79]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[82]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[85]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[88]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[91]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[94]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[97]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[100]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[103]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[106]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[109]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[112]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[115]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[118]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[121]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[124]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[127]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[130]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[133]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[136]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[139]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[142]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[145]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[148]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[151]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[154]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[157]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[160]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[163]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[166]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[169]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[172]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[175]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[178]*acadoWorkspace.QDy[62]; -acadoWorkspace.g[2] = + acadoWorkspace.evGx[2]*acadoWorkspace.QDy[3] + acadoWorkspace.evGx[5]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[8]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[11]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[14]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[17]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[20]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[23]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[26]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[29]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[32]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[35]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[38]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[41]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[44]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[47]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[50]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[53]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[56]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[59]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[62]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[65]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[68]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[71]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[74]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[77]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[80]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[83]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[86]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[89]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[92]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[95]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[98]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[101]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[104]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[107]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[110]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[113]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[116]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[119]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[122]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[125]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[128]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[131]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[134]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[137]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[140]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[143]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[146]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[149]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[152]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[155]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[158]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[161]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[164]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[167]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[170]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[173]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[176]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[179]*acadoWorkspace.QDy[62]; - - -acado_multEQDy( acadoWorkspace.E, &(acadoWorkspace.QDy[ 3 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QDy[ 6 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QDy[ 9 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 3 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.QDy[ 6 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QDy[ 9 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 4 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.QDy[ 9 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 5 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 6 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 7 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 8 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 9 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 10 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 11 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 12 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 13 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 14 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 15 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 16 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 17 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 18 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 19 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 20 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 20 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 20 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 21 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 21 ]) ); -acado_multEQDy( &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 22 ]) ); - -acadoWorkspace.lb[0] = acadoWorkspace.Dx0[0]; -acadoWorkspace.lb[1] = acadoWorkspace.Dx0[1]; -acadoWorkspace.lb[2] = acadoWorkspace.Dx0[2]; -acadoWorkspace.ub[0] = acadoWorkspace.Dx0[0]; -acadoWorkspace.ub[1] = acadoWorkspace.Dx0[1]; -acadoWorkspace.ub[2] = acadoWorkspace.Dx0[2]; -tmp = acadoVariables.x[4] + acadoWorkspace.d[1]; -acadoWorkspace.lbA[0] = - tmp; -acadoWorkspace.ubA[0] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[7] + acadoWorkspace.d[4]; -acadoWorkspace.lbA[1] = - tmp; -acadoWorkspace.ubA[1] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[10] + acadoWorkspace.d[7]; -acadoWorkspace.lbA[2] = - tmp; -acadoWorkspace.ubA[2] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[13] + acadoWorkspace.d[10]; -acadoWorkspace.lbA[3] = - tmp; -acadoWorkspace.ubA[3] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[16] + acadoWorkspace.d[13]; -acadoWorkspace.lbA[4] = - tmp; -acadoWorkspace.ubA[4] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[19] + acadoWorkspace.d[16]; -acadoWorkspace.lbA[5] = - tmp; -acadoWorkspace.ubA[5] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[22] + acadoWorkspace.d[19]; -acadoWorkspace.lbA[6] = - tmp; -acadoWorkspace.ubA[6] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[25] + acadoWorkspace.d[22]; -acadoWorkspace.lbA[7] = - tmp; -acadoWorkspace.ubA[7] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[28] + acadoWorkspace.d[25]; -acadoWorkspace.lbA[8] = - tmp; -acadoWorkspace.ubA[8] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[31] + acadoWorkspace.d[28]; -acadoWorkspace.lbA[9] = - tmp; -acadoWorkspace.ubA[9] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[34] + acadoWorkspace.d[31]; -acadoWorkspace.lbA[10] = - tmp; -acadoWorkspace.ubA[10] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[37] + acadoWorkspace.d[34]; -acadoWorkspace.lbA[11] = - tmp; -acadoWorkspace.ubA[11] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[40] + acadoWorkspace.d[37]; -acadoWorkspace.lbA[12] = - tmp; -acadoWorkspace.ubA[12] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[43] + acadoWorkspace.d[40]; -acadoWorkspace.lbA[13] = - tmp; -acadoWorkspace.ubA[13] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[46] + acadoWorkspace.d[43]; -acadoWorkspace.lbA[14] = - tmp; -acadoWorkspace.ubA[14] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[49] + acadoWorkspace.d[46]; -acadoWorkspace.lbA[15] = - tmp; -acadoWorkspace.ubA[15] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[52] + acadoWorkspace.d[49]; -acadoWorkspace.lbA[16] = - tmp; -acadoWorkspace.ubA[16] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[55] + acadoWorkspace.d[52]; -acadoWorkspace.lbA[17] = - tmp; -acadoWorkspace.ubA[17] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[58] + acadoWorkspace.d[55]; -acadoWorkspace.lbA[18] = - tmp; -acadoWorkspace.ubA[18] = (real_t)1.0000000000000000e+12 - tmp; -tmp = acadoVariables.x[61] + acadoWorkspace.d[58]; -acadoWorkspace.lbA[19] = - tmp; -acadoWorkspace.ubA[19] = (real_t)1.0000000000000000e+12 - tmp; - -} - -void acado_expand( ) -{ -acadoVariables.x[0] += acadoWorkspace.x[0]; -acadoVariables.x[1] += acadoWorkspace.x[1]; -acadoVariables.x[2] += acadoWorkspace.x[2]; - -acadoVariables.u[0] += acadoWorkspace.x[3]; -acadoVariables.u[1] += acadoWorkspace.x[4]; -acadoVariables.u[2] += acadoWorkspace.x[5]; -acadoVariables.u[3] += acadoWorkspace.x[6]; -acadoVariables.u[4] += acadoWorkspace.x[7]; -acadoVariables.u[5] += acadoWorkspace.x[8]; -acadoVariables.u[6] += acadoWorkspace.x[9]; -acadoVariables.u[7] += acadoWorkspace.x[10]; -acadoVariables.u[8] += acadoWorkspace.x[11]; -acadoVariables.u[9] += acadoWorkspace.x[12]; -acadoVariables.u[10] += acadoWorkspace.x[13]; -acadoVariables.u[11] += acadoWorkspace.x[14]; -acadoVariables.u[12] += acadoWorkspace.x[15]; -acadoVariables.u[13] += acadoWorkspace.x[16]; -acadoVariables.u[14] += acadoWorkspace.x[17]; -acadoVariables.u[15] += acadoWorkspace.x[18]; -acadoVariables.u[16] += acadoWorkspace.x[19]; -acadoVariables.u[17] += acadoWorkspace.x[20]; -acadoVariables.u[18] += acadoWorkspace.x[21]; -acadoVariables.u[19] += acadoWorkspace.x[22]; - -acadoVariables.x[3] += + acadoWorkspace.evGx[0]*acadoWorkspace.x[0] + acadoWorkspace.evGx[1]*acadoWorkspace.x[1] + acadoWorkspace.evGx[2]*acadoWorkspace.x[2] + acadoWorkspace.d[0]; -acadoVariables.x[4] += + acadoWorkspace.evGx[3]*acadoWorkspace.x[0] + acadoWorkspace.evGx[4]*acadoWorkspace.x[1] + acadoWorkspace.evGx[5]*acadoWorkspace.x[2] + acadoWorkspace.d[1]; -acadoVariables.x[5] += + acadoWorkspace.evGx[6]*acadoWorkspace.x[0] + acadoWorkspace.evGx[7]*acadoWorkspace.x[1] + acadoWorkspace.evGx[8]*acadoWorkspace.x[2] + acadoWorkspace.d[2]; -acadoVariables.x[6] += + acadoWorkspace.evGx[9]*acadoWorkspace.x[0] + acadoWorkspace.evGx[10]*acadoWorkspace.x[1] + acadoWorkspace.evGx[11]*acadoWorkspace.x[2] + acadoWorkspace.d[3]; -acadoVariables.x[7] += + acadoWorkspace.evGx[12]*acadoWorkspace.x[0] + acadoWorkspace.evGx[13]*acadoWorkspace.x[1] + acadoWorkspace.evGx[14]*acadoWorkspace.x[2] + acadoWorkspace.d[4]; -acadoVariables.x[8] += + acadoWorkspace.evGx[15]*acadoWorkspace.x[0] + acadoWorkspace.evGx[16]*acadoWorkspace.x[1] + acadoWorkspace.evGx[17]*acadoWorkspace.x[2] + acadoWorkspace.d[5]; -acadoVariables.x[9] += + acadoWorkspace.evGx[18]*acadoWorkspace.x[0] + acadoWorkspace.evGx[19]*acadoWorkspace.x[1] + acadoWorkspace.evGx[20]*acadoWorkspace.x[2] + acadoWorkspace.d[6]; -acadoVariables.x[10] += + acadoWorkspace.evGx[21]*acadoWorkspace.x[0] + acadoWorkspace.evGx[22]*acadoWorkspace.x[1] + acadoWorkspace.evGx[23]*acadoWorkspace.x[2] + acadoWorkspace.d[7]; -acadoVariables.x[11] += + acadoWorkspace.evGx[24]*acadoWorkspace.x[0] + acadoWorkspace.evGx[25]*acadoWorkspace.x[1] + acadoWorkspace.evGx[26]*acadoWorkspace.x[2] + acadoWorkspace.d[8]; -acadoVariables.x[12] += + acadoWorkspace.evGx[27]*acadoWorkspace.x[0] + acadoWorkspace.evGx[28]*acadoWorkspace.x[1] + acadoWorkspace.evGx[29]*acadoWorkspace.x[2] + acadoWorkspace.d[9]; -acadoVariables.x[13] += + acadoWorkspace.evGx[30]*acadoWorkspace.x[0] + acadoWorkspace.evGx[31]*acadoWorkspace.x[1] + acadoWorkspace.evGx[32]*acadoWorkspace.x[2] + acadoWorkspace.d[10]; -acadoVariables.x[14] += + acadoWorkspace.evGx[33]*acadoWorkspace.x[0] + acadoWorkspace.evGx[34]*acadoWorkspace.x[1] + acadoWorkspace.evGx[35]*acadoWorkspace.x[2] + acadoWorkspace.d[11]; -acadoVariables.x[15] += + acadoWorkspace.evGx[36]*acadoWorkspace.x[0] + acadoWorkspace.evGx[37]*acadoWorkspace.x[1] + acadoWorkspace.evGx[38]*acadoWorkspace.x[2] + acadoWorkspace.d[12]; -acadoVariables.x[16] += + acadoWorkspace.evGx[39]*acadoWorkspace.x[0] + acadoWorkspace.evGx[40]*acadoWorkspace.x[1] + acadoWorkspace.evGx[41]*acadoWorkspace.x[2] + acadoWorkspace.d[13]; -acadoVariables.x[17] += + acadoWorkspace.evGx[42]*acadoWorkspace.x[0] + acadoWorkspace.evGx[43]*acadoWorkspace.x[1] + acadoWorkspace.evGx[44]*acadoWorkspace.x[2] + acadoWorkspace.d[14]; -acadoVariables.x[18] += + acadoWorkspace.evGx[45]*acadoWorkspace.x[0] + acadoWorkspace.evGx[46]*acadoWorkspace.x[1] + acadoWorkspace.evGx[47]*acadoWorkspace.x[2] + acadoWorkspace.d[15]; -acadoVariables.x[19] += + acadoWorkspace.evGx[48]*acadoWorkspace.x[0] + acadoWorkspace.evGx[49]*acadoWorkspace.x[1] + acadoWorkspace.evGx[50]*acadoWorkspace.x[2] + acadoWorkspace.d[16]; -acadoVariables.x[20] += + acadoWorkspace.evGx[51]*acadoWorkspace.x[0] + acadoWorkspace.evGx[52]*acadoWorkspace.x[1] + acadoWorkspace.evGx[53]*acadoWorkspace.x[2] + acadoWorkspace.d[17]; -acadoVariables.x[21] += + acadoWorkspace.evGx[54]*acadoWorkspace.x[0] + acadoWorkspace.evGx[55]*acadoWorkspace.x[1] + acadoWorkspace.evGx[56]*acadoWorkspace.x[2] + acadoWorkspace.d[18]; -acadoVariables.x[22] += + acadoWorkspace.evGx[57]*acadoWorkspace.x[0] + acadoWorkspace.evGx[58]*acadoWorkspace.x[1] + acadoWorkspace.evGx[59]*acadoWorkspace.x[2] + acadoWorkspace.d[19]; -acadoVariables.x[23] += + acadoWorkspace.evGx[60]*acadoWorkspace.x[0] + acadoWorkspace.evGx[61]*acadoWorkspace.x[1] + acadoWorkspace.evGx[62]*acadoWorkspace.x[2] + acadoWorkspace.d[20]; -acadoVariables.x[24] += + acadoWorkspace.evGx[63]*acadoWorkspace.x[0] + acadoWorkspace.evGx[64]*acadoWorkspace.x[1] + acadoWorkspace.evGx[65]*acadoWorkspace.x[2] + acadoWorkspace.d[21]; -acadoVariables.x[25] += + acadoWorkspace.evGx[66]*acadoWorkspace.x[0] + acadoWorkspace.evGx[67]*acadoWorkspace.x[1] + acadoWorkspace.evGx[68]*acadoWorkspace.x[2] + acadoWorkspace.d[22]; -acadoVariables.x[26] += + acadoWorkspace.evGx[69]*acadoWorkspace.x[0] + acadoWorkspace.evGx[70]*acadoWorkspace.x[1] + acadoWorkspace.evGx[71]*acadoWorkspace.x[2] + acadoWorkspace.d[23]; -acadoVariables.x[27] += + acadoWorkspace.evGx[72]*acadoWorkspace.x[0] + acadoWorkspace.evGx[73]*acadoWorkspace.x[1] + acadoWorkspace.evGx[74]*acadoWorkspace.x[2] + acadoWorkspace.d[24]; -acadoVariables.x[28] += + acadoWorkspace.evGx[75]*acadoWorkspace.x[0] + acadoWorkspace.evGx[76]*acadoWorkspace.x[1] + acadoWorkspace.evGx[77]*acadoWorkspace.x[2] + acadoWorkspace.d[25]; -acadoVariables.x[29] += + acadoWorkspace.evGx[78]*acadoWorkspace.x[0] + acadoWorkspace.evGx[79]*acadoWorkspace.x[1] + acadoWorkspace.evGx[80]*acadoWorkspace.x[2] + acadoWorkspace.d[26]; -acadoVariables.x[30] += + acadoWorkspace.evGx[81]*acadoWorkspace.x[0] + acadoWorkspace.evGx[82]*acadoWorkspace.x[1] + acadoWorkspace.evGx[83]*acadoWorkspace.x[2] + acadoWorkspace.d[27]; -acadoVariables.x[31] += + acadoWorkspace.evGx[84]*acadoWorkspace.x[0] + acadoWorkspace.evGx[85]*acadoWorkspace.x[1] + acadoWorkspace.evGx[86]*acadoWorkspace.x[2] + acadoWorkspace.d[28]; -acadoVariables.x[32] += + acadoWorkspace.evGx[87]*acadoWorkspace.x[0] + acadoWorkspace.evGx[88]*acadoWorkspace.x[1] + acadoWorkspace.evGx[89]*acadoWorkspace.x[2] + acadoWorkspace.d[29]; -acadoVariables.x[33] += + acadoWorkspace.evGx[90]*acadoWorkspace.x[0] + acadoWorkspace.evGx[91]*acadoWorkspace.x[1] + acadoWorkspace.evGx[92]*acadoWorkspace.x[2] + acadoWorkspace.d[30]; -acadoVariables.x[34] += + acadoWorkspace.evGx[93]*acadoWorkspace.x[0] + acadoWorkspace.evGx[94]*acadoWorkspace.x[1] + acadoWorkspace.evGx[95]*acadoWorkspace.x[2] + acadoWorkspace.d[31]; -acadoVariables.x[35] += + acadoWorkspace.evGx[96]*acadoWorkspace.x[0] + acadoWorkspace.evGx[97]*acadoWorkspace.x[1] + acadoWorkspace.evGx[98]*acadoWorkspace.x[2] + acadoWorkspace.d[32]; -acadoVariables.x[36] += + acadoWorkspace.evGx[99]*acadoWorkspace.x[0] + acadoWorkspace.evGx[100]*acadoWorkspace.x[1] + acadoWorkspace.evGx[101]*acadoWorkspace.x[2] + acadoWorkspace.d[33]; -acadoVariables.x[37] += + acadoWorkspace.evGx[102]*acadoWorkspace.x[0] + acadoWorkspace.evGx[103]*acadoWorkspace.x[1] + acadoWorkspace.evGx[104]*acadoWorkspace.x[2] + acadoWorkspace.d[34]; -acadoVariables.x[38] += + acadoWorkspace.evGx[105]*acadoWorkspace.x[0] + acadoWorkspace.evGx[106]*acadoWorkspace.x[1] + acadoWorkspace.evGx[107]*acadoWorkspace.x[2] + acadoWorkspace.d[35]; -acadoVariables.x[39] += + acadoWorkspace.evGx[108]*acadoWorkspace.x[0] + acadoWorkspace.evGx[109]*acadoWorkspace.x[1] + acadoWorkspace.evGx[110]*acadoWorkspace.x[2] + acadoWorkspace.d[36]; -acadoVariables.x[40] += + acadoWorkspace.evGx[111]*acadoWorkspace.x[0] + acadoWorkspace.evGx[112]*acadoWorkspace.x[1] + acadoWorkspace.evGx[113]*acadoWorkspace.x[2] + acadoWorkspace.d[37]; -acadoVariables.x[41] += + acadoWorkspace.evGx[114]*acadoWorkspace.x[0] + acadoWorkspace.evGx[115]*acadoWorkspace.x[1] + acadoWorkspace.evGx[116]*acadoWorkspace.x[2] + acadoWorkspace.d[38]; -acadoVariables.x[42] += + acadoWorkspace.evGx[117]*acadoWorkspace.x[0] + acadoWorkspace.evGx[118]*acadoWorkspace.x[1] + acadoWorkspace.evGx[119]*acadoWorkspace.x[2] + acadoWorkspace.d[39]; -acadoVariables.x[43] += + acadoWorkspace.evGx[120]*acadoWorkspace.x[0] + acadoWorkspace.evGx[121]*acadoWorkspace.x[1] + acadoWorkspace.evGx[122]*acadoWorkspace.x[2] + acadoWorkspace.d[40]; -acadoVariables.x[44] += + acadoWorkspace.evGx[123]*acadoWorkspace.x[0] + acadoWorkspace.evGx[124]*acadoWorkspace.x[1] + acadoWorkspace.evGx[125]*acadoWorkspace.x[2] + acadoWorkspace.d[41]; -acadoVariables.x[45] += + acadoWorkspace.evGx[126]*acadoWorkspace.x[0] + acadoWorkspace.evGx[127]*acadoWorkspace.x[1] + acadoWorkspace.evGx[128]*acadoWorkspace.x[2] + acadoWorkspace.d[42]; -acadoVariables.x[46] += + acadoWorkspace.evGx[129]*acadoWorkspace.x[0] + acadoWorkspace.evGx[130]*acadoWorkspace.x[1] + acadoWorkspace.evGx[131]*acadoWorkspace.x[2] + acadoWorkspace.d[43]; -acadoVariables.x[47] += + acadoWorkspace.evGx[132]*acadoWorkspace.x[0] + acadoWorkspace.evGx[133]*acadoWorkspace.x[1] + acadoWorkspace.evGx[134]*acadoWorkspace.x[2] + acadoWorkspace.d[44]; -acadoVariables.x[48] += + acadoWorkspace.evGx[135]*acadoWorkspace.x[0] + acadoWorkspace.evGx[136]*acadoWorkspace.x[1] + acadoWorkspace.evGx[137]*acadoWorkspace.x[2] + acadoWorkspace.d[45]; -acadoVariables.x[49] += + acadoWorkspace.evGx[138]*acadoWorkspace.x[0] + acadoWorkspace.evGx[139]*acadoWorkspace.x[1] + acadoWorkspace.evGx[140]*acadoWorkspace.x[2] + acadoWorkspace.d[46]; -acadoVariables.x[50] += + acadoWorkspace.evGx[141]*acadoWorkspace.x[0] + acadoWorkspace.evGx[142]*acadoWorkspace.x[1] + acadoWorkspace.evGx[143]*acadoWorkspace.x[2] + acadoWorkspace.d[47]; -acadoVariables.x[51] += + acadoWorkspace.evGx[144]*acadoWorkspace.x[0] + acadoWorkspace.evGx[145]*acadoWorkspace.x[1] + acadoWorkspace.evGx[146]*acadoWorkspace.x[2] + acadoWorkspace.d[48]; -acadoVariables.x[52] += + acadoWorkspace.evGx[147]*acadoWorkspace.x[0] + acadoWorkspace.evGx[148]*acadoWorkspace.x[1] + acadoWorkspace.evGx[149]*acadoWorkspace.x[2] + acadoWorkspace.d[49]; -acadoVariables.x[53] += + acadoWorkspace.evGx[150]*acadoWorkspace.x[0] + acadoWorkspace.evGx[151]*acadoWorkspace.x[1] + acadoWorkspace.evGx[152]*acadoWorkspace.x[2] + acadoWorkspace.d[50]; -acadoVariables.x[54] += + acadoWorkspace.evGx[153]*acadoWorkspace.x[0] + acadoWorkspace.evGx[154]*acadoWorkspace.x[1] + acadoWorkspace.evGx[155]*acadoWorkspace.x[2] + acadoWorkspace.d[51]; -acadoVariables.x[55] += + acadoWorkspace.evGx[156]*acadoWorkspace.x[0] + acadoWorkspace.evGx[157]*acadoWorkspace.x[1] + acadoWorkspace.evGx[158]*acadoWorkspace.x[2] + acadoWorkspace.d[52]; -acadoVariables.x[56] += + acadoWorkspace.evGx[159]*acadoWorkspace.x[0] + acadoWorkspace.evGx[160]*acadoWorkspace.x[1] + acadoWorkspace.evGx[161]*acadoWorkspace.x[2] + acadoWorkspace.d[53]; -acadoVariables.x[57] += + acadoWorkspace.evGx[162]*acadoWorkspace.x[0] + acadoWorkspace.evGx[163]*acadoWorkspace.x[1] + acadoWorkspace.evGx[164]*acadoWorkspace.x[2] + acadoWorkspace.d[54]; -acadoVariables.x[58] += + acadoWorkspace.evGx[165]*acadoWorkspace.x[0] + acadoWorkspace.evGx[166]*acadoWorkspace.x[1] + acadoWorkspace.evGx[167]*acadoWorkspace.x[2] + acadoWorkspace.d[55]; -acadoVariables.x[59] += + acadoWorkspace.evGx[168]*acadoWorkspace.x[0] + acadoWorkspace.evGx[169]*acadoWorkspace.x[1] + acadoWorkspace.evGx[170]*acadoWorkspace.x[2] + acadoWorkspace.d[56]; -acadoVariables.x[60] += + acadoWorkspace.evGx[171]*acadoWorkspace.x[0] + acadoWorkspace.evGx[172]*acadoWorkspace.x[1] + acadoWorkspace.evGx[173]*acadoWorkspace.x[2] + acadoWorkspace.d[57]; -acadoVariables.x[61] += + acadoWorkspace.evGx[174]*acadoWorkspace.x[0] + acadoWorkspace.evGx[175]*acadoWorkspace.x[1] + acadoWorkspace.evGx[176]*acadoWorkspace.x[2] + acadoWorkspace.d[58]; -acadoVariables.x[62] += + acadoWorkspace.evGx[177]*acadoWorkspace.x[0] + acadoWorkspace.evGx[178]*acadoWorkspace.x[1] + acadoWorkspace.evGx[179]*acadoWorkspace.x[2] + acadoWorkspace.d[59]; - -acado_multEDu( acadoWorkspace.E, &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 3 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 6 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 6 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 9 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 9 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 9 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 12 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 12 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 12 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 12 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 15 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 15 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 15 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 15 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 15 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 18 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 18 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 18 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 18 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 18 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 18 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 21 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 21 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 21 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 21 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 21 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 21 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 21 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 24 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 27 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 30 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 33 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 36 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 39 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 42 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 45 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 48 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 51 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 54 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.x[ 21 ]), &(acadoVariables.x[ 57 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.x[ 21 ]), &(acadoVariables.x[ 60 ]) ); -acado_multEDu( &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.x[ 22 ]), &(acadoVariables.x[ 60 ]) ); -} - -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 * 3]; -acadoWorkspace.state[1] = acadoVariables.x[index * 3 + 1]; -acadoWorkspace.state[2] = acadoVariables.x[index * 3 + 2]; -acadoWorkspace.state[15] = acadoVariables.u[index]; -acadoWorkspace.state[16] = acadoVariables.od[index * 2]; -acadoWorkspace.state[17] = acadoVariables.od[index * 2 + 1]; - -acado_integrate(acadoWorkspace.state, index == 0, index); - -acadoVariables.x[index * 3 + 3] = acadoWorkspace.state[0]; -acadoVariables.x[index * 3 + 4] = acadoWorkspace.state[1]; -acadoVariables.x[index * 3 + 5] = acadoWorkspace.state[2]; -} -} - -void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ) -{ -int index; -for (index = 0; index < 20; ++index) -{ -acadoVariables.x[index * 3] = acadoVariables.x[index * 3 + 3]; -acadoVariables.x[index * 3 + 1] = acadoVariables.x[index * 3 + 4]; -acadoVariables.x[index * 3 + 2] = acadoVariables.x[index * 3 + 5]; -} - -if (strategy == 1 && xEnd != 0) -{ -acadoVariables.x[60] = xEnd[0]; -acadoVariables.x[61] = xEnd[1]; -acadoVariables.x[62] = xEnd[2]; -} -else if (strategy == 2) -{ -acadoWorkspace.state[0] = acadoVariables.x[60]; -acadoWorkspace.state[1] = acadoVariables.x[61]; -acadoWorkspace.state[2] = acadoVariables.x[62]; -if (uEnd != 0) -{ -acadoWorkspace.state[15] = uEnd[0]; -} -else -{ -acadoWorkspace.state[15] = acadoVariables.u[19]; -} -acadoWorkspace.state[16] = acadoVariables.od[40]; -acadoWorkspace.state[17] = acadoVariables.od[41]; - -acado_integrate(acadoWorkspace.state, 1, 19); - -acadoVariables.x[60] = acadoWorkspace.state[0]; -acadoVariables.x[61] = acadoWorkspace.state[1]; -acadoVariables.x[62] = acadoWorkspace.state[2]; -} -} - -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]; -kkt = fabs( kkt ); -for (index = 0; index < 23; ++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); -} -for (index = 0; index < 20; ++index) -{ -prd = acadoWorkspace.y[index + 23]; -if (prd > 1e-12) -kkt += fabs(acadoWorkspace.lbA[index] * prd); -else if (prd < -1e-12) -kkt += fabs(acadoWorkspace.ubA[index] * prd); -} -return kkt; -} - -real_t acado_getObjective( ) -{ -real_t objVal; - -int lRun1; -/** Row vector of size: 4 */ -real_t tmpDy[ 4 ]; - -/** Row vector of size: 3 */ -real_t tmpDyN[ 3 ]; - -for (lRun1 = 0; lRun1 < 20; ++lRun1) -{ -acadoWorkspace.objValueIn[0] = acadoVariables.x[lRun1 * 3]; -acadoWorkspace.objValueIn[1] = acadoVariables.x[lRun1 * 3 + 1]; -acadoWorkspace.objValueIn[2] = acadoVariables.x[lRun1 * 3 + 2]; -acadoWorkspace.objValueIn[3] = acadoVariables.u[lRun1]; -acadoWorkspace.objValueIn[4] = acadoVariables.od[lRun1 * 2]; -acadoWorkspace.objValueIn[5] = acadoVariables.od[lRun1 * 2 + 1]; - -acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); -acadoWorkspace.Dy[lRun1 * 4] = acadoWorkspace.objValueOut[0] - acadoVariables.y[lRun1 * 4]; -acadoWorkspace.Dy[lRun1 * 4 + 1] = acadoWorkspace.objValueOut[1] - acadoVariables.y[lRun1 * 4 + 1]; -acadoWorkspace.Dy[lRun1 * 4 + 2] = acadoWorkspace.objValueOut[2] - acadoVariables.y[lRun1 * 4 + 2]; -acadoWorkspace.Dy[lRun1 * 4 + 3] = acadoWorkspace.objValueOut[3] - acadoVariables.y[lRun1 * 4 + 3]; -} -acadoWorkspace.objValueIn[0] = acadoVariables.x[60]; -acadoWorkspace.objValueIn[1] = acadoVariables.x[61]; -acadoWorkspace.objValueIn[2] = acadoVariables.x[62]; -acadoWorkspace.objValueIn[3] = acadoVariables.od[40]; -acadoWorkspace.objValueIn[4] = acadoVariables.od[41]; -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]; -objVal = 0.0000000000000000e+00; -for (lRun1 = 0; lRun1 < 20; ++lRun1) -{ -tmpDy[0] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 4] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 8] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 12]; -tmpDy[1] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16 + 1] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 5] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 9] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 13]; -tmpDy[2] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16 + 2] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 6] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 10] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 14]; -tmpDy[3] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16 + 3] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 7] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 11] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 15]; -objVal += + acadoWorkspace.Dy[lRun1 * 4]*tmpDy[0] + acadoWorkspace.Dy[lRun1 * 4 + 1]*tmpDy[1] + acadoWorkspace.Dy[lRun1 * 4 + 2]*tmpDy[2] + acadoWorkspace.Dy[lRun1 * 4 + 3]*tmpDy[3]; -} - -tmpDyN[0] = + acadoWorkspace.DyN[0]*acadoVariables.WN[0] + acadoWorkspace.DyN[1]*acadoVariables.WN[3] + acadoWorkspace.DyN[2]*acadoVariables.WN[6]; -tmpDyN[1] = + acadoWorkspace.DyN[0]*acadoVariables.WN[1] + acadoWorkspace.DyN[1]*acadoVariables.WN[4] + acadoWorkspace.DyN[2]*acadoVariables.WN[7]; -tmpDyN[2] = + acadoWorkspace.DyN[0]*acadoVariables.WN[2] + acadoWorkspace.DyN[1]*acadoVariables.WN[5] + acadoWorkspace.DyN[2]*acadoVariables.WN[8]; -objVal += + acadoWorkspace.DyN[0]*tmpDyN[0] + acadoWorkspace.DyN[1]*tmpDyN[1] + acadoWorkspace.DyN[2]*tmpDyN[2]; - -objVal *= 0.5; -return objVal; -} - diff --git a/selfdrive/controls/lib/longitudinal_mpc/libmpc_py.py b/selfdrive/controls/lib/longitudinal_mpc/libmpc_py.py deleted file mode 100644 index 95e9135a813770..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/libmpc_py.py +++ /dev/null @@ -1,51 +0,0 @@ -import os -import platform -import subprocess - -from cffi import FFI - -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) - - ffi = FFI() - ffi.cdef(""" - typedef struct { - double x_ego, v_ego, a_ego, x_l, v_l, a_l; - } state_t; - - - typedef struct { - double x_ego[21]; - double v_ego[21]; - double a_ego[21]; - double j_ego[20]; - double x_l[21]; - double v_l[21]; - double a_l[21]; - double t[21]; - double cost; - } log_t; - - void init(double ttcCost, double distanceCost, double accelerationCost, double jerkCost); - void init_with_simulation(double v_ego, double x_l, double v_l, double a_l, double l); - int run_mpc(state_t * x0, log_t * solution, - double l, double a_l_0); - """) - - return (ffi, ffi.dlopen(libmpc_fn)) - -mpcs = [_get_libmpc(1), _get_libmpc(2)] - -def get_libmpc(mpc_id): - return mpcs[mpc_id - 1] diff --git a/selfdrive/controls/lib/longitudinal_mpc/longitudinal_mpc.c b/selfdrive/controls/lib/longitudinal_mpc/longitudinal_mpc.c deleted file mode 100644 index d4bfee8c8aac0d..00000000000000 --- a/selfdrive/controls/lib/longitudinal_mpc/longitudinal_mpc.c +++ /dev/null @@ -1,173 +0,0 @@ -#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, x_l, v_l, a_l; -} state_t; - - -typedef struct { - double x_ego[N+1]; - double v_ego[N+1]; - double a_ego[N+1]; - double j_ego[N]; - double x_l[N+1]; - double v_l[N+1]; - double a_l[N+1]; - double t[N+1]; - double cost; -} log_t; - -void init(double ttcCost, double distanceCost, double accelerationCost, 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] = ttcCost * f; // exponential cost for time-to-collision (ttc) - acadoVariables.W[NY*NY*i + (NY+1)*1] = distanceCost * f; // desired distance - acadoVariables.W[NY*NY*i + (NY+1)*2] = accelerationCost * f; // acceleration - acadoVariables.W[NY*NY*i + (NY+1)*3] = jerkCost * f; // jerk - } - acadoVariables.WN[(NYN+1)*0] = ttcCost * STEP_MULTIPLIER; // exponential cost for danger zone - acadoVariables.WN[(NYN+1)*1] = distanceCost * STEP_MULTIPLIER; // desired distance - acadoVariables.WN[(NYN+1)*2] = accelerationCost * STEP_MULTIPLIER; // acceleration - -} - -void init_with_simulation(double v_ego, double x_l_0, double v_l_0, double a_l_0, double l){ - int i; - - double x_l = x_l_0; - double v_l = v_l_0; - double a_l = a_l_0; - - double x_ego = 0.0; - double a_ego = -(v_ego - v_l) * (v_ego - v_l) / (2.0 * x_l + 0.01) + a_l; - - if (a_ego > 0){ - a_ego = 0.0; - } - - - double dt = 0.2; - double t = 0.; - - for (i = 0; i < N + 1; ++i){ - if (i > 4){ - dt = 0.6; - } - - /* printf("%.2f\t%.2f\t%.2f\t%.2f\n", t, x_ego, v_ego, a_l); */ - acadoVariables.x[i*NX] = x_ego; - acadoVariables.x[i*NX+1] = v_ego; - acadoVariables.x[i*NX+2] = a_ego; - - v_ego += a_ego * dt; - - if (v_ego <= 0.0) { - v_ego = 0.0; - a_ego = 0.0; - } - - 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 l, double a_l_0){ - // Calculate lead vehicle predictions - int i; - double t = 0.; - double dt = 0.2; - double x_l = x0->x_l; - double v_l = x0->v_l; - double a_l = a_l_0; - - /* printf("t\tx_l\t_v_l\t_al\n"); */ - for (i = 0; i < N + 1; ++i){ - if (i > 4){ - dt = 0.6; - } - - /* printf("%.2f\t%.2f\t%.2f\t%.2f\n", t, x_l, v_l, a_l); */ - - acadoVariables.od[i*NOD] = x_l; - acadoVariables.od[i*NOD+1] = v_l; - - solution->x_l[i] = x_l; - solution->v_l[i] = v_l; - solution->a_l[i] = a_l; - solution->t[i] = t; - - a_l = a_l_0 * exp(-l * t * t / 2); - x_l += v_l * dt; - v_l += a_l * dt; - if (v_l < 0.0){ - a_l = 0.0; - v_l = 0.0; - } - - t += dt; - } - - 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; - - 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]; - - 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.2 seconds. - - return acado_getNWSR(); -} diff --git a/selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore b/selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore new file mode 100644 index 00000000000000..6f09b1aa0cdb7e --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore @@ -0,0 +1,2 @@ +acados_ocp_long.json +c_generated_code/ diff --git a/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript b/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript new file mode 100644 index 00000000000000..4abe90f8f892b0 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript @@ -0,0 +1,87 @@ +Import('env', 'envCython', 'arch', 'common') + +gen = "c_generated_code" + +casadi_model = [ + f'{gen}/long_model/long_expl_ode_fun.c', + f'{gen}/long_model/long_expl_vde_forw.c', +] + +casadi_cost_y = [ + f'{gen}/long_cost/long_cost_y_fun.c', + f'{gen}/long_cost/long_cost_y_fun_jac_ut_xt.c', + f'{gen}/long_cost/long_cost_y_hess.c', +] + +casadi_cost_e = [ + f'{gen}/long_cost/long_cost_y_e_fun.c', + f'{gen}/long_cost/long_cost_y_e_fun_jac_ut_xt.c', + f'{gen}/long_cost/long_cost_y_e_hess.c', +] + +casadi_cost_0 = [ + f'{gen}/long_cost/long_cost_y_0_fun.c', + f'{gen}/long_cost/long_cost_y_0_fun_jac_ut_xt.c', + f'{gen}/long_cost/long_cost_y_0_hess.c', +] + +casadi_constraints = [ + f'{gen}/long_constraints/long_constr_h_fun.c', + f'{gen}/long_constraints/long_constr_h_fun_jac_uxt_zt.c', + f'{gen}/long_constraints/long_constr_h_e_fun.c', + f'{gen}/long_constraints/long_constr_h_e_fun_jac_uxt_zt.c', +] + +build_files = [f'{gen}/acados_solver_long.c'] + casadi_model + casadi_cost_y + casadi_cost_e + \ + casadi_cost_0 + casadi_constraints + +# extra generated files used to trigger a rebuild +generated_files = [ + f'{gen}/Makefile', + + f'{gen}/main_long.c', + f'{gen}/acados_solver_long.h', + f'{gen}/acados_solver.pxd', + + f'{gen}/long_model/long_expl_vde_adj.c', + + f'{gen}/long_model/long_model.h', + f'{gen}/long_constraints/long_h_constraint.h', + f'{gen}/long_constraints/long_h_e_constraint.h', + f'{gen}/long_cost/long_cost_y_fun.h', + f'{gen}/long_cost/long_cost_y_e_fun.h', + f'{gen}/long_cost/long_cost_y_0_fun.h', +] + build_files + +lenv = env.Clone() +lenv.Clean(generated_files, Dir(gen)) + +lenv.Command(generated_files, + ["long_mpc.py"], + f"cd {Dir('.').abspath} && python long_mpc.py") + +lenv["CFLAGS"].append("-DACADOS_WITH_QPOASES") +lenv["CXXFLAGS"].append("-DACADOS_WITH_QPOASES") +lenv["CCFLAGS"].append("-Wno-unused") +lenv["LINKFLAGS"].append("-Wl,--disable-new-dtags") +lib_solver = lenv.SharedLibrary(f"{gen}/acados_ocp_solver_long", + build_files, + LIBS=['m', 'acados', 'hpipm', 'blasfeo', 'qpOASES_e']) + +# generate cython stuff +acados_ocp_solver_pyx = File("#pyextra/acados_template/acados_ocp_solver_pyx.pyx") +acados_ocp_solver_common = File("#pyextra/acados_template/acados_solver_common.pxd") +libacados_ocp_solver_pxd = File(f'{gen}/acados_solver.pxd') +libacados_ocp_solver_c = File(f'{gen}/acados_ocp_solver_pyx.c') + +lenv2 = envCython.Clone() +lenv2["LINKFLAGS"] += [lib_solver[0].get_labspath()] +lenv2.Command(libacados_ocp_solver_c, + [acados_ocp_solver_pyx, acados_ocp_solver_common, libacados_ocp_solver_pxd], + f'cython' + \ + f' -o {libacados_ocp_solver_c.get_labspath()}' + \ + f' -I {libacados_ocp_solver_pxd.get_dir().get_labspath()}' + \ + f' -I {acados_ocp_solver_common.get_dir().get_labspath()}' + \ + f' {acados_ocp_solver_pyx.get_labspath()}') +lib_cython = lenv2.Program(f'{gen}/acados_ocp_solver_pyx.so', [libacados_ocp_solver_c]) +lenv2.Depends(lib_cython, lib_solver) diff --git a/selfdrive/controls/lib/longitudinal_mpc/__init__.py b/selfdrive/controls/lib/longitudinal_mpc_lib/__init__.py similarity index 100% rename from selfdrive/controls/lib/longitudinal_mpc/__init__.py rename to selfdrive/controls/lib/longitudinal_mpc_lib/__init__.py diff --git a/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py b/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py new file mode 100644 index 00000000000000..e0e0208d67f230 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py @@ -0,0 +1,387 @@ +#!/usr/bin/env python3 +import os +import numpy as np + +from common.realtime import sec_since_boot +from common.numpy_fast import clip, interp +from selfdrive.swaglog import cloudlog +from selfdrive.modeld.constants import index_function +from selfdrive.controls.lib.radar_helpers import _LEAD_ACCEL_TAU + +if __name__ == '__main__': # generating code + from pyextra.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver +else: + # from pyextra.acados_template import AcadosOcpSolver as AcadosOcpSolverFast + from selfdrive.controls.lib.longitudinal_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverFast # pylint: disable=no-name-in-module, import-error + +from casadi import SX, vertcat + +LONG_MPC_DIR = os.path.dirname(os.path.abspath(__file__)) +EXPORT_DIR = os.path.join(LONG_MPC_DIR, "c_generated_code") +JSON_FILE = "acados_ocp_long.json" + +SOURCES = ['lead0', 'lead1', 'cruise'] + +X_DIM = 3 +U_DIM = 1 +PARAM_DIM= 4 +COST_E_DIM = 5 +COST_DIM = COST_E_DIM + 1 +CONSTR_DIM = 4 + +X_EGO_OBSTACLE_COST = 3. +X_EGO_COST = 0. +V_EGO_COST = 0. +A_EGO_COST = 0. +J_EGO_COST = 5.0 +A_CHANGE_COST = .5 +DANGER_ZONE_COST = 100. +CRASH_DISTANCE = .5 +LIMIT_COST = 1e6 + + +# Less timestamps doesn't hurt performance and leads to +# much better convergence of the MPC with low iterations +N = 12 +MAX_T = 10.0 +T_IDXS_LST = [index_function(idx, max_val=MAX_T, max_idx=N+1) for idx in range(N+1)] + +T_IDXS = np.array(T_IDXS_LST) +T_DIFFS = np.diff(T_IDXS, prepend=[0.]) +MIN_ACCEL = -3.5 +T_FOLLOW = 1.45 +COMFORT_BRAKE = 2.5 +STOP_DISTANCE = 6.0 + +def get_stopped_equivalence_factor(v_lead): + return (v_lead**2) / (2 * COMFORT_BRAKE) + +def get_safe_obstacle_distance(v_ego): + return (v_ego**2) / (2 * COMFORT_BRAKE) + T_FOLLOW * v_ego + STOP_DISTANCE + +def desired_follow_distance(v_ego, v_lead): + return get_safe_obstacle_distance(v_ego) - get_stopped_equivalence_factor(v_lead) + + +def gen_long_model(): + model = AcadosModel() + model.name = 'long' + + # set up states & controls + x_ego = SX.sym('x_ego') + v_ego = SX.sym('v_ego') + a_ego = SX.sym('a_ego') + model.x = vertcat(x_ego, v_ego, a_ego) + + # controls + j_ego = SX.sym('j_ego') + model.u = vertcat(j_ego) + + # xdot + x_ego_dot = SX.sym('x_ego_dot') + v_ego_dot = SX.sym('v_ego_dot') + a_ego_dot = SX.sym('a_ego_dot') + model.xdot = vertcat(x_ego_dot, v_ego_dot, a_ego_dot) + + # live parameters + x_obstacle = SX.sym('x_obstacle') + a_min = SX.sym('a_min') + a_max = SX.sym('a_max') + prev_a = SX.sym('prev_a') + model.p = vertcat(a_min, a_max, x_obstacle, prev_a) + + # dynamics model + f_expl = vertcat(v_ego, a_ego, j_ego) + model.f_impl_expr = model.xdot - f_expl + model.f_expl_expr = f_expl + return model + + +def gen_long_mpc_solver(): + ocp = AcadosOcp() + ocp.model = gen_long_model() + + Tf = T_IDXS[-1] + + # set dimensions + ocp.dims.N = N + + # set cost module + ocp.cost.cost_type = 'NONLINEAR_LS' + ocp.cost.cost_type_e = 'NONLINEAR_LS' + + QR = np.zeros((COST_DIM, COST_DIM)) + Q = np.zeros((COST_E_DIM, COST_E_DIM)) + + ocp.cost.W = QR + ocp.cost.W_e = Q + + x_ego, v_ego, a_ego = ocp.model.x[0], ocp.model.x[1], ocp.model.x[2] + j_ego = ocp.model.u[0] + + a_min, a_max = ocp.model.p[0], ocp.model.p[1] + x_obstacle = ocp.model.p[2] + prev_a = ocp.model.p[3] + + ocp.cost.yref = np.zeros((COST_DIM, )) + ocp.cost.yref_e = np.zeros((COST_E_DIM, )) + + desired_dist_comfort = get_safe_obstacle_distance(v_ego) + + # The main cost in normal operation is how close you are to the "desired" distance + # from an obstacle at every timestep. This obstacle can be a lead car + # or other object. In e2e mode we can use x_position targets as a cost + # instead. + costs = [((x_obstacle - x_ego) - (desired_dist_comfort)) / (v_ego + 10.), + x_ego, + v_ego, + a_ego, + 20*(a_ego - prev_a), + j_ego] + ocp.model.cost_y_expr = vertcat(*costs) + ocp.model.cost_y_expr_e = vertcat(*costs[:-1]) + + # Constraints on speed, acceleration and desired distance to + # the obstacle, which is treated as a slack constraint so it + # behaves like an assymetrical cost. + constraints = vertcat((v_ego), + (a_ego - a_min), + (a_max - a_ego), + ((x_obstacle - x_ego) - (3/4) * (desired_dist_comfort)) / (v_ego + 10.)) + ocp.model.con_h_expr = constraints + ocp.model.con_h_expr_e = vertcat(np.zeros(CONSTR_DIM)) + + x0 = np.zeros(X_DIM) + ocp.constraints.x0 = x0 + ocp.parameter_values = np.array([-1.2, 1.2, 0.0, 0.0]) + + # We put all constraint cost weights to 0 and only set them at runtime + cost_weights = np.zeros(CONSTR_DIM) + ocp.cost.zl = cost_weights + ocp.cost.Zl = cost_weights + ocp.cost.Zu = cost_weights + ocp.cost.zu = cost_weights + + ocp.constraints.lh = np.zeros(CONSTR_DIM) + ocp.constraints.lh_e = np.zeros(CONSTR_DIM) + ocp.constraints.uh = 1e4*np.ones(CONSTR_DIM) + ocp.constraints.uh_e = 1e4*np.ones(CONSTR_DIM) + ocp.constraints.idxsh = np.arange(CONSTR_DIM) + + # The HPIPM solver can give decent solutions even when it is stopped early + # Which is critical for our purpose where the compute time is strictly bounded + # We use HPIPM in the SPEED_ABS mode, which ensures fastest runtime. This + # does not cause issues since the problem is well bounded. + ocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM' + ocp.solver_options.hessian_approx = 'GAUSS_NEWTON' + ocp.solver_options.integrator_type = 'ERK' + ocp.solver_options.nlp_solver_type = 'SQP_RTI' + ocp.solver_options.qp_solver_cond_N = N//4 + + # More iterations take too much time and less lead to inaccurate convergence in + # some situations. Ideally we would run just 1 iteration to ensure fixed runtime. + ocp.solver_options.qp_solver_iter_max = 10 + + # set prediction horizon + ocp.solver_options.tf = Tf + ocp.solver_options.shooting_nodes = T_IDXS + + ocp.code_export_directory = EXPORT_DIR + return ocp + + +class LongitudinalMpc(): + def __init__(self, e2e=False): + self.e2e = e2e + self.reset() + self.accel_limit_arr = np.zeros((N+1, 2)) + self.accel_limit_arr[:,0] = -1.2 + self.accel_limit_arr[:,1] = 1.2 + self.source = SOURCES[2] + + def reset(self): + self.solver = AcadosOcpSolverFast('long', N, EXPORT_DIR) + self.v_solution = [0.0 for i in range(N+1)] + self.a_solution = [0.0 for i in range(N+1)] + self.prev_a = np.array(self.a_solution) + self.j_solution = [0.0 for i in range(N)] + self.yref = np.zeros((N+1, COST_DIM)) + for i in range(N): + self.solver.cost_set(i, "yref", self.yref[i]) + self.solver.cost_set(N, "yref", self.yref[N][:COST_E_DIM]) + self.x_sol = np.zeros((N+1, X_DIM)) + self.u_sol = np.zeros((N,1)) + self.params = np.zeros((N+1, PARAM_DIM)) + for i in range(N+1): + self.solver.set(i, 'x', np.zeros(X_DIM)) + self.last_cloudlog_t = 0 + self.status = False + self.crash_cnt = 0.0 + self.solution_status = 0 + self.x0 = np.zeros(X_DIM) + self.set_weights() + + def set_weights(self): + if self.e2e: + self.set_weights_for_xva_policy() + else: + self.set_weights_for_lead_policy() + + def set_weights_for_lead_policy(self): + W = np.asfortranarray(np.diag([X_EGO_OBSTACLE_COST, X_EGO_COST, V_EGO_COST, A_EGO_COST, A_CHANGE_COST, J_EGO_COST])) + for i in range(N): + W[4,4] = A_CHANGE_COST * np.interp(T_IDXS[i], [0.0, 1.0, 2.0], [1.0, 1.0, 0.0]) + self.solver.cost_set(i, 'W', W) + # Setting the slice without the copy make the array not contiguous, + # causing issues with the C interface. + self.solver.cost_set(N, 'W', np.copy(W[:COST_E_DIM, :COST_E_DIM])) + + # Set L2 slack cost on lower bound constraints + Zl = np.array([LIMIT_COST, LIMIT_COST, LIMIT_COST, DANGER_ZONE_COST]) + for i in range(N): + self.solver.cost_set(i, 'Zl', Zl) + + def set_weights_for_xva_policy(self): + W = np.asfortranarray(np.diag([0., 10., 1., 10., 0.0, 1.])) + for i in range(N): + self.solver.cost_set(i, 'W', W) + # Setting the slice without the copy make the array not contiguous, + # causing issues with the C interface. + self.solver.cost_set(N, 'W', np.copy(W[:COST_E_DIM, :COST_E_DIM])) + + # Set L2 slack cost on lower bound constraints + Zl = np.array([LIMIT_COST, LIMIT_COST, LIMIT_COST, 0.0]) + for i in range(N): + self.solver.cost_set(i, 'Zl', Zl) + + def set_cur_state(self, v, a): + if abs(self.x0[1] - v) > 2.: + self.x0[1] = v + self.x0[2] = a + for i in range(0, N+1): + self.solver.set(i, 'x', self.x0) + else: + self.x0[1] = v + self.x0[2] = a + + def extrapolate_lead(self, x_lead, v_lead, a_lead, a_lead_tau): + a_lead_traj = a_lead * np.exp(-a_lead_tau * (T_IDXS**2)/2.) + v_lead_traj = np.clip(v_lead + np.cumsum(T_DIFFS * a_lead_traj), 0.0, 1e8) + x_lead_traj = x_lead + np.cumsum(T_DIFFS * v_lead_traj) + lead_xv = np.column_stack((x_lead_traj, v_lead_traj)) + return lead_xv + + def process_lead(self, lead): + v_ego = self.x0[1] + if lead is not None and lead.status: + x_lead = lead.dRel + v_lead = lead.vLead + a_lead = lead.aLeadK + a_lead_tau = lead.aLeadTau + else: + # Fake a fast lead car, so mpc can keep running in the same mode + x_lead = 50.0 + v_lead = v_ego + 10.0 + a_lead = 0.0 + a_lead_tau = _LEAD_ACCEL_TAU + + # MPC will not converge if immediate crash is expected + # Clip lead distance to what is still possible to brake for + min_x_lead = ((v_ego + v_lead)/2) * (v_ego - v_lead) / (-MIN_ACCEL * 2) + x_lead = clip(x_lead, min_x_lead, 1e8) + v_lead = clip(v_lead, 0.0, 1e8) + a_lead = clip(a_lead, -10., 5.) + lead_xv = self.extrapolate_lead(x_lead, v_lead, a_lead, a_lead_tau) + return lead_xv + + def set_accel_limits(self, min_a, max_a): + self.cruise_min_a = min_a + self.cruise_max_a = max_a + + def update(self, carstate, radarstate, v_cruise, prev_accel_constraint=False): + v_ego = self.x0[1] + a_ego = self.x0[2] + self.status = radarstate.leadOne.status or radarstate.leadTwo.status + + lead_xv_0 = self.process_lead(radarstate.leadOne) + lead_xv_1 = self.process_lead(radarstate.leadTwo) + + # set accel limits in params + self.params[:,0] = interp(float(self.status), [0.0, 1.0], [self.cruise_min_a, MIN_ACCEL]) + self.params[:,1] = self.cruise_max_a + + # To estimate a safe distance from a moving lead, we calculate how much stopping + # distance that lead needs as a minimum. We can add that to the current distance + # and then treat that as a stopped car/obstacle at this new distance. + lead_0_obstacle = lead_xv_0[:,0] + get_stopped_equivalence_factor(lead_xv_0[:,1]) + lead_1_obstacle = lead_xv_1[:,0] + get_stopped_equivalence_factor(lead_xv_1[:,1]) + + # Fake an obstacle for cruise, this ensures smooth acceleration to set speed + # when the leads are no factor. + v_lower = v_ego + (T_IDXS * self.cruise_min_a * 1.05) + v_upper = v_ego + (T_IDXS * self.cruise_max_a * 1.05) + v_cruise_clipped = np.clip(v_cruise * np.ones(N+1), + v_lower, + v_upper) + cruise_obstacle = np.cumsum(T_DIFFS * v_cruise_clipped) + get_safe_obstacle_distance(v_cruise_clipped) + + x_obstacles = np.column_stack([lead_0_obstacle, lead_1_obstacle, cruise_obstacle]) + self.source = SOURCES[np.argmin(x_obstacles[0])] + self.params[:,2] = np.min(x_obstacles, axis=1) + if prev_accel_constraint: + self.params[:,3] = np.copy(self.prev_a) + else: + self.params[:,3] = a_ego + + self.run() + if (np.any(lead_xv_0[:,0] - self.x_sol[:,0] < CRASH_DISTANCE) and + radarstate.leadOne.modelProb > 0.9): + self.crash_cnt += 1 + else: + self.crash_cnt = 0 + + def update_with_xva(self, x, v, a): + self.yref[:,1] = x + self.yref[:,2] = v + self.yref[:,3] = a + for i in range(N): + self.solver.cost_set(i, "yref", self.yref[i]) + self.solver.cost_set(N, "yref", self.yref[N][:COST_E_DIM]) + self.accel_limit_arr[:,0] = -10. + self.accel_limit_arr[:,1] = 10. + x_obstacle = 1e5*np.ones((N+1)) + self.params = np.concatenate([self.accel_limit_arr, + x_obstacle[:,None], + self.prev_a[:,None]], axis=1) + self.run() + + + def run(self): + for i in range(N+1): + self.solver.set(i, 'p', self.params[i]) + self.solver.constraints_set(0, "lbx", self.x0) + self.solver.constraints_set(0, "ubx", self.x0) + self.solution_status = self.solver.solve() + for i in range(N+1): + self.x_sol[i] = self.solver.get(i, 'x') + for i in range(N): + self.u_sol[i] = self.solver.get(i, 'u') + + self.v_solution = self.x_sol[:,1] + self.a_solution = self.x_sol[:,2] + self.j_solution = self.u_sol[:,0] + + self.prev_a = np.interp(T_IDXS + 0.05, T_IDXS, self.a_solution) + + t = sec_since_boot() + if self.solution_status != 0: + if t > self.last_cloudlog_t + 5.0: + self.last_cloudlog_t = t + cloudlog.warning("Long mpc reset, solution_status: %s" % ( + self.solution_status)) + self.reset() + + +if __name__ == "__main__": + ocp = gen_long_mpc_solver() + AcadosOcpSolver.generate(ocp, json_file=JSON_FILE, build=False) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py new file mode 100755 index 00000000000000..41bae4c47518b8 --- /dev/null +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +import math +import numpy as np +from common.numpy_fast import interp + +import cereal.messaging as messaging +from common.realtime import DT_MDL +from selfdrive.modeld.constants import T_IDXS +from selfdrive.config import Conversions as CV +from selfdrive.controls.lib.longcontrol import LongCtrlState +from selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import LongitudinalMpc +from selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import T_IDXS as T_IDXS_MPC +from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, CONTROL_N +from selfdrive.swaglog import cloudlog + +LON_MPC_STEP = 0.2 # first step is 0.2s +AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted +A_CRUISE_MIN = -1.2 +A_CRUISE_MAX_VALS = [1.2, 1.2, 0.8, 0.6] +A_CRUISE_MAX_BP = [0., 15., 25., 40.] + +# Lookup table for turns +_A_TOTAL_MAX_V = [1.7, 3.2] +_A_TOTAL_MAX_BP = [20., 40.] + + +def get_max_accel(v_ego): + return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS) + + +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.)) + + return [a_target[0], min(a_target[1], a_x_allowed)] + + +class Planner: + def __init__(self, CP, init_v=0.0, init_a=0.0): + self.CP = CP + self.mpc = LongitudinalMpc() + + self.fcw = False + + self.v_desired = init_v + self.a_desired = init_a + self.alpha = np.exp(-DT_MDL / 2.0) + + self.v_desired_trajectory = np.zeros(CONTROL_N) + self.a_desired_trajectory = np.zeros(CONTROL_N) + self.j_desired_trajectory = np.zeros(CONTROL_N) + + def update(self, sm): + v_ego = sm['carState'].vEgo + a_ego = sm['carState'].aEgo + + v_cruise_kph = sm['controlsState'].vCruise + v_cruise_kph = min(v_cruise_kph, V_CRUISE_MAX) + v_cruise = v_cruise_kph * CV.KPH_TO_MS + + long_control_state = sm['controlsState'].longControlState + force_slow_decel = sm['controlsState'].forceDecel + + prev_accel_constraint = True + if long_control_state == LongCtrlState.off or sm['carState'].gasPressed: + self.v_desired = v_ego + self.a_desired = a_ego + # Smoothly changing between accel trajectory is only relevant when OP is driving + prev_accel_constraint = False + + # Prevent divergence, smooth in current v_ego + self.v_desired = self.alpha * self.v_desired + (1 - self.alpha) * v_ego + self.v_desired = max(0.0, self.v_desired) + + accel_limits = [A_CRUISE_MIN, get_max_accel(v_ego)] + accel_limits_turns = limit_accel_in_turns(v_ego, sm['carState'].steeringAngleDeg, accel_limits, self.CP) + if force_slow_decel: + # if required so, force a smooth deceleration + accel_limits_turns[1] = min(accel_limits_turns[1], AWARENESS_DECEL) + accel_limits_turns[0] = min(accel_limits_turns[0], accel_limits_turns[1]) + # clip limits, cannot init MPC outside of bounds + accel_limits_turns[0] = min(accel_limits_turns[0], self.a_desired + 0.05) + accel_limits_turns[1] = max(accel_limits_turns[1], self.a_desired - 0.05) + self.mpc.set_accel_limits(accel_limits_turns[0], accel_limits_turns[1]) + self.mpc.set_cur_state(self.v_desired, self.a_desired) + self.mpc.update(sm['carState'], sm['radarState'], v_cruise, prev_accel_constraint=prev_accel_constraint) + self.v_desired_trajectory = np.interp(T_IDXS[:CONTROL_N], T_IDXS_MPC, self.mpc.v_solution) + self.a_desired_trajectory = np.interp(T_IDXS[:CONTROL_N], T_IDXS_MPC, self.mpc.a_solution) + self.j_desired_trajectory = np.interp(T_IDXS[:CONTROL_N], T_IDXS_MPC[:-1], self.mpc.j_solution) + + # TODO counter is only needed because radar is glitchy, remove once radar is gone + self.fcw = self.mpc.crash_cnt > 5 + if self.fcw: + cloudlog.info("FCW triggered") + + # Interpolate 0.05 seconds and save as starting point for next iteration + a_prev = self.a_desired + self.a_desired = float(interp(DT_MDL, T_IDXS[:CONTROL_N], self.a_desired_trajectory)) + self.v_desired = self.v_desired + DT_MDL * (self.a_desired + a_prev) / 2.0 + + def publish(self, sm, pm): + plan_send = messaging.new_message('longitudinalPlan') + + plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState']) + + longitudinalPlan = plan_send.longitudinalPlan + longitudinalPlan.modelMonoTime = sm.logMonoTime['modelV2'] + longitudinalPlan.processingDelay = (plan_send.logMonoTime / 1e9) - sm.logMonoTime['modelV2'] + + longitudinalPlan.speeds = [float(x) for x in self.v_desired_trajectory] + longitudinalPlan.accels = [float(x) for x in self.a_desired_trajectory] + longitudinalPlan.jerks = [float(x) for x in self.j_desired_trajectory] + + longitudinalPlan.hasLead = sm['radarState'].leadOne.status + longitudinalPlan.longitudinalPlanSource = self.mpc.source + longitudinalPlan.fcw = self.fcw + + pm.send('longitudinalPlan', plan_send) diff --git a/selfdrive/controls/lib/model_parser.py b/selfdrive/controls/lib/model_parser.py deleted file mode 100644 index 9b28c66bb9da48..00000000000000 --- a/selfdrive/controls/lib/model_parser.py +++ /dev/null @@ -1,66 +0,0 @@ -from common.numpy_fast import interp -import numpy as np -from selfdrive.controls.lib.latcontrol_helpers import model_polyfit, calc_desired_path, compute_path_pinv - -CAMERA_OFFSET = 0.06 # m from center car to camera - - -class ModelParser(object): - def __init__(self): - self.d_poly = [0., 0., 0., 0.] - self.c_poly = [0., 0., 0., 0.] - self.c_prob = 0. - self.last_model = 0. - self.lead_dist, self.lead_prob, self.lead_var = 0, 0, 1 - self._path_pinv = compute_path_pinv() - - self.lane_width_estimate = 3.7 - self.lane_width_certainty = 1.0 - self.lane_width = 3.7 - self.l_prob = 0. - self.r_prob = 0. - self.x_points = np.arange(50) - - def update(self, v_ego, md): - if len(md.leftLane.poly): - l_poly = np.array(md.leftLane.poly) - r_poly = np.array(md.rightLane.poly) - p_poly = np.array(md.path.poly) - else: - l_poly = model_polyfit(md.leftLane.points, self._path_pinv) # left line - r_poly = model_polyfit(md.rightLane.points, self._path_pinv) # right line - p_poly = model_polyfit(md.path.points, self._path_pinv) # predicted path - - # only offset left and right lane lines; offsetting p_poly does not make sense - l_poly[3] += CAMERA_OFFSET - r_poly[3] += CAMERA_OFFSET - - p_prob = 1. # model does not tell this probability yet, so set to 1 for now - l_prob = md.leftLane.prob # left line prob - r_prob = md.rightLane.prob # right line prob - - # Find current lanewidth - lr_prob = l_prob * r_prob - self.lane_width_certainty += 0.05 * (lr_prob - self.lane_width_certainty) - current_lane_width = abs(l_poly[3] - 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 - - self.lead_dist = md.lead.dist - self.lead_prob = md.lead.prob - self.lead_var = md.lead.std**2 - - # compute target path - self.d_poly, self.c_poly, self.c_prob = calc_desired_path( - l_poly, r_poly, p_poly, l_prob, r_prob, p_prob, v_ego, self.lane_width) - - self.r_poly = r_poly - self.r_prob = r_prob - - self.l_poly = l_poly - self.l_prob = l_prob - - self.p_poly = p_poly - self.p_prob = p_prob diff --git a/selfdrive/controls/lib/pathplanner.py b/selfdrive/controls/lib/pathplanner.py deleted file mode 100644 index cbd144edcd1b37..00000000000000 --- a/selfdrive/controls/lib/pathplanner.py +++ /dev/null @@ -1,140 +0,0 @@ -import os -import math -import numpy as np - -from common.realtime import sec_since_boot -from selfdrive.services import service_list -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.model_parser import ModelParser -import selfdrive.messaging as messaging - -LOG_MPC = os.environ.get('LOG_MPC', False) - - -def calc_states_after_delay(states, v_ego, steer_angle, curvature_factor, steer_ratio, delay): - states[0].x = v_ego * delay - states[0].psi = v_ego * curvature_factor * math.radians(steer_angle) / steer_ratio * delay - return states - - -class PathPlanner(object): - def __init__(self, CP): - self.MP = ModelParser() - - self.l_poly = [0., 0., 0., 0.] - self.r_poly = [0., 0., 0., 0.] - - self.last_cloudlog_t = 0 - - self.plan = messaging.pub_sock(service_list['pathPlan'].port) - self.livempc = messaging.pub_sock(service_list['liveMpc'].port) - - self.setup_mpc(CP.steerRateCost) - self.solution_invalid_cnt = 0 - - def setup_mpc(self, steer_rate_cost): - self.libmpc = libmpc_py.libmpc - self.libmpc.init(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, steer_rate_cost) - - self.mpc_solution = libmpc_py.ffi.new("log_t *") - self.cur_state = libmpc_py.ffi.new("state_t *") - self.cur_state[0].x = 0.0 - self.cur_state[0].y = 0.0 - self.cur_state[0].psi = 0.0 - self.cur_state[0].delta = 0.0 - - self.angle_steers_des = 0.0 - self.angle_steers_des_mpc = 0.0 - self.angle_steers_des_prev = 0.0 - self.angle_steers_des_time = 0.0 - - self.l_poly = libmpc_py.ffi.new("double[4]") - self.r_poly = libmpc_py.ffi.new("double[4]") - self.p_poly = libmpc_py.ffi.new("double[4]") - - def update(self, sm, CP, VM): - v_ego = sm['carState'].vEgo - angle_steers = sm['carState'].steeringAngle - active = sm['controlsState'].active - - angle_offset_average = sm['liveParameters'].angleOffsetAverage - angle_offset_bias = sm['controlsState'].angleModelBias + angle_offset_average - - self.MP.update(v_ego, sm['model']) - - # Run MPC - self.angle_steers_des_prev = self.angle_steers_des_mpc - VM.update_params(sm['liveParameters'].stiffnessFactor, sm['liveParameters'].steerRatio) - curvature_factor = VM.curvature_factor(v_ego) - self.l_poly = list(self.MP.l_poly) - self.r_poly = list(self.MP.r_poly) - self.p_poly = list(self.MP.p_poly) - - # account for actuation delay - self.cur_state = calc_states_after_delay(self.cur_state, v_ego, angle_steers - angle_offset_average, 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, - self.l_poly, self.r_poly, self.p_poly, - self.MP.l_prob, self.MP.r_prob, self.MP.p_prob, curvature_factor, v_ego_mpc, self.MP.lane_width) - - # reset to current steer angle if not active or overriding - if active: - delta_desired = self.mpc_solution[0].delta[1] - rate_desired = math.degrees(self.mpc_solution[0].rate[0] * VM.sR) - else: - delta_desired = math.radians(angle_steers - angle_offset_bias) / VM.sR - rate_desired = 0.0 - - self.cur_state[0].delta = delta_desired - - self.angle_steers_des_mpc = float(math.degrees(delta_desired * VM.sR) + angle_offset_bias) - - # Check for infeasable MPC solution - mpc_nans = np.any(np.isnan(list(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) - self.cur_state[0].delta = math.radians(angle_steers - angle_offset_bias) / VM.sR - - if t > self.last_cloudlog_t + 5.0: - self.last_cloudlog_t = t - cloudlog.warning("Lateral mpc - nan: True") - - if self.mpc_solution[0].cost > 20000. or mpc_nans: # TODO: find a better way to detect when MPC did not converge - self.solution_invalid_cnt += 1 - else: - self.solution_invalid_cnt = 0 - plan_solution_valid = self.solution_invalid_cnt < 2 - - plan_send = messaging.new_message() - plan_send.init('pathPlan') - plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState', 'liveParameters', 'model']) - plan_send.pathPlan.laneWidth = float(self.MP.lane_width) - plan_send.pathPlan.dPoly = [float(x) for x in self.MP.d_poly] - plan_send.pathPlan.cPoly = [float(x) for x in self.MP.c_poly] - plan_send.pathPlan.cProb = float(self.MP.c_prob) - plan_send.pathPlan.lPoly = [float(x) for x in self.l_poly] - plan_send.pathPlan.lProb = float(self.MP.l_prob) - plan_send.pathPlan.rPoly = [float(x) for x in self.r_poly] - plan_send.pathPlan.rProb = float(self.MP.r_prob) - plan_send.pathPlan.angleSteers = float(self.angle_steers_des_mpc) - plan_send.pathPlan.rateSteers = float(rate_desired) - plan_send.pathPlan.angleOffset = float(angle_offset_average) - plan_send.pathPlan.mpcSolutionValid = bool(plan_solution_valid) - plan_send.pathPlan.paramsValid = bool(sm['liveParameters'].valid) - plan_send.pathPlan.sensorValid = bool(sm['liveParameters'].sensorValid) - - self.plan.send(plan_send.to_bytes()) - - if LOG_MPC: - dat = messaging.new_message() - dat.init('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()) diff --git a/selfdrive/controls/lib/pid.py b/selfdrive/controls/lib/pid.py index b68dc3810eef4b..e384aaaedf1d2d 100644 --- a/selfdrive/controls/lib/pid.py +++ b/selfdrive/controls/lib/pid.py @@ -1,4 +1,6 @@ import numpy as np +from numbers import Number + from common.numpy_fast import clip, interp def apply_deadzone(error, deadzone): @@ -10,11 +12,15 @@ def apply_deadzone(error, deadzone): error = 0. return error -class PIController(object): - 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_f = k_f # feedforward gain +class PIController(): + def __init__(self, k_p, k_i, k_f=1., pos_limit=None, neg_limit=None, rate=100, sat_limit=0.8): + self._k_p = k_p # proportional gain + self._k_i = k_i # integral gain + self.k_f = k_f # feedforward gain + if isinstance(self._k_p, Number): + self._k_p = [[0], [self._k_p]] + if isinstance(self._k_i, Number): + self._k_i = [[0], [self._k_i]] self.pos_limit = pos_limit self.neg_limit = neg_limit @@ -23,7 +29,6 @@ def __init__(self, k_p, k_i, k_f=1., pos_limit=None, neg_limit=None, rate=100, s self.i_unwind_rate = 0.3 / rate self.i_rate = 1.0 / rate self.sat_limit = sat_limit - self.convert = convert self.reset() @@ -35,10 +40,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 @@ -68,24 +73,15 @@ def update(self, setpoint, measurement, speed=0.0, check_saturation=True, overri i = self.i + error * self.k_i * self.i_rate control = self.p + self.f + i - if self.convert is not None: - control = self.convert(control, speed=self.speed) - # 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 control = self.p + self.f + self.i - 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 diff --git a/selfdrive/controls/lib/planner.py b/selfdrive/controls/lib/planner.py deleted file mode 100755 index 9aaec513bee969..00000000000000 --- a/selfdrive/controls/lib/planner.py +++ /dev/null @@ -1,257 +0,0 @@ -#!/usr/bin/env python -import zmq -import math -import numpy as np -from common.params import Params -from common.numpy_fast import interp - -import selfdrive.messaging as messaging -from cereal import car -from common.realtime import sec_since_boot, DT_PLAN -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.fcw import FCWChecker -from selfdrive.controls.lib.long_mpc import LongitudinalMpc - -NO_CURVATURE_SPEED = 200. * CV.MPH_TO_MS - -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 -_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 -_A_CRUISE_MAX_V = [1.1, 1.1, .8, .5, .3] -_A_CRUISE_MAX_V_FOLLOWING = [1.6, 1.6, 1.2, .7, .3] -_A_CRUISE_MAX_BP = [0., 5., 10., 20., 40.] - -# Lookup table for turns -_A_TOTAL_MAX_V = [1.5, 1.9, 3.2] -_A_TOTAL_MAX_BP = [0., 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) - 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.)) - - a_target[1] = min(a_target[1], a_x_allowed) - return a_target - - -class Planner(object): - def __init__(self, CP, fcw_enabled): - self.CP = CP - self.poller = zmq.Poller() - - 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.v_acc_start = 0.0 - self.a_acc_start = 0.0 - - self.v_acc = 0.0 - self.v_acc_future = 0.0 - self.a_acc = 0.0 - self.v_cruise = 0.0 - self.a_cruise = 0.0 - - self.longitudinalPlanSource = 'cruise' - self.fcw_checker = FCWChecker() - self.fcw_enabled = fcw_enabled - - self.params = Params() - - def choose_solution(self, v_cruise_setpoint, enabled): - if enabled: - solutions = {'cruise': self.v_cruise} - if self.mpc1.prev_lead_status: - solutions['mpc1'] = self.mpc1.v_mpc - if self.mpc2.prev_lead_status: - solutions['mpc2'] = self.mpc2.v_mpc - - slowest = min(solutions, key=solutions.get) - - self.longitudinalPlanSource = slowest - - # Choose lowest of MPC and cruise - if slowest == 'mpc1': - self.v_acc = self.mpc1.v_mpc - self.a_acc = self.mpc1.a_mpc - elif slowest == 'mpc2': - self.v_acc = self.mpc2.v_mpc - self.a_acc = self.mpc2.a_mpc - elif slowest == 'cruise': - self.v_acc = self.v_cruise - self.a_acc = self.a_cruise - - 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, live_map_data): - """Gets called when new radarState is available""" - cur_time = sec_since_boot() - v_ego = sm['carState'].vEgo - - long_control_state = sm['controlsState'].longControlState - v_cruise_kph = sm['controlsState'].vCruise - force_slow_decel = sm['controlsState'].forceDecel - v_cruise_setpoint = v_cruise_kph * CV.KPH_TO_MS - - lead_1 = sm['radarState'].leadOne - lead_2 = sm['radarState'].leadTwo - - 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 - - v_speedlimit = NO_CURVATURE_SPEED - v_curvature = NO_CURVATURE_SPEED - - #map_age = cur_time - rcv_times['liveMapData'] - map_valid = False # live_map_data.liveMapData.mapValid and map_age < 10.0 - - # Speed limit and curvature - set_speed_limit_active = self.params.get("LimitSetSpeed") == "1" and self.params.get("SpeedLimitOffset") is not None - if set_speed_limit_active and map_valid: - if live_map_data.liveMapData.speedLimitValid: - speed_limit = live_map_data.liveMapData.speedLimit - offset = float(self.params.get("SpeedLimitOffset")) - v_speedlimit = speed_limit + offset - - if live_map_data.liveMapData.curvatureValid: - curvature = abs(live_map_data.liveMapData.curvature) - a_y_max = 2.975 - v_ego * 0.0375 # ~1.85 @ 75mph, ~2.6 @ 25mph - v_curvature = math.sqrt(a_y_max / max(1e-4, curvature)) - v_curvature = min(NO_CURVATURE_SPEED, v_curvature) - - decel_for_turn = bool(v_curvature < min([v_cruise_setpoint, v_speedlimit, v_ego + 1.])) - v_cruise_setpoint = min([v_cruise_setpoint, v_curvature, v_speedlimit]) - - # Calculate speed for normal cruise control - if enabled: - accel_limits = [float(x) for x in calc_cruise_accel_limits(v_ego, following)] - jerk_limits = [min(-0.1, accel_limits[0]), max(0.1, accel_limits[1])] # TODO: make a separate lookup for jerk tuning - accel_limits = limit_accel_in_turns(v_ego, sm['carState'].steeringAngle, accel_limits, self.CP) - - if force_slow_decel: - # if required so, force a smooth deceleration - accel_limits[1] = min(accel_limits[1], AWARENESS_DECEL) - accel_limits[0] = min(accel_limits[0], accel_limits[1]) - - # Change accel limits based on time remaining to turn - if decel_for_turn: - time_to_turn = max(1.0, live_map_data.liveMapData.distToTurn / max(self.v_cruise, 1.)) - required_decel = min(0, (v_curvature - self.v_cruise) / time_to_turn) - accel_limits[0] = max(accel_limits[0], required_decel) - - self.v_cruise, self.a_cruise = speed_smoother(self.v_acc_start, self.a_acc_start, - v_cruise_setpoint, - accel_limits[1], accel_limits[0], - 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_accel = self.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.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.choose_solution(v_cruise_setpoint, enabled) - - # determine fcw - if self.mpc1.new_lead: - self.fcw_checker.reset_lead(cur_time) - - blinkers = sm['carState'].leftBlinker or sm['carState'].rightBlinker - fcw = self.fcw_checker.update(self.mpc1.mpc_solution, cur_time, v_ego, sm['carState'].aEgo, - lead_1.dRel, lead_1.vLead, lead_1.aLeadK, - lead_1.yRel, lead_1.vLat, - lead_1.fcw, blinkers) and not sm['carState'].brakePressed - if fcw: - cloudlog.info("FCW triggered %s", self.fcw_checker.counters) - - radar_dead = not sm.alive['radarState'] - - radar_errors = list(sm['radarState'].radarErrors) - radar_fault = car.RadarData.Error.fault in radar_errors - radar_can_error = car.RadarData.Error.canError in radar_errors - - # **** send the plan **** - plan_send = messaging.new_message() - plan_send.init('plan') - - plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState', 'radarState']) - - plan_send.plan.mdMonoTime = sm.logMonoTime['model'] - plan_send.plan.radarStateMonoTime = sm.logMonoTime['radarState'] - - # longitudal plan - plan_send.plan.vCruise = self.v_cruise - plan_send.plan.aCruise = self.a_cruise - plan_send.plan.vStart = self.v_acc_start - plan_send.plan.aStart = self.a_acc_start - plan_send.plan.vTarget = self.v_acc - plan_send.plan.aTarget = self.a_acc - plan_send.plan.vTargetFuture = self.v_acc_future - plan_send.plan.hasLead = self.mpc1.prev_lead_status - plan_send.plan.longitudinalPlanSource = self.longitudinalPlanSource - - plan_send.plan.vCurvature = v_curvature - plan_send.plan.decelForTurn = decel_for_turn - plan_send.plan.mapValid = map_valid - - radar_valid = not (radar_dead or radar_fault) - plan_send.plan.radarValid = bool(radar_valid) - plan_send.plan.radarCanError = bool(radar_can_error) - - 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()) - - # 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 - self.v_acc_start = v_acc_sol - self.a_acc_start = a_acc_sol diff --git a/selfdrive/controls/lib/radar_helpers.py b/selfdrive/controls/lib/radar_helpers.py index 7efb9f334d7af5..01498fa1388552 100644 --- a/selfdrive/controls/lib/radar_helpers.py +++ b/selfdrive/controls/lib/radar_helpers.py @@ -1,128 +1,62 @@ -import numpy as np - -from common.numpy_fast import clip, interp +from common.numpy_fast import mean from common.kalman.simple_kalman import KF1D +from selfdrive.config import RADAR_TO_CAMERA + +# the longer lead decels, the more likely it will keep decelerating +# TODO is this a good default? _LEAD_ACCEL_TAU = 1.5 -NO_FUSION_SCORE = 100 # bad default fusion score # radar tracks SPEED, ACCEL = 0, 1 # Kalman filter states enum -rate, ratev = 20., 20. # model and radar are both at 20Hz -ts = 1./rate -freq_v_lat = 0.2 # Hz -k_v_lat = 2*np.pi*freq_v_lat*ts / (1 + 2*np.pi*freq_v_lat*ts) - -freq_a_lead = .5 # Hz -k_a_lead = 2*np.pi*freq_a_lead*ts / (1 + 2*np.pi*freq_a_lead*ts) - # stationary qualification parameters -v_stationary_thr = 4. # objects moving below this speed are classified as stationary -v_oncoming_thr = -3.9 # needs to be a bit lower in abs value than v_stationary_thr to not leave "holes" v_ego_stationary = 4. # no stationary object flag below this speed -# Lead Kalman Filter params -_VLEAD_A = [[1.0, ts], [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]] - -RDR_TO_LDR = 2.7 +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) -class Track(object): - def __init__(self): - self.ekf = None - self.stationary = True - self.initted = False - - def update(self, d_rel, y_rel, v_rel, d_path, v_ego_t_aligned, measured, steer_override): - if self.initted: - # pylint: disable=access-member-before-definition - self.dPathPrev = self.dPath - self.vLeadPrev = self.vLead - self.vRelPrev = self.vRel - + def update(self, d_rel, y_rel, v_rel, v_lead, measured): # relative values, copy self.dRel = d_rel # LONG_DIST self.yRel = y_rel # -LAT_DIST self.vRel = v_rel # REL_SPEED + self.vLead = v_lead self.measured = measured # measured or estimate - # compute distance to path - self.dPath = d_path - # computed velocity and accelerations - self.vLead = self.vRel + v_ego_t_aligned - - if not self.initted: - self.initted = True - self.aLeadTau = _LEAD_ACCEL_TAU - self.cnt = 1 - self.vision_cnt = 0 - self.vision = False - self.aRel = 0. # nidec gives no information about this - self.vLat = 0. - self.kf = KF1D([[self.vLead], [0.0]], _VLEAD_A, _VLEAD_C, _VLEAD_K) - else: - # estimate acceleration - # TODO: use Kalman filter - a_rel_unfilt = (self.vRel - self.vRelPrev) / ts - a_rel_unfilt = clip(a_rel_unfilt, -10., 10.) - self.aRel = k_a_lead * a_rel_unfilt + (1 - k_a_lead) * self.aRel - - # TODO: use Kalman filter - # neglect steer override cases as dPath is too noisy - v_lat_unfilt = 0. if steer_override else (self.dPath - self.dPathPrev) / ts - self.vLat = k_v_lat * v_lat_unfilt + (1 - k_v_lat) * self.vLat - + 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]) - if self.stationary: - # stationary objects can become non stationary, but not the other way around - self.stationary = v_ego_t_aligned > v_ego_stationary and abs(self.vLead) < v_stationary_thr - self.oncoming = self.vLead < v_oncoming_thr - - self.vision_score = NO_FUSION_SCORE - # Learn if constant acceleration if abs(self.aLeadK) < 0.5: self.aLeadTau = _LEAD_ACCEL_TAU else: self.aLeadTau *= 0.9 - def update_vision_score(self, dist_to_vision, rel_speed_diff): - # rel speed is very hard to estimate from vision - if dist_to_vision < 4.0 and rel_speed_diff < 10.: - self.vision_score = dist_to_vision + rel_speed_diff - else: - self.vision_score = NO_FUSION_SCORE - - def update_vision_fusion(self): - # vision point is never stationary - # don't trust 1 or 2 fusions until model quality is much better - if self.vision_cnt >= 3: - self.vision = True - self.stationary = False + 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] + def reset_a_lead(self, aLeadK, aLeadTau): + 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): +class Cluster(): def __init__(self): self.tracks = set() @@ -165,95 +99,59 @@ def vLeadK(self): @property def aLeadK(self): - return mean([t.aLeadK for t in self.tracks]) + if all(t.cnt <= 1 for t in self.tracks): + return 0. + else: + return mean([t.aLeadK for t in self.tracks if t.cnt > 1]) @property def aLeadTau(self): - return mean([t.aLeadTau for t in self.tracks]) - - @property - def vision(self): - return any([t.vision for t in self.tracks]) + if all(t.cnt <= 1 for t in self.tracks): + return _LEAD_ACCEL_TAU + else: + return mean([t.aLeadTau for t in self.tracks if t.cnt > 1]) @property def measured(self): - return any([t.measured for t in self.tracks]) + return any(t.measured for t in self.tracks) - @property - def vision_cnt(self): - return max([t.vision_cnt for t in self.tracks]) - - @property - def stationary(self): - return all([t.stationary for t in self.tracks]) - - @property - def oncoming(self): - return all([t.oncoming for t in self.tracks]) - - def toRadarState(self): + def get_RadarState(self, model_prob=0.0): return { - "dRel": float(self.dRel) - RDR_TO_LDR, + "dRel": float(self.dRel), "yRel": float(self.yRel), "vRel": float(self.vRel), - "aRel": float(self.aRel), "vLead": float(self.vLead), - "dPath": float(self.dPath), - "vLat": float(self.vLat), "vLeadK": float(self.vLeadK), "aLeadK": float(self.aLeadK), "status": True, - "fcw": self.is_potential_fcw(), + "fcw": self.is_potential_fcw(model_prob), + "modelProb": model_prob, + "radar": True, "aLeadTau": float(self.aLeadTau) } + def get_RadarState_from_vision(self, lead_msg, v_ego): + return { + "dRel": float(lead_msg.x[0] - RADAR_TO_CAMERA), + "yRel": float(-lead_msg.y[0]), + "vRel": float(lead_msg.v[0] - v_ego), + "vLead": float(lead_msg.v[0]), + "vLeadK": float(lead_msg.v[0]), + "aLeadK": float(0), + "aLeadTau": _LEAD_ACCEL_TAU, + "fcw": False, + "modelProb": float(lead_msg.prob), + "radar": False, + "status": True + } + def __str__(self): - ret = "x: %4.1f y: %4.1f v: %4.1f a: %4.1f d: %4.2f" % (self.dRel, self.yRel, self.vRel, self.aLeadK, self.dPath) - if self.stationary: - ret += " stationary" - if self.vision: - ret += " vision" - if self.oncoming: - ret += " oncoming" - if self.vision_cnt > 0: - ret += " vision_cnt: %6.0f" % self.vision_cnt + ret = "x: %4.1f y: %4.1f v: %4.1f a: %4.1f" % (self.dRel, self.yRel, self.vRel, self.aLeadK) return ret - def is_potential_lead(self, v_ego): - # predict cut-ins by extrapolating lateral speed by a lookahead time - # 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 = 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 - - def is_potential_lead2(self, lead_clusters): - if len(lead_clusters) > 0: - lead_cluster = lead_clusters[0] - # check if the new lead is too close and roughly at the same speed of the first lead: - # it might just be the second axle of the same vehicle - return (self.dRel - lead_cluster.dRel) > 8. or abs(self.vRel - lead_cluster.vRel) > 1. - else: - return False + def potential_low_speed_lead(self, v_ego): + # stop for stuff in front of you and low speed, even without model confirmation + return abs(self.yRel) < 1.5 and (v_ego < v_ego_stationary) and self.dRel < 25 - def is_potential_fcw(self): - # is this cluster trustrable enough for triggering fcw? - # fcw can trigger only on clusters that have been fused vision model for at least 20 frames - return self.vision_cnt >= 20 + def is_potential_fcw(self, model_prob): + return model_prob > .9 diff --git a/selfdrive/controls/lib/speed_smoother.py b/selfdrive/controls/lib/speed_smoother.py deleted file mode 100644 index 1ee7ec6b18cb5d..00000000000000 --- a/selfdrive/controls/lib/speed_smoother.py +++ /dev/null @@ -1,99 +0,0 @@ -import numpy as np - - -def get_delta_out_limits(aEgo, aMax, aMin, jMax, jMin): - - tDelta = 0. - if aEgo > aMax: - tDelta = (aMax - aEgo) / jMin - elif aEgo < aMin: - tDelta = (aMin - aEgo) / jMax - - return tDelta - - -def speed_smoother(vEgo, aEgo, vT, aMax, aMin, jMax, jMin, ts): - - dV = vT - vEgo - - # recover quickly if dV is positive and aEgo is negative or viceversa - if dV > 0. and aEgo < 0.: - jMax *= 3. - elif dV < 0. and aEgo > 0.: - jMin *= 3. - - tDelta = get_delta_out_limits(aEgo, aMax, aMin, jMax, jMin) - - if (ts <= tDelta): - if (aEgo < aMin): - vEgo += ts * aEgo + 0.5 * ts**2 * jMax - aEgo += ts * jMax - return vEgo, aEgo - elif (aEgo > aMax): - vEgo += ts * aEgo + 0.5 * ts**2 * jMin - aEgo += ts * jMin - return vEgo, aEgo - - if aEgo > aMax: - dV -= 0.5 * (aMax**2 - aEgo**2) / jMin - vEgo += 0.5 * (aMax**2 - aEgo**2) / jMin - aEgo += tDelta * jMin - elif aEgo < aMin: - dV -= 0.5 * (aMin**2 - aEgo**2) / jMax - vEgo += 0.5 * (aMin**2 - aEgo**2) / jMax - aEgo += tDelta * jMax - - ts -= tDelta - - jLim = jMin if aEgo >= 0 else jMax - # if we reduce the accel to zero immediately, how much delta speed we generate? - dv_min_shift = - 0.5 * aEgo**2 / jLim - - # flip signs so we can consider only one case - flipped = False - if dV < dv_min_shift: - flipped = True - dV *= -1 - vEgo *= -1 - aEgo *= -1 - aMax = -aMin - jMaxcopy = -jMin - jMin = -jMax - jMax = jMaxcopy - - # small addition needed to avoid numerical issues with sqrt of ~zero - aPeak = np.sqrt((0.5 * aEgo**2 / jMax + dV + 1e-9) / (0.5 / jMax - 0.5 / jMin)) - - if aPeak > aMax: - aPeak = aMax - t1 = (aPeak - aEgo) / jMax - if aPeak <= 0: # there is no solution, so stop after t1 - t2 = t1 + ts + 1e-9 - t3 = t2 - else: - vChange = dV - 0.5 * (aPeak**2 - aEgo**2) / jMax + 0.5 * aPeak**2 / jMin - if vChange < aPeak * ts: - t2 = t1 + vChange / aPeak - else: - t2 = t1 + ts - t3 = t2 - aPeak / jMin - else: - t1 = (aPeak - aEgo) / jMax - t2 = t1 - t3 = t2 - aPeak / jMin - - dt1 = min(ts, t1) - dt2 = max(min(ts, t2) - t1, 0.) - dt3 = max(min(ts, t3) - t2, 0.) - - if ts > t3: - vEgo += dV - aEgo = 0. - else: - vEgo += aEgo * dt1 + 0.5 * dt1**2 * jMax + aPeak * dt2 + aPeak * dt3 + 0.5 * dt3**2 * jMin - aEgo += jMax * dt1 + dt3 * jMin - - vEgo *= -1 if flipped else 1 - aEgo *= -1 if flipped else 1 - - return float(vEgo), float(aEgo) diff --git a/selfdrive/controls/lib/vehicle_model.py b/selfdrive/controls/lib/vehicle_model.py index 1dc77bf375afb6..a0b1dddfd7b9f5 100755 --- a/selfdrive/controls/lib/vehicle_model.py +++ b/selfdrive/controls/lib/vehicle_model.py @@ -1,9 +1,6 @@ -#!/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" +Dynamic bicycle model from "The Science of Vehicle Dynamics (2014), M. Guiggiani" The state is x = [v, r]^T with v lateral speed [m/s], and r rotational speed [rad/s] @@ -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,16 +37,16 @@ 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), + If the speed is too low we can't use the dynamic model (tire slip is undefined), we then have to use the kinematic model Args: @@ -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 + + 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 stiffness Front [N/rad] + cR: Tire stiffness 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 - CP = CarInterface.get_params(CAR.CIVIC, {}) - VM = VehicleModel(CP) - print(VM.yaw_rate(math.radians(20), 10.)) + +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 306dab05ba16cf..02f1c19a7725f7 100755 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -1,58 +1,49 @@ -#!/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 - +from selfdrive.controls.lib.longitudinal_planner import Planner +from selfdrive.controls.lib.lateral_planner import LateralPlanner +from selfdrive.hardware import TICI +import cereal.messaging as messaging -def plannerd_thread(): - gc.disable() - # start the loop - set_realtime_priority(2) - - params = Params() - - # Get FCW toggle from settings - fcw_enabled = params.get("IsFcwEnabled") == "1" +def plannerd_thread(sm=None, pm=None): + config_realtime_process(5 if TICI else 2, Priority.CTRL_LOW) cloudlog.info("plannerd is waiting for CarParams") - CP = car.CarParams.from_bytes(Params().get("CarParams", block=True)) + params = Params() + CP = car.CarParams.from_bytes(params.get("CarParams", block=True)) cloudlog.info("plannerd got CarParams: %s", CP.carName) - PL = Planner(CP, fcw_enabled) - PP = PathPlanner(CP) + use_lanelines = not params.get_bool('EndToEndToggle') + wide_camera = params.get_bool('EnableWideCamera') if TICI else False + + cloudlog.event("e2e mode", on=use_lanelines) - VM = VehicleModel(CP) + longitudinal_planner = Planner(CP) + lateral_planner = LateralPlanner(CP, use_lanelines=use_lanelines, wide_camera=wide_camera) - sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'model', 'liveParameters']) + if sm is None: + sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'modelV2'], + poll=['radarState', 'modelV2'], ignore_avg_freq=['radarState']) - sm['liveParameters'].valid = True - sm['liveParameters'].sensorValid = True - sm['liveParameters'].steerRatio = CP.steerRatio - sm['liveParameters'].stiffnessFactor = 1.0 - live_map_data = messaging.new_message() - live_map_data.init('liveMapData') + if pm is None: + pm = messaging.PubMaster(['longitudinalPlan', 'lateralPlan']) while True: sm.update() - if sm.updated['model']: - PP.update(sm, CP, VM) - if sm.updated['radarState']: - PL.update(sm, CP, VM, PP, live_map_data.liveMapData) - # elif socket is live_map_data_sock: - # live_map_data = msg + if sm.updated['modelV2']: + lateral_planner.update(sm) + lateral_planner.publish(sm, pm) + longitudinal_planner.update(sm) + longitudinal_planner.publish(sm, pm) -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 b37ed8f75519b5..88f39ce4318538 100755 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -1,295 +1,245 @@ -#!/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 selfdrive.messaging as messaging -from selfdrive.services import service_list -from selfdrive.controls.lib.latcontrol_helpers import calc_lookahead_offset -from selfdrive.controls.lib.model_parser import ModelParser -from selfdrive.controls.lib.radar_helpers import Track, Cluster, \ - RDR_TO_LDR, NO_FUSION_SCORE - -from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid -from selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.swaglog import cloudlog +import cereal.messaging as messaging from cereal import car +from common.numpy_fast import interp from common.params import Params -from common.realtime import set_realtime_priority, Ratekeeper, DT_MDL -from common.kalman.ekf import EKF, SimpleSensor - -DEBUG = False - -#vision point -DIMSV = 2 -XV, SPEEDV = 0, 1 -VISION_POINT = -1 - - -class EKFV1D(EKF): - def __init__(self): - super(EKFV1D, self).__init__(False) - self.identity = numpy.matlib.identity(DIMSV) - self.state = np.matlib.zeros((DIMSV, 1)) - self.var_init = 1e2 # ~ model variance when probability is 70%, so good starting point - self.covar = self.identity * self.var_init - - self.process_noise = np.matlib.diag([0.5, 1]) - - def calc_transfer_fun(self, dt): - tf = np.matlib.identity(DIMSV) - tf[XV, SPEEDV] = dt - tfj = tf - return tf, tfj - - -## fuses camera and radar data for best lead detection -def radard_thread(gctx=None): - set_realtime_priority(2) - - # 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)) - mocked = CP.carName == "mock" - VM = VehicleModel(CP) - 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 - - sm = messaging.SubMaster(['model', 'controlsState', 'liveParameters']) - - # Default parameters - live_parameters = messaging.new_message() - live_parameters.init('liveParameters') - live_parameters.liveParameters.valid = True - live_parameters.liveParameters.steerRatio = CP.steerRatio - live_parameters.liveParameters.stiffnessFactor = 1.0 - - MP = ModelParser() - RI = RadarInterface(CP) - - last_md_ts = 0 - last_controls_state_ts = 0 - - # *** publish radarState and liveTracks - radarState = messaging.pub_sock(service_list['radarState'].port) - liveTracks = messaging.pub_sock(service_list['liveTracks'].port) - - path_x = np.arange(0.0, 140.0, 0.1) # 140 meters is max - - # 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 - - active = 0 - steer_angle = 0. - steer_override = False - - tracks = defaultdict(dict) - - # Kalman filter stuff: - ekfv = EKFV1D() - speedSensorV = SimpleSensor(XV, 1, 2) - - # v_ego - v_ego = 0. - v_ego_hist_t = deque([0], maxlen=v_len) - v_ego_hist_v = deque([0], maxlen=v_len) - v_ego_t_aligned = 0. - - rk = Ratekeeper(rate, print_delay_threshold=None) - while 1: - rr = RI.update() +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.hardware import TICI + + +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.01s and 0.2s + assert dt > .01 and dt < .2, "Radar time step must be between .01s and 0.2s" + 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, 21)] + K0 = [0.12287673, 0.14556536, 0.16522756, 0.18281627, 0.1988689, 0.21372394, + 0.22761098, 0.24069424, 0.253096, 0.26491023, 0.27621103, 0.28705801, + 0.29750003, 0.30757767, 0.31732515, 0.32677158, 0.33594201, 0.34485814, + 0.35353899, 0.36200124] + K1 = [0.29666309, 0.29330885, 0.29042818, 0.28787125, 0.28555364, 0.28342219, + 0.28144091, 0.27958406, 0.27783249, 0.27617149, 0.27458948, 0.27307714, + 0.27162685, 0.27023228, 0.26888809, 0.26758976, 0.26633338, 0.26511557, + 0.26393339, 0.26278425] + self.K = [[interp(dt, dts, K0)], [interp(dt, dts, K1)]] + + +def laplacian_cdf(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 + offset_vision_dist = lead.x[0] - RADAR_TO_CAMERA + + def prob(c): + prob_d = laplacian_cdf(c.dRel, offset_vision_dist, lead.xStd[0]) + prob_y = laplacian_cdf(c.yRel, -lead.y[0], lead.yStd[0]) + prob_v = laplacian_cdf(c.vRel + v_ego, lead.v[0], lead.vStd[0]) + + # This is isn't exactly right, but good heuristic + 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(cluster.dRel - offset_vision_dist) < max([(offset_vision_dist)*.25, 5.0]) + vel_sane = (abs(cluster.vRel + v_ego - lead.v[0]) < 10) or (v_ego + cluster.vRel > 3) + if dist_sane and vel_sane: + return cluster + else: + return None + + +def get_lead(v_ego, ready, clusters, lead_msg, low_speed_override=True): + # Determine leads, this is where the essential logic happens + if len(clusters) > 0 and ready and lead_msg.prob > .5: + cluster = match_vision_to_cluster(v_ego, lead_msg, clusters) + else: + cluster = None + + lead_dict = {'status': False} + if cluster is not None: + lead_dict = cluster.get_RadarState(lead_msg.prob) + elif (cluster is None) and ready and (lead_msg.prob > .5): + lead_dict = Cluster().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: + 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 = closest_cluster.get_RadarState() + + return lead_dict + + +class RadarD(): + def __init__(self, radar_ts, delay=0): + self.current_time = 0 + + self.tracks = defaultdict(dict) + self.kalman_params = KalmanParams(radar_ts) + + # v_ego + self.v_ego = 0. + self.v_ego_hist = deque([0], maxlen=delay+1) + + self.ready = False + + def update(self, sm, rr, enable_lead): + self.current_time = 1e-9*max(sm.logMonoTime.values()) + + if sm.updated['carState']: + self.v_ego = sm['carState'].vEgo + self.v_ego_hist.append(self.v_ego) + if sm.updated['modelV2']: + self.ready = True ar_pts = {} for pt in rr.points: - ar_pts[pt.trackId] = [pt.dRel + RDR_TO_LDR, pt.yRel, pt.vRel, pt.measured] - - sm.update(0) - - if sm.updated['liveParameters']: - VM.update_params(sm['liveParameters'].stiffnessFactor, sm['liveParameters'].steerRatio) - - if sm.updated['controlsState']: - active = sm['controlsState'].active - v_ego = sm['controlsState'].vEgo - steer_angle = sm['controlsState'].angleSteers - steer_override = sm['controlsState'].steerOverride - - v_ego_hist_v.append(v_ego) - v_ego_hist_t.append(float(rk.frame)/rate) - - last_controls_state_ts = sm.logMonoTime['controlsState'] - - if sm.updated['model']: - last_md_ts = sm.logMonoTime['model'] - MP.update(v_ego, sm['model']) - - - # run kalman filter only if prob is high enough - if MP.lead_prob > 0.7: - reading = speedSensorV.read(MP.lead_dist, covar=np.matrix(MP.lead_var)) - ekfv.update_scalar(reading) - ekfv.predict(DT_MDL) - - # When changing lanes the distance to the lead car can suddenly change, - # which makes the Kalman filter output large relative acceleration - if mocked and abs(MP.lead_dist - ekfv.state[XV]) > 2.0: - ekfv.state[XV] = MP.lead_dist - ekfv.covar = (np.diag([MP.lead_var, ekfv.var_init])) - ekfv.state[SPEEDV] = 0. - - ar_pts[VISION_POINT] = (float(ekfv.state[XV]), np.polyval(MP.d_poly, float(ekfv.state[XV])), - float(ekfv.state[SPEEDV]), False) - else: - ekfv.state[XV] = MP.lead_dist - ekfv.covar = (np.diag([MP.lead_var, ekfv.var_init])) - ekfv.state[SPEEDV] = 0. - - if VISION_POINT in ar_pts: - del ar_pts[VISION_POINT] - - # *** compute the likely path_y *** - if (active and not steer_override) or mocked: - # use path from model (always when mocking as steering is too noisy) - path_y = np.polyval(MP.d_poly, path_x) - else: - # use path from steer, set angle_offset to 0 it does not only report the physical offset - path_y = calc_lookahead_offset(v_ego, steer_angle, path_x, VM, angle_offset=live_parameters.liveParameters.angleOffsetAverage)[0] + ar_pts[pt.trackId] = [pt.dRel, pt.yRel, pt.vRel, pt.measured] # *** remove missing points from meta data *** - for ids in tracks.keys(): + for ids in list(self.tracks.keys()): if ids not in ar_pts: - tracks.pop(ids, None) + self.tracks.pop(ids, None) # *** compute the tracks *** for ids in ar_pts: - # ignore standalone vision point, unless we are mocking the radar - if ids == VISION_POINT and not mocked: - continue rpt = ar_pts[ids] # align v_ego by a fixed time to align it with the radar measurement - cur_time = float(rk.frame)/rate - v_ego_t_aligned = np.interp(cur_time - RI.delay, v_ego_hist_t, v_ego_hist_v) - - d_path = np.sqrt(np.amin((path_x - rpt[0]) ** 2 + (path_y - rpt[1]) ** 2)) - # add sign - d_path *= np.sign(rpt[1] - np.interp(rpt[0], path_x, path_y)) + v_lead = rpt[2] + self.v_ego_hist[0] # create the track if it doesn't exist or it's a new track - if ids not in tracks: - tracks[ids] = Track() - tracks[ids].update(rpt[0], rpt[1], rpt[2], d_path, v_ego_t_aligned, rpt[3], steer_override) - - # allow the vision model to remove the stationary flag if distance and rel speed roughly match - if VISION_POINT in ar_pts: - fused_id = None - best_score = NO_FUSION_SCORE - for ids in tracks: - dist_to_vision = np.sqrt((0.5*(ar_pts[VISION_POINT][0] - tracks[ids].dRel)) ** 2 + (2*(ar_pts[VISION_POINT][1] - tracks[ids].yRel)) ** 2) - rel_speed_diff = abs(ar_pts[VISION_POINT][2] - tracks[ids].vRel) - tracks[ids].update_vision_score(dist_to_vision, rel_speed_diff) - if best_score > tracks[ids].vision_score: - fused_id = ids - best_score = tracks[ids].vision_score - - if fused_id is not None: - tracks[fused_id].vision_cnt += 1 - tracks[fused_id].update_vision_fusion() - - if DEBUG: - print("NEW CYCLE") - if VISION_POINT in ar_pts: - print("vision", ar_pts[VISION_POINT]) - - idens = list(tracks.keys()) - track_pts = np.array([tracks[iden].get_key_for_cluster() for iden in idens]) + if ids not in self.tracks: + self.tracks[ids] = Track(v_lead, self.kalman_params) + self.tracks[ids].update(rpt[0], rpt[1], rpt[2], v_lead, rpt[3]) + + 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].add(tracks[idens[idx]]) - + clusters[cluster_i].add(self.tracks[idens[idx]]) elif len(track_pts) == 1: - # TODO: why do we need this? + # FIXME: cluster_point_centroid hangs forever if len(track_pts) == 1 + cluster_idxs = [0] clusters = [Cluster()] - clusters[0].add(tracks[idens[0]]) + clusters[0].add(self.tracks[idens[0]]) else: clusters = [] - if DEBUG: - for i in clusters: - print(i) - # *** extract the lead car *** - lead_clusters = [c for c in clusters - if c.is_potential_lead(v_ego)] - lead_clusters.sort(key=lambda x: x.dRel) - lead_len = len(lead_clusters) - - # *** extract the second lead from the whole set of leads *** - lead2_clusters = [c for c in lead_clusters - if c.is_potential_lead2(lead_clusters)] - lead2_clusters.sort(key=lambda x: x.dRel) - lead2_len = len(lead2_clusters) + # if a new point, reset accel to the rest of the cluster + 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 + self.tracks[idens[idx]].reset_a_lead(aLeadK, aLeadTau) # *** publish radarState *** - dat = messaging.new_message() - dat.init('radarState') - dat.valid = sm.all_alive_and_valid(service_list=['controlsState']) - dat.radarState.mdMonoTime = last_md_ts - dat.radarState.canMonoTimes = list(rr.canMonoTimes) - dat.radarState.radarErrors = list(rr.errors) - dat.radarState.controlsStateMonoTime = last_controls_state_ts - if lead_len > 0: - dat.radarState.leadOne = lead_clusters[0].toRadarState() - if lead2_len > 0: - dat.radarState.leadTwo = lead2_clusters[0].toRadarState() - else: - dat.radarState.leadTwo.status = False - else: - dat.radarState.leadOne.status = False + dat = messaging.new_message('radarState') + dat.valid = sm.all_alive_and_valid() and len(rr.errors) == 0 + radarState = dat.radarState + radarState.mdMonoTime = sm.logMonoTime['modelV2'] + radarState.canMonoTimes = list(rr.canMonoTimes) + radarState.radarErrors = list(rr.errors) + radarState.carStateMonoTime = sm.logMonoTime['carState'] + + if enable_lead: + if len(sm['modelV2'].leadsV3) > 1: + radarState.leadOne = get_lead(self.v_ego, self.ready, clusters, sm['modelV2'].leadsV3[0], low_speed_override=True) + radarState.leadTwo = get_lead(self.v_ego, self.ready, clusters, sm['modelV2'].leadsV3[1], low_speed_override=False) + return dat + + +# fuses camera and radar data for best lead detection +def radard_thread(sm=None, pm=None, can_sock=None): + config_realtime_process(5 if TICI else 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)) + 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 + + # *** setup messaging + if can_sock is None: + can_sock = messaging.sub_sock('can') + if sm is None: + sm = messaging.SubMaster(['modelV2', 'carState'], ignore_avg_freq=['modelV2', 'carState']) # Can't check average frequency, since radar determines timing + if pm is None: + pm = messaging.PubMaster(['radarState', 'liveTracks']) + + RI = RadarInterface(CP) + + rk = Ratekeeper(1.0 / CP.radarTimeStep, print_delay_threshold=None) + RD = RadarD(CP.radarTimeStep, RI.delay) + # TODO: always log leads once we can hide them conditionally + enable_lead = CP.openpilotLongitudinalControl or not CP.radarOffCan + + while 1: + can_strings = messaging.drain_sock_raw(can_sock, wait_for_one=True) + rr = RI.update(can_strings) + + if rr is None: + continue + + sm.update(0) + + dat = RD.update(sm, rr, enable_lead) dat.radarState.cumLagMs = -rk.remaining*1000. - radarState.send(dat.to_bytes()) + + pm.send('radarState', dat) # *** publish tracks for UI debugging (keep last) *** - dat = messaging.new_message() - dat.init('liveTracks', len(tracks)) - - for cnt, ids in enumerate(tracks.keys()): - if DEBUG: - print("id: %4.0f x: %4.1f y: %4.1f vr: %4.1f d: %4.1f va: %4.1f vl: %4.1f vlk: %4.1f alk: %4.1f s: %1.0f v: %1.0f" % \ - (ids, tracks[ids].dRel, tracks[ids].yRel, tracks[ids].vRel, - tracks[ids].dPath, tracks[ids].vLat, - tracks[ids].vLead, tracks[ids].vLeadK, - tracks[ids].aLeadK, - tracks[ids].stationary, - tracks[ids].measured)) + tracks = RD.tracks + dat = messaging.new_message('liveTracks', len(tracks)) + + 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), - "aRel": float(tracks[ids].aRel), - "stationary": bool(tracks[ids].stationary), - "oncoming": bool(tracks[ids].oncoming), } - 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__": 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 77b37bb740ed9e..00000000000000 --- a/selfdrive/controls/tests/test_lateral_mpc.py +++ /dev/null @@ -1,121 +0,0 @@ -import unittest -import copy -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 - - -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 = copy.copy(poly_l) - p_l[3] += poly_shift - p_r = copy.copy(poly_r) - p_r[3] += poly_shift - p_p = copy.copy(poly_p) - p_p[3] += poly_shift - - 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)) - p_poly = libmpc_py.ffi.new("double[4]", map(float, p_p)) - - 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, p_poly, l_prob, r_prob, p_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)) diff --git a/selfdrive/crash.py b/selfdrive/crash.py index 6ceb56b627756c..e42b7532b06947 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -1,66 +1,27 @@ """Install exception handler for process crash.""" -import os -import sys -import threading -import capnp -from selfdrive.version import version, dirty - from selfdrive.swaglog import cloudlog +from selfdrive.version import get_version -if os.getenv("NOLOG") or os.getenv("NOCRASH"): - def capture_exception(*exc_info): - 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 - client = Client('https://1994756b5e6f41cf939a4c65de45f4f2:cefebaf3a8aa40d182609785f7189bd7@app.getsentry.com/77924', - install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty}) - - def capture_exception(*args, **kwargs): - exc_info = sys.exc_info() - if not exc_info[0] is capnp.lib.capnp.KjException: - client.captureException(*args, **kwargs) - cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) - - def bind_user(**kwargs): - client.user_context(kwargs) - - def bind_extra(**kwargs): - client.extra_context(kwargs) - - def install(): - # 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) - __excepthook__(*exc_info) - sys.excepthook = handle_exception +import sentry_sdk +from sentry_sdk.integrations.threading import ThreadingIntegration - """ - 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 capture_exception(*args, **kwargs) -> None: + cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) - def init(self, *args, **kwargs): - init_original(self, *args, **kwargs) - run_original = self.run + try: + sentry_sdk.capture_exception(*args, **kwargs) + sentry_sdk.flush() # https://github.com/getsentry/sentry-python/issues/291 + except Exception: + cloudlog.exception("sentry exception") - def run_with_except_hook(*args2, **kwargs2): - try: - run_original(*args2, **kwargs2) - except Exception: - sys.excepthook(*sys.exc_info()) +def bind_user(**kwargs) -> None: + sentry_sdk.set_user(kwargs) - self.run = run_with_except_hook +def bind_extra(**kwargs) -> None: + for k, v in kwargs.items(): + sentry_sdk.set_tag(k, v) - threading.Thread.__init__ = init +def init() -> None: + sentry_sdk.init("https://a8dc76b5bfb34908a601d67e2aa8bcf9@o33823.ingest.sentry.io/77924", + default_integrations=False, integrations=[ThreadingIntegration(propagate_hub=True)], + release=get_version()) 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_print_changes.py b/selfdrive/debug/can_print_changes.py new file mode 100755 index 00000000000000..4fa775ac17e2e3 --- /dev/null +++ b/selfdrive/debug/can_print_changes.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +import binascii +import sys +from collections import defaultdict + +import cereal.messaging as messaging +from common.realtime import sec_since_boot + + +def can_printer(bus=0): + """Collects messages and prints when a new bit transition is observed. + This is very useful to find signals based on user triggered actions, such as blinkers and seatbelt. + Leave the script running until no new transitions are seen, then perform the action.""" + logcan = messaging.sub_sock('can') + + low_to_high = defaultdict(int) + high_to_low = defaultdict(int) + + while 1: + can_recv = messaging.drain_sock(logcan, wait_for_one=True) + for x in can_recv: + for y in x.can: + if y.src == bus: + i = int.from_bytes(y.dat, byteorder='big') + + l_h = low_to_high[y.address] + h_l = high_to_low[y.address] + + change = None + if (i | l_h) != l_h: + low_to_high[y.address] = i | l_h + change = "+" + + if (~i | h_l) != h_l: + high_to_low[y.address] = ~i | h_l + change = "-" + + if change: + print(f"{sec_since_boot():.2f}\t{hex(y.address)} ({y.address})\t{change}{binascii.hexlify(y.dat)}") + + +if __name__ == "__main__": + if len(sys.argv) > 1: + can_printer(int(sys.argv[1])) + else: + can_printer() diff --git a/selfdrive/debug/can_printer.py b/selfdrive/debug/can_printer.py index daa0500b2f20e6..cb6ff29006bdda 100755 --- a/selfdrive/debug/can_printer.py +++ b/selfdrive/debug/can_printer.py @@ -1,42 +1,43 @@ -#!/usr/bin/env python -import os -import sys +#!/usr/bin/env python3 +import argparse +import binascii 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) +def can_printer(bus, max_msg, addr): + logcan = messaging.sub_sock('can', addr=addr) start = sec_since_boot() lp = sec_since_boot() msgs = defaultdict(list) - canbus = int(os.getenv("CAN", bus)) while 1: can_recv = messaging.drain_sock(logcan, wait_for_one=True) for x in can_recv: for y in x.can: - if y.src == canbus: + if y.src == bus: msgs[y.address].append(y.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: x[-1].encode("hex"), msgs.values()))): - if max_msg is None or k < max_msg: - dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k,k),len(msgs[k]), v) + for addr in sorted(msgs.keys()): + a = msgs[addr][-1].decode('ascii', 'backslashreplace') + x = binascii.hexlify(msgs[addr][-1]).decode('ascii') + if max_msg is None or addr < max_msg: + dd += "%04X(%4d)(%6d) %s \"%s\"\n" % (addr, addr, len(msgs[addr]), x.ljust(20), a) print(dd) lp = sec_since_boot() if __name__ == "__main__": - if len(sys.argv) > 3: - can_printer(int(sys.argv[1]), int(sys.argv[2]), sys.argv[3]) - elif len(sys.argv) > 2: - can_printer(int(sys.argv[1]), int(sys.argv[2])) - elif len(sys.argv) > 1: - can_printer(int(sys.argv[1])) - else: - can_printer() - + parser = argparse.ArgumentParser(description="simple CAN data viewer", + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + + parser.add_argument("--bus", type=int, help="CAN bus to print out", default=0) + parser.add_argument("--max_msg", type=int, help="max addr ") + parser.add_argument("--addr", default="127.0.0.1") + + args = parser.parse_args() + can_printer(args.bus, args.max_msg, args.addr) diff --git a/selfdrive/debug/check_freq.py b/selfdrive/debug/check_freq.py new file mode 100755 index 00000000000000..300b3ea1fb133c --- /dev/null +++ b/selfdrive/debug/check_freq.py @@ -0,0 +1,47 @@ +#!/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)) + valids = 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) + valids[name].append(msg.valid) + + 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%%, valid " % (name, 1.0 / mean, np.min(dts) / mean * 100, np.max(dts) / mean * 100), all(valids[name])) + + 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/check_timings.py b/selfdrive/debug/check_timings.py new file mode 100755 index 00000000000000..03e39fd70df462 --- /dev/null +++ b/selfdrive/debug/check_timings.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# type: ignore +import sys +import time +import numpy as np +from collections import defaultdict, deque + +import cereal.messaging as messaging + +socks = {s: messaging.sub_sock(s, conflate=False) for s in sys.argv[1:]} +ts = defaultdict(lambda: deque(maxlen=100)) + +if __name__ == "__main__": + while True: + print() + for s, sock in socks.items(): + msgs = messaging.drain_sock(sock) + for m in msgs: + ts[s].append(m.logMonoTime / 1e6) + + if len(ts[s]): + d = np.diff(ts[s]) + print(f"{s:25} {np.mean(d):.2f} {np.std(d):.2f} {np.max(d):.2f} {np.min(d):.2f}") + time.sleep(1) 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/count_events.py b/selfdrive/debug/count_events.py new file mode 100755 index 00000000000000..8b32ce9d21f79c --- /dev/null +++ b/selfdrive/debug/count_events.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +import sys +from collections import Counter +from pprint import pprint +from tqdm import tqdm + +from tools.lib.route import Route +from tools.lib.logreader import LogReader + +if __name__ == "__main__": + r = Route(sys.argv[1]) + + cnt_valid: Counter = Counter() + cnt_events: Counter = Counter() + + for q in tqdm(r.qlog_paths()): + if q is None: + continue + lr = list(LogReader(q)) + for msg in lr: + if msg.which() == 'carEvents': + for e in msg.carEvents: + cnt_events[e.name] += 1 + if not msg.valid: + cnt_valid[msg.which()] += 1 + + print("Events") + pprint(cnt_events) + + print("\n\n") + print("Not valid") + pprint(cnt_valid) diff --git a/selfdrive/debug/cpu_usage_stat.py b/selfdrive/debug/cpu_usage_stat.py index 7adf7ef78ee02f..aafc696b464509 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,25 +15,36 @@ 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 + +from selfdrive.manager.process_config import managed_processes # 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'] + # android procs + 'SurfaceFlinger', 'sensors.qcom' +] + list(managed_processes.keys()) + 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", - formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("proc_names", nargs="?", default='', - help="Process names to be monitored, comma seperated") + help="Process names to be monitored, comma separated") parser.add_argument("--list_all", action='store_true', help="Show all running processes' cmdline") parser.add_argument("--detailed_times", action='store_true', @@ -63,12 +66,12 @@ def get_arg_parser(): for p in psutil.process_iter(): if p == psutil.Process(): continue - matched = any([l for l in p.cmdline() if any([pn for pn in monitored_proc_names if re.match(r'.*{}.*'.format(pn), l, re.M | re.I)])]) + matched = any(l for l in p.cmdline() if any(pn for pn in monitored_proc_names if re.match(r'.*{}.*'.format(pn), l, re.M | re.I))) if matched: 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 +97,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,9 +115,9 @@ 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( - sum([stat['avg']['total'] for k, stat in stats.items()]), i, i * SLEEP_INTERVAL + sum(stat['avg']['total'] for k, stat in stats.items()), i, i * SLEEP_INTERVAL )) diff --git a/selfdrive/debug/cycle_alerts.py b/selfdrive/debug/cycle_alerts.py new file mode 100755 index 00000000000000..f28d5373f44c7f --- /dev/null +++ b/selfdrive/debug/cycle_alerts.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +# flake8: noqa +# pylint: skip-file +# type: ignore + +import time + +from cereal import car, log +import cereal.messaging as messaging +from common.realtime import DT_CTRL +from selfdrive.car.honda.interface import CarInterface +from selfdrive.controls.lib.events import ET, EVENTS, Events +from selfdrive.controls.lib.alertmanager import AlertManager + +EventName = car.CarEvent.EventName + +def cycle_alerts(duration=200, is_metric=False): + # all alerts + #alerts = list(EVENTS.keys()) + + # this plays each type of audible alert + alerts = [ + (EventName.buttonEnable, ET.ENABLE), + (EventName.buttonCancel, ET.USER_DISABLE), + (EventName.wrongGear, ET.NO_ENTRY), + + (EventName.vehicleModelInvalid, ET.SOFT_DISABLE), + (EventName.accFaulted, ET.IMMEDIATE_DISABLE), + + # DM sequence + (EventName.preDriverDistracted, ET.WARNING), + (EventName.promptDriverDistracted, ET.WARNING), + (EventName.driverDistracted, ET.WARNING), + ] + + CP = CarInterface.get_params("HONDA CIVIC 2016") + sm = messaging.SubMaster(['deviceState', 'pandaStates', 'roadCameraState', 'modelV2', 'liveCalibration', + 'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman']) + + pm = messaging.PubMaster(['controlsState', 'pandaStates', 'deviceState']) + + events = Events() + AM = AlertManager() + + frame = 0 + while True: + current_alert_types = [ET.PERMANENT, ET.USER_DISABLE, ET.IMMEDIATE_DISABLE, + ET.SOFT_DISABLE, ET.PRE_ENABLE, ET.NO_ENTRY, + ET.ENABLE, ET.WARNING] + + for alert, et in alerts: + events.clear() + events.add(alert) + + a = events.create_alerts([et, ], [CP, sm, is_metric, 0]) + AM.add_many(frame, a) + AM.process_alerts(frame) + print(AM.alert) + for _ in range(duration): + dat = messaging.new_message() + dat.init('controlsState') + dat.controlsState.enabled = True + + 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 + pm.send('controlsState', dat) + + dat = messaging.new_message() + dat.init('deviceState') + dat.deviceState.started = True + pm.send('deviceState', dat) + + dat = messaging.new_message('pandaStates', 1) + dat.pandaStates[0].ignitionLine = True + dat.pandaStates[0].pandaType = log.PandaState.PandaType.uno + pm.send('pandaStates', dat) + + frame += 1 + time.sleep(DT_CTRL) + +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..f0faf400177469 --- /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.5, 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..047c874fb777d9 100755 --- a/selfdrive/debug/dump.py +++ b/selfdrive/debug/dump.py @@ -1,78 +1,48 @@ -#!/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 +import codecs +codecs.register_error("strict", codecs.backslashreplace_errors) 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 = argparse.ArgumentParser(description='Dump communcation sockets. See cereal/services.py for a complete list of available sockets.') parser.add_argument('--pipe', action='store_true') parser.add_argument('--raw', action='store_true') 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") + parser.add_argument("socket", type=str, nargs='*', help="socket names to dump. defaults to all services defined in cereal") 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(100) + 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 +63,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..98e7d872462bcc --- /dev/null +++ b/selfdrive/debug/filter_log_message.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +import argparse +import json + +import cereal.messaging as messaging +from tools.lib.robust_logreader import RobustLogReader as LogReader +from tools.lib.route import Route + +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", +} + + +def print_logmessage(t, msg, min_level): + try: + log = json.loads(msg) + if log['levelnum'] >= min_level: + print(f"[{t / 1e9:.6f}] {log['filename']}:{log.get('lineno', '')} - {log.get('funcname', '')}: {log['msg']}") + if 'exc_info' in log: + print(log['exc_info']) + except json.decoder.JSONDecodeError: + print(f"[{t / 1e9:.6f}] decode error: {msg}") + + +def print_androidlog(t, msg): + source = ANDROID_LOG_SOURCE[msg.id] + try: + m = json.loads(msg.message)['MESSAGE'] + except Exception: + m = msg.message + + print(f"[{t / 1e9:.6f}] {source} {msg.pid} {msg.tag} - {m}") + + +if __name__ == "__main__": + + parser = argparse.ArgumentParser() + parser.add_argument('--level', default='DEBUG') + parser.add_argument('--addr', default='127.0.0.1') + parser.add_argument("route", type=str, nargs='*', help="route name + segment number for offline usage") + args = parser.parse_args() + + logs = None + if len(args.route): + r = Route(args.route[0]) + logs = r.log_paths() + + if len(args.route) == 2 and logs: + n = int(args.route[1]) + logs = [logs[n]] + + min_level = LEVELS[args.level] + + if logs: + for log in logs: + if log: + lr = LogReader(log) + for m in lr: + if m.which() == 'logMessage': + print_logmessage(m.logMonoTime, m.logMessage, min_level) + elif m.which() == 'androidLog': + print_androidlog(m.logMonoTime, m.androidLog) + else: + sm = messaging.SubMaster(['logMessage', 'androidLog'], addr=args.addr) + while True: + sm.update() + + if sm.updated['logMessage']: + print_logmessage(sm.logMonoTime['logMessage'], sm['logMessage'], min_level) + + if sm.updated['androidLog']: + print_androidlog(sm.logMonoTime['androidLog'], sm['androidLog']) diff --git a/selfdrive/debug/fingerprint_from_route.py b/selfdrive/debug/fingerprint_from_route.py new file mode 100755 index 00000000000000..098e39fbe8778f --- /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: ./fingerprint_from_route.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/hyundai_enable_radar_points.py b/selfdrive/debug/hyundai_enable_radar_points.py new file mode 100755 index 00000000000000..204d2480c3b993 --- /dev/null +++ b/selfdrive/debug/hyundai_enable_radar_points.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +"""Some Hyundai radars can be reconfigured to output (debug) radar points on bus 1. +Reconfiguration is done over UDS by reading/writing to 0x0142 using the Read/Write Data By Identifier +endpoints (0x22 & 0x2E). This script checks your radar firmware version against a list of known +firmware versions. If you want to try on a new radar make sure to note the default config value +in case it's different from the other radars and you need to revert the changes. + +After changing the config the car should not show any faults when openpilot is not running. +These config changes are persistent accross car reboots. You need to run this script again +to go back to the default values. + +USE AT YOUR OWN RISK! Safety features, like AEB and FCW, might be affected by these changes.""" + +import sys +import argparse +from subprocess import check_output, CalledProcessError + +from panda.python import Panda +from panda.python.uds import UdsClient, SESSION_TYPE, DATA_IDENTIFIER_TYPE + +# If your radar supports changing data identifier 0x0142 as well make a PR to +# this file to add your firmware version. Make sure to post a drive as proof! +# NOTE: these firmware versions do not match what openpilot uses +# because this script uses a different diagnostic session type +SUPPORTED_FW_VERSIONS = { + # 2020 SONATA + b"DN8_ SCC FHCUP 1.00 1.00 99110-L0000\x19\x08)\x15T ": { + "default_config": b"\x00\x00\x00\x01\x00\x00", + "tracks_enabled": b"\x00\x00\x00\x01\x00\x01", + }, + # 2021 SONATA HYBRID + b"DNhe SCC FHCUP 1.00 1.02 99110-L5000 \x01#\x15# ": { + "default_config": b"\x00\x00\x00\x01\x00\x00", + "tracks_enabled": b"\x00\x00\x00\x01\x00\x01", + }, + # 2020 PALISADE + b"LX2_ SCC FHCUP 1.00 1.04 99110-S8100\x19\x05\x02\x16V ": { + "default_config": b"\x00\x00\x00\x01\x00\x00", + "tracks_enabled": b"\x00\x00\x00\x01\x00\x01", + }, + # 2020 SANTA FE + b"TM__ SCC F-CUP 1.00 1.03 99110-S2000\x19\x050\x13' ": { + "default_config": b"\x00\x00\x00\x01\x00\x00", + "tracks_enabled": b"\x00\x00\x00\x01\x00\x01", + }, + + # 2020 GENESIS G70 + b'IK__ SCC F-CUP 1.00 1.02 96400-G9100\x18\x07\x06\x17\x12 ': { + "default config": b"\x00\x00\x00\x01\x00\x00", + "tracks_enabled": b"\x00\x00\x00\x01\x00\x01", + }, +} + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='configure radar to output points (or reset to default)') + parser.add_argument('--default', action="store_true", default=False, help='reset to default configuration (default: false)') + parser.add_argument('--debug', action="store_true", default=False, help='enable debug output (default: false)') + parser.add_argument('--bus', type=int, default=0, help='can bus to use (default: 0)') + args = parser.parse_args() + + try: + check_output(["pidof", "boardd"]) + print("boardd is running, please kill openpilot before running this script! (aborted)") + sys.exit(1) + except CalledProcessError as e: + if e.returncode != 1: # 1 == no process found (boardd not running) + raise e + + confirm = input("power on the vehicle keeping the engine off (press start button twice) then type OK to continue: ").upper().strip() + if confirm != "OK": + print("\nyou didn't type 'OK! (aborted)") + sys.exit(0) + + panda = Panda() # type: ignore + panda.set_safety_mode(Panda.SAFETY_ELM327) + uds_client = UdsClient(panda, 0x7D0, bus=args.bus, debug=args.debug) + + print("\n[START DIAGNOSTIC SESSION]") + session_type : SESSION_TYPE = 0x07 # type: ignore + uds_client.diagnostic_session_control(session_type) + + print("[HARDWARE/SOFTWARE VERSION]") + fw_version_data_id : DATA_IDENTIFIER_TYPE = 0xf100 # type: ignore + fw_version = uds_client.read_data_by_identifier(fw_version_data_id) + print(fw_version) + if fw_version not in SUPPORTED_FW_VERSIONS.keys(): + print("radar not supported! (aborted)") + sys.exit(1) + + print("[GET CONFIGURATION]") + config_data_id : DATA_IDENTIFIER_TYPE = 0x0142 # type: ignore + current_config = uds_client.read_data_by_identifier(config_data_id) + new_config = SUPPORTED_FW_VERSIONS[fw_version]["default_config" if args.default else "tracks_enabled"] + print(f"current config: 0x{current_config.hex()}") + if current_config != new_config: + print("[CHANGE CONFIGURATION]") + print(f"new config: 0x{new_config.hex()}") + uds_client.write_data_by_identifier(config_data_id, new_config) + if not args.default and current_config != SUPPORTED_FW_VERSIONS[fw_version]["default_config"]: + print("\ncurrent config does not match expected default! (aborted)") + sys.exit(1) + + print("[DONE]") + print("\nrestart your vehicle and ensure there are no faults") + if not args.default: + print("you can run this script again with --default to go back to the original (factory) settings") + else: + print("[DONE]") + print("\ncurrent config is already the desired configuration") + sys.exit(0) diff --git a/selfdrive/debug/live_cpu_and_temp.py b/selfdrive/debug/live_cpu_and_temp.py new file mode 100755 index 00000000000000..5589b0d6ddc8fe --- /dev/null +++ b/selfdrive/debug/live_cpu_and_temp.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +import argparse + +from cereal.messaging import SubMaster +from common.numpy_fast import mean + + +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(['deviceState', 'procLog']) + + last_temp = 0.0 + last_mem = 0.0 + total_times = [0.]*8 + busy_times = [0.]*8 + + prev_proclog = None + prev_proclog_t = None + + while True: + sm.update() + + if sm.updated['deviceState']: + t = sm['deviceState'] + last_temp = mean(t.cpuTempC) + last_mem = t.memoryUsagePercent + + if sm.updated['procLog']: + m = sm['procLog'] + + cores = [0.]*8 + total_times_new = [0.]*8 + busy_times_new = [0.]*8 + + 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(8): + 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 %.2fC" % (100. * 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/run_process_on_route.py b/selfdrive/debug/run_process_on_route.py new file mode 100755 index 00000000000000..bcb741f54ea533 --- /dev/null +++ b/selfdrive/debug/run_process_on_route.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import argparse + +from selfdrive.test.process_replay.compare_logs import save_log +from selfdrive.test.process_replay.process_replay import CONFIGS, replay_process +from tools.lib.logreader import MultiLogIterator +from tools.lib.route import Route + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Run process on route and create new logs", + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("route", help="The route name to use") + parser.add_argument("process", help="The process to run") + args = parser.parse_args() + + cfg = [c for c in CONFIGS if c.proc_name == args.process][0] + + route = Route(args.route) + lr = MultiLogIterator(route.log_paths(), wraparound=False) + inputs = list(lr) + + outputs = replay_process(cfg, inputs) + + # Remove message generated by the process under test and merge in the new messages + produces = set(o.which() for o in outputs) + inputs = [i for i in inputs if i.which() not in produces] + outputs = sorted(inputs + outputs, key=lambda x: x.logMonoTime) + + fn = f"{args.route}_{args.process}.bz2" + save_log(fn, outputs) diff --git a/selfdrive/debug/set_car_params.py b/selfdrive/debug/set_car_params.py new file mode 100755 index 00000000000000..bcdaed07783a61 --- /dev/null +++ b/selfdrive/debug/set_car_params.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import sys + +from common.params import Params +from tools.lib.route import Route +from tools.lib.logreader import LogReader + +if __name__ == "__main__": + r = Route(sys.argv[1]) + cp = [m for m in LogReader(r.qlog_paths()[0]) if m.which() == 'carParams'] + Params().put("CarParams", cp[0].carParams.as_builder().to_bytes()) diff --git a/selfdrive/debug/show_matching_cars.py b/selfdrive/debug/show_matching_cars.py new file mode 100755 index 00000000000000..79a23c1f8222a1 --- /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_legacy_fingerprint_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_legacy_fingerprint_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..44b3ba16afa6c7 --- /dev/null +++ b/selfdrive/debug/test_fw_query_on_routes.py @@ -0,0 +1,191 @@ +#!/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 tools.lib.route import Route +from selfdrive.car.car_helpers import interface_names +from selfdrive.car.fw_versions import match_fw_to_car_exact, match_fw_to_car_fuzzy, build_fw_dict +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.volkswagen.values import FW_VERSIONS as VW_FW_VERSIONS +from selfdrive.car.mazda.values import FW_VERSIONS as MAZDA_FW_VERSIONS + + +NO_API = "NO_API" in os.environ +SUPPORTED_CARS = set(interface_names['toyota']) +SUPPORTED_CARS |= set(interface_names['honda']) +SUPPORTED_CARS |= set(interface_names['hyundai']) +SUPPORTED_CARS |= set(interface_names['volkswagen']) +SUPPORTED_CARS |= set(interface_names['mazda']) + +try: + from xx.pipeline.c.CarState import migration +except ImportError: + migration = {} + +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) + + not_fingerprinted = 0 + solved_by_fuzzy = 0 + + good_exact = 0 + wrong_fuzzy = 0 + good_fuzzy = 0 + + dongles = [] + for route in tqdm(routes): + route = route.rstrip() + dongle_id, time = route.split('|') + + if dongle_id in dongles: + continue + + if NO_API: + qlog_path = f"cd:/{dongle_id}/{time}/0/qlog.bz2" + else: + route = Route(route) + qlog_path = route.qlog_paths()[0] + + if qlog_path is None: + continue + + try: + lr = LogReader(qlog_path) + dongles.append(dongle_id) + + for msg in lr: + if msg.which() == "pandaStates": + if msg.pandaStates[0].pandaType not in ['uno', 'blackPanda', 'dos']: + break + + elif msg.which() == "carParams": + bts = msg.carParams.as_builder().to_bytes() + + car_fw = msg.carParams.carFw + if len(car_fw) == 0: + break + + live_fingerprint = msg.carParams.carFingerprint + live_fingerprint = migration.get(live_fingerprint, live_fingerprint) + + if args.car is not None: + live_fingerprint = args.car + + if live_fingerprint not in SUPPORTED_CARS: + break + + fw_versions_dict = build_fw_dict(car_fw) + exact_matches = match_fw_to_car_exact(fw_versions_dict) + fuzzy_matches = match_fw_to_car_fuzzy(fw_versions_dict) + + if (len(exact_matches) == 1) and (list(exact_matches)[0] == live_fingerprint): + good_exact += 1 + print(f"Correct! Live: {live_fingerprint} - Fuzzy: {fuzzy_matches}") + + # Check if fuzzy match was correct + if len(fuzzy_matches) == 1: + if list(fuzzy_matches)[0] != live_fingerprint: + wrong_fuzzy += 1 + print(f"{dongle_id}|{time}") + print("Fuzzy match wrong! Fuzzy:", fuzzy_matches, "Live:", live_fingerprint) + else: + good_fuzzy += 1 + break + + print(f"{dongle_id}|{time}") + print("Old style:", live_fingerprint, "Vin", msg.carParams.carVin) + print("New style (exact):", exact_matches) + print("New style (fuzzy):", fuzzy_matches) + + 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, VW_FW_VERSIONS, MAZDA_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() + not_fingerprinted += 1 + + if len(fuzzy_matches) == 1: + if list(fuzzy_matches)[0] == live_fingerprint: + solved_by_fuzzy += 1 + else: + wrong_fuzzy += 1 + print("Fuzzy match wrong! Fuzzy:", fuzzy_matches, "Live:", live_fingerprint) + + break + except Exception: + traceback.print_exc() + except KeyboardInterrupt: + break + + print() + # Print FW versions that need to be added seperated out by car and address + for car, m in sorted(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() + + print() + print(f"Number of dongle ids checked: {len(dongles)}") + print(f"Fingerprinted: {good_exact}") + print(f"Not fingerprinted: {not_fingerprinted}") + print(f" of which had a fuzzy match: {solved_by_fuzzy}") + + print() + print(f"Correct fuzzy matches: {good_fuzzy}") + print(f"Wrong fuzzy matches: {wrong_fuzzy}") + 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..29465ecc8d352c --- /dev/null +++ b/selfdrive/debug/uiview.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +import time +from cereal import messaging, log +from selfdrive.manager.process_config import managed_processes + +if __name__ == "__main__": + procs = ['camerad', 'ui', 'modeld', 'calibrationd'] + + for p in procs: + managed_processes[p].start() + + pm = messaging.PubMaster(['controlsState', 'deviceState', 'pandaStates', 'carParams']) + + msgs = {s: messaging.new_message(s) for s in ['controlsState', 'deviceState', 'carParams']} + msgs['deviceState'].deviceState.started = True + msgs['carParams'].carParams.openpilotLongitudinalControl = True + + msgs['pandaStates'] = messaging.new_message('pandaStates', 1) + msgs['pandaStates'].pandaStates[0].ignitionLine = True + msgs['pandaStates'].pandaStates[0].pandaType = log.PandaState.PandaType.uno + + try: + while True: + time.sleep(1 / 100) # continually send, rate doesn't matter + for s in msgs: + pm.send(s, msgs[s]) + except KeyboardInterrupt: + for p in procs: + managed_processes[p].stop() 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.h b/selfdrive/hardware/base.h new file mode 100644 index 00000000000000..05e55cc0340c66 --- /dev/null +++ b/selfdrive/hardware/base.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +// no-op base hw class +class HardwareNone { +public: + static constexpr float MAX_VOLUME = 0.7; + static constexpr float MIN_VOLUME = 0.2; + + static std::string get_os_version() { return ""; } + + static void reboot() {} + static void poweroff() {} + static void set_brightness(int percent) {} + static void set_display_power(bool on) {} + + static bool get_ssh_enabled() { return false; } + static void set_ssh_enabled(bool enabled) {} + + static bool PC() { return false; } + static bool EON() { return false; } + static bool TICI() { return false; } +}; diff --git a/selfdrive/hardware/base.py b/selfdrive/hardware/base.py new file mode 100644 index 00000000000000..06c86f0c26dfe4 --- /dev/null +++ b/selfdrive/hardware/base.py @@ -0,0 +1,143 @@ +from abc import abstractmethod +from collections import namedtuple + +ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient', 'pmic']) + +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_os_version(self): + pass + + @abstractmethod + def get_device_type(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_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 + + @abstractmethod + def shutdown(self): + pass + + @abstractmethod + def get_thermal_config(self): + pass + + @abstractmethod + def set_screen_brightness(self, percentage): + pass + + @abstractmethod + def get_screen_brightness(self): + pass + + @abstractmethod + def set_power_save(self, powersave_enabled): + pass + + @abstractmethod + def get_gpu_usage_percent(self): + pass + + @abstractmethod + def get_modem_version(self): + pass + + @abstractmethod + def get_modem_temperatures(self): + pass + + @abstractmethod + def get_nvme_temperatures(self): + pass + + @abstractmethod + def initialize_hardware(self): + pass + + @abstractmethod + def get_networks(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/androidd.py b/selfdrive/hardware/eon/androidd.py new file mode 100755 index 00000000000000..b836eb01294dc6 --- /dev/null +++ b/selfdrive/hardware/eon/androidd.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +import os +import time +import psutil +from typing import Optional + +from common.realtime import set_core_affinity, set_realtime_priority +from selfdrive.swaglog import cloudlog + + +MAX_MODEM_CRASHES = 3 +MODEM_PATH = "/sys/devices/soc/2080000.qcom,mss/subsys5" +WATCHED_PROCS = ["zygote", "zygote64", "/system/bin/servicemanager", "/system/bin/surfaceflinger"] + + +def get_modem_crash_count() -> Optional[int]: + try: + with open(os.path.join(MODEM_PATH, "crash_count")) as f: + return int(f.read()) + except Exception: + cloudlog.exception("Error reading modem crash count") + return None + +def get_modem_state() -> str: + try: + with open(os.path.join(MODEM_PATH, "state")) as f: + return f.read().strip() + except Exception: + cloudlog.exception("Error reading modem state") + return "" + +def main(): + set_core_affinity(1) + set_realtime_priority(1) + + procs = {} + crash_count = 0 + modem_killed = False + modem_state = "ONLINE" + while True: + # check critical android services + if any(p is None or not p.is_running() for p in procs.values()) or not len(procs): + cur = {p: None for p in WATCHED_PROCS} + for p in psutil.process_iter(attrs=['cmdline']): + cmdline = None if not len(p.info['cmdline']) else p.info['cmdline'][0] + if cmdline in WATCHED_PROCS: + cur[cmdline] = p + + if len(procs): + for p in WATCHED_PROCS: + if cur[p] != procs[p]: + cloudlog.event("android service pid changed", proc=p, cur=cur[p], prev=procs[p]) + procs.update(cur) + + if os.path.exists(MODEM_PATH): + # check modem state + state = get_modem_state() + if state != modem_state and not modem_killed: + cloudlog.event("modem state changed", state=state) + modem_state = state + + # check modem crashes + cnt = get_modem_crash_count() + if cnt is not None: + if cnt > crash_count: + cloudlog.event("modem crash", count=cnt) + crash_count = cnt + + # handle excessive modem crashes + if crash_count > MAX_MODEM_CRASHES and not modem_killed: + cloudlog.event("killing modem") + with open("/sys/kernel/debug/msm_subsys/modem", "w") as f: + f.write("put") + modem_killed = True + + time.sleep(1) + +if __name__ == "__main__": + main() diff --git a/selfdrive/hardware/eon/hardware.h b/selfdrive/hardware/eon/hardware.h new file mode 100644 index 00000000000000..bcd1aaba740302 --- /dev/null +++ b/selfdrive/hardware/eon/hardware.h @@ -0,0 +1,73 @@ +#pragma once + +#include +#include + +#include +#include +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/base.h" + +class HardwareEon : public HardwareNone { +public: + static constexpr float MAX_VOLUME = 1.0; + static constexpr float MIN_VOLUME = 0.5; + + static bool EON() { return true; } + static std::string get_os_version() { + return "NEOS " + util::read_file("/VERSION"); + }; + + static void reboot() { std::system("reboot"); }; + static void poweroff() { std::system("LD_LIBRARY_PATH= svc power shutdown"); }; + static void set_brightness(int percent) { + std::ofstream brightness_control("/sys/class/leds/lcd-backlight/brightness"); + if (brightness_control.is_open()) { + brightness_control << (int)(percent * (255/100.)) << "\n"; + brightness_control.close(); + } + }; + static void set_display_power(bool on) { + auto dtoken = android::SurfaceComposerClient::getBuiltInDisplay(android::ISurfaceComposer::eDisplayIdMain); + android::SurfaceComposerClient::setDisplayPowerMode(dtoken, on ? HWC_POWER_MODE_NORMAL : HWC_POWER_MODE_OFF); + }; + + static bool get_ssh_enabled() { + return std::system("getprop persist.neos.ssh | grep -qF '1'") == 0; + }; + static void set_ssh_enabled(bool enabled) { + std::string cmd = util::string_format("setprop persist.neos.ssh %d", enabled ? 1 : 0); + std::system(cmd.c_str()); + }; + + // android only + inline static bool launched_activity = false; + static void check_activity() { + int ret = std::system("dumpsys SurfaceFlinger --list | grep -Fq 'com.android.settings'"); + launched_activity = ret == 0; + } + + static void close_activities() { + if(launched_activity) { + std::system("pm disable com.android.settings && pm enable com.android.settings"); + } + } + + static void launch_activity(std::string activity, std::string opts = "") { + if (!launched_activity) { + std::string cmd = "am start -n " + activity + " " + opts + + " --ez extra_prefs_show_button_bar true \ + --es extra_prefs_set_next_text ''"; + std::system(cmd.c_str()); + } + launched_activity = true; + } + static void launch_wifi() { + launch_activity("com.android.settings/.wifi.WifiPickerActivity", "-a android.net.wifi.PICK_WIFI_NETWORK"); + } + static void launch_tethering() { + launch_activity("com.android.settings/.TetherSettings"); + } +}; diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py new file mode 100644 index 00000000000000..fa275c5a9c7ef8 --- /dev/null +++ b/selfdrive/hardware/eon/hardware.py @@ -0,0 +1,410 @@ +import binascii +import itertools +import os +import re +import serial +import struct +import subprocess +from typing import List, Union + +from cereal import log +from selfdrive.hardware.base import HardwareBase, ThermalConfig + +NetworkType = log.DeviceState.NetworkType +NetworkStrength = log.DeviceState.NetworkStrength + +MODEM_PATH = "/dev/smd11" + +def service_call(call: List[str]) -> Union[bytes, None]: + 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) -> Union[bytes, None]: + try: + return struct.unpack(fmt, r)[0] + except Exception: + return None + + +def parse_service_call_string(r: bytes) -> Union[str, None]: + try: + r = r[8:] # Cut off length field + r_str = 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_str[::2], r_str[1::2], fillvalue='\x00'): + result += b + a + + return result.replace('\x00', '') + except Exception: + return None + + +def parse_service_call_bytes(ret: str) -> Union[bytes, None]: + 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: str) -> Union[str, None]: + try: + return subprocess.check_output(["getprop", key], encoding='utf8').strip() + except subprocess.CalledProcessError: + return None + + +class Android(HardwareBase): + def get_os_version(self): + with open("/VERSION") as f: + return f.read().strip() + + def get_device_type(self): + return "eon" + + 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 len(ret) == 0: + 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_info(self): + msg = log.DeviceState.NetworkInfo.new_message() + msg.state = getprop("gsm.sim.state") or "" + msg.technology = getprop("gsm.network.type") or "" + msg.operator = getprop("gsm.sim.operator.numeric") or "" + + try: + modem = serial.Serial(MODEM_PATH, 115200, timeout=0.1) + modem.write(b"AT$QCRSRP?\r") + msg.extra = modem.read_until(b"OK\r\n").decode('utf-8') + + rsrp = msg.extra.split("$QCRSRP: ")[1].split("\r")[0].split(",") + msg.channel = int(rsrp[1]) + except Exception: + pass + + return msg + + 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 + + def shutdown(self): + os.system('LD_LIBRARY_PATH="" svc power shutdown') + + def get_thermal_config(self): + return ThermalConfig(cpu=((5, 7, 10, 12), 10), gpu=((16,), 10), mem=(2, 10), bat=(29, 1000), ambient=(25, 1), pmic=((22,), 1000)) + + def set_screen_brightness(self, percentage): + with open("/sys/class/leds/lcd-backlight/brightness", "w") as f: + f.write(str(int(percentage * 2.55))) + + def get_screen_brightness(self): + try: + with open("/sys/class/leds/lcd-backlight/brightness") as f: + return int(float(f.read()) / 2.55) + except Exception: + return 0 + + def set_power_save(self, powersave_enabled): + pass + + def get_gpu_usage_percent(self): + try: + used, total = open('/sys/devices/soc/b00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/gpubusy').read().strip().split() + perc = 100.0 * int(used) / int(total) + return min(max(perc, 0), 100) + except Exception: + return 0 + + def get_modem_version(self): + return None + + def get_modem_temperatures(self): + # Not sure if we can get this on the LeEco + return [] + + def get_nvme_temperatures(self): + return [] + + def initialize_hardware(self): + pass + + def get_networks(self): + return None diff --git a/selfdrive/hardware/eon/neos.json b/selfdrive/hardware/eon/neos.json new file mode 100644 index 00000000000000..228029e9fb7024 --- /dev/null +++ b/selfdrive/hardware/eon/neos.json @@ -0,0 +1,7 @@ +{ + "ota_url": "https://commadist.azureedge.net/neosupdate/ota-signed-5dc2575d713977666a8e14ae1b43a04d7f63123934c80fa10751d949a107653e.zip", + "ota_hash": "5dc2575d713977666a8e14ae1b43a04d7f63123934c80fa10751d949a107653e", + "recovery_url": "https://commadist.azureedge.net/neosupdate/recovery-f01a55c9ba52ca57668d1684c6bf4118efd31916b04f8c1fcd8495013d3677eb.img", + "recovery_len": 15222060, + "recovery_hash": "f01a55c9ba52ca57668d1684c6bf4118efd31916b04f8c1fcd8495013d3677eb" +} diff --git a/selfdrive/hardware/eon/neos.py b/selfdrive/hardware/eon/neos.py new file mode 100755 index 00000000000000..6f290fbcd19e5d --- /dev/null +++ b/selfdrive/hardware/eon/neos.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +import argparse +import hashlib +import json +import logging +import os +import requests + +NEOSUPDATE_DIR = "/data/neoupdate" + +RECOVERY_DEV = "/dev/block/bootdevice/by-name/recovery" +RECOVERY_COMMAND = "/cache/recovery/command" + + +def get_fn(url: str): + return os.path.join(NEOSUPDATE_DIR, os.path.basename(url)) + + +def download_file(url: str, fn: str, sha256: str, display_name: str, cloudlog=logging) -> None: + # check if already downloaded + if check_hash(fn, sha256): + cloudlog.info(f"{display_name} already cached") + return + + try: + with open(fn, "ab+") as f: + headers = {"Range": f"bytes={f.tell()}-"} + r = requests.get(url, stream=True, allow_redirects=True, headers=headers) + r.raise_for_status() + + total = int(r.headers['Content-Length']) + if 'Content-Range' in r.headers: + total = int(r.headers['Content-Range'].split('/')[-1]) + + for chunk in r.iter_content(chunk_size=1024 * 1024): + f.write(chunk) + print(f"Downloading {display_name}: {f.tell() / total * 100}", flush=True) + except Exception: + cloudlog.error("download error") + if os.path.isfile(fn): + os.unlink(fn) + raise + + if not check_hash(fn, sha256): + if os.path.isfile(fn): + os.unlink(fn) + raise Exception("downloaded update failed hash check") + + +def check_hash(fn: str, sha256: str, length: int = -1) -> bool: + if not os.path.exists(fn): + return False + + h = hashlib.sha256() + with open(fn, "rb") as f: + while f.tell() != length: + r = min(max(0, length - f.tell()), 1024 * 1024) if length > 0 else 1024 * 1024 + dat = f.read(r) + if not dat: + break + h.update(dat) + return h.hexdigest().lower() == sha256.lower() + + +def flash_update(update_fn: str, out_path: str) -> None: + with open(update_fn, "rb") as update, open(out_path, "w+b") as out: + while True: + dat = update.read(8192) + if len(dat) == 0: + break + out.write(dat) + + +def download_neos_update(manifest_path: str, cloudlog=logging) -> None: + with open(manifest_path) as f: + m = json.load(f) + + os.makedirs(NEOSUPDATE_DIR, exist_ok=True) + + # handle recovery updates + if not check_hash(RECOVERY_DEV, m['recovery_hash'], m['recovery_len']): + cloudlog.info("recovery needs update") + recovery_fn = os.path.join(NEOSUPDATE_DIR, os.path.basename(m['recovery_url'])) + download_file(m['recovery_url'], recovery_fn, m['recovery_hash'], "recovery", cloudlog) + + flash_update(recovery_fn, RECOVERY_DEV) + assert check_hash(RECOVERY_DEV, m['recovery_hash'], m['recovery_len']), "recovery flash corrupted" + cloudlog.info("recovery successfully flashed") + + # download OTA update + download_file(m['ota_url'], get_fn(m['ota_url']), m['ota_hash'], "system", cloudlog) + + +def verify_update_ready(manifest_path: str) -> bool: + with open(manifest_path) as f: + m = json.load(f) + + ota_downloaded = check_hash(get_fn(m['ota_url']), m['ota_hash']) + recovery_flashed = check_hash(RECOVERY_DEV, m['recovery_hash'], m['recovery_len']) + return ota_downloaded and recovery_flashed + + +def perform_ota_update(manifest_path: str) -> None: + with open(manifest_path) as f: + m = json.load(f) + + # reboot into recovery + ota_fn = get_fn(m['ota_url']) + with open(RECOVERY_COMMAND, "w") as rf: + rf.write(f"--update_package={ota_fn}\n") + os.system("service call power 16 i32 0 s16 recovery i32 1") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="NEOS update utility", + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("--swap", action="store_true", help="Peform update after downloading") + parser.add_argument("--swap-if-ready", action="store_true", help="Perform update if already downloaded") + parser.add_argument("manifest", help="Manifest json") + args = parser.parse_args() + + logging.basicConfig(level=logging.INFO) + + if args.swap_if_ready: + if verify_update_ready(args.manifest): + perform_ota_update(args.manifest) + else: + download_neos_update(args.manifest, logging) + if args.swap: + perform_ota_update(args.manifest) diff --git a/selfdrive/hardware/eon/updater b/selfdrive/hardware/eon/updater new file mode 100755 index 00000000000000..eaf34e957ceb32 Binary files /dev/null and b/selfdrive/hardware/eon/updater differ diff --git a/selfdrive/hardware/hw.h b/selfdrive/hardware/hw.h new file mode 100644 index 00000000000000..d7a6c8d1d5a60d --- /dev/null +++ b/selfdrive/hardware/hw.h @@ -0,0 +1,36 @@ +#pragma once + +#include "selfdrive/hardware/base.h" +#include "selfdrive/common/util.h" + +#ifdef QCOM +#include "selfdrive/hardware/eon/hardware.h" +#define Hardware HardwareEon +#elif QCOM2 +#include "selfdrive/hardware/tici/hardware.h" +#define Hardware HardwareTici +#else +class HardwarePC : public HardwareNone { +public: + static std::string get_os_version() { return "openpilot for PC"; } + static bool PC() { return true; } + static bool TICI() { return util::getenv("TICI", 0) == 1; } +}; +#define Hardware HardwarePC +#endif + +namespace Path { +inline static std::string HOME = util::getenv("HOME"); +inline std::string log_root() { + if (const char *env = getenv("LOG_ROOT")) { + return env; + } + return Hardware::PC() ? HOME + "/.comma/media/0/realdata" : "/data/media/0/realdata"; +} +inline std::string params() { + return Hardware::PC() ? HOME + "/.comma/params" : "/data/params"; +} +inline std::string rsa_file() { + return Hardware::PC() ? HOME + "/.comma/persist/comma/id_rsa" : "/persist/comma/id_rsa"; +} +} // namespace Path 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..8231bbc2f967ba --- /dev/null +++ b/selfdrive/hardware/pc/hardware.py @@ -0,0 +1,108 @@ +import random + +from cereal import log +from selfdrive.hardware.base import HardwareBase, ThermalConfig + +NetworkType = log.DeviceState.NetworkType +NetworkStrength = log.DeviceState.NetworkStrength + + +class Pc(HardwareBase): + def get_os_version(self): + return None + + def get_device_type(self): + return "pc" + + 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_info(self): + return None + + 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 + + def shutdown(self): + print("SHUTDOWN!") + + def get_thermal_config(self): + return ThermalConfig(cpu=((None,), 1), gpu=((None,), 1), mem=(None, 1), bat=(None, 1), ambient=(None, 1), pmic=((None,), 1)) + + def set_screen_brightness(self, percentage): + pass + + def get_screen_brightness(self): + return 0 + + def set_power_save(self, powersave_enabled): + pass + + def get_gpu_usage_percent(self): + return 0 + + def get_modem_version(self): + return None + + def get_modem_temperatures(self): + return [] + + def get_nvme_temperatures(self): + return [] + + def initialize_hardware(self): + pass + + def get_networks(self): + return None 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/agnos.json b/selfdrive/hardware/tici/agnos.json new file mode 100644 index 00000000000000..f22575a33523e8 --- /dev/null +++ b/selfdrive/hardware/tici/agnos.json @@ -0,0 +1,52 @@ +[ + { + "name": "boot", + "url": "https://commadist.azureedge.net/agnosupdate/boot-5ad783213b7de18400f5fd3609fe75677fec80780ae31cbdf5a8ee7106675d7c.img.xz", + "hash": "5ad783213b7de18400f5fd3609fe75677fec80780ae31cbdf5a8ee7106675d7c", + "hash_raw": "5ad783213b7de18400f5fd3609fe75677fec80780ae31cbdf5a8ee7106675d7c", + "size": 14768128, + "sparse": false, + "full_check": true, + "has_ab": true + }, + { + "name": "abl", + "url": "https://commadist.azureedge.net/agnosupdate/abl-ab4068f005ed9cb7fbca55c6d658880df1abfb1a4e6afb64f3fc5e64dac6fc82.img.xz", + "hash": "ab4068f005ed9cb7fbca55c6d658880df1abfb1a4e6afb64f3fc5e64dac6fc82", + "hash_raw": "ab4068f005ed9cb7fbca55c6d658880df1abfb1a4e6afb64f3fc5e64dac6fc82", + "size": 274432, + "sparse": false, + "full_check": true, + "has_ab": true + }, + { + "name": "xbl", + "url": "https://commadist.azureedge.net/agnosupdate/xbl-2b1b67aa918cd127f2b0b4ed0a372f3a93676cf9d270bd3e56329516efdc5a35.img.xz", + "hash": "2b1b67aa918cd127f2b0b4ed0a372f3a93676cf9d270bd3e56329516efdc5a35", + "hash_raw": "2b1b67aa918cd127f2b0b4ed0a372f3a93676cf9d270bd3e56329516efdc5a35", + "size": 3670016, + "sparse": false, + "full_check": true, + "has_ab": true + }, + { + "name": "xbl_config", + "url": "https://commadist.azureedge.net/agnosupdate/xbl_config-3aa926394b4cec464300bfc0e7ab77d50889b38041138c60cd84c397930b38ad.img.xz", + "hash": "3aa926394b4cec464300bfc0e7ab77d50889b38041138c60cd84c397930b38ad", + "hash_raw": "3aa926394b4cec464300bfc0e7ab77d50889b38041138c60cd84c397930b38ad", + "size": 364544, + "sparse": false, + "full_check": true, + "has_ab": true + }, + { + "name": "system", + "url": "https://commadist.azureedge.net/agnosupdate/system-0fee88a42385d067756e9b25d57a80228835310deb7b5eef7b7bed5c22c45515.img.xz", + "hash": "a043cba1ae08ca6d17704a8a0978b1e27e5bc79abb85b97efd35203ae26ae1ea", + "hash_raw": "0fee88a42385d067756e9b25d57a80228835310deb7b5eef7b7bed5c22c45515", + "size": 10737418240, + "sparse": true, + "full_check": false, + "has_ab": true + } +] diff --git a/selfdrive/hardware/tici/agnos.py b/selfdrive/hardware/tici/agnos.py new file mode 100755 index 00000000000000..a28b13ac4a4bd9 --- /dev/null +++ b/selfdrive/hardware/tici/agnos.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python3 +import json +import lzma +import hashlib +import requests +import struct +import subprocess +import time +import os +from typing import Generator + +SPARSE_CHUNK_FMT = struct.Struct('H2xI4x') + + +class StreamingDecompressor: + def __init__(self, url: str) -> None: + self.buf = b"" + + self.req = requests.get(url, stream=True, headers={'Accept-Encoding': None}) + self.it = self.req.iter_content(chunk_size=1024 * 1024) + self.decompressor = lzma.LZMADecompressor(format=lzma.FORMAT_AUTO) + self.eof = False + self.sha256 = hashlib.sha256() + + def read(self, length: int) -> bytes: + while len(self.buf) < length: + self.req.raise_for_status() + + try: + compressed = next(self.it) + except StopIteration: + self.eof = True + break + out = self.decompressor.decompress(compressed) + self.buf += out + + result = self.buf[:length] + self.buf = self.buf[length:] + + self.sha256.update(result) + return result + + +def unsparsify(f: StreamingDecompressor) -> Generator[bytes, None, None]: + # https://source.android.com/devices/bootloader/images#sparse-format + magic = struct.unpack("I", f.read(4))[0] + assert(magic == 0xed26ff3a) + + # Version + major = struct.unpack("H", f.read(2))[0] + minor = struct.unpack("H", f.read(2))[0] + assert(major == 1 and minor == 0) + + f.read(2) # file header size + f.read(2) # chunk header size + + block_sz = struct.unpack("I", f.read(4))[0] + f.read(4) # total blocks + num_chunks = struct.unpack("I", f.read(4))[0] + f.read(4) # crc checksum + + for _ in range(num_chunks): + chunk_type, out_blocks = SPARSE_CHUNK_FMT.unpack(f.read(12)) + + if chunk_type == 0xcac1: # Raw + # TODO: yield in smaller chunks. Yielding only block_sz is too slow. Largest observed data chunk is 252 MB. + yield f.read(out_blocks * block_sz) + elif chunk_type == 0xcac2: # Fill + filler = f.read(4) * (block_sz // 4) + for _ in range(out_blocks): + yield filler + elif chunk_type == 0xcac3: # Don't care + yield b"" + else: + raise Exception("Unhandled sparse chunk type") + +# noop wrapper with same API as unsparsify() for non sparse images +def noop(f: StreamingDecompressor) -> Generator[bytes, None, None]: + while not f.eof: + yield f.read(1024 * 1024) + + +def get_target_slot_number() -> int: + current_slot = subprocess.check_output(["abctl", "--boot_slot"], encoding='utf-8').strip() + return 1 if current_slot == "_a" else 0 + + +def slot_number_to_suffix(slot_number: int) -> str: + assert slot_number in (0, 1) + return '_a' if slot_number == 0 else '_b' + + +def get_partition_path(target_slot_number: int, partition: dict) -> str: + path = f"/dev/disk/by-partlabel/{partition['name']}" + + if partition.get('has_ab', True): + path += slot_number_to_suffix(target_slot_number) + + return path + + +def verify_partition(target_slot_number: int, partition: dict) -> bool: + full_check = partition['full_check'] + path = get_partition_path(target_slot_number, partition) + partition_size = partition['size'] + + with open(path, 'rb+') as out: + if full_check: + raw_hash = hashlib.sha256() + + pos = 0 + chunk_size = 1024 * 1024 + while pos < partition_size: + n = min(chunk_size, partition_size - pos) + raw_hash.update(out.read(n)) + pos += n + + return raw_hash.hexdigest().lower() == partition['hash_raw'].lower() + else: + out.seek(partition_size) + return out.read(64) == partition['hash_raw'].lower().encode() + + +def clear_partition_hash(target_slot_number: int, partition: dict) -> None: + path = get_partition_path(target_slot_number, partition) + with open(path, 'wb+') as out: + partition_size = partition['size'] + + out.seek(partition_size) + out.write(b"\x00" * 64) + os.sync() + + +def flash_partition(target_slot_number: int, partition: dict, cloudlog): + cloudlog.info(f"Downloading and writing {partition['name']}") + + if verify_partition(target_slot_number, partition): + cloudlog.info(f"Already flashed {partition['name']}") + return + + downloader = StreamingDecompressor(partition['url']) + + # Clear hash before flashing in case we get interrupted + full_check = partition['full_check'] + if not full_check: + clear_partition_hash(target_slot_number, partition) + + path = get_partition_path(target_slot_number, partition) + with open(path, 'wb+') as out: + # Flash partition + last_p = 0 + raw_hash = hashlib.sha256() + f = unsparsify if partition['sparse'] else noop + for chunk in f(downloader): + raw_hash.update(chunk) + out.write(chunk) + p = int(out.tell() / partition['size'] * 100) + if p != last_p: + last_p = p + print(f"Installing {partition['name']}: {p}", flush=True) + + if raw_hash.hexdigest().lower() != partition['hash_raw'].lower(): + raise Exception(f"Raw hash mismatch '{raw_hash.hexdigest().lower()}'") + + if downloader.sha256.hexdigest().lower() != partition['hash'].lower(): + raise Exception("Uncompressed hash mismatch") + + if out.tell() != partition['size']: + raise Exception("Uncompressed size mismatch") + + # Write hash after successfull flash + os.sync() + if not full_check: + out.write(partition['hash_raw'].lower().encode()) + + +def swap(manifest_path: str, target_slot_number: int, cloudlog) -> None: + update = json.load(open(manifest_path)) + for partition in update: + if not partition.get('full_check', False): + clear_partition_hash(target_slot_number, partition) + + while True: + out = subprocess.check_output(f"abctl --set_active {target_slot_number}", shell=True, stderr=subprocess.STDOUT, encoding='utf8') + if ("No such file or directory" not in out) and ("lun as boot lun" in out): + cloudlog.info(f"Swap successfull {out}") + break + else: + cloudlog.error(f"Swap failed {out}") + + +def flash_agnos_update(manifest_path: str, target_slot_number: int, cloudlog) -> None: + update = json.load(open(manifest_path)) + + cloudlog.info(f"Target slot {target_slot_number}") + + # set target slot as unbootable + os.system(f"abctl --set_unbootable {target_slot_number}") + + for partition in update: + success = False + + for retries in range(10): + try: + flash_partition(target_slot_number, partition, cloudlog) + success = True + break + + except requests.exceptions.RequestException: + cloudlog.exception("Failed") + cloudlog.info(f"Failed to download {partition['name']}, retrying ({retries})") + time.sleep(10) + + if not success: + cloudlog.info(f"Failed to flash {partition['name']}, aborting") + raise Exception("Maximum retries exceeded") + + cloudlog.info(f"AGNOS ready on slot {target_slot_number}") + + +def verify_agnos_update(manifest_path: str, target_slot_number: int) -> bool: + update = json.load(open(manifest_path)) + return all(verify_partition(target_slot_number, partition) for partition in update) + + +if __name__ == "__main__": + import logging + import argparse + + parser = argparse.ArgumentParser(description="Flash and verify AGNOS update", + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + + parser.add_argument("--verify", action="store_true", help="Verify and perform swap if update ready") + parser.add_argument("--swap", action="store_true", help="Verify and perform swap, downloads if necessary") + parser.add_argument("manifest", help="Manifest json") + args = parser.parse_args() + + logging.basicConfig(level=logging.INFO) + + target_slot_number = get_target_slot_number() + if args.verify: + if verify_agnos_update(args.manifest, target_slot_number): + swap(args.manifest, target_slot_number, logging) + exit(0) + exit(1) + elif args.swap: + while not verify_agnos_update(args.manifest, target_slot_number): + logging.error("Verification failed. Flashing AGNOS") + flash_agnos_update(args.manifest, target_slot_number, logging) + + logging.warning(f"Verification succeeded. Swapping to slot {target_slot_number}") + swap(args.manifest, target_slot_number, logging) + else: + flash_agnos_update(args.manifest, target_slot_number, logging) diff --git a/selfdrive/hardware/tici/amplifier.py b/selfdrive/hardware/tici/amplifier.py new file mode 100755 index 00000000000000..a8b27986308aaa --- /dev/null +++ b/selfdrive/hardware/tici/amplifier.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +from smbus2 import SMBus +from collections import namedtuple + +# https://datasheets.maximintegrated.com/en/ds/MAX98089.pdf + +AmpConfig = namedtuple('AmpConfig', ['name', 'value', 'register', 'offset', 'mask']) +EQParams = namedtuple('EQParams', ['K', 'k1', 'k2', 'c1', 'c2']) + +def configs_from_eq_params(base, eq_params): + return [ + AmpConfig("K (high)", (eq_params.K >> 8), base, 0, 0xFF), + AmpConfig("K (low)", (eq_params.K & 0xFF), base + 1, 0, 0xFF), + AmpConfig("k1 (high)", (eq_params.k1 >> 8), base + 2, 0, 0xFF), + AmpConfig("k1 (low)", (eq_params.k1 & 0xFF), base + 3, 0, 0xFF), + AmpConfig("k2 (high)", (eq_params.k2 >> 8), base + 4, 0, 0xFF), + AmpConfig("k2 (low)", (eq_params.k2 & 0xFF), base + 5, 0, 0xFF), + AmpConfig("c1 (high)", (eq_params.c1 >> 8), base + 6, 0, 0xFF), + AmpConfig("c1 (low)", (eq_params.c1 & 0xFF), base + 7, 0, 0xFF), + AmpConfig("c2 (high)", (eq_params.c2 >> 8), base + 8, 0, 0xFF), + AmpConfig("c2 (low)", (eq_params.c2 & 0xFF), base + 9, 0, 0xFF), + ] + +BASE_CONFIG = [ + AmpConfig("MCLK prescaler", 0b01, 0x10, 4, 0b00110000), + AmpConfig("PM: enable speakers", 0b11, 0x4D, 4, 0b00110000), + AmpConfig("PM: enable DACs", 0b11, 0x4D, 0, 0b00000011), + AmpConfig("Right speaker output from right DAC", 0b1, 0x2C, 0, 0b11111111), + AmpConfig("Right Speaker Mixer Gain", 0b00, 0x2D, 2, 0b00001100), + AmpConfig("Enable PLL1", 0b1, 0x12, 7, 0b10000000), + AmpConfig("Enable PLL2", 0b1, 0x1A, 7, 0b10000000), + AmpConfig("DAI1: I2S mode", 0b00100, 0x14, 2, 0b01111100), + AmpConfig("DAI2: I2S mode", 0b00100, 0x1C, 2, 0b01111100), + AmpConfig("Right speaker output volume", 0x1c, 0x3E, 0, 0b00011111), + AmpConfig("DAI1 Passband filtering: music mode", 0b1, 0x18, 7, 0b10000000), + AmpConfig("DAI1 voice mode gain (DV1G)", 0b00, 0x2F, 4, 0b00110000), + AmpConfig("DAI1 attenuation (DV1)", 0x0, 0x2F, 0, 0b00001111), + AmpConfig("DAI2 attenuation (DV2)", 0x0, 0x31, 0, 0b00001111), + AmpConfig("DAI2: DC blocking", 0b1, 0x20, 0, 0b00000001), + AmpConfig("DAI2: High sample rate", 0b0, 0x20, 3, 0b00001000), + AmpConfig("ALC enable", 0b1, 0x43, 7, 0b10000000), + AmpConfig("ALC/excursion limiter release time", 0b101, 0x43, 4, 0b01110000), + AmpConfig("ALC multiband enable", 0b1, 0x43, 3, 0b00001000), + AmpConfig("DAI1 EQ enable", 0b0, 0x49, 0, 0b00000001), + AmpConfig("DAI2 EQ enable", 0b1, 0x49, 1, 0b00000010), + AmpConfig("DAI2 EQ clip detection disabled", 0b1, 0x32, 4, 0b00010000), + AmpConfig("DAI2 EQ attenuation", 0x5, 0x32, 0, 0b00001111), + AmpConfig("Excursion limiter upper corner freq", 0b100, 0x41, 4, 0b01110000), + AmpConfig("Excursion limiter lower corner freq", 0b00, 0x41, 0, 0b00000011), + AmpConfig("Excursion limiter threshold", 0b000, 0x42, 0, 0b00001111), + AmpConfig("Distortion limit (THDCLP)", 0x6, 0x46, 4, 0b11110000), + AmpConfig("Distortion limiter release time constant", 0b0, 0x46, 0, 0b00000001), + AmpConfig("Right DAC input mixer: DAI1 left", 0b0, 0x22, 3, 0b00001000), + AmpConfig("Right DAC input mixer: DAI1 right", 0b0, 0x22, 2, 0b00000100), + AmpConfig("Right DAC input mixer: DAI2 left", 0b1, 0x22, 1, 0b00000010), + AmpConfig("Right DAC input mixer: DAI2 right", 0b0, 0x22, 0, 0b00000001), + AmpConfig("DAI1 audio port selector", 0b10, 0x16, 6, 0b11000000), + AmpConfig("DAI2 audio port selector", 0b01, 0x1E, 6, 0b11000000), + AmpConfig("Enable left digital microphone", 0b1, 0x48, 5, 0b00100000), + AmpConfig("Enable right digital microphone", 0b1, 0x48, 4, 0b00010000), + AmpConfig("Enhanced volume smoothing disabled", 0b0, 0x49, 7, 0b10000000), + AmpConfig("Volume adjustment smoothing disabled", 0b0, 0x49, 6, 0b01000000), + AmpConfig("Zero-crossing detection disabled", 0b0, 0x49, 5, 0b00100000), +] + +BASE_CONFIG += configs_from_eq_params(0x84, EQParams(0x274F, 0xC0FF, 0x3BF9, 0x0B3C, 0x1656)) +BASE_CONFIG += configs_from_eq_params(0x8E, EQParams(0x1009, 0xC6BF, 0x2952, 0x1C97, 0x30DF)) +BASE_CONFIG += configs_from_eq_params(0x98, EQParams(0x0F75, 0xCBE5, 0x0ED2, 0x2528, 0x3E42)) +BASE_CONFIG += configs_from_eq_params(0xA2, EQParams(0x091F, 0x3D4C, 0xCE11, 0x1266, 0x2807)) +BASE_CONFIG += configs_from_eq_params(0xAC, EQParams(0x0A9E, 0x3F20, 0xE573, 0x0A8B, 0x3A3B)) + +class Amplifier: + AMP_I2C_BUS = 0 + AMP_ADDRESS = 0x10 + + def __init__(self, debug=False): + self.debug = debug + + def set_config(self, config): + with SMBus(self.AMP_I2C_BUS) as bus: + if self.debug: + print(f"Setting \"{config.name}\" to {config.value}:") + + old_value = bus.read_byte_data(self.AMP_ADDRESS, config.register, force=True) + new_value = (old_value & (~config.mask)) | ((config.value << config.offset) & config.mask) + bus.write_byte_data(self.AMP_ADDRESS, config.register, new_value, force=True) + + if self.debug: + print(f" Changed {hex(config.register)}: {hex(old_value)} -> {hex(new_value)}") + + def set_global_shutdown(self, amp_disabled): + self.set_config(AmpConfig("Global shutdown", 0b0 if amp_disabled else 0b1, 0x51, 7, 0b10000000)) + + def initialize_configuration(self): + self.set_global_shutdown(amp_disabled=True) + + for config in BASE_CONFIG: + self.set_config(config) + + self.set_global_shutdown(amp_disabled=False) + + +if __name__ == "__main__": + Amplifier(debug=True).initialize_configuration() diff --git a/selfdrive/hardware/tici/hardware.h b/selfdrive/hardware/tici/hardware.h new file mode 100644 index 00000000000000..c37dbb0a364dca --- /dev/null +++ b/selfdrive/hardware/tici/hardware.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/base.h" + +class HardwareTici : public HardwareNone { +public: + static constexpr float MAX_VOLUME = 0.9; + static constexpr float MIN_VOLUME = 0.2; + static bool TICI() { return true; } + static std::string get_os_version() { + return "AGNOS " + util::read_file("/VERSION"); + }; + + static void reboot() { std::system("sudo reboot"); }; + static void poweroff() { std::system("sudo poweroff"); }; + static void set_brightness(int percent) { + std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness"); + if (brightness_control.is_open()) { + brightness_control << (percent * (int)(1023/100.)) << "\n"; + brightness_control.close(); + } + }; + static void set_display_power(bool on) { + std::ofstream bl_power_control("/sys/class/backlight/panel0-backlight/bl_power"); + if (bl_power_control.is_open()) { + bl_power_control << (on ? "0" : "4") << "\n"; + bl_power_control.close(); + } + }; + + static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); }; + static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); }; +}; diff --git a/selfdrive/hardware/tici/hardware.py b/selfdrive/hardware/tici/hardware.py new file mode 100644 index 00000000000000..855eee908efc62 --- /dev/null +++ b/selfdrive/hardware/tici/hardware.py @@ -0,0 +1,348 @@ +import json +import math +import os +import subprocess +from enum import IntEnum +from functools import cached_property +from pathlib import Path + +from cereal import log +from selfdrive.hardware.base import HardwareBase, ThermalConfig +from selfdrive.hardware.tici import iwlist +from selfdrive.hardware.tici.amplifier import Amplifier + +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" + +class MM_MODEM_STATE(IntEnum): + FAILED = -1 + UNKNOWN = 0 + INITIALIZING = 1 + LOCKED = 2 + DISABLED = 3 + DISABLING = 4 + ENABLING = 5 + ENABLED = 6 + SEARCHING = 7 + REGISTERED = 8 + DISCONNECTING = 9 + CONNECTING = 10 + CONNECTED = 11 + +TIMEOUT = 0.1 + +NetworkType = log.DeviceState.NetworkType +NetworkStrength = log.DeviceState.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): + @cached_property + def bus(self): + import dbus # pylint: disable=import-error + return dbus.SystemBus() + + @cached_property + def nm(self): + return self.bus.get_object(NM, '/org/freedesktop/NetworkManager') + + @cached_property + def mm(self): + return self.bus.get_object(MM, '/org/freedesktop/ModemManager1') + + @cached_property + def amplifier(self): + return Amplifier() + + def get_os_version(self): + with open("/VERSION") as f: + return f.read().strip() + + def get_device_type(self): + return "tici" + + def get_sound_card_online(self): + return (os.path.isfile('/proc/asound/card0/state') and + open('/proc/asound/card0/state').read().strip() == 'ONLINE') + + def reboot(self, reason=None): + subprocess.check_output(["sudo", "reboot"]) + + def uninstall(self): + Path("/data/__system_reset__").touch() + os.sync() + self.reboot() + + def get_serial(self): + return self.get_cmdline()['androidboot.serialno'] + + def get_network_type(self): + try: + primary_connection = self.nm.Get(NM, 'PrimaryConnection', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + primary_connection = self.bus.get_object(NM, primary_connection) + primary_type = primary_connection.Get(NM_CON_ACT, 'Type', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + primary_id = primary_connection.Get(NM_CON_ACT, 'Id', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + + if primary_type == '802-3-ethernet': + return NetworkType.ethernet + elif primary_type == '802-11-wireless' and primary_id != 'Hotspot': + return NetworkType.wifi + else: + active_connections = self.nm.Get(NM, 'ActiveConnections', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + for conn in active_connections: + c = self.bus.get_object(NM, conn) + tp = c.Get(NM_CON_ACT, 'Type', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + if tp == 'gsm': + modem = self.get_modem() + access_t = modem.Get(MM_MODEM, 'AccessTechnologies', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + 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 + except Exception: + pass + + return NetworkType.none + + def get_modem(self): + objects = self.mm.GetManagedObjects(dbus_interface="org.freedesktop.DBus.ObjectManager", timeout=TIMEOUT) + 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, timeout=TIMEOUT) + 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, timeout=TIMEOUT) + + 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, timeout=TIMEOUT)), + 'mcc_mnc': str(sim.Get(MM_SIM, 'OperatorIdentifier', dbus_interface=DBUS_PROPS, timeout=TIMEOUT)), + 'network_type': ["Unknown"], + 'sim_state': ["READY"], + 'data_connected': modem.Get(MM_MODEM, 'State', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) == 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, timeout=TIMEOUT)) + + def get_network_info(self): + modem = self.get_modem() + try: + info = modem.Command("AT+QNWINFO", math.ceil(TIMEOUT), dbus_interface=MM_MODEM, timeout=TIMEOUT) + extra = modem.Command('AT+QENG="servingcell"', math.ceil(TIMEOUT), dbus_interface=MM_MODEM, timeout=TIMEOUT) + state = modem.Get(MM_MODEM, 'State', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + except Exception: + return None + + if info and info.startswith('+QNWINFO: '): + info = info.replace('+QNWINFO: ', '').replace('"', '').split(',') + extra = "" if extra is None else extra.replace('+QENG: "servingcell",', '').replace('"', '') + state = "" if state is None else MM_MODEM_STATE(state).name + + if len(info) != 4: + return None + + technology, operator, band, channel = info + + return({ + 'technology': technology, + 'operator': operator, + 'band': band, + 'channel': int(channel), + 'extra': extra, + 'state': state, + }) + else: + return None + + 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 + + try: + 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, timeout=TIMEOUT) + 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, timeout=TIMEOUT)) + network_strength = self.parse_strength(strength) + else: # Cellular + modem = self.get_modem() + strength = int(modem.Get(MM_MODEM, 'SignalQuality', dbus_interface=DBUS_PROPS, timeout=TIMEOUT)[0]) + network_strength = self.parse_strength(strength) + except Exception: + pass + + return network_strength + + def get_modem_version(self): + try: + modem = self.get_modem() + return modem.Get(MM_MODEM, 'Revision', dbus_interface=DBUS_PROPS, timeout=TIMEOUT) + except Exception: + return None + + def get_modem_temperatures(self): + timeout = 0.2 # Default timeout is too short + try: + modem = self.get_modem() + temps = modem.Command("AT+QTEMP", math.ceil(timeout), dbus_interface=MM_MODEM, timeout=timeout) + return list(map(int, temps.split(' ')[1].split(','))) + except Exception: + return [] + + def get_nvme_temperatures(self): + ret = [] + try: + out = subprocess.check_output("sudo smartctl -aj /dev/nvme0", shell=True) + dat = json.loads(out) + ret = list(map(int, dat["nvme_smart_health_information_log"]["temperature_sensors"])) + except Exception: + pass + return ret + + # 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) + + def shutdown(self): + # Note that for this to work and have the device stay powered off, the panda needs to be in UsbPowerMode::CLIENT! + os.system("sudo poweroff") + + def get_thermal_config(self): + return ThermalConfig(cpu=((1, 2, 3, 4, 5, 6, 7, 8), 1000), gpu=((48,49), 1000), mem=(15, 1000), bat=(None, 1), ambient=(65, 1000), pmic=((35, 36), 1000)) + + def set_screen_brightness(self, percentage): + try: + with open("/sys/class/backlight/panel0-backlight/brightness", "w") as f: + f.write(str(int(percentage * 10.23))) + except Exception: + pass + + def get_screen_brightness(self): + try: + with open("/sys/class/backlight/panel0-backlight/brightness") as f: + return int(float(f.read()) / 10.23) + except Exception: + return 0 + + def set_power_save(self, powersave_enabled): + # amplifier, 100mW at idle + self.amplifier.set_global_shutdown(amp_disabled=powersave_enabled) + if not powersave_enabled: + self.amplifier.initialize_configuration() + + # offline big cluster, leave core 4 online for boardd + for i in range(5, 8): + # TODO: fix permissions with udev + val = "0" if powersave_enabled else "1" + os.system(f"sudo su -c 'echo {val} > /sys/devices/system/cpu/cpu{i}/online'") + + for n in ('0', '4'): + gov = 'userspace' if powersave_enabled else 'performance' + os.system(f"sudo su -c 'echo {gov} > /sys/devices/system/cpu/cpufreq/policy{n}/scaling_governor'") + + if powersave_enabled: + os.system(f"sudo su -c 'echo 979200 > /sys/devices/system/cpu/cpufreq/policy{n}/scaling_setspeed'") + + def get_gpu_usage_percent(self): + try: + used, total = open('/sys/class/kgsl/kgsl-3d0/gpubusy').read().strip().split() + return 100.0 * int(used) / int(total) + except Exception: + return 0 + + def initialize_hardware(self): + self.amplifier.initialize_configuration() + + def get_networks(self): + r = {} + + wlan = iwlist.scan() + if wlan is not None: + r['wlan'] = wlan + + lte_info = self.get_network_info() + if lte_info is not None: + extra = lte_info['extra'] + + # ,"LTE",,,,,,,, + # ,,,,,,, + if 'LTE' in extra: + extra = extra.split(',') + try: + r['lte'] = [{ + "mcc": int(extra[3]), + "mnc": int(extra[4]), + "cid": int(extra[5], 16), + "nmr": [{"pci": int(extra[6]), "earfcn": int(extra[7])}], + }] + except (ValueError, IndexError): + pass + + return r diff --git a/selfdrive/hardware/tici/iwlist.py b/selfdrive/hardware/tici/iwlist.py new file mode 100644 index 00000000000000..1e7c428b40679a --- /dev/null +++ b/selfdrive/hardware/tici/iwlist.py @@ -0,0 +1,35 @@ +import subprocess + + +def scan(interface="wlan0"): + result = [] + try: + r = subprocess.check_output(["iwlist", interface, "scan"], encoding='utf8') + + mac = None + for line in r.split('\n'): + if "Address" in line: + # Based on the adapter eithere a percentage or dBm is returned + # Add previous network in case no dBm signal level was seen + if mac is not None: + result.append({"mac": mac}) + mac = None + + mac = line.split(' ')[-1] + elif "dBm" in line: + try: + level = line.split('Signal level=')[1] + rss = int(level.split(' ')[0]) + result.append({"mac": mac, "rss": rss}) + mac = None + except ValueError: + continue + + # Add last network if no dBm was found + if mac is not None: + result.append({"mac": mac}) + + return result + + except Exception: + return None 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/hardware/tici/updater b/selfdrive/hardware/tici/updater new file mode 100755 index 00000000000000..1c577512005494 Binary files /dev/null and b/selfdrive/hardware/tici/updater differ diff --git a/selfdrive/locationd/.gitignore b/selfdrive/locationd/.gitignore index 8cdb0d23050783..5268902785092c 100644 --- a/selfdrive/locationd/.gitignore +++ b/selfdrive/locationd/.gitignore @@ -1,3 +1,5 @@ ubloxd ubloxd_test -params_learner \ No newline at end of file +params_learner +paramsd +locationd diff --git a/selfdrive/locationd/Makefile b/selfdrive/locationd/Makefile deleted file mode 100644 index f7652648e1bbe1..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 params_learner - -include ../common/cereal.mk - -LOC_OBJS = locationd_yawrate.o params_learner.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) - -params_learner: $(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 params_learner 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..4b7fba19b6c933 --- /dev/null +++ b/selfdrive/locationd/SConscript @@ -0,0 +1,22 @@ +Import('env', 'common', 'cereal', 'messaging', 'libkf', 'transformations') + +loc_libs = [cereal, messaging, 'zmq', common, 'capnp', 'kj', 'kaitai', 'pthread'] + +if GetOption('kaitai'): + generated = Dir('generated').srcnode().abspath + cmd = f"kaitai-struct-compiler --target cpp_stl --outdir {generated} $SOURCES" + env.Command(['generated/ubx.cpp', 'generated/ubx.h'], 'ubx.ksy', cmd) + env.Command(['generated/gps.cpp', 'generated/gps.h'], 'gps.ksy', cmd) + +env.Program("ubloxd", ["ubloxd.cc", "ublox_msg.cc", "generated/ubx.cpp", "generated/gps.cpp"], LIBS=loc_libs) + +ekf_sym_cc = env.SharedObject("#rednose/helpers/ekf_sym.cc") +locationd_sources = ["locationd.cc", "models/live_kf.cc", ekf_sym_cc] +lenv = env.Clone() +lenv["_LIBFLAGS"] += f' {libkf[0].get_labspath()}' +locationd = lenv.Program("locationd", locationd_sources, LIBS=loc_libs + transformations) +lenv.Depends(locationd, libkf) + +if File("liblocationd.cc").exists(): + liblocationd = lenv.SharedLibrary("liblocationd", ["liblocationd.cc"] + locationd_sources, LIBS=loc_libs + transformations) + lenv.Depends(liblocationd, libkf) 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 e3a0b10ad0ae91..604f4f68d92967 100755 --- a/selfdrive/locationd/calibrationd.py +++ b/selfdrive/locationd/calibrationd.py @@ -1,120 +1,216 @@ -#!/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 copy -import json import numpy as np -import selfdrive.messaging as messaging -from selfdrive.locationd.calibration_helpers import Calibration +import cereal.messaging as messaging +from cereal import log +from selfdrive.hardware import TICI +from common.params import Params, put_nonblocking +from common.transformations.model import model_height +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 -from selfdrive.services import service_list -from common.params import Params -from common.transformations.model import model_height, get_camera_frame_from_model_frame, get_camera_frame_from_medmodel_frame -from common.transformations.camera import view_frame_from_device_frame, get_view_frame_from_road_frame, \ - eon_intrinsics, get_calib_from_vp, H, W - -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 accommodate 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") + self.wide_camera = TICI and params.get_bool('EnableWideCamera') + rpy_init = RPY_INIT + valid_blocks = 0 + + if param_put and calibration_params: try: - 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() + msg = log.Event.from_bytes(calibration_params) + rpy_init = list(msg.liveCalibration.rpyCalib) + valid_blocks = msg.liveCalibration.validBlocks except Exception: - cloudlog.exception("CalibrationParams file found but error encountered") + cloudlog.exception("Error reading cached CalibrationParams") + 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 - - 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) - ke = eon_intrinsics.dot(extrinsic_matrix) - warp_matrix = get_camera_frame_from_model_frame(ke) - warp_matrix_big = get_camera_frame_from_medmodel_frame(ke) - - 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.warpMatrix2 = [float(x) for x in warp_matrix.flatten()] - cal_send.liveCalibration.warpMatrixBig = [float(x) for x in warp_matrix_big.flatten()] - cal_send.liveCalibration.extrinsicMatrix = [float(x) for x in extrinsic_matrix.flatten()] - - livecalibration.send(cal_send.to_bytes()) - - -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) + self.cal_status = Calibration.INVALID + + # If spread is too high, assume mounting was changed and reset to last block. + # Make the transition smooth. Abrupt transitions 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: + put_nonblocking("CalibrationParams", self.get_msg().to_bytes()) + + 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)) + if self.wide_camera: + angle_std_threshold = 4*MAX_VEL_ANGLE_STD + else: + angle_std_threshold = MAX_VEL_ANGLE_STD + certain_if_calib = ((np.arctan2(trans_std[1], trans[0]) < angle_std_threshold) or + (self.valid_blocks < INPUTS_NEEDED)) + if not (straight_and_fast and certain_if_calib): + return None + + 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) + + 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) + + 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']) + 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/generated/gps.cpp b/selfdrive/locationd/generated/gps.cpp new file mode 100644 index 00000000000000..9b020735bb0c6b --- /dev/null +++ b/selfdrive/locationd/generated/gps.cpp @@ -0,0 +1,325 @@ +// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild + +#include "gps.h" +#include "kaitai/exceptions.h" + +gps_t::gps_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = this; + m_tlm = 0; + m_how = 0; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::_read() { + m_tlm = new tlm_t(m__io, this, m__root); + m_how = new how_t(m__io, this, m__root); + n_body = true; + switch (how()->subframe_id()) { + case 1: { + n_body = false; + m_body = new subframe_1_t(m__io, this, m__root); + break; + } + case 2: { + n_body = false; + m_body = new subframe_2_t(m__io, this, m__root); + break; + } + case 3: { + n_body = false; + m_body = new subframe_3_t(m__io, this, m__root); + break; + } + case 4: { + n_body = false; + m_body = new subframe_4_t(m__io, this, m__root); + break; + } + } +} + +gps_t::~gps_t() { + _clean_up(); +} + +void gps_t::_clean_up() { + if (m_tlm) { + delete m_tlm; m_tlm = 0; + } + if (m_how) { + delete m_how; m_how = 0; + } + if (!n_body) { + if (m_body) { + delete m_body; m_body = 0; + } + } +} + +gps_t::subframe_1_t::subframe_1_t(kaitai::kstream* p__io, gps_t* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + f_af_0 = false; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::subframe_1_t::_read() { + m_week_no = m__io->read_bits_int_be(10); + m_code = m__io->read_bits_int_be(2); + m_sv_accuracy = m__io->read_bits_int_be(4); + m_sv_health = m__io->read_bits_int_be(6); + m_iodc_msb = m__io->read_bits_int_be(2); + m_l2_p_data_flag = m__io->read_bits_int_be(1); + m_reserved1 = m__io->read_bits_int_be(23); + m_reserved2 = m__io->read_bits_int_be(24); + m_reserved3 = m__io->read_bits_int_be(24); + m_reserved4 = m__io->read_bits_int_be(16); + m__io->align_to_byte(); + m_t_gd = m__io->read_s1(); + m_iodc_lsb = m__io->read_u1(); + m_t_oc = m__io->read_u2be(); + m_af_2 = m__io->read_s1(); + m_af_1 = m__io->read_s2be(); + m_af_0_sign = m__io->read_bits_int_be(1); + m_af_0_value = m__io->read_bits_int_be(21); + m_reserved5 = m__io->read_bits_int_be(2); +} + +gps_t::subframe_1_t::~subframe_1_t() { + _clean_up(); +} + +void gps_t::subframe_1_t::_clean_up() { +} + +int32_t gps_t::subframe_1_t::af_0() { + if (f_af_0) + return m_af_0; + m_af_0 = ((af_0_sign()) ? ((af_0_value() - (1 << 21))) : (af_0_value())); + f_af_0 = true; + return m_af_0; +} + +gps_t::subframe_3_t::subframe_3_t(kaitai::kstream* p__io, gps_t* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + f_omega_dot = false; + f_idot = false; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::subframe_3_t::_read() { + m_c_ic = m__io->read_s2be(); + m_omega_0 = m__io->read_s4be(); + m_c_is = m__io->read_s2be(); + m_i_0 = m__io->read_s4be(); + m_c_rc = m__io->read_s2be(); + m_omega = m__io->read_s4be(); + m_omega_dot_sign = m__io->read_bits_int_be(1); + m_omega_dot_value = m__io->read_bits_int_be(23); + m__io->align_to_byte(); + m_iode = m__io->read_u1(); + m_idot_sign = m__io->read_bits_int_be(1); + m_idot_value = m__io->read_bits_int_be(13); + m_reserved = m__io->read_bits_int_be(2); +} + +gps_t::subframe_3_t::~subframe_3_t() { + _clean_up(); +} + +void gps_t::subframe_3_t::_clean_up() { +} + +int32_t gps_t::subframe_3_t::omega_dot() { + if (f_omega_dot) + return m_omega_dot; + m_omega_dot = ((omega_dot_sign()) ? ((omega_dot_value() - (1 << 23))) : (omega_dot_value())); + f_omega_dot = true; + return m_omega_dot; +} + +int32_t gps_t::subframe_3_t::idot() { + if (f_idot) + return m_idot; + m_idot = ((idot_sign()) ? ((idot_value() - (1 << 13))) : (idot_value())); + f_idot = true; + return m_idot; +} + +gps_t::subframe_4_t::subframe_4_t(kaitai::kstream* p__io, gps_t* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::subframe_4_t::_read() { + m_data_id = m__io->read_bits_int_be(2); + m_page_id = m__io->read_bits_int_be(6); + m__io->align_to_byte(); + n_body = true; + switch (page_id()) { + case 56: { + n_body = false; + m_body = new ionosphere_data_t(m__io, this, m__root); + break; + } + } +} + +gps_t::subframe_4_t::~subframe_4_t() { + _clean_up(); +} + +void gps_t::subframe_4_t::_clean_up() { + if (!n_body) { + if (m_body) { + delete m_body; m_body = 0; + } + } +} + +gps_t::subframe_4_t::ionosphere_data_t::ionosphere_data_t(kaitai::kstream* p__io, gps_t::subframe_4_t* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::subframe_4_t::ionosphere_data_t::_read() { + m_a0 = m__io->read_s1(); + m_a1 = m__io->read_s1(); + m_a2 = m__io->read_s1(); + m_a3 = m__io->read_s1(); + m_b0 = m__io->read_s1(); + m_b1 = m__io->read_s1(); + m_b2 = m__io->read_s1(); + m_b3 = m__io->read_s1(); +} + +gps_t::subframe_4_t::ionosphere_data_t::~ionosphere_data_t() { + _clean_up(); +} + +void gps_t::subframe_4_t::ionosphere_data_t::_clean_up() { +} + +gps_t::how_t::how_t(kaitai::kstream* p__io, gps_t* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::how_t::_read() { + m_tow_count = m__io->read_bits_int_be(17); + m_alert = m__io->read_bits_int_be(1); + m_anti_spoof = m__io->read_bits_int_be(1); + m_subframe_id = m__io->read_bits_int_be(3); + m_reserved = m__io->read_bits_int_be(2); +} + +gps_t::how_t::~how_t() { + _clean_up(); +} + +void gps_t::how_t::_clean_up() { +} + +gps_t::tlm_t::tlm_t(kaitai::kstream* p__io, gps_t* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::tlm_t::_read() { + m_magic = m__io->read_bytes(1); + if (!(magic() == std::string("\x8B", 1))) { + throw kaitai::validation_not_equal_error(std::string("\x8B", 1), magic(), _io(), std::string("/types/tlm/seq/0")); + } + m_tlm = m__io->read_bits_int_be(14); + m_integrity_status = m__io->read_bits_int_be(1); + m_reserved = m__io->read_bits_int_be(1); +} + +gps_t::tlm_t::~tlm_t() { + _clean_up(); +} + +void gps_t::tlm_t::_clean_up() { +} + +gps_t::subframe_2_t::subframe_2_t(kaitai::kstream* p__io, gps_t* p__parent, gps_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void gps_t::subframe_2_t::_read() { + m_iode = m__io->read_u1(); + m_c_rs = m__io->read_s2be(); + m_delta_n = m__io->read_s2be(); + m_m_0 = m__io->read_s4be(); + m_c_uc = m__io->read_s2be(); + m_e = m__io->read_s4be(); + m_c_us = m__io->read_s2be(); + m_sqrt_a = m__io->read_u4be(); + m_t_oe = m__io->read_u2be(); + m_fit_interval_flag = m__io->read_bits_int_be(1); + m_aoda = m__io->read_bits_int_be(5); + m_reserved = m__io->read_bits_int_be(2); +} + +gps_t::subframe_2_t::~subframe_2_t() { + _clean_up(); +} + +void gps_t::subframe_2_t::_clean_up() { +} diff --git a/selfdrive/locationd/generated/gps.h b/selfdrive/locationd/generated/gps.h new file mode 100644 index 00000000000000..293e2e4a05974a --- /dev/null +++ b/selfdrive/locationd/generated/gps.h @@ -0,0 +1,359 @@ +#ifndef GPS_H_ +#define GPS_H_ + +// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild + +#include "kaitai/kaitaistruct.h" +#include + +#if KAITAI_STRUCT_VERSION < 9000L +#error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required" +#endif + +class gps_t : public kaitai::kstruct { + +public: + class subframe_1_t; + class subframe_3_t; + class subframe_4_t; + class how_t; + class tlm_t; + class subframe_2_t; + + gps_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = 0, gps_t* p__root = 0); + +private: + void _read(); + void _clean_up(); + +public: + ~gps_t(); + + class subframe_1_t : public kaitai::kstruct { + + public: + + subframe_1_t(kaitai::kstream* p__io, gps_t* p__parent = 0, gps_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~subframe_1_t(); + + private: + bool f_af_0; + int32_t m_af_0; + + public: + int32_t af_0(); + + private: + uint64_t m_week_no; + uint64_t m_code; + uint64_t m_sv_accuracy; + uint64_t m_sv_health; + uint64_t m_iodc_msb; + bool m_l2_p_data_flag; + uint64_t m_reserved1; + uint64_t m_reserved2; + uint64_t m_reserved3; + uint64_t m_reserved4; + int8_t m_t_gd; + uint8_t m_iodc_lsb; + uint16_t m_t_oc; + int8_t m_af_2; + int16_t m_af_1; + bool m_af_0_sign; + uint64_t m_af_0_value; + uint64_t m_reserved5; + gps_t* m__root; + gps_t* m__parent; + + public: + uint64_t week_no() const { return m_week_no; } + uint64_t code() const { return m_code; } + uint64_t sv_accuracy() const { return m_sv_accuracy; } + uint64_t sv_health() const { return m_sv_health; } + uint64_t iodc_msb() const { return m_iodc_msb; } + bool l2_p_data_flag() const { return m_l2_p_data_flag; } + uint64_t reserved1() const { return m_reserved1; } + uint64_t reserved2() const { return m_reserved2; } + uint64_t reserved3() const { return m_reserved3; } + uint64_t reserved4() const { return m_reserved4; } + int8_t t_gd() const { return m_t_gd; } + uint8_t iodc_lsb() const { return m_iodc_lsb; } + uint16_t t_oc() const { return m_t_oc; } + int8_t af_2() const { return m_af_2; } + int16_t af_1() const { return m_af_1; } + bool af_0_sign() const { return m_af_0_sign; } + uint64_t af_0_value() const { return m_af_0_value; } + uint64_t reserved5() const { return m_reserved5; } + gps_t* _root() const { return m__root; } + gps_t* _parent() const { return m__parent; } + }; + + class subframe_3_t : public kaitai::kstruct { + + public: + + subframe_3_t(kaitai::kstream* p__io, gps_t* p__parent = 0, gps_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~subframe_3_t(); + + private: + bool f_omega_dot; + int32_t m_omega_dot; + + public: + int32_t omega_dot(); + + private: + bool f_idot; + int32_t m_idot; + + public: + int32_t idot(); + + private: + int16_t m_c_ic; + int32_t m_omega_0; + int16_t m_c_is; + int32_t m_i_0; + int16_t m_c_rc; + int32_t m_omega; + bool m_omega_dot_sign; + uint64_t m_omega_dot_value; + uint8_t m_iode; + bool m_idot_sign; + uint64_t m_idot_value; + uint64_t m_reserved; + gps_t* m__root; + gps_t* m__parent; + + public: + int16_t c_ic() const { return m_c_ic; } + int32_t omega_0() const { return m_omega_0; } + int16_t c_is() const { return m_c_is; } + int32_t i_0() const { return m_i_0; } + int16_t c_rc() const { return m_c_rc; } + int32_t omega() const { return m_omega; } + bool omega_dot_sign() const { return m_omega_dot_sign; } + uint64_t omega_dot_value() const { return m_omega_dot_value; } + uint8_t iode() const { return m_iode; } + bool idot_sign() const { return m_idot_sign; } + uint64_t idot_value() const { return m_idot_value; } + uint64_t reserved() const { return m_reserved; } + gps_t* _root() const { return m__root; } + gps_t* _parent() const { return m__parent; } + }; + + class subframe_4_t : public kaitai::kstruct { + + public: + class ionosphere_data_t; + + subframe_4_t(kaitai::kstream* p__io, gps_t* p__parent = 0, gps_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~subframe_4_t(); + + class ionosphere_data_t : public kaitai::kstruct { + + public: + + ionosphere_data_t(kaitai::kstream* p__io, gps_t::subframe_4_t* p__parent = 0, gps_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~ionosphere_data_t(); + + private: + int8_t m_a0; + int8_t m_a1; + int8_t m_a2; + int8_t m_a3; + int8_t m_b0; + int8_t m_b1; + int8_t m_b2; + int8_t m_b3; + gps_t* m__root; + gps_t::subframe_4_t* m__parent; + + public: + int8_t a0() const { return m_a0; } + int8_t a1() const { return m_a1; } + int8_t a2() const { return m_a2; } + int8_t a3() const { return m_a3; } + int8_t b0() const { return m_b0; } + int8_t b1() const { return m_b1; } + int8_t b2() const { return m_b2; } + int8_t b3() const { return m_b3; } + gps_t* _root() const { return m__root; } + gps_t::subframe_4_t* _parent() const { return m__parent; } + }; + + private: + uint64_t m_data_id; + uint64_t m_page_id; + ionosphere_data_t* m_body; + bool n_body; + + public: + bool _is_null_body() { body(); return n_body; }; + + private: + gps_t* m__root; + gps_t* m__parent; + + public: + uint64_t data_id() const { return m_data_id; } + uint64_t page_id() const { return m_page_id; } + ionosphere_data_t* body() const { return m_body; } + gps_t* _root() const { return m__root; } + gps_t* _parent() const { return m__parent; } + }; + + class how_t : public kaitai::kstruct { + + public: + + how_t(kaitai::kstream* p__io, gps_t* p__parent = 0, gps_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~how_t(); + + private: + uint64_t m_tow_count; + bool m_alert; + bool m_anti_spoof; + uint64_t m_subframe_id; + uint64_t m_reserved; + gps_t* m__root; + gps_t* m__parent; + + public: + uint64_t tow_count() const { return m_tow_count; } + bool alert() const { return m_alert; } + bool anti_spoof() const { return m_anti_spoof; } + uint64_t subframe_id() const { return m_subframe_id; } + uint64_t reserved() const { return m_reserved; } + gps_t* _root() const { return m__root; } + gps_t* _parent() const { return m__parent; } + }; + + class tlm_t : public kaitai::kstruct { + + public: + + tlm_t(kaitai::kstream* p__io, gps_t* p__parent = 0, gps_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~tlm_t(); + + private: + std::string m_magic; + uint64_t m_tlm; + bool m_integrity_status; + bool m_reserved; + gps_t* m__root; + gps_t* m__parent; + + public: + std::string magic() const { return m_magic; } + uint64_t tlm() const { return m_tlm; } + bool integrity_status() const { return m_integrity_status; } + bool reserved() const { return m_reserved; } + gps_t* _root() const { return m__root; } + gps_t* _parent() const { return m__parent; } + }; + + class subframe_2_t : public kaitai::kstruct { + + public: + + subframe_2_t(kaitai::kstream* p__io, gps_t* p__parent = 0, gps_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~subframe_2_t(); + + private: + uint8_t m_iode; + int16_t m_c_rs; + int16_t m_delta_n; + int32_t m_m_0; + int16_t m_c_uc; + int32_t m_e; + int16_t m_c_us; + uint32_t m_sqrt_a; + uint16_t m_t_oe; + bool m_fit_interval_flag; + uint64_t m_aoda; + uint64_t m_reserved; + gps_t* m__root; + gps_t* m__parent; + + public: + uint8_t iode() const { return m_iode; } + int16_t c_rs() const { return m_c_rs; } + int16_t delta_n() const { return m_delta_n; } + int32_t m_0() const { return m_m_0; } + int16_t c_uc() const { return m_c_uc; } + int32_t e() const { return m_e; } + int16_t c_us() const { return m_c_us; } + uint32_t sqrt_a() const { return m_sqrt_a; } + uint16_t t_oe() const { return m_t_oe; } + bool fit_interval_flag() const { return m_fit_interval_flag; } + uint64_t aoda() const { return m_aoda; } + uint64_t reserved() const { return m_reserved; } + gps_t* _root() const { return m__root; } + gps_t* _parent() const { return m__parent; } + }; + +private: + tlm_t* m_tlm; + how_t* m_how; + kaitai::kstruct* m_body; + bool n_body; + +public: + bool _is_null_body() { body(); return n_body; }; + +private: + gps_t* m__root; + kaitai::kstruct* m__parent; + +public: + tlm_t* tlm() const { return m_tlm; } + how_t* how() const { return m_how; } + kaitai::kstruct* body() const { return m_body; } + gps_t* _root() const { return m__root; } + kaitai::kstruct* _parent() const { return m__parent; } +}; + +#endif // GPS_H_ diff --git a/selfdrive/locationd/generated/ubx.cpp b/selfdrive/locationd/generated/ubx.cpp new file mode 100644 index 00000000000000..5e743e1ee7e95d --- /dev/null +++ b/selfdrive/locationd/generated/ubx.cpp @@ -0,0 +1,340 @@ +// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild + +#include "ubx.h" +#include "kaitai/exceptions.h" + +ubx_t::ubx_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, ubx_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = this; + f_checksum = false; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void ubx_t::_read() { + m_magic = m__io->read_bytes(2); + if (!(magic() == std::string("\xB5\x62", 2))) { + throw kaitai::validation_not_equal_error(std::string("\xB5\x62", 2), magic(), _io(), std::string("/seq/0")); + } + m_msg_type = m__io->read_u2be(); + m_length = m__io->read_u2le(); + n_body = true; + switch (msg_type()) { + case 2569: { + n_body = false; + m_body = new mon_hw_t(m__io, this, m__root); + break; + } + case 533: { + n_body = false; + m_body = new rxm_rawx_t(m__io, this, m__root); + break; + } + case 531: { + n_body = false; + m_body = new rxm_sfrbx_t(m__io, this, m__root); + break; + } + case 2571: { + n_body = false; + m_body = new mon_hw2_t(m__io, this, m__root); + break; + } + case 263: { + n_body = false; + m_body = new nav_pvt_t(m__io, this, m__root); + break; + } + } +} + +ubx_t::~ubx_t() { + _clean_up(); +} + +void ubx_t::_clean_up() { + if (!n_body) { + if (m_body) { + delete m_body; m_body = 0; + } + } + if (f_checksum) { + } +} + +ubx_t::rxm_rawx_t::rxm_rawx_t(kaitai::kstream* p__io, ubx_t* p__parent, ubx_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + m_measurements = 0; + m__raw_measurements = 0; + m__io__raw_measurements = 0; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void ubx_t::rxm_rawx_t::_read() { + m_rcv_tow = m__io->read_f8le(); + m_week = m__io->read_u2le(); + m_leap_s = m__io->read_s1(); + m_num_meas = m__io->read_u1(); + m_rec_stat = m__io->read_u1(); + m_reserved1 = m__io->read_bytes(3); + int l_measurements = num_meas(); + m__raw_measurements = new std::vector(); + m__raw_measurements->reserve(l_measurements); + m__io__raw_measurements = new std::vector(); + m__io__raw_measurements->reserve(l_measurements); + m_measurements = new std::vector(); + m_measurements->reserve(l_measurements); + for (int i = 0; i < l_measurements; i++) { + m__raw_measurements->push_back(m__io->read_bytes(32)); + kaitai::kstream* io__raw_measurements = new kaitai::kstream(m__raw_measurements->at(m__raw_measurements->size() - 1)); + m__io__raw_measurements->push_back(io__raw_measurements); + m_measurements->push_back(new meas_t(io__raw_measurements, this, m__root)); + } +} + +ubx_t::rxm_rawx_t::~rxm_rawx_t() { + _clean_up(); +} + +void ubx_t::rxm_rawx_t::_clean_up() { + if (m__raw_measurements) { + delete m__raw_measurements; m__raw_measurements = 0; + } + if (m__io__raw_measurements) { + for (std::vector::iterator it = m__io__raw_measurements->begin(); it != m__io__raw_measurements->end(); ++it) { + delete *it; + } + delete m__io__raw_measurements; m__io__raw_measurements = 0; + } + if (m_measurements) { + for (std::vector::iterator it = m_measurements->begin(); it != m_measurements->end(); ++it) { + delete *it; + } + delete m_measurements; m_measurements = 0; + } +} + +ubx_t::rxm_rawx_t::meas_t::meas_t(kaitai::kstream* p__io, ubx_t::rxm_rawx_t* p__parent, ubx_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void ubx_t::rxm_rawx_t::meas_t::_read() { + m_pr_mes = m__io->read_f8le(); + m_cp_mes = m__io->read_f8le(); + m_do_mes = m__io->read_f4le(); + m_gnss_id = static_cast(m__io->read_u1()); + m_sv_id = m__io->read_u1(); + m_reserved2 = m__io->read_bytes(1); + m_freq_id = m__io->read_u1(); + m_lock_time = m__io->read_u2le(); + m_cno = m__io->read_u1(); + m_pr_stdev = m__io->read_u1(); + m_cp_stdev = m__io->read_u1(); + m_do_stdev = m__io->read_u1(); + m_trk_stat = m__io->read_u1(); + m_reserved3 = m__io->read_bytes(1); +} + +ubx_t::rxm_rawx_t::meas_t::~meas_t() { + _clean_up(); +} + +void ubx_t::rxm_rawx_t::meas_t::_clean_up() { +} + +ubx_t::rxm_sfrbx_t::rxm_sfrbx_t(kaitai::kstream* p__io, ubx_t* p__parent, ubx_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + m_body = 0; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void ubx_t::rxm_sfrbx_t::_read() { + m_gnss_id = static_cast(m__io->read_u1()); + m_sv_id = m__io->read_u1(); + m_reserved1 = m__io->read_bytes(1); + m_freq_id = m__io->read_u1(); + m_num_words = m__io->read_u1(); + m_reserved2 = m__io->read_bytes(1); + m_version = m__io->read_u1(); + m_reserved3 = m__io->read_bytes(1); + int l_body = num_words(); + m_body = new std::vector(); + m_body->reserve(l_body); + for (int i = 0; i < l_body; i++) { + m_body->push_back(m__io->read_u4le()); + } +} + +ubx_t::rxm_sfrbx_t::~rxm_sfrbx_t() { + _clean_up(); +} + +void ubx_t::rxm_sfrbx_t::_clean_up() { + if (m_body) { + delete m_body; m_body = 0; + } +} + +ubx_t::nav_pvt_t::nav_pvt_t(kaitai::kstream* p__io, ubx_t* p__parent, ubx_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void ubx_t::nav_pvt_t::_read() { + m_i_tow = m__io->read_u4le(); + m_year = m__io->read_u2le(); + m_month = m__io->read_u1(); + m_day = m__io->read_u1(); + m_hour = m__io->read_u1(); + m_min = m__io->read_u1(); + m_sec = m__io->read_u1(); + m_valid = m__io->read_u1(); + m_t_acc = m__io->read_u4le(); + m_nano = m__io->read_s4le(); + m_fix_type = m__io->read_u1(); + m_flags = m__io->read_u1(); + m_flags2 = m__io->read_u1(); + m_num_sv = m__io->read_u1(); + m_lon = m__io->read_s4le(); + m_lat = m__io->read_s4le(); + m_height = m__io->read_s4le(); + m_h_msl = m__io->read_s4le(); + m_h_acc = m__io->read_u4le(); + m_v_acc = m__io->read_u4le(); + m_vel_n = m__io->read_s4le(); + m_vel_e = m__io->read_s4le(); + m_vel_d = m__io->read_s4le(); + m_g_speed = m__io->read_s4le(); + m_head_mot = m__io->read_s4le(); + m_s_acc = m__io->read_s4le(); + m_head_acc = m__io->read_u4le(); + m_p_dop = m__io->read_u2le(); + m_flags3 = m__io->read_u1(); + m_reserved1 = m__io->read_bytes(5); + m_head_veh = m__io->read_s4le(); + m_mag_dec = m__io->read_s2le(); + m_mag_acc = m__io->read_u2le(); +} + +ubx_t::nav_pvt_t::~nav_pvt_t() { + _clean_up(); +} + +void ubx_t::nav_pvt_t::_clean_up() { +} + +ubx_t::mon_hw2_t::mon_hw2_t(kaitai::kstream* p__io, ubx_t* p__parent, ubx_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void ubx_t::mon_hw2_t::_read() { + m_ofs_i = m__io->read_s1(); + m_mag_i = m__io->read_u1(); + m_ofs_q = m__io->read_s1(); + m_mag_q = m__io->read_u1(); + m_cfg_source = static_cast(m__io->read_u1()); + m_reserved1 = m__io->read_bytes(3); + m_low_lev_cfg = m__io->read_u4le(); + m_reserved2 = m__io->read_bytes(8); + m_post_status = m__io->read_u4le(); + m_reserved3 = m__io->read_bytes(4); +} + +ubx_t::mon_hw2_t::~mon_hw2_t() { + _clean_up(); +} + +void ubx_t::mon_hw2_t::_clean_up() { +} + +ubx_t::mon_hw_t::mon_hw_t(kaitai::kstream* p__io, ubx_t* p__parent, ubx_t* p__root) : kaitai::kstruct(p__io) { + m__parent = p__parent; + m__root = p__root; + + try { + _read(); + } catch(...) { + _clean_up(); + throw; + } +} + +void ubx_t::mon_hw_t::_read() { + m_pin_sel = m__io->read_u4le(); + m_pin_bank = m__io->read_u4le(); + m_pin_dir = m__io->read_u4le(); + m_pin_val = m__io->read_u4le(); + m_noise_per_ms = m__io->read_u2le(); + m_agc_cnt = m__io->read_u2le(); + m_a_status = static_cast(m__io->read_u1()); + m_a_power = static_cast(m__io->read_u1()); + m_flags = m__io->read_u1(); + m_reserved1 = m__io->read_bytes(1); + m_used_mask = m__io->read_u4le(); + m_vp = m__io->read_bytes(17); + m_jam_ind = m__io->read_u1(); + m_reserved2 = m__io->read_bytes(2); + m_pin_irq = m__io->read_u4le(); + m_pull_h = m__io->read_u4le(); + m_pull_l = m__io->read_u4le(); +} + +ubx_t::mon_hw_t::~mon_hw_t() { + _clean_up(); +} + +void ubx_t::mon_hw_t::_clean_up() { +} + +uint16_t ubx_t::checksum() { + if (f_checksum) + return m_checksum; + std::streampos _pos = m__io->pos(); + m__io->seek((length() + 6)); + m_checksum = m__io->read_u2le(); + m__io->seek(_pos); + f_checksum = true; + return m_checksum; +} diff --git a/selfdrive/locationd/generated/ubx.h b/selfdrive/locationd/generated/ubx.h new file mode 100644 index 00000000000000..6be4ce8c4b7c66 --- /dev/null +++ b/selfdrive/locationd/generated/ubx.h @@ -0,0 +1,410 @@ +#ifndef UBX_H_ +#define UBX_H_ + +// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild + +#include "kaitai/kaitaistruct.h" +#include +#include + +#if KAITAI_STRUCT_VERSION < 9000L +#error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required" +#endif + +class ubx_t : public kaitai::kstruct { + +public: + class rxm_rawx_t; + class rxm_sfrbx_t; + class nav_pvt_t; + class mon_hw2_t; + class mon_hw_t; + + enum gnss_type_t { + GNSS_TYPE_GPS = 0, + GNSS_TYPE_SBAS = 1, + GNSS_TYPE_GALILEO = 2, + GNSS_TYPE_BEIDOU = 3, + GNSS_TYPE_IMES = 4, + GNSS_TYPE_QZSS = 5, + GNSS_TYPE_GLONASS = 6 + }; + + ubx_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = 0, ubx_t* p__root = 0); + +private: + void _read(); + void _clean_up(); + +public: + ~ubx_t(); + + class rxm_rawx_t : public kaitai::kstruct { + + public: + class meas_t; + + rxm_rawx_t(kaitai::kstream* p__io, ubx_t* p__parent = 0, ubx_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~rxm_rawx_t(); + + class meas_t : public kaitai::kstruct { + + public: + + meas_t(kaitai::kstream* p__io, ubx_t::rxm_rawx_t* p__parent = 0, ubx_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~meas_t(); + + private: + double m_pr_mes; + double m_cp_mes; + float m_do_mes; + gnss_type_t m_gnss_id; + uint8_t m_sv_id; + std::string m_reserved2; + uint8_t m_freq_id; + uint16_t m_lock_time; + uint8_t m_cno; + uint8_t m_pr_stdev; + uint8_t m_cp_stdev; + uint8_t m_do_stdev; + uint8_t m_trk_stat; + std::string m_reserved3; + ubx_t* m__root; + ubx_t::rxm_rawx_t* m__parent; + + public: + double pr_mes() const { return m_pr_mes; } + double cp_mes() const { return m_cp_mes; } + float do_mes() const { return m_do_mes; } + gnss_type_t gnss_id() const { return m_gnss_id; } + uint8_t sv_id() const { return m_sv_id; } + std::string reserved2() const { return m_reserved2; } + uint8_t freq_id() const { return m_freq_id; } + uint16_t lock_time() const { return m_lock_time; } + uint8_t cno() const { return m_cno; } + uint8_t pr_stdev() const { return m_pr_stdev; } + uint8_t cp_stdev() const { return m_cp_stdev; } + uint8_t do_stdev() const { return m_do_stdev; } + uint8_t trk_stat() const { return m_trk_stat; } + std::string reserved3() const { return m_reserved3; } + ubx_t* _root() const { return m__root; } + ubx_t::rxm_rawx_t* _parent() const { return m__parent; } + }; + + private: + double m_rcv_tow; + uint16_t m_week; + int8_t m_leap_s; + uint8_t m_num_meas; + uint8_t m_rec_stat; + std::string m_reserved1; + std::vector* m_measurements; + ubx_t* m__root; + ubx_t* m__parent; + std::vector* m__raw_measurements; + std::vector* m__io__raw_measurements; + + public: + double rcv_tow() const { return m_rcv_tow; } + uint16_t week() const { return m_week; } + int8_t leap_s() const { return m_leap_s; } + uint8_t num_meas() const { return m_num_meas; } + uint8_t rec_stat() const { return m_rec_stat; } + std::string reserved1() const { return m_reserved1; } + std::vector* measurements() const { return m_measurements; } + ubx_t* _root() const { return m__root; } + ubx_t* _parent() const { return m__parent; } + std::vector* _raw_measurements() const { return m__raw_measurements; } + std::vector* _io__raw_measurements() const { return m__io__raw_measurements; } + }; + + class rxm_sfrbx_t : public kaitai::kstruct { + + public: + + rxm_sfrbx_t(kaitai::kstream* p__io, ubx_t* p__parent = 0, ubx_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~rxm_sfrbx_t(); + + private: + gnss_type_t m_gnss_id; + uint8_t m_sv_id; + std::string m_reserved1; + uint8_t m_freq_id; + uint8_t m_num_words; + std::string m_reserved2; + uint8_t m_version; + std::string m_reserved3; + std::vector* m_body; + ubx_t* m__root; + ubx_t* m__parent; + + public: + gnss_type_t gnss_id() const { return m_gnss_id; } + uint8_t sv_id() const { return m_sv_id; } + std::string reserved1() const { return m_reserved1; } + uint8_t freq_id() const { return m_freq_id; } + uint8_t num_words() const { return m_num_words; } + std::string reserved2() const { return m_reserved2; } + uint8_t version() const { return m_version; } + std::string reserved3() const { return m_reserved3; } + std::vector* body() const { return m_body; } + ubx_t* _root() const { return m__root; } + ubx_t* _parent() const { return m__parent; } + }; + + class nav_pvt_t : public kaitai::kstruct { + + public: + + nav_pvt_t(kaitai::kstream* p__io, ubx_t* p__parent = 0, ubx_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~nav_pvt_t(); + + private: + uint32_t m_i_tow; + uint16_t m_year; + uint8_t m_month; + uint8_t m_day; + uint8_t m_hour; + uint8_t m_min; + uint8_t m_sec; + uint8_t m_valid; + uint32_t m_t_acc; + int32_t m_nano; + uint8_t m_fix_type; + uint8_t m_flags; + uint8_t m_flags2; + uint8_t m_num_sv; + int32_t m_lon; + int32_t m_lat; + int32_t m_height; + int32_t m_h_msl; + uint32_t m_h_acc; + uint32_t m_v_acc; + int32_t m_vel_n; + int32_t m_vel_e; + int32_t m_vel_d; + int32_t m_g_speed; + int32_t m_head_mot; + int32_t m_s_acc; + uint32_t m_head_acc; + uint16_t m_p_dop; + uint8_t m_flags3; + std::string m_reserved1; + int32_t m_head_veh; + int16_t m_mag_dec; + uint16_t m_mag_acc; + ubx_t* m__root; + ubx_t* m__parent; + + public: + uint32_t i_tow() const { return m_i_tow; } + uint16_t year() const { return m_year; } + uint8_t month() const { return m_month; } + uint8_t day() const { return m_day; } + uint8_t hour() const { return m_hour; } + uint8_t min() const { return m_min; } + uint8_t sec() const { return m_sec; } + uint8_t valid() const { return m_valid; } + uint32_t t_acc() const { return m_t_acc; } + int32_t nano() const { return m_nano; } + uint8_t fix_type() const { return m_fix_type; } + uint8_t flags() const { return m_flags; } + uint8_t flags2() const { return m_flags2; } + uint8_t num_sv() const { return m_num_sv; } + int32_t lon() const { return m_lon; } + int32_t lat() const { return m_lat; } + int32_t height() const { return m_height; } + int32_t h_msl() const { return m_h_msl; } + uint32_t h_acc() const { return m_h_acc; } + uint32_t v_acc() const { return m_v_acc; } + int32_t vel_n() const { return m_vel_n; } + int32_t vel_e() const { return m_vel_e; } + int32_t vel_d() const { return m_vel_d; } + int32_t g_speed() const { return m_g_speed; } + int32_t head_mot() const { return m_head_mot; } + int32_t s_acc() const { return m_s_acc; } + uint32_t head_acc() const { return m_head_acc; } + uint16_t p_dop() const { return m_p_dop; } + uint8_t flags3() const { return m_flags3; } + std::string reserved1() const { return m_reserved1; } + int32_t head_veh() const { return m_head_veh; } + int16_t mag_dec() const { return m_mag_dec; } + uint16_t mag_acc() const { return m_mag_acc; } + ubx_t* _root() const { return m__root; } + ubx_t* _parent() const { return m__parent; } + }; + + class mon_hw2_t : public kaitai::kstruct { + + public: + + enum config_source_t { + CONFIG_SOURCE_FLASH = 102, + CONFIG_SOURCE_OTP = 111, + CONFIG_SOURCE_CONFIG_PINS = 112, + CONFIG_SOURCE_ROM = 113 + }; + + mon_hw2_t(kaitai::kstream* p__io, ubx_t* p__parent = 0, ubx_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~mon_hw2_t(); + + private: + int8_t m_ofs_i; + uint8_t m_mag_i; + int8_t m_ofs_q; + uint8_t m_mag_q; + config_source_t m_cfg_source; + std::string m_reserved1; + uint32_t m_low_lev_cfg; + std::string m_reserved2; + uint32_t m_post_status; + std::string m_reserved3; + ubx_t* m__root; + ubx_t* m__parent; + + public: + int8_t ofs_i() const { return m_ofs_i; } + uint8_t mag_i() const { return m_mag_i; } + int8_t ofs_q() const { return m_ofs_q; } + uint8_t mag_q() const { return m_mag_q; } + config_source_t cfg_source() const { return m_cfg_source; } + std::string reserved1() const { return m_reserved1; } + uint32_t low_lev_cfg() const { return m_low_lev_cfg; } + std::string reserved2() const { return m_reserved2; } + uint32_t post_status() const { return m_post_status; } + std::string reserved3() const { return m_reserved3; } + ubx_t* _root() const { return m__root; } + ubx_t* _parent() const { return m__parent; } + }; + + class mon_hw_t : public kaitai::kstruct { + + public: + + enum antenna_status_t { + ANTENNA_STATUS_INIT = 0, + ANTENNA_STATUS_DONTKNOW = 1, + ANTENNA_STATUS_OK = 2, + ANTENNA_STATUS_SHORT = 3, + ANTENNA_STATUS_OPEN = 4 + }; + + enum antenna_power_t { + ANTENNA_POWER_FALSE = 0, + ANTENNA_POWER_TRUE = 1, + ANTENNA_POWER_DONTKNOW = 2 + }; + + mon_hw_t(kaitai::kstream* p__io, ubx_t* p__parent = 0, ubx_t* p__root = 0); + + private: + void _read(); + void _clean_up(); + + public: + ~mon_hw_t(); + + private: + uint32_t m_pin_sel; + uint32_t m_pin_bank; + uint32_t m_pin_dir; + uint32_t m_pin_val; + uint16_t m_noise_per_ms; + uint16_t m_agc_cnt; + antenna_status_t m_a_status; + antenna_power_t m_a_power; + uint8_t m_flags; + std::string m_reserved1; + uint32_t m_used_mask; + std::string m_vp; + uint8_t m_jam_ind; + std::string m_reserved2; + uint32_t m_pin_irq; + uint32_t m_pull_h; + uint32_t m_pull_l; + ubx_t* m__root; + ubx_t* m__parent; + + public: + uint32_t pin_sel() const { return m_pin_sel; } + uint32_t pin_bank() const { return m_pin_bank; } + uint32_t pin_dir() const { return m_pin_dir; } + uint32_t pin_val() const { return m_pin_val; } + uint16_t noise_per_ms() const { return m_noise_per_ms; } + uint16_t agc_cnt() const { return m_agc_cnt; } + antenna_status_t a_status() const { return m_a_status; } + antenna_power_t a_power() const { return m_a_power; } + uint8_t flags() const { return m_flags; } + std::string reserved1() const { return m_reserved1; } + uint32_t used_mask() const { return m_used_mask; } + std::string vp() const { return m_vp; } + uint8_t jam_ind() const { return m_jam_ind; } + std::string reserved2() const { return m_reserved2; } + uint32_t pin_irq() const { return m_pin_irq; } + uint32_t pull_h() const { return m_pull_h; } + uint32_t pull_l() const { return m_pull_l; } + ubx_t* _root() const { return m__root; } + ubx_t* _parent() const { return m__parent; } + }; + +private: + bool f_checksum; + uint16_t m_checksum; + +public: + uint16_t checksum(); + +private: + std::string m_magic; + uint16_t m_msg_type; + uint16_t m_length; + kaitai::kstruct* m_body; + bool n_body; + +public: + bool _is_null_body() { body(); return n_body; }; + +private: + ubx_t* m__root; + kaitai::kstruct* m__parent; + +public: + std::string magic() const { return m_magic; } + uint16_t msg_type() const { return m_msg_type; } + uint16_t length() const { return m_length; } + kaitai::kstruct* body() const { return m_body; } + ubx_t* _root() const { return m__root; } + kaitai::kstruct* _parent() const { return m__parent; } +}; + +#endif // UBX_H_ 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/locationd.cc b/selfdrive/locationd/locationd.cc new file mode 100755 index 00000000000000..0350625a915c1e --- /dev/null +++ b/selfdrive/locationd/locationd.cc @@ -0,0 +1,538 @@ +#include +#include + +#include + +#include "locationd.h" + +using namespace EKFS; +using namespace Eigen; + +ExitHandler do_exit; +const double ACCEL_SANITY_CHECK = 100.0; // m/s^2 +const double ROTATION_SANITY_CHECK = 10.0; // rad/s +const double TRANS_SANITY_CHECK = 200.0; // m/s +const double CALIB_RPY_SANITY_CHECK = 0.5; // rad (+- 30 deg) +const double ALTITUDE_SANITY_CHECK = 10000; // m +const double MIN_STD_SANITY_CHECK = 1e-5; // m or rad +const double VALID_TIME_SINCE_RESET = 1.0; // s +const double VALID_POS_STD = 50.0; // m +const double MAX_RESET_TRACKER = 5.0; +const double SANE_GPS_UNCERTAINTY = 1500.0; // m + +static VectorXd floatlist2vector(const capnp::List::Reader& floatlist) { + VectorXd res(floatlist.size()); + for (int i = 0; i < floatlist.size(); i++) { + res[i] = floatlist[i]; + } + return res; +} + +static Vector4d quat2vector(const Quaterniond& quat) { + return Vector4d(quat.w(), quat.x(), quat.y(), quat.z()); +} + +static Quaterniond vector2quat(const VectorXd& vec) { + return Quaterniond(vec(0), vec(1), vec(2), vec(3)); +} + +static void init_measurement(cereal::LiveLocationKalman::Measurement::Builder meas, const VectorXd& val, const VectorXd& std, bool valid) { + meas.setValue(kj::arrayPtr(val.data(), val.size())); + meas.setStd(kj::arrayPtr(std.data(), std.size())); + meas.setValid(valid); +} + + +static MatrixXdr rotate_cov(const MatrixXdr& rot_matrix, const MatrixXdr& cov_in) { + // To rotate a covariance matrix, the cov matrix needs to multiplied left and right by the transform matrix + return ((rot_matrix * cov_in) * rot_matrix.transpose()); +} + +static VectorXd rotate_std(const MatrixXdr& rot_matrix, const VectorXd& std_in) { + // Stds cannot be rotated like values, only covariances can be rotated + return rotate_cov(rot_matrix, std_in.array().square().matrix().asDiagonal()).diagonal().array().sqrt(); +} + +Localizer::Localizer() { + this->kf = std::make_unique(); + this->reset_kalman(); + + this->calib = Vector3d(0.0, 0.0, 0.0); + this->device_from_calib = MatrixXdr::Identity(3, 3); + this->calib_from_device = MatrixXdr::Identity(3, 3); + + for (int i = 0; i < POSENET_STD_HIST_HALF * 2; i++) { + this->posenet_stds.push_back(10.0); + } + + VectorXd ecef_pos = this->kf->get_x().segment(STATE_ECEF_POS_START); + this->converter = std::make_unique((ECEF) { .x = ecef_pos[0], .y = ecef_pos[1], .z = ecef_pos[2] }); +} + +void Localizer::build_live_location(cereal::LiveLocationKalman::Builder& fix) { + VectorXd predicted_state = this->kf->get_x(); + MatrixXdr predicted_cov = this->kf->get_P(); + VectorXd predicted_std = predicted_cov.diagonal().array().sqrt(); + + VectorXd fix_ecef = predicted_state.segment(STATE_ECEF_POS_START); + ECEF fix_ecef_ecef = { .x = fix_ecef(0), .y = fix_ecef(1), .z = fix_ecef(2) }; + VectorXd fix_ecef_std = predicted_std.segment(STATE_ECEF_POS_ERR_START); + VectorXd vel_ecef = predicted_state.segment(STATE_ECEF_VELOCITY_START); + VectorXd vel_ecef_std = predicted_std.segment(STATE_ECEF_VELOCITY_ERR_START); + VectorXd fix_pos_geo_vec = this->get_position_geodetic(); + //fix_pos_geo_std = np.abs(coord.ecef2geodetic(fix_ecef + fix_ecef_std) - fix_pos_geo) + VectorXd orientation_ecef = quat2euler(vector2quat(predicted_state.segment(STATE_ECEF_ORIENTATION_START))); + VectorXd orientation_ecef_std = predicted_std.segment(STATE_ECEF_ORIENTATION_ERR_START); + MatrixXdr device_from_ecef = euler2rot(orientation_ecef).transpose(); + //VectorXd calibrated_orientation_ecef = rot2euler(device_from_ecef); + VectorXd calibrated_orientation_ecef = rot2euler((this->calib_from_device * device_from_ecef).transpose()); + + VectorXd acc_calib = this->calib_from_device * predicted_state.segment(STATE_ACCELERATION_START); + MatrixXdr acc_calib_cov = predicted_cov.block(STATE_ACCELERATION_ERR_START, STATE_ACCELERATION_ERR_START); + VectorXd acc_calib_std = rotate_cov(this->calib_from_device, acc_calib_cov).diagonal().array().sqrt(); + VectorXd ang_vel_calib = this->calib_from_device * predicted_state.segment(STATE_ANGULAR_VELOCITY_START); + + MatrixXdr vel_angular_cov = predicted_cov.block(STATE_ANGULAR_VELOCITY_ERR_START, STATE_ANGULAR_VELOCITY_ERR_START); + VectorXd ang_vel_calib_std = rotate_cov(this->calib_from_device, vel_angular_cov).diagonal().array().sqrt(); + + VectorXd vel_device = device_from_ecef * vel_ecef; + VectorXd device_from_ecef_eul = quat2euler(vector2quat(predicted_state.segment(STATE_ECEF_ORIENTATION_START))).transpose(); + MatrixXdr condensed_cov(STATE_ECEF_ORIENTATION_ERR_LEN + STATE_ECEF_VELOCITY_ERR_LEN, STATE_ECEF_ORIENTATION_ERR_LEN + STATE_ECEF_VELOCITY_ERR_LEN); + condensed_cov.topLeftCorner() = + predicted_cov.block(STATE_ECEF_ORIENTATION_ERR_START, STATE_ECEF_ORIENTATION_ERR_START); + condensed_cov.topRightCorner() = + predicted_cov.block(STATE_ECEF_ORIENTATION_ERR_START, STATE_ECEF_VELOCITY_ERR_START); + condensed_cov.bottomRightCorner() = + predicted_cov.block(STATE_ECEF_VELOCITY_ERR_START, STATE_ECEF_VELOCITY_ERR_START); + condensed_cov.bottomLeftCorner() = + predicted_cov.block(STATE_ECEF_VELOCITY_ERR_START, STATE_ECEF_ORIENTATION_ERR_START); + VectorXd H_input(device_from_ecef_eul.size() + vel_ecef.size()); + H_input << device_from_ecef_eul, vel_ecef; + MatrixXdr HH = this->kf->H(H_input); + MatrixXdr vel_device_cov = (HH * condensed_cov) * HH.transpose(); + VectorXd vel_device_std = vel_device_cov.diagonal().array().sqrt(); + + VectorXd vel_calib = this->calib_from_device * vel_device; + VectorXd vel_calib_std = rotate_cov(this->calib_from_device, vel_device_cov).diagonal().array().sqrt(); + + VectorXd orientation_ned = ned_euler_from_ecef(fix_ecef_ecef, orientation_ecef); + //orientation_ned_std = ned_euler_from_ecef(fix_ecef, orientation_ecef + orientation_ecef_std) - orientation_ned + VectorXd calibrated_orientation_ned = ned_euler_from_ecef(fix_ecef_ecef, calibrated_orientation_ecef); + VectorXd nextfix_ecef = fix_ecef + vel_ecef; + VectorXd ned_vel = this->converter->ecef2ned((ECEF) { .x = nextfix_ecef(0), .y = nextfix_ecef(1), .z = nextfix_ecef(2) }).to_vector() - converter->ecef2ned(fix_ecef_ecef).to_vector(); + //ned_vel_std = self.converter->ecef2ned(fix_ecef + vel_ecef + vel_ecef_std) - self.converter->ecef2ned(fix_ecef + vel_ecef) + + VectorXd accDevice = predicted_state.segment(STATE_ACCELERATION_START); + VectorXd accDeviceErr = predicted_std.segment(STATE_ACCELERATION_ERR_START); + + VectorXd angVelocityDevice = predicted_state.segment(STATE_ANGULAR_VELOCITY_START); + VectorXd angVelocityDeviceErr = predicted_std.segment(STATE_ANGULAR_VELOCITY_ERR_START); + + Vector3d nans = Vector3d(NAN, NAN, NAN); + + // write measurements to msg + init_measurement(fix.initPositionGeodetic(), fix_pos_geo_vec, nans, this->gps_mode); + init_measurement(fix.initPositionECEF(), fix_ecef, fix_ecef_std, this->gps_mode); + init_measurement(fix.initVelocityECEF(), vel_ecef, vel_ecef_std, this->gps_mode); + init_measurement(fix.initVelocityNED(), ned_vel, nans, this->gps_mode); + init_measurement(fix.initVelocityDevice(), vel_device, vel_device_std, true); + init_measurement(fix.initAccelerationDevice(), accDevice, accDeviceErr, true); + init_measurement(fix.initOrientationECEF(), orientation_ecef, orientation_ecef_std, this->gps_mode); + init_measurement(fix.initCalibratedOrientationECEF(), calibrated_orientation_ecef, nans, this->calibrated && this->gps_mode); + init_measurement(fix.initOrientationNED(), orientation_ned, nans, this->gps_mode); + init_measurement(fix.initCalibratedOrientationNED(), calibrated_orientation_ned, nans, this->calibrated && this->gps_mode); + init_measurement(fix.initAngularVelocityDevice(), angVelocityDevice, angVelocityDeviceErr, true); + init_measurement(fix.initVelocityCalibrated(), vel_calib, vel_calib_std, this->calibrated); + init_measurement(fix.initAngularVelocityCalibrated(), ang_vel_calib, ang_vel_calib_std, this->calibrated); + init_measurement(fix.initAccelerationCalibrated(), acc_calib, acc_calib_std, this->calibrated); + + double old_mean = 0.0, new_mean = 0.0; + int i = 0; + for (double x : this->posenet_stds) { + if (i < POSENET_STD_HIST_HALF) { + old_mean += x; + } else { + new_mean += x; + } + i++; + } + old_mean /= POSENET_STD_HIST_HALF; + new_mean /= POSENET_STD_HIST_HALF; + // experimentally found these values, no false positives in 20k minutes of driving + bool std_spike = (new_mean / old_mean > 4.0 && new_mean > 7.0); + + fix.setPosenetOK(!(std_spike && this->car_speed > 5.0)); + fix.setDeviceStable(!this->device_fell); + fix.setExcessiveResets(this->reset_tracker > MAX_RESET_TRACKER); + this->device_fell = false; + + //fix.setGpsWeek(this->time.week); + //fix.setGpsTimeOfWeek(this->time.tow); + fix.setUnixTimestampMillis(this->unix_timestamp_millis); + + double time_since_reset = this->kf->get_filter_time() - this->last_reset_time; + fix.setTimeSinceReset(time_since_reset); + if (fix_ecef_std.norm() < VALID_POS_STD && this->calibrated && time_since_reset > VALID_TIME_SINCE_RESET) { + fix.setStatus(cereal::LiveLocationKalman::Status::VALID); + } else if (fix_ecef_std.norm() < VALID_POS_STD && time_since_reset > VALID_TIME_SINCE_RESET) { + fix.setStatus(cereal::LiveLocationKalman::Status::UNCALIBRATED); + } else { + fix.setStatus(cereal::LiveLocationKalman::Status::UNINITIALIZED); + } +} + +VectorXd Localizer::get_position_geodetic() { + VectorXd fix_ecef = this->kf->get_x().segment(STATE_ECEF_POS_START); + ECEF fix_ecef_ecef = { .x = fix_ecef(0), .y = fix_ecef(1), .z = fix_ecef(2) }; + Geodetic fix_pos_geo = ecef2geodetic(fix_ecef_ecef); + return Vector3d(fix_pos_geo.lat, fix_pos_geo.lon, fix_pos_geo.alt); +} + +VectorXd Localizer::get_state() { + return this->kf->get_x(); +} + +VectorXd Localizer::get_stdev() { + return this->kf->get_P().diagonal().array().sqrt(); +} + +void Localizer::handle_sensors(double current_time, const capnp::List::Reader& log) { + // TODO does not yet account for double sensor readings in the log + for (int i = 0; i < log.size(); i++) { + const cereal::SensorEventData::Reader& sensor_reading = log[i]; + + // Ignore empty readings (e.g. in case the magnetometer had no data ready) + if (sensor_reading.getTimestamp() == 0) { + continue; + } + + double sensor_time = 1e-9 * sensor_reading.getTimestamp(); + + // sensor time and log time should be close + if (std::abs(current_time - sensor_time) > 0.1) { + LOGE("Sensor reading ignored, sensor timestamp more than 100ms off from log time"); + return; + } + + // TODO: handle messages from two IMUs at the same time + if (sensor_reading.getSource() == cereal::SensorEventData::SensorSource::BMX055) { + continue; + } + + // Gyro Uncalibrated + if (sensor_reading.getSensor() == SENSOR_GYRO_UNCALIBRATED && sensor_reading.getType() == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED) { + auto v = sensor_reading.getGyroUncalibrated().getV(); + auto meas = Vector3d(-v[2], -v[1], -v[0]); + if (meas.norm() < ROTATION_SANITY_CHECK) { + this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_GYRO, { meas }); + } + } + + // Accelerometer + if (sensor_reading.getSensor() == SENSOR_ACCELEROMETER && sensor_reading.getType() == SENSOR_TYPE_ACCELEROMETER) { + auto v = sensor_reading.getAcceleration().getV(); + + // 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 + this->device_fell |= (floatlist2vector(v) - Vector3d(10.0, 0.0, 0.0)).norm() > 40.0; + + auto meas = Vector3d(-v[2], -v[1], -v[0]); + if (meas.norm() < ACCEL_SANITY_CHECK) { + this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_ACCEL, { meas }); + } + } + } +} + +void Localizer::input_fake_gps_observations(double current_time) { + // This is done to make sure that the error estimate of the position does not blow up + // when the filter is in no-gps mode + // Steps : first predict -> observe current obs with reasonable STD + this->kf->predict(current_time); + + VectorXd current_x = this->kf->get_x(); + VectorXd ecef_pos = current_x.segment(STATE_ECEF_POS_START); + VectorXd ecef_vel = current_x.segment(STATE_ECEF_VELOCITY_START); + MatrixXdr ecef_pos_R = this->kf->get_fake_gps_pos_cov(); + MatrixXdr ecef_vel_R = this->kf->get_fake_gps_vel_cov(); + + this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_POS, { ecef_pos }, { ecef_pos_R }); + this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); +} + +void Localizer::handle_gps(double current_time, const cereal::GpsLocationData::Reader& log) { + // ignore the message if the fix is invalid + + bool gps_invalid_flag = (log.getFlags() % 2 == 0); + bool gps_unreasonable = (Vector2d(log.getAccuracy(), log.getVerticalAccuracy()).norm() >= SANE_GPS_UNCERTAINTY); + bool gps_accuracy_insane = ((log.getVerticalAccuracy() <= 0) || (log.getSpeedAccuracy() <= 0) || (log.getBearingAccuracyDeg() <= 0)); + bool gps_lat_lng_alt_insane = ((std::abs(log.getLatitude()) > 90) || (std::abs(log.getLongitude()) > 180) || (std::abs(log.getAltitude()) > ALTITUDE_SANITY_CHECK)); + bool gps_vel_insane = (floatlist2vector(log.getVNED()).norm() > TRANS_SANITY_CHECK); + + if (gps_invalid_flag || gps_unreasonable || gps_accuracy_insane || gps_lat_lng_alt_insane || gps_vel_insane){ + this->determine_gps_mode(current_time); + return; + } + + // Process message + this->last_gps_fix = current_time; + this->gps_mode = true; + Geodetic geodetic = { log.getLatitude(), log.getLongitude(), log.getAltitude() }; + this->converter = std::make_unique(geodetic); + + VectorXd ecef_pos = this->converter->ned2ecef({ 0.0, 0.0, 0.0 }).to_vector(); + VectorXd ecef_vel = this->converter->ned2ecef({ log.getVNED()[0], log.getVNED()[1], log.getVNED()[2] }).to_vector() - ecef_pos; + MatrixXdr ecef_pos_R = Vector3d::Constant(std::pow(10.0 * log.getAccuracy(),2) + std::pow(10.0 * log.getVerticalAccuracy(),2)).asDiagonal(); + MatrixXdr ecef_vel_R = Vector3d::Constant(std::pow(log.getSpeedAccuracy() * 10.0, 2)).asDiagonal(); + + this->unix_timestamp_millis = log.getTimestamp(); + double gps_est_error = (this->kf->get_x().segment(STATE_ECEF_POS_START) - ecef_pos).norm(); + + VectorXd orientation_ecef = quat2euler(vector2quat(this->kf->get_x().segment(STATE_ECEF_ORIENTATION_START))); + VectorXd orientation_ned = ned_euler_from_ecef({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ecef); + VectorXd orientation_ned_gps = Vector3d(0.0, 0.0, DEG2RAD(log.getBearingDeg())); + VectorXd orientation_error = (orientation_ned - orientation_ned_gps).array() - M_PI; + for (int i = 0; i < orientation_error.size(); i++) { + orientation_error(i) = std::fmod(orientation_error(i), 2.0 * M_PI); + if (orientation_error(i) < 0.0) { + orientation_error(i) += 2.0 * M_PI; + } + orientation_error(i) -= M_PI; + } + VectorXd initial_pose_ecef_quat = quat2vector(euler2quat(ecef_euler_from_ned({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ned_gps))); + + if (ecef_vel.norm() > 5.0 && orientation_error.norm() > 1.0) { + LOGE("Locationd vs ubloxLocation orientation difference too large, kalman reset"); + this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); + this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_ORIENTATION_FROM_GPS, { initial_pose_ecef_quat }); + } else if (gps_est_error > 100.0) { + LOGE("Locationd vs ubloxLocation position difference too large, kalman reset"); + this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); + } + + this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_POS, { ecef_pos }, { ecef_pos_R }); + this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); +} + +void Localizer::handle_car_state(double current_time, const cereal::CarState::Reader& log) { + this->car_speed = std::abs(log.getVEgo()); + if (log.getStandstill()) { + this->kf->predict_and_observe(current_time, OBSERVATION_NO_ROT, { Vector3d(0.0, 0.0, 0.0) }); + this->kf->predict_and_observe(current_time, OBSERVATION_NO_ACCEL, { Vector3d(0.0, 0.0, 0.0) }); + } +} + +void Localizer::handle_cam_odo(double current_time, const cereal::CameraOdometry::Reader& log) { + VectorXd rot_device = this->device_from_calib * floatlist2vector(log.getRot()); + VectorXd trans_device = this->device_from_calib * floatlist2vector(log.getTrans()); + + if ((rot_device.norm() > ROTATION_SANITY_CHECK) || (trans_device.norm() > TRANS_SANITY_CHECK)) { + return; + } + + VectorXd rot_calib_std = floatlist2vector(log.getRotStd()); + VectorXd trans_calib_std = floatlist2vector(log.getTransStd()); + + if ((rot_calib_std.minCoeff() <= MIN_STD_SANITY_CHECK) || (trans_calib_std.minCoeff() <= MIN_STD_SANITY_CHECK)) { + return; + } + + if ((rot_calib_std.norm() > 10 * ROTATION_SANITY_CHECK) || (trans_calib_std.norm() > 10 * TRANS_SANITY_CHECK)) { + return; + } + + this->posenet_stds.pop_front(); + this->posenet_stds.push_back(trans_calib_std[0]); + + // Multiply by 10 to avoid to high certainty in kalman filter because of temporally correlated noise + trans_calib_std *= 10.0; + rot_calib_std *= 10.0; + MatrixXdr rot_device_cov = rotate_std(this->device_from_calib, rot_calib_std).array().square().matrix().asDiagonal(); + MatrixXdr trans_device_cov = rotate_std(this->device_from_calib, trans_calib_std).array().square().matrix().asDiagonal(); + this->kf->predict_and_observe(current_time, OBSERVATION_CAMERA_ODO_ROTATION, + { rot_device }, { rot_device_cov }); + this->kf->predict_and_observe(current_time, OBSERVATION_CAMERA_ODO_TRANSLATION, + { trans_device }, { trans_device_cov }); +} + +void Localizer::handle_live_calib(double current_time, const cereal::LiveCalibrationData::Reader& log) { + if (log.getRpyCalib().size() > 0) { + auto live_calib = floatlist2vector(log.getRpyCalib()); + if ((live_calib.minCoeff() < -CALIB_RPY_SANITY_CHECK) || (live_calib.maxCoeff() > CALIB_RPY_SANITY_CHECK)) { + return; + } + + this->calib = live_calib; + this->device_from_calib = euler2rot(this->calib); + this->calib_from_device = this->device_from_calib.transpose(); + this->calibrated = log.getCalStatus() == 1; + } +} + +void Localizer::reset_kalman(double current_time) { + VectorXd init_x = this->kf->get_initial_x(); + MatrixXdr init_P = this->kf->get_initial_P(); + this->reset_kalman(current_time, init_x, init_P); +} + +void Localizer::finite_check(double current_time) { + bool all_finite = this->kf->get_x().array().isFinite().all() or this->kf->get_P().array().isFinite().all(); + if (!all_finite) { + LOGE("Non-finite values detected, kalman reset"); + this->reset_kalman(current_time); + } +} + +void Localizer::time_check(double current_time) { + if (std::isnan(this->last_reset_time)) { + this->last_reset_time = current_time; + } + double filter_time = this->kf->get_filter_time(); + bool big_time_gap = !std::isnan(filter_time) && (current_time - filter_time > 10); + if (big_time_gap) { + LOGE("Time gap of over 10s detected, kalman reset"); + this->reset_kalman(current_time); + } +} + +void Localizer::update_reset_tracker() { + // reset tracker is tuned to trigger when over 1reset/10s over 2min period + if (this->isGpsOK()) { + this->reset_tracker *= .99995; + } else { + this->reset_tracker = 0.0; + } +} + +void Localizer::reset_kalman(double current_time, VectorXd init_orient, VectorXd init_pos, VectorXd init_vel, MatrixXdr init_pos_R, MatrixXdr init_vel_R) { + // too nonlinear to init on completely wrong + VectorXd current_x = this->kf->get_x(); + MatrixXdr current_P = this->kf->get_P(); + MatrixXdr init_P = this->kf->get_initial_P(); + MatrixXdr reset_orientation_P = this->kf->get_reset_orientation_P(); + int non_ecef_state_err_len = init_P.rows() - (STATE_ECEF_POS_ERR_LEN + STATE_ECEF_ORIENTATION_ERR_LEN + STATE_ECEF_VELOCITY_ERR_LEN); + + current_x.segment(STATE_ECEF_ORIENTATION_START) = init_orient; + current_x.segment(STATE_ECEF_VELOCITY_START) = init_vel; + current_x.segment(STATE_ECEF_POS_START) = init_pos; + + init_P.block(STATE_ECEF_POS_ERR_START, STATE_ECEF_POS_ERR_START).diagonal() = init_pos_R.diagonal(); + init_P.block(STATE_ECEF_ORIENTATION_ERR_START, STATE_ECEF_ORIENTATION_ERR_START).diagonal() = reset_orientation_P.diagonal(); + init_P.block(STATE_ECEF_VELOCITY_ERR_START, STATE_ECEF_VELOCITY_ERR_START).diagonal() = init_vel_R.diagonal(); + init_P.block(STATE_ANGULAR_VELOCITY_ERR_START, STATE_ANGULAR_VELOCITY_ERR_START, non_ecef_state_err_len, non_ecef_state_err_len).diagonal() = current_P.block(STATE_ANGULAR_VELOCITY_ERR_START, STATE_ANGULAR_VELOCITY_ERR_START, non_ecef_state_err_len, non_ecef_state_err_len).diagonal(); + + this->reset_kalman(current_time, current_x, init_P); +} + +void Localizer::reset_kalman(double current_time, VectorXd init_x, MatrixXdr init_P) { + this->kf->init_state(init_x, init_P, current_time); + this->last_reset_time = current_time; + this->reset_tracker += 1.0; +} + +void Localizer::handle_msg_bytes(const char *data, const size_t size) { + AlignedBuffer aligned_buf; + + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(data, size)); + cereal::Event::Reader event = cmsg.getRoot(); + + this->handle_msg(event); +} + +void Localizer::handle_msg(const cereal::Event::Reader& log) { + double t = log.getLogMonoTime() * 1e-9; + this->time_check(t); + if (log.isSensorEvents()) { + this->handle_sensors(t, log.getSensorEvents()); + } else if (log.isGpsLocationExternal()) { + this->handle_gps(t, log.getGpsLocationExternal()); + } else if (log.isCarState()) { + this->handle_car_state(t, log.getCarState()); + } else if (log.isCameraOdometry()) { + this->handle_cam_odo(t, log.getCameraOdometry()); + } else if (log.isLiveCalibration()) { + this->handle_live_calib(t, log.getLiveCalibration()); + } + this->finite_check(); + this->update_reset_tracker(); +} + +kj::ArrayPtr Localizer::get_message_bytes(MessageBuilder& msg_builder, uint64_t logMonoTime, + bool inputsOK, bool sensorsOK, bool gpsOK) +{ + cereal::Event::Builder evt = msg_builder.initEvent(); + evt.setLogMonoTime(logMonoTime); + cereal::LiveLocationKalman::Builder liveLoc = evt.initLiveLocationKalman(); + this->build_live_location(liveLoc); + liveLoc.setInputsOK(inputsOK); + liveLoc.setSensorsOK(sensorsOK); + liveLoc.setGpsOK(gpsOK); + return msg_builder.toBytes(); +} + + +bool Localizer::isGpsOK() { + return this->kf->get_filter_time() - this->last_gps_fix < 1.0; +} + +void Localizer::determine_gps_mode(double current_time) { + // 1. If the pos_std is greater than what's not acceptible and localizer is in gps-mode, reset to no-gps-mode + // 2. If the pos_std is greater than what's not acceptible and localizer is in no-gps-mode, fake obs + // 3. If the pos_std is smaller than what's not acceptible, let gps-mode be whatever it is + VectorXd current_pos_std = this->kf->get_P().block(STATE_ECEF_POS_ERR_START, STATE_ECEF_POS_ERR_START).diagonal().array().sqrt(); + if (current_pos_std.norm() > SANE_GPS_UNCERTAINTY){ + if (this->gps_mode){ + this->gps_mode = false; + this->reset_kalman(current_time); + } + else{ + this->input_fake_gps_observations(current_time); + } + } +} + +int Localizer::locationd_thread() { + const std::initializer_list service_list = + { "gpsLocationExternal", "sensorEvents", "cameraOdometry", "liveCalibration", "carState" }; + PubMaster pm({ "liveLocationKalman" }); + SubMaster sm(service_list, nullptr, { "gpsLocationExternal" }); + + while (!do_exit) { + sm.update(); + for (const char* service : service_list) { + if (sm.updated(service) && sm.valid(service)) { + const cereal::Event::Reader log = sm[service]; + this->handle_msg(log); + } + } + + if (sm.updated("cameraOdometry")) { + uint64_t logMonoTime = sm["cameraOdometry"].getLogMonoTime(); + bool inputsOK = sm.allAliveAndValid(); + bool sensorsOK = sm.alive("sensorEvents") && sm.valid("sensorEvents"); + bool gpsOK = this->isGpsOK(); + + MessageBuilder msg_builder; + kj::ArrayPtr bytes = this->get_message_bytes(msg_builder, logMonoTime, inputsOK, sensorsOK, gpsOK); + pm.send("liveLocationKalman", bytes.begin(), bytes.size()); + + if (sm.frame % 1200 == 0 && gpsOK) { // once a minute + VectorXd posGeo = this->get_position_geodetic(); + std::string lastGPSPosJSON = util::string_format( + "{\"latitude\": %.15f, \"longitude\": %.15f, \"altitude\": %.15f}", posGeo(0), posGeo(1), posGeo(2)); + + std::thread([] (const std::string gpsjson) { + Params().put("LastGPSPosition", gpsjson); + }, lastGPSPosJSON).detach(); + } + } + } + return 0; +} + +int main() { + util::set_realtime_priority(5); + + Localizer localizer; + return localizer.locationd_thread(); +} diff --git a/selfdrive/locationd/locationd.h b/selfdrive/locationd/locationd.h new file mode 100755 index 00000000000000..9bc864bf6d8cca --- /dev/null +++ b/selfdrive/locationd/locationd.h @@ -0,0 +1,75 @@ +#pragma once + +#include +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "common/transformations/coordinates.hpp" +#include "common/transformations/orientation.hpp" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" + +#include "selfdrive/sensord/sensors/constants.h" +#define VISION_DECIMATION 2 +#define SENSOR_DECIMATION 10 +#include "selfdrive/locationd/models/live_kf.h" + +#define POSENET_STD_HIST_HALF 20 + +class Localizer { +public: + Localizer(); + + int locationd_thread(); + + void reset_kalman(double current_time = NAN); + void reset_kalman(double current_time, Eigen::VectorXd init_orient, Eigen::VectorXd init_pos, Eigen::VectorXd init_vel, MatrixXdr init_pos_R, MatrixXdr init_vel_R); + void reset_kalman(double current_time, Eigen::VectorXd init_x, MatrixXdr init_P); + void finite_check(double current_time = NAN); + void time_check(double current_time = NAN); + void update_reset_tracker(); + bool isGpsOK(); + void determine_gps_mode(double current_time); + + kj::ArrayPtr get_message_bytes(MessageBuilder& msg_builder, uint64_t logMonoTime, + bool inputsOK, bool sensorsOK, bool gpsOK); + void build_live_location(cereal::LiveLocationKalman::Builder& fix); + + Eigen::VectorXd get_position_geodetic(); + Eigen::VectorXd get_state(); + Eigen::VectorXd get_stdev(); + + void handle_msg_bytes(const char *data, const size_t size); + void handle_msg(const cereal::Event::Reader& log); + void handle_sensors(double current_time, const capnp::List::Reader& log); + void handle_gps(double current_time, const cereal::GpsLocationData::Reader& log); + void handle_car_state(double current_time, const cereal::CarState::Reader& log); + void handle_cam_odo(double current_time, const cereal::CameraOdometry::Reader& log); + void handle_live_calib(double current_time, const cereal::LiveCalibrationData::Reader& log); + + void input_fake_gps_observations(double current_time); + +private: + std::unique_ptr kf; + + Eigen::VectorXd calib; + MatrixXdr device_from_calib; + MatrixXdr calib_from_device; + bool calibrated = false; + + double car_speed = 0.0; + double last_reset_time = NAN; + std::deque posenet_stds; + + std::unique_ptr converter; + + int64_t unix_timestamp_millis = 0; + double last_gps_fix = 0; + double reset_tracker = 0.0; + bool device_fell = false; + bool gps_mode = false; +}; diff --git a/selfdrive/locationd/locationd_yawrate.cc b/selfdrive/locationd/locationd_yawrate.cc deleted file mode 100644 index f03f808ffdb99d..00000000000000 --- a/selfdrive/locationd/locationd_yawrate.cc +++ /dev/null @@ -1,311 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include "json11.hpp" - -#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" - -const int num_polls = 3; - -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) { - double dt = current_time - prev_update_time; - prev_update_time = current_time; - if (dt < 1.0e-9) { - return; - } - - // 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 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 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); - } - - void 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; - } - - -public: - Eigen::Vector2d x; - double steering_angle = 0; - double car_speed = 0; - double prev_update_time = -1; - double controls_state_time = -1; - double sensor_data_time = -1; - - 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); - } - - cereal::Event::Which handle_log(const unsigned char* msg_dat, size_t msg_size) { - const kj::ArrayPtr view((const capnp::word*)msg_dat, msg_size); - capnp::FlatArrayMessageReader msg(view); - cereal::Event::Reader event = msg.getRoot(); - double current_time = event.getLogMonoTime() / 1.0e9; - - 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; - } - - return type; - } -}; - - - -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 = sensor_events_sock; - polls[1].events = ZMQ_POLLIN; - polls[2].socket = camera_odometry_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; - - 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)); - - auto which = localizer.handle_log((const unsigned char*)amsg.begin(), amsg.size()); - zmq_msg_close(&msg); - - 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 10 Hz - if (save_counter % 10 == 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); - - 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; -} - - -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) { - Localizer * loc = (Localizer*) localizer; - loc->handle_log(data, len); - } - - 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]; - } - double localizer_get_t(void * localizer) { - Localizer * loc = (Localizer*) localizer; - return loc->prev_update_time; - } -} 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/car_kf.py b/selfdrive/locationd/models/car_kf.py new file mode 100755 index 00000000000000..dac95dcd7bbce3 --- /dev/null +++ b/selfdrive/locationd/models/car_kf.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python3 +import math +import sys +from typing import Any, Dict + +import numpy as np + +from selfdrive.locationd.models.constants import ObservationKind +from selfdrive.swaglog import cloudlog + +from rednose.helpers.kalmanfilter import KalmanFilter + +if __name__ == '__main__': # Generating sympy + import sympy as sp + from rednose.helpers.ekf_sym import gen_code +else: + from rednose.helpers.ekf_sym_pyx import EKF_sym # pylint: disable=no-name-in-module, import-error + + +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 = [ + 'mass', + 'rotational_inertia', + 'center_to_front', + 'center_to_rear', + 'stiffness_front', + 'stiffness_rear', + ] + + @staticmethod + def generate_code(generated_dir): + dim_state = CarKalman.initial_x.shape[0] + name = CarKalman.name + + # vehicle models comes from The Science of Vehicle Dynamics: Handling, Braking, and Ride of Road and Race Cars + # Model used is in 6.15 with formula from 6.198 + + # globals + global_vars = [sp.Symbol(name) for name in CarKalman.global_vars] + m, j, aF, aR, cF_orig, cR_orig = 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=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, logger=cloudlog) + + +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..7450f76be7e3bb --- /dev/null +++ b/selfdrive/locationd/models/constants.py @@ -0,0 +1,82 @@ +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 + NO_ACCEL = 33 + + 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.cc b/selfdrive/locationd/models/live_kf.cc new file mode 100755 index 00000000000000..5ff0f2699555b1 --- /dev/null +++ b/selfdrive/locationd/models/live_kf.cc @@ -0,0 +1,122 @@ +#include "live_kf.h" + +using namespace EKFS; +using namespace Eigen; + +Eigen::Map get_mapvec(Eigen::VectorXd& vec) { + return Eigen::Map(vec.data(), vec.rows(), vec.cols()); +} + +Eigen::Map get_mapmat(MatrixXdr& mat) { + return Eigen::Map(mat.data(), mat.rows(), mat.cols()); +} + +std::vector> get_vec_mapvec(std::vector& vec_vec) { + std::vector> res; + for (Eigen::VectorXd& vec : vec_vec) { + res.push_back(get_mapvec(vec)); + } + return res; +} + +std::vector> get_vec_mapmat(std::vector& mat_vec) { + std::vector> res; + for (MatrixXdr& mat : mat_vec) { + res.push_back(get_mapmat(mat)); + } + return res; +} + +LiveKalman::LiveKalman() { + this->dim_state = live_initial_x.rows(); + this->dim_state_err = live_initial_P_diag.rows(); + + this->initial_x = live_initial_x; + this->initial_P = live_initial_P_diag.asDiagonal(); + this->fake_gps_pos_cov = live_fake_gps_pos_cov_diag.asDiagonal(); + this->fake_gps_vel_cov = live_fake_gps_vel_cov_diag.asDiagonal(); + this->reset_orientation_P = live_reset_orientation_diag.asDiagonal(); + this->Q = live_Q_diag.asDiagonal(); + for (auto& pair : live_obs_noise_diag) { + this->obs_noise[pair.first] = pair.second.asDiagonal(); + } + + // init filter + this->filter = std::make_shared(this->name, get_mapmat(this->Q), get_mapvec(this->initial_x), + get_mapmat(initial_P), this->dim_state, this->dim_state_err, 0, 0, 0, std::vector(), + std::vector{3}, std::vector(), 0.2); +} + +void LiveKalman::init_state(VectorXd& state, VectorXd& covs_diag, double filter_time) { + MatrixXdr covs = covs_diag.asDiagonal(); + this->filter->init_state(get_mapvec(state), get_mapmat(covs), filter_time); +} + +void LiveKalman::init_state(VectorXd& state, MatrixXdr& covs, double filter_time) { + this->filter->init_state(get_mapvec(state), get_mapmat(covs), filter_time); +} + +void LiveKalman::init_state(VectorXd& state, double filter_time) { + MatrixXdr covs = this->filter->covs(); + this->filter->init_state(get_mapvec(state), get_mapmat(covs), filter_time); +} + +VectorXd LiveKalman::get_x() { + return this->filter->state(); +} + +MatrixXdr LiveKalman::get_P() { + return this->filter->covs(); +} + +double LiveKalman::get_filter_time() { + return this->filter->get_filter_time(); +} + +std::vector LiveKalman::get_R(int kind, int n) { + std::vector R; + for (int i = 0; i < n; i++) { + R.push_back(this->obs_noise[kind]); + } + return R; +} + +std::optional LiveKalman::predict_and_observe(double t, int kind, std::vector meas, std::vector R) { + std::optional r; + if (R.size() == 0) { + R = this->get_R(kind, meas.size()); + } + r = this->filter->predict_and_update_batch(t, kind, get_vec_mapvec(meas), get_vec_mapmat(R)); + return r; +} + +void LiveKalman::predict(double t) { + this->filter->predict(t); +} + +Eigen::VectorXd LiveKalman::get_initial_x() { + return this->initial_x; +} + +MatrixXdr LiveKalman::get_initial_P() { + return this->initial_P; +} + +MatrixXdr LiveKalman::get_fake_gps_pos_cov() { + return this->fake_gps_pos_cov; +} + +MatrixXdr LiveKalman::get_fake_gps_vel_cov() { + return this->fake_gps_vel_cov; +} + +MatrixXdr LiveKalman::get_reset_orientation_P() { + return this->reset_orientation_P; +} + +MatrixXdr LiveKalman::H(VectorXd in) { + assert(in.size() == 6); + Matrix res; + this->filter->get_extra_routine("H")(in.data(), res.data()); + return res; +} diff --git a/selfdrive/locationd/models/live_kf.h b/selfdrive/locationd/models/live_kf.h new file mode 100755 index 00000000000000..06ec3854cb3d62 --- /dev/null +++ b/selfdrive/locationd/models/live_kf.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include + +#include +#include + +#include "generated/live_kf_constants.h" +#include "rednose/helpers/ekf_sym.h" + +#define EARTH_GM 3.986005e14 // m^3/s^2 (gravitational constant * mass of earth) + +using namespace EKFS; + +Eigen::Map get_mapvec(Eigen::VectorXd& vec); +Eigen::Map get_mapmat(MatrixXdr& mat); +std::vector> get_vec_mapvec(std::vector& vec_vec); +std::vector> get_vec_mapmat(std::vector& mat_vec); + +class LiveKalman { +public: + LiveKalman(); + + void init_state(Eigen::VectorXd& state, Eigen::VectorXd& covs_diag, double filter_time); + void init_state(Eigen::VectorXd& state, MatrixXdr& covs, double filter_time); + void init_state(Eigen::VectorXd& state, double filter_time); + + Eigen::VectorXd get_x(); + MatrixXdr get_P(); + double get_filter_time(); + std::vector get_R(int kind, int n); + + std::optional predict_and_observe(double t, int kind, std::vector meas, std::vector R = {}); + std::optional predict_and_update_odo_speed(std::vector speed, double t, int kind); + std::optional predict_and_update_odo_trans(std::vector trans, double t, int kind); + std::optional predict_and_update_odo_rot(std::vector rot, double t, int kind); + void predict(double t); + + Eigen::VectorXd get_initial_x(); + MatrixXdr get_initial_P(); + MatrixXdr get_fake_gps_pos_cov(); + MatrixXdr get_fake_gps_vel_cov(); + MatrixXdr get_reset_orientation_P(); + + MatrixXdr H(Eigen::VectorXd in); + +private: + std::string name = "live"; + + std::shared_ptr filter; + + int dim_state; + int dim_state_err; + + Eigen::VectorXd initial_x; + MatrixXdr initial_P; + MatrixXdr fake_gps_pos_cov; + MatrixXdr fake_gps_vel_cov; + MatrixXdr reset_orientation_P; + MatrixXdr Q; // process noise + std::unordered_map obs_noise; +}; diff --git a/selfdrive/locationd/models/live_kf.py b/selfdrive/locationd/models/live_kf.py new file mode 100755 index 00000000000000..fa529459328f75 --- /dev/null +++ b/selfdrive/locationd/models/live_kf.py @@ -0,0 +1,242 @@ +#!/usr/bin/env python3 + +import sys +import os +import numpy as np + +from selfdrive.locationd.models.constants import ObservationKind + +import sympy as sp +import inspect +from rednose.helpers.sympy_helpers import euler_rotate, quat_matrix_r, quat_rotate +from rednose.helpers.ekf_sym import gen_code + +EARTH_GM = 3.986005e14 # m^3/s^2 (gravitational constant * mass of earth) + + +def numpy2eigenstring(arr): + assert(len(arr.shape) == 1) + arr_str = np.array2string(arr, precision=20, separator=',')[1:-1].replace(' ', '').replace('\n', '') + return f"(Eigen::VectorXd({len(arr)}) << {arr_str}).finished()" + + +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 + ACCELERATION = slice(16, 19) # Acceleration in device frame in m/s**2 + ACC_BIAS = slice(19, 22) # Acceletometer bias in m/s**2 + + # 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) + ACCELERATION_ERR = slice(15, 18) + ACC_BIAS_ERR = slice(18, 21) + + +class LiveKalman(): + name = 'live' + + initial_x = np.array([3.88e6, -3.37e6, 3.76e6, + 0.42254641, -0.31238054, -0.83602975, -0.15788347, # NED [0,0,0] -> ECEF Quat + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0]) + + # state covariance + initial_P_diag = np.array([10**2, 10**2, 10**2, + 0.01**2, 0.01**2, 0.01**2, + 10**2, 10**2, 10**2, + 1**2, 1**2, 1**2, + 1**2, 1**2, 1**2, + 100**2, 100**2, 100**2, + 0.01**2, 0.01**2, 0.01**2]) + + # state covariance when resetting midway in a segment + reset_orientation_diag = np.array([1**2, 1**2, 1**2]) + + # fake observation covariance, to ensure the uncertainty estimate of the filter is under control + fake_gps_pos_cov_diag = np.array([1000**2, 1000**2, 1000**2]) + fake_gps_vel_cov_diag = np.array([10**2, 10**2, 10**2]) + + # process noise + Q_diag = np.array([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, + 3**2, 3**2, 3**2, + 0.005**2, 0.005**2, 0.005**2]) + + obs_noise_diag = {ObservationKind.PHONE_GYRO: np.array([0.025**2, 0.025**2, 0.025**2]), + ObservationKind.PHONE_ACCEL: np.array([.5**2, .5**2, .5**2]), + ObservationKind.CAMERA_ODO_ROTATION: np.array([0.05**2, 0.05**2, 0.05**2]), + ObservationKind.NO_ROT: np.array([0.005**2, 0.005**2, 0.005**2]), + ObservationKind.NO_ACCEL: np.array([0.05**2, 0.05**2, 0.05**2]), + ObservationKind.ECEF_POS: np.array([5**2, 5**2, 5**2]), + ObservationKind.ECEF_VEL: np.array([.5**2, .5**2, .5**2]), + ObservationKind.ECEF_ORIENTATION_FROM_GPS: np.array([.2**2, .2**2, .2**2, .2**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, :] + acceleration = state[States.ACCELERATION, :] + acc_bias = state[States.ACC_BIAS, :] + + 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 + # + 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 + acc_bias) + h_acc_stationary_sym = acceleration + h_phone_rot_sym = sp.Matrix([vroll, vpitch, vyaw]) + h_pos_sym = sp.Matrix([x, y, z]) + h_vel_sym = sp.Matrix([vx, vy, vz]) + h_orientation_sym = q + h_relative_motion = sp.Matrix(quat_rot.T * v) + + obs_eqs = [[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_acc_stationary_sym, ObservationKind.NO_ACCEL, None]] + + # this returns a sympy routine for the jacobian of the observation function of the local vel + in_vec = sp.MatrixSymbol('in_vec', 6, 1) # roll, pitch, yaw, vx, vy, vz + h = euler_rotate(in_vec[0], in_vec[1], in_vec[2]).T * (sp.Matrix([in_vec[3], in_vec[4], in_vec[5]])) + extra_routines = [('H', h.jacobian(in_vec), [in_vec])] + + gen_code(generated_dir, name, f_sym, dt, state_sym, obs_eqs, dim_state, dim_state_err, eskf_params, extra_routines=extra_routines) + + # write constants to extra header file for use in cpp + live_kf_header = "#pragma once\n\n" + live_kf_header += "#include \n" + live_kf_header += "#include \n\n" + for state, slc in inspect.getmembers(States, lambda x: type(x) == slice): + assert(slc.step is None) # unsupported + live_kf_header += f'#define STATE_{state}_START {slc.start}\n' + live_kf_header += f'#define STATE_{state}_END {slc.stop}\n' + live_kf_header += f'#define STATE_{state}_LEN {slc.stop - slc.start}\n' + live_kf_header += "\n" + + for kind, val in inspect.getmembers(ObservationKind, lambda x: type(x) == int): + live_kf_header += f'#define OBSERVATION_{kind} {val}\n' + live_kf_header += "\n" + + live_kf_header += f"static const Eigen::VectorXd live_initial_x = {numpy2eigenstring(LiveKalman.initial_x)};\n" + live_kf_header += f"static const Eigen::VectorXd live_initial_P_diag = {numpy2eigenstring(LiveKalman.initial_P_diag)};\n" + live_kf_header += f"static const Eigen::VectorXd live_fake_gps_pos_cov_diag = {numpy2eigenstring(LiveKalman.fake_gps_pos_cov_diag)};\n" + live_kf_header += f"static const Eigen::VectorXd live_fake_gps_vel_cov_diag = {numpy2eigenstring(LiveKalman.fake_gps_vel_cov_diag)};\n" + live_kf_header += f"static const Eigen::VectorXd live_reset_orientation_diag = {numpy2eigenstring(LiveKalman.reset_orientation_diag)};\n" + live_kf_header += f"static const Eigen::VectorXd live_Q_diag = {numpy2eigenstring(LiveKalman.Q_diag)};\n" + live_kf_header += "static const std::unordered_map> live_obs_noise_diag = {\n" + for kind, noise in LiveKalman.obs_noise_diag.items(): + live_kf_header += f" {{ {kind}, {numpy2eigenstring(noise)} }},\n" + live_kf_header += "};\n\n" + + open(os.path.join(generated_dir, "live_kf_constants.h"), 'w').write(live_kf_header) + + +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 a150805d863f03..00000000000000 --- a/selfdrive/locationd/params_learner.cc +++ /dev/null @@ -1,75 +0,0 @@ -#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; -} 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.py b/selfdrive/locationd/paramsd.py new file mode 100755 index 00000000000000..914e0d0223714e --- /dev/null +++ b/selfdrive/locationd/paramsd.py @@ -0,0 +1,181 @@ +#!/usr/bin/env python3 +import gc +import math + +import json +import numpy as np + +import cereal.messaging as messaging +from cereal import car +from common.params import Params, put_nonblocking +from common.realtime import set_realtime_priority, DT_MDL +from common.numpy_fast import clip +from selfdrive.locationd.models.car_kf import CarKalman, ObservationKind, States +from selfdrive.locationd.models.constants import GENERATED_DIR +from selfdrive.swaglog import cloudlog + + +MAX_ANGLE_OFFSET_DELTA = 20 * DT_MDL # Max 20 deg/s + +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_global("mass", CP.mass) + self.kf.filter.set_global("rotational_inertia", CP.rotationalInertia) + self.kf.filter.set_global("center_to_front", CP.centerToFront) + self.kf.filter.set_global("center_to_rear", CP.wheelbase - CP.centerToFront) + self.kf.filter.set_global("stiffness_front", CP.tireStiffnessFront) + self.kf.filter.set_global("stiffness_rear", CP.tireStiffnessRear) + + 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] + + yaw_rate_valid = msg.angularVelocityCalibrated.valid + yaw_rate_valid = yaw_rate_valid and 0 < yaw_rate_std < 10 # rad/s + yaw_rate_valid = yaw_rate_valid and abs(yaw_rate) < 1 # rad/s + + if self.active: + if msg.inputsOK and msg.posenetOK and yaw_rate_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.steeringAngleDeg + 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.steeringAngleDeg)]])) + 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.set_filter_time(t) + self.kf.filter.reset_rewind() + + +def main(sm=None, pm=None): + gc.disable() + set_realtime_priority(5) + + 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 + + # Check if starting values are sane + if params is not None: + try: + angle_offset_sane = abs(params.get('angleOffsetAverageDeg')) < 10.0 + steer_ratio_sane = min_sr <= params['steerRatio'] <= max_sr + params_sane = angle_offset_sane and steer_ratio_sane + if not params_sane: + cloudlog.info(f"Invalid starting values found {params}") + params = None + except Exception as e: + cloudlog.info(f"Error reading params {params}: {str(e)}") + params = None + + # TODO: cache the params with the capnp struct + if params is None: + params = { + 'carFingerprint': CP.carFingerprint, + 'steerRatio': CP.steerRatio, + 'stiffnessFactor': 1.0, + 'angleOffsetAverageDeg': 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['angleOffsetAverageDeg'])) + angle_offset_average = params['angleOffsetAverageDeg'] + angle_offset = angle_offset_average + + while True: + sm.update() + for which in sorted(sm.updated.keys(), key=lambda x: sm.logMonoTime[x]): + if sm.updated[which]: + t = sm.logMonoTime[which] * 1e-9 + learner.handle_log(t, which, sm[which]) + + if sm.updated['liveLocationKalman']: + x = learner.kf.x + P = np.sqrt(learner.kf.P.diagonal()) + if not all(map(math.isfinite, x)): + cloudlog.error("NaN in liveParameters estimate. Resetting to default values") + learner = ParamsLearner(CP, CP.steerRatio, 1.0, 0.0) + x = learner.kf.x + + angle_offset_average = clip(math.degrees(x[States.ANGLE_OFFSET]), angle_offset_average - MAX_ANGLE_OFFSET_DELTA, angle_offset_average + MAX_ANGLE_OFFSET_DELTA) + angle_offset = clip(math.degrees(x[States.ANGLE_OFFSET] + x[States.ANGLE_OFFSET_FAST]), angle_offset - MAX_ANGLE_OFFSET_DELTA, angle_offset + MAX_ANGLE_OFFSET_DELTA) + + msg = messaging.new_message('liveParameters') + msg.logMonoTime = sm.logMonoTime['carState'] + + msg.liveParameters.posenetValid = True + msg.liveParameters.sensorValid = True + msg.liveParameters.steerRatio = float(x[States.STEER_RATIO]) + msg.liveParameters.stiffnessFactor = float(x[States.STIFFNESS]) + msg.liveParameters.angleOffsetAverageDeg = angle_offset_average + msg.liveParameters.angleOffsetDeg = angle_offset + msg.liveParameters.valid = all(( + abs(msg.liveParameters.angleOffsetAverageDeg) < 10.0, + abs(msg.liveParameters.angleOffsetDeg) < 10.0, + 0.2 <= msg.liveParameters.stiffnessFactor <= 5.0, + min_sr <= msg.liveParameters.steerRatio <= max_sr, + )) + msg.liveParameters.steerRatioStd = float(P[States.STEER_RATIO]) + msg.liveParameters.stiffnessFactorStd = float(P[States.STIFFNESS]) + msg.liveParameters.angleOffsetAverageStd = float(P[States.ANGLE_OFFSET]) + msg.liveParameters.angleOffsetFastStd = float(P[States.ANGLE_OFFSET_FAST]) + + if sm.frame % 1200 == 0: # once a minute + params = { + 'carFingerprint': CP.carFingerprint, + 'steerRatio': msg.liveParameters.steerRatio, + 'stiffnessFactor': msg.liveParameters.stiffnessFactor, + 'angleOffsetAverageDeg': msg.liveParameters.angleOffsetAverageDeg, + } + 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/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..9e32c7b070ba57 100644 --- a/selfdrive/locationd/ublox_msg.cc +++ b/selfdrive/locationd/ublox_msg.cc @@ -1,161 +1,29 @@ -#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" - #include "ublox_msg.h" -#define UBLOX_MSG_SIZE(hdr) (*(uint16_t *)&hdr[4]) -#define GET_FIELD_U(w, nb, pos) (((w) >> (pos)) & ((1<<(nb))-1)) +#include -namespace ublox { +#include +#include +#include +#include +#include +#include +#include -inline int twos_complement(uint32_t v, uint32_t nb) { - int sign = v >> (nb - 1); - int value = v; - if(sign != 0) - value = value - (1 << nb); - return value; -} +#include "selfdrive/common/swaglog.h" -inline int GET_FIELD_S(uint32_t w, uint32_t nb, uint32_t pos) { - int v = GET_FIELD_U(w, nb, pos); - return twos_complement(v, nb); -} +const double gpsPi = 3.1415926535898; +#define UBLOX_MSG_SIZE(hdr) (*(uint16_t *)&hdr[4]) -class EphemerisData { - public: - 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); - int iodc = (GET_FIELD_U(subframes[1][2+0], 2, 6) << 8) | GET_FIELD_U( - subframes[1][2+5], 8, 22); - - int t_oc = GET_FIELD_U(subframes[1][2+5], 16, 6); - int a_f2 = GET_FIELD_S(subframes[1][2+6], 8, 22); - int a_f1 = GET_FIELD_S(subframes[1][2+6], 16, 6); - int a_f0 = GET_FIELD_S(subframes[1][2+7], 22, 8); - - int c_rs = GET_FIELD_S(subframes[2][2+0], 16, 6); - int delta_n = GET_FIELD_S(subframes[2][2+1], 16, 14); - int m_0 = (GET_FIELD_S(subframes[2][2+1], 8, 6) << 24) | GET_FIELD_U( - subframes[2][2+2], 24, 6); - int c_uc = GET_FIELD_S(subframes[2][2+3], 16, 14); - int e = (GET_FIELD_U(subframes[2][2+3], 8, 6) << 24) | GET_FIELD_U(subframes[2][2+4], 24, 6); - int c_us = GET_FIELD_S(subframes[2][2+5], 16, 14); - uint32_t a_powhalf = (GET_FIELD_U(subframes[2][2+5], 8, 6) << 24) | GET_FIELD_U( - subframes[2][2+6], 24, 6); - int t_oe = GET_FIELD_U(subframes[2][2+7], 16, 14); - - int c_ic = GET_FIELD_S(subframes[3][2+0], 16, 14); - int omega_0 = (GET_FIELD_S(subframes[3][2+0], 8, 6) << 24) | GET_FIELD_U( - subframes[3][2+1], 24, 6); - int c_is = GET_FIELD_S(subframes[3][2+2], 16, 14); - int i_0 = (GET_FIELD_S(subframes[3][2+2], 8, 6) << 24) | GET_FIELD_U( - subframes[3][2+3], 24, 6); - int c_rc = GET_FIELD_S(subframes[3][2+4], 16, 14); - int w = (GET_FIELD_S(subframes[3][2+4], 8, 6) << 24) | GET_FIELD_U(subframes[3][5], 24, 6); - int omega_dot = GET_FIELD_S(subframes[3][2+6], 24, 6); - int idot = GET_FIELD_S(subframes[3][2+7], 14, 8); - - this->_rsvd1 = GET_FIELD_U(subframes[1][2+1], 23, 6); - this->_rsvd2 = GET_FIELD_U(subframes[1][2+2], 24, 6); - this->_rsvd3 = GET_FIELD_U(subframes[1][2+3], 24, 6); - this->_rsvd4 = GET_FIELD_U(subframes[1][2+4], 16, 14); - this->aodo = GET_FIELD_U(subframes[2][2+7], 5, 8); - - double gpsPi = 3.1415926535898; - - // now form variables in radians, meters and seconds etc - this->Tgd = t_gd * pow(2, -31); - this->A = pow(a_powhalf * pow(2, -19), 2.0); - this->cic = c_ic * pow(2, -29); - this->cis = c_is * pow(2, -29); - this->crc = c_rc * pow(2, -5); - this->crs = c_rs * pow(2, -5); - this->cuc = c_uc * pow(2, -29); - this->cus = c_us * pow(2, -29); - this->deltaN = delta_n * pow(2, -43) * gpsPi; - this->ecc = e * pow(2, -33); - this->i0 = i_0 * pow(2, -31) * gpsPi; - this->idot = idot * pow(2, -43) * gpsPi; - this->M0 = m_0 * pow(2, -31) * gpsPi; - this->omega = w * pow(2, -31) * gpsPi; - this->omega_dot = omega_dot * pow(2, -43) * gpsPi; - this->omega0 = omega_0 * pow(2, -31) * gpsPi; - this->toe = t_oe * pow(2, 4); - - this->toc = t_oc * pow(2, 4); - this->gpsWeek = week_no; - this->af0 = a_f0 * pow(2, -31); - this->af1 = a_f1 * pow(2, -43); - this->af2 = a_f2 * pow(2, -55); - - uint32_t iode1 = GET_FIELD_U(subframes[2][2+0], 8, 22); - uint32_t iode2 = GET_FIELD_U(subframes[3][2+7], 8, 22); - this->valid = (iode1 == iode2) && (iode1 == (iodc & 0xff)); - this->iode = iode1; - - if (GET_FIELD_U(subframes[4][2+0], 6, 22) == 56 && - GET_FIELD_U(subframes[4][2+0], 2, 28) == 1 && - GET_FIELD_U(subframes[5][2+0], 2, 28) == 1) { - double a0 = GET_FIELD_S(subframes[4][2], 8, 14) * pow(2, -30); - double a1 = GET_FIELD_S(subframes[4][2], 8, 6) * pow(2, -27); - double a2 = GET_FIELD_S(subframes[4][3], 8, 22) * pow(2, -24); - double a3 = GET_FIELD_S(subframes[4][3], 8, 14) * pow(2, -24); - double b0 = GET_FIELD_S(subframes[4][3], 8, 6) * pow(2, 11); - double b1 = GET_FIELD_S(subframes[4][4], 8, 22) * pow(2, 14); - double b2 = GET_FIELD_S(subframes[4][4], 8, 14) * pow(2, 16); - double b3 = GET_FIELD_S(subframes[4][4], 8, 6) * pow(2, 16); - this->ionoAlpha[0] = a0;this->ionoAlpha[1] = a1;this->ionoAlpha[2] = a2;this->ionoAlpha[3] = a3; - this->ionoBeta[0] = b0;this->ionoBeta[1] = b1;this->ionoBeta[2] = b2;this->ionoBeta[3] = b3; - this->ionoCoeffsValid = true; - } else { - this->ionoCoeffsValid = false; - } - } - uint16_t svId; - double Tgd, A, cic, cis, crc, crs, cuc, cus, deltaN, ecc, i0, idot, M0, omega, omega_dot, omega0, toe, toc; - uint32_t gpsWeek, iode, _rsvd1, _rsvd2, _rsvd3, _rsvd4, aodo; - double af0, af1, af2; - bool valid; - double ionoAlpha[4], ionoBeta[4]; - bool ionoCoeffsValid; -}; - -UbloxMsgParser::UbloxMsgParser() :bytes_in_parse_buf(0) { - nav_frame_buffer[0U] = std::map(); - for(int i = 1;i < 33;i++) - nav_frame_buffer[0U][i] = subframes_map(); +inline static bool bit_to_bool(uint8_t val, int shifts) { + return (bool)(val & (1 << shifts)); } inline int UbloxMsgParser::needed_bytes() { // Msg header incomplete? - if(bytes_in_parse_buf < UBLOX_HEADER_SIZE) - return UBLOX_HEADER_SIZE + UBLOX_CHECKSUM_SIZE - bytes_in_parse_buf; - uint16_t needed = UBLOX_MSG_SIZE(msg_parse_buf) + UBLOX_HEADER_SIZE + UBLOX_CHECKSUM_SIZE; + if(bytes_in_parse_buf < ublox::UBLOX_HEADER_SIZE) + return ublox::UBLOX_HEADER_SIZE + ublox::UBLOX_CHECKSUM_SIZE - bytes_in_parse_buf; + uint16_t needed = UBLOX_MSG_SIZE(msg_parse_buf) + ublox::UBLOX_HEADER_SIZE + ublox::UBLOX_CHECKSUM_SIZE; // too much data if(needed < (uint16_t)bytes_in_parse_buf) return -1; @@ -164,212 +32,314 @@ inline int UbloxMsgParser::needed_bytes() { inline bool UbloxMsgParser::valid_cheksum() { uint8_t ck_a = 0, ck_b = 0; - for(int i = 2; i < bytes_in_parse_buf - UBLOX_CHECKSUM_SIZE;i++) { + for(int i = 2; i < bytes_in_parse_buf - ublox::UBLOX_CHECKSUM_SIZE;i++) { ck_a = (ck_a + msg_parse_buf[i]) & 0xFF; ck_b = (ck_b + ck_a) & 0xFF; } if(ck_a != msg_parse_buf[bytes_in_parse_buf - 2]) { - LOGD("Checksum a mismtach: %02X, %02X", ck_a, msg_parse_buf[6]); + LOGD("Checksum a mismatch: %02X, %02X", ck_a, msg_parse_buf[6]); return false; } if(ck_b != msg_parse_buf[bytes_in_parse_buf - 1]) { - LOGD("Checksum b mismtach: %02X, %02X", ck_b, msg_parse_buf[7]); + LOGD("Checksum b mismatch: %02X, %02X", ck_b, msg_parse_buf[7]); return false; } return true; } inline bool UbloxMsgParser::valid() { - return bytes_in_parse_buf >= UBLOX_HEADER_SIZE + UBLOX_CHECKSUM_SIZE && - needed_bytes() == 0 && - valid_cheksum(); + return bytes_in_parse_buf >= ublox::UBLOX_HEADER_SIZE + ublox::UBLOX_CHECKSUM_SIZE && + needed_bytes() == 0 && valid_cheksum(); } inline bool UbloxMsgParser::valid_so_far() { - if(bytes_in_parse_buf > 0 && msg_parse_buf[0] != PREAMBLE1) { - //LOGD("PREAMBLE1 invalid, %02X.", msg_parse_buf[0]); + if(bytes_in_parse_buf > 0 && msg_parse_buf[0] != ublox::PREAMBLE1) { return false; } - if(bytes_in_parse_buf > 1 && msg_parse_buf[1] != PREAMBLE2) { - //LOGD("PREAMBLE2 invalid, %02X.", msg_parse_buf[1]); + if(bytes_in_parse_buf > 1 && msg_parse_buf[1] != ublox::PREAMBLE2) { return false; } - if(needed_bytes() == 0 && !valid()) + if(needed_bytes() == 0 && !valid()) { return false; - return true; -} - -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(); - gpsLoc.setSource(cereal::GpsLocationData::SensorSource::UBLOX); - gpsLoc.setFlags(msg->flags); - gpsLoc.setLatitude(msg->lat * 1e-07); - gpsLoc.setLongitude(msg->lon * 1e-07); - gpsLoc.setAltitude(msg->height * 1e-03); - gpsLoc.setSpeed(msg->gSpeed * 1e-03); - gpsLoc.setBearing(msg->headMot * 1e-5); - gpsLoc.setAccuracy(msg->hAcc * 1e-03); - std::tm timeinfo = std::tm(); - timeinfo.tm_year = msg->year - 1900; - timeinfo.tm_mon = msg->month - 1; - timeinfo.tm_mday = msg->day; - timeinfo.tm_hour = msg->hour; - timeinfo.tm_min = msg->min; - timeinfo.tm_sec = msg->sec; - 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.setVerticalAccuracy(msg->vAcc * 1e-03); - gpsLoc.setSpeedAccuracy(msg->sAcc * 1e-03); - gpsLoc.setBearingAccuracy(msg->headAcc * 1e-05); - return capnp::messageToFlatArray(msg_builder); -} - -inline bool bit_to_bool(uint8_t val, int shifts) { - return (val & (1 << shifts)) ? true : false; -} - -kj::Array UbloxMsgParser::gen_raw() { - rxm_raw_msg *msg = (rxm_raw_msg *)&msg_parse_buf[UBLOX_HEADER_SIZE]; - if(bytes_in_parse_buf != ( - UBLOX_HEADER_SIZE + sizeof(rxm_raw_msg) + msg->numMeas * sizeof(rxm_raw_msg_extra) + UBLOX_CHECKSUM_SIZE - )) { - LOGD("Invalid measurement size %u, %u, %u, %u", msg->numMeas, bytes_in_parse_buf, sizeof(rxm_raw_msg_extra), sizeof(rxm_raw_msg)); - 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(); - mr.setRcvTow(msg->rcvTow); - mr.setGpsWeek(msg->week); - mr.setLeapSeconds(msg->leapS); - mr.setGpsWeek(msg->week); - auto mb = mr.initMeasurements(msg->numMeas); - for(int8_t i = 0; i < msg->numMeas; i++) { - mb[i].setSvId(measurements[i].svId); - mb[i].setSigId(measurements[i].sigId); - mb[i].setPseudorange(measurements[i].prMes); - mb[i].setCarrierCycles(measurements[i].cpMes); - mb[i].setDoppler(measurements[i].doMes); - mb[i].setGnssId(measurements[i].gnssId); - mb[i].setGlonassFrequencyIndex(measurements[i].freqId); - mb[i].setLocktime(measurements[i].locktime); - mb[i].setCno(measurements[i].cno); - mb[i].setPseudorangeStdev(0.01*(pow(2, (measurements[i].prStdev & 15)))); // weird scaling, might be wrong - mb[i].setCarrierPhaseStdev(0.004*(measurements[i].cpStdev & 15)); - mb[i].setDopplerStdev(0.002*(pow(2, (measurements[i].doStdev & 15)))); // weird scaling, might be wrong - auto ts = mb[i].initTrackingStatus(); - ts.setPseudorangeValid(bit_to_bool(measurements[i].trkStat, 0)); - ts.setCarrierPhaseValid(bit_to_bool(measurements[i].trkStat, 1)); - ts.setHalfCycleValid(bit_to_bool(measurements[i].trkStat, 2)); - ts.setHalfCycleSubtracted(bit_to_bool(measurements[i].trkStat, 3)); - } - - mr.setNumMeas(msg->numMeas); - auto rs = mr.initReceiverStatus(); - rs.setLeapSecValid(bit_to_bool(msg->recStat, 0)); - rs.setClkReset(bit_to_bool(msg->recStat, 2)); - return capnp::messageToFlatArray(msg_builder); + return true; } -kj::Array UbloxMsgParser::gen_nav_data() { - rxm_sfrbx_msg *msg = (rxm_sfrbx_msg *)&msg_parse_buf[UBLOX_HEADER_SIZE]; - if(bytes_in_parse_buf != ( - UBLOX_HEADER_SIZE + sizeof(rxm_sfrbx_msg) + msg->numWords * sizeof(rxm_sfrbx_msg_extra) + UBLOX_CHECKSUM_SIZE - )) { - LOGD("Invalid sfrbx words size %u, %u, %u, %u", msg->numWords, bytes_in_parse_buf, sizeof(rxm_raw_msg_extra), sizeof(rxm_raw_msg)); - return kj::Array(); - } - rxm_sfrbx_msg_extra *measurements = (rxm_sfrbx_msg_extra *)&msg_parse_buf[UBLOX_HEADER_SIZE + sizeof(rxm_sfrbx_msg)]; - if(msg->gnssId == 0) { - uint8_t subframeId = GET_FIELD_U(measurements[1].dwrd, 3, 8); - std::vector words; - for(int i = 0; i < msg->numWords;i++) - words.push_back(measurements[i].dwrd); - - if(subframeId == 1) { - nav_frame_buffer[msg->gnssId][msg->svid] = subframes_map(); - nav_frame_buffer[msg->gnssId][msg->svid][subframeId] = words; - } else if(nav_frame_buffer[msg->gnssId][msg->svid].find(subframeId-1) != nav_frame_buffer[msg->gnssId][msg->svid].end()) - 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(); - eph.setSvId(ephem_data.svId); - eph.setToc(ephem_data.toc); - eph.setGpsWeek(ephem_data.gpsWeek); - eph.setAf0(ephem_data.af0); - eph.setAf1(ephem_data.af1); - eph.setAf2(ephem_data.af2); - eph.setIode(ephem_data.iode); - eph.setCrs(ephem_data.crs); - eph.setDeltaN(ephem_data.deltaN); - eph.setM0(ephem_data.M0); - eph.setCuc(ephem_data.cuc); - eph.setEcc(ephem_data.ecc); - eph.setCus(ephem_data.cus); - eph.setA(ephem_data.A); - eph.setToe(ephem_data.toe); - eph.setCic(ephem_data.cic); - eph.setOmega0(ephem_data.omega0); - eph.setCis(ephem_data.cis); - eph.setI0(ephem_data.i0); - eph.setCrc(ephem_data.crc); - eph.setOmega(ephem_data.omega); - eph.setOmegaDot(ephem_data.omega_dot); - eph.setIDot(ephem_data.idot); - 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); - } else { - eph.setIonoAlpha(kj::ArrayPtr()); - eph.setIonoBeta(kj::ArrayPtr()); - } - return capnp::messageToFlatArray(msg_builder); - } - } - return kj::Array(); -} 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) { - bytes_consumed = min((size_t)needed, incoming_data_len ); + bytes_consumed = std::min((uint32_t)needed, incoming_data_len ); // Add data to buffer memcpy(msg_parse_buf + bytes_in_parse_buf, incoming_data, bytes_consumed); bytes_in_parse_buf += bytes_consumed; } else { bytes_consumed = incoming_data_len; } + // Validate msg format, detect invalid header and invalid checksum. while(!valid_so_far() && bytes_in_parse_buf != 0) { - //LOGD("Drop corrupt data, remained in buf: %u", bytes_in_parse_buf); // Corrupted msg, drop a byte. bytes_in_parse_buf -= 1; if(bytes_in_parse_buf > 0) memmove(&msg_parse_buf[0], &msg_parse_buf[1], bytes_in_parse_buf); } + // There is redundant data at the end of buffer, reset the buffer. - if(needed_bytes() == -1) + if(needed_bytes() == -1) { bytes_in_parse_buf = 0; + } return valid(); } + +std::pair> UbloxMsgParser::gen_msg() { + std::string dat = data(); + kaitai::kstream stream(dat); + + ubx_t ubx_message(&stream); + auto body = ubx_message.body(); + + switch (ubx_message.msg_type()) { + case 0x0107: + return {"gpsLocationExternal", gen_nav_pvt(static_cast(body))}; + break; + case 0x0213: + return {"ubloxGnss", gen_rxm_sfrbx(static_cast(body))}; + break; + case 0x0215: + return {"ubloxGnss", gen_rxm_rawx(static_cast(body))}; + break; + case 0x0a09: + return {"ubloxGnss", gen_mon_hw(static_cast(body))}; + break; + case 0x0a0b: + return {"ubloxGnss", gen_mon_hw2(static_cast(body))}; + break; + default: + LOGE("Unknown message type %x", ubx_message.msg_type()); + return {"ubloxGnss", kj::Array()}; + break; + } +} + + +kj::Array UbloxMsgParser::gen_nav_pvt(ubx_t::nav_pvt_t *msg) { + 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); + gpsLoc.setLongitude(msg->lon() * 1e-07); + gpsLoc.setAltitude(msg->height() * 1e-03); + gpsLoc.setSpeed(msg->g_speed() * 1e-03); + gpsLoc.setBearingDeg(msg->head_mot() * 1e-5); + gpsLoc.setAccuracy(msg->h_acc() * 1e-03); + std::tm timeinfo = std::tm(); + timeinfo.tm_year = msg->year() - 1900; + timeinfo.tm_mon = msg->month() - 1; + timeinfo.tm_mday = msg->day(); + timeinfo.tm_hour = msg->hour(); + timeinfo.tm_min = msg->min(); + timeinfo.tm_sec = msg->sec(); + + std::time_t utc_tt = timegm(&timeinfo); + gpsLoc.setTimestamp(utc_tt * 1e+03 + msg->nano() * 1e-06); + float f[] = { msg->vel_n() * 1e-03f, msg->vel_e() * 1e-03f, msg->vel_d() * 1e-03f }; + gpsLoc.setVNED(f); + gpsLoc.setVerticalAccuracy(msg->v_acc() * 1e-03); + gpsLoc.setSpeedAccuracy(msg->s_acc() * 1e-03); + gpsLoc.setBearingAccuracyDeg(msg->head_acc() * 1e-05); + return capnp::messageToFlatArray(msg_builder); +} + + +kj::Array UbloxMsgParser::gen_rxm_sfrbx(ubx_t::rxm_sfrbx_t *msg) { + auto body = *msg->body(); + + if (msg->gnss_id() == ubx_t::gnss_type_t::GNSS_TYPE_GPS) { + // GPS subframes are packed into 10x 4 bytes, each containing 3 actual bytes + // We will first need to separate the data from the padding and parity + assert(body.size() == 10); + + std::string subframe_data; + subframe_data.reserve(30); + for (uint32_t word : body) { + word = word >> 6; // TODO: Verify parity + subframe_data.push_back(word >> 16); + subframe_data.push_back(word >> 8); + subframe_data.push_back(word >> 0); + } + + // Collect subframes in map and parse when we have all the parts + { + kaitai::kstream stream(subframe_data); + gps_t subframe(&stream); + int subframe_id = subframe.how()->subframe_id(); + + if (subframe_id == 1) gps_subframes[msg->sv_id()].clear(); + gps_subframes[msg->sv_id()][subframe_id] = subframe_data; + } + + if (gps_subframes[msg->sv_id()].size() == 5) { + MessageBuilder msg_builder; + auto eph = msg_builder.initEvent().initUbloxGnss().initEphemeris(); + eph.setSvId(msg->sv_id()); + + // Subframe 1 + { + kaitai::kstream stream(gps_subframes[msg->sv_id()][1]); + gps_t subframe(&stream); + gps_t::subframe_1_t* subframe_1 = static_cast(subframe.body()); + + eph.setGpsWeek(subframe_1->week_no()); + eph.setTgd(subframe_1->t_gd() * pow(2, -31)); + eph.setToc(subframe_1->t_oc() * pow(2, 4)); + eph.setAf2(subframe_1->af_2() * pow(2, -55)); + eph.setAf1(subframe_1->af_1() * pow(2, -43)); + eph.setAf0(subframe_1->af_0() * pow(2, -31)); + } + + // Subframe 2 + { + kaitai::kstream stream(gps_subframes[msg->sv_id()][2]); + gps_t subframe(&stream); + gps_t::subframe_2_t* subframe_2 = static_cast(subframe.body()); + + eph.setCrs(subframe_2->c_rs() * pow(2, -5)); + eph.setDeltaN(subframe_2->delta_n() * pow(2, -43) * gpsPi); + eph.setM0(subframe_2->m_0() * pow(2, -31) * gpsPi); + eph.setCuc(subframe_2->c_uc() * pow(2, -29)); + eph.setEcc(subframe_2->e() * pow(2, -33)); + eph.setCus(subframe_2->c_us() * pow(2, -29)); + eph.setA(pow(subframe_2->sqrt_a() * pow(2, -19), 2.0)); + eph.setToe(subframe_2->t_oe() * pow(2, 4)); + } + + // Subframe 3 + { + kaitai::kstream stream(gps_subframes[msg->sv_id()][3]); + gps_t subframe(&stream); + gps_t::subframe_3_t* subframe_3 = static_cast(subframe.body()); + + eph.setCic(subframe_3->c_ic() * pow(2, -29)); + eph.setOmega0(subframe_3->omega_0() * pow(2, -31) * gpsPi); + eph.setCis(subframe_3->c_is() * pow(2, -29)); + eph.setI0(subframe_3->i_0() * pow(2, -31) * gpsPi); + eph.setCrc(subframe_3->c_rc() * pow(2, -5)); + eph.setOmega(subframe_3->omega() * pow(2, -31) * gpsPi); + eph.setOmegaDot(subframe_3->omega_dot() * pow(2, -43) * gpsPi); + eph.setIode(subframe_3->iode()); + eph.setIDot(subframe_3->idot() * pow(2, -43) * gpsPi); + } + + // Subframe 4 + { + kaitai::kstream stream(gps_subframes[msg->sv_id()][4]); + gps_t subframe(&stream); + gps_t::subframe_4_t* subframe_4 = static_cast(subframe.body()); + + // This is page 18, why is the page id 56? + if (subframe_4->data_id() == 1 && subframe_4->page_id() == 56) { + auto iono = static_cast(subframe_4->body()); + double a0 = iono->a0() * pow(2, -30); + double a1 = iono->a1() * pow(2, -27); + double a2 = iono->a2() * pow(2, -24); + double a3 = iono->a3() * pow(2, -24); + eph.setIonoAlpha({a0, a1, a2, a3}); + + double b0 = iono->b0() * pow(2, 11); + double b1 = iono->b1() * pow(2, 14); + double b2 = iono->b2() * pow(2, 16); + double b3 = iono->b3() * pow(2, 16); + eph.setIonoBeta({b0, b1, b2, b3}); + } + } + + return capnp::messageToFlatArray(msg_builder); + } + } + return kj::Array(); +} + +kj::Array UbloxMsgParser::gen_rxm_rawx(ubx_t::rxm_rawx_t *msg) { + MessageBuilder msg_builder; + auto mr = msg_builder.initEvent().initUbloxGnss().initMeasurementReport(); + mr.setRcvTow(msg->rcv_tow()); + mr.setGpsWeek(msg->week()); + mr.setLeapSeconds(msg->leap_s()); + mr.setGpsWeek(msg->week()); + + auto mb = mr.initMeasurements(msg->num_meas()); + auto measurements = *msg->measurements(); + for(int8_t i = 0; i < msg->num_meas(); i++) { + mb[i].setSvId(measurements[i]->sv_id()); + mb[i].setPseudorange(measurements[i]->pr_mes()); + mb[i].setCarrierCycles(measurements[i]->cp_mes()); + mb[i].setDoppler(measurements[i]->do_mes()); + mb[i].setGnssId(measurements[i]->gnss_id()); + mb[i].setGlonassFrequencyIndex(measurements[i]->freq_id()); + mb[i].setLocktime(measurements[i]->lock_time()); + mb[i].setCno(measurements[i]->cno()); + mb[i].setPseudorangeStdev(0.01 * (pow(2, (measurements[i]->pr_stdev() & 15)))); // weird scaling, might be wrong + mb[i].setCarrierPhaseStdev(0.004 * (measurements[i]->cp_stdev() & 15)); + mb[i].setDopplerStdev(0.002 * (pow(2, (measurements[i]->do_stdev() & 15)))); // weird scaling, might be wrong + + auto ts = mb[i].initTrackingStatus(); + auto trk_stat = measurements[i]->trk_stat(); + ts.setPseudorangeValid(bit_to_bool(trk_stat, 0)); + ts.setCarrierPhaseValid(bit_to_bool(trk_stat, 1)); + ts.setHalfCycleValid(bit_to_bool(trk_stat, 2)); + ts.setHalfCycleSubtracted(bit_to_bool(trk_stat, 3)); + } + + mr.setNumMeas(msg->num_meas()); + auto rs = mr.initReceiverStatus(); + rs.setLeapSecValid(bit_to_bool(msg->rec_stat(), 0)); + rs.setClkReset(bit_to_bool(msg->rec_stat(), 2)); + return capnp::messageToFlatArray(msg_builder); +} + +kj::Array UbloxMsgParser::gen_mon_hw(ubx_t::mon_hw_t *msg) { + MessageBuilder msg_builder; + auto hwStatus = msg_builder.initEvent().initUbloxGnss().initHwStatus(); + hwStatus.setNoisePerMS(msg->noise_per_ms()); + hwStatus.setFlags(msg->flags()); + hwStatus.setAgcCnt(msg->agc_cnt()); + hwStatus.setAStatus((cereal::UbloxGnss::HwStatus::AntennaSupervisorState) msg->a_status()); + hwStatus.setAPower((cereal::UbloxGnss::HwStatus::AntennaPowerStatus) msg->a_power()); + hwStatus.setJamInd(msg->jam_ind()); + return capnp::messageToFlatArray(msg_builder); +} + +kj::Array UbloxMsgParser::gen_mon_hw2(ubx_t::mon_hw2_t *msg) { + MessageBuilder msg_builder; + auto hwStatus = msg_builder.initEvent().initUbloxGnss().initHwStatus2(); + hwStatus.setOfsI(msg->ofs_i()); + hwStatus.setMagI(msg->mag_i()); + hwStatus.setOfsQ(msg->ofs_q()); + hwStatus.setMagQ(msg->mag_q()); + + switch (msg->cfg_source()) { + case ubx_t::mon_hw2_t::config_source_t::CONFIG_SOURCE_ROM: + hwStatus.setCfgSource(cereal::UbloxGnss::HwStatus2::ConfigSource::ROM); + break; + case ubx_t::mon_hw2_t::config_source_t::CONFIG_SOURCE_OTP: + hwStatus.setCfgSource(cereal::UbloxGnss::HwStatus2::ConfigSource::OTP); + break; + case ubx_t::mon_hw2_t::config_source_t::CONFIG_SOURCE_CONFIG_PINS: + hwStatus.setCfgSource(cereal::UbloxGnss::HwStatus2::ConfigSource::CONFIGPINS); + break; + case ubx_t::mon_hw2_t::config_source_t::CONFIG_SOURCE_FLASH: + hwStatus.setCfgSource(cereal::UbloxGnss::HwStatus2::ConfigSource::FLASH); + break; + default: + hwStatus.setCfgSource(cereal::UbloxGnss::HwStatus2::ConfigSource::UNDEFINED); + break; + } + + hwStatus.setLowLevCfg(msg->low_lev_cfg()); + hwStatus.setPostStatus(msg->post_status()); + + return capnp::messageToFlatArray(msg_builder); } diff --git a/selfdrive/locationd/ublox_msg.h b/selfdrive/locationd/ublox_msg.h index c7860f14cf4e5a..b8a48ad2da6636 100644 --- a/selfdrive/locationd/ublox_msg.h +++ b/selfdrive/locationd/ublox_msg.h @@ -1,149 +1,116 @@ #pragma once -#include - -#define min(x, y) ((x) <= (y) ? (x) : (y)) - -// NAV_PVT -typedef struct __attribute__((packed)) { - uint32_t iTOW; - uint16_t year; - int8_t month; - int8_t day; - int8_t hour; - int8_t min; - int8_t sec; - int8_t valid; - uint32_t tAcc; - int32_t nano; - int8_t fixType; - int8_t flags; - int8_t flags2; - int8_t numSV; - int32_t lon; - int32_t lat; - int32_t height; - int32_t hMSL; - uint32_t hAcc; - uint32_t vAcc; - int32_t velN; - int32_t velE; - int32_t velD; - int32_t gSpeed; - int32_t headMot; - uint32_t sAcc; - uint32_t headAcc; - uint16_t pDOP; - int8_t reserverd1[6]; - int32_t headVeh; - int16_t magDec; - uint16_t magAcc; -} nav_pvt_msg; - -// RXM_RAW -typedef struct __attribute__((packed)) { - double rcvTow; - uint16_t week; - int8_t leapS; - int8_t numMeas; - int8_t recStat; - int8_t reserved1[3]; -} rxm_raw_msg; - -// Extra data count is in numMeas -typedef struct __attribute__((packed)) { - double prMes; - double cpMes; - float doMes; - int8_t gnssId; - int8_t svId; - int8_t sigId; - int8_t freqId; - uint16_t locktime; - int8_t cno; - int8_t prStdev; - int8_t cpStdev; - int8_t doStdev; - int8_t trkStat; - int8_t reserved3; -} rxm_raw_msg_extra; -// RXM_SFRBX -typedef struct __attribute__((packed)) { - int8_t gnssId; - int8_t svid; - int8_t reserved1; - int8_t freqId; - int8_t numWords; - int8_t reserved2; - int8_t version; - int8_t reserved3; -} rxm_sfrbx_msg; - -// Extra data count is in numWords -typedef struct __attribute__((packed)) { - uint32_t dwrd; -} rxm_sfrbx_msg_extra; +#include +#include +#include +#include +#include +#include +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/util.h" +#include "selfdrive/locationd/generated/gps.h" +#include "selfdrive/locationd/generated/ubx.h" + +using namespace std::string_literals; + +// protocol constants namespace ublox { - // protocol constants const uint8_t PREAMBLE1 = 0xb5; const uint8_t PREAMBLE2 = 0x62; - // message classes + const int UBLOX_HEADER_SIZE = 6; + const int UBLOX_CHECKSUM_SIZE = 2; + const int UBLOX_MAX_MSG_SIZE = 65536; + + // Boardd still uses these: const uint8_t CLASS_NAV = 0x01; const uint8_t CLASS_RXM = 0x02; + const uint8_t CLASS_MON = 0x0A; + + struct ubx_mga_ini_time_utc_t { + uint8_t type; + uint8_t version; + uint8_t ref; + int8_t leapSecs; + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; + uint8_t reserved1; + uint32_t ns; + uint16_t tAccS; + uint16_t reserved2; + uint32_t tAccNs; + } __attribute__((packed)); + + inline std::string ubx_add_checksum(const std::string &msg) { + assert(msg.size() > 2); + + uint8_t ck_a = 0, ck_b = 0; + for(int i = 2; i < msg.size(); i++) { + ck_a = (ck_a + msg[i]) & 0xFF; + ck_b = (ck_b + ck_a) & 0xFF; + } + + std::string r = msg; + r.push_back(ck_a); + r.push_back(ck_b); + return r; + } + + inline std::string build_ubx_mga_ini_time_utc(struct tm time) { + ublox::ubx_mga_ini_time_utc_t payload = { + .type = 0x10, + .version = 0x0, + .ref = 0x0, + .leapSecs = -128, // Unknown + .year = (uint16_t)(1900 + time.tm_year), + .month = (uint8_t)(1 + time.tm_mon), + .day = (uint8_t)time.tm_mday, + .hour = (uint8_t)time.tm_hour, + .minute = (uint8_t)time.tm_min, + .second = (uint8_t)time.tm_sec, + .reserved1 = 0x0, + .ns = 0, + .tAccS = 30, + .reserved2 = 0x0, + .tAccNs = 0, + }; + assert(sizeof(payload) == 24); + + std::string msg = "\xb5\x62\x13\x40\x18\x00"s; + msg += std::string((char*)&payload, sizeof(payload)); + + return ubx_add_checksum(msg); + } +} - // NAV messages - const uint8_t MSG_NAV_PVT = 0x7; +class UbloxMsgParser { + public: + bool add_data(const uint8_t *incoming_data, uint32_t incoming_data_len, size_t &bytes_consumed); + inline void reset() {bytes_in_parse_buf = 0;} + inline int needed_bytes(); + inline std::string data() {return std::string((const char*)msg_parse_buf, bytes_in_parse_buf);} - // RXM messages - const uint8_t MSG_RXM_RAW = 0x15; - const uint8_t MSG_RXM_SFRBX = 0x13; + std::pair> gen_msg(); + kj::Array gen_nav_pvt(ubx_t::nav_pvt_t *msg); + kj::Array gen_rxm_sfrbx(ubx_t::rxm_sfrbx_t *msg); + kj::Array gen_rxm_rawx(ubx_t::rxm_rawx_t *msg); + kj::Array gen_mon_hw(ubx_t::mon_hw_t *msg); + kj::Array gen_mon_hw2(ubx_t::mon_hw2_t *msg); - const int UBLOX_HEADER_SIZE = 6; - const int UBLOX_CHECKSUM_SIZE = 2; - const int UBLOX_MAX_MSG_SIZE = 65536; + private: + inline bool valid_cheksum(); + inline bool valid(); + inline bool valid_so_far(); - typedef std::map> subframes_map; - - class UbloxMsgParser { - public: - - UbloxMsgParser(); - kj::Array gen_solution(); - kj::Array gen_raw(); - - kj::Array gen_nav_data(); - bool add_data(const uint8_t *incoming_data, uint32_t incoming_data_len, size_t &bytes_consumed); - inline void reset() {bytes_in_parse_buf = 0;} - inline uint8_t msg_class() { - return msg_parse_buf[2]; - } - - inline uint8_t msg_id() { - return msg_parse_buf[3]; - } - inline int needed_bytes(); - - 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"); - } - private: - inline bool valid_cheksum(); - inline bool valid(); - inline bool valid_so_far(); - - uint8_t msg_parse_buf[UBLOX_HEADER_SIZE + UBLOX_MAX_MSG_SIZE]; - int bytes_in_parse_buf; - std::map> nav_frame_buffer; - }; + std::unordered_map> gps_subframes; -} + size_t bytes_in_parse_buf = 0; + uint8_t msg_parse_buf[ublox::UBLOX_HEADER_SIZE + ublox::UBLOX_MAX_MSG_SIZE]; + +}; -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); -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..ae07284c8ee36d 100644 --- a/selfdrive/locationd/ubloxd.cc +++ b/selfdrive/locationd/ubloxd.cc @@ -1,45 +1,64 @@ -#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" - -#include "ublox_msg.h" - -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); -} +#include -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); -} +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/locationd/ublox_msg.h" + +ExitHandler do_exit; +using namespace ublox; int main() { - return ubloxd_main(poll_ubloxraw_msg, send_gps_event); + LOGW("starting ubloxd"); + AlignedBuffer aligned_buf; + UbloxMsgParser parser; + + PubMaster pm({"ubloxGnss", "gpsLocationExternal"}); + + std::unique_ptr context(Context::create()); + std::unique_ptr subscriber(SubSocket::create(context.get(), "ubloxRaw")); + assert(subscriber != NULL); + subscriber->setTimeout(100); + + + while (!do_exit) { + std::unique_ptr msg(subscriber->receive()); + if (!msg) { + if (errno == EINTR) { + do_exit = true; + } + continue; + } + + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(msg.get())); + 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)) { + + try { + auto ublox_msg = parser.gen_msg(); + if (ublox_msg.second.size() > 0) { + auto bytes = ublox_msg.second.asBytes(); + pm.send(ublox_msg.first.c_str(), bytes.begin(), bytes.size()); + } + } catch (const std::exception& e) { + LOGE("Error parsing ublox message %s", e.what()); + } + + parser.reset(); + } + bytes_consumed += bytes_consumed_this_time; + } + } + + return 0; } diff --git a/selfdrive/locationd/ubloxd_main.cc b/selfdrive/locationd/ubloxd_main.cc deleted file mode 100644 index 3ea080ad9d9da9..00000000000000 --- a/selfdrive/locationd/ubloxd_main.cc +++ /dev/null @@ -1,113 +0,0 @@ -#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" - -#include "ublox_msg.h" - -volatile int 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); - - 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; -} diff --git a/selfdrive/locationd/ubloxd_test.cc b/selfdrive/locationd/ubloxd_test.cc deleted file mode 100644 index a1395fa5960d13..00000000000000 --- a/selfdrive/locationd/ubloxd_test.cc +++ /dev/null @@ -1,103 +0,0 @@ -#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" -#include "common/util.h" -#include "ublox_msg.h" - -using namespace ublox; - -void write_file(std::string fpath, uint8_t *data, int len) { - FILE* f = fopen(fpath.c_str(), "wb"); - if (!f) { - std::cout << "Open " << fpath << " failed" << std::endl; - return; - } - fwrite(data, len, 1, f); - fclose(f); -} - -static size_t len = 0U; -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; - 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); - 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()); - consumed += consuming; - return 1; - } else - return -1; -} - -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 main(int argc, char** argv) { - if(argc < 3) { - printf("Format: ubloxd_test stream_file_path save_prefix\n"); - return 0; - } - // Parse 11360 msgs, generate 9452 events - data = (uint8_t *)read_file(argv[1], &len); - if(data == NULL) { - LOGE("Read file %s failed\n", argv[1]); - return -1; - } - prefix = argv[2]; - ubloxd_main(poll_ubloxraw_msg, send_gps_event); - free(data); - printf("Generated %d cereal events\n", save_idx); - if(save_idx != 9452) { - printf("Event count error: %d\n", save_idx); - return -1; - } - return 0; -} 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..8811f32fe65118 --- /dev/null +++ b/selfdrive/logcatd/SConscript @@ -0,0 +1,6 @@ +Import('env', 'cereal', 'messaging', 'common', 'arch') + +if arch == "aarch64": + env.Program('logcatd', 'logcatd_android.cc', LIBS=[cereal, messaging, common, 'cutils', 'zmq', 'capnp', 'kj']) +else: + env.Program('logcatd', 'logcatd_systemd.cc', LIBS=[cereal, messaging, common, '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..1a982a0feb48d7 --- /dev/null +++ b/selfdrive/logcatd/logcatd_android.cc @@ -0,0 +1,72 @@ +#include +#include + +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/util.h" + +int main() { + setpriority(PRIO_PROCESS, 0, -15); + + ExitHandler do_exit; + PubMaster pm({"androidLog"}); + + log_time last_log_time = {}; + logger_list *logger_list = android_logger_list_alloc(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 0, 0); + + while (!do_exit) { + // setup android logging + if (!logger_list) { + logger_list = android_logger_list_alloc_time(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, last_log_time, 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); + + while (!do_exit) { + log_msg log_msg; + int 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; + last_log_time.tv_sec = entry.tv_sec; + last_log_time.tv_nsec = entry.tv_nsec; + + 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_free(logger_list); + logger_list = NULL; + util::sleep_for(500); + } + + if (logger_list) { + android_logger_list_free(logger_list); + } + + return 0; +} diff --git a/selfdrive/logcatd/logcatd_systemd.cc b/selfdrive/logcatd/logcatd_systemd.cc new file mode 100644 index 00000000000000..7c7800dfea9347 --- /dev/null +++ b/selfdrive/logcatd/logcatd_systemd.cc @@ -0,0 +1,71 @@ +#include + +#include +#include +#include +#include + +#include "json11.hpp" + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" + +ExitHandler do_exit; +int main(int argc, char *argv[]) { + + PubMaster pm({"androidLog"}); + + sd_journal *journal; + int err = sd_journal_open(&journal, 0); + assert(err >= 0); + err = sd_journal_get_fd(journal); // needed so sd_journal_wait() works properly if files rotate + assert(err >= 0); + err = sd_journal_seek_tail(journal); + assert(err >= 0); + + while (!do_exit) { + err = sd_journal_next(journal); + assert(err >= 0); + + // Wait for new message if we didn't receive anything + if (err == 0) { + err = sd_journal_wait(journal, 1000 * 1000); + assert (err >= 0); + continue; // Try again + } + + uint64_t timestamp = 0; + err = sd_journal_get_realtime_usec(journal, ×tamp); + assert(err >= 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..2adcfb846cf1e5 --- /dev/null +++ b/selfdrive/loggerd/SConscript @@ -0,0 +1,31 @@ +Import('env', 'arch', 'cereal', 'messaging', 'common', 'visionipc', 'gpucommon') + + +logger_lib = env.Library('logger', ["logger.cc"]) +libs = [logger_lib, common, cereal, messaging, visionipc, + 'zmq', 'capnp', 'kj', 'z', + 'avformat', 'avcodec', 'swscale', 'avutil', + 'yuv', 'bz2', 'OpenCL'] + +src = ['loggerd.cc'] +if arch in ["aarch64", "larch64"]: + src += ['omx_encoder.cc'] + libs += ['OmxCore', 'gsl', 'CB'] + gpucommon + if arch == "aarch64": + libs += ['OmxVenc', 'cutils'] + else: + libs += ['pthread'] +else: + src += ['raw_logger.cc'] + libs += ['pthread'] + +if arch == "Darwin": + # fix OpenCL + del libs[libs.index('OpenCL')] + env['FRAMEWORKS'] = ['OpenCL'] + +env.Program('loggerd', ['main.cc'] + src, LIBS=libs) +env.Program('bootlog.cc', LIBS=libs) + +if GetOption('test'): + env.Program('tests/test_logger', ['tests/test_runner.cc', 'tests/test_loggerd.cc', 'tests/test_logger.cc', env.Object('logger_util', '#/selfdrive/ui/replay/util.cc')] + src, LIBS=[libs] + ['curl', 'crypto', 'bz2']) diff --git a/selfdrive/loggerd/bootlog.cc b/selfdrive/loggerd/bootlog.cc new file mode 100644 index 00000000000000..52099583775c12 --- /dev/null +++ b/selfdrive/loggerd/bootlog.cc @@ -0,0 +1,77 @@ +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/loggerd/logger.h" + + +static kj::Array build_boot_log() { + std::vector bootlog_commands; + if (Hardware::TICI()) { + bootlog_commands.push_back("journalctl"); + bootlog_commands.push_back("sudo nvme smart-log --output-format=json /dev/nvme0"); + } + + MessageBuilder msg; + auto boot = msg.initEvent().initBoot(); + + boot.setWallTimeNanos(nanos_since_epoch()); + + std::string pstore = "/sys/fs/pstore"; + std::map pstore_map = util::read_files_in_dir(pstore); + + const std::vector log_keywords = {"Kernel panic"}; + auto lpstore = boot.initPstore().initEntries(pstore_map.size()); + int i = 0; + for (auto& kv : pstore_map) { + auto lentry = lpstore[i]; + lentry.setKey(kv.first); + lentry.setValue(capnp::Data::Reader((const kj::byte*)kv.second.data(), kv.second.size())); + i++; + + for (auto &k : log_keywords) { + if (kv.second.find(k) != std::string::npos) { + LOGE("%s: found '%s'", kv.first.c_str(), k.c_str()); + } + } + } + + // Gather output of commands + i = 0; + auto commands = boot.initCommands().initEntries(bootlog_commands.size()); + for (auto &command : bootlog_commands) { + auto lentry = commands[i]; + + lentry.setKey(command); + + const std::string result = util::check_output(command); + lentry.setValue(capnp::Data::Reader((const kj::byte*)result.data(), result.size())); + + i++; + } + + boot.setLaunchLog(util::read_file("/tmp/launch_log")); + return capnp::messageToFlatArray(msg); +} + +int main(int argc, char** argv) { + clear_locks(LOG_ROOT); + + const std::string path = LOG_ROOT + "/boot/" + logger_get_route_name() + ".bz2"; + LOGW("bootlog to %s", path.c_str()); + + // Open bootlog + bool r = util::create_directories(LOG_ROOT + "/boot/", 0775); + assert(r); + + BZFile bz_file(path.c_str()); + + // Write initdata + bz_file.write(logger_build_init_data().asBytes()); + + // Write bootlog + bz_file.write(build_boot_log().asBytes()); + + return 0; +} 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..b626073ce41b7d 100644 --- a/selfdrive/loggerd/config.py +++ b/selfdrive/loggerd/config.py @@ -1,19 +1,34 @@ import os +from pathlib import Path +from selfdrive.hardware import PC -if os.environ.get('LOGGERD_ROOT', False): - ROOT = os.environ['LOGGERD_ROOT'] - print("Custom loggerd root: ", ROOT) +if os.environ.get('LOG_ROOT', False): + ROOT = os.environ['LOG_ROOT'] +elif PC: + ROOT = os.path.join(str(Path.home()), ".comma", "media", "0", "realdata") 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..16083ec921674a 100644 --- a/selfdrive/loggerd/deleter.py +++ b/selfdrive/loggerd/deleter.py @@ -1,19 +1,25 @@ -#!/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 + +DELETE_LAST = ['boot', 'crash'] 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 = sorted(listdir_by_creation(ROOT), key=lambda x: x in DELETE_LAST) for delete_dir in dirs: delete_path = os.path.join(ROOT, delete_dir) @@ -31,7 +37,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 deleted file mode 100644 index 1b85ad263deb9d..00000000000000 --- a/selfdrive/loggerd/encoder.c +++ /dev/null @@ -1,714 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include "common/mutex.h" -#include "common/swaglog.h" - -#include "encoder.h" - -#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) { - pthread_cond_wait(&s->state_cv, &s->state_lock); - } - pthread_mutex_unlock(&s->state_lock); -} - -static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_EVENTTYPE event, - OMX_U32 data1, OMX_U32 data2, OMX_PTR event_data) { - EncoderState *s = app_data; - - switch (event) { - case OMX_EventCmdComplete: - assert(data1 == OMX_CommandStateSet); - LOG("set state event 0x%x", data2); - pthread_mutex_lock(&s->state_lock); - s->state = data2; - pthread_cond_broadcast(&s->state_cv); - pthread_mutex_unlock(&s->state_lock); - break; - case OMX_EventError: - LOGE("OMX error 0x%08x", data1); - // assert(false); - break; - default: - LOGE("unhandled event %d", event); - assert(false); - break; - } - - pthread_mutex_unlock(&s->state_lock); - - return OMX_ErrorNone; -} - -static OMX_ERRORTYPE empty_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, - OMX_BUFFERHEADERTYPE *buffer) { - EncoderState *s = app_data; - - // printf("empty_buffer_done\n"); - - queue_push(&s->free_in, (void*)buffer); - - return OMX_ErrorNone; -} - - -static OMX_ERRORTYPE fill_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, - OMX_BUFFERHEADERTYPE *buffer) { - EncoderState *s = app_data; - - // printf("fill_buffer_done\n"); - - queue_push(&s->done_out, (void*)buffer); - - return OMX_ErrorNone; -} - -static OMX_CALLBACKTYPE omx_callbacks = { - .EventHandler = event_handler, - .EmptyBufferDone = empty_buffer_done, - .FillBufferDone = fill_buffer_done, -}; - -#define PORT_INDEX_IN 0 -#define PORT_INDEX_OUT 1 - -static const char* omx_color_fomat_name(uint32_t format) { - switch (format) { - case OMX_COLOR_FormatUnused: return "OMX_COLOR_FormatUnused"; - case OMX_COLOR_FormatMonochrome: return "OMX_COLOR_FormatMonochrome"; - case OMX_COLOR_Format8bitRGB332: return "OMX_COLOR_Format8bitRGB332"; - case OMX_COLOR_Format12bitRGB444: return "OMX_COLOR_Format12bitRGB444"; - case OMX_COLOR_Format16bitARGB4444: return "OMX_COLOR_Format16bitARGB4444"; - case OMX_COLOR_Format16bitARGB1555: return "OMX_COLOR_Format16bitARGB1555"; - case OMX_COLOR_Format16bitRGB565: return "OMX_COLOR_Format16bitRGB565"; - 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_Format24bitRGB888: return "OMX_COLOR_Format24bitRGB888"; - case OMX_COLOR_Format24bitBGR888: return "OMX_COLOR_Format24bitBGR888"; - case OMX_COLOR_Format24bitARGB1887: return "OMX_COLOR_Format24bitARGB1887"; - case OMX_COLOR_Format25bitARGB1888: return "OMX_COLOR_Format25bitARGB1888"; - case OMX_COLOR_Format32bitBGRA8888: return "OMX_COLOR_Format32bitBGRA8888"; - case OMX_COLOR_Format32bitARGB8888: return "OMX_COLOR_Format32bitARGB8888"; - case OMX_COLOR_FormatYUV411Planar: return "OMX_COLOR_FormatYUV411Planar"; - case OMX_COLOR_FormatYUV411PackedPlanar: return "OMX_COLOR_FormatYUV411PackedPlanar"; - case OMX_COLOR_FormatYUV420Planar: return "OMX_COLOR_FormatYUV420Planar"; - case OMX_COLOR_FormatYUV420PackedPlanar: return "OMX_COLOR_FormatYUV420PackedPlanar"; - case OMX_COLOR_FormatYUV420SemiPlanar: return "OMX_COLOR_FormatYUV420SemiPlanar"; - case OMX_COLOR_FormatYUV422Planar: return "OMX_COLOR_FormatYUV422Planar"; - case OMX_COLOR_FormatYUV422PackedPlanar: return "OMX_COLOR_FormatYUV422PackedPlanar"; - case OMX_COLOR_FormatYUV422SemiPlanar: return "OMX_COLOR_FormatYUV422SemiPlanar"; - case OMX_COLOR_FormatYCbYCr: return "OMX_COLOR_FormatYCbYCr"; - case OMX_COLOR_FormatYCrYCb: return "OMX_COLOR_FormatYCrYCb"; - case OMX_COLOR_FormatCbYCrY: return "OMX_COLOR_FormatCbYCrY"; - case OMX_COLOR_FormatCrYCbY: return "OMX_COLOR_FormatCrYCbY"; - case OMX_COLOR_FormatYUV444Interleaved: return "OMX_COLOR_FormatYUV444Interleaved"; - 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_FormatL32: return "OMX_COLOR_FormatL32"; - case OMX_COLOR_FormatYUV420PackedSemiPlanar: return "OMX_COLOR_FormatYUV420PackedSemiPlanar"; - case OMX_COLOR_FormatYUV422PackedSemiPlanar: return "OMX_COLOR_FormatYUV422PackedSemiPlanar"; - case OMX_COLOR_Format18BitBGR666: return "OMX_COLOR_Format18BitBGR666"; - case OMX_COLOR_Format24BitARGB6666: return "OMX_COLOR_Format24BitARGB6666"; - case OMX_COLOR_Format24BitABGR6666: return "OMX_COLOR_Format24BitABGR6666"; - - case OMX_COLOR_FormatAndroidOpaque: return "OMX_COLOR_FormatAndroidOpaque"; - case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar: return "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar"; - case OMX_QCOM_COLOR_FormatYVU420SemiPlanar: return "OMX_QCOM_COLOR_FormatYVU420SemiPlanar"; - case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: return "OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka"; - case OMX_SEC_COLOR_FormatNV12Tiled: return "OMX_SEC_COLOR_FormatNV12Tiled"; - case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m: return "OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m"; - - // case QOMX_COLOR_FormatYVU420SemiPlanar: return "QOMX_COLOR_FormatYVU420SemiPlanar"; - case QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka: return "QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka"; - case QOMX_COLOR_FormatYUV420PackedSemiPlanar16m2ka: return "QOMX_COLOR_FormatYUV420PackedSemiPlanar16m2ka"; - // case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: return "QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka"; - // case QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m: return "QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m"; - case QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mMultiView: return "QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mMultiView"; - case QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mCompressed: return "QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mCompressed"; - case QOMX_COLOR_Format32bitRGBA8888: return "QOMX_COLOR_Format32bitRGBA8888"; - case QOMX_COLOR_Format32bitRGBA8888Compressed: return "QOMX_COLOR_Format32bitRGBA8888Compressed"; - - default: - return "unkn"; - } -} - - -void encoder_init(EncoderState *s, const char* filename, int width, int height, int fps, int bitrate) { - int err; - - memset(s, 0, sizeof(*s)); - s->filename = filename; - s->width = width; - s->height = height; - s->fps = fps; - mutex_init_reentrant(&s->lock); - - s->segment = -1; - - s->state = OMX_StateLoaded; - - s->codec_config = NULL; - - queue_init(&s->free_in); - queue_init(&s->done_out); - - 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); - assert(err == OMX_ErrorNone); - // printf("handle: %p\n", s->handle); - - // setup input port - - OMX_PARAM_PORTDEFINITIONTYPE in_port = {0}; - in_port.nSize = sizeof(in_port); - in_port.nPortIndex = (OMX_U32) PORT_INDEX_IN; - err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, - (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); - in_port.format.video.nSliceHeight = s->height; - // in_port.nBufferSize = (s->width * s->height * 3) / 2; - in_port.nBufferSize = VENUS_BUFFER_SIZE(COLOR_FMT_NV12, s->width, s->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; - - err = OMX_SetParameter(s->handle, OMX_IndexParamPortDefinition, - (OMX_PTR) &in_port); - assert(err == OMX_ErrorNone); - - - err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, - (OMX_PTR) &in_port); - assert(err == OMX_ErrorNone); - s->num_in_bufs = in_port.nBufferCountActual; - - // printf("in width: %d, stride: %d\n", - // in_port.format.video.nFrameWidth, in_port.format.video.nStride); - - // setup output port - - OMX_PARAM_PORTDEFINITIONTYPE out_port = {0}; - out_port.nSize = sizeof(out_port); - out_port.nPortIndex = (OMX_U32) PORT_INDEX_OUT; - 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; - 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; - err = OMX_GetParameter(s->handle, OMX_IndexParamVideoBitrate, - (OMX_PTR) &bitrate_type); - assert(err == OMX_ErrorNone); - - bitrate_type.eControlRate = OMX_Video_ControlRateVariable; - bitrate_type.nTargetBitrate = bitrate; - - err = OMX_SetParameter(s->handle, OMX_IndexParamVideoBitrate, - (OMX_PTR) &bitrate_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); - - - 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.eProfile = OMX_VIDEO_AVCProfileBaseline; - avc.eLevel = OMX_VIDEO_AVCLevel31; - - avc.nAllowedPictureTypes |= OMX_VIDEO_PictureTypeB; - avc.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable; - - err = OMX_SetParameter(s->handle, OMX_IndexParamVideoAvc, &avc); - assert(err == OMX_ErrorNone); -#endif - - - // for (int i = 0; ; i++) { - // OMX_VIDEO_PARAM_PORTFORMATTYPE video_port_format = {0}; - // video_port_format.nSize = sizeof(video_port_format); - // video_port_format.nIndex = i; - // video_port_format.nPortIndex = PORT_INDEX_IN; - // if (OMX_GetParameter(s->handle, OMX_IndexParamVideoPortFormat, &video_port_format) != OMX_ErrorNone) - // break; - // printf("in %d: compression 0x%x format 0x%x %s\n", i, - // video_port_format.eCompressionFormat, video_port_format.eColorFormat, - // omx_color_fomat_name(video_port_format.eColorFormat)); - // } - - // for (int i=0; i<32; i++) { - // OMX_VIDEO_PARAM_PROFILELEVELTYPE params = {0}; - // params.nSize = sizeof(params); - // params.nPortIndex = PORT_INDEX_OUT; - // params.nProfileIndex = i; - // if (OMX_GetParameter(s->handle, OMX_IndexParamVideoProfileLevelQuerySupported, ¶ms) != OMX_ErrorNone) - // break; - // printf("profile %d level 0x%x\n", params.eProfile, params.eLevel); - // } - - err = OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateIdle, NULL); - assert(err == OMX_ErrorNone); - - s->in_buf_headers = calloc(s->num_in_bufs, sizeof(OMX_BUFFERHEADERTYPE*)); - for (int i=0; inum_in_bufs; i++) { - err = OMX_AllocateBuffer(s->handle, &s->in_buf_headers[i], PORT_INDEX_IN, s, - in_port.nBufferSize); - assert(err == OMX_ErrorNone); - } - - s->out_buf_headers = calloc(s->num_out_bufs, sizeof(OMX_BUFFERHEADERTYPE*)); - for (int i=0; inum_out_bufs; i++) { - err = OMX_AllocateBuffer(s->handle, &s->out_buf_headers[i], PORT_INDEX_OUT, s, - out_port.nBufferSize); - assert(err == OMX_ErrorNone); - } - - wait_for_state(s, OMX_StateIdle); - - err = OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateExecuting, NULL); - assert(err == OMX_ErrorNone); - - wait_for_state(s, OMX_StateExecuting); - - // give omx all the output buffers - for (int i = 0; i < s->num_out_bufs; i++) { - // printf("fill %p\n", s->out_buf_headers[i]); - err = OMX_FillThisBuffer(s->handle, s->out_buf_headers[i]); - assert(err == OMX_ErrorNone); - } - - // fill the input free queue - for (int i = 0; i < s->num_in_bufs; i++) { - queue_push(&s->free_in, (void*)s->in_buf_headers[i]); - } -} - -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) { - if (s->codec_config_len < out_buf->nFilledLen) { - s->codec_config = realloc(s->codec_config, out_buf->nFilledLen); - } - 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); - } - - if (s->of) { - // printf("write %d flags 0x%x\n", out_buf->nFilledLen, out_buf->nFlags); - fwrite(buf_data, out_buf->nFilledLen, 1, s->of); - } - - // give omx back the buffer - err = OMX_FillThisBuffer(s->handle, out_buf); - assert(err == OMX_ErrorNone); -} - -int encoder_encode_frame(EncoderState *s, uint64_t ts, - const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, - int *frame_segment, VIPCBufExtra *extra) { - int err; - - pthread_mutex_lock(&s->lock); - - if (s->opening) { - encoder_open(s, s->next_path); - s->opening = false; - } - - if (!s->open) { - pthread_mutex_unlock(&s->lock); - return -1; - } - - // 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); - 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; - } - - int ret = s->counter; - - uint8_t *in_buf_ptr = in_buf->pBuffer; - // printf("in_buf ptr %p\n", in_buf_ptr); - - 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); - // 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)); - - err = I420ToNV12(y_ptr, s->width, - u_ptr, s->width/2, - v_ptr, s->width/2, - in_y_ptr, in_y_stride, - in_uv_ptr, in_uv_stride, - s->width, s->height); - assert(err == 0); - - // in_buf->nFilledLen = (s->width*s->height) + (s->width*s->height/2); - 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; - - err = OMX_EmptyThisBuffer(s->handle, in_buf); - assert(err == OMX_ErrorNone); - - // pump output - while (true) { - OMX_BUFFERHEADERTYPE *out_buf = queue_try_pop(&s->done_out); - if (!out_buf) { - break; - } - handle_out_buf(s, out_buf); - } - - s->dirty = true; - - s->counter++; - - if (frame_segment) { - *frame_segment = s->segment; - } - - if (s->closing) { - encoder_close(s); - s->closing = false; - } - - pthread_mutex_unlock(&s->lock); - return ret; -} - -void encoder_open(EncoderState *s, const char* path) { - int err; - - 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); - - if (s->codec_config_len > 0) { - fwrite(s->codec_config, s->codec_config_len, 1, s->of); - } - - // create camera lock file - snprintf(s->lock_path, sizeof(s->lock_path), "%s/%s.lock", path, s->filename); - int lock_fd = open(s->lock_path, O_RDWR | O_CREAT, 0777); - assert(lock_fd >= 0); - close(lock_fd); - - s->open = true; - s->counter = 0; - - pthread_mutex_unlock(&s->lock); -} - -void encoder_close(EncoderState *s) { - int err; - - pthread_mutex_lock(&s->lock); - - if (s->open) { - if (s->dirty) { - // drain output only if there could be frames in the encoder - - OMX_BUFFERHEADERTYPE* in_buf = queue_pop(&s->free_in); - in_buf->nFilledLen = 0; - in_buf->nOffset = 0; - in_buf->nFlags = OMX_BUFFERFLAG_EOS; - in_buf->nTimeStamp = 0; - - err = OMX_EmptyThisBuffer(s->handle, in_buf); - assert(err == OMX_ErrorNone); - - while (true) { - OMX_BUFFERHEADERTYPE *out_buf = queue_pop(&s->done_out); - - handle_out_buf(s, out_buf); - - if (out_buf->nFlags & OMX_BUFFERFLAG_EOS) { - break; - } - } - s->dirty = false; - } - - fclose(s->of); - unlink(s->lock_path); - } - s->open = false; - - pthread_mutex_unlock(&s->lock); -} - -void encoder_rotate(EncoderState *s, const char* new_path, int new_segment) { - pthread_mutex_lock(&s->lock); - snprintf(s->next_path, sizeof(s->next_path), "%s", new_path); - s->next_segment = new_segment; - if (s->open) { - if (s->next_segment == -1) { - s->closing = true; - } else { - s->rotating = true; - } - } else { - s->segment = s->next_segment; - s->opening = true; - } - pthread_mutex_unlock(&s->lock); -} - -void encoder_destroy(EncoderState *s) { - int err; - - assert(!s->open); - - err = OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateIdle, NULL); - assert(err == OMX_ErrorNone); - - wait_for_state(s, OMX_StateIdle); - - err = OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateLoaded, NULL); - assert(err == OMX_ErrorNone); - - for (int i=0; inum_in_bufs; i++) { - err = OMX_FreeBuffer(s->handle, PORT_INDEX_IN, s->in_buf_headers[i]); - assert(err == OMX_ErrorNone); - } - free(s->in_buf_headers); - - for (int i=0; inum_out_bufs; i++) { - err = OMX_FreeBuffer(s->handle, PORT_INDEX_OUT, s->out_buf_headers[i]); - assert(err == OMX_ErrorNone); - } - free(s->out_buf_headers); - - wait_for_state(s, OMX_StateLoaded); - - err = OMX_FreeHandle(s->handle); - assert(err == OMX_ErrorNone); -} - -#if 0 - -// cd one/selfdrive/visiond -// clang -// -fPIC -pie -// -std=gnu11 -O2 -g -// -o encoder -// -I ~/one/selfdrive -// -I ~/one/phonelibs/openmax/include -// -I ~/one/phonelibs/libyuv/include -// -lOmxVenc -lOmxCore -llog -// encoder.c -// buffering.c -// -L ~/one/phonelibs/libyuv/lib -l:libyuv.a - -int main() { - int err; - - EncoderState state; - EncoderState *s = &state; - memset(s, 0, sizeof(*s)); - - int w = 1164; - int h = 874; - - encoder_init(s, w, h, 20); - printf("inited\n"); - - encoder_open(s, "/sdcard/t1"); - - // uint8_t *tmpy = malloc(640*480); - // uint8_t *tmpu = malloc((640/2)*(480/2)); - // uint8_t *tmpv = malloc((640/2)*(480/2)); - - // memset(tmpy, 0, 640*480); - // // memset(tmpu, 0xff, (640/2)*(480/2)); - // memset(tmpv, 0, (640/2)*(480/2)); - -// #if 0 - // FILE *infile = fopen("/sdcard/camera_t2.yuv", "rb"); - uint8_t *inbuf = malloc(w*h*3/2); - 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; - uint8_t *tmpu = inbuf + w*h; - uint8_t *tmpv = inbuf + w*h + (w/2)*(h/2); - - for (int y=0; yof); - // s->of = fopen("/sdcard/tmpout2.hevc", "wb"); - // if (s->codec_config) { - // fwrite(s->codec_config, s->codec_config_len, 1, s->of); - // } - // encoder_open(s, "/sdcard/t1"); - - 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; - uint8_t *tmpu = inbuf + w*h; - uint8_t *tmpv = inbuf + w*h + (w/2)*(h/2); - - for (int y=0; y -#include -#include - -#include - -#include - -#include "common/cqueue.h" -#include "common/visionipc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct EncoderState { - pthread_mutex_t lock; - int width, height, fps; - const char* path; - char vid_path[1024]; - char lock_path[1024]; - bool open; - bool dirty; - int counter; - int segment; - - bool rotating; - bool closing; - bool opening; - char next_path[1024]; - int next_segment; - - const char* filename; - FILE *of; - - size_t codec_config_len; - uint8_t *codec_config; - - pthread_mutex_t state_lock; - pthread_cond_t state_cv; - OMX_STATETYPE state; - - OMX_HANDLETYPE handle; - - int num_in_bufs; - OMX_BUFFERHEADERTYPE** in_buf_headers; - - int num_out_bufs; - OMX_BUFFERHEADERTYPE** out_buf_headers; - - Queue free_in; - Queue done_out; - - void *stream_sock_raw; -} 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, - const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, - 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); -void encoder_close(EncoderState *s); -void encoder_destroy(EncoderState *s); - -#ifdef __cplusplus -} -#endif - -#endif +#pragma once + +#include + +class VideoEncoder { +public: + virtual ~VideoEncoder() {} + virtual int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, + int in_width, int in_height, uint64_t ts) = 0; + virtual void encoder_open(const char* path) = 0; + virtual void encoder_close() = 0; +}; diff --git a/selfdrive/loggerd/frame_logger.h b/selfdrive/loggerd/frame_logger.h deleted file mode 100644 index bfc0681b756af0..00000000000000 --- a/selfdrive/loggerd/frame_logger.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef FRAMELOGGER_H -#define FRAMELOGGER_H - -#include - -#include -#include - -class FrameLogger { -public: - virtual ~FrameLogger() {} - - virtual void Open(const std::string &path) = 0; - virtual void Close() = 0; - - 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; - } - - if (!is_open) return -1; - - if (rotating) { - Close(); - Open(next_path); - segment = next_segment; - rotating = false; - } - - int ret = ProcessFrame(ts, y_ptr, u_ptr, v_ptr); - - if (ret >= 0 && frame_segment) { - *frame_segment = segment; - } - - if (closing) { - Close(); - closing = false; - } - - return ret; - } - - void Rotate(const std::string &new_path, int new_segment) { - std::lock_guard guard(lock); - - next_path = new_path; - next_segment = new_segment; - if (is_open) { - if (next_segment == -1) { - closing = true; - } else { - rotating = true; - } - } else { - segment = next_segment; - opening = true; - } - } - -protected: - - virtual int ProcessFrame(uint64_t ts, const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr) = 0; - - std::recursive_mutex lock; - - bool is_open = false; - int segment = -1; - - std::string vid_path, lock_path; - -private: - int next_segment = -1; - bool opening = false, closing = false, rotating = false; - std::string next_path; -}; - -#endif 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..81cfd131f6ffef --- /dev/null +++ b/selfdrive/loggerd/logger.cc @@ -0,0 +1,281 @@ +#include "selfdrive/loggerd/logger.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef QCOM +#include +#endif + +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/version.h" + +// ***** logging helpers ***** + +void append_property(const char* key, const char* value, void *cookie) { + std::vector > *properties = + (std::vector > *)cookie; + + properties->push_back(std::make_pair(std::string(key), std::string(value))); +} + +// ***** log metadata ***** +kj::Array logger_build_init_data() { + MessageBuilder msg; + auto init = msg.initEvent().initInitData(); + + if (Hardware::EON()) { + init.setDeviceType(cereal::InitData::DeviceType::NEO); + } else if (Hardware::TICI()) { + init.setDeviceType(cereal::InitData::DeviceType::TICI); + } else { + init.setDeviceType(cereal::InitData::DeviceType::PC); + } + + init.setVersion(COMMA_VERSION); + + std::ifstream cmdline_stream("/proc/cmdline"); + std::vector kernel_args; + std::string buf; + while (cmdline_stream >> buf) { + kernel_args.push_back(buf); + } + + auto lkernel_args = init.initKernelArgs(kernel_args.size()); + for (int i=0; i > properties; + property_list(append_property, (void*)&properties); + + auto lentries = init.initAndroidProperties().initEntries(properties.size()); + for (int i=0; i params_map = params.readAll(); + + init.setGitCommit(params_map["GitCommit"]); + init.setGitBranch(params_map["GitBranch"]); + init.setGitRemote(params_map["GitRemote"]); + init.setPassive(params.getBool("Passive")); + init.setDongleId(params_map["DongleId"]); + + auto lparams = init.initParams().initEntries(params_map.size()); + int i = 0; + for (auto& [key, value] : params_map) { + auto lentry = lparams[i]; + lentry.setKey(key); + if ( !(params.getKeyType(key) & DONT_LOG) ) { + lentry.setValue(capnp::Data::Reader((const kj::byte*)value.data(), value.size())); + } + i++; + + } + return capnp::messageToFlatArray(msg); +} + +std::string logger_get_route_name() { + char route_name[64] = {'\0'}; + time_t rawtime = time(NULL); + struct tm timeinfo; + localtime_r(&rawtime, &timeinfo); + strftime(route_name, sizeof(route_name), "%Y-%m-%d--%H-%M-%S", &timeinfo); + return route_name; +} + +void log_init_data(LoggerState *s) { + auto bytes = s->init_data.asBytes(); + logger_log(s, bytes.begin(), bytes.size(), s->has_qlog); +} + + +static void lh_log_sentinel(LoggerHandle *h, SentinelType type) { + MessageBuilder msg; + auto sen = msg.initEvent().initSentinel(); + sen.setType(type); + sen.setSignal(h->exit_signal); + auto bytes = msg.toBytes(); + + lh_log(h, bytes.begin(), bytes.size(), true); +} + +// ***** logging functions ***** + +void logger_init(LoggerState *s, const char* log_name, bool has_qlog) { + pthread_mutex_init(&s->lock, NULL); + + s->part = -1; + s->has_qlog = has_qlog; + s->route_name = logger_get_route_name(); + snprintf(s->log_name, sizeof(s->log_name), "%s", log_name); + s->init_data = logger_build_init_data(); +} + +static LoggerHandle* logger_open(LoggerState *s, const char* root_path) { + 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.c_str(), 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); + h->end_sentinel_type = SentinelType::END_OF_SEGMENT; + h->exit_signal = 0; + + if (!util::create_directories(h->segment_path, 0775)) return nullptr; + + FILE* lock_file = fopen(h->lock_path, "wb"); + if (lock_file == NULL) return NULL; + fclose(lock_file); + + h->log = std::make_unique(h->log_path); + if (s->has_qlog) { + h->q_log = std::make_unique(h->qlog_path); + } + + pthread_mutex_init(&h->lock, NULL); + h->refcnt++; + return h; +} + +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; + + 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); + + // write beggining of log metadata + log_init_data(s); + lh_log_sentinel(s->cur_handle, is_start_of_route ? SentinelType::START_OF_ROUTE : 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, ExitHandler *exit_handler) { + pthread_mutex_lock(&s->lock); + if (s->cur_handle) { + s->cur_handle->exit_signal = exit_handler && exit_handler->signal.load(); + s->cur_handle->end_sentinel_type = SentinelType::END_OF_ROUTE; + 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); + h->log->write(data, data_size); + if (in_qlog && h->q_log) { + h->q_log->write(data, data_size); + } + pthread_mutex_unlock(&h->lock); +} + +void lh_close(LoggerHandle* h) { + pthread_mutex_lock(&h->lock); + assert(h->refcnt > 0); + if (h->refcnt == 1) { + // a very ugly hack. only here can guarantee sentinel is the last msg + pthread_mutex_unlock(&h->lock); + lh_log_sentinel(h, h->end_sentinel_type); + pthread_mutex_lock(&h->lock); + } + h->refcnt--; + if (h->refcnt == 0) { + h->log.reset(nullptr); + h->q_log.reset(nullptr); + unlink(h->lock_path); + pthread_mutex_unlock(&h->lock); + pthread_mutex_destroy(&h->lock); + return; + } + pthread_mutex_unlock(&h->lock); +} + +int clear_locks_fn(const char* fpath, const struct stat *sb, int tyupeflag) { + const char* dot = strrchr(fpath, '.'); + if (dot && strcmp(dot, ".lock") == 0) { + unlink(fpath); + } + return 0; +} + +void clear_locks(const std::string log_root) { + ftw(log_root.c_str(), clear_locks_fn, 16); +} diff --git a/selfdrive/loggerd/logger.h b/selfdrive/loggerd/logger.h index ab8798481cb738..e85d7810e0710a 100644 --- a/selfdrive/loggerd/logger.h +++ b/selfdrive/loggerd/logger.h @@ -1,39 +1,82 @@ -#ifndef LOGGER_H -#define LOGGER_H +#pragma once -#include -#include +#include #include + +#include +#include +#include + #include +#include +#include -#ifdef __cplusplus -extern "C" { -#endif +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/util.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/hardware/hw.h" + +const std::string LOG_ROOT = Path::log_root(); #define LOGGER_MAX_HANDLES 16 +class BZFile { + public: + BZFile(const char* path) { + file = util::safe_fopen(path, "wb"); + assert(file != nullptr); + int bzerror; + bz_file = BZ2_bzWriteOpen(&bzerror, file, 9, 0, 30); + assert(bzerror == BZ_OK); + } + ~BZFile() { + int bzerror; + BZ2_bzWriteClose(&bzerror, bz_file, 0, nullptr, nullptr); + if (bzerror != BZ_OK) { + LOGE("BZ2_bzWriteClose error, bzerror=%d", bzerror); + } + util::safe_fflush(file); + int err = fclose(file); + assert(err == 0); + } + inline void write(void* data, size_t size) { + int bzerror; + do { + BZ2_bzWrite(&bzerror, bz_file, data, size); + } while (bzerror == BZ_IO_ERROR && errno == EINTR); + + if (bzerror != BZ_OK && !error_logged) { + LOGE("BZ2_bzWrite error, bzerror=%d", bzerror); + error_logged = true; + } + } + inline void write(kj::ArrayPtr array) { write(array.begin(), array.size()); } + + private: + bool error_logged = false; + FILE* file = nullptr; + BZFILE* bz_file = nullptr; +}; + +typedef cereal::Sentinel::SentinelType SentinelType; + typedef struct LoggerHandle { pthread_mutex_t lock; + SentinelType end_sentinel_type; + int exit_signal; int refcnt; char segment_path[4096]; char log_path[4096]; - char lock_path[4096]; - FILE* log_file; - BZFILE* bz_file; - - FILE* qlog_file; char qlog_path[4096]; - BZFILE* bz_qlog; + char lock_path[4096]; + std::unique_ptr log, q_log; } LoggerHandle; typedef struct LoggerState { pthread_mutex_t lock; - - uint8_t* init_data; - size_t init_data_len; - int part; - char route_name[64]; + kj::Array init_data; + std::string route_name; char log_name[64]; bool has_qlog; @@ -41,19 +84,16 @@ typedef struct LoggerState { LoggerHandle* cur_handle; } LoggerState; -void logger_init(LoggerState *s, const char* log_name, const uint8_t* init_data, size_t init_data_len, bool has_qlog); +kj::Array logger_build_init_data(); +std::string logger_get_route_name(); +void logger_init(LoggerState *s, const char* log_name, bool has_qlog); int logger_next(LoggerState *s, const char* root_path, char* out_segment_path, size_t out_segment_path_len, int* out_part); LoggerHandle* logger_get_handle(LoggerState *s); -void logger_close(LoggerState *s); +void logger_close(LoggerState *s, ExitHandler *exit_handler=nullptr); void logger_log(LoggerState *s, uint8_t* data, size_t data_size, bool in_qlog); void lh_log(LoggerHandle* h, uint8_t* data, size_t data_size, bool in_qlog); void lh_close(LoggerHandle* h); - -#ifdef __cplusplus -} -#endif - -#endif +void clear_locks(const std::string log_root); diff --git a/selfdrive/loggerd/loggerd.cc b/selfdrive/loggerd/loggerd.cc index db59780f0b3bba..37f03ef4e51665 100644 --- a/selfdrive/loggerd/loggerd.cc +++ b/selfdrive/loggerd/loggerd.cc @@ -1,770 +1,269 @@ -#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 "common/version.h" -#include "common/timing.h" -#include "common/params.h" -#include "common/swaglog.h" -#include "common/visionipc.h" -#include "common/utilpp.h" -#include "common/util.h" - -#include "logger.h" - - -#ifndef DISABLE_ENCODER -#include "encoder.h" -#include "raw_logger.h" -#endif - -#include "cereal/gen/cpp/log.capnp.h" - -#define CAMERA_FPS 20 -#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) { - static std::mt19937 gen(millis_since_boot()); - - std::uniform_real_distribution<> dist(a, b); - return dist(gen); -} +#include "selfdrive/loggerd/loggerd.h" +ExitHandler do_exit; -volatile int do_exit = 0; -static void set_do_exit(int sig) { - do_exit = 1; -} -struct LoggerdState { - void *ctx; - LoggerState logger; - - std::mutex lock; - std::condition_variable cv; - char segment_path[4096]; - uint32_t last_frame_id; - uint32_t rotate_last_frame_id; - int rotate_segment; -}; -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"); - - set_thread_name("FrontCameraEncoder"); +// Handle initial encoder syncing by waiting for all encoders to reach the same frame id +bool sync_encoders(LoggerdState *s, CameraType cam_type, uint32_t frame_id) { + if (s->camera_synced[cam_type]) return true; + + if (s->max_waiting > 1 && s->encoders_ready != s->max_waiting) { + // add a small margin to the start frame id in case one of the encoders already dropped the next frame + update_max_atomic(s->start_frame_id, frame_id + 2); + if (std::exchange(s->camera_ready[cam_type], true) == false) { + ++s->encoders_ready; + LOGE("camera %d encoder ready", cam_type); + } + return false; } else { - set_thread_name("RearCameraEncoder"); + if (s->max_waiting == 1) update_max_atomic(s->start_frame_id, frame_id); + bool synced = frame_id >= s->start_frame_id; + s->camera_synced[cam_type] = synced; + if (!synced) LOGE("camera %d waiting for frame %d, cur %d", cam_type, (int)s->start_frame_id, frame_id); + return synced; } +} - VisionStream stream; - - bool encoder_inited = false; - EncoderState encoder; - - int encoder_segment = -1; - int cnt = 0; +bool trigger_rotate_if_needed(LoggerdState *s, int cur_seg, uint32_t frame_id) { + const int frames_per_seg = SEGMENT_LENGTH * MAIN_FPS; + if (cur_seg >= 0 && frame_id >= ((cur_seg + 1) * frames_per_seg) + s->start_frame_id) { + // trigger rotate and wait until the main logger has rotated to the new segment + ++s->ready_to_rotate; + std::unique_lock lk(s->rotate_lock); + s->rotate_cv.wait(lk, [&] { + return s->rotate_segment > cur_seg || do_exit; + }); + return !do_exit; + } + return false; +} - void *idx_sock = zmq_socket(s.ctx, ZMQ_PUB); - assert(idx_sock); - zmq_bind(idx_sock, front ? "tcp://*:8061" : "tcp://*:8015"); +void encoder_thread(LoggerdState *s, const LogCameraInfo &cam_info) { + util::set_thread_name(cam_info.filename); + int cur_seg = -1; + int encode_idx = 0; LoggerHandle *lh = NULL; + std::vector encoders; + VisionIpcClient vipc_client = VisionIpcClient("camerad", cam_info.stream_type, false); 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); - } - if (err != 0) { - LOGD("visionstream connect fail"); - usleep(100000); + if (!vipc_client.connect(false)) { + util::sleep_for(5); continue; } - if (!encoder_inited) { + // init encoders + if (encoders.empty()) { + VisionBuf buf_info = vipc_client.buffers[0]; 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"); - } - } - // 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); + // main encoder + encoders.push_back(new Encoder(cam_info.filename, buf_info.width, buf_info.height, + cam_info.fps, cam_info.bitrate, cam_info.is_h265, + cam_info.downscale, cam_info.record)); + // qcamera encoder + if (cam_info.has_qcamera) { + encoders.push_back(new Encoder(qcam_info.filename, qcam_info.frame_width, qcam_info.frame_height, + qcam_info.fps, qcam_info.bitrate, qcam_info.is_h265, qcam_info.downscale)); + } } while (!do_exit) { - VIPCBufExtra extra; - VIPCBuf* buf = visionstream_get(&stream, &extra); - if (buf == NULL) { - LOG("visionstream get failed"); - break; - } - - 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); - - { - 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; + VisionIpcBufExtra extra; + VisionBuf* buf = vipc_client.recv(&extra); + if (buf == nullptr) continue; + + if (cam_info.trigger_rotate) { + s->last_camera_seen_tms = millis_since_boot(); + if (!sync_encoders(s, cam_info.type, extra.frame_id)) { + continue; } - 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); - - encoder_rotate(&encoder, s.segment_path, s.rotate_segment); - - if (raw_clips) { - rawlogger->Rotate(s.segment_path, s.rotate_segment); - } - - encoder_segment = s.rotate_segment; - if (lh) { - lh_close(lh); - } - lh = logger_get_handle(&s.logger); - } + // check if we're ready to rotate + trigger_rotate_if_needed(s, cur_seg, extra.frame_id); + if (do_exit) break; } - { - // encode hevc - int out_segment = -1; - int out_id = encoder_encode_frame(&encoder, cnt*50000ULL, - y, u, v, &out_segment, &extra); + // rotate the encoder if the logger is on a newer segment + if (s->rotate_segment > cur_seg) { + cur_seg = s->rotate_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(front ? cereal::EncodeIndex::Type::FRONT : cereal::EncodeIndex::Type::FULL_H_E_V_C); - 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)); + LOGW("camera %d rotate encoder to %s", cam_info.type, s->segment_path); + for (auto &e : encoders) { + e->encoder_close(); + e->encoder_open(s->segment_path); } if (lh) { - lh_log(lh, bytes.begin(), bytes.size(), false); + lh_close(lh); } + lh = logger_get_handle(&s->logger); } - 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); + // encode a frame + for (int i = 0; i < encoders.size(); ++i) { + int out_id = encoders[i]->encode_frame(buf->y, buf->u, buf->v, + buf->width, buf->height, extra.timestamp_eof); - if (rawlogger_clip_cnt == 0) { - LOG("starting raw clip in seg %d", out_segment); - } + if (out_id == -1) { + LOGE("Failed to encode frame. frame_id: %d encode_id: %d", extra.frame_id, encode_idx); + } - // publish encode index - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto eidx = event.initEncodeIdx(); + // publish encode index + if (i == 0 && out_id != -1) { + MessageBuilder msg; + // this is really ugly + bool valid = (buf->get_frame_id() == extra.frame_id); + auto eidx = cam_info.type == DriverCam ? msg.initEvent(valid).initDriverEncodeIdx() : + (cam_info.type == WideRoadCam ? msg.initEvent(valid).initWideRoadEncodeIdx() : msg.initEvent(valid).initRoadEncodeIdx()); eidx.setFrameId(extra.frame_id); - eidx.setType(cereal::EncodeIndex::Type::FULL_LOSSLESS_CLIP); - eidx.setEncodeId(cnt); - eidx.setSegmentNum(out_segment); + eidx.setTimestampSof(extra.timestamp_sof); + eidx.setTimestampEof(extra.timestamp_eof); + if (Hardware::TICI()) { + eidx.setType(cereal::EncodeIndex::Type::FULL_H_E_V_C); + } else { + eidx.setType(cam_info.type == DriverCam ? cereal::EncodeIndex::Type::FRONT : cereal::EncodeIndex::Type::FULL_H_E_V_C); + } + eidx.setEncodeId(encode_idx); + eidx.setSegmentNum(cur_seg); 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); + auto bytes = msg.toBytes(); + lh_log(lh, bytes.begin(), bytes.size(), true); } } } - cnt++; + encode_idx++; } if (lh) { lh_close(lh); lh = NULL; } - - if (raw_clips) { - rawlogger->Close(); - delete rawlogger; - } - - visionstream_destroy(&stream); - } - - if (encoder_inited) { - LOG("encoder destroy"); - 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; + LOG("encoder destroy"); + for(auto &e : encoders) { + e->encoder_close(); + delete e; } - - 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()); - } - return 0; -} -#endif - } -void append_property(const char* key, const char* value, void *cookie) { - std::vector > *properties = - (std::vector > *)cookie; - - properties->push_back(std::make_pair(std::string(key), std::string(value))); -} - -kj::Array gen_init_data() { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto init = event.initInitData(); - - init.setDeviceType(cereal::InitData::DeviceType::NEO); - init.setVersion(capnp::Text::Reader(COMMA_VERSION)); - - std::ifstream cmdline_stream("/proc/cmdline"); - std::vector kernel_args; - std::string buf; - while (cmdline_stream >> buf) { - kernel_args.push_back(buf); - } - - auto lkernel_args = init.initKernelArgs(kernel_args.size()); - for (int i=0; i > properties; - property_list(append_property, (void*)&properties); - - auto lentries = init.initAndroidProperties().initEntries(properties.size()); - for (int i=0; i params; - read_db_all(NULL, ¶ms); - auto lparams = init.initParams().initEntries(params.size()); - int i = 0; - for (auto& kv : params) { - 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); + std::unique_lock lk(s->rotate_lock); + int segment = -1; + int err = logger_next(&s->logger, LOG_ROOT.c_str(), s->segment_path, sizeof(s->segment_path), &segment); + assert(err == 0); + s->rotate_segment = segment; + s->ready_to_rotate = 0; + s->last_rotate_tms = millis_since_boot(); } - - return words; + s->rotate_cv.notify_all(); + LOGW((s->logger.part == 0) ? "logging to %s" : "rotated to %s", s->segment_path); } -static int clear_locks_fn(const char* fpath, const struct stat *sb, int tyupeflag) { - const char* dot = strrchr(fpath, '.'); - if (dot && strcmp(dot, ".lock") == 0) { - unlink(fpath); +void rotate_if_needed(LoggerdState *s) { + if (s->ready_to_rotate == s->max_waiting) { + logger_rotate(s); } - return 0; -} -static void clear_locks() { - ftw(LOG_ROOT, clear_locks_fn, 16); -} - -static void bootlog() { - int err; - - { - auto words = gen_init_data(); - auto bytes = words.asBytes(); - logger_init(&s.logger, "bootlog", bytes.begin(), bytes.size(), false); + double tms = millis_since_boot(); + if ((tms - s->last_rotate_tms) > SEGMENT_LENGTH * 1000 && + (tms - s->last_camera_seen_tms) > NO_CAMERA_PATIENCE && + !LOGGERD_TEST) { + LOGW("no camera packet seen. auto rotating"); + logger_rotate(s); } - - err = logger_next(&s.logger, LOG_ROOT, s.segment_path, sizeof(s.segment_path), &s.rotate_segment); - assert(err == 0); - LOGW("bootlog to %s", s.segment_path); - - { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - - auto boot = event.initBoot(); - - boot.setWallTimeNanos(nanos_since_epoch()); - - std::string lastKmsg = util::read_file("/sys/fs/pstore/console-ramoops"); - boot.setLastKmsg(capnp::Data::Reader((const kj::byte*)lastKmsg.data(), lastKmsg.size())); - - 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(); - logger_log(&s.logger, bytes.begin(), bytes.size(), false); - } - - logger_close(&s.logger); } -int main(int argc, char** argv) { - int err; - - if (argc > 1 && strcmp(argv[1], "--bootlog") == 0) { - bootlog(); - return 0; +void loggerd_thread() { + // setup messaging + typedef struct QlogState { + std::string name; + int counter, freq; + } QlogState; + std::unordered_map qlog_states; + + std::unique_ptr ctx(Context::create()); + std::unique_ptr poller(Poller::create()); + + // subscribe to all socks + for (const auto& it : services) { + if (!it.should_log) continue; + + SubSocket * sock = SubSocket::create(ctx.get(), it.name); + assert(sock != NULL); + poller->registerSocket(sock); + qlog_states[sock] = { + .name = it.name, + .counter = 0, + .freq = it.decimation, + }; } - setpriority(PRIO_PROCESS, 0, -12); - - 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"; - - // 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; - - zmq_connect(sock, ss.str().c_str()); - - 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); - socks.push_back(sock); - - if (name == "frame") { - LOGD("found frame sock at port %d", port); - frame_sock = sock; - } - - qlog_counter[sock] = (qlog_freq == 0) ? -1 : 0; - qlog_freqs[sock] = qlog_freq; + LoggerdState s; + // init logger + logger_init(&s.logger, "rlog", true); + logger_rotate(&s); + Params().put("CurrentRoute", s.logger.route_name); + + // init encoders + s.last_camera_seen_tms = millis_since_boot(); + std::vector encoder_threads; + for (const auto &cam : cameras_logged) { + if (cam.enable) { + encoder_threads.push_back(std::thread(encoder_thread, &s, cam)); + if (cam.trigger_rotate) s.max_waiting++; } } - - { - 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; - -#ifndef DISABLE_ENCODER - // rear camera - std::thread encoder_thread_handle(encoder_thread, is_streaming, false, false); - - // front camera - std::thread front_encoder_thread_handle(encoder_thread, false, false, true); -#endif - -#if ENABLE_LIDAR - std::thread lidar_thread_handle(lidar_thread); -#endif - - uint64_t msg_count = 0; - uint64_t bytes_count = 0; - + uint64_t msg_count = 0, bytes_count = 0; + double start_ts = 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; i((len / sizeof(capnp::word)) + 1); - memcpy(amsg.begin(), data, len); - - // 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(); - } + // poll for new messages on all sockets + for (auto sock : poller->poll(1000)) { + if (do_exit) break; + + // drain socket + int count = 0; + QlogState &qs = qlog_states[sock]; + Message *msg = nullptr; + while (!do_exit && (msg = sock->receive(true))) { + const bool in_qlog = qs.freq != -1 && (qs.counter++ % qs.freq == 0); + logger_log(&s.logger, (uint8_t *)msg->getData(), msg->getSize(), in_qlog); + bytes_count += msg->getSize(); + delete msg; + + rotate_if_needed(&s); + + if ((++msg_count % 1000) == 0) { + double seconds = (millis_since_boot() - start_ts) / 1000.0; + LOGD("%lu messages, %.2f msg/sec, %.2f KB/sec", msg_count, msg_count / seconds, bytes_count * 0.001 / seconds); } - 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)); - } - - logger_log(&s.logger, data, len, qlog_counter[socks[i]] == 0); - zmq_msg_close(&msg); - - 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]]; + count++; + if (count >= 200) { + LOGE("large volume of '%s' messages", qs.name.c_str()); + break; } - - bytes_count += len; - msg_count++; } } - - double ts = seconds_since_boot(); - if (ts - last_rotate_ts > SEGMENT_LENGTH) { - // rotate the log - - last_rotate_ts += SEGMENT_LENGTH; - - std::lock_guard guard(s.lock); - s.rotate_last_frame_id = s.last_frame_id; - - 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); - } - } - - if ((msg_count%1000) == 0) { - LOGD("%lu messages, %.2f msg/sec, %.2f KB/sec", msg_count, msg_count*1.0/(ts-start_ts), bytes_count*0.001/(ts-start_ts)); - } } - LOGW("joining threads"); - s.cv.notify_all(); + LOGW("closing encoders"); + s.rotate_cv.notify_all(); + for (auto &t : encoder_threads) t.join(); -#ifndef DISABLE_ENCODER - front_encoder_thread_handle.join(); - encoder_thread_handle.join(); - LOGW("encoder joined"); -#endif + LOGW("closing logger"); + logger_close(&s.logger, &do_exit); -#if ENABLE_LIDAR - lidar_thread_handle.join(); - LOGW("lidar joined"); -#endif - - logger_close(&s.logger); + if (do_exit.power_failure) { + LOGE("power failure"); + sync(); + LOGE("sync done"); + } - return 0; + // messaging cleanup + for (auto &[sock, qs] : qlog_states) delete sock; } diff --git a/selfdrive/loggerd/loggerd.h b/selfdrive/loggerd/loggerd.h new file mode 100644 index 00000000000000..bdf5ef8f9d840f --- /dev/null +++ b/selfdrive/loggerd/loggerd.h @@ -0,0 +1,131 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "cereal/services.h" +#include "cereal/visionipc/visionipc.h" +#include "cereal/visionipc/visionipc_client.h" +#include "selfdrive/camerad/cameras/camera_common.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" + +#include "selfdrive/loggerd/encoder.h" +#include "selfdrive/loggerd/logger.h" +#if defined(QCOM) || defined(QCOM2) +#include "selfdrive/loggerd/omx_encoder.h" +#define Encoder OmxEncoder +#else +#include "selfdrive/loggerd/raw_logger.h" +#define Encoder RawLogger +#endif + +constexpr int MAIN_FPS = 20; +const int MAIN_BITRATE = Hardware::TICI() ? 10000000 : 5000000; +const int DCAM_BITRATE = Hardware::TICI() ? MAIN_BITRATE : 2500000; + +#define NO_CAMERA_PATIENCE 500 // fall back to time-based rotation if all cameras are dead + +const bool LOGGERD_TEST = getenv("LOGGERD_TEST"); +const int SEGMENT_LENGTH = LOGGERD_TEST ? atoi(getenv("LOGGERD_SEGMENT_LENGTH")) : 60; + +struct LogCameraInfo { + CameraType type; + const char *filename; + VisionStreamType stream_type; + int frame_width, frame_height; + int fps; + int bitrate; + bool is_h265; + bool downscale; + bool has_qcamera; + bool trigger_rotate; + bool enable; + bool record; +}; + +const LogCameraInfo cameras_logged[] = { + { + .type = RoadCam, + .stream_type = VISION_STREAM_ROAD, + .filename = "fcamera.hevc", + .fps = MAIN_FPS, + .bitrate = MAIN_BITRATE, + .is_h265 = true, + .downscale = false, + .has_qcamera = true, + .trigger_rotate = true, + .enable = true, + .record = true, + }, + { + .type = DriverCam, + .stream_type = VISION_STREAM_DRIVER, + .filename = "dcamera.hevc", + .fps = MAIN_FPS, // on EONs, more compressed this way + .bitrate = DCAM_BITRATE, + .is_h265 = true, + .downscale = false, + .has_qcamera = false, + .trigger_rotate = Hardware::TICI(), + .enable = !Hardware::PC(), + .record = Params().getBool("RecordFront"), + }, + { + .type = WideRoadCam, + .stream_type = VISION_STREAM_WIDE_ROAD, + .filename = "ecamera.hevc", + .fps = MAIN_FPS, + .bitrate = MAIN_BITRATE, + .is_h265 = true, + .downscale = false, + .has_qcamera = false, + .trigger_rotate = true, + .enable = Hardware::TICI(), + .record = Hardware::TICI(), + }, +}; +const LogCameraInfo qcam_info = { + .filename = "qcamera.ts", + .fps = MAIN_FPS, + .bitrate = 256000, + .is_h265 = false, + .downscale = true, + .frame_width = Hardware::TICI() ? 526 : 480, + .frame_height = Hardware::TICI() ? 330 : 360 // keep pixel count the same? +}; + +struct LoggerdState { + LoggerState logger = {}; + char segment_path[4096]; + std::mutex rotate_lock; + std::condition_variable rotate_cv; + std::atomic rotate_segment; + std::atomic last_camera_seen_tms; + std::atomic ready_to_rotate; // count of encoders ready to rotate + int max_waiting = 0; + double last_rotate_tms = 0.; // last rotate time in ms + + // Sync logic for startup + std::atomic encoders_ready = 0; + std::atomic start_frame_id = 0; + bool camera_ready[WideRoadCam + 1] = {}; + bool camera_synced[WideRoadCam + 1] = {}; +}; + +bool sync_encoders(LoggerdState *s, CameraType cam_type, uint32_t frame_id); +bool trigger_rotate_if_needed(LoggerdState *s, int cur_seg, uint32_t frame_id); +void rotate_if_needed(LoggerdState *s); +void loggerd_thread(); diff --git a/selfdrive/loggerd/main.cc b/selfdrive/loggerd/main.cc new file mode 100644 index 00000000000000..7069aa70683baf --- /dev/null +++ b/selfdrive/loggerd/main.cc @@ -0,0 +1,20 @@ +#include "selfdrive/loggerd/loggerd.h" + +#include + +int main(int argc, char** argv) { + if (Hardware::EON()) { + setpriority(PRIO_PROCESS, 0, -20); + } else if (Hardware::TICI()) { + int ret; + ret = util::set_core_affinity({0, 1, 2, 3}); + assert(ret == 0); + // TODO: why does this impact camerad timings? + //ret = util::set_realtime_priority(1); + //assert(ret == 0); + } + + loggerd_thread(); + + return 0; +} diff --git a/selfdrive/loggerd/omx_encoder.cc b/selfdrive/loggerd/omx_encoder.cc new file mode 100644 index 00000000000000..672238eaeb85d3 --- /dev/null +++ b/selfdrive/loggerd/omx_encoder.cc @@ -0,0 +1,607 @@ +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#include "selfdrive/loggerd/omx_encoder.h" + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include "libyuv.h" + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/loggerd/include/msm_media_info.h" + +// Check the OMX error code and assert if an error occurred. +#define OMX_CHECK(_expr) \ + do { \ + assert(OMX_ErrorNone == (_expr)); \ + } while (0) + +extern ExitHandler do_exit; + +// ***** OMX callback functions ***** + +void OmxEncoder::wait_for_state(OMX_STATETYPE state_) { + std::unique_lock lk(this->state_lock); + while (this->state != state_) { + this->state_cv.wait(lk); + } +} + +static OMX_CALLBACKTYPE omx_callbacks = { + .EventHandler = OmxEncoder::event_handler, + .EmptyBufferDone = OmxEncoder::empty_buffer_done, + .FillBufferDone = OmxEncoder::fill_buffer_done, +}; + +OMX_ERRORTYPE OmxEncoder::event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_EVENTTYPE event, + OMX_U32 data1, OMX_U32 data2, OMX_PTR event_data) { + OmxEncoder *e = (OmxEncoder*)app_data; + if (event == OMX_EventCmdComplete) { + assert(data1 == OMX_CommandStateSet); + LOG("set state event 0x%x", data2); + { + std::unique_lock lk(e->state_lock); + e->state = (OMX_STATETYPE)data2; + } + e->state_cv.notify_all(); + } else if (event == OMX_EventError) { + LOGE("OMX error 0x%08x", data1); + } else { + LOGE("OMX unhandled event %d", event); + assert(false); + } + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE OmxEncoder::empty_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, + OMX_BUFFERHEADERTYPE *buffer) { + // printf("empty_buffer_done\n"); + OmxEncoder *e = (OmxEncoder*)app_data; + e->free_in.push(buffer); + return OMX_ErrorNone; +} + +OMX_ERRORTYPE OmxEncoder::fill_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, + OMX_BUFFERHEADERTYPE *buffer) { + // printf("fill_buffer_done\n"); + OmxEncoder *e = (OmxEncoder*)app_data; + e->done_out.push(buffer); + return OMX_ErrorNone; +} + +#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"; + case OMX_COLOR_FormatMonochrome: return "OMX_COLOR_FormatMonochrome"; + case OMX_COLOR_Format8bitRGB332: return "OMX_COLOR_Format8bitRGB332"; + case OMX_COLOR_Format12bitRGB444: return "OMX_COLOR_Format12bitRGB444"; + case OMX_COLOR_Format16bitARGB4444: return "OMX_COLOR_Format16bitARGB4444"; + case OMX_COLOR_Format16bitARGB1555: return "OMX_COLOR_Format16bitARGB1555"; + case OMX_COLOR_Format16bitRGB565: return "OMX_COLOR_Format16bitRGB565"; + 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_Format24bitRGB888: return "OMX_COLOR_Format24bitRGB888"; + case OMX_COLOR_Format24bitBGR888: return "OMX_COLOR_Format24bitBGR888"; + case OMX_COLOR_Format24bitARGB1887: return "OMX_COLOR_Format24bitARGB1887"; + case OMX_COLOR_Format25bitARGB1888: return "OMX_COLOR_Format25bitARGB1888"; + case OMX_COLOR_Format32bitBGRA8888: return "OMX_COLOR_Format32bitBGRA8888"; + case OMX_COLOR_Format32bitARGB8888: return "OMX_COLOR_Format32bitARGB8888"; + case OMX_COLOR_FormatYUV411Planar: return "OMX_COLOR_FormatYUV411Planar"; + case OMX_COLOR_FormatYUV411PackedPlanar: return "OMX_COLOR_FormatYUV411PackedPlanar"; + case OMX_COLOR_FormatYUV420Planar: return "OMX_COLOR_FormatYUV420Planar"; + case OMX_COLOR_FormatYUV420PackedPlanar: return "OMX_COLOR_FormatYUV420PackedPlanar"; + case OMX_COLOR_FormatYUV420SemiPlanar: return "OMX_COLOR_FormatYUV420SemiPlanar"; + case OMX_COLOR_FormatYUV422Planar: return "OMX_COLOR_FormatYUV422Planar"; + case OMX_COLOR_FormatYUV422PackedPlanar: return "OMX_COLOR_FormatYUV422PackedPlanar"; + case OMX_COLOR_FormatYUV422SemiPlanar: return "OMX_COLOR_FormatYUV422SemiPlanar"; + case OMX_COLOR_FormatYCbYCr: return "OMX_COLOR_FormatYCbYCr"; + case OMX_COLOR_FormatYCrYCb: return "OMX_COLOR_FormatYCrYCb"; + case OMX_COLOR_FormatCbYCrY: return "OMX_COLOR_FormatCbYCrY"; + case OMX_COLOR_FormatCrYCbY: return "OMX_COLOR_FormatCrYCbY"; + case OMX_COLOR_FormatYUV444Interleaved: return "OMX_COLOR_FormatYUV444Interleaved"; + 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_FormatL32: return "OMX_COLOR_FormatL32"; + case OMX_COLOR_FormatYUV420PackedSemiPlanar: return "OMX_COLOR_FormatYUV420PackedSemiPlanar"; + case OMX_COLOR_FormatYUV422PackedSemiPlanar: return "OMX_COLOR_FormatYUV422PackedSemiPlanar"; + case OMX_COLOR_Format18BitBGR666: return "OMX_COLOR_Format18BitBGR666"; + case OMX_COLOR_Format24BitARGB6666: return "OMX_COLOR_Format24BitARGB6666"; + case OMX_COLOR_Format24BitABGR6666: return "OMX_COLOR_Format24BitABGR6666"; + + case OMX_COLOR_FormatAndroidOpaque: return "OMX_COLOR_FormatAndroidOpaque"; + case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar: return "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar"; + case OMX_QCOM_COLOR_FormatYVU420SemiPlanar: return "OMX_QCOM_COLOR_FormatYVU420SemiPlanar"; + case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: return "OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka"; + case OMX_SEC_COLOR_FormatNV12Tiled: return "OMX_SEC_COLOR_FormatNV12Tiled"; + case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m: return "OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m"; + + // case QOMX_COLOR_FormatYVU420SemiPlanar: return "QOMX_COLOR_FormatYVU420SemiPlanar"; + case QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka: return "QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka"; + case QOMX_COLOR_FormatYUV420PackedSemiPlanar16m2ka: return "QOMX_COLOR_FormatYUV420PackedSemiPlanar16m2ka"; + // case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: return "QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka"; + // case QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m: return "QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m"; + case QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mMultiView: return "QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mMultiView"; + case QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mCompressed: return "QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mCompressed"; + case QOMX_COLOR_Format32bitRGBA8888: return "QOMX_COLOR_Format32bitRGBA8888"; + case QOMX_COLOR_Format32bitRGBA8888Compressed: return "QOMX_COLOR_Format32bitRGBA8888Compressed"; + + default: + return "unkn"; + } +} + + +// ***** encoder functions ***** + +OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale, bool write) { + this->filename = filename; + this->write = write; + this->width = width; + this->height = height; + this->fps = fps; + this->remuxing = !h265; + + this->downscale = downscale; + if (this->downscale) { + this->y_ptr2 = (uint8_t *)malloc(this->width*this->height); + this->u_ptr2 = (uint8_t *)malloc(this->width*this->height/4); + this->v_ptr2 = (uint8_t *)malloc(this->width*this->height/4); + } + + auto component = (OMX_STRING)(h265 ? "OMX.qcom.video.encoder.hevc" : "OMX.qcom.video.encoder.avc"); + int err = OMX_GetHandle(&this->handle, component, this, &omx_callbacks); + if (err != OMX_ErrorNone) { + LOGE("error getting codec: %x", err); + } + assert(err == OMX_ErrorNone); + // printf("handle: %p\n", this->handle); + + // setup input port + + OMX_PARAM_PORTDEFINITIONTYPE in_port = {0}; + in_port.nSize = sizeof(in_port); + in_port.nPortIndex = (OMX_U32) PORT_INDEX_IN; + OMX_CHECK(OMX_GetParameter(this->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &in_port)); + + in_port.format.video.nFrameWidth = this->width; + in_port.format.video.nFrameHeight = this->height; + in_port.format.video.nStride = VENUS_Y_STRIDE(COLOR_FMT_NV12, this->width); + in_port.format.video.nSliceHeight = this->height; + // in_port.nBufferSize = (this->width * this->height * 3) / 2; + in_port.nBufferSize = VENUS_BUFFER_SIZE(COLOR_FMT_NV12, this->width, this->height); + in_port.format.video.xFramerate = (this->fps * 65536); + in_port.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + // in_port.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; + in_port.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m; + + OMX_CHECK(OMX_SetParameter(this->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &in_port)); + OMX_CHECK(OMX_GetParameter(this->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &in_port)); + this->in_buf_headers.resize(in_port.nBufferCountActual); + + // setup output port + + OMX_PARAM_PORTDEFINITIONTYPE out_port = {0}; + out_port.nSize = sizeof(out_port); + out_port.nPortIndex = (OMX_U32) PORT_INDEX_OUT; + OMX_CHECK(OMX_GetParameter(this->handle, OMX_IndexParamPortDefinition, (OMX_PTR)&out_port)); + out_port.format.video.nFrameWidth = this->width; + out_port.format.video.nFrameHeight = this->height; + out_port.format.video.xFramerate = 0; + out_port.format.video.nBitrate = bitrate; + 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; + + OMX_CHECK(OMX_SetParameter(this->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &out_port)); + + OMX_CHECK(OMX_GetParameter(this->handle, OMX_IndexParamPortDefinition, (OMX_PTR) &out_port)); + this->out_buf_headers.resize(out_port.nBufferCountActual); + + OMX_VIDEO_PARAM_BITRATETYPE bitrate_type = {0}; + bitrate_type.nSize = sizeof(bitrate_type); + bitrate_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; + OMX_CHECK(OMX_GetParameter(this->handle, OMX_IndexParamVideoBitrate, (OMX_PTR) &bitrate_type)); + bitrate_type.eControlRate = OMX_Video_ControlRateVariable; + bitrate_type.nTargetBitrate = bitrate; + + OMX_CHECK(OMX_SetParameter(this->handle, OMX_IndexParamVideoBitrate, (OMX_PTR) &bitrate_type)); + + if (h265) { + // setup HEVC + #ifndef QCOM2 + OMX_VIDEO_PARAM_HEVCTYPE hevc_type = {0}; + OMX_INDEXTYPE index_type = (OMX_INDEXTYPE) OMX_IndexParamVideoHevc; + #else + OMX_VIDEO_PARAM_PROFILELEVELTYPE hevc_type = {0}; + OMX_INDEXTYPE index_type = OMX_IndexParamVideoProfileLevelCurrent; + #endif + hevc_type.nSize = sizeof(hevc_type); + hevc_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT; + OMX_CHECK(OMX_GetParameter(this->handle, index_type, (OMX_PTR) &hevc_type)); + + hevc_type.eProfile = OMX_VIDEO_HEVCProfileMain; + hevc_type.eLevel = OMX_VIDEO_HEVCHighTierLevel5; + + OMX_CHECK(OMX_SetParameter(this->handle, index_type, (OMX_PTR) &hevc_type)); + } else { + // setup h264 + OMX_VIDEO_PARAM_AVCTYPE avc = { 0 }; + avc.nSize = sizeof(avc); + avc.nPortIndex = (OMX_U32) PORT_INDEX_OUT; + OMX_CHECK(OMX_GetParameter(this->handle, OMX_IndexParamVideoAvc, &avc)); + + avc.nBFrames = 0; + avc.nPFrames = 15; + + avc.eProfile = OMX_VIDEO_AVCProfileHigh; + avc.eLevel = OMX_VIDEO_AVCLevel31; + + avc.nAllowedPictureTypes |= OMX_VIDEO_PictureTypeB; + avc.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable; + + avc.nRefFrames = 1; + avc.bUseHadamard = OMX_TRUE; + avc.bEntropyCodingCABAC = OMX_TRUE; + avc.bWeightedPPrediction = OMX_TRUE; + avc.bconstIpred = OMX_TRUE; + + OMX_CHECK(OMX_SetParameter(this->handle, OMX_IndexParamVideoAvc, &avc)); + } + + + // for (int i = 0; ; i++) { + // OMX_VIDEO_PARAM_PORTFORMATTYPE video_port_format = {0}; + // video_port_format.nSize = sizeof(video_port_format); + // video_port_format.nIndex = i; + // video_port_format.nPortIndex = PORT_INDEX_IN; + // if (OMX_GetParameter(this->handle, OMX_IndexParamVideoPortFormat, &video_port_format) != OMX_ErrorNone) + // break; + // printf("in %d: compression 0x%x format 0x%x %s\n", i, + // video_port_format.eCompressionFormat, video_port_format.eColorFormat, + // omx_color_fomat_name(video_port_format.eColorFormat)); + // } + + // for (int i=0; i<32; i++) { + // OMX_VIDEO_PARAM_PROFILELEVELTYPE params = {0}; + // params.nSize = sizeof(params); + // params.nPortIndex = PORT_INDEX_OUT; + // params.nProfileIndex = i; + // if (OMX_GetParameter(this->handle, OMX_IndexParamVideoProfileLevelQuerySupported, ¶ms) != OMX_ErrorNone) + // break; + // printf("profile %d level 0x%x\n", params.eProfile, params.eLevel); + // } + + OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateIdle, NULL)); + + for (auto &buf : this->in_buf_headers) { + OMX_CHECK(OMX_AllocateBuffer(this->handle, &buf, PORT_INDEX_IN, this, + in_port.nBufferSize)); + } + + for (auto &buf : this->out_buf_headers) { + OMX_CHECK(OMX_AllocateBuffer(this->handle, &buf, PORT_INDEX_OUT, this, + out_port.nBufferSize)); + } + + wait_for_state(OMX_StateIdle); + + OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateExecuting, NULL)); + + wait_for_state(OMX_StateExecuting); + + // give omx all the output buffers + for (auto &buf : this->out_buf_headers) { + // printf("fill %p\n", this->out_buf_headers[i]); + OMX_CHECK(OMX_FillThisBuffer(this->handle, buf)); + } + + // fill the input free queue + for (auto &buf : this->in_buf_headers) { + this->free_in.push(buf); + } +} + +void OmxEncoder::handle_out_buf(OmxEncoder *e, OMX_BUFFERHEADERTYPE *out_buf) { + int err; + uint8_t *buf_data = out_buf->pBuffer + out_buf->nOffset; + + if (out_buf->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { + if (e->codec_config_len < out_buf->nFilledLen) { + e->codec_config = (uint8_t *)realloc(e->codec_config, out_buf->nFilledLen); + } + e->codec_config_len = out_buf->nFilledLen; + memcpy(e->codec_config, buf_data, out_buf->nFilledLen); +#ifdef QCOM2 + out_buf->nTimeStamp = 0; +#endif + } + + if (e->of) { + //printf("write %d flags 0x%x\n", out_buf->nFilledLen, out_buf->nFlags); + size_t written = util::safe_fwrite(buf_data, 1, out_buf->nFilledLen, e->of); + if (written != out_buf->nFilledLen) { + LOGE("failed to write file.errno=%d", errno); + } + } + + if (e->remuxing) { + if (!e->wrote_codec_config && e->codec_config_len > 0) { + // extradata will be freed by av_free() in avcodec_free_context() + e->codec_ctx->extradata = (uint8_t*)av_mallocz(e->codec_config_len + AV_INPUT_BUFFER_PADDING_SIZE); + e->codec_ctx->extradata_size = e->codec_config_len; + memcpy(e->codec_ctx->extradata, e->codec_config, e->codec_config_len); + + err = avcodec_parameters_from_context(e->out_stream->codecpar, e->codec_ctx); + assert(err >= 0); + err = avformat_write_header(e->ofmt_ctx, NULL); + assert(err >= 0); + + e->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; + + enum AVRounding rnd = static_cast(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); + pkt.pts = pkt.dts = av_rescale_q_rnd(out_buf->nTimeStamp, in_timebase, e->ofmt_ctx->streams[0]->time_base, rnd); + pkt.duration = av_rescale_q(50*1000, in_timebase, e->ofmt_ctx->streams[0]->time_base); + + if (out_buf->nFlags & OMX_BUFFERFLAG_SYNCFRAME) { + pkt.flags |= AV_PKT_FLAG_KEY; + } + + err = av_write_frame(e->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 + OMX_CHECK(OMX_FillThisBuffer(e->handle, out_buf)); +} + +int OmxEncoder::encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, + int in_width, int in_height, uint64_t ts) { + int err; + if (!this->is_open) { + return -1; + } + + // 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(&this->lock); + OMX_BUFFERHEADERTYPE* in_buf = nullptr; + while (!this->free_in.try_pop(in_buf, 20)) { + if (do_exit) { + return -1; + } + } + + //pthread_mutex_lock(&this->lock); + + int ret = this->counter; + + uint8_t *in_buf_ptr = in_buf->pBuffer; + // printf("in_buf ptr %p\n", in_buf_ptr); + + uint8_t *in_y_ptr = in_buf_ptr; + int in_y_stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, this->width); + int in_uv_stride = VENUS_UV_STRIDE(COLOR_FMT_NV12, this->width); + // uint8_t *in_uv_ptr = in_buf_ptr + (this->width * this->height); + uint8_t *in_uv_ptr = in_buf_ptr + (in_y_stride * VENUS_Y_SCANLINES(COLOR_FMT_NV12, this->height)); + + if (this->downscale) { + I420Scale(y_ptr, in_width, + u_ptr, in_width/2, + v_ptr, in_width/2, + in_width, in_height, + this->y_ptr2, this->width, + this->u_ptr2, this->width/2, + this->v_ptr2, this->width/2, + this->width, this->height, + libyuv::kFilterNone); + y_ptr = this->y_ptr2; + u_ptr = this->u_ptr2; + v_ptr = this->v_ptr2; + } + err = libyuv::I420ToNV12(y_ptr, this->width, + u_ptr, this->width/2, + v_ptr, this->width/2, + in_y_ptr, in_y_stride, + in_uv_ptr, in_uv_stride, + this->width, this->height); + assert(err == 0); + + // in_buf->nFilledLen = (this->width*this->height) + (this->width*this->height/2); + in_buf->nFilledLen = VENUS_BUFFER_SIZE(COLOR_FMT_NV12, this->width, this->height); + in_buf->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; + in_buf->nOffset = 0; + in_buf->nTimeStamp = ts/1000LL; // OMX_TICKS, in microseconds + this->last_t = in_buf->nTimeStamp; + + OMX_CHECK(OMX_EmptyThisBuffer(this->handle, in_buf)); + + // pump output + while (true) { + OMX_BUFFERHEADERTYPE *out_buf; + if (!this->done_out.try_pop(out_buf)) { + break; + } + handle_out_buf(this, out_buf); + } + + this->dirty = true; + + this->counter++; + + return ret; +} + +void OmxEncoder::encoder_open(const char* path) { + int err; + + snprintf(this->vid_path, sizeof(this->vid_path), "%s/%s", path, this->filename); + LOGD("encoder_open %s remuxing:%d", this->vid_path, this->remuxing); + + if (this->remuxing) { + avformat_alloc_output_context2(&this->ofmt_ctx, NULL, NULL, this->vid_path); + assert(this->ofmt_ctx); + + this->out_stream = avformat_new_stream(this->ofmt_ctx, NULL); + assert(this->out_stream); + + // set codec correctly + av_register_all(); + + AVCodec *codec = NULL; + codec = avcodec_find_encoder(AV_CODEC_ID_H264); + assert(codec); + + this->codec_ctx = avcodec_alloc_context3(codec); + assert(this->codec_ctx); + this->codec_ctx->width = this->width; + this->codec_ctx->height = this->height; + this->codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P; + this->codec_ctx->time_base = (AVRational){ 1, this->fps }; + + err = avio_open(&this->ofmt_ctx->pb, this->vid_path, AVIO_FLAG_WRITE); + assert(err >= 0); + + this->wrote_codec_config = false; + } else { + if (this->write) { + this->of = util::safe_fopen(this->vid_path, "wb"); + assert(this->of); +#ifndef QCOM2 + if (this->codec_config_len > 0) { + util::safe_fwrite(this->codec_config, 1, this->codec_config_len, this->of); + } +#endif + } + } + + // create camera lock file + snprintf(this->lock_path, sizeof(this->lock_path), "%s/%s.lock", path, this->filename); + int lock_fd = HANDLE_EINTR(open(this->lock_path, O_RDWR | O_CREAT, 0664)); + assert(lock_fd >= 0); + close(lock_fd); + + this->is_open = true; + this->counter = 0; +} + +void OmxEncoder::encoder_close() { + if (this->is_open) { + if (this->dirty) { + // drain output only if there could be frames in the encoder + + OMX_BUFFERHEADERTYPE* in_buf = this->free_in.pop(); + in_buf->nFilledLen = 0; + in_buf->nOffset = 0; + in_buf->nFlags = OMX_BUFFERFLAG_EOS; + in_buf->nTimeStamp = this->last_t + 1000000LL/this->fps; + + OMX_CHECK(OMX_EmptyThisBuffer(this->handle, in_buf)); + + while (true) { + OMX_BUFFERHEADERTYPE *out_buf = this->done_out.pop(); + + handle_out_buf(this, out_buf); + + if (out_buf->nFlags & OMX_BUFFERFLAG_EOS) { + break; + } + } + this->dirty = false; + } + + if (this->remuxing) { + av_write_trailer(this->ofmt_ctx); + avcodec_free_context(&this->codec_ctx); + avio_closep(&this->ofmt_ctx->pb); + avformat_free_context(this->ofmt_ctx); + } else { + if (this->of) { + util::safe_fflush(this->of); + fclose(this->of); + this->of = nullptr; + } + } + unlink(this->lock_path); + } + this->is_open = false; +} + +OmxEncoder::~OmxEncoder() { + assert(!this->is_open); + + OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateIdle, NULL)); + + wait_for_state(OMX_StateIdle); + + OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateLoaded, NULL)); + + for (auto &buf : this->in_buf_headers) { + OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_IN, buf)); + } + + for (auto &buf : this->out_buf_headers) { + OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_OUT, buf)); + } + + wait_for_state(OMX_StateLoaded); + + OMX_CHECK(OMX_FreeHandle(this->handle)); + + OMX_BUFFERHEADERTYPE *out_buf; + while (this->free_in.try_pop(out_buf)); + while (this->done_out.try_pop(out_buf)); + + if (this->codec_config) { + free(this->codec_config); + } + + if (this->downscale) { + free(this->y_ptr2); + free(this->u_ptr2); + free(this->v_ptr2); + } +} diff --git a/selfdrive/loggerd/omx_encoder.h b/selfdrive/loggerd/omx_encoder.h new file mode 100644 index 00000000000000..74ea17f640fdf5 --- /dev/null +++ b/selfdrive/loggerd/omx_encoder.h @@ -0,0 +1,73 @@ +#pragma once + +#include +#include +#include + +#include +extern "C" { +#include +} + +#include "selfdrive/common/queue.h" +#include "selfdrive/loggerd/encoder.h" + +// OmxEncoder, lossey codec using hardware hevc +class OmxEncoder : public VideoEncoder { +public: + OmxEncoder(const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale, bool write = true); + ~OmxEncoder(); + int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, + int in_width, int in_height, uint64_t ts); + void encoder_open(const char* path); + void encoder_close(); + + // OMX callbacks + static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_EVENTTYPE event, + OMX_U32 data1, OMX_U32 data2, OMX_PTR event_data); + static OMX_ERRORTYPE empty_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, + OMX_BUFFERHEADERTYPE *buffer); + static OMX_ERRORTYPE fill_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, + OMX_BUFFERHEADERTYPE *buffer); + +private: + void wait_for_state(OMX_STATETYPE state); + static void handle_out_buf(OmxEncoder *e, OMX_BUFFERHEADERTYPE *out_buf); + + int width, height, fps; + char vid_path[1024]; + char lock_path[1024]; + bool is_open = false; + bool dirty = false; + bool write = false; + int counter = 0; + + const char* filename; + FILE *of = nullptr; + + size_t codec_config_len; + uint8_t *codec_config = NULL; + bool wrote_codec_config; + + std::mutex state_lock; + std::condition_variable state_cv; + OMX_STATETYPE state = OMX_StateLoaded; + + OMX_HANDLETYPE handle; + + std::vector in_buf_headers; + std::vector out_buf_headers; + + uint64_t last_t; + + SafeQueue free_in; + SafeQueue done_out; + + AVFormatContext *ofmt_ctx; + AVCodecContext *codec_ctx; + AVStream *out_stream; + bool remuxing; + + bool downscale; + uint8_t *y_ptr2, *u_ptr2, *v_ptr2; +}; diff --git a/selfdrive/loggerd/raw_logger.cc b/selfdrive/loggerd/raw_logger.cc index 37b3f284287bc9..b0f9f7a9c817e8 100644 --- a/selfdrive/loggerd/raw_logger.cc +++ b/selfdrive/loggerd/raw_logger.cc @@ -1,30 +1,30 @@ -#include -#include -#include +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#include "selfdrive/loggerd/raw_logger.h" #include #include +#include +#include +#include + #define __STDC_CONSTANT_MACROS extern "C" { -#include #include #include +#include } -#include "common/swaglog.h" -#include "common/utilpp.h" - -#include "raw_logger.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" -RawLogger::RawLogger(const std::string &afilename, int awidth, int aheight, int afps) - : filename(afilename), - width(awidth), - height(aheight), - fps(afps) { +RawLogger::RawLogger(const char* filename, int width, int height, int fps, + int bitrate, bool h265, bool downscale, bool write) + : filename(filename), fps(fps) { - int err = 0; + // TODO: respect write arg av_register_all(); codec = avcodec_find_encoder(AV_CODEC_ID_FFVHUFF); @@ -44,7 +44,7 @@ RawLogger::RawLogger(const std::string &afilename, int awidth, int aheight, int codec_ctx->time_base = (AVRational){ 1, fps }; - err = avcodec_open2(codec_ctx, codec, NULL); + int err = avcodec_open2(codec_ctx, codec, NULL); assert(err >= 0); frame = av_frame_alloc(); @@ -63,19 +63,15 @@ RawLogger::~RawLogger() { av_free(codec_ctx); } -void RawLogger::Open(const std::string &path) { - int err = 0; - - std::lock_guard guard(lock); - - vid_path = util::string_format("%s/%s.mkv", path.c_str(), filename.c_str()); +void RawLogger::encoder_open(const char* path) { + vid_path = util::string_format("%s/%s.mkv", path, filename); // create camera lock file - lock_path = util::string_format("%s/%s.lock", path.c_str(), filename.c_str()); + lock_path = util::string_format("%s/%s.lock", path, filename); LOG("open %s\n", lock_path.c_str()); - int lock_fd = open(lock_path.c_str(), O_RDWR | O_CREAT, 0777); + int lock_fd = HANDLE_EINTR(open(lock_path.c_str(), O_RDWR | O_CREAT, 0664)); assert(lock_fd >= 0); close(lock_fd); @@ -90,7 +86,7 @@ void RawLogger::Open(const std::string &path) { stream->time_base = (AVRational){ 1, fps }; // codec_ctx->time_base = stream->time_base; - err = avcodec_parameters_from_context(stream->codecpar, codec_ctx); + int err = avcodec_parameters_from_context(stream->codecpar, codec_ctx); assert(err >= 0); err = avio_open(&format_ctx->pb, vid_path.c_str(), AVIO_FLAG_WRITE); @@ -103,14 +99,10 @@ void RawLogger::Open(const std::string &path) { counter = 0; } -void RawLogger::Close() { - int err = 0; - - std::lock_guard guard(lock); - +void RawLogger::encoder_close() { if (!is_open) return; - err = av_write_trailer(format_ctx); + int err = av_write_trailer(format_ctx); assert(err == 0); avcodec_close(stream->codec); @@ -125,9 +117,8 @@ void RawLogger::Close() { is_open = false; } -int RawLogger::ProcessFrame(uint64_t ts, const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr) { - int err = 0; - +int RawLogger::encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, + int in_width, int in_height, uint64_t ts) { AVPacket pkt; av_init_packet(&pkt); pkt.data = NULL; @@ -136,17 +127,16 @@ int RawLogger::ProcessFrame(uint64_t ts, const uint8_t *y_ptr, const uint8_t *u_ frame->data[0] = (uint8_t*)y_ptr; frame->data[1] = (uint8_t*)u_ptr; frame->data[2] = (uint8_t*)v_ptr; - frame->pts = ts; + frame->pts = counter; int ret = counter; int got_output = 0; - err = avcodec_encode_video2(codec_ctx, &pkt, frame, &got_output); + int err = avcodec_encode_video2(codec_ctx, &pkt, frame, &got_output); if (err) { LOGE("encoding error\n"); ret = -1; } else if (got_output) { - av_packet_rescale_ts(&pkt, codec_ctx->time_base, stream->time_base); pkt.stream_index = 0; @@ -159,5 +149,6 @@ int RawLogger::ProcessFrame(uint64_t ts, const uint8_t *y_ptr, const uint8_t *u_ } } + av_packet_unref(&pkt); return ret; } diff --git a/selfdrive/loggerd/raw_logger.h b/selfdrive/loggerd/raw_logger.h index 249be40db8816c..9cef7ddcabda6e 100644 --- a/selfdrive/loggerd/raw_logger.h +++ b/selfdrive/loggerd/raw_logger.h @@ -1,35 +1,36 @@ -#ifndef FFV1LOGGER_H -#define FFV1LOGGER_H +#pragma once #include #include - #include #include -#include -#include extern "C" { -#include #include #include +#include } -#include "frame_logger.h" +#include "selfdrive/loggerd/encoder.h" -class RawLogger : public FrameLogger { -public: - RawLogger(const std::string &filename, int awidth, int aheight, int afps); +class RawLogger : public VideoEncoder { + public: + RawLogger(const char* filename, int width, int height, int fps, + int bitrate, bool h265, bool downscale, bool write = true); ~RawLogger(); - - int ProcessFrame(uint64_t ts, const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr); - void Open(const std::string &path); - void Close(); + int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, + int in_width, int in_height, uint64_t ts); + void encoder_open(const char* path); + void encoder_close(); private: - std::string filename; - int width, height, fps; + const char* filename; + //bool write; + int fps; int counter = 0; + bool is_open = false; + + std::string vid_path, lock_path; AVCodec *codec = NULL; AVCodecContext *codec_ctx = NULL; @@ -39,5 +40,3 @@ class RawLogger : public FrameLogger { AVFrame *frame = NULL; }; - -#endif 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 7cad71bf7da010..10bf218b03245c 100644 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -1,62 +1,42 @@ -#!/usr/bin/env python -import os -import re -import time -import stat +#!/usr/bin/env python3 import json +import os import random -import ctypes -import inspect import requests -import traceback import threading -import subprocess +import time +import traceback +from pathlib import Path -from collections import Counter -from selfdrive.swaglog import cloudlog +from cereal import log +import cereal.messaging as messaging +from common.api import Api +from common.params import Params +from selfdrive.hardware import TICI +from selfdrive.loggerd.xattr_cache import getxattr, setxattr from selfdrive.loggerd.config import ROOT +from selfdrive.swaglog import cloudlog -from common.params import Params -from common.api import api_get +NetworkType = log.DeviceState.NetworkType +UPLOAD_ATTR_NAME = 'user.upload' +UPLOAD_ATTR_VALUE = b'1' +allow_sleep = bool(os.getenv("UPLOADER_SLEEP", "1")) +force_wifi = os.getenv("FORCEWIFI") is not None fake_upload = os.getenv("FAKEUPLOAD") is not None -def raise_on_thread(t, exctype): - for ctid, tobj in threading._active.items(): - if tobj is t: - tid = ctid - break - 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)") - - res = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), - ctypes.py_object(exctype)) - if res == 0: - raise ValueError("invalid thread id") - elif res != 1: - # "if it returns a number greater than one, you're in trouble, - # and you should call it again with exc=NULL to revert the effect" - 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 listdir_by_creation_date(d): - times_and_paths = list(listdir_with_creation_date(d)) - return [path for _, path in sorted(times_and_paths)] +def get_directory_sort(d): + return list(map(lambda s: s.rjust(10, '0'), d.rsplit('--', 1))) + +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): @@ -68,34 +48,11 @@ def clear_locks(root): except OSError: 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 - -def is_on_hotspot(): - try: - result = subprocess.check_output(["ifconfig", "wlan0"]) - result = re.findall(r"inet addr:((\d+\.){3}\d+)", result)[0][0] - - is_android = result.startswith('192.168.43.') - is_ios = result.startswith('172.20.10.') - is_entune = result.startswith('10.0.2.') - return (is_android or is_ios or is_entune) - except: - return False - -class Uploader(object): - def __init__(self, dongle_id, access_token, root): +class Uploader(): + def __init__(self, dongle_id, root): self.dongle_id = dongle_id - self.access_token = access_token + self.api = Api(dongle_id) self.root = root self.upload_thread = None @@ -103,82 +60,92 @@ def __init__(self, dongle_id, access_token, root): self.last_resp = None self.last_exc = None - def clean_dirs(self): - try: - for logname in os.listdir(self.root): - path = os.path.join(self.root, logname) - # remove empty directories - if not os.listdir(path): - os.rmdir(path) - except OSError: - cloudlog.exception("clean_dirs failed") + self.immediate_size = 0 + self.immediate_count = 0 + + # stats for last successfully uploaded file + self.last_time = 0 + self.last_speed = 0 + self.last_filename = "" + + self.immediate_folders = ["crash/", "boot/"] + self.immediate_priority = {"qlog.bz2": 0, "qcamera.ts": 1} + + def get_upload_sort(self, name): + if name in self.immediate_priority: + return self.immediate_priority[name] + return 1000 - def gen_upload_files(self): + def list_upload_files(self): if not os.path.isdir(self.root): return - for logname in listdir_by_creation_date(self.root): + + self.immediate_size = 0 + self.immediate_count = 0 + + for logname in listdir_by_creation(self.root): path = os.path.join(self.root, logname) try: names = os.listdir(path) except OSError: continue + 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 + + try: + if name in self.immediate_priority: + self.immediate_count += 1 + self.immediate_size += os.path.getsize(fn) + except OSError: + pass 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): - # try to upload qlog files first - for name, key, fn in self.gen_upload_files(): - if name == "qlog.bz2": - return (key, fn, 0) - - 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 other files - for name, key, fn in self.gen_upload_files(): - if not name.endswith('.lock') and not name.endswith(".tmp"): - return (key, fn, 4) + def next_file_to_upload(self): + upload_files = list(self.list_upload_files()) - return None + for name, key, fn in upload_files: + if any(f in fn for f in self.immediate_folders): + return (key, fn) + + for name, key, fn in upload_files: + if name in self.immediate_priority: + return (key, fn) + return None def do_upload(self, key, fn): try: - url_resp = api_get("v1.2/"+self.dongle_id+"/upload_url/", timeout=2, path=key, access_token=self.access_token) + url_resp = self.api.get("v1.4/" + 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'] - cloudlog.info("upload_url v1.2 %s %s", url, str(headers)) + cloudlog.debug("upload_url v1.4 %s %s", url, str(headers)) if fake_upload: - cloudlog.info("*** WARNING, THIS IS A FAKE UPLOAD TO %s ***" % url) - class FakeResponse(object): + cloudlog.debug("*** WARNING, THIS IS A FAKE UPLOAD TO %s ***" % url) + + class FakeResponse(): def __init__(self): self.status_code = 200 + self.last_resp = FakeResponse() else: with open(fn, "rb") as f: @@ -207,78 +174,95 @@ def upload(self, key, fn): cloudlog.event("upload", key=key, fn=fn, sz=sz) - cloudlog.info("checking %r with size %r", key, sz) + cloudlog.debug("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) + start_time = time.monotonic() + cloudlog.debug("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, 403, 412): + cloudlog.event("upload_success" if stat.status_code != 412 else "upload_ignored", key=key, fn=fn, sz=sz, debug=True) try: - os.unlink(fn) + # tag file as uploaded + setxattr(fn, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE) except OSError: - cloudlog.exception("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) + self.last_filename = fn + self.last_time = time.monotonic() - start_time + self.last_speed = (sz / 1e6) / self.last_time success = True else: - cloudlog.event("upload_failed", stat=stat, exc=self.last_exc, key=key, fn=fn, sz=sz) + cloudlog.event("upload_failed", stat=stat, exc=self.last_exc, key=key, fn=fn, sz=sz, debug=True) success = False - self.clean_dirs() - return success - + def get_msg(self): + msg = messaging.new_message("uploaderState") + us = msg.uploaderState + us.immediateQueueSize = int(self.immediate_size / 1e6) + us.immediateQueueCount = self.immediate_count + us.lastTime = self.last_time + us.lastSpeed = self.last_speed + us.lastFilename = self.last_filename + return msg def uploader_fn(exit_event): - cloudlog.info("uploader_fn") - params = Params() - dongle_id, access_token = params.get("DongleId"), params.get("AccessToken") + dongle_id = params.get("DongleId", encoding='utf8') - if dongle_id is None or access_token is None: - cloudlog.info("uploader MISSING DONGLE_ID or ACCESS_TOKEN") - raise Exception("uploader can't start without dongle id and access token") + if dongle_id is None: + cloudlog.info("uploader missing dongle_id") + raise Exception("uploader can't start without dongle id") - uploader = Uploader(dongle_id, access_token, ROOT) + if TICI and not Path("/data/media").is_mount(): + cloudlog.warning("NVME not mounted") + + sm = messaging.SubMaster(['deviceState']) + pm = messaging.PubMaster(['uploaderState']) + 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 + while not exit_event.is_set(): + sm.update(0) + offroad = params.get_bool("IsOffroad") + network_type = sm['deviceState'].networkType if not force_wifi else NetworkType.wifi + if network_type == NetworkType.none: + if allow_sleep: + time.sleep(60 if offroad else 5) + continue - d = uploader.next_file_to_upload(with_raw=allow_raw_upload and should_upload) - if d is None: - time.sleep(5) + d = uploader.next_file_to_upload() + if d is None: # Nothing to upload + if allow_sleep: + 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.info("to upload %r", d) + cloudlog.debug("upload %r over %s", d, network_type) success = uploader.upload(key, fn) if success: backoff = 0.1 - else: - cloudlog.info("backoff %r", backoff) + elif allow_sleep: + cloudlog.info("upload backoff %r", backoff) time.sleep(backoff + random.uniform(0, backoff)) backoff = min(backoff*2, 120) + + pm.send("uploaderState", uploader.get_msg()) 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..9c40976562abd9 100755 --- a/selfdrive/logmessaged.py +++ b/selfdrive/logmessaged.py @@ -1,40 +1,36 @@ -#!/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 +from typing import NoReturn -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) +import cereal.messaging as messaging +from common.logging_extra import SwagLogFileFormatter +from selfdrive.swaglog import get_file_handler - le_level = 20 #logging.INFO + +def main() -> NoReturn: + log_handler = get_file_handler() + log_handler.setFormatter(SwagLogFileFormatter(None)) + log_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()) - - # print "RECV", repr(dat) - - levelnum = ord(dat[0]) - dat = dat[1:] - - if levelnum >= le_level: - # push to logentries - # TODO: push to athena instead - le_handler.emit_raw(dat) + dat = b''.join(sock.recv_multipart()) + level = dat[0] + record = dat[1:].decode("utf-8") + if level >= log_level: + log_handler.emit(record) # then we publish them msg = messaging.new_message() - msg.logMessage = dat + msg.logMessage = record pub_sock.send(msg.to_bytes()) + if __name__ == "__main__": main() diff --git a/selfdrive/manager.py b/selfdrive/manager.py deleted file mode 100755 index c3be2c094d09ed..00000000000000 --- a/selfdrive/manager.py +++ /dev/null @@ -1,545 +0,0 @@ -#!/usr/bin/env python2.7 -import os -import sys -import fcntl -import errno -import signal -import subprocess - -from common.basedir import BASEDIR -sys.path.append(os.path.join(BASEDIR, "pyextra")) -os.environ['BASEDIR'] = BASEDIR - -def unblock_stdout(): - # get a non-blocking stdout - child_pid, child_pty = os.forkpty() - 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) - - while True: - try: - dat = os.read(child_pty, 4096) - except OSError as e: - if e.errno == errno.EIO: - break - continue - - if not dat: - break - - try: - sys.stdout.write(dat) - except (OSError, IOError): - pass - - os._exit(os.wait()[1]) - -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 != 3) - - 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") - - unblock_stdout() - -import glob -import shutil -import hashlib -import importlib -import subprocess -import traceback -from multiprocessing import Process - -from setproctitle import setproctitle #pylint: disable=no-name-in-module - -from common.params import Params -import cereal -ThermalStatus = cereal.log.ThermalData.ThermalStatus - -from selfdrive.services import service_list -from selfdrive.swaglog import cloudlog -import selfdrive.messaging as messaging -from selfdrive.registration import register -from selfdrive.version import version, dirty -import selfdrive.crash as crash - -from selfdrive.loggerd.config import ROOT - -# comment out anything you don't want to run -managed_processes = { - "thermald": "selfdrive.thermald", - "uploader": "selfdrive.loggerd.uploader", - "deleter": "selfdrive.loggerd.deleter", - "controlsd": "selfdrive.controls.controlsd", - "plannerd": "selfdrive.controls.plannerd", - "radard": "selfdrive.controls.radard", - "ubloxd": ("selfdrive/locationd", ["./ubloxd"]), - "loggerd": ("selfdrive/loggerd", ["./loggerd"]), - "logmessaged": "selfdrive.logmessaged", - "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"]), - "calibrationd": "selfdrive.locationd.calibrationd", - "params_learner": ("selfdrive/locationd", ["./params_learner"]), - "visiond": ("selfdrive/visiond", ["./visiond"]), - "sensord": ("selfdrive/sensord", ["./start_sensord.py"]), - "gpsd": ("selfdrive/sensord", ["./start_gpsd.py"]), - "updated": "selfdrive.updated", - "athena": "selfdrive.athena.athenad", -} -android_packages = ("ai.comma.plus.offroad", "ai.comma.plus.frame") - -running = {} -def get_running(): - return running - -# due to qualcomm kernel bugs SIGKILLing visiond sometimes causes page table corruption -unkillable_processes = ['visiond'] - -# processes to end with SIGINT instead of SIGTERM -interrupt_processes = [] - -persistent_processes = [ - 'thermald', - 'logmessaged', - 'logcatd', - 'tombstoned', - 'uploader', - 'ui', - 'updated', - 'athena', -] - -car_started_processes = [ - 'controlsd', - 'plannerd', - 'loggerd', - 'sensord', - 'radard', - 'calibrationd', - 'params_learner', - 'visiond', - 'proclogd', - 'ubloxd', - 'gpsd', - 'deleter', -] - -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) - else: - 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) - - # because when extracted from pex zips permissions get lost -_- - os.chmod(pargs[0], 0o700) - - os.execvp(pargs[0], pargs) - -def start_managed_process(name): - if name in running or name not in managed_processes: - return - proc = managed_processes[name] - if isinstance(proc, str): - cloudlog.info("starting python %s" % proc) - running[name] = Process(name=name, target=launcher, args=(proc,)) - else: - pdir, pargs = proc - cwd = os.path.join(BASEDIR, pdir) - cloudlog.info("starting process %s" % name) - running[name] = Process(name=name, target=nativelauncher, args=(pargs, cwd)) - running[name].start() - -def prepare_managed_process(p): - proc = managed_processes[p] - if isinstance(proc, str): - # import this python - cloudlog.info("preimporting %s" % proc) - importlib.import_module(proc) - else: - # build this process - cloudlog.info("building %s" % (proc,)) - try: - subprocess.check_call(["make", "-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])) - -def kill_managed_process(name): - if name not in running or name not in managed_processes: - return - cloudlog.info("killing %s" % name) - - if running[name].exitcode is None: - if name in interrupt_processes: - os.kill(running[name].pid, signal.SIGINT) - else: - running[name].terminate() - - # give it 5 seconds to die - running[name].join(5.0) - 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) - if running[name].exitcode is None: - cloudlog.critical("FORCE REBOOTING PHONE!") - os.system("date >> /sdcard/unkillable_reboot") - os.system("reboot") - raise RuntimeError - else: - cloudlog.info("killing %s with SIGKILL" % name) - os.kill(running[name].pid, signal.SIGKILL) - running[name].join() - - 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') - - for name in list(running.keys()): - kill_managed_process(name) - cloudlog.info("everything is dead") - - -# ****************** 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 - - # set dongle id - cloudlog.info("dongle id is " + dongle_id) - os.environ['DONGLE_ID'] = dongle_id - - cloudlog.info("dirty is %d" % dirty) - if not dirty: - os.environ['CLEAN'] = '1' - - 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) - - os.umask(0) - try: - os.mkdir(ROOT, 0o777) - 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 manager_thread(): - # now loop - thermal_sock = messaging.sub_sock(service_list['thermal'].port) - - cloudlog.info("manager start") - cloudlog.info({"environ": os.environ}) - - # save boot log - subprocess.call(["./loggerd", "--bootlog"], cwd=os.path.join(BASEDIR, "selfdrive/loggerd")) - - # 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") - - if os.getenv("NOBOARD") is None: - start_managed_process("pandad") - - params = Params() - logger_dead = False - - while 1: - # get health of board, log this in "thermal" - 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") - - if msg.thermal.freeSpace < 0.05: - logger_dead = True - - if msg.thermal.started: - for p in car_started_processes: - if p == "loggerd" and logger_dead: - kill_managed_process(p) - else: - start_managed_process(p) - else: - logger_dead = 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)) - - # 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 manager_update(): - if os.path.exists(os.path.join(BASEDIR, "vpn")): - cloudlog.info("installing vpn") - os.system(os.path.join(BASEDIR, "vpn", "install.sh")) - update_apks() - -def manager_prepare(): - # build cereal first - subprocess.check_call(["make", "-j4"], cwd=os.path.join(BASEDIR, "cereal")) - - # 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") - -def main(): - # the flippening! - os.system('LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1') - - 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 - - params = Params() - params.manager_start() - - # 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") - - # is this chffrplus? - 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 os.getenv("PREPAREONLY") is not None: - return - - # SystemExit on sigterm - signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(1)) - - try: - manager_thread() - except Exception: - traceback.print_exc() - crash.capture_exception() - finally: - cleanup_all_processes(None, None) - - if params.get("DoUninstall") == "1": - uninstall() - -if __name__ == "__main__": - main() - # manual exit because we are forked - sys.exit(0) diff --git a/selfdrive/test/plant/__init__.py b/selfdrive/manager/__init__.py similarity index 100% rename from selfdrive/test/plant/__init__.py rename to selfdrive/manager/__init__.py diff --git a/selfdrive/manager/build.py b/selfdrive/manager/build.py new file mode 100755 index 00000000000000..078f18fd29e276 --- /dev/null +++ b/selfdrive/manager/build.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +import os +import subprocess +import sys +import time +import textwrap +from pathlib import Path + +# NOTE: Do NOT import anything here that needs be built (e.g. params) +from common.basedir import BASEDIR +from common.spinner import Spinner +from common.text_window import TextWindow +from selfdrive.hardware import TICI +from selfdrive.swaglog import cloudlog, add_file_handler +from selfdrive.version import get_dirty + +MAX_CACHE_SIZE = 4e9 if "CI" in os.environ else 2e9 +CACHE_DIR = Path("/data/scons_cache" if TICI else "/tmp/scons_cache") + +TOTAL_SCONS_NODES = 2405 +MAX_BUILD_PROGRESS = 100 +PREBUILT = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) + + +def build(spinner, dirty=False): + env = os.environ.copy() + env['SCONS_PROGRESS'] = "1" + nproc = os.cpu_count() + j_flag = "" if nproc is None else f"-j{nproc - 1}" + + for retry in [True, False]: + scons = subprocess.Popen(["scons", j_flag, "--cache-populate"], 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() + if line is None: + continue + line = line.rstrip() + + prefix = b'progress: ' + if line.startswith(prefix): + i = int(line[len(prefix):]) + spinner.update_progress(MAX_BUILD_PROGRESS * min(1., i / TOTAL_SCONS_NODES), 100.) + 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') + compile_output += r + + if retry and (not dirty): + if not os.getenv("CI"): + print("scons build failed, cleaning in") + for i in range(3, -1, -1): + print("....%d" % i) + time.sleep(1) + subprocess.check_call(["scons", "-c"], cwd=BASEDIR, env=env) + 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_file_handler(cloudlog) + cloudlog.error("scons build failed\n" + error_s) + + # Show TextWindow + spinner.close() + if not os.getenv("CI"): + 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 + + # enforce max cache size + cache_files = [f for f in CACHE_DIR.rglob('*') if f.is_file()] + cache_files.sort(key=lambda f: f.stat().st_mtime) + cache_size = sum(f.stat().st_size for f in cache_files) + for f in cache_files: + if cache_size < MAX_CACHE_SIZE: + break + cache_size -= f.stat().st_size + f.unlink() + + +if __name__ == "__main__" and not PREBUILT: + spinner = Spinner() + spinner.update_progress(0, 100) + build(spinner, get_dirty()) diff --git a/selfdrive/manager/helpers.py b/selfdrive/manager/helpers.py new file mode 100644 index 00000000000000..fdda0deb9ac002 --- /dev/null +++ b/selfdrive/manager/helpers.py @@ -0,0 +1,38 @@ +import os +import sys +import fcntl +import errno +import signal + + +def unblock_stdout(): + # get a non-blocking stdout + child_pid, child_pty = os.forkpty() + 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) + + while True: + try: + dat = os.read(child_pty, 4096) + except OSError as e: + if e.errno == errno.EIO: + break + continue + + if not dat: + break + + try: + sys.stdout.write(dat.decode('utf8')) + except (OSError, IOError, UnicodeDecodeError): + pass + + # 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) diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py new file mode 100755 index 00000000000000..386876b6921635 --- /dev/null +++ b/selfdrive/manager/manager.py @@ -0,0 +1,233 @@ +#!/usr/bin/env python3 +import datetime +import os +import signal +import subprocess +import sys +import traceback + +import cereal.messaging as messaging +import selfdrive.crash as crash +from common.basedir import BASEDIR +from common.params import Params, ParamKeyType +from common.text_window import TextWindow +from selfdrive.boardd.set_time import set_time +from selfdrive.hardware import HARDWARE, PC +from selfdrive.manager.helpers import unblock_stdout +from selfdrive.manager.process import ensure_running +from selfdrive.manager.process_config import managed_processes +from selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID +from selfdrive.swaglog import cloudlog, add_file_handler +from selfdrive.version import get_dirty, get_commit, get_version, get_origin, get_short_branch, \ + terms_version, training_version, get_comma_remote + + +sys.path.append(os.path.join(BASEDIR, "pyextra")) + + +def manager_init(): + # update system time from panda + set_time(cloudlog) + + # save boot log + subprocess.call("./bootlog", cwd=os.path.join(BASEDIR, "selfdrive/loggerd")) + + params = Params() + params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START) + + default_params = [ + ("CompletedTrainingVersion", "0"), + ("HasAcceptedTerms", "0"), + ("OpenpilotEnabledToggle", "1"), + ] + if not PC: + default_params.append(("LastUpdateTime", datetime.datetime.utcnow().isoformat().encode('utf8'))) + + if params.get_bool("RecordFrontLock"): + params.put_bool("RecordFront", True) + + if not params.get_bool("DisableRadar_Allow"): + params.delete("DisableRadar") + + # set unset params + 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_bool("Passive", bool(int(os.getenv("PASSIVE")))) + + if params.get("Passive") is None: + raise Exception("Passive must be set to continue") + + # Create folders needed for msgq + try: + os.mkdir("/dev/shm") + except FileExistsError: + pass + except PermissionError: + print("WARNING: failed to make /dev/shm") + + # set version params + params.put("Version", get_version()) + params.put("TermsVersion", terms_version) + params.put("TrainingVersion", training_version) + params.put("GitCommit", get_commit(default="")) + params.put("GitBranch", get_short_branch(default="")) + params.put("GitRemote", get_origin(default="")) + + # set dongle id + reg_res = register(show_spinner=True) + if reg_res: + dongle_id = reg_res + else: + serial = params.get("HardwareSerial") + raise Exception(f"Registration failed for device {serial}") + os.environ['DONGLE_ID'] = dongle_id # Needed for swaglog + + if not get_dirty(): + os.environ['CLEAN'] = '1' + + cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=get_dirty(), + device=HARDWARE.get_device_type()) + + if get_comma_remote() and not (os.getenv("NOLOG") or os.getenv("NOCRASH") or PC): + crash.init() + crash.bind_user(id=dongle_id) + crash.bind_extra(dirty=get_dirty(), origin=get_origin(), branch=get_short_branch(), commit=get_commit(), + device=HARDWARE.get_device_type()) + + +def manager_prepare(): + for p in managed_processes.values(): + p.prepare() + + +def manager_cleanup(): + # send signals to kill all procs + for p in managed_processes.values(): + p.stop(block=False) + + # ensure all are killed + for p in managed_processes.values(): + p.stop(block=True) + + cloudlog.info("everything is dead") + + +def manager_thread(): + cloudlog.info("manager start") + cloudlog.info({"environ": os.environ}) + + params = Params() + + ignore = [] + if params.get("DongleId", encoding='utf8') == UNREGISTERED_DONGLE_ID: + ignore += ["manage_athenad", "uploader"] + if os.getenv("NOBOARD") is not None: + ignore.append("pandad") + if os.getenv("BLOCK") is not None: + ignore += os.getenv("BLOCK").split(",") + + ensure_running(managed_processes.values(), started=False, not_run=ignore) + + started_prev = False + sm = messaging.SubMaster(['deviceState']) + pm = messaging.PubMaster(['managerState']) + + while True: + sm.update() + not_run = ignore[:] + + if sm['deviceState'].freeSpacePercent < 5: + not_run.append("loggerd") + + started = sm['deviceState'].started + driverview = params.get_bool("IsDriverViewEnabled") + ensure_running(managed_processes.values(), started, driverview, not_run) + + # trigger an update after going offroad + if started_prev and not started and 'updated' in managed_processes: + os.sync() + managed_processes['updated'].signal(signal.SIGHUP) + + started_prev = started + + running = ' '.join("%s%s\u001b[0m" % ("\u001b[32m" if p.proc.is_alive() else "\u001b[31m", p.name) + for p in managed_processes.values() if p.proc) + print(running) + cloudlog.debug(running) + + # send managerState + msg = messaging.new_message('managerState') + msg.managerState.processes = [p.get_process_state_msg() for p in managed_processes.values()] + pm.send('managerState', msg) + + # Exit main loop when uninstall/shutdown/reboot is needed + shutdown = False + for param in ("DoUninstall", "DoShutdown", "DoReboot"): + if params.get_bool(param): + cloudlog.warning(f"Shutting down manager - {param} set") + shutdown = True + + if shutdown: + break + + +def main(): + prepare_only = os.getenv("PREPAREONLY") is not None + + manager_init() + + # Start UI early so prepare can happen in the background + if not prepare_only: + managed_processes['ui'].start() + + manager_prepare() + + if prepare_only: + return + + # SystemExit on sigterm + signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(1)) + + try: + manager_thread() + except Exception: + traceback.print_exc() + crash.capture_exception() + finally: + manager_cleanup() + + params = Params() + if params.get_bool("DoUninstall"): + cloudlog.warning("uninstalling") + HARDWARE.uninstall() + elif params.get_bool("DoReboot"): + cloudlog.warning("reboot") + HARDWARE.reboot() + elif params.get_bool("DoShutdown"): + cloudlog.warning("shutdown") + HARDWARE.shutdown() + + +if __name__ == "__main__": + unblock_stdout() + + try: + main() + except Exception: + add_file_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 + with TextWindow(error) as t: + t.wait_for_exit() + + raise + + # manual exit because we are forked + sys.exit(0) diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py new file mode 100644 index 00000000000000..d9a1619411a390 --- /dev/null +++ b/selfdrive/manager/process.py @@ -0,0 +1,292 @@ +import importlib +import os +import signal +import struct +import time +import subprocess +from abc import ABC, abstractmethod +from multiprocessing import Process + +from setproctitle import setproctitle # pylint: disable=no-name-in-module + +import cereal.messaging as messaging +import selfdrive.crash as crash +from common.basedir import BASEDIR +from common.params import Params +from common.realtime import sec_since_boot +from selfdrive.swaglog import cloudlog +from selfdrive.hardware import HARDWARE +from cereal import log + +WATCHDOG_FN = "/dev/shm/wd_" +ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None + + +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 because 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) + os.execvp(pargs[0], pargs) + + +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.monotonic() + while time.monotonic() - t < timeout and process.exitcode is None: + time.sleep(0.001) + + +class ManagerProcess(ABC): + unkillable = False + daemon = False + sigkill = False + proc = None + enabled = True + name = "" + + last_watchdog_time = 0 + watchdog_max_dt = None + watchdog_seen = False + shutting_down = False + + @abstractmethod + def prepare(self): + pass + + @abstractmethod + def start(self): + pass + + def restart(self): + self.stop() + self.start() + + def check_watchdog(self, started): + if self.watchdog_max_dt is None or self.proc is None: + return + + try: + fn = WATCHDOG_FN + str(self.proc.pid) + self.last_watchdog_time = struct.unpack('Q', open(fn, "rb").read())[0] + except Exception: + pass + + dt = sec_since_boot() - self.last_watchdog_time / 1e9 + + if dt > self.watchdog_max_dt: + # Only restart while offroad for now + if self.watchdog_seen and ENABLE_WATCHDOG: + cloudlog.error(f"Watchdog timeout for {self.name} (exitcode {self.proc.exitcode}) restarting ({started=})") + self.restart() + else: + self.watchdog_seen = True + + def stop(self, retry=True, block=True): + if self.proc is None: + return + + if self.proc.exitcode is None: + if not self.shutting_down: + cloudlog.info(f"killing {self.name}") + sig = signal.SIGKILL if self.sigkill else signal.SIGINT + self.signal(sig) + self.shutting_down = True + + if not block: + return + + join_process(self.proc, 5) + + # If process failed to die send SIGKILL or reboot + if self.proc.exitcode is None and retry: + if self.unkillable: + cloudlog.critical(f"unkillable process {self.name} failed to exit! rebooting in 15 if it doesn't die") + join_process(self.proc, 15) + + if self.proc.exitcode is None: + cloudlog.critical(f"unkillable process {self.name} failed to die!") + os.system("date >> /data/unkillable_reboot") + os.sync() + HARDWARE.reboot() + raise RuntimeError + else: + cloudlog.info(f"killing {self.name} with SIGKILL") + self.signal(signal.SIGKILL) + self.proc.join() + + ret = self.proc.exitcode + cloudlog.info(f"{self.name} is dead with {ret}") + + if self.proc.exitcode is not None: + self.shutting_down = False + self.proc = None + + return ret + + def signal(self, sig): + if self.proc is None: + return + + # Don't signal if already exited + if self.proc.exitcode is not None and self.proc.pid is not None: + return + + cloudlog.info(f"sending signal {sig} to {self.name}") + os.kill(self.proc.pid, sig) + + def get_process_state_msg(self): + state = log.ManagerState.ProcessState.new_message() + state.name = self.name + if self.proc: + state.running = self.proc.is_alive() + state.shouldBeRunning = self.proc is not None and not self.shutting_down + state.pid = self.proc.pid or 0 + state.exitCode = self.proc.exitcode or 0 + return state + + +class NativeProcess(ManagerProcess): + def __init__(self, name, cwd, cmdline, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False, watchdog_max_dt=None): + self.name = name + self.cwd = cwd + self.cmdline = cmdline + self.enabled = enabled + self.persistent = persistent + self.driverview = driverview + self.unkillable = unkillable + self.sigkill = sigkill + self.watchdog_max_dt = watchdog_max_dt + + def prepare(self): + pass + + def start(self): + # In case we only tried a non blocking stop we need to stop it before restarting + if self.shutting_down: + self.stop() + + if self.proc is not None: + return + + cwd = os.path.join(BASEDIR, self.cwd) + cloudlog.info("starting process %s" % self.name) + self.proc = Process(name=self.name, target=nativelauncher, args=(self.cmdline, cwd)) + self.proc.start() + self.watchdog_seen = False + self.shutting_down = False + + +class PythonProcess(ManagerProcess): + def __init__(self, name, module, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False, watchdog_max_dt=None): + self.name = name + self.module = module + self.enabled = enabled + self.persistent = persistent + self.driverview = driverview + self.unkillable = unkillable + self.sigkill = sigkill + self.watchdog_max_dt = watchdog_max_dt + + def prepare(self): + if self.enabled: + cloudlog.info("preimporting %s" % self.module) + importlib.import_module(self.module) + + def start(self): + # In case we only tried a non blocking stop we need to stop it before restarting + if self.shutting_down: + self.stop() + + if self.proc is not None: + return + + cloudlog.info("starting python %s" % self.module) + self.proc = Process(name=self.name, target=launcher, args=(self.module,)) + self.proc.start() + self.watchdog_seen = False + self.shutting_down = False + + +class DaemonProcess(ManagerProcess): + """Python process that has to stay running across manager restart. + This is used for athena so you don't lose SSH access when restarting manager.""" + def __init__(self, name, module, param_name, enabled=True): + self.name = name + self.module = module + self.param_name = param_name + self.enabled = enabled + self.persistent = True + + def prepare(self): + pass + + def start(self): + params = Params() + pid = params.get(self.param_name, encoding='utf-8') + + if pid is not None: + try: + os.kill(int(pid), 0) + with open(f'/proc/{pid}/cmdline') as f: + if self.module in f.read(): + # daemon is running + return + except (OSError, FileNotFoundError): + # process is dead + pass + + cloudlog.info("starting daemon %s" % self.name) + proc = subprocess.Popen(['python', '-m', self.module], # 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(self.param_name, str(proc.pid)) + + def stop(self, retry=True, block=True): + pass + + +def ensure_running(procs, started, driverview=False, not_run=None): + if not_run is None: + not_run = [] + + for p in procs: + if p.name in not_run: + p.stop(block=False) + elif not p.enabled: + p.stop(block=False) + elif p.persistent: + p.start() + elif p.driverview and driverview: + p.start() + elif started: + p.start() + else: + p.stop(block=False) + + p.check_watchdog(started) + diff --git a/selfdrive/manager/process_config.py b/selfdrive/manager/process_config.py new file mode 100644 index 00000000000000..2e3741350eb5b0 --- /dev/null +++ b/selfdrive/manager/process_config.py @@ -0,0 +1,45 @@ +import os + +from selfdrive.manager.process import PythonProcess, NativeProcess, DaemonProcess +from selfdrive.hardware import EON, TICI, PC + +WEBCAM = os.getenv("USE_WEBCAM") is not None + +procs = [ + DaemonProcess("manage_athenad", "selfdrive.athena.manage_athenad", "AthenadPid"), + # due to qualcomm kernel bugs SIGKILLing camerad sometimes causes page table corruption + NativeProcess("camerad", "selfdrive/camerad", ["./camerad"], unkillable=True, driverview=True), + NativeProcess("clocksd", "selfdrive/clocksd", ["./clocksd"]), + NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], enabled=(not PC or WEBCAM), driverview=True), + NativeProcess("logcatd", "selfdrive/logcatd", ["./logcatd"]), + NativeProcess("loggerd", "selfdrive/loggerd", ["./loggerd"]), + NativeProcess("modeld", "selfdrive/modeld", ["./modeld"]), + NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], enabled=(PC or TICI), persistent=True), + NativeProcess("proclogd", "selfdrive/proclogd", ["./proclogd"]), + NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], enabled=not PC, persistent=EON, sigkill=EON), + NativeProcess("ubloxd", "selfdrive/locationd", ["./ubloxd"], enabled=(not PC or WEBCAM)), + NativeProcess("ui", "selfdrive/ui", ["./ui"], persistent=True, watchdog_max_dt=(5 if TICI else None)), + NativeProcess("soundd", "selfdrive/ui/soundd", ["./soundd"], persistent=True), + NativeProcess("locationd", "selfdrive/locationd", ["./locationd"]), + NativeProcess("boardd", "selfdrive/boardd", ["./boardd"], enabled=False), + PythonProcess("calibrationd", "selfdrive.locationd.calibrationd"), + PythonProcess("controlsd", "selfdrive.controls.controlsd"), + PythonProcess("deleter", "selfdrive.loggerd.deleter", persistent=True), + PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", enabled=(not PC or WEBCAM), driverview=True), + PythonProcess("logmessaged", "selfdrive.logmessaged", persistent=True), + PythonProcess("pandad", "selfdrive.pandad", persistent=True), + PythonProcess("paramsd", "selfdrive.locationd.paramsd"), + PythonProcess("plannerd", "selfdrive.controls.plannerd"), + PythonProcess("radard", "selfdrive.controls.radard"), + PythonProcess("thermald", "selfdrive.thermald.thermald", persistent=True), + PythonProcess("timezoned", "selfdrive.timezoned", enabled=TICI, persistent=True), + PythonProcess("tombstoned", "selfdrive.tombstoned", enabled=not PC, persistent=True), + PythonProcess("updated", "selfdrive.updated", enabled=not PC, persistent=True), + PythonProcess("uploader", "selfdrive.loggerd.uploader", persistent=True), + + # EON only + PythonProcess("rtshield", "selfdrive.rtshield", enabled=EON), + PythonProcess("androidd", "selfdrive.hardware.eon.androidd", enabled=EON, persistent=True), +] + +managed_processes = {p.name: p for p in procs} diff --git a/selfdrive/test/tests/plant/__init__.py b/selfdrive/manager/test/__init__.py similarity index 100% rename from selfdrive/test/tests/plant/__init__.py rename to selfdrive/manager/test/__init__.py diff --git a/selfdrive/manager/test/test_manager.py b/selfdrive/manager/test/test_manager.py new file mode 100755 index 00000000000000..d16a145031df08 --- /dev/null +++ b/selfdrive/manager/test/test_manager.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +import os +import signal +import time +import unittest + +import selfdrive.manager.manager as manager +from selfdrive.hardware import EON, TICI, HARDWARE +from selfdrive.manager.process import DaemonProcess +from selfdrive.manager.process_config import managed_processes + +os.environ['FAKEUPLOAD'] = "1" + +# TODO: make eon fast +MAX_STARTUP_TIME = 30 if EON else 15 +ALL_PROCESSES = [p.name for p in managed_processes.values() if (type(p) is not DaemonProcess) and p.enabled and (p.name not in ['updated', 'pandad'])] + + +class TestManager(unittest.TestCase): + def setUp(self): + os.environ['PASSIVE'] = '0' + HARDWARE.set_power_save(False) + + def tearDown(self): + manager.manager_cleanup() + + def test_manager_prepare(self): + os.environ['PREPAREONLY'] = '1' + manager.main() + + def test_startup_time(self): + for _ in range(10): + start = time.monotonic() + os.environ['PREPAREONLY'] = '1' + manager.main() + t = time.monotonic() - start + assert t < MAX_STARTUP_TIME, f"startup took {t}s, expected <{MAX_STARTUP_TIME}s" + + # ensure all processes exit cleanly + def test_clean_exit(self): + HARDWARE.set_power_save(False) + manager.manager_prepare() + for p in ALL_PROCESSES: + managed_processes[p].start() + + time.sleep(10) + + for p in reversed(ALL_PROCESSES): + state = managed_processes[p].get_process_state_msg() + self.assertTrue(state.running, f"{p} not running") + + exit_code = managed_processes[p].stop(retry=False) + if (TICI and p in ['ui', 'navd']) or (EON and p == 'logcatd'): + # TODO: make Qt UI exit gracefully + continue + + # Make sure the process is actually dead + managed_processes[p].stop() + + # TODO: interrupted blocking read exits with 1 in cereal. use a more unique return code + exit_codes = [0, 1] + if managed_processes[p].sigkill: + exit_codes = [-signal.SIGKILL] + assert exit_code in exit_codes, f"{p} died with {exit_code}" + + +if __name__ == "__main__": + unittest.main() diff --git a/selfdrive/messaging.py b/selfdrive/messaging.py deleted file mode 100644 index 4e78f66c817bad..00000000000000 --- a/selfdrive/messaging.py +++ /dev/null @@ -1,132 +0,0 @@ -import zmq - -from cereal import log -from common.realtime import sec_since_boot -from selfdrive.services import service_list - -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): - 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 poller is not None: - poller.register(sock, zmq.POLLIN) - return sock - -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.sock = {} - self.freq = {} - self.data = {} - self.logMonoTime = {} - self.valid = {} - for s in services: - # TODO: get address automatically from service_list - 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] = data.logMonoTime - self.valid[s] = data.valid - - def __getitem__(self, s): - return self.data[s] - - def update(self, timeout=-1): - # TODO: add optional input that specify the service to wait for - self.frame += 1 - self.updated = dict.fromkeys(self.updated, False) - cur_time = sec_since_boot() - for sock, _ in self.poller.poll(timeout): - msg = recv_one(sock) - 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): - 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..ceb3c560bcce65 --- /dev/null +++ b/selfdrive/modeld/SConscript @@ -0,0 +1,80 @@ +Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc') +lenv = env.Clone() + +libs = [cereal, messaging, common, visionipc, gpucommon, + 'OpenCL', 'SNPE', 'symphony-cpu', 'capnp', 'zmq', 'kj', 'yuv'] + +def get_dlsym_offset(): + """Returns the offset between dlopen and dlsym in libdl.so""" + import ctypes + libdl = ctypes.PyDLL('libdl.so') + dlopen = ctypes.cast(libdl.dlopen, ctypes.c_void_p).value + dlsym = ctypes.cast(libdl.dlsym, ctypes.c_void_p).value + return dlsym - dlopen + + +common_src = [ + "models/commonmodel.cc", + "runners/snpemodel.cc", + "transforms/loadyuv.cc", + "transforms/transform.cc" +] + +thneed_src = [ + "thneed/thneed.cc", + "thneed/serialize.cc", + "runners/thneedmodel.cc", +] + +use_thneed = not GetOption('no_thneed') + +if arch == "aarch64" or arch == "larch64": + libs += ['gsl', 'CB'] + libs += ['gnustl_shared'] if arch == "aarch64" else ['pthread', 'dl'] + + if use_thneed: + common_src += thneed_src + dlsym_offset = get_dlsym_offset() + lenv['CXXFLAGS'].append("-DUSE_THNEED") + lenv['CXXFLAGS'].append(f"-DDLSYM_OFFSET={dlsym_offset}") +else: + libs += ['pthread'] + + if not GetOption('snpe'): + # 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_model = lenv.Object(common_src) + +# build thneed model +if use_thneed and arch in ("aarch64", "larch64"): + compiler = lenv.Program('thneed/compile', ["thneed/compile.cc"]+common_model, LIBS=libs) + cmd = f"cd {Dir('.').abspath} && {compiler[0].abspath} ../../models/supercombo.dlc ../../models/supercombo.thneed --binary" + + lib_paths = ':'.join(Dir(p).abspath for p in lenv["LIBPATH"]) + cenv = Environment(ENV={'LD_LIBRARY_PATH': f"{lib_paths}:{lenv['ENV']['LD_LIBRARY_PATH']}"}) + cenv.Command("../../models/supercombo.thneed", ["../../models/supercombo.dlc", compiler], cmd) + +lenv.Program('_dmonitoringmodeld', [ + "dmonitoringmodeld.cc", + "models/dmonitoring.cc", + ]+common_model, LIBS=libs) + +lenv.Program('_modeld', [ + "modeld.cc", + "models/driving.cc", + ]+common_model, LIBS=libs) diff --git a/selfdrive/modeld/constants.py b/selfdrive/modeld/constants.py new file mode 100644 index 00000000000000..125864b98b0e4b --- /dev/null +++ b/selfdrive/modeld/constants.py @@ -0,0 +1,7 @@ +IDX_N = 33 + +def index_function(idx, max_val=192, max_idx=32): + return (max_val) * ((idx/max_idx)**2) + + +T_IDXS = [index_function(idx, max_val=10.0) for idx in range(IDX_N)] diff --git a/selfdrive/modeld/dmonitoringmodeld b/selfdrive/modeld/dmonitoringmodeld new file mode 100755 index 00000000000000..9acd7bcc33cf40 --- /dev/null +++ b/selfdrive/modeld/dmonitoringmodeld @@ -0,0 +1,17 @@ +#!/bin/sh + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +cd $DIR + +if [ -d /system ]; then + if [ -f /TICI ]; then # QCOM2 + export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/third_party/snpe/larch64:$LD_LIBRARY_PATH" + else # QCOM + export LD_LIBRARY_PATH="/data/pythonpath/third_party/snpe/aarch64/:$LD_LIBRARY_PATH" + fi + export ADSP_LIBRARY_PATH="/data/pythonpath/third_party/snpe/dsp/" +else + # PC + export LD_LIBRARY_PATH="$DIR/../../third_party/snpe/x86_64-linux-clang:$DIR/../../openpilot/third_party/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..c85c05c9d1f60c --- /dev/null +++ b/selfdrive/modeld/dmonitoringmodeld.cc @@ -0,0 +1,55 @@ +#include +#include + +#include +#include + +#include "cereal/visionipc/visionipc_client.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/modeld/models/dmonitoring.h" + +ExitHandler do_exit; + +void run_model(DMonitoringModelState &model, VisionIpcClient &vipc_client) { + PubMaster pm({"driverState"}); + double last = 0; + + while (!do_exit) { + VisionIpcBufExtra extra = {}; + VisionBuf *buf = vipc_client.recv(&extra); + if (buf == nullptr) continue; + + double t1 = millis_since_boot(); + DMonitoringResult res = dmonitoring_eval_frame(&model, buf->addr, buf->width, buf->height); + double t2 = millis_since_boot(); + + // send dm packet + dmonitoring_publish(pm, extra.frame_id, res, (t2 - t1) / 1000.0, model.output); + + //printf("dmonitoring process: %.2fms, from last %.2fms\n", t2 - t1, t1 - last); + last = t1; + } +} + +int main(int argc, char **argv) { + setpriority(PRIO_PROCESS, 0, -15); + + // init the models + DMonitoringModelState model; + dmonitoring_init(&model); + + VisionIpcClient vipc_client = VisionIpcClient("camerad", VISION_STREAM_DRIVER, true); + while (!do_exit && !vipc_client.connect(false)) { + util::sleep_for(100); + } + + // run the models + if (vipc_client.connected) { + LOGW("connected with buffer size: %d", vipc_client.buffers[0].len); + run_model(model, vipc_client); + } + + dmonitoring_free(&model); + return 0; +} diff --git a/selfdrive/modeld/modeld b/selfdrive/modeld/modeld new file mode 100755 index 00000000000000..fcf2812cb7305a --- /dev/null +++ b/selfdrive/modeld/modeld @@ -0,0 +1,16 @@ +#!/bin/sh + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +cd $DIR + +if [ -d /system ]; then + if [ -f /TICI ]; then # QCOM2 + export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/third_party/snpe/larch64:$LD_LIBRARY_PATH" + else # QCOM + export LD_LIBRARY_PATH="/data/pythonpath/third_party/snpe/aarch64/:$LD_LIBRARY_PATH" + fi +else + # PC + export LD_LIBRARY_PATH="$DIR/../../third_party/snpe/x86_64-linux-clang:$DIR/../../openpilot/third_party/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..9e1750eeafac2e --- /dev/null +++ b/selfdrive/modeld/modeld.cc @@ -0,0 +1,174 @@ +#include +#include +#include + +#include + +#include "cereal/messaging/messaging.h" +#include "cereal/visionipc/visionipc_client.h" +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/modeld/models/driving.h" + +ExitHandler do_exit; +// globals +bool live_calib_seen; +mat3 cur_transform; +std::mutex transform_lock; + +void calibration_thread(bool wide_camera) { + util::set_thread_name("calibration"); + util::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 cam_intrinsics = Eigen::Matrix(wide_camera ? ecam_intrinsic_matrix.v : fcam_intrinsic_matrix.v); + const mat3 yuv_transform = get_model_yuv_transform(); + + while (!do_exit) { + sm.update(100); + if(sm.updated("liveCalibration")) { + 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 = cam_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); + std::lock_guard lk(transform_lock); + cur_transform = model_transform; + live_calib_seen = true; + } + } +} + +void run_model(ModelState &model, VisionIpcClient &vipc_client) { + // messaging + PubMaster pm({"modelV2", "cameraOdometry"}); + SubMaster sm({"lateralPlan", "roadCameraState"}); + + // setup filter to track dropped frames + FirstOrderFilter frame_dropped_filter(0., 10., 1. / MODEL_FREQ); + + uint32_t frame_id = 0, last_vipc_frame_id = 0; + double last = 0; + uint32_t run_count = 0; + + while (!do_exit) { + VisionIpcBufExtra extra = {}; + VisionBuf *buf = vipc_client.recv(&extra); + if (buf == nullptr) continue; + + transform_lock.lock(); + mat3 model_transform = cur_transform; + const bool run_model_this_iter = live_calib_seen; + transform_lock.unlock(); + + // TODO: path planner timeout? + sm.update(0); + int desire = ((int)sm["lateralPlan"].getLateralPlan().getDesire()); + frame_id = sm["roadCameraState"].getRoadCameraState().getFrameId(); + + if (run_model_this_iter) { + run_count++; + + float vec_desire[DESIRE_LEN] = {0}; + if (desire >= 0 && desire < DESIRE_LEN) { + vec_desire[desire] = 1.0; + } + + double mt1 = millis_since_boot(); + ModelOutput *model_output = model_eval_frame(&model, buf->buf_cl, buf->width, buf->height, + model_transform, vec_desire); + double 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; + float frames_dropped = frame_dropped_filter.update((float)std::min(vipc_dropped_frames, 10U)); + if (run_count < 10) { // let frame drops warm up + frame_dropped_filter.reset(0); + frames_dropped = 0.; + } + + float frame_drop_ratio = frames_dropped / (1 + frames_dropped); + + model_publish(pm, extra.frame_id, frame_id, frame_drop_ratio, *model_output, extra.timestamp_eof, model_execution_time, + kj::ArrayPtr(model.output.data(), model.output.size())); + posenet_publish(pm, extra.frame_id, vipc_dropped_frames, *model_output, extra.timestamp_eof); + + //printf("model process: %.2fms, from last %.2fms, vipc_frame_id %u, frame_id, %u, frame_drop %.3f\n", mt2 - mt1, mt1 - last, extra.frame_id, frame_id, frame_drop_ratio); + last = mt1; + last_vipc_frame_id = extra.frame_id; + } + } +} + +int main(int argc, char **argv) { + if (!Hardware::PC()) { + int ret; + ret = util::set_realtime_priority(54); + assert(ret == 0); + util::set_core_affinity({Hardware::EON() ? 2 : 7}); + assert(ret == 0); + } + + bool wide_camera = Hardware::TICI() ? Params().getBool("EnableWideCamera") : false; + + // start calibration thread + std::thread thread = std::thread(calibration_thread, wide_camera); + + // 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"); + + VisionIpcClient vipc_client = VisionIpcClient("camerad", wide_camera ? VISION_STREAM_WIDE_ROAD : VISION_STREAM_ROAD, true, device_id, context); + while (!do_exit && !vipc_client.connect(false)) { + util::sleep_for(100); + } + + // run the models + // vipc_client.connected is false only when do_exit is true + if (vipc_client.connected) { + const VisionBuf *b = &vipc_client.buffers[0]; + LOGW("connected with buffer size: %d (%d x %d)", b->len, b->width, b->height); + run_model(model, vipc_client); + } + + model_free(&model); + LOG("joining calibration thread"); + thread.join(); + CL_CHECK(clReleaseContext(context)); + return 0; +} diff --git a/selfdrive/modeld/models/commonmodel.cc b/selfdrive/modeld/models/commonmodel.cc new file mode 100644 index 00000000000000..1a1f6eaea6aade --- /dev/null +++ b/selfdrive/modeld/models/commonmodel.cc @@ -0,0 +1,76 @@ +#include "selfdrive/modeld/models/commonmodel.h" + +#include +#include +#include +#include + +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/mat.h" +#include "selfdrive/common/timing.h" + +ModelFrame::ModelFrame(cl_device_id device_id, cl_context context) { + input_frames = std::make_unique(buf_size); + + q = CL_CHECK_ERR(clCreateCommandQueue(context, device_id, 0, &err)); + y_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, MODEL_WIDTH * MODEL_HEIGHT, NULL, &err)); + u_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, (MODEL_WIDTH / 2) * (MODEL_HEIGHT / 2), NULL, &err)); + v_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, (MODEL_WIDTH / 2) * (MODEL_HEIGHT / 2), NULL, &err)); + net_input_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, MODEL_FRAME_SIZE * sizeof(float), NULL, &err)); + + transform_init(&transform, context, device_id); + loadyuv_init(&loadyuv, context, device_id, MODEL_WIDTH, MODEL_HEIGHT); +} + +float* ModelFrame::prepare(cl_mem yuv_cl, int frame_width, int frame_height, const mat3 &projection, cl_mem *output) { + transform_queue(&this->transform, q, + yuv_cl, frame_width, frame_height, + y_cl, u_cl, v_cl, MODEL_WIDTH, MODEL_HEIGHT, projection); + + if (output == NULL) { + loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, net_input_cl); + + std::memmove(&input_frames[0], &input_frames[MODEL_FRAME_SIZE], sizeof(float) * MODEL_FRAME_SIZE); + CL_CHECK(clEnqueueReadBuffer(q, net_input_cl, CL_TRUE, 0, MODEL_FRAME_SIZE * sizeof(float), &input_frames[MODEL_FRAME_SIZE], 0, nullptr, nullptr)); + clFinish(q); + return &input_frames[0]; + } else { + loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, *output, true); + // NOTE: Since thneed is using a different command queue, this clFinish is needed to ensure the image is ready. + clFinish(q); + return NULL; + } +} + +ModelFrame::~ModelFrame() { + transform_destroy(&transform); + loadyuv_destroy(&loadyuv); + CL_CHECK(clReleaseMemObject(net_input_cl)); + CL_CHECK(clReleaseMemObject(v_cl)); + CL_CHECK(clReleaseMemObject(u_cl)); + CL_CHECK(clReleaseMemObject(y_cl)); + CL_CHECK(clReleaseCommandQueue(q)); +} + +void softmax(const float* input, float* output, size_t len) { + const float max_val = *std::max_element(input, input + len); + float denominator = 0; + for(int i = 0; i < len; i++) { + float const v_exp = expf(input[i] - 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..19af75eef4be1f --- /dev/null +++ b/selfdrive/modeld/models/commonmodel.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +#include + +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include "selfdrive/common/mat.h" +#include "selfdrive/modeld/transforms/loadyuv.h" +#include "selfdrive/modeld/transforms/transform.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); + +class ModelFrame { +public: + ModelFrame(cl_device_id device_id, cl_context context); + ~ModelFrame(); + float* prepare(cl_mem yuv_cl, int width, int height, const mat3& transform, cl_mem *output); + + const int MODEL_WIDTH = 512; + const int MODEL_HEIGHT = 256; + const int MODEL_FRAME_SIZE = MODEL_WIDTH * MODEL_HEIGHT * 3 / 2; + const int buf_size = MODEL_FRAME_SIZE * 2; + +private: + Transform transform; + LoadYUVState loadyuv; + cl_command_queue q; + cl_mem y_cl, u_cl, v_cl, net_input_cl; + std::unique_ptr input_frames; +}; diff --git a/selfdrive/modeld/models/dmonitoring.cc b/selfdrive/modeld/models/dmonitoring.cc new file mode 100644 index 00000000000000..2acdf7d2b7aa78 --- /dev/null +++ b/selfdrive/modeld/models/dmonitoring.cc @@ -0,0 +1,228 @@ +#include + +#include "libyuv.h" + +#include "selfdrive/common/mat.h" +#include "selfdrive/common/modeldata.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/hardware/hw.h" + +#include "selfdrive/modeld/models/dmonitoring.h" + +constexpr int MODEL_WIDTH = 320; +constexpr int MODEL_HEIGHT = 640; + +template +static inline T *get_buffer(std::vector &buf, const size_t size) { + if (buf.size() < size) buf.resize(size); + return buf.data(); +} + +static inline void init_yuv_buf(std::vector &buf, const int width, int height) { + uint8_t *y = get_buffer(buf, width * height * 3 / 2); + uint8_t *u = y + width * height; + uint8_t *v = u + (width / 2) * (height / 2); + + // needed on comma two to make the padded border black + // equivalent to RGB(0,0,0) in YUV space + memset(y, 16, width * height); + memset(u, 128, (width / 2) * (height / 2)); + memset(v, 128, (width / 2) * (height / 2)); +} + +void dmonitoring_init(DMonitoringModelState* s) { + s->is_rhd = Params().getBool("IsRHD"); + for (int x = 0; x < std::size(s->tensor); ++x) { + s->tensor[x] = (x - 128.f) * 0.0078125f; + } + init_yuv_buf(s->resized_buf, MODEL_WIDTH, MODEL_HEIGHT); + +#ifdef USE_ONNX_MODEL + s->m = new ONNXModel("../../models/dmonitoring_model.onnx", &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME); +#else + s->m = new SNPEModel("../../models/dmonitoring_model_q.dlc", &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME); +#endif +} + +static inline auto get_yuv_buf(std::vector &buf, const int width, int height) { + uint8_t *y = get_buffer(buf, width * height * 3 / 2); + uint8_t *u = y + width * height; + uint8_t *v = u + (width /2) * (height / 2); + return std::make_tuple(y, u, v); +} + +struct Rect {int x, y, w, h;}; +void crop_yuv(uint8_t *raw, int width, int height, uint8_t *y, uint8_t *u, uint8_t *v, const Rect &rect) { + uint8_t *raw_y = raw; + uint8_t *raw_u = raw_y + (width * height); + uint8_t *raw_v = raw_u + ((width / 2) * (height / 2)); + for (int r = 0; r < rect.h / 2; r++) { + memcpy(y + 2 * r * rect.w, raw_y + (2 * r + rect.y) * width + rect.x, rect.w); + memcpy(y + (2 * r + 1) * rect.w, raw_y + (2 * r + rect.y + 1) * width + rect.x, rect.w); + memcpy(u + r * (rect.w / 2), raw_u + (r + (rect.y / 2)) * width / 2 + (rect.x / 2), rect.w / 2); + memcpy(v + r * (rect.w / 2), raw_v + (r + (rect.y / 2)) * width / 2 + (rect.x / 2), rect.w / 2); + } +} + +DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height) { + Rect crop_rect; + if (width == TICI_CAM_WIDTH) { + const int cropped_height = tici_dm_crop::width / 1.33; + crop_rect = {width / 2 - tici_dm_crop::width / 2 + tici_dm_crop::x_offset, + height / 2 - cropped_height / 2 + tici_dm_crop::y_offset, + cropped_height / 2, + cropped_height}; + if (!s->is_rhd) { + crop_rect.x += tici_dm_crop::width - crop_rect.w; + } + } else { + const int adapt_width = 372; + crop_rect = {0, 0, adapt_width, height}; + if (!s->is_rhd) { + crop_rect.x += width - crop_rect.w; + } + } + + int resized_width = MODEL_WIDTH; + int resized_height = MODEL_HEIGHT; + + auto [cropped_y, cropped_u, cropped_v] = get_yuv_buf(s->cropped_buf, crop_rect.w, crop_rect.h); + if (!s->is_rhd) { + crop_yuv((uint8_t *)stream_buf, width, height, cropped_y, cropped_u, cropped_v, crop_rect); + } else { + auto [mirror_y, mirror_u, mirror_v] = get_yuv_buf(s->premirror_cropped_buf, crop_rect.w, crop_rect.h); + crop_yuv((uint8_t *)stream_buf, width, height, mirror_y, mirror_u, mirror_v, crop_rect); + libyuv::I420Mirror(mirror_y, crop_rect.w, + mirror_u, crop_rect.w / 2, + mirror_v, crop_rect.w / 2, + cropped_y, crop_rect.w, + cropped_u, crop_rect.w / 2, + cropped_v, crop_rect.w / 2, + crop_rect.w, crop_rect.h); + } + + auto [resized_buf, resized_u, resized_v] = get_yuv_buf(s->resized_buf, resized_width, resized_height); + uint8_t *resized_y = resized_buf; + libyuv::FilterMode mode = libyuv::FilterModeEnum::kFilterBilinear; + if (Hardware::TICI()) { + libyuv::I420Scale(cropped_y, crop_rect.w, + cropped_u, crop_rect.w / 2, + cropped_v, crop_rect.w / 2, + crop_rect.w, crop_rect.h, + resized_y, resized_width, + resized_u, resized_width / 2, + resized_v, resized_width / 2, + resized_width, resized_height, + mode); + } else { + const int source_height = 0.7*resized_height; + const int extra_height = (resized_height - source_height) / 2; + const int extra_width = (resized_width - source_height / 2) / 2; + const int source_width = source_height / 2 + extra_width; + libyuv::I420Scale(cropped_y, crop_rect.w, + cropped_u, crop_rect.w / 2, + cropped_v, crop_rect.w / 2, + crop_rect.w, crop_rect.h, + resized_y + extra_height * resized_width, resized_width, + resized_u + extra_height / 2 * resized_width / 2, resized_width / 2, + resized_v + extra_height / 2 * resized_width / 2, resized_width / 2, + source_width, source_height, + mode); + } + + 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 r = 0; r < MODEL_HEIGHT/2; r++) { + for (int c = 0; c < MODEL_WIDTH/2; c++) { + // Y_ul + net_input_buf[(r*MODEL_WIDTH/2) + c + (0*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r)*resized_width + 2*c]]; + // Y_dl + net_input_buf[(r*MODEL_WIDTH/2) + c + (1*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r+1)*resized_width + 2*c]]; + // Y_ur + net_input_buf[(r*MODEL_WIDTH/2) + c + (2*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r)*resized_width + 2*c+1]]; + // Y_dr + net_input_buf[(r*MODEL_WIDTH/2) + c + (3*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r+1)*resized_width + 2*c+1]]; + // U + net_input_buf[(r*MODEL_WIDTH/2) + c + (4*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_u[r*resized_width/2 + c]]; + // V + net_input_buf[(r*MODEL_WIDTH/2) + c + (5*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_v[r*resized_width/2 + c]]; + } + } + + //printf("preprocess completed. %d \n", yuv_buf_len); + //FILE *dump_yuv_file = fopen("/tmp/rawdump.yuv", "wb"); + //fwrite(resized_buf, yuv_buf_len, 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}; + for (int i = 0; i < 3; ++i) { + ret.face_orientation[i] = s->output[i]; + ret.face_orientation_meta[i] = softplus(s->output[6 + i]); + } + for (int i = 0; i < 2; ++i) { + ret.face_position[i] = s->output[3 + i]; + ret.face_position_meta[i] = softplus(s->output[9 + i]); + } + ret.face_prob = s->output[12]; + ret.left_eye_prob = s->output[21]; + ret.right_eye_prob = s->output[30]; + ret.left_blink_prob = s->output[31]; + ret.right_blink_prob = s->output[32]; + ret.sg_prob = s->output[33]; + ret.poor_vision = s->output[34]; + ret.partial_face = s->output[35]; + ret.distracted_pose = s->output[36]; + ret.distracted_eyes = s->output[37]; + ret.occluded_prob = s->output[38]; + ret.dsp_execution_time = (t2 - t1) / 1000.; + return ret; +} + +void dmonitoring_publish(PubMaster &pm, uint32_t frame_id, const DMonitoringResult &res, float execution_time, kj::ArrayPtr raw_pred) { + // 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.setSunglassesProb(res.sg_prob); + framed.setPoorVision(res.poor_vision); + framed.setPartialFace(res.partial_face); + framed.setDistractedPose(res.distracted_pose); + framed.setDistractedEyes(res.distracted_eyes); + framed.setOccludedProb(res.occluded_prob); + if (send_raw_pred) { + framed.setRawPredictions(raw_pred.asBytes()); + } + + 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..9b3ee631f0ccc5 --- /dev/null +++ b/selfdrive/modeld/models/dmonitoring.h @@ -0,0 +1,46 @@ +#pragma once + +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/util.h" +#include "selfdrive/modeld/models/commonmodel.h" +#include "selfdrive/modeld/runners/run.h" + +#define OUTPUT_SIZE 39 + +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 poor_vision; + float partial_face; + float distracted_pose; + float distracted_eyes; + float occluded_prob; + float dsp_execution_time; +} DMonitoringResult; + +typedef struct DMonitoringModelState { + RunModel *m; + bool is_rhd; + float output[OUTPUT_SIZE]; + std::vector resized_buf; + std::vector cropped_buf; + std::vector premirror_cropped_buf; + std::vector net_input_buf; + float tensor[UINT8_MAX + 1]; +} 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, float execution_time, kj::ArrayPtr raw_pred); +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..629e1d7ed150fd --- /dev/null +++ b/selfdrive/modeld/models/driving.cc @@ -0,0 +1,345 @@ +#include "selfdrive/modeld/models/driving.h" + +#include +#include + +#include +#include + +#include + +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/timing.h" + +constexpr float FCW_THRESHOLD_5MS2_HIGH = 0.15; +constexpr float FCW_THRESHOLD_5MS2_LOW = 0.05; +constexpr float FCW_THRESHOLD_3MS2 = 0.7; + +std::array prev_brake_5ms2_probs = {0,0,0,0,0}; +std::array prev_brake_3ms2_probs = {0,0,0}; + +// #define DUMP_YUV + +template +constexpr const kj::ArrayPtr to_kj_array_ptr(const std::array &arr) { + return kj::ArrayPtr(arr.data(), arr.size()); +} + +void model_init(ModelState* s, cl_device_id device_id, cl_context context) { + s->frame = new ModelFrame(device_id, context); + +#ifdef USE_THNEED + s->m = std::make_unique("../../models/supercombo.thneed", &s->output[0], NET_OUTPUT_SIZE, USE_GPU_RUNTIME); +#elif USE_ONNX_MODEL + s->m = std::make_unique("../../models/supercombo.onnx", &s->output[0], NET_OUTPUT_SIZE, USE_GPU_RUNTIME); +#else + s->m = std::make_unique("../../models/supercombo.dlc", &s->output[0], NET_OUTPUT_SIZE, USE_GPU_RUNTIME); +#endif + +#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().getBool("IsRHD") ? 1 : 0; + s->traffic_convention[idx] = 1.0; + s->m->addTrafficConvention(s->traffic_convention, TRAFFIC_CONVENTION_LEN); +#endif +} + +ModelOutput* 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 + + // if getInputBuf is not NULL, net_input_buf will be + auto net_input_buf = s->frame->prepare(yuv_cl, width, height, transform, static_cast(s->m->getInputBuf())); + s->m->execute(net_input_buf, s->frame->buf_size); + + return (ModelOutput*)&s->output; +} + +void model_free(ModelState* s) { + delete s->frame; +} + +void fill_lead(cereal::ModelDataV2::LeadDataV3::Builder lead, const ModelOutputLeads &leads, int t_idx, float prob_t) { + std::array lead_t = {0.0, 2.0, 4.0, 6.0, 8.0, 10.0}; + const auto &best_prediction = leads.get_best_prediction(t_idx); + lead.setProb(sigmoid(leads.prob[t_idx])); + lead.setProbTime(prob_t); + std::array lead_x, lead_y, lead_v, lead_a; + std::array lead_x_std, lead_y_std, lead_v_std, lead_a_std; + for (int i=0; i desire_state_softmax; + softmax(meta_data.desire_state_prob.array.data(), desire_state_softmax.data(), DESIRE_LEN); + + std::array desire_pred_softmax; + for (int i=0; i lat_long_t = {2,4,6,8,10}; + std::array gas_disengage_sigmoid, brake_disengage_sigmoid, steer_override_sigmoid, + brake_3ms2_sigmoid, brake_4ms2_sigmoid, brake_5ms2_sigmoid; + for (int i=0; i threshold; + } + for (int i=0; i FCW_THRESHOLD_3MS2; + } + + auto disengage = meta.initDisengagePredictions(); + disengage.setT(to_kj_array_ptr(lat_long_t)); + disengage.setGasDisengageProbs(to_kj_array_ptr(gas_disengage_sigmoid)); + disengage.setBrakeDisengageProbs(to_kj_array_ptr(brake_disengage_sigmoid)); + disengage.setSteerOverrideProbs(to_kj_array_ptr(steer_override_sigmoid)); + disengage.setBrake3MetersPerSecondSquaredProbs(to_kj_array_ptr(brake_3ms2_sigmoid)); + disengage.setBrake4MetersPerSecondSquaredProbs(to_kj_array_ptr(brake_4ms2_sigmoid)); + disengage.setBrake5MetersPerSecondSquaredProbs(to_kj_array_ptr(brake_5ms2_sigmoid)); + + meta.setEngagedProb(sigmoid(meta_data.engaged_prob)); + meta.setDesirePrediction(to_kj_array_ptr(desire_pred_softmax)); + meta.setDesireState(to_kj_array_ptr(desire_state_softmax)); + meta.setHardBrakePredicted(above_fcw_threshold); +} + +template +void fill_xyzt(cereal::ModelDataV2::XYZTData::Builder xyzt, const std::array &t, + const std::array &x, const std::array &y, const std::array &z) { + xyzt.setT(to_kj_array_ptr(t)); + xyzt.setX(to_kj_array_ptr(x)); + xyzt.setY(to_kj_array_ptr(y)); + xyzt.setZ(to_kj_array_ptr(z)); +} + +template +void fill_xyzt(cereal::ModelDataV2::XYZTData::Builder xyzt, const std::array &t, + const std::array &x, const std::array &y, const std::array &z, + const std::array &x_std, const std::array &y_std, const std::array &z_std) { + fill_xyzt(xyzt, t, x, y, z); + xyzt.setXStd(to_kj_array_ptr(x_std)); + xyzt.setYStd(to_kj_array_ptr(y_std)); + xyzt.setZStd(to_kj_array_ptr(z_std)); +} + +void fill_plan(cereal::ModelDataV2::Builder &framed, const ModelOutputPlanPrediction &plan) { + std::array pos_x, pos_y, pos_z; + std::array pos_x_std, pos_y_std, pos_z_std; + std::array vel_x, vel_y, vel_z; + std::array rot_x, rot_y, rot_z; + std::array rot_rate_x, rot_rate_y, rot_rate_z; + + for(int i=0; i &plan_t, + const ModelOutputLaneLines &lanes) { + std::array left_far_y, left_far_z; + std::array left_near_y, left_near_z; + std::array right_near_y, right_near_z; + std::array right_far_y, right_far_z; + for (int j=0; j &plan_t, + const ModelOutputRoadEdges &edges) { + std::array left_y, left_z; + std::array right_y, right_z; + for (int j=0; j plan_t; + std::fill_n(plan_t.data(), plan_t.size(), NAN); + plan_t[0] = 0.0; + for (int xidx=1, tidx=0; xidx t_offsets = {0.0, 2.0, 4.0}; + for (int i=0; i raw_pred) { + const uint32_t frame_age = (frame_id > vipc_frame_id) ? (frame_id - vipc_frame_id) : 0; + MessageBuilder msg; + auto framed = msg.initEvent().initModelV2(); + 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.setRawPredictions(raw_pred.asBytes()); + } + fill_model(framed, net_outputs); + pm.send("modelV2", msg); +} + +void posenet_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t vipc_dropped_frames, + const ModelOutput &net_outputs, uint64_t timestamp_eof) { + MessageBuilder msg; + auto v_mean = net_outputs.pose.velocity_mean; + auto r_mean = net_outputs.pose.rotation_mean; + auto v_std = net_outputs.pose.velocity_std; + auto r_std = net_outputs.pose.rotation_std; + + auto posenetd = msg.initEvent(vipc_dropped_frames < 1).initCameraOdometry(); + posenetd.setTrans({v_mean.x, v_mean.y, v_mean.z}); + posenetd.setRot({r_mean.x, r_mean.y, r_mean.z}); + posenetd.setTransStd({exp(v_std.x), exp(v_std.y), exp(v_std.z)}); + posenetd.setRotStd({exp(r_std.x), exp(r_std.y), exp(r_std.z)}); + + 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..5749fb5ec2a42b --- /dev/null +++ b/selfdrive/modeld/models/driving.h @@ -0,0 +1,243 @@ +#pragma once + +// gate this here +#define TEMPORAL +#define DESIRE +#define TRAFFIC_CONVENTION + +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/mat.h" +#include "selfdrive/common/modeldata.h" +#include "selfdrive/common/util.h" +#include "selfdrive/modeld/models/commonmodel.h" +#include "selfdrive/modeld/runners/run.h" + +constexpr int DESIRE_LEN = 8; +constexpr int DESIRE_PRED_LEN = 4; +constexpr int TRAFFIC_CONVENTION_LEN = 2; +constexpr int MODEL_FREQ = 20; + +constexpr int DISENGAGE_LEN = 5; +constexpr int BLINKER_LEN = 6; +constexpr int META_STRIDE = 7; + +constexpr int PLAN_MHP_N = 5; + +constexpr int LEAD_MHP_N = 2; +constexpr int LEAD_TRAJ_LEN = 6; +constexpr int LEAD_PRED_DIM = 4; +constexpr int LEAD_MHP_SELECTION = 3; + +struct ModelOutputXYZ { + float x; + float y; + float z; +}; +static_assert(sizeof(ModelOutputXYZ) == sizeof(float)*3); + +struct ModelOutputYZ { + float y; + float z; +}; +static_assert(sizeof(ModelOutputYZ) == sizeof(float)*2); + +struct ModelOutputPlanElement { + ModelOutputXYZ position; + ModelOutputXYZ velocity; + ModelOutputXYZ acceleration; + ModelOutputXYZ rotation; + ModelOutputXYZ rotation_rate; +}; +static_assert(sizeof(ModelOutputPlanElement) == sizeof(ModelOutputXYZ)*5); + +struct ModelOutputPlanPrediction { + std::array mean; + std::array std; + float prob; +}; +static_assert(sizeof(ModelOutputPlanPrediction) == (sizeof(ModelOutputPlanElement)*TRAJECTORY_SIZE*2) + sizeof(float)); + +struct ModelOutputPlans { + std::array prediction; + + constexpr const ModelOutputPlanPrediction &get_best_prediction() const { + int max_idx = 0; + for (int i = 1; i < prediction.size(); i++) { + if (prediction[i].prob > prediction[max_idx].prob) { + max_idx = i; + } + } + return prediction[max_idx]; + } +}; +static_assert(sizeof(ModelOutputPlans) == sizeof(ModelOutputPlanPrediction)*PLAN_MHP_N); + +struct ModelOutputLinesXY { + std::array left_far; + std::array left_near; + std::array right_near; + std::array right_far; +}; +static_assert(sizeof(ModelOutputLinesXY) == sizeof(ModelOutputYZ)*TRAJECTORY_SIZE*4); + +struct ModelOutputLineProbVal { + float val_deprecated; + float val; +}; +static_assert(sizeof(ModelOutputLineProbVal) == sizeof(float)*2); + +struct ModelOutputLinesProb { + ModelOutputLineProbVal left_far; + ModelOutputLineProbVal left_near; + ModelOutputLineProbVal right_near; + ModelOutputLineProbVal right_far; +}; +static_assert(sizeof(ModelOutputLinesProb) == sizeof(ModelOutputLineProbVal)*4); + +struct ModelOutputLaneLines { + ModelOutputLinesXY mean; + ModelOutputLinesXY std; + ModelOutputLinesProb prob; +}; +static_assert(sizeof(ModelOutputLaneLines) == (sizeof(ModelOutputLinesXY)*2) + sizeof(ModelOutputLinesProb)); + +struct ModelOutputEdgessXY { + std::array left; + std::array right; +}; +static_assert(sizeof(ModelOutputEdgessXY) == sizeof(ModelOutputYZ)*TRAJECTORY_SIZE*2); + +struct ModelOutputRoadEdges { + ModelOutputEdgessXY mean; + ModelOutputEdgessXY std; +}; +static_assert(sizeof(ModelOutputRoadEdges) == (sizeof(ModelOutputEdgessXY)*2)); + +struct ModelOutputLeadElement { + float x; + float y; + float velocity; + float acceleration; +}; +static_assert(sizeof(ModelOutputLeadElement) == sizeof(float)*4); + +struct ModelOutputLeadPrediction { + std::array mean; + std::array std; + std::array prob; +}; +static_assert(sizeof(ModelOutputLeadPrediction) == (sizeof(ModelOutputLeadElement)*LEAD_TRAJ_LEN*2) + (sizeof(float)*LEAD_MHP_SELECTION)); + +struct ModelOutputLeads { + std::array prediction; + std::array prob; + + constexpr const ModelOutputLeadPrediction &get_best_prediction(int t_idx) const { + int max_idx = 0; + for (int i = 1; i < prediction.size(); i++) { + if (prediction[i].prob[t_idx] > prediction[max_idx].prob[t_idx]) { + max_idx = i; + } + } + return prediction[max_idx]; + } +}; +static_assert(sizeof(ModelOutputLeads) == (sizeof(ModelOutputLeadPrediction)*LEAD_MHP_N) + (sizeof(float)*LEAD_MHP_SELECTION)); + +struct ModelOutputPose { + ModelOutputXYZ velocity_mean; + ModelOutputXYZ rotation_mean; + ModelOutputXYZ velocity_std; + ModelOutputXYZ rotation_std; +}; +static_assert(sizeof(ModelOutputPose) == sizeof(ModelOutputXYZ)*4); + +struct ModelOutputDisengageProb { + float gas_disengage; + float brake_disengage; + float steer_override; + float brake_3ms2; + float brake_4ms2; + float brake_5ms2; + float gas_pressed; +}; +static_assert(sizeof(ModelOutputDisengageProb) == sizeof(float)*7); + +struct ModelOutputBlinkerProb { + float left; + float right; +}; +static_assert(sizeof(ModelOutputBlinkerProb) == sizeof(float)*2); + +struct ModelOutputDesireProb { + union { + struct { + float none; + float turn_left; + float turn_right; + float lane_change_left; + float lane_change_right; + float keep_left; + float keep_right; + float null; + }; + struct { + std::array array; + }; + }; +}; +static_assert(sizeof(ModelOutputDesireProb) == sizeof(float)*DESIRE_LEN); + +struct ModelOutputMeta { + ModelOutputDesireProb desire_state_prob; + float engaged_prob; + std::array disengage_prob; + std::array blinker_prob; + std::array desire_pred_prob; +}; +static_assert(sizeof(ModelOutputMeta) == sizeof(ModelOutputDesireProb) + sizeof(float) + (sizeof(ModelOutputDisengageProb)*DISENGAGE_LEN) + (sizeof(ModelOutputBlinkerProb)*BLINKER_LEN) + (sizeof(ModelOutputDesireProb)*DESIRE_PRED_LEN)); + +struct ModelOutput { + const ModelOutputPlans plans; + const ModelOutputLaneLines lane_lines; + const ModelOutputRoadEdges road_edges; + const ModelOutputLeads leads; + const ModelOutputMeta meta; + const ModelOutputPose pose; +}; + +constexpr int OUTPUT_SIZE = sizeof(ModelOutput) / sizeof(float); +#ifdef TEMPORAL + constexpr int TEMPORAL_SIZE = 512; +#else + constexpr int TEMPORAL_SIZE = 0; +#endif +constexpr int NET_OUTPUT_SIZE = OUTPUT_SIZE + TEMPORAL_SIZE; + +// TODO: convert remaining arrays to std::array and update model runners +struct ModelState { + ModelFrame *frame; + std::array output = {}; + std::unique_ptr m; +#ifdef DESIRE + float prev_desire[DESIRE_LEN] = {}; + float pulse_desire[DESIRE_LEN] = {}; +#endif +#ifdef TRAFFIC_CONVENTION + float traffic_convention[TRAFFIC_CONVENTION_LEN] = {}; +#endif +}; + +void model_init(ModelState* s, cl_device_id device_id, cl_context context); +ModelOutput *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 ModelOutput &net_outputs, uint64_t timestamp_eof, + float model_execution_time, kj::ArrayPtr raw_pred); +void posenet_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t vipc_dropped_frames, + const ModelOutput &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..c64f300fe2411b --- /dev/null +++ b/selfdrive/modeld/runners/run.h @@ -0,0 +1,10 @@ +#pragma once + +#include "runmodel.h" +#include "snpemodel.h" + +#if defined(USE_THNEED) +#include "thneedmodel.h" +#elif defined(USE_ONNX_MODEL) +#include "onnxmodel.h" +#endif diff --git a/selfdrive/modeld/runners/runmodel.h b/selfdrive/modeld/runners/runmodel.h new file mode 100644 index 00000000000000..948048f5d303c7 --- /dev/null +++ b/selfdrive/modeld/runners/runmodel.h @@ -0,0 +1,11 @@ +#pragma once +class RunModel { +public: + virtual ~RunModel() {} + 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) {} + virtual void* getInputBuf() { return nullptr; } +}; + diff --git a/selfdrive/modeld/runners/snpemodel.cc b/selfdrive/modeld/runners/snpemodel.cc new file mode 100644 index 00000000000000..3a6e9e622cd65c --- /dev/null +++ b/selfdrive/modeld/runners/snpemodel.cc @@ -0,0 +1,187 @@ +#pragma clang diagnostic ignored "-Wexceptions" + +#include "selfdrive/modeld/runners/snpemodel.h" + +#include +#include +#include + +#include "selfdrive/common/util.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 + model_data = util::read_file(path); + assert(model_data.size() > 0); + + // load model + std::unique_ptr container = zdl::DlContainer::IDlContainer::open((uint8_t*)model_data.data(), model_data.size()); + if (!container) { PrintErrorStringAndExit(); } + printf("loaded model with size: %lu\n", model_data.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) { + bool ret = inputBuffer->setBufferAddress(net_input_buf); + assert(ret == true); + 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 + bool ret = inputBuffer->setBufferAddress(net_input_buf); + assert(ret == true); + 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..6d3a70414c697a --- /dev/null +++ b/selfdrive/modeld/runners/snpemodel.h @@ -0,0 +1,64 @@ +#pragma once + +#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 "selfdrive/modeld/thneed/thneed.h" +#endif + +class SNPEModel : public RunModel { +public: + SNPEModel(const char *path, float *loutput, size_t loutput_size, int runtime); + 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); + +#ifdef USE_THNEED + Thneed *thneed = NULL; +#endif + +private: + std::string model_data; + +#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; +}; diff --git a/selfdrive/modeld/runners/thneedmodel.cc b/selfdrive/modeld/runners/thneedmodel.cc new file mode 100644 index 00000000000000..0beb6a27946c85 --- /dev/null +++ b/selfdrive/modeld/runners/thneedmodel.cc @@ -0,0 +1,47 @@ +#include "selfdrive/modeld/runners/thneedmodel.h" + +#include + +ThneedModel::ThneedModel(const char *path, float *loutput, size_t loutput_size, int runtime) { + thneed = new Thneed(true); + thneed->record = 0; + thneed->load(path); + thneed->clexec(); + thneed->find_inputs_outputs(); + + recorded = false; + output = loutput; +} + +void ThneedModel::addRecurrent(float *state, int state_size) { + recurrent = state; +} + +void ThneedModel::addTrafficConvention(float *state, int state_size) { + trafficConvention = state; +} + +void ThneedModel::addDesire(float *state, int state_size) { + desire = state; +} + +void* ThneedModel::getInputBuf() { + if (thneed->input_clmem.size() > 3) return &(thneed->input_clmem[3]); + else return nullptr; +} + +void ThneedModel::execute(float *net_input_buf, int buf_size) { + float *inputs[4] = {recurrent, trafficConvention, desire, net_input_buf}; + if (!recorded) { + thneed->record = THNEED_RECORD; + thneed->copy_inputs(inputs); + thneed->clexec(); + thneed->copy_output(output); + thneed->stop(); + + recorded = true; + } else { + thneed->execute(inputs, output); + } +} + diff --git a/selfdrive/modeld/runners/thneedmodel.h b/selfdrive/modeld/runners/thneedmodel.h new file mode 100644 index 00000000000000..1720d5ff20158f --- /dev/null +++ b/selfdrive/modeld/runners/thneedmodel.h @@ -0,0 +1,25 @@ +#pragma once + +#include "selfdrive/modeld/runners/runmodel.h" +#include "selfdrive/modeld/thneed/thneed.h" + +class ThneedModel : public RunModel { +public: + ThneedModel(const char *path, float *loutput, size_t loutput_size, int runtime); + 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); + void* getInputBuf(); +private: + Thneed *thneed = NULL; + bool recorded; + + float *output; + + // recurrent and desire + float *recurrent; + float *trafficConvention; + float *desire; +}; + diff --git a/selfdrive/modeld/thneed/compile.cc b/selfdrive/modeld/thneed/compile.cc new file mode 100644 index 00000000000000..01a71b74750efe --- /dev/null +++ b/selfdrive/modeld/thneed/compile.cc @@ -0,0 +1,35 @@ +#include + +#include "selfdrive/modeld/runners/snpemodel.h" +#include "selfdrive/modeld/thneed/thneed.h" + +#define TEMPORAL_SIZE 512 +#define DESIRE_LEN 8 +#define TRAFFIC_CONVENTION_LEN 2 + +// TODO: This should probably use SNPE directly. +int main(int argc, char* argv[]) { + #define OUTPUT_SIZE 0x10000 + float *output = (float*)calloc(OUTPUT_SIZE, sizeof(float)); + SNPEModel mdl(argv[1], output, 0, USE_GPU_RUNTIME); + + float state[TEMPORAL_SIZE] = {0}; + float desire[DESIRE_LEN] = {0}; + float traffic_convention[TRAFFIC_CONVENTION_LEN] = {0}; + float *input = (float*)calloc(0x1000000, sizeof(float)); + + mdl.addRecurrent(state, TEMPORAL_SIZE); + mdl.addDesire(desire, DESIRE_LEN); + mdl.addTrafficConvention(traffic_convention, TRAFFIC_CONVENTION_LEN); + + // first run + printf("************** execute 1 **************\n"); + memset(output, 0, OUTPUT_SIZE * sizeof(float)); + mdl.execute(input, 0); + + // save model + bool save_binaries = (argc > 3) && (strcmp(argv[3], "--binary") == 0); + mdl.thneed->save(argv[2], save_binaries); + return 0; +} + 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/serialize.cc b/selfdrive/modeld/thneed/serialize.cc new file mode 100644 index 00000000000000..cd5584553b6f38 --- /dev/null +++ b/selfdrive/modeld/thneed/serialize.cc @@ -0,0 +1,258 @@ +#include +#include + +#include "json11.hpp" +#include "selfdrive/common/util.h" +#include "selfdrive/common/clutil.h" +#include "selfdrive/modeld/thneed/thneed.h" +using namespace json11; + +extern map g_program_source; + +void Thneed::load(const char *filename) { + printf("Thneed::load: loading from %s\n", filename); + + string buf = util::read_file(filename); + int jsz = *(int *)buf.data(); + string err; + string jj(buf.data() + sizeof(int), jsz); + Json jdat = Json::parse(jj, err); + + map real_mem; + real_mem[NULL] = NULL; + + int ptr = sizeof(int)+jsz; + for (auto &obj : jdat["objects"].array_items()) { + auto mobj = obj.object_items(); + int sz = mobj["size"].int_value(); + cl_mem clbuf = NULL; + + if (mobj["buffer_id"].string_value().size() > 0) { + // image buffer must already be allocated + clbuf = real_mem[*(cl_mem*)(mobj["buffer_id"].string_value().data())]; + assert(mobj["needs_load"].bool_value() == false); + } else { + if (mobj["needs_load"].bool_value()) { + //printf("loading %p %d @ 0x%X\n", clbuf, sz, ptr); + clbuf = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR | CL_MEM_READ_WRITE, sz, &buf[ptr], NULL); + ptr += sz; + } else { + clbuf = clCreateBuffer(context, CL_MEM_READ_WRITE, sz, NULL, NULL); + } + } + assert(clbuf != NULL); + + if (mobj["arg_type"] == "image2d_t" || mobj["arg_type"] == "image1d_t") { + cl_image_desc desc = {0}; + desc.image_type = (mobj["arg_type"] == "image2d_t") ? CL_MEM_OBJECT_IMAGE2D : CL_MEM_OBJECT_IMAGE1D_BUFFER; + desc.image_width = mobj["width"].int_value(); + desc.image_height = mobj["height"].int_value(); + desc.image_row_pitch = mobj["row_pitch"].int_value(); + desc.buffer = clbuf; + + cl_image_format format; + format.image_channel_order = CL_RGBA; + format.image_channel_data_type = CL_HALF_FLOAT; + + clbuf = clCreateImage(context, CL_MEM_READ_WRITE, &format, &desc, NULL, NULL); + assert(clbuf != NULL); + } + + real_mem[*(cl_mem*)(mobj["id"].string_value().data())] = clbuf; + } + + map g_programs; + for (const auto &[name, source] : jdat["programs"].object_items()) { + if (record & THNEED_DEBUG) printf("building %s with size %zu\n", name.c_str(), source.string_value().size()); + g_programs[name] = cl_program_from_source(context, device_id, source.string_value()); + } + + for (auto &obj : jdat["binaries"].array_items()) { + string name = obj["name"].string_value(); + size_t length = obj["length"].int_value(); + if (record & THNEED_DEBUG) printf("binary %s with size %zu\n", name.c_str(), length); + g_programs[name] = cl_program_from_binary(context, device_id, (const uint8_t*)&buf[ptr], length); + ptr += length; + } + + for (auto &obj : jdat["kernels"].array_items()) { + auto gws = obj["global_work_size"]; + auto lws = obj["local_work_size"]; + auto kk = shared_ptr(new CLQueuedKernel(this)); + + kk->name = obj["name"].string_value(); + kk->program = g_programs[kk->name]; + kk->work_dim = obj["work_dim"].int_value(); + for (int i = 0; i < kk->work_dim; i++) { + kk->global_work_size[i] = gws[i].int_value(); + kk->local_work_size[i] = lws[i].int_value(); + } + kk->num_args = obj["num_args"].int_value(); + for (int i = 0; i < kk->num_args; i++) { + string arg = obj["args"].array_items()[i].string_value(); + int arg_size = obj["args_size"].array_items()[i].int_value(); + kk->args_size.push_back(arg_size); + if (arg_size == 8) { + cl_mem val = *(cl_mem*)(arg.data()); + val = real_mem[val]; + kk->args.push_back(string((char*)&val, sizeof(val))); + } else { + kk->args.push_back(arg); + } + } + kq.push_back(kk); + } + + clFinish(command_queue); +} + +void Thneed::save(const char *filename, bool save_binaries) { + printf("Thneed::save: saving to %s\n", filename); + + // get kernels + std::vector kernels; + std::set saved_objects; + std::vector objects; + std::map programs; + std::map binaries; + + for (auto &k : kq) { + kernels.push_back(k->to_json()); + + // check args for objects + int i = 0; + for (auto &a : k->args) { + if (a.size() == 8) { + if (saved_objects.find(a) == saved_objects.end()) { + saved_objects.insert(a); + cl_mem val = *(cl_mem*)(a.data()); + if (val != NULL) { + bool needs_load = k->arg_names[i] == "weights" || k->arg_names[i] == "biases"; + + auto jj = Json::object({ + {"id", a}, + {"arg_type", k->arg_types[i]}, + }); + + if (k->arg_types[i] == "image2d_t" || k->arg_types[i] == "image1d_t") { + cl_mem buf; + clGetImageInfo(val, CL_IMAGE_BUFFER, sizeof(buf), &buf, NULL); + string aa = string((char *)&buf, sizeof(buf)); + jj["buffer_id"] = aa; + + size_t width, height, row_pitch; + 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); + jj["width"] = (int)width; + jj["height"] = (int)height; + jj["row_pitch"] = (int)row_pitch; + jj["size"] = (int)(height * row_pitch); + jj["needs_load"] = false; + + if (saved_objects.find(aa) == saved_objects.end()) { + saved_objects.insert(aa); + size_t sz; + clGetMemObjectInfo(buf, CL_MEM_SIZE, sizeof(sz), &sz, NULL); + // save the buffer + objects.push_back(Json::object({ + {"id", aa}, + {"arg_type", ""}, + {"needs_load", needs_load}, + {"size", (int)sz} + })); + if (needs_load) assert(sz == height * row_pitch); + } + } else { + size_t sz = 0; + clGetMemObjectInfo(val, CL_MEM_SIZE, sizeof(sz), &sz, NULL); + jj["size"] = (int)sz; + jj["needs_load"] = needs_load; + } + + objects.push_back(jj); + } + } + } + i++; + } + + if (save_binaries) { + int err; + size_t binary_size = 0; + err = clGetProgramInfo(k->program, CL_PROGRAM_BINARY_SIZES, sizeof(binary_size), &binary_size, NULL); + assert(err == 0); + assert(binary_size > 0); + string sv(binary_size, '\x00'); + + uint8_t* bufs[1] = { (uint8_t*)sv.data(), }; + err = clGetProgramInfo(k->program, CL_PROGRAM_BINARIES, sizeof(bufs), &bufs, NULL); + assert(err == 0); + + binaries[k->name] = sv; + } else { + programs[k->name] = g_program_source[k->program]; + } + } + + vector saved_buffers; + for (auto &obj : objects) { + auto mobj = obj.object_items(); + cl_mem val = *(cl_mem*)(mobj["id"].string_value().data()); + int sz = mobj["size"].int_value(); + if (mobj["needs_load"].bool_value()) { + char *buf = (char *)malloc(sz); + if (mobj["arg_type"] == "image2d_t" || mobj["arg_type"] == "image1d_t") { + assert(false); + } else { + // buffers allocated with CL_MEM_HOST_WRITE_ONLY, hence this hack + //hexdump((uint32_t*)val, 0x100); + + // the worst hack in thneed, the flags are at 0x14 + ((uint32_t*)val)[0x14] &= ~CL_MEM_HOST_WRITE_ONLY; + cl_int ret = clEnqueueReadBuffer(command_queue, val, CL_TRUE, 0, sz, buf, 0, NULL, NULL); + assert(ret == CL_SUCCESS); + } + //printf("saving buffer: %d %p %s\n", sz, buf, mobj["arg_type"].string_value().c_str()); + saved_buffers.push_back(string(buf, sz)); + free(buf); + } + } + + std::vector jbinaries; + for (auto &obj : binaries) { + jbinaries.push_back(Json::object({{"name", obj.first}, {"length", (int)obj.second.size()}})); + saved_buffers.push_back(obj.second); + } + + Json jdat = Json::object({ + {"kernels", kernels}, + {"objects", objects}, + {"programs", programs}, + {"binaries", jbinaries}, + }); + + string str = jdat.dump(); + int jsz = str.length(); + + FILE *f = fopen(filename, "wb"); + fwrite(&jsz, 1, sizeof(jsz), f); + fwrite(str.data(), 1, jsz, f); + for (auto &s : saved_buffers) { + fwrite(s.data(), 1, s.length(), f); + } + fclose(f); +} + +Json CLQueuedKernel::to_json() const { + return Json::object { + { "name", name }, + { "work_dim", (int)work_dim }, + { "global_work_size", Json::array { (int)global_work_size[0], (int)global_work_size[1], (int)global_work_size[2] } }, + { "local_work_size", Json::array { (int)local_work_size[0], (int)local_work_size[1], (int)local_work_size[2] } }, + { "num_args", (int)num_args }, + { "args", args }, + { "args_size", args_size }, + }; +} + diff --git a/selfdrive/modeld/thneed/thneed.cc b/selfdrive/modeld/thneed/thneed.cc new file mode 100644 index 00000000000000..a934094ecc3a26 --- /dev/null +++ b/selfdrive/modeld/thneed/thneed.cc @@ -0,0 +1,595 @@ +#include "selfdrive/modeld/thneed/thneed.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include "selfdrive/common/clutil.h" +#include "selfdrive/common/timing.h" +//#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; + +void hexdump(uint8_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->cmds.push_back(unique_ptr(new + CachedSync(thneed, 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((uint8_t *)prop->value, prop->sizebytes); + if (prop->type == KGSL_PROP_PWR_CONSTRAINT) { + struct kgsl_device_constraint *constraint = (struct kgsl_device_constraint *)prop->value; + hexdump((uint8_t *)constraint->data, constraint->size); + } + } + } + } else if (request == IOCTL_KGSL_DRAWCTXT_CREATE || request == IOCTL_KGSL_DRAWCTXT_DESTROY) { + // this happens + } else if (request == IOCTL_KGSL_GPUOBJ_ALLOC || request == IOCTL_KGSL_GPUOBJ_FREE) { + // this happens + } else { + if (thneed->record & THNEED_DEBUG) { + printf("other ioctl %lx\n", request); + } + } + } + + 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) { + void *ret = (void*)base; + size = (size+0xff) & (~0xFF); + assert(size <= remaining); + remaining -= size; + base += size; + return ret; +} + +// *********** CachedSync, at the ioctl layer *********** + +void CachedSync::exec() { + struct kgsl_gpuobj_sync cmd; + + cmd.objs = (uint64_t)data.data(); + cmd.obj_len = data.length(); + cmd.count = data.length() / sizeof(struct kgsl_gpuobj_sync_obj); + + int ret = ioctl(thneed->fd, IOCTL_KGSL_GPUOBJ_SYNC, &cmd); + assert(ret == 0); +} + +// *********** 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() { + cache.timestamp = ++thneed->timestamp; + int ret = ioctl(thneed->fd, IOCTL_KGSL_GPU_COMMAND, &cache); + + 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(0x80000, fd); + record = THNEED_RECORD; + timestamp = -1; + g_thneed = this; +} + +void Thneed::stop() { + find_inputs_outputs(); + printf("Thneed::stop: recorded %lu commands\n", cmds.size()); + record = 0; +} + +void Thneed::find_inputs_outputs() { + cl_int err; + if (inputs.size() > 0) return; + + // save the global inputs/outputs + for (auto &k : kq) { + for (int i = 0; i < k->num_args; i++) { + if (k->name == "zero_pad_image_float" && k->arg_names[i] == "input") { + cl_mem aa = *(cl_mem*)(k->args[i].data()); + input_clmem.push_back(aa); + + size_t sz; + clGetMemObjectInfo(aa, CL_MEM_SIZE, sizeof(sz), &sz, NULL); + input_sizes.push_back(sz); + + void *ret = clEnqueueMapBuffer(command_queue, aa, CL_TRUE, CL_MAP_WRITE, 0, sz, 0, NULL, NULL, &err); + assert(err == CL_SUCCESS); + inputs.push_back(ret); + } + + if (k->name == "image2d_to_buffer_float" && k->arg_names[i] == "output") { + output = *(cl_mem*)(k->args[i].data()); + } + } + } +} + +void Thneed::copy_inputs(float **finputs) { + //cl_int ret; + for (int idx = 0; idx < inputs.size(); ++idx) { + if (record & THNEED_DEBUG) printf("copying %lu -- %p -> %p\n", input_sizes[idx], finputs[idx], inputs[idx]); + if (finputs[idx] != NULL) memcpy(inputs[idx], finputs[idx], input_sizes[idx]); + } +} + +void Thneed::copy_output(float *foutput) { + 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"); + } +} + +void Thneed::wait() { + struct kgsl_device_waittimestamp_ctxtid wait; + wait.context_id = context_id; + wait.timestamp = timestamp; + wait.timeout = -1; + + uint64_t tb = nanos_since_boot(); + int wret = ioctl(fd, IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID, &wait); + uint64_t te = nanos_since_boot(); + + if (record & THNEED_DEBUG) printf("wait %d after %lu us\n", wret, (te-tb)/1000); +} + +void Thneed::execute(float **finputs, float *foutput, bool slow) { + uint64_t tb, te; + if (record & THNEED_DEBUG) tb = nanos_since_boot(); + + // ****** copy inputs + copy_inputs(finputs); + + // ****** set power constraint + int ret; + 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(); + if ((i == cmds.size()) || slow) wait(); + } + + // ****** copy outputs + copy_output(foutput); + + // ****** 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() { + device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); + context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); + //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 = CL_CHECK_ERR(clCreateCommandQueueWithProperties(context, device_id, props, &err)); + 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) { +#if defined(QCOM) || defined(QCOM2) + void *(*my_dlsym)(void *handle, const char *symbol) = (void *(*)(void *handle, const char *symbol))((uintptr_t)dlopen + DLSYM_OFFSET); +#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)); + clGetKernelArgInfo(kernel, i, CL_KERNEL_ARG_TYPE_NAME, sizeof(arg_name), arg_name, NULL); + arg_types.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(); + arg_types.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)); + clGetKernelArgInfo(kernel, j, CL_KERNEL_ARG_TYPE_NAME, sizeof(arg_name), arg_name, NULL); + arg_types.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); + } + } + + 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++) { + string arg = args[i]; + printf(" %s %s", arg_types[i].c_str(), 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 (arg_types[i] == "float") { + 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 (arg_types[i] == "image2d_t" || arg_types[i] == "image1d_t") { + 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..77d27e04352482 --- /dev/null +++ b/selfdrive/modeld/thneed/thneed.h @@ -0,0 +1,134 @@ +#pragma once + +#ifndef __user +#define __user __attribute__(()) +#endif + +#include +#include +#include +#include +#include + +#include + +#include "selfdrive/modeld/thneed/include/msm_kgsl.h" + +#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 arg_types; + 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 CachedIoctl { + public: + virtual void exec() {} +}; + +class CachedSync: public CachedIoctl { + public: + CachedSync(Thneed *lthneed, string ldata) { thneed = lthneed; data = ldata; } + void exec(); + private: + Thneed *thneed; + string data; +}; + +class CachedCommand: public CachedIoctl { + public: + CachedCommand(Thneed *lthneed, struct kgsl_gpu_command *cmd); + void exec(); + private: + void disassemble(int cmd_index); + 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); + void wait(); + int optimize(); + + vector input_clmem; + vector inputs; + vector input_sizes; + 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; + int fd; + + // all CL kernels + void find_inputs_outputs(); + void copy_inputs(float **finputs); + void copy_output(float *foutput); + cl_int clexec(); + vector > kq; + + // pending CL kernels + vector > ckq; + + // loading and saving + void load(const char *filename); + void save(const char *filename, bool save_binaries=false); + private: + void clinit(); +}; + diff --git a/selfdrive/modeld/transforms/loadyuv.cc b/selfdrive/modeld/transforms/loadyuv.cc new file mode 100644 index 00000000000000..39f404a897c0a1 --- /dev/null +++ b/selfdrive/modeld/transforms/loadyuv.cc @@ -0,0 +1,74 @@ +#include "selfdrive/modeld/transforms/loadyuv.h" + +#include +#include +#include + +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)); + s->copy_krnl = CL_CHECK_ERR(clCreateKernel(prg, "copy", &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)); + CL_CHECK(clReleaseKernel(s->copy_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, bool do_shift) { + cl_int global_out_off = 0; + if (do_shift) { + // shift the image in slot 1 to slot 0, then place the new image in slot 1 + global_out_off += (s->width*s->height) + (s->width/2)*(s->height/2)*2; + CL_CHECK(clSetKernelArg(s->copy_krnl, 0, sizeof(cl_mem), &out_cl)); + CL_CHECK(clSetKernelArg(s->copy_krnl, 1, sizeof(cl_int), &global_out_off)); + const size_t copy_work_size = global_out_off/8; + CL_CHECK(clEnqueueNDRangeKernel(q, s->copy_krnl, 1, NULL, + ©_work_size, NULL, 0, 0, NULL)); + } + + CL_CHECK(clSetKernelArg(s->loadys_krnl, 0, sizeof(cl_mem), &y_cl)); + CL_CHECK(clSetKernelArg(s->loadys_krnl, 1, sizeof(cl_mem), &out_cl)); + CL_CHECK(clSetKernelArg(s->loadys_krnl, 2, sizeof(cl_int), &global_out_off)); + + 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; + global_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), &global_out_off)); + + CL_CHECK(clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL, + &loaduv_work_size, NULL, 0, 0, NULL)); + + global_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), &global_out_off)); + + CL_CHECK(clEnqueueNDRangeKernel(q, s->loaduv_krnl, 1, NULL, + &loaduv_work_size, NULL, 0, 0, NULL)); +} diff --git a/selfdrive/modeld/transforms/loadyuv.cl b/selfdrive/modeld/transforms/loadyuv.cl new file mode 100644 index 00000000000000..7dd3d973a3ef69 --- /dev/null +++ b/selfdrive/modeld/transforms/loadyuv.cl @@ -0,0 +1,47 @@ +#define UV_SIZE ((TRANSFORMED_WIDTH/2)*(TRANSFORMED_HEIGHT/2)) + +__kernel void loadys(__global uchar8 const * const Y, + __global float * out, + int out_offset) +{ + const int gid = get_global_id(0); + const int ois = gid * 8; + const int oy = ois / TRANSFORMED_WIDTH; + const int ox = ois % TRANSFORMED_WIDTH; + + const uchar8 ys = Y[gid]; + const float8 ysf = convert_float8(ys); + + // 02 + // 13 + + __global float* outy0; + __global float* outy1; + if ((oy & 1) == 0) { + outy0 = out + out_offset; //y0 + outy1 = out + out_offset + UV_SIZE*2; //y2 + } else { + outy0 = out + out_offset + UV_SIZE; //y1 + outy1 = out + out_offset + UV_SIZE*3; //y3 + } + + vstore4(ysf.s0246, 0, outy0 + (oy/2) * (TRANSFORMED_WIDTH/2) + ox/2); + vstore4(ysf.s1357, 0, outy1 + (oy/2) * (TRANSFORMED_WIDTH/2) + ox/2); +} + +__kernel void loaduv(__global uchar8 const * const in, + __global float8 * out, + int out_offset) +{ + const int gid = get_global_id(0); + const uchar8 inv = in[gid]; + const float8 outv = convert_float8(inv); + out[gid + out_offset / 8] = outv; +} + +__kernel void copy(__global float8 * inout, + int in_offset) +{ + const int gid = get_global_id(0); + inout[gid] = inout[gid + in_offset / 8]; +} diff --git a/selfdrive/modeld/transforms/loadyuv.h b/selfdrive/modeld/transforms/loadyuv.h new file mode 100644 index 00000000000000..a3161b293518d9 --- /dev/null +++ b/selfdrive/modeld/transforms/loadyuv.h @@ -0,0 +1,16 @@ +#pragma once + +#include "selfdrive/common/clutil.h" + +typedef struct { + int width, height; + cl_kernel loadys_krnl, loaduv_krnl, copy_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, bool do_shift = false); diff --git a/selfdrive/modeld/transforms/transform.cc b/selfdrive/modeld/transforms/transform.cc new file mode 100644 index 00000000000000..5f4929bab39475 --- /dev/null +++ b/selfdrive/modeld/transforms/transform.cc @@ -0,0 +1,95 @@ +#include "selfdrive/modeld/transforms/transform.h" + +#include +#include + +#include "selfdrive/common/clutil.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, + const 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/modeld/transforms/transform.h b/selfdrive/modeld/transforms/transform.h new file mode 100644 index 00000000000000..f34613684c92f6 --- /dev/null +++ b/selfdrive/modeld/transforms/transform.h @@ -0,0 +1,25 @@ +#pragma once + +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include "selfdrive/common/mat.h" + +typedef struct { + cl_kernel krnl; + cl_mem m_y_cl, m_uv_cl; +} Transform; + +void transform_init(Transform* s, cl_context ctx, cl_device_id device_id); + +void transform_destroy(Transform* transform); + +void transform_queue(Transform* s, cl_command_queue q, + cl_mem 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, + const mat3& projection); diff --git a/selfdrive/monitoring/dmonitoringd.py b/selfdrive/monitoring/dmonitoringd.py new file mode 100755 index 00000000000000..f11d72266ca568 --- /dev/null +++ b/selfdrive/monitoring/dmonitoringd.py @@ -0,0 +1,84 @@ +#!/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 +from selfdrive.locationd.calibrationd import Calibration + + +def dmonitoringd_thread(sm=None, pm=None): + if pm is None: + pm = messaging.PubMaster(['driverMonitoringState']) + + if sm is None: + sm = messaging.SubMaster(['driverState', 'liveCalibration', 'carState', 'controlsState', 'modelV2'], poll=['driverState']) + + driver_status = DriverStatus(rhd=Params().get_bool("IsRHD")) + + sm['liveCalibration'].calStatus = Calibration.INVALID + sm['liveCalibration'].rpyCalib = [0, 0, 0] + sm['carState'].buttonEvents = [] + 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 + if driver_engaged: + driver_status.update(Events(), True, sm['controlsState'].enabled, sm['carState'].standstill) + v_cruise_last = v_cruise + + if sm.updated['modelV2']: + driver_status.set_policy(sm['modelV2']) + + # 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 >= driver_status.settings._MAX_TERMINAL_ALERTS or \ + driver_status.terminal_time >= driver_status.settings._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 driverMonitoringState packet + dat = messaging.new_message('driverMonitoringState') + dat.driverMonitoringState = { + "events": events.to_msg(), + "faceDetected": driver_status.face_detected, + "isDistracted": driver_status.driver_distracted, + "awarenessStatus": driver_status.awareness, + "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, + "isActiveMode": driver_status.active_monitoring_mode, + } + pm.send('driverMonitoringState', 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..e4018d66f67efb --- /dev/null +++ b/selfdrive/monitoring/driver_monitor.py @@ -0,0 +1,271 @@ +from math import atan2 + +from cereal import car +from common.numpy_fast import interp +from common.realtime import DT_DMON +from selfdrive.hardware import TICI +from common.filter_simple import FirstOrderFilter +from common.stat_live import RunningStatFilter + +EventName = car.CarEvent.EventName + +# ****************************************************************************************** +# NOTE: To fork maintainers. +# Disabling or nerfing safety features will get you and your users banned from our servers. +# We recommend that you do not change these numbers from the defaults. +# ****************************************************************************************** + +class DRIVER_MONITOR_SETTINGS(): + def __init__(self, TICI=TICI, DT_DMON=DT_DMON): + self._DT_DMON = DT_DMON + self._AWARENESS_TIME = 35. # passive wheeltouch total timeout + self._AWARENESS_PRE_TIME_TILL_TERMINAL = 12. + self._AWARENESS_PROMPT_TIME_TILL_TERMINAL = 6. + self._DISTRACTED_TIME = 11. # active monitoring total timeout + self._DISTRACTED_PRE_TIME_TILL_TERMINAL = 8. + self._DISTRACTED_PROMPT_TIME_TILL_TERMINAL = 6. + + self._FACE_THRESHOLD = 0.5 + self._PARTIAL_FACE_THRESHOLD = 0.765 if TICI else 0.43 + self._EYE_THRESHOLD = 0.61 if TICI else 0.55 + self._SG_THRESHOLD = 0.89 if TICI else 0.86 + self._BLINK_THRESHOLD = 0.82 if TICI else 0.588 + self._BLINK_THRESHOLD_SLACK = 0.9 if TICI else 0.77 + self._BLINK_THRESHOLD_STRICT = self._BLINK_THRESHOLD + self._PITCH_WEIGHT = 1.35 # pitch matters a lot more + self._POSESTD_THRESHOLD = 0.38 if TICI else 0.3 + + self._METRIC_THRESHOLD = 0.48 + self._METRIC_THRESHOLD_SLACK = 0.66 + self._METRIC_THRESHOLD_STRICT = self._METRIC_THRESHOLD + self._PITCH_NATURAL_OFFSET = 0.02 # people don't seem to look straight when they drive relaxed, rather a bit up + self._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) + + self._HI_STD_FALLBACK_TIME = int(10 / self._DT_DMON) # fall back to wheel touch if model is uncertain for 10s + self._DISTRACTED_FILTER_TS = 0.25 # 0.6Hz + + self._POSE_CALIB_MIN_SPEED = 13 # 30 mph + self._POSE_OFFSET_MIN_COUNT = int(60 / self._DT_DMON) # valid data counts before calibration completes, 1min cumulative + self._POSE_OFFSET_MAX_COUNT = int(360 / self._DT_DMON) # stop deweighting new data after 6 min, aka "short term memory" + + self._RECOVERY_FACTOR_MAX = 5. # relative to minus step change + self._RECOVERY_FACTOR_MIN = 1.25 # relative to minus step change + + self._MAX_TERMINAL_ALERTS = 3 # not allowed to engage after 3 terminal alerts + self._MAX_TERMINAL_DURATION = int(30 / self._DT_DMON) # not allowed to engage after 30s of 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: + 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, yaw_net, roll_net = angles_desc + + 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) + + 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_net, pitch, yaw + +class DriverPose(): + def __init__(self, max_trackable): + 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=max_trackable) + self.yaw_offseter = RunningStatFilter(max_trackable=max_trackable) + 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, rhd=False, settings=DRIVER_MONITOR_SETTINGS()): + # init policy settings + self.settings = settings + + # init driver status + self.is_rhd_region = rhd + self.pose = DriverPose(self.settings._POSE_OFFSET_MAX_COUNT) + self.pose_calibrated = False + self.blink = DriverBlink() + self.awareness = 1. + self.awareness_active = 1. + self.awareness_passive = 1. + self.driver_distracted = False + self.driver_distraction_filter = FirstOrderFilter(0., self.settings._DISTRACTED_FILTER_TS, self.settings._DT_DMON) + self.face_detected = False + self.face_partial = False + self.terminal_alert_cnt = 0 + self.terminal_time = 0 + self.step_change = 0. + self.active_monitoring_mode = True + self.is_model_uncertain = False + self.hi_stds = 0 + self.threshold_pre = self.settings._DISTRACTED_PRE_TIME_TILL_TERMINAL / self.settings._DISTRACTED_TIME + self.threshold_prompt = self.settings._DISTRACTED_PROMPT_TIME_TILL_TERMINAL / self.settings._DISTRACTED_TIME + + 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 = self.settings._DT_DMON / self.settings._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 = self.settings._DISTRACTED_PRE_TIME_TILL_TERMINAL / self.settings._DISTRACTED_TIME + self.threshold_prompt = self.settings._DISTRACTED_PROMPT_TIME_TILL_TERMINAL / self.settings._DISTRACTED_TIME + self.step_change = self.settings._DT_DMON / self.settings._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 = self.settings._AWARENESS_PRE_TIME_TILL_TERMINAL / self.settings._AWARENESS_TIME + self.threshold_prompt = self.settings._AWARENESS_PROMPT_TIME_TILL_TERMINAL / self.settings._AWARENESS_TIME + self.step_change = self.settings._DT_DMON / self.settings._AWARENESS_TIME + self.active_monitoring_mode = False + + def _is_driver_distracted(self, pose, blink): + if not self.pose_calibrated: + pitch_error = pose.pitch - self.settings._PITCH_NATURAL_OFFSET + yaw_error = pose.yaw - self.settings._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() + + pitch_error = 0 if pitch_error > 0 else abs(pitch_error) # no positive pitch limit + yaw_error = abs(yaw_error) + + if pitch_error*self.settings._PITCH_WEIGHT > self.settings._METRIC_THRESHOLD*pose.cfactor or \ + yaw_error > self.settings._METRIC_THRESHOLD*pose.cfactor: + return DistractedType.BAD_POSE + elif (blink.left_blink + blink.right_blink)*0.5 > self.settings._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], + [self.settings._METRIC_THRESHOLD_STRICT, + self.settings. _METRIC_THRESHOLD, + self.settings._METRIC_THRESHOLD_SLACK]) / self.settings._METRIC_THRESHOLD + self.blink.cfactor = interp(ep, [0, 0.5, 1], + [self.settings._BLINK_THRESHOLD_STRICT, + self.settings._BLINK_THRESHOLD, + self.settings._BLINK_THRESHOLD_SLACK]) / self.settings._BLINK_THRESHOLD + + def get_pose(self, driver_state, cal_rpy, car_speed, op_engaged): + if not all(len(x) > 0 for x in [driver_state.faceOrientation, driver_state.facePosition, + driver_state.faceOrientationStd, driver_state.facePositionStd]): + return + + self.face_partial = driver_state.partialFace > self.settings._PARTIAL_FACE_THRESHOLD + self.face_detected = driver_state.faceProb > self.settings._FACE_THRESHOLD or self.face_partial + 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 < self.settings._POSESTD_THRESHOLD and not self.face_partial + self.blink.left_blink = driver_state.leftBlinkProb * (driver_state.leftEyeProb > self.settings._EYE_THRESHOLD) * (driver_state.sunglassesProb < self.settings._SG_THRESHOLD) + self.blink.right_blink = driver_state.rightBlinkProb * (driver_state.rightEyeProb > self.settings._EYE_THRESHOLD) * (driver_state.sunglassesProb < self.settings._SG_THRESHOLD) + + self.driver_distracted = self._is_driver_distracted(self.pose, self.blink) > 0 and \ + driver_state.faceProb > self.settings._FACE_THRESHOLD and self.pose.low_std + 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 > self.settings._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 > self.settings._POSE_OFFSET_MIN_COUNT and \ + self.pose.yaw_offseter.filtered_stat.n > self.settings._POSE_OFFSET_MIN_COUNT + + self.is_model_uncertain = self.hi_stds > self.settings._HI_STD_FALLBACK_TIME + self._set_timers(self.face_detected and not self.is_model_uncertain) + if self.face_detected and not self.pose.low_std and not self.driver_distracted: + 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 (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 + ((self.settings._RECOVERY_FACTOR_MAX-self.settings._RECOVERY_FACTOR_MIN)*(1.-self.awareness)+self.settings._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 + + standstill_exemption = standstill and self.awareness - self.step_change <= self.threshold_prompt + certainly_distracted = self.driver_distraction_filter.x > 0.63 and self.driver_distracted and self.face_detected + maybe_distracted = self.hi_stds > self.settings._HI_STD_FALLBACK_TIME or not self.face_detected + if certainly_distracted or maybe_distracted: + # should always be counting if distracted unless at standstill and reaching orange + if not standstill_exemption: + 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.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 09f2e717f9f24b..b725ca9ddab5aa 100755 --- a/selfdrive/pandad.py +++ b/selfdrive/pandad.py @@ -1,58 +1,50 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # simple boardd wrapper that updates the panda first import os +import usb1 import time +import subprocess +from typing import List +from functools import cmp_to_key +from panda import DEFAULT_FW_FN, DEFAULT_H7_FW_FN, MCU_TYPE_H7, Panda, PandaDFU +from common.basedir import BASEDIR +from common.params import Params from selfdrive.swaglog import cloudlog -from panda import Panda, PandaDFU, BASEDIR -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(panda : Panda) -> bytes: + fn = DEFAULT_H7_FW_FN if (panda.get_mcu_type() == MCU_TYPE_H7) else DEFAULT_FW_FN - panda = None - panda_dfu = None + try: + return Panda.get_signature_from_firmware(fn) + except Exception: + cloudlog.exception("Error computing expected signature") + return b"" - cloudlog.info("Connecting to panda") - while True: - # break on normal mode Panda - panda_list = Panda.list() - if len(panda_list) > 0: - cloudlog.info("Panda found, connecting") - panda = Panda(panda_list[0]) - break - - # flash on DFU mode Panda - panda_dfu = PandaDFU.list() - if len(panda_dfu) > 0: - cloudlog.info("Panda in DFU mode found, flashing recovery") - 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)) - - if panda.bootstub or not current_version.startswith(repo_version): - cloudlog.info("Panda firmware out of date, update required") +def flash_panda(panda_serial : str) -> Panda: + panda = Panda(panda_serial) - 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() + fw_signature = get_expected_signature(panda) + 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" % ( + panda_serial, + panda_version, + panda_signature.hex()[:16], + fw_signature.hex()[:16], + )) + + if panda.bootstub or panda_signature != fw_signature: + cloudlog.info("Panda firmware out of date, update required") + panda.flash() 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,17 +52,75 @@ 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 + return panda -def main(gctx=None): - update_panda() +def panda_sort_cmp(a : Panda, b : Panda): + a_type = a.get_type() + b_type = b.get_type() - os.chdir("boardd") - os.execvp("./boardd", ["./boardd"]) + # make sure the internal one is always first + if a.is_internal() and not b.is_internal(): + return -1 + if not a.is_internal() and b.is_internal(): + return 1 + + # sort by hardware type + if a_type != b_type: + return a_type < b_type + + # last resort: sort by serial number + return a.get_usb_serial() < b.get_usb_serial() + +def main() -> None: + while True: + try: + # Flash all Pandas in DFU mode + for p in PandaDFU.list(): + cloudlog.info(f"Panda in DFU mode found, flashing recovery {p}") + PandaDFU(p).recover() + time.sleep(1) + + panda_serials = Panda.list() + if len(panda_serials) == 0: + continue + + cloudlog.info(f"{len(panda_serials)} panda(s) found, connecting - {panda_serials}") + + # Flash pandas + pandas = [] + for serial in panda_serials: + pandas.append(flash_panda(serial)) + + # check health for lost heartbeat + for panda in pandas: + health = panda.health() + if health["heartbeat_lost"]: + Params().put_bool("PandaHeartbeatLost", True) + cloudlog.event("heartbeat lost", deviceState=health, serial=panda.get_usb_serial()) + + cloudlog.info(f"Resetting panda {panda.get_usb_serial()}") + panda.reset() + + # sort pandas to have deterministic order + pandas.sort(key=cmp_to_key(panda_sort_cmp)) + panda_serials = list(map(lambda p: p.get_usb_serial(), pandas)) + + # close all pandas + for p in pandas: + p.close() + except (usb1.USBErrorNoDevice, usb1.USBErrorPipe): + # a panda was disconnected while setting everything up. let's try again + cloudlog.exception("Panda USB exception while setting up") + continue + + # run boardd with all connected serials as arguments + os.chdir(os.path.join(BASEDIR, "selfdrive/boardd")) + subprocess.run(["./boardd", *panda_serials], check=True) 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..1b94a32f1b3634 --- /dev/null +++ b/selfdrive/proclogd/SConscript @@ -0,0 +1,6 @@ +Import('env', 'cereal', 'messaging', 'common') +libs = [cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj', 'common', 'zmq', 'json11'] +env.Program('proclogd', ['main.cc', 'proclog.cc'], LIBS=libs) + +if GetOption('test'): + env.Program('tests/test_proclog', ['tests/test_proclog.cc', 'proclog.cc'], LIBS=libs) diff --git a/selfdrive/proclogd/main.cc b/selfdrive/proclogd/main.cc new file mode 100644 index 00000000000000..4e31597c2bc0d2 --- /dev/null +++ b/selfdrive/proclogd/main.cc @@ -0,0 +1,22 @@ + +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/proclogd/proclog.h" + +ExitHandler do_exit; + +int main(int argc, char **argv) { + setpriority(PRIO_PROCESS, 0, -15); + + PubMaster publisher({"procLog"}); + while (!do_exit) { + MessageBuilder msg; + buildProcLogMessage(msg); + publisher.send("procLog", msg); + + util::sleep_for(2000); // 2 secs + } + + return 0; +} diff --git a/selfdrive/proclogd/proclog.cc b/selfdrive/proclogd/proclog.cc new file mode 100644 index 00000000000000..26fc1d94d0d085 --- /dev/null +++ b/selfdrive/proclogd/proclog.cc @@ -0,0 +1,239 @@ +#include "selfdrive/proclogd/proclog.h" + +#include + +#include +#include +#include +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" + +namespace Parser { + +// parse /proc/stat +std::vector cpuTimes(std::istream &stream) { + std::vector cpu_times; + std::string line; + // skip the first line for cpu total + std::getline(stream, line); + while (std::getline(stream, line)) { + if (line.compare(0, 3, "cpu") != 0) break; + + CPUTime t = {}; + std::istringstream iss(line); + if (iss.ignore(3) >> t.id >> t.utime >> t.ntime >> t.stime >> t.itime >> t.iowtime >> t.irqtime >> t.sirqtime) + cpu_times.push_back(t); + } + return cpu_times; +} + +// parse /proc/meminfo +std::unordered_map memInfo(std::istream &stream) { + std::unordered_map mem_info; + std::string line, key; + while (std::getline(stream, line)) { + uint64_t val = 0; + std::istringstream iss(line); + if (iss >> key >> val) { + mem_info[key] = val * 1024; + } + } + return mem_info; +} + +// field position (https://man7.org/linux/man-pages/man5/proc.5.html) +enum StatPos { + pid = 1, + state = 3, + ppid = 4, + utime = 14, + stime = 15, + cutime = 16, + cstime = 17, + priority = 18, + nice = 19, + num_threads = 20, + starttime = 22, + vsize = 23, + rss = 24, + processor = 39, + MAX_FIELD = 52, +}; + +// parse /proc/pid/stat +std::optional procStat(std::string stat) { + // To avoid being fooled by names containing a closing paren, scan backwards. + auto open_paren = stat.find('('); + auto close_paren = stat.rfind(')'); + if (open_paren == std::string::npos || close_paren == std::string::npos || open_paren > close_paren) { + return std::nullopt; + } + + std::string name = stat.substr(open_paren + 1, close_paren - open_paren - 1); + // repace space in name with _ + std::replace(&stat[open_paren], &stat[close_paren], ' ', '_'); + std::istringstream iss(stat); + std::vector v{std::istream_iterator(iss), + std::istream_iterator()}; + try { + if (v.size() != StatPos::MAX_FIELD) { + throw std::invalid_argument("stat"); + } + ProcStat p = { + .name = name, + .pid = stoi(v[StatPos::pid - 1]), + .state = v[StatPos::state - 1][0], + .ppid = stoi(v[StatPos::ppid - 1]), + .utime = stoul(v[StatPos::utime - 1]), + .stime = stoul(v[StatPos::stime - 1]), + .cutime = stol(v[StatPos::cutime - 1]), + .cstime = stol(v[StatPos::cstime - 1]), + .priority = stol(v[StatPos::priority - 1]), + .nice = stol(v[StatPos::nice - 1]), + .num_threads = stol(v[StatPos::num_threads - 1]), + .starttime = stoull(v[StatPos::starttime - 1]), + .vms = stoul(v[StatPos::vsize - 1]), + .rss = stoul(v[StatPos::rss - 1]), + .processor = stoi(v[StatPos::processor - 1]), + }; + return p; + } catch (const std::invalid_argument &e) { + LOGE("failed to parse procStat (%s) :%s", e.what(), stat.c_str()); + } catch (const std::out_of_range &e) { + LOGE("failed to parse procStat (%s) :%s", e.what(), stat.c_str()); + } + return std::nullopt; +} + +// return list of PIDs from /proc +std::vector pids() { + std::vector ids; + DIR *d = opendir("/proc"); + assert(d); + char *p_end; + struct dirent *de = NULL; + while ((de = readdir(d))) { + if (de->d_type == DT_DIR) { + int pid = strtol(de->d_name, &p_end, 10); + if (p_end == (de->d_name + strlen(de->d_name))) { + ids.push_back(pid); + } + } + } + closedir(d); + return ids; +} + +// null-delimited cmdline arguments to vector +std::vector cmdline(std::istream &stream) { + std::vector ret; + std::string line; + while (std::getline(stream, line, '\0')) { + if (!line.empty()) { + ret.push_back(line); + } + } + return ret; +} + +const ProcCache &getProcExtraInfo(int pid, const std::string &name) { + static std::unordered_map proc_cache; + ProcCache &cache = proc_cache[pid]; + if (cache.pid != pid || cache.name != name) { + cache.pid = pid; + cache.name = name; + std::string proc_path = "/proc/" + std::to_string(pid); + cache.exe = util::readlink(proc_path + "/exe"); + std::ifstream stream(proc_path + "/cmdline"); + cache.cmdline = cmdline(stream); + } + return cache; +} + +} // namespace Parser + +const double jiffy = sysconf(_SC_CLK_TCK); +const size_t page_size = sysconf(_SC_PAGE_SIZE); + +void buildCPUTimes(cereal::ProcLog::Builder &builder) { + std::ifstream stream("/proc/stat"); + std::vector stats = Parser::cpuTimes(stream); + + auto log_cpu_times = builder.initCpuTimes(stats.size()); + for (int i = 0; i < stats.size(); ++i) { + auto l = log_cpu_times[i]; + const CPUTime &r = stats[i]; + l.setCpuNum(r.id); + l.setUser(r.utime / jiffy); + l.setNice(r.ntime / jiffy); + l.setSystem(r.stime / jiffy); + l.setIdle(r.itime / jiffy); + l.setIowait(r.iowtime / jiffy); + l.setIrq(r.irqtime / jiffy); + l.setSoftirq(r.sirqtime / jiffy); + } +} + +void buildMemInfo(cereal::ProcLog::Builder &builder) { + std::ifstream stream("/proc/meminfo"); + auto mem_info = Parser::memInfo(stream); + + auto mem = builder.initMem(); + mem.setTotal(mem_info["MemTotal:"]); + mem.setFree(mem_info["MemFree:"]); + mem.setAvailable(mem_info["MemAvailable:"]); + mem.setBuffers(mem_info["Buffers:"]); + mem.setCached(mem_info["Cached:"]); + mem.setActive(mem_info["Active:"]); + mem.setInactive(mem_info["Inactive:"]); + mem.setShared(mem_info["Shmem:"]); +} + +void buildProcs(cereal::ProcLog::Builder &builder) { + auto pids = Parser::pids(); + std::vector proc_stats; + proc_stats.reserve(pids.size()); + for (int pid : pids) { + std::string path = "/proc/" + std::to_string(pid) + "/stat"; + if (auto stat = Parser::procStat(util::read_file(path))) { + proc_stats.push_back(*stat); + } + } + + auto procs = builder.initProcs(proc_stats.size()); + for (size_t i = 0; i < proc_stats.size(); i++) { + auto l = procs[i]; + const ProcStat &r = proc_stats[i]; + l.setPid(r.pid); + l.setState(r.state); + l.setPpid(r.ppid); + l.setCpuUser(r.utime / jiffy); + l.setCpuSystem(r.stime / jiffy); + l.setCpuChildrenUser(r.cutime / jiffy); + l.setCpuChildrenSystem(r.cstime / jiffy); + l.setPriority(r.priority); + l.setNice(r.nice); + l.setNumThreads(r.num_threads); + l.setStartTime(r.starttime / jiffy); + l.setMemVms(r.vms); + l.setMemRss((uint64_t)r.rss * page_size); + l.setProcessor(r.processor); + l.setName(r.name); + + const ProcCache &extra_info = Parser::getProcExtraInfo(r.pid, r.name); + l.setExe(extra_info.exe); + auto lcmdline = l.initCmdline(extra_info.cmdline.size()); + for (size_t j = 0; j < lcmdline.size(); j++) { + lcmdline.set(j, extra_info.cmdline[j]); + } + } +} + +void buildProcLogMessage(MessageBuilder &msg) { + auto procLog = msg.initEvent().initProcLog(); + buildProcs(procLog); + buildCPUTimes(procLog); + buildMemInfo(procLog); +} diff --git a/selfdrive/proclogd/proclog.h b/selfdrive/proclogd/proclog.h new file mode 100644 index 00000000000000..9ed53d1bac7686 --- /dev/null +++ b/selfdrive/proclogd/proclog.h @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +#include "cereal/messaging/messaging.h" + +struct CPUTime { + int id; + unsigned long utime, ntime, stime, itime; + unsigned long iowtime, irqtime, sirqtime; +}; + +struct ProcCache { + int pid; + std::string name, exe; + std::vector cmdline; +}; + +struct ProcStat { + int pid, ppid, processor; + char state; + long cutime, cstime, priority, nice, num_threads; + unsigned long utime, stime, vms, rss; + unsigned long long starttime; + std::string name; +}; + +namespace Parser { + +std::vector pids(); +std::optional procStat(std::string stat); +std::vector cmdline(std::istream &stream); +std::vector cpuTimes(std::istream &stream); +std::unordered_map memInfo(std::istream &stream); +const ProcCache &getProcExtraInfo(int pid, const std::string &name); + +}; // namespace Parser + +void buildProcLogMessage(MessageBuilder &msg); diff --git a/selfdrive/proclogd/proclogd.cc b/selfdrive/proclogd/proclogd.cc deleted file mode 100644 index fbb7704e0378e7..00000000000000 --- a/selfdrive/proclogd/proclogd.cc +++ /dev/null @@ -1,245 +0,0 @@ -#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/timing.h" -#include "common/utilpp.h" - -namespace { - -struct ProcCache { - std::string name; - std::vector cmdline; - std::string exe; -}; - -} - -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); - - double jiffy = sysconf(_SC_CLK_TCK); - size_t page_size = sysconf(_SC_PAGE_SIZE); - - std::unordered_map proc_cache; - - while (1) { - - capnp::MallocMessageBuilder msg; - cereal::Event::Builder event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto procLog = event.initProcLog(); - - auto orphanage = msg.getOrphanage(); - - // stat - { - std::vector> otimes; - - std::ifstream sstat("/proc/stat"); - std::string stat_line; - while (std::getline(sstat, stat_line)) { - if (util::starts_with(stat_line, "cpu ")) { - // cpu total - } else if (util::starts_with(stat_line, "cpu")) { - // specific cpu - int id; - 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); - - auto ltimeo = orphanage.newOrphan(); - auto ltime = ltimeo.get(); - ltime.setCpuNum(id); - ltime.setUser(utime / jiffy); - ltime.setNice(ntime / jiffy); - ltime.setSystem(stime / jiffy); - ltime.setIdle(itime / jiffy); - ltime.setIowait(iowtime / jiffy); - ltime.setIrq(irqtime / jiffy); - ltime.setSoftirq(irqtime / jiffy); - - otimes.push_back(std::move(ltimeo)); - - } else { - break; - } - } - - auto ltimes = procLog.initCpuTimes(otimes.size()); - for (size_t i = 0; i < otimes.size(); i++) { - ltimes.adoptWithCaveats(i, std::move(otimes[i])); - } - } - - // meminfo - { - auto mem = procLog.initMem(); - - 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); - } - - mem.setTotal(mem_total * 1024); - mem.setFree(mem_free * 1024); - mem.setAvailable(mem_available * 1024); - mem.setBuffers(mem_buffers * 1024); - mem.setCached(mem_cached * 1024); - mem.setActive(mem_active * 1024); - mem.setInactive(mem_inactive * 1024); - mem.setShared(mem_shared * 1024); - } - - // processes - { - std::vector> oprocs; - struct dirent *de = NULL; - DIR *d = opendir("/proc"); - assert(d); - while ((de = readdir(d))) { - if (!isdigit(de->d_name[0])) continue; - pid_t pid = atoi(de->d_name); - - - auto lproco = orphanage.newOrphan(); - auto lproc = lproco.get(); - - lproc.setPid(pid); - - char tcomm[PATH_MAX] = {0}; - - { - std::string stat = util::read_file(util::string_format("/proc/%d/stat", pid)); - - char state; - - int ppid; - unsigned long utime, stime; - long cutime, cstime, priority, nice, num_threads; - unsigned long long starttime; - unsigned long vms, rss; - int processor; - - int count = sscanf(stat.data(), - "%*d (%1024[^)]) %c %d %*d %*d %*d %*d %*d %*d %*d %*d %*d " - "%lu %lu %ld %ld %ld %ld %ld %*d %lld " - "%lu %lu %*d %*d %*d %*d %*d %*d %*d " - "%*d %*d %*d %*d %*d %*d %*d %d", - tcomm, &state, &ppid, - &utime, &stime, &cutime, &cstime, &priority, &nice, &num_threads, &starttime, - &vms, &rss, &processor); - - if (count != 14) continue; - - lproc.setState(state); - lproc.setPpid(ppid); - lproc.setCpuUser(utime / jiffy); - lproc.setCpuSystem(stime / jiffy); - lproc.setCpuChildrenUser(cutime / jiffy); - lproc.setCpuChildrenSystem(cstime / jiffy); - lproc.setPriority(priority); - lproc.setNice(nice); - lproc.setNumThreads(num_threads); - lproc.setStartTime(starttime / jiffy); - lproc.setMemVms(vms); - lproc.setMemRss((uint64_t)rss * page_size); - lproc.setProcessor(processor); - } - - std::string name(tcomm); - lproc.setName(name); - - // populate other things from cache - auto cache_it = proc_cache.find(pid); - ProcCache cache; - if (cache_it != proc_cache.end()) { - cache = cache_it->second; - } - if (cache_it == proc_cache.end() || cache.name != name) { - cache = (ProcCache){ - .name = name, - .exe = util::readlink(util::string_format("/proc/%d/exe", pid)), - }; - - // null-delimited cmdline arguments to vector - 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--; - } - - while (cmdline_p < cmdline_ep) { - std::string arg(cmdline_p); - cache.cmdline.push_back(arg); - cmdline_p += arg.size() + 1; - } - - proc_cache[pid] = cache; - } - - auto lcmdline = lproc.initCmdline(cache.cmdline.size()); - for (size_t i = 0; i < lcmdline.size(); i++) { - lcmdline.set(i, cache.cmdline[i]); - } - lproc.setExe(cache.exe); - - oprocs.push_back(std::move(lproco)); - } - closedir(d); - - auto lprocs = procLog.initProcs(oprocs.size()); - for (size_t i = 0; i < oprocs.size(); i++) { - lprocs.adoptWithCaveats(i, std::move(oprocs[i])); - } - } - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(publisher, bytes.begin(), bytes.size(), 0); - - usleep(2000000); // 2 secs - } - - return 0; -} diff --git a/selfdrive/registration.py b/selfdrive/registration.py deleted file mode 100644 index 9f689984999c06..00000000000000 --- a/selfdrive/registration.py +++ /dev/null @@ -1,103 +0,0 @@ -import os -import json -import subprocess -import struct - -from datetime import datetime, timedelta -from selfdrive.swaglog import cloudlog -from selfdrive.version import 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 - - -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 register(): - params = Params() - params.put("Version", 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()) - - # 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"): - 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") - - dongle_id, access_token = params.get("DongleId"), params.get("AccessToken") - 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() - - # late import - import jwt - 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) - dongleauth = json.loads(resp.text) - dongle_id, access_token = dongleauth["dongle_id"].encode('ascii'), dongleauth["access_token"].encode('ascii') - - params.put("DongleId", dongle_id) - params.put("AccessToken", access_token) - return dongle_id, access_token - except Exception: - cloudlog.exception("failed to authenticate") - if dongle_id is not None and access_token is not None: - return dongle_id, access_token - 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..ad7538d7a8bc2c --- /dev/null +++ b/selfdrive/rtshield.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +import os +import time +from typing import NoReturn + +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() -> NoReturn: + 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..186e302bc3d4ea --- /dev/null +++ b/selfdrive/sensord/SConscript @@ -0,0 +1,22 @@ +Import('env', 'arch', 'common', 'cereal', 'messaging') + +if arch == "aarch64": + env.Program('_sensord', 'sensors_qcom.cc', LIBS=['hardware', common, 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', + 'sensors/mmc5603nj_magn.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.cc b/selfdrive/sensord/gpsd.cc deleted file mode 100644 index 6bf7a6a9e1861b..00000000000000 --- a/selfdrive/sensord/gpsd.cc +++ /dev/null @@ -1,268 +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" - -#include "rawgps.h" - -volatile int do_exit = 0; - -namespace { - -pthread_t clock_thread_handle; - -// zmq output -void *gps_context; -void *gps_publisher; -void *gps_location_publisher; - -const GpsInterface* gGpsInterface = NULL; -const AGpsInterface* gAGpsInterface = NULL; - -void set_do_exit(int sig) { - do_exit = 1; -} - -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(); - 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); -} - -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(); - locationData.setFlags(location->flags); - locationData.setLatitude(location->latitude); - locationData.setLongitude(location->longitude); - locationData.setAltitude(location->altitude); - locationData.setSpeed(location->speed); - locationData.setBearing(location->bearing); - locationData.setAccuracy(location->accuracy); - 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); -} - -pthread_t create_thread_callback(const char* name, void (*start)(void *), void* arg) { - LOG("creating thread: %s", name); - pthread_t thread; - pthread_attr_t attr; - int err; - - err = pthread_attr_init(&attr); - err = pthread_create(&thread, &attr, (void*(*)(void*))start, arg); - - return thread; -} - -GpsCallbacks gps_callbacks = { - sizeof(GpsCallbacks), - location_callback, - NULL, - NULL, - nmea_callback, - NULL, - NULL, - NULL, - create_thread_callback, -}; - -void agps_status_cb(AGpsStatus *status) { - switch (status->status) { - case GPS_REQUEST_AGPS_DATA_CONN: - fprintf(stdout, "*** data_conn_open\n"); - gAGpsInterface->data_conn_open("internet"); - break; - case GPS_RELEASE_AGPS_DATA_CONN: - fprintf(stdout, "*** data_conn_closed\n"); - gAGpsInterface->data_conn_closed(); - break; - } -} - -AGpsCallbacks agps_callbacks = { - agps_status_cb, - create_thread_callback, -}; - - - -void gps_init() { - LOG("*** init GPS"); - hw_module_t* module = NULL; - hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); - assert(module); - - static hw_device_t* device = NULL; - module->methods->open(module, GPS_HARDWARE_MODULE_ID, &device); - assert(device); - - // ** get gps interface ** - gps_device_t* gps_device = (gps_device_t *)device; - gGpsInterface = gps_device->get_gps_interface(gps_device); - assert(gGpsInterface); - - gAGpsInterface = (const AGpsInterface*)gGpsInterface->get_extension(AGPS_INTERFACE); - assert(gAGpsInterface); - - - gGpsInterface->init(&gps_callbacks); - gAGpsInterface->init(&agps_callbacks); - gAGpsInterface->set_server(AGPS_TYPE_SUPL, "supl.google.com", 7276); - - // gGpsInterface->delete_aiding_data(GPS_DELETE_ALL); - gGpsInterface->start(); - gGpsInterface->set_position_mode(GPS_POSITION_MODE_MS_BASED, - 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() { - 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/libdiag.h b/selfdrive/sensord/libdiag.h index ab3ee91b14a0db..03a59464edc5c1 100644 --- a/selfdrive/sensord/libdiag.h +++ b/selfdrive/sensord/libdiag.h @@ -1,5 +1,4 @@ -#ifndef LIBDIAG_H -#define LIBDIAG_H +#pragma once #include #include @@ -36,5 +35,3 @@ int diag_send_dci_async_req(int client_id, unsigned char buf[], int bytes, unsig #ifdef __cplusplus } #endif - -#endif 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..9ea848d577f26c --- /dev/null +++ b/selfdrive/sensord/sensord @@ -0,0 +1,4 @@ +#!/bin/sh +cd "$(dirname "$0")" +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..f5d68bdee5c6c5 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_accel.cc @@ -0,0 +1,69 @@ +#include "bmx055_accel.h" + +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" + +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_X_LSB, 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.h b/selfdrive/sensord/sensors/bmx055_accel.h new file mode 100644 index 00000000000000..86ec419cde2d4f --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_accel.h @@ -0,0 +1,37 @@ +#pragma once + +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +// 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_X_LSB 0x02 +#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..f0e3034e3ffeee --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_gyro.cc @@ -0,0 +1,80 @@ +#include "bmx055_gyro.h" + +#include +#include + +#include "selfdrive/common/swaglog.h" + +#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_RATE_X_LSB, 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.h b/selfdrive/sensord/sensors/bmx055_gyro.h new file mode 100644 index 00000000000000..ed0c16ff05f134 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_gyro.h @@ -0,0 +1,37 @@ +#pragma once + +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +// 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_RATE_X_LSB 0x02 +#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..29e0d809d8ccd3 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_magn.cc @@ -0,0 +1,250 @@ +#include "bmx055_magn.h" + +#include + +#include +#include +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" + +static int16_t compensate_x(trim_data_t trim_data, int16_t mag_data_x, uint16_t data_rhall) { + uint16_t process_comp_x0 = data_rhall; + int32_t process_comp_x1 = ((int32_t)trim_data.dig_xyz1) * 16384; + uint16_t process_comp_x2 = ((uint16_t)(process_comp_x1 / process_comp_x0)) - ((uint16_t)0x4000); + int16_t retval = ((int16_t)process_comp_x2); + int32_t process_comp_x3 = (((int32_t)retval) * ((int32_t)retval)); + int32_t process_comp_x4 = (((int32_t)trim_data.dig_xy2) * (process_comp_x3 / 128)); + int32_t process_comp_x5 = (int32_t)(((int16_t)trim_data.dig_xy1) * 128); + int32_t process_comp_x6 = ((int32_t)retval) * process_comp_x5; + int32_t process_comp_x7 = (((process_comp_x4 + process_comp_x6) / 512) + ((int32_t)0x100000)); + int32_t process_comp_x8 = ((int32_t)(((int16_t)trim_data.dig_x2) + ((int16_t)0xA0))); + int32_t process_comp_x9 = ((process_comp_x7 * process_comp_x8) / 4096); + int32_t process_comp_x10 = ((int32_t)mag_data_x) * process_comp_x9; + retval = ((int16_t)(process_comp_x10 / 8192)); + retval = (retval + (((int16_t)trim_data.dig_x1) * 8)) / 16; + + return retval; +} + +static int16_t compensate_y(trim_data_t trim_data, int16_t mag_data_y, uint16_t data_rhall) { + uint16_t process_comp_y0 = trim_data.dig_xyz1; + int32_t process_comp_y1 = (((int32_t)trim_data.dig_xyz1) * 16384) / process_comp_y0; + uint16_t process_comp_y2 = ((uint16_t)process_comp_y1) - ((uint16_t)0x4000); + int16_t retval = ((int16_t)process_comp_y2); + int32_t process_comp_y3 = ((int32_t) retval) * ((int32_t)retval); + int32_t process_comp_y4 = ((int32_t)trim_data.dig_xy2) * (process_comp_y3 / 128); + int32_t process_comp_y5 = ((int32_t)(((int16_t)trim_data.dig_xy1) * 128)); + int32_t process_comp_y6 = ((process_comp_y4 + (((int32_t)retval) * process_comp_y5)) / 512); + int32_t process_comp_y7 = ((int32_t)(((int16_t)trim_data.dig_y2) + ((int16_t)0xA0))); + int32_t process_comp_y8 = (((process_comp_y6 + ((int32_t)0x100000)) * process_comp_y7) / 4096); + int32_t process_comp_y9 = (((int32_t)mag_data_y) * process_comp_y8); + retval = (int16_t)(process_comp_y9 / 8192); + retval = (retval + (((int16_t)trim_data.dig_y1) * 8)) / 16; + + return retval; +} + +static int16_t compensate_z(trim_data_t trim_data, int16_t mag_data_z, uint16_t data_rhall) { + int16_t process_comp_z0 = ((int16_t)data_rhall) - ((int16_t) trim_data.dig_xyz1); + int32_t process_comp_z1 = (((int32_t)trim_data.dig_z3) * ((int32_t)(process_comp_z0))) / 4; + int32_t process_comp_z2 = (((int32_t)(mag_data_z - trim_data.dig_z4)) * 32768); + int32_t process_comp_z3 = ((int32_t)trim_data.dig_z1) * (((int16_t)data_rhall) * 2); + int16_t process_comp_z4 = (int16_t)((process_comp_z3 + (32768)) / 65536); + int32_t retval = ((process_comp_z2 - process_comp_z1) / (trim_data.dig_z2 + process_comp_z4)); + + /* saturate result to +/- 2 micro-tesla */ + retval = std::clamp(retval, -32767, 32767); + + /* Conversion of LSB to micro-tesla*/ + retval = retval / 16; + + return (int16_t)retval; +} + +BMX055_Magn::BMX055_Magn(I2CBus *bus) : I2CSensor(bus) {} + +int BMX055_Magn::init() { + int ret; + uint8_t buffer[1]; + uint8_t trim_x1y1[2] = {0}; + uint8_t trim_x2y2[2] = {0}; + uint8_t trim_xy1xy2[2] = {0}; + uint8_t trim_z1[2] = {0}; + uint8_t trim_z2[2] = {0}; + uint8_t trim_z3[2] = {0}; + uint8_t trim_z4[2] = {0}; + uint8_t trim_xyz1[2] = {0}; + + // suspend -> sleep + ret = set_register(BMX055_MAGN_I2C_REG_PWR_0, 0x01); + if(ret < 0) { + LOGE("Enabling power failed: %d", ret); + goto fail; + } + util::sleep_for(5); // 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; + } + + // Load magnetometer trim + ret = read_register(BMX055_MAGN_I2C_REG_DIG_X1, trim_x1y1, 2); + if(ret < 0) goto fail; + ret = read_register(BMX055_MAGN_I2C_REG_DIG_X2, trim_x2y2, 2); + if(ret < 0) goto fail; + ret = read_register(BMX055_MAGN_I2C_REG_DIG_XY2, trim_xy1xy2, 2); + if(ret < 0) goto fail; + ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z1_LSB, trim_z1, 2); + if(ret < 0) goto fail; + ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z2_LSB, trim_z2, 2); + if(ret < 0) goto fail; + ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z3_LSB, trim_z3, 2); + if(ret < 0) goto fail; + ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z4_LSB, trim_z4, 2); + if(ret < 0) goto fail; + ret = read_register(BMX055_MAGN_I2C_REG_DIG_XYZ1_LSB, trim_xyz1, 2); + if(ret < 0) goto fail; + + // Read trim data + trim_data.dig_x1 = trim_x1y1[0]; + trim_data.dig_y1 = trim_x1y1[1]; + + trim_data.dig_x2 = trim_x2y2[0]; + trim_data.dig_y2 = trim_x2y2[1]; + + trim_data.dig_xy1 = trim_xy1xy2[1]; // NB: MSB/LSB swapped + trim_data.dig_xy2 = trim_xy1xy2[0]; + + trim_data.dig_z1 = read_16_bit(trim_z1[0], trim_z1[1]); + trim_data.dig_z2 = read_16_bit(trim_z2[0], trim_z2[1]); + trim_data.dig_z3 = read_16_bit(trim_z3[0], trim_z3[1]); + trim_data.dig_z4 = read_16_bit(trim_z4[0], trim_z4[1]); + + trim_data.dig_xyz1 = read_16_bit(trim_xyz1[0], trim_xyz1[1] & 0x7f); + assert(trim_data.dig_xyz1 != 0); + + perform_self_test(); + + // f_max = 1 / (145us * nXY + 500us * NZ + 980us) + // Chose NXY = 7, NZ = 12, which gives 125 Hz, + // and has the same ratio as the high accuracy preset + ret = set_register(BMX055_MAGN_I2C_REG_REPXY, (7 - 1) / 2); + if (ret < 0) { + goto fail; + } + + ret = set_register(BMX055_MAGN_I2C_REG_REPZ, 12 - 1); + if (ret < 0) { + goto fail; + } + + + return 0; + + fail: + return ret; +} + +bool BMX055_Magn::perform_self_test() { + uint8_t buffer[8]; + int16_t x, y; + int16_t neg_z, pos_z; + + // Increase z reps for less false positives (~30 Hz ODR) + set_register(BMX055_MAGN_I2C_REG_REPXY, 1); + set_register(BMX055_MAGN_I2C_REG_REPZ, 64 - 1); + + // Clean existing measurement + read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); + + uint8_t forced = BMX055_MAGN_FORCED; + + // Negative current + set_register(BMX055_MAGN_I2C_REG_MAG, forced | (uint8_t(0b10) << 6)); + util::sleep_for(100); + + read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); + parse_xyz(buffer, &x, &y, &neg_z); + + // Positive current + set_register(BMX055_MAGN_I2C_REG_MAG, forced | (uint8_t(0b11) << 6)); + util::sleep_for(100); + + read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); + parse_xyz(buffer, &x, &y, &pos_z); + + // Put back in normal mode + set_register(BMX055_MAGN_I2C_REG_MAG, 0); + + int16_t diff = pos_z - neg_z; + bool passed = (diff > 180) && (diff < 240); + + if (!passed) { + LOGE("self test failed: neg %d pos %d diff %d", neg_z, pos_z, diff); + } + + return passed; +} + +bool BMX055_Magn::parse_xyz(uint8_t buffer[8], int16_t *x, int16_t *y, int16_t *z) { + bool ready = buffer[6] & 0x1; + if (ready) { + int16_t mdata_x = (int16_t) (((int16_t)buffer[1] << 8) | buffer[0]) >> 3; + int16_t mdata_y = (int16_t) (((int16_t)buffer[3] << 8) | buffer[2]) >> 3; + int16_t mdata_z = (int16_t) (((int16_t)buffer[5] << 8) | buffer[4]) >> 1; + uint16_t data_r = (uint16_t) (((uint16_t)buffer[7] << 8) | buffer[6]) >> 2; + assert(data_r != 0); + + *x = compensate_x(trim_data, mdata_x, data_r); + *y = compensate_y(trim_data, mdata_y, data_r); + *z = compensate_z(trim_data, mdata_z, data_r); + } + return ready; +} + + +void BMX055_Magn::get_event(cereal::SensorEventData::Builder &event) { + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[8]; + int16_t _x, _y, x, y, z; + + int len = read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); + assert(len == sizeof(buffer)); + + if (parse_xyz(buffer, &_x, &_y, &z)) { + event.setSource(cereal::SensorEventData::SensorSource::BMX055); + event.setVersion(2); + event.setSensor(SENSOR_MAGNETOMETER_UNCALIBRATED); + event.setType(SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED); + event.setTimestamp(start_time); + + // Move magnetometer into same reference frame as accel/gryo + x = -_y; + y = _x; + + // Axis convention + x = -x; + y = -y; + + float xyz[] = {(float)x, (float)y, (float)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 completed this cycle. + set_register(BMX055_MAGN_I2C_REG_MAG, BMX055_MAGN_FORCED); +} diff --git a/selfdrive/sensord/sensors/bmx055_magn.h b/selfdrive/sensord/sensors/bmx055_magn.h new file mode 100644 index 00000000000000..d60fd5515c15da --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_magn.h @@ -0,0 +1,63 @@ +#pragma once +#include + +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +// 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 + +#define BMX055_MAGN_I2C_REG_DIG_X1 0x5D +#define BMX055_MAGN_I2C_REG_DIG_Y1 0x5E +#define BMX055_MAGN_I2C_REG_DIG_Z4_LSB 0x62 +#define BMX055_MAGN_I2C_REG_DIG_Z4_MSB 0x63 +#define BMX055_MAGN_I2C_REG_DIG_X2 0x64 +#define BMX055_MAGN_I2C_REG_DIG_Y2 0x65 +#define BMX055_MAGN_I2C_REG_DIG_Z2_LSB 0x68 +#define BMX055_MAGN_I2C_REG_DIG_Z2_MSB 0x69 +#define BMX055_MAGN_I2C_REG_DIG_Z1_LSB 0x6A +#define BMX055_MAGN_I2C_REG_DIG_Z1_MSB 0x6B +#define BMX055_MAGN_I2C_REG_DIG_XYZ1_LSB 0x6C +#define BMX055_MAGN_I2C_REG_DIG_XYZ1_MSB 0x6D +#define BMX055_MAGN_I2C_REG_DIG_Z3_LSB 0x6E +#define BMX055_MAGN_I2C_REG_DIG_Z3_MSB 0x6F +#define BMX055_MAGN_I2C_REG_DIG_XY2 0x70 +#define BMX055_MAGN_I2C_REG_DIG_XY1 0x71 + +// Constants +#define BMX055_MAGN_CHIP_ID 0x32 +#define BMX055_MAGN_FORCED (0b01 << 1) + +struct trim_data_t { + int8_t dig_x1; + int8_t dig_y1; + int8_t dig_x2; + int8_t dig_y2; + uint16_t dig_z1; + int16_t dig_z2; + int16_t dig_z3; + int16_t dig_z4; + uint8_t dig_xy1; + int8_t dig_xy2; + uint16_t dig_xyz1; +}; + + +class BMX055_Magn : public I2CSensor{ + uint8_t get_device_address() {return BMX055_MAGN_I2C_ADDR;} + trim_data_t trim_data = {0}; + bool perform_self_test(); + bool parse_xyz(uint8_t buffer[8], int16_t *x, int16_t *y, int16_t *z); +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..339a987ce09a7b --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_temp.cc @@ -0,0 +1,44 @@ +#include "bmx055_temp.h" + +#include + +#include "selfdrive/sensord/sensors/bmx055_accel.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" + +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.h b/selfdrive/sensord/sensors/bmx055_temp.h new file mode 100644 index 00000000000000..5ffaa8fb6b3d79 --- /dev/null +++ b/selfdrive/sensord/sensors/bmx055_temp.h @@ -0,0 +1,12 @@ +#pragma once + +#include "selfdrive/sensord/sensors/bmx055_accel.h" +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +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.h b/selfdrive/sensord/sensors/constants.h new file mode 100644 index 00000000000000..c216f838a5ab0e --- /dev/null +++ b/selfdrive/sensord/sensors/constants.h @@ -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..812a41fa8a256c --- /dev/null +++ b/selfdrive/sensord/sensors/file_sensor.cc @@ -0,0 +1,14 @@ +#include "file_sensor.h" + +#include + +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.h b/selfdrive/sensord/sensors/file_sensor.h new file mode 100644 index 00000000000000..c5b4643e16b506 --- /dev/null +++ b/selfdrive/sensord/sensors/file_sensor.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +#include "cereal/gen/cpp/log.capnp.h" +#include "selfdrive/sensord/sensors/sensor.h" + +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..40dfa4a736516e --- /dev/null +++ b/selfdrive/sensord/sensors/i2c_sensor.cc @@ -0,0 +1,28 @@ +#include "i2c_sensor.h" + +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); +} + +int32_t read_20_bit(uint8_t b2, uint8_t b1, uint8_t b0) { + uint32_t combined = (uint32_t(b0) << 16) | (uint32_t(b1) << 8) | uint32_t(b2); + return int32_t(combined) / (1 << 4); +} + + +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.h b/selfdrive/sensord/sensors/i2c_sensor.h new file mode 100644 index 00000000000000..83c66eac879ad0 --- /dev/null +++ b/selfdrive/sensord/sensors/i2c_sensor.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "cereal/gen/cpp/log.capnp.h" +#include "selfdrive/common/i2c.h" +#include "selfdrive/sensord/sensors/constants.h" +#include "selfdrive/sensord/sensors/sensor.h" + +int16_t read_12_bit(uint8_t lsb, uint8_t msb); +int16_t read_16_bit(uint8_t lsb, uint8_t msb); +int32_t read_20_bit(uint8_t b2, uint8_t b1, uint8_t b0); + + +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..4d00d37bdabdef --- /dev/null +++ b/selfdrive/sensord/sensors/light_sensor.cc @@ -0,0 +1,22 @@ +#include "light_sensor.h" + +#include + +#include "selfdrive/common/timing.h" +#include "selfdrive/sensord/sensors/constants.h" + +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.h b/selfdrive/sensord/sensors/light_sensor.h new file mode 100644 index 00000000000000..faf901d41c633b --- /dev/null +++ b/selfdrive/sensord/sensors/light_sensor.h @@ -0,0 +1,8 @@ +#pragma once +#include "file_sensor.h" + +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..83222858e7ba9d --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_accel.cc @@ -0,0 +1,64 @@ +#include "lsm6ds3_accel.h" + +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" + +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 && buffer[0] != LSM6DS3TRC_ACCEL_CHIP_ID) { + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], LSM6DS3_ACCEL_CHIP_ID); + ret = -1; + goto fail; + } + + if (buffer[0] == LSM6DS3TRC_ACCEL_CHIP_ID) { + source = cereal::SensorEventData::SensorSource::LSM6DS3TRC; + } + + // 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(source); + 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.h b/selfdrive/sensord/sensors/lsm6ds3_accel.h new file mode 100644 index 00000000000000..4a6b68744519c7 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_accel.h @@ -0,0 +1,26 @@ +#pragma once + +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +// 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 LSM6DS3TRC_ACCEL_CHIP_ID 0x6A +#define LSM6DS3_ACCEL_ODR_104HZ (0b0100 << 4) + + +class LSM6DS3_Accel : public I2CSensor { + uint8_t get_device_address() {return LSM6DS3_ACCEL_I2C_ADDR;} + cereal::SensorEventData::SensorSource source = cereal::SensorEventData::SensorSource::LSM6DS3; +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..6732ead0f16193 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_gyro.cc @@ -0,0 +1,68 @@ +#include "lsm6ds3_gyro.h" + +#include +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" + +#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 && buffer[0] != LSM6DS3TRC_GYRO_CHIP_ID) { + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], LSM6DS3_GYRO_CHIP_ID); + ret = -1; + goto fail; + } + + if (buffer[0] == LSM6DS3TRC_GYRO_CHIP_ID) { + source = cereal::SensorEventData::SensorSource::LSM6DS3TRC; + } + + // 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 = 8.75 / 1000.0; + 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(source); + event.setVersion(2); + 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.h b/selfdrive/sensord/sensors/lsm6ds3_gyro.h new file mode 100644 index 00000000000000..d7e8f0025a7c3a --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_gyro.h @@ -0,0 +1,26 @@ +#pragma once + +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +// 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 LSM6DS3TRC_GYRO_CHIP_ID 0x6A +#define LSM6DS3_GYRO_ODR_104HZ (0b0100 << 4) + + +class LSM6DS3_Gyro : public I2CSensor { + uint8_t get_device_address() {return LSM6DS3_GYRO_I2C_ADDR;} + cereal::SensorEventData::SensorSource source = cereal::SensorEventData::SensorSource::LSM6DS3; +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..6b093fce05847b --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_temp.cc @@ -0,0 +1,50 @@ +#include "lsm6ds3_temp.h" + +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" + +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 && buffer[0] != LSM6DS3TRC_TEMP_CHIP_ID) { + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], LSM6DS3_TEMP_CHIP_ID); + ret = -1; + goto fail; + } + + if (buffer[0] == LSM6DS3TRC_TEMP_CHIP_ID) { + source = cereal::SensorEventData::SensorSource::LSM6DS3TRC; + } + +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 scale = (source == cereal::SensorEventData::SensorSource::LSM6DS3TRC) ? 256.0f : 16.0f; + float temp = 25.0f + read_16_bit(buffer[0], buffer[1]) / scale; + + event.setSource(source); + event.setVersion(1); + event.setType(SENSOR_TYPE_AMBIENT_TEMPERATURE); + event.setTimestamp(start_time); + event.setTemperature(temp); + +} diff --git a/selfdrive/sensord/sensors/lsm6ds3_temp.h b/selfdrive/sensord/sensors/lsm6ds3_temp.h new file mode 100644 index 00000000000000..8188f467005fd7 --- /dev/null +++ b/selfdrive/sensord/sensors/lsm6ds3_temp.h @@ -0,0 +1,25 @@ +#pragma once + +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +// 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 +#define LSM6DS3TRC_TEMP_CHIP_ID 0x6A + + +class LSM6DS3_Temp : public I2CSensor { + uint8_t get_device_address() {return LSM6DS3_TEMP_I2C_ADDR;} + cereal::SensorEventData::SensorSource source = cereal::SensorEventData::SensorSource::LSM6DS3; + +public: + LSM6DS3_Temp(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/mmc5603nj_magn.cc b/selfdrive/sensord/sensors/mmc5603nj_magn.cc new file mode 100644 index 00000000000000..68878867e46a9a --- /dev/null +++ b/selfdrive/sensord/sensors/mmc5603nj_magn.cc @@ -0,0 +1,77 @@ +#include "mmc5603nj_magn.h" + +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" + +MMC5603NJ_Magn::MMC5603NJ_Magn(I2CBus *bus) : I2CSensor(bus) {} + +int MMC5603NJ_Magn::init() { + int ret = 0; + uint8_t buffer[1]; + + ret = read_register(MMC5603NJ_I2C_REG_ID, buffer, 1); + if(ret < 0) { + LOGE("Reading chip ID failed: %d", ret); + goto fail; + } + + if(buffer[0] != MMC5603NJ_CHIP_ID) { + LOGE("Chip ID wrong. Got: %d, Expected %d", buffer[0], MMC5603NJ_CHIP_ID); + ret = -1; + goto fail; + } + + // Set 100 Hz + ret = set_register(MMC5603NJ_I2C_REG_ODR, 100); + if (ret < 0) { + goto fail; + } + + // Set BW to 0b01 for 1-150 Hz operation + ret = set_register(MMC5603NJ_I2C_REG_INTERNAL_1, 0b01); + if (ret < 0) { + goto fail; + } + + // Set compute measurement rate + ret = set_register(MMC5603NJ_I2C_REG_INTERNAL_0, MMC5603NJ_CMM_FREQ_EN | MMC5603NJ_AUTO_SR_EN); + if (ret < 0) { + goto fail; + } + + // Enable continuous mode, set every 100 measurements + ret = set_register(MMC5603NJ_I2C_REG_INTERNAL_2, MMC5603NJ_CMM_EN | MMC5603NJ_EN_PRD_SET | 0b11); + if (ret < 0) { + goto fail; + } + +fail: + return ret; +} + +void MMC5603NJ_Magn::get_event(cereal::SensorEventData::Builder &event) { + + uint64_t start_time = nanos_since_boot(); + uint8_t buffer[9]; + int len = read_register(MMC5603NJ_I2C_REG_XOUT0, buffer, sizeof(buffer)); + assert(len == sizeof(buffer)); + + float scale = 1.0 / 16384.0; + float x = read_20_bit(buffer[6], buffer[1], buffer[0]) * scale; + float y = read_20_bit(buffer[7], buffer[3], buffer[2]) * scale; + float z = read_20_bit(buffer[8], buffer[5], buffer[4]) * scale; + + event.setSource(cereal::SensorEventData::SensorSource::MMC5603NJ); + 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); + +} diff --git a/selfdrive/sensord/sensors/mmc5603nj_magn.h b/selfdrive/sensord/sensors/mmc5603nj_magn.h new file mode 100644 index 00000000000000..58840bbf277dd0 --- /dev/null +++ b/selfdrive/sensord/sensors/mmc5603nj_magn.h @@ -0,0 +1,29 @@ +#pragma once + +#include "selfdrive/sensord/sensors/i2c_sensor.h" + +// Address of the chip on the bus +#define MMC5603NJ_I2C_ADDR 0x30 + +// Registers of the chip +#define MMC5603NJ_I2C_REG_XOUT0 0x00 +#define MMC5603NJ_I2C_REG_ODR 0x1A +#define MMC5603NJ_I2C_REG_INTERNAL_0 0x1B +#define MMC5603NJ_I2C_REG_INTERNAL_1 0x1C +#define MMC5603NJ_I2C_REG_INTERNAL_2 0x1D +#define MMC5603NJ_I2C_REG_ID 0x39 + +// Constants +#define MMC5603NJ_CHIP_ID 0x10 +#define MMC5603NJ_CMM_FREQ_EN (1 << 7) +#define MMC5603NJ_AUTO_SR_EN (1 << 5) +#define MMC5603NJ_CMM_EN (1 << 4) +#define MMC5603NJ_EN_PRD_SET (1 << 3) + +class MMC5603NJ_Magn : public I2CSensor { + uint8_t get_device_address() {return MMC5603NJ_I2C_ADDR;} +public: + MMC5603NJ_Magn(I2CBus *bus); + int init(); + void get_event(cereal::SensorEventData::Builder &event); +}; diff --git a/selfdrive/sensord/sensors/sensor.h b/selfdrive/sensord/sensors/sensor.h new file mode 100644 index 00000000000000..3fb58ad2ae60b5 --- /dev/null +++ b/selfdrive/sensord/sensors/sensor.h @@ -0,0 +1,10 @@ +#pragma once + +#include "cereal/gen/cpp/log.capnp.h" + +class Sensor { +public: + virtual ~Sensor() {}; + 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..fcdb9a72d78fee --- /dev/null +++ b/selfdrive/sensord/sensors_qcom.cc @@ -0,0 +1,228 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.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 + +ExitHandler do_exit; +volatile sig_atomic_t re_init_sensors = 0; + +namespace { + +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({"deviceState"}); + 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); + bool offroad = !sm["deviceState"].getDeviceState().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, -18); + 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..c3e5bbcdfae3f5 --- /dev/null +++ b/selfdrive/sensord/sensors_qcom2.cc @@ -0,0 +1,116 @@ +#include + +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/i2c.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" +#include "selfdrive/sensord/sensors/bmx055_accel.h" +#include "selfdrive/sensord/sensors/bmx055_gyro.h" +#include "selfdrive/sensord/sensors/bmx055_magn.h" +#include "selfdrive/sensord/sensors/bmx055_temp.h" +#include "selfdrive/sensord/sensors/constants.h" +#include "selfdrive/sensord/sensors/light_sensor.h" +#include "selfdrive/sensord/sensors/lsm6ds3_accel.h" +#include "selfdrive/sensord/sensors/lsm6ds3_gyro.h" +#include "selfdrive/sensord/sensors/lsm6ds3_temp.h" +#include "selfdrive/sensord/sensors/mmc5603nj_magn.h" +#include "selfdrive/sensord/sensors/sensor.h" + +#define I2C_BUS_IMU 1 + +ExitHandler do_exit; + +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); + + MMC5603NJ_Magn mmc5603nj_magn(i2c_bus_imu); + + LightSensor light("/sys/class/i2c-adapter/i2c-2/2-0038/iio:device1/in_intensity_both_raw"); + + // Sensor init + std::vector> sensors_init; // Sensor, required + sensors_init.push_back({&bmx055_accel, false}); + sensors_init.push_back({&bmx055_gyro, false}); + sensors_init.push_back({&bmx055_magn, false}); + sensors_init.push_back({&bmx055_temp, false}); + + sensors_init.push_back({&lsm6ds3_accel, true}); + sensors_init.push_back({&lsm6ds3_gyro, true}); + sensors_init.push_back({&lsm6ds3_temp, true}); + + sensors_init.push_back({&mmc5603nj_magn, false}); + + sensors_init.push_back({&light, true}); + + bool has_magnetometer = false; + + // Initialize sensors + std::vector sensors; + for (auto &sensor : sensors_init) { + int err = sensor.first->init(); + if (err < 0) { + // Fail on required sensors + if (sensor.second) { + LOGE("Error initializing sensors"); + return -1; + } + } else { + if (sensor.first == &bmx055_magn || sensor.first == &mmc5603nj_magn) { + has_magnetometer = true; + } + sensors.push_back(sensor.first); + } + } + + if (!has_magnetometer) { + LOGE("No magnetometer present"); + 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, -18); + 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/service_list.yaml b/selfdrive/service_list.yaml deleted file mode 100644 index 9d141c88d12a00..00000000000000 --- a/selfdrive/service_list.yaml +++ /dev/null @@ -1,163 +0,0 @@ -# TODO: these port numbers are hardcoded in c, fix this - -# LogRotate: 8001 is a PUSH PULL socket between loggerd and visiond - -# all ZMQ pub sub: port, should_log, frequency, (qlog_decimation) - -# frame syncing packet -frame: [8002, true, 20., 1] -# accel, gyro, and compass -sensorEvents: [8003, true, 100., 100] -# GPS data, also global timestamp -gpsNMEA: [8004, true, 9.] # 9 msgs each sec -# CPU+MEM+GPU+BAT temps -thermal: [8005, true, 1., 1] -# List(CanData), list of can messages -can: [8006, true, 100.] -controlsState: [8007, true, 100., 100] -#liveEvent: [8008, true, 0.] -model: [8009, true, 20.] -features: [8010, true, 0.] -health: [8011, true, 1., 1] -radarState: [8012, true, 20.] -#liveUI: [8014, true, 0.] -encodeIdx: [8015, true, 20.] -liveTracks: [8016, true, 20.] -sendcan: [8017, true, 100.] -logMessage: [8018, true, 0.] -liveCalibration: [8019, true, 5.] -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.] -gpsLocation: [8026, true, 1., 1] -ethernetData: [8027, true, 0.] -navUpdate: [8028, true, 0.] -qcomGnss: [8029, true, 0.] -lidarPts: [8030, true, 0.] -procLog: [8031, true, 0.5] -gpsLocationExternal: [8032, true, 10., 1] -ubloxGnss: [8033, true, 10.] -clocks: [8034, true, 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.] -ubloxRaw: [8042, true, 20.] -gpsPlannerPoints: [8043, true, 0.] -gpsPlannerPlan: [8044, true, 0.] -applanixRaw: [8046, true, 0.] -orbLocation: [8047, true, 0.] -trafficEvents: [8048, true, 0.] -liveLocationTiming: [8049, true, 0.] -orbslamCorrection: [8050, true, 0.] -liveLocationCorrected: [8051, true, 0.] -orbObservation: [8052, true, 0.] -applanixLocation: [8053, true, 0.] -liveLocationKalman: [8054, true, 0.] -uiNavigationEvent: [8055, true, 0.] -orbOdometry: [8057, true, 0.] -orbFeatures: [8058, false, 0.] -orbKeyFrame: [8059, true, 0.] -uiLayoutState: [8060, true, 0.] -frontEncodeIdx: [8061, true, 5.] -orbFeaturesSummary: [8062, true, 0.] -driverMonitoring: [8063, true, 5., 1] -liveParameters: [8064, true, 10.] -liveMapData: [8065, true, 0.] -cameraOdometry: [8066, true, 5.] -pathPlan: [8067, true, 20.] -kalmanOdometry: [8068, true, 0.] -thumbnail: [8069, true, 0.2, 1] -carEvents: [8070, true, 1., 1] -carParams: [8071, true, 0.02, 1] - -testModel: [8040, false, 0.] -testLiveLocation: [8045, false, 0.] -testJoystick: [8056, false, 0.] - -# 8080 is reserved for slave testing daemon -# 8762 is reserved for logserver - -# manager -- base process to manage starting and stopping of all others -# subscribes: thermal - -# **** processes that communicate with the outside world **** - -# thermald -- decides when to start and stop onroad -# subscribes: health, location -# publishes: thermal - -# boardd -- communicates with the car -# subscribes: sendcan -# publishes: can, health, ubloxRaw - -# sensord -- publishes IMU and Magnetometer -# publishes: sensorEvents - -# gpsd -- publishes EON's gps -# publishes: gpsNMEA - -# visiond -- talks to the cameras, runs the model, saves the videos -# publishes: frame, model, driverMonitoring, cameraOdometry, thumbnail - -# **** stateful data transformers **** - -# 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 -# publishes: carState, carControl, sendcan, controlsState, carEvents, carParams - -# radard -- processes the radar and vision data -# subscribes: can, controlsState, model, liveParameters -# publishes: radarState, liveTracks - -# params_learner -- learns vehicle params by observing the vehicle dynamics -# subscribes: controlsState, sensorEvents, cameraOdometry -# publishes: liveParameters - -# calibrationd -- reads posenet and applies a temporal filter on the frame region to look at -# subscribes: cameraOdometry -# publishes: liveCalibration - -# ubloxd -- read raw ublox data and converts them in readable format -# subscribes: ubloxRaw -# publishes: ubloxGnss - -# **** LOGGING SERVICE **** - -# loggerd -# subscribes: EVERYTHING - -# **** NON VITAL SERVICES **** - -# ui -# subscribes: thermal, model, controlsState, uiLayout, liveCalibration, radarState, liveMpc, plusFrame, liveMapData - -# uploader -# communicates through file system with loggerd - -# deleter -# communicates through file system with loggerd and uploader - -# logmessaged -- central logging service, can log to cloud -# publishes: logMessage - -# logcatd -- fetches logcat info from android -# publishes: androidLog - -# proclogd -- fetches process information -# publishes: procLog - -# tombstoned -- reports native crashes - -# athenad -- on request, open a sub socket and return the value - -# updated -- waits for network access and tries to update every hour 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..a987bfe72c00a1 100644 --- a/selfdrive/swaglog.py +++ b/selfdrive/swaglog.py @@ -1,11 +1,72 @@ -import os import logging +import os +import time +from pathlib import Path +from logging.handlers import BaseRotatingHandler import zmq -from common.logging_extra import SwagLogger, SwagFormatter +from common.logging_extra import SwagLogger, SwagFormatter, SwagLogFileFormatter +from selfdrive.hardware import PC + +if PC: + SWAGLOG_DIR = os.path.join(str(Path.home()), ".comma", "log") +else: + SWAGLOG_DIR = "/data/log/" + +def get_file_handler(): + Path(SWAGLOG_DIR).mkdir(parents=True, exist_ok=True) + base_filename = os.path.join(SWAGLOG_DIR, "swaglog") + handler = SwaglogRotatingFileHandler(base_filename) + return handler + +class SwaglogRotatingFileHandler(BaseRotatingHandler): + def __init__(self, base_filename, interval=60, max_bytes=1024*256, backup_count=2500, encoding=None): + super().__init__(base_filename, mode="a", encoding=encoding, delay=True) + self.base_filename = base_filename + self.interval = interval # seconds + self.max_bytes = max_bytes + self.backup_count = backup_count + self.log_files = self.get_existing_logfiles() + log_indexes = [f.split(".")[-1] for f in self.log_files] + self.last_file_idx = max([int(i) for i in log_indexes if i.isdigit()] or [-1]) + self.last_rollover = None + self.doRollover() + + def _open(self): + self.last_rollover = time.monotonic() + self.last_file_idx += 1 + next_filename = f"{self.base_filename}.{self.last_file_idx:010}" + stream = open(next_filename, self.mode, encoding=self.encoding) + self.log_files.insert(0, next_filename) + return stream + + def get_existing_logfiles(self): + log_files = list() + base_dir = os.path.dirname(self.base_filename) + for fn in os.listdir(base_dir): + fp = os.path.join(base_dir, fn) + if fp.startswith(self.base_filename) and os.path.isfile(fp): + log_files.append(fp) + return sorted(log_files) + + def shouldRollover(self, record): + size_exceeded = self.max_bytes > 0 and self.stream.tell() >= self.max_bytes + time_exceeded = self.interval > 0 and self.last_rollover + self.interval <= time.monotonic() + return size_exceeded or time_exceeded + + def doRollover(self): + if self.stream: + self.stream.close() + self.stream = self._open() -class LogMessageHandler(logging.Handler): + if self.backup_count > 0: + while len(self.log_files) > self.backup_count: + to_delete = self.log_files.pop() + if os.path.exists(to_delete): # just being safe, should always exist + os.remove(to_delete) + +class UnixDomainSocketHandler(logging.Handler): def __init__(self, formatter): logging.Handler.__init__(self) self.setFormatter(formatter) @@ -14,6 +75,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 +86,37 @@ 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_file_handler(log): + """ + Function to add the file log handler to swaglog. + This can be used to store logs when logmessaged is not running. + """ + handler = get_file_handler() + handler.setFormatter(SwagLogFileFormatter(log)) + log.addHandler(handler) + + cloudlog = log = SwagLogger() log.setLevel(logging.DEBUG) + outhandler = logging.StreamHandler() -log.addHandler(outhandler) -log.addHandler(LogMessageHandler(SwagFormatter(log))) +print_level = os.environ.get('LOGPRINT', 'warning') +if print_level == 'debug': + outhandler.setLevel(logging.DEBUG) +elif print_level == 'info': + outhandler.setLevel(logging.INFO) +elif print_level == 'warning': + outhandler.setLevel(logging.WARNING) + +log.addHandler(outhandler) +# logs are sent through IPC before writing to disk to prevent disk I/O blocking +log.addHandler(UnixDomainSocketHandler(SwagFormatter(log))) diff --git a/selfdrive/test/helpers.py b/selfdrive/test/helpers.py new file mode 100644 index 00000000000000..0bb475c9296123 --- /dev/null +++ b/selfdrive/test/helpers.py @@ -0,0 +1,59 @@ +import os +import time +from functools import wraps + +from selfdrive.hardware import PC +from selfdrive.manager.process_config import managed_processes +from selfdrive.version import training_version, terms_version + + +def set_params_enabled(): + from common.params import Params + params = Params() + params.put("HasAcceptedTerms", terms_version) + params.put("CompletedTrainingVersion", training_version) + params.put_bool("OpenpilotEnabledToggle", True) + params.put_bool("CommunityFeaturesToggle", True) + params.put_bool("Passive", False) + + +def phone_only(f): + @wraps(f) + def wrap(self, *args, **kwargs): + if PC: + self.skipTest("This test is not meant to run on PC") + f(self, *args, **kwargs) + return wrap + +def release_only(f): + @wraps(f) + def wrap(self, *args, **kwargs): + if "RELEASE" not in os.environ: + self.skipTest("This test is only for release branches") + f(self, *args, **kwargs) + return wrap + +def with_processes(processes, init_time=0, ignore_stopped=None): + ignore_stopped = [] if ignore_stopped is None else ignore_stopped + + def wrapper(func): + @wraps(func) + def wrap(*args, **kwargs): + # start and assert started + for n, p in enumerate(processes): + managed_processes[p].start() + if n < len(processes) - 1: + time.sleep(init_time) + assert all(managed_processes[name].proc.exitcode is None for name in processes) + + # call the function + try: + func(*args, **kwargs) + # assert processes are still started + assert all(managed_processes[name].proc.exitcode is None for name in processes if name not in ignore_stopped) + finally: + for p in processes: + managed_processes[p].stop() + + return wrap + return wrapper diff --git a/selfdrive/test/plant/maneuver.py b/selfdrive/test/plant/maneuver.py deleted file mode 100644 index 551fbd0d9e10e2..00000000000000 --- a/selfdrive/test/plant/maneuver.py +++ /dev/null @@ -1,72 +0,0 @@ -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.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 - ) - - 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) - if controls_state: - last_controls_state = controls_state[-1] - - d_rel = distance_lead - distance if self.lead_relevancy else 200. - v_rel = speed_lead - speed if self.lead_relevancy else 0. - - if last_controls_state: - # print(last_controls_state) - #develop plots - plot.add_data( - time=plant.current_time(), - gas=gas, brake=brake, steer_torque=steer_torque, - distance=distance, speed=speed, acceleration=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=fcw) - - print("maneuver end") - - return (None, plot) - - 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 e39bafd7921961..00000000000000 --- a/selfdrive/test/plant/plant.py +++ /dev/null @@ -1,393 +0,0 @@ -#!/usr/bin/env python -import os -import struct -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() - - 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): - can_msgs.extend(can_capnp_to_can_list(a.sendcan, [0,2])) - self.cp.update_can(can_msgs) - - # ******** get controlsState messages for plotting *** - controls_state_msgs = [] - for a in messaging.drain_sock(Plant.controls_state): - 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', - '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', - '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, #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 - 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]) - - Plant.logcan.send(can_list_to_can_capnp(can_msgs)) - - # 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.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.descriptor = [0.] * 7 - 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 - md.model.lead.dist = float(d_rel) - md.model.lead.prob = 1. - md.model.lead.std = 0.1 - cal.liveCalibration.calStatus = 1 - cal.liveCalibration.calPerc = 100 - # fake values? - Plant.model.send(md.to_bytes()) - Plant.cal.send(cal.to_bytes()) - - # ******** 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 - - self.rk.keep_time() - return (distance, speed, acceleration, distance_lead, brake, gas, steer_torque, fcw, 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..260a1b44874730 --- /dev/null +++ b/selfdrive/test/setup_device_ci.sh @@ -0,0 +1,72 @@ +#!/usr/bin/bash + +set -e + +if [ -z "$SOURCE_DIR" ]; then + echo "SOURCE_DIR must be set" + exit 1 +fi + +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 + +umount /data/safe_staging/merged/ || true +sudo umount /data/safe_staging/merged/ || true + +if [ -f "/EON" ]; then + rm -rf /data/core + rm -rf /data/neoupdate + rm -rf /data/safe_staging +fi + +export KEYS_PATH="/usr/comma/setup_keys" +export CONTINUE_PATH="/data/continue.sh" +if [ -f "/EON" ]; then + export KEYS_PATH="/data/data/com.termux/files/home/setup_keys" + export CONTINUE_PATH="/data/data/com.termux/files/continue.sh" +fi +tee $CONTINUE_PATH << EOF +#!/usr/bin/bash + +PARAMS_ROOT="/data/params/d" + +while true; do + mkdir -p \$PARAMS_ROOT + cp $KEYS_PATH \$PARAMS_ROOT/GithubSshKeys + echo -n 1 > \$PARAMS_ROOT/SshEnabled + sleep 1m +done + +sleep infinity +EOF +chmod +x $CONTINUE_PATH + +# set up environment +if [ ! -d "$SOURCE_DIR" ]; then + git clone https://github.com/commaai/openpilot.git $SOURCE_DIR +fi +cd $SOURCE_DIR + +rm -f .git/index.lock +git reset --hard +git fetch +find . -maxdepth 1 -not -path './.git' -not -name '.' -not -name '..' -exec rm -rf '{}' \; +git fetch --verbose origin $GIT_COMMIT +git reset --hard $GIT_COMMIT +git checkout $GIT_COMMIT +git clean -xdf +git submodule update --init --recursive +git submodule foreach --recursive "git reset --hard && git clean -xdf" + +echo "git checkout done, t=$SECONDS" + +rsync -a --delete $SOURCE_DIR $TEST_DIR + +echo "$TEST_DIR synced with $GIT_COMMIT, t=$SECONDS" diff --git a/selfdrive/test/test_fingerprints.py b/selfdrive/test/test_fingerprints.py index 721ea163fcc8af..07e47748271cdc 100755 --- a/selfdrive/test/test_fingerprints.py +++ b/selfdrive/test/test_fingerprints.py @@ -1,8 +1,15 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import os import sys from common.basedir import BASEDIR +# 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: # - keys are all the car names that which we have a fingerprint dict for @@ -20,9 +27,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,31 +45,51 @@ def check_fingerprint_consistency(f1, f2): return not is_f1_in_f2 and not is_f2_in_f1 -fingerprints = _get_fingerprints() -fingerprints_flat = [] -car_names = [] -for brand in fingerprints: - for car in fingerprints[brand]: - fingerprints_flat += fingerprints[brand][car] - for i in range(len(fingerprints[brand][car])): - car_names.append(car) - - -valid = True -for idx1, f1 in enumerate(fingerprints_flat): - for idx2, f2 in enumerate(fingerprints_flat): - if idx1 < idx2 and not check_fingerprint_consistency(f1, f2): - valid = False - print("Those two fingerprints are inconsistent {0} {1}".format(car_names[idx1], car_names[idx2])) - print("") - print(', '.join("%d: %d" % v for v in sorted(f1.items()))) - print("") - print(', '.join("%d: %d" % v for v in sorted(f2.items()))) - print("") - -print("Found {0} individual fingerprints".format(len(fingerprints_flat))) -if not valid or len(fingerprints_flat) == 0: - print("TEST FAILED") - sys.exit(1) -else: - print("TEST SUCESSFUL") +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) + + + +if __name__ == "__main__": + fingerprints = _get_fingerprints() + + fingerprints_flat = [] + car_names = [] + brand_names = [] + for brand in fingerprints: + for car in fingerprints[brand]: + 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): + for idx2, f2 in enumerate(fingerprints_flat): + if idx1 < idx2 and not check_fingerprint_consistency(f1, f2): + valid = False + print("Those two fingerprints are inconsistent {0} {1}".format(car_names[idx1], car_names[idx2])) + print("") + print(', '.join("%d: %d" % v for v in sorted(f1.items()))) + print("") + print(', '.join("%d: %d" % v for v in sorted(f2.items()))) + print("") + + print("Found {0} individual fingerprints".format(len(fingerprints_flat))) + if not valid or len(fingerprints_flat) == 0: + print("TEST FAILED") + sys.exit(1) + else: + print("TEST SUCESSFUL") diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py new file mode 100755 index 00000000000000..bc44aa3ea1d6ff --- /dev/null +++ b/selfdrive/test/test_onroad.py @@ -0,0 +1,267 @@ +#!/usr/bin/env python3 +import json +import os +import subprocess +import time +import numpy as np +import unittest +from collections import Counter +from pathlib import Path + +from cereal import car +import cereal.messaging as messaging +from cereal.services import service_list +from common.basedir import BASEDIR +from common.timeout import Timeout +from common.params import Params +from selfdrive.controls.lib.events import EVENTS, ET +from selfdrive.hardware import EON, TICI +from selfdrive.loggerd.config import ROOT +from selfdrive.test.helpers import set_params_enabled, release_only +from tools.lib.logreader import LogReader + +# Baseline CPU usage by process +PROCS = { + "selfdrive.controls.controlsd": 50.0, + "./loggerd": 45.0, + "./locationd": 9.1, + "selfdrive.controls.plannerd": 22.6, + "./_ui": 20.0, + "selfdrive.locationd.paramsd": 9.1, + "./camerad": 7.07, + "./_sensord": 6.17, + "selfdrive.controls.radard": 5.67, + "./_modeld": 4.48, + "./boardd": 3.63, + "./_dmonitoringmodeld": 2.67, + "selfdrive.thermald.thermald": 2.41, + "selfdrive.locationd.calibrationd": 2.0, + "./_soundd": 1.0, + "selfdrive.monitoring.dmonitoringd": 1.90, + "./proclogd": 1.54, + "selfdrive.logmessaged": 0.2, + "./clocksd": 0.02, + "./ubloxd": 0.02, + "selfdrive.tombstoned": 0, + "./logcatd": 0, +} + +if EON: + PROCS.update({ + "selfdrive.hardware.eon.androidd": 0.4, + }) + +if TICI: + PROCS.update({ + "./loggerd": 70.0, + "selfdrive.controls.controlsd": 28.0, + "./camerad": 31.0, + "./_ui": 30.2, + "selfdrive.controls.plannerd": 11.7, + "./_dmonitoringmodeld": 10.0, + "selfdrive.locationd.paramsd": 5.0, + "selfdrive.controls.radard": 3.6, + "selfdrive.thermald.thermald": 1.5, + }) + + +TIMINGS = { + # rtols: max/min, rsd + "can": [2.5, 0.35], + "pandaStates": [2.5, 0.35], + "peripheralState": [2.5, 0.35], + "sendcan": [2.5, 0.35], + "carState": [2.5, 0.35], + "carControl": [2.5, 0.35], + "controlsState": [2.5, 0.35], + "lateralPlan": [2.5, 0.5], + "longitudinalPlan": [2.5, 0.5], + "roadCameraState": [2.5, 0.35], + "driverCameraState": [2.5, 0.35], + "modelV2": [2.5, 0.35], + "driverState": [2.5, 0.35], + "liveLocationKalman": [2.5, 0.35], +} +if EON: + TIMINGS.update({ + "roadCameraState": [2.5, 0.45], + }) +if TICI: + TIMINGS.update({ + "wideRoadCameraState": [1.5, 0.35], + }) + + +def cputime_total(ct): + return ct.cpuUser + ct.cpuSystem + ct.cpuChildrenUser + ct.cpuChildrenSystem + + +def check_cpu_usage(first_proc, last_proc): + result = "\n" + result += "------------------------------------------------\n" + result += "------------------ CPU Usage -------------------\n" + result += "------------------------------------------------\n" + + r = True + dt = (last_proc.logMonoTime - first_proc.logMonoTime) / 1e9 + for proc_name, normal_cpu_usage in PROCS.items(): + first, last = None, None + 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.15, normal_cpu_usage + 5.0): + # cpu usage is high while playing sounds + if not (proc_name == "./_soundd" and cpu_usage < 65.): + 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 {first=} {last=}\n" + r = False + result += "------------------------------------------------\n" + print(result) + return r + + +class TestOnroad(unittest.TestCase): + + @classmethod + def setUpClass(cls): + if "DEBUG" in os.environ: + segs = filter(lambda x: os.path.exists(os.path.join(x, "rlog.bz2")), Path(ROOT).iterdir()) + segs = sorted(segs, key=lambda x: x.stat().st_mtime) + cls.lr = list(LogReader(os.path.join(segs[-1], "rlog.bz2"))) + return + + # setup env + os.environ['REPLAY'] = "1" + os.environ['SKIP_FW_QUERY'] = "1" + os.environ['FINGERPRINT'] = "TOYOTA COROLLA TSS2 2019" + + params = Params() + params.clear_all() + set_params_enabled() + + # Make sure athena isn't running + os.system("pkill -9 -f athena") + + # start manager and run openpilot for a minute + try: + manager_path = os.path.join(BASEDIR, "selfdrive/manager/manager.py") + proc = subprocess.Popen(["python", manager_path]) + + sm = messaging.SubMaster(['carState']) + with Timeout(150, "controls didn't start"): + while sm.rcv_frame['carState'] < 0: + sm.update(1000) + + # make sure we get at least two full segments + route = None + cls.segments = [] + with Timeout(300, "timed out waiting for logs"): + while route is None: + route = params.get("CurrentRoute", encoding="utf-8") + time.sleep(0.1) + + while len(cls.segments) < 3: + segs = set() + if Path(ROOT).exists(): + segs = set(Path(ROOT).glob(f"{route}--*")) + cls.segments = sorted(segs, key=lambda s: int(str(s).rsplit('--')[-1])) + time.sleep(2) + + # chop off last, incomplete segment + cls.segments = cls.segments[:-1] + + finally: + proc.terminate() + if proc.wait(60) is None: + proc.kill() + + cls.lrs = [list(LogReader(os.path.join(str(s), "rlog.bz2"))) for s in cls.segments] + + # use the second segment by default as it's the first full segment + cls.lr = list(LogReader(os.path.join(str(cls.segments[1]), "rlog.bz2"))) + + def test_cloudlog_size(self): + msgs = [m for m in self.lr if m.which() == 'logMessage'] + + total_size = sum(len(m.as_builder().to_bytes()) for m in msgs) + self.assertLess(total_size, 3.5e5) + + cnt = Counter(json.loads(m.logMessage)['filename'] for m in msgs) + big_logs = [f for f, n in cnt.most_common(3) if n / sum(cnt.values()) > 30.] + self.assertEqual(len(big_logs), 0, f"Log spam: {big_logs}") + + def test_cpu_usage(self): + proclogs = [m for m in self.lr if m.which() == 'procLog'] + self.assertGreater(len(proclogs), service_list['procLog'].frequency * 45, "insufficient samples") + cpu_ok = check_cpu_usage(proclogs[0], proclogs[-1]) + self.assertTrue(cpu_ok) + + def test_model_execution_timings(self): + result = "\n" + result += "------------------------------------------------\n" + result += "----------------- Model Timing -----------------\n" + result += "------------------------------------------------\n" + # TODO: this went up when plannerd cpu usage increased, why? + cfgs = [("modelV2", 0.038, 0.036), ("driverState", 0.028, 0.026)] + for (s, instant_max, avg_max) in cfgs: + ts = [getattr(getattr(m, s), "modelExecutionTime") for m in self.lr if m.which() == s] + self.assertLess(min(ts), instant_max, f"high '{s}' execution time: {min(ts)}") + self.assertLess(np.mean(ts), avg_max, f"high avg '{s}' execution time: {np.mean(ts)}") + result += f"'{s}' execution time: {min(ts)}\n" + result += f"'{s}' avg execution time: {np.mean(ts)}\n" + result += "------------------------------------------------\n" + print(result) + + def test_timings(self): + passed = True + result = "\n" + result += "------------------------------------------------\n" + result += "----------------- Service Timings --------------\n" + result += "------------------------------------------------\n" + for s, (maxmin, rsd) in TIMINGS.items(): + msgs = [m.logMonoTime for m in self.lr if m.which() == s] + if not len(msgs): + raise Exception(f"missing {s}") + + ts = np.diff(msgs) / 1e9 + dt = 1 / service_list[s].frequency + + try: + np.testing.assert_allclose(np.mean(ts), dt, rtol=0.03, err_msg=f"{s} - failed mean timing check") + np.testing.assert_allclose([np.max(ts), np.min(ts)], dt, rtol=maxmin, err_msg=f"{s} - failed max/min timing check") + except Exception as e: + result += str(e) + "\n" + passed = False + + if np.std(ts) / dt > rsd: + result += f"{s} - failed RSD timing check\n" + passed = False + + result += f"{s.ljust(40)}: {np.array([np.mean(ts), np.max(ts), np.min(ts)])*1e3}\n" + result += f"{''.ljust(40)} {np.max(np.absolute([np.max(ts)/dt, np.min(ts)/dt]))} {np.std(ts)/dt}\n" + result += "="*67 + print(result) + self.assertTrue(passed) + + @release_only + def test_startup(self): + startup_alert = None + for msg in self.lrs[0]: + # can't use carEvents because the first msg can be dropped while loggerd is starting up + if msg.which() == "controlsState": + startup_alert = msg.controlsState.alertText1 + break + expected = EVENTS[car.CarEvent.EventName.startup][ET.PERMANENT].alert_text_1 + self.assertEqual(startup_alert, expected, "wrong startup alert") + + +if __name__ == "__main__": + unittest.main() diff --git a/selfdrive/test/test_openpilot.py b/selfdrive/test/test_openpilot.py deleted file mode 100644 index 13770f50a5ff6b..00000000000000 --- a/selfdrive/test/test_openpilot.py +++ /dev/null @@ -1,93 +0,0 @@ -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 -import time - -DID_INIT = False - -# must run first -@phone_only -def test_manager_prepare(): - global DID_INIT - 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']) -def test_logging(): - print("LOGGING IS SET UP") - time.sleep(1.0) - -@phone_only -@with_processes(['visiond']) -def test_visiond(): - print("VISIOND IS SET UP") - time.sleep(5.0) - -@phone_only -@with_processes(['sensord']) -def test_sensord(): - print("SENSORS ARE SET UP") - time.sleep(1.0) - -@phone_only -@with_processes(['ui']) -def test_ui(): - print("RUNNING UI") - time.sleep(1.0) - -# will have one thing to upload if loggerd ran -# TODO: assert it actually uploaded -@phone_only -@with_processes(['uploader']) -def test_uploader(): - print("UPLOADER") - time.sleep(10.0) diff --git a/selfdrive/test/tests/plant/test_longitudinal.py b/selfdrive/test/tests/plant/test_longitudinal.py deleted file mode 100755 index 9806f5a19015a4..00000000000000 --- a/selfdrive/test/tests/plant/test_longitudinal.py +++ /dev/null @@ -1,339 +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 - -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)] - ), - 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)] - ), - 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.] - ), - 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.] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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)] - ), - 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 = [] - ), - 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 = [] - ), - 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 = [] - ), - 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 = [] - ) -] - -# 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): - - 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 - -WORKERS = 8 -def run_maneuver_worker(k): - output_dir = os.path.join(os.getcwd(), 'out/longitudinal') - for i, man in enumerate(maneuvers[k::WORKERS]): - manager.start_managed_process('radard') - manager.start_managed_process('controlsd') - manager.start_managed_process('plannerd') - - score, plot = man.evaluate() - plot.write_plot(output_dir, "maneuver" + str(WORKERS * i + k+1).zfill(2)) - - manager.kill_managed_process('radard') - manager.kill_managed_process('controlsd') - manager.kill_managed_process('plannerd') - time.sleep(5) - -for k in xrange(WORKERS): - setattr(LongitudinalControl, - "test_longitudinal_maneuvers_%d" % (k+1), - lambda self, k=k: run_maneuver_worker(k)) - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py deleted file mode 100755 index ef75cfffd982f1..00000000000000 --- a/selfdrive/thermald.py +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/env python2.7 -import os -from smbus2 import SMBus -from cereal import log -from selfdrive.version import 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 -from common.numpy_fast import clip -from common.filter_simple import FirstOrderFilter - -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. - - -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): - - # charging disallowed if: - # - there are health packets from panda, and; - # - 12V battery voltage is too low, and; - # - onroad isn't started - if charging_disabled and (health is None or health.health.voltage > 11800): - 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: - charging_disabled = True - os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled') - - return charging_disabled - - -def thermald_thread(): - 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 = 1500 - current_filter = FirstOrderFilter(0., CURRENT_TAU, 1.) - 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 - 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())) - - 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 > 95. 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 > 90.0: - # hysteresis between engage not allowed and uploader not allowed - thermal_status = clip(thermal_status, ThermalStatus.yellow, ThermalStatus.red) - elif max_cpu_temp > 85.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 - 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") == "1" - 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: - 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.thermal.chargingDisabled = charging_disabled - msg.thermal.chargingError = current_filter.x > 0. and msg.thermal.batteryPercent < 90 # 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()) - print(msg) - - # report to server once per minute - if (count%60) == 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..9c0736391728e8 --- /dev/null +++ b/selfdrive/thermald/power_monitoring.py @@ -0,0 +1,189 @@ +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 # Lower limit on the LPF car battery voltage +VBATT_INSTANT_PAUSE_CHARGING = 7.0 # Lower limit on the instant car battery voltage measurements to avoid triggering on instant power loss +MAX_TIME_OFFROAD_S = 30*3600 +MIN_ON_TIME_S = 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 peripheralState voltage + self.car_voltage_instant_mV = 12e3 # Last value of peripheralState 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, peripheralState, ignition): + try: + now = sec_since_boot() + + # If peripheralState is None, we're probably not in a car, so we don't care + if peripheralState is None or peripheralState.pandaType == log.PandaState.PandaType.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_instant_mV = peripheralState.voltage + self.car_voltage_mV = ((peripheralState.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 ignition: + # 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 = peripheralState.pandaType == log.PandaState.PandaType.uno + # Get current power draw somehow + current_power = HARDWARE.get_current_power_draw() # pylint: disable=assignment-from-none + 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, ignition, in_car, offroad_timestamp): + if 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)) and (self.car_voltage_instant_mV > (VBATT_INSTANT_PAUSE_CHARGING * 1e3)) + disable_charging |= (self.car_battery_capacity_uWh <= 0) + disable_charging &= not ignition + disable_charging &= (not self.params.get_bool("DisablePowerDown")) + disable_charging &= in_car + disable_charging |= self.params.get_bool("ForcePowerDown") + return disable_charging + + # See if we need to shutdown + def should_shutdown(self, peripheralState, ignition, in_car, offroad_timestamp, started_seen): + if offroad_timestamp is None: + return False + + now = sec_since_boot() + panda_charging = (peripheralState.usbPowerMode != log.PeripheralState.UsbPowerMode.client) + BATT_PERC_OFF = 10 + + should_shutdown = False + # Wait until we have shut down charging before powering down + should_shutdown |= (not panda_charging and self.should_disable_charging(ignition, in_car, 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 or (now > MIN_ON_TIME_S) + return should_shutdown diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py new file mode 100755 index 00000000000000..1b467f9627bbaf --- /dev/null +++ b/selfdrive/thermald/thermald.py @@ -0,0 +1,432 @@ +#!/usr/bin/env python3 +import datetime +import os +import time +from pathlib import Path +from typing import Dict, Optional, Tuple +from collections import namedtuple, OrderedDict + +import psutil +from smbus2 import SMBus + +import cereal.messaging as messaging +from cereal import log +from common.filter_simple import FirstOrderFilter +from common.numpy_fast import interp +from common.params import Params, ParamKeyType +from common.realtime import DT_TRML, sec_since_boot +from common.dict_helpers import strip_deprecated_keys +from selfdrive.controls.lib.alertmanager import set_offroad_alert +from selfdrive.controls.lib.pid import PIController +from selfdrive.hardware import EON, TICI, PC, HARDWARE +from selfdrive.loggerd.config import get_available_percent +from selfdrive.swaglog import cloudlog +from selfdrive.thermald.power_monitoring import PowerMonitoring +from selfdrive.version import terms_version, training_version + +ThermalStatus = log.DeviceState.ThermalStatus +NetworkType = log.DeviceState.NetworkType +NetworkStrength = log.DeviceState.NetworkStrength +CURRENT_TAU = 15. # 15s time constant +TEMP_TAU = 5. # 5s time constant +DISCONNECT_TIMEOUT = 5. # wait 5 seconds before going offroad after disconnect so you get an alert + +ThermalBand = namedtuple("ThermalBand", ['min_temp', 'max_temp']) + +# List of thermal bands. We will stay within this region as long as we are within the bounds. +# When exiting the bounds, we'll jump to the lower or higher band. Bands are ordered in the dict. +THERMAL_BANDS = OrderedDict({ + ThermalStatus.green: ThermalBand(None, 80.0), + ThermalStatus.yellow: ThermalBand(75.0, 96.0), + ThermalStatus.red: ThermalBand(80.0, 107.), + ThermalStatus.danger: ThermalBand(94.0, None), +}) + +# Override to highest thermal band when offroad and above this temp +OFFROAD_DANGER_TEMP = 79.5 if TICI else 70.0 + +prev_offroad_states: Dict[str, Tuple[bool, Optional[str]]] = {} + +def read_tz(x): + if x is None: + return 0 + + try: + with open(f"/sys/devices/virtual/thermal/thermal_zone{x}/temp") as f: + return int(f.read()) + except FileNotFoundError: + return 0 + + +def read_thermal(thermal_config): + dat = messaging.new_message('deviceState') + dat.deviceState.cpuTempC = [read_tz(z) / thermal_config.cpu[1] for z in thermal_config.cpu[0]] + dat.deviceState.gpuTempC = [read_tz(z) / thermal_config.gpu[1] for z in thermal_config.gpu[0]] + dat.deviceState.memoryTempC = read_tz(thermal_config.mem[0]) / thermal_config.mem[1] + dat.deviceState.ambientTempC = read_tz(thermal_config.ambient[0]) / thermal_config.ambient[1] + dat.deviceState.pmicTempC = [read_tz(z) / thermal_config.pmic[1] for z in thermal_config.pmic[0]] + return dat + + +def setup_eon_fan(): + os.system("echo 2 > /sys/module/dwc3_msm/parameters/otg_switch") + + +last_eon_fan_val = None +def set_eon_fan(val): + global last_eon_fan_val + + if last_eon_fan_val is None or last_eon_fan_val != val: + bus = SMBus(7, force=True) + 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]) + 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] + + +def handle_fan_eon(controller, max_cpu_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 + + set_eon_fan(fan_speed // 16384) + + return fan_speed + + +def handle_fan_uno(controller, max_cpu_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 + + +last_ignition = False +def handle_fan_tici(controller, max_cpu_temp, fan_speed, ignition): + global last_ignition + + controller.neg_limit = -(80 if ignition else 30) + controller.pos_limit = -(30 if ignition else 0) + + if ignition != last_ignition: + controller.reset() + + fan_pwr_out = -int(controller.update( + setpoint=75, + measurement=max_cpu_temp, + feedforward=interp(max_cpu_temp, [60.0, 100.0], [0, -80]) + )) + + last_ignition = ignition + return fan_pwr_out + + +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(): + + pm = messaging.PubMaster(['deviceState']) + + pandaState_timeout = int(1000 * 2.5 * DT_TRML) # 2.5x the expected pandaState frequency + pandaState_sock = messaging.sub_sock('pandaStates', timeout=pandaState_timeout) + sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "managerState"]) + + fan_speed = 0 + count = 0 + + onroad_conditions = { + "ignition": False, + } + startup_conditions = {} + startup_conditions_prev = {} + + off_ts = None + started_ts = None + started_seen = False + thermal_status = ThermalStatus.green + usb_power = True + + network_type = NetworkType.none + network_strength = NetworkStrength.unknown + network_info = None + modem_version = None + registered_count = 0 + nvme_temps = None + modem_temps = None + + current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML) + temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_TRML) + pandaState_prev = None + should_start_prev = False + in_car = False + handle_fan = None + is_uno = False + ui_running_prev = False + + params = Params() + power_monitor = PowerMonitoring() + no_panda_cnt = 0 + + HARDWARE.initialize_hardware() + thermal_config = HARDWARE.get_thermal_config() + + # TODO: use PI controller for UNO + controller = PIController(k_p=0, k_i=2e-3, neg_limit=-80, pos_limit=0, rate=(1 / DT_TRML)) + + # Leave flag for loggerd to indicate device was left onroad + if params.get_bool("IsOnroad"): + params.put_bool("BootedOnroad", True) + + while True: + pandaStates = messaging.recv_sock(pandaState_sock, wait=True) + + sm.update(0) + peripheralState = sm['peripheralState'] + + msg = read_thermal(thermal_config) + + if pandaStates is not None and len(pandaStates.pandaStates) > 0: + pandaState = pandaStates.pandaStates[0] + + # If we lose connection to the panda, wait 5 seconds before going offroad + if pandaState.pandaType == log.PandaState.PandaType.unknown: + no_panda_cnt += 1 + if no_panda_cnt > DISCONNECT_TIMEOUT / DT_TRML: + if onroad_conditions["ignition"]: + cloudlog.error("Lost panda connection while onroad") + onroad_conditions["ignition"] = False + else: + no_panda_cnt = 0 + onroad_conditions["ignition"] = pandaState.ignitionLine or pandaState.ignitionCan + + in_car = pandaState.harnessStatus != log.PandaState.HarnessStatus.notConnected + usb_power = peripheralState.usbPowerMode != log.PeripheralState.UsbPowerMode.client + + # Setup fan handler on first connect to panda + if handle_fan is None and peripheralState.pandaType != log.PandaState.PandaType.unknown: + is_uno = peripheralState.pandaType == log.PandaState.PandaType.uno + + if TICI: + cloudlog.info("Setting up TICI fan handler") + handle_fan = handle_fan_tici + elif is_uno or PC: + 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 pandaState_prev is not None: + if pandaState.pandaType == log.PandaState.PandaType.unknown and \ + pandaState_prev.pandaType != log.PandaState.PandaType.unknown: + params.clear_all(ParamKeyType.CLEAR_ON_PANDA_DISCONNECT) + pandaState_prev = pandaState + + # these are expensive calls. 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) + network_info = HARDWARE.get_network_info() # pylint: disable=assignment-from-none + nvme_temps = HARDWARE.get_nvme_temperatures() + modem_temps = HARDWARE.get_modem_temperatures() + + # Log modem version once + if modem_version is None: + modem_version = HARDWARE.get_modem_version() # pylint: disable=assignment-from-none + if modem_version is not None: + cloudlog.warning(f"Modem version: {modem_version}") + + if TICI and (network_info.get('state', None) == "REGISTERED"): + registered_count += 1 + else: + registered_count = 0 + + if registered_count > 10: + cloudlog.warning(f"Modem stuck in registered state {network_info}. nmcli conn up lte") + os.system("nmcli conn up lte") + registered_count = 0 + + except Exception: + cloudlog.exception("Error getting network status") + + msg.deviceState.freeSpacePercent = get_available_percent(default=100.0) + msg.deviceState.memoryUsagePercent = int(round(psutil.virtual_memory().percent)) + msg.deviceState.cpuUsagePercent = [int(round(n)) for n in psutil.cpu_percent(percpu=True)] + msg.deviceState.gpuUsagePercent = int(round(HARDWARE.get_gpu_usage_percent())) + msg.deviceState.networkType = network_type + msg.deviceState.networkStrength = network_strength + if network_info is not None: + msg.deviceState.networkInfo = network_info + if nvme_temps is not None: + msg.deviceState.nvmeTempC = nvme_temps + if modem_temps is not None: + msg.deviceState.modemTempC = modem_temps + + msg.deviceState.screenBrightnessPercent = HARDWARE.get_screen_brightness() + msg.deviceState.batteryPercent = HARDWARE.get_battery_capacity() + msg.deviceState.batteryCurrent = HARDWARE.get_battery_current() + msg.deviceState.usbOnline = HARDWARE.get_usb_present() + current_filter.update(msg.deviceState.batteryCurrent / 1e6) + + max_comp_temp = temp_filter.update( + max(max(msg.deviceState.cpuTempC), msg.deviceState.memoryTempC, max(msg.deviceState.gpuTempC)) + ) + + if handle_fan is not None: + fan_speed = handle_fan(controller, max_comp_temp, fan_speed, onroad_conditions["ignition"]) + msg.deviceState.fanSpeedPercentDesired = fan_speed + + 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 is_offroad_for_5_min and max_comp_temp > OFFROAD_DANGER_TEMP: + # If device is offroad we want to cool down before going onroad + # since going onroad increases load and can make temps go over 107 + thermal_status = ThermalStatus.danger + else: + current_band = THERMAL_BANDS[thermal_status] + band_idx = list(THERMAL_BANDS.keys()).index(thermal_status) + if current_band.min_temp is not None and max_comp_temp < current_band.min_temp: + thermal_status = list(THERMAL_BANDS.keys())[band_idx - 1] + elif current_band.max_temp is not None and max_comp_temp > current_band.max_temp: + thermal_status = list(THERMAL_BANDS.keys())[band_idx + 1] + + # **** starting logic **** + + # Ensure date/time are valid + now = datetime.datetime.utcnow() + 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"])) + + startup_conditions["up_to_date"] = params.get("Offroad_ConnectivityNeeded") is None or params.get_bool("DisableUpdates") or params.get_bool("SnoozeUpdate") + startup_conditions["not_uninstalling"] = not params.get_bool("DoUninstall") + startup_conditions["accepted_terms"] = params.get("HasAcceptedTerms") == terms_version + + # with 2% left, we killall, otherwise the phone will take a long time to boot + startup_conditions["free_space"] = msg.deviceState.freeSpacePercent > 2 + startup_conditions["completed_training"] = params.get("CompletedTrainingVersion") == training_version or \ + params.get_bool("Passive") + startup_conditions["not_driver_view"] = not params.get_bool("IsDriverViewEnabled") + startup_conditions["not_taking_snapshot"] = not params.get_bool("IsTakingSnapshot") + # 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 + onroad_conditions["device_temp_good"] = thermal_status < ThermalStatus.danger + set_offroad_alert_if_changed("Offroad_TemperatureTooHigh", (not onroad_conditions["device_temp_good"])) + + if TICI: + set_offroad_alert_if_changed("Offroad_StorageMissing", (not Path("/data/media").is_mount())) + + # Handle offroad/onroad transition + should_start = all(onroad_conditions.values()) + if started_ts is None: + should_start = should_start and all(startup_conditions.values()) + + if should_start != should_start_prev or (count == 0): + params.put_bool("IsOnroad", should_start) + params.put_bool("IsOffroad", not should_start) + HARDWARE.set_power_save(not should_start) + + if should_start: + off_ts = None + if started_ts is None: + started_ts = sec_since_boot() + started_seen = True + else: + if onroad_conditions["ignition"] and (startup_conditions != startup_conditions_prev): + cloudlog.event("Startup blocked", startup_conditions=startup_conditions, onroad_conditions=onroad_conditions) + + started_ts = None + if off_ts is None: + off_ts = sec_since_boot() + + # Offroad power monitoring + power_monitor.calculate(peripheralState, onroad_conditions["ignition"]) + msg.deviceState.offroadPowerUsageUwh = power_monitor.get_power_used() + msg.deviceState.carBatteryCapacityUwh = max(0, power_monitor.get_car_battery_capacity()) + current_power_draw = HARDWARE.get_current_power_draw() # pylint: disable=assignment-from-none + msg.deviceState.powerDrawW = current_power_draw if current_power_draw is not None else 0 + + # Check if we need to disable charging (handled by boardd) + msg.deviceState.chargingDisabled = power_monitor.should_disable_charging(onroad_conditions["ignition"], in_car, off_ts) + + # Check if we need to shut down + if power_monitor.should_shutdown(peripheralState, onroad_conditions["ignition"], in_car, off_ts, started_seen): + cloudlog.info(f"shutting device down, offroad since {off_ts}") + # TODO: add function for blocking cloudlog instead of sleep + time.sleep(10) + HARDWARE.shutdown() + + # If UI has crashed, set the brightness to reasonable non-zero value + ui_running = "ui" in (p.name for p in sm["managerState"].processes if p.running) + if ui_running_prev and not ui_running: + HARDWARE.set_screen_brightness(20) + ui_running_prev = ui_running + + msg.deviceState.chargingError = current_filter.x > 0. and msg.deviceState.batteryPercent < 90 # if current is positive, then battery is being discharged + msg.deviceState.started = started_ts is not None + msg.deviceState.startedMonoTime = int(1e9*(started_ts or 0)) + + last_ping = params.get("LastAthenaPingTime") + if last_ping is not None: + msg.deviceState.lastAthenaPingTime = int(last_ping) + + msg.deviceState.thermalStatus = thermal_status + pm.send("deviceState", msg) + + if EON and not is_uno: + 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 every 10 minutes + if (count % int(600. / DT_TRML)) == 0: + if EON and started_ts is None and msg.deviceState.memoryUsagePercent > 40: + cloudlog.event("High offroad memory usage", mem=msg.deviceState.memoryUsagePercent) + + cloudlog.event("STATUS_PACKET", + count=count, + pandaStates=(strip_deprecated_keys(pandaStates.to_dict()) if pandaStates else None), + peripheralState=strip_deprecated_keys(peripheralState.to_dict()), + location=(strip_deprecated_keys(sm["gpsLocationExternal"].to_dict()) if sm.alive["gpsLocationExternal"] else None), + deviceState=strip_deprecated_keys(msg.to_dict())) + + count += 1 + + +def main(): + thermald_thread() + + +if __name__ == "__main__": + main() diff --git a/selfdrive/timezoned.py b/selfdrive/timezoned.py new file mode 100755 index 00000000000000..74da5fe35cbba0 --- /dev/null +++ b/selfdrive/timezoned.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +import json +import os +import time +import subprocess + +import requests +from timezonefinder import TimezoneFinder + +from common.params import Params +from selfdrive.hardware import TICI +from selfdrive.swaglog import cloudlog + + +def set_timezone(valid_timezones, timezone): + if timezone not in valid_timezones: + cloudlog.error(f"Timezone not supported {timezone}") + return + + cloudlog.debug(f"Setting timezone to {timezone}") + try: + if TICI: + tzpath = os.path.join("/usr/share/zoneinfo/", timezone) + subprocess.check_call(f'sudo su -c "ln -snf {tzpath} /data/etc/tmptime && \ + mv /data/etc/tmptime /data/etc/localtime"', shell=True) + subprocess.check_call(f'sudo su -c "echo \"{timezone}\" > /data/etc/timezone"', shell=True) + else: + subprocess.check_call(f'sudo timedatectl set-timezone {timezone}', shell=True) + except subprocess.CalledProcessError: + cloudlog.exception(f"Error setting timezone to {timezone}") + + +def main(): + params = Params() + tf = TimezoneFinder() + + # Get allowed timezones + valid_timezones = subprocess.check_output('timedatectl list-timezones', shell=True, encoding='utf8').strip().split('\n') + + while True: + time.sleep(60) + + is_onroad = not params.get_bool("IsOffroad") + if is_onroad: + continue + + # Set based on param + timezone = params.get("Timezone", encoding='utf8') + if timezone is not None: + cloudlog.debug("Setting timezone based on param") + set_timezone(valid_timezones, timezone) + continue + + location = params.get("LastGPSPosition", encoding='utf8') + + # Find timezone based on IP geolocation if no gps location is available + if location is None: + cloudlog.debug("Setting timezone based on IP lookup") + try: + r = requests.get("https://ipapi.co/timezone", timeout=10) + if r.status_code == 200: + set_timezone(valid_timezones, r.text) + else: + cloudlog.error(f"Unexpected status code from api {r.status_code}") + + time.sleep(3600) # Don't make too many API requests + except requests.exceptions.RequestException: + cloudlog.exception("Error getting timezone based on IP") + continue + + # Find timezone by reverse geocoding the last known gps location + else: + cloudlog.debug("Setting timezone based on GPS location") + try: + location = json.loads(location) + except Exception: + cloudlog.exception("Error parsing location") + continue + + timezone = tf.timezone_at(lng=location['longitude'], lat=location['latitude']) + if timezone is None: + cloudlog.error(f"No timezone found based on location, {location}") + continue + set_timezone(valid_timezones, timezone) + + +if __name__ == "__main__": + main() diff --git a/selfdrive/tombstoned.py b/selfdrive/tombstoned.py old mode 100644 new mode 100755 index 3af76818d484cd..a301725baee709 --- a/selfdrive/tombstoned.py +++ b/selfdrive/tombstoned.py @@ -1,122 +1,234 @@ +#!/usr/bin/env python3 +import datetime import os import re +import shutil +import signal +import subprocess import time -import datetime +import glob -from raven import Client -from raven.transport.http import HTTPTransport +import sentry_sdk -from selfdrive.version import version, dirty +from common.params import Params +from common.file_helpers import mkdirs_exists_ok +from selfdrive.hardware import TICI, HARDWARE +from selfdrive.loggerd.config import ROOT from selfdrive.swaglog import cloudlog +from selfdrive.version import get_branch, get_commit, get_dirty, get_origin, get_version -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")] - -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() - else: - signal_parseddict = {} - signal = signal_parseddict.get('signal', 'unknown') - code = signal_parseddict.get('code', 'unknown') - fault_addr = signal_parseddict.get('fault_addr', '') - - abort_line = parsedict.get('abort', '') - - 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] - - - 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, - }, - ) +MAX_SIZE = 100000 * 10 # mal size is 40-100k, allow up to 1M +if TICI: + MAX_SIZE = MAX_SIZE * 100 # Allow larger size for tici since files contain coredump +MAX_TOMBSTONE_FN_LEN = 62 # 85 - 23 ("/crash/") + +TOMBSTONE_DIR = "/data/tombstones/" +APPORT_DIR = "/var/crash/" + + +def safe_fn(s): + extra = ['_'] + return "".join(c for c in s if c.isalnum() or c in extra).rstrip() + + +def sentry_report(fn, message, contents): cloudlog.error({'tombstone': message}) + with sentry_sdk.configure_scope() as scope: + scope.set_extra("tombstone_fn", fn) + scope.set_extra("tombstone", contents) + sentry_sdk.capture_message(message=message) + sentry_sdk.flush() + + +def clear_apport_folder(): + for f in glob.glob(APPORT_DIR + '*'): + try: + os.remove(f) + except Exception: + pass + + +def get_apport_stacktrace(fn): + try: + cmd = f'apport-retrace -s <(cat <(echo "Package: openpilot") "{fn}")' + return subprocess.check_output(cmd, shell=True, encoding='utf8', timeout=30, executable='/bin/bash') # pylint: disable=unexpected-keyword-arg + except subprocess.CalledProcessError: + return "Error getting stacktrace" + except subprocess.TimeoutExpired: + return "Timeout getting stacktrace" + + +def get_tombstones(): + """Returns list of (filename, ctime) for all tombstones in /data/tombstones + and apport crashlogs in /var/crash""" + files = [] + for folder in [TOMBSTONE_DIR, APPORT_DIR]: + 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_android(fn): + 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() + + message = " ".join(contents.split('\n')[5:7]) + + # Cut off pid/tid, since that varies per run + name_idx = message.find('name') + if name_idx >= 0: + message = message[name_idx:] + + executable = "" + start_exe_idx = message.find('>>> ') + end_exe_idx = message.find(' <<<') + if start_exe_idx >= 0 and end_exe_idx >= 0: + executable = message[start_exe_idx + 4:end_exe_idx] + + # Cut off fault addr + fault_idx = message.find(', fault addr') + if fault_idx >= 0: + message = message[:fault_idx] + + sentry_report(fn, message, contents) + + # Copy crashlog to upload folder + clean_path = executable.replace('./', '').replace('/', '_') + date = datetime.datetime.now().strftime("%Y-%m-%d--%H-%M-%S") + + new_fn = f"{date}_{get_commit(default='nocommit')[:8]}_{safe_fn(clean_path)}"[:MAX_TOMBSTONE_FN_LEN] + + crashlog_dir = os.path.join(ROOT, "crash") + mkdirs_exists_ok(crashlog_dir) + + shutil.copy(fn, os.path.join(crashlog_dir, new_fn)) + -def main(gctx=None): +def report_tombstone_apport(fn): + f_size = os.path.getsize(fn) + if f_size > MAX_SIZE: + cloudlog.error(f"Tombstone {fn} too big, {f_size}. Skipping...") + return + + message = "" # One line description of the crash + contents = "" # Full file contents without coredump + path = "" # File path relative to openpilot directory + + proc_maps = False + + with open(fn) as f: + for line in f: + if "CoreDump" in line: + break + elif "ProcMaps" in line: + proc_maps = True + elif "ProcStatus" in line: + proc_maps = False + + if not proc_maps: + contents += line + + if "ExecutablePath" in line: + path = line.strip().split(': ')[-1] + path = path.replace('/data/openpilot/', '') + message += path + elif "Signal" in line: + message += " - " + line.strip() + + try: + sig_num = int(line.strip().split(': ')[-1]) + message += " (" + signal.Signals(sig_num).name + ")" # pylint: disable=no-member + except ValueError: + pass + + stacktrace = get_apport_stacktrace(fn) + stacktrace_s = stacktrace.split('\n') + crash_function = "No stacktrace" + + if len(stacktrace_s) > 2: + found = False + + # Try to find first entry in openpilot, fall back to first line + for line in stacktrace_s: + if "at selfdrive/" in line: + crash_function = line + found = True + break + + if not found: + crash_function = stacktrace_s[1] + + # Remove arguments that can contain pointers to make sentry one-liner unique + crash_function = " ".join(x for x in crash_function.split(' ')[1:] if not x.startswith('0x')) + crash_function = re.sub(r'\(.*?\)', '', crash_function) + + contents = stacktrace + "\n\n" + contents + message = message + " - " + crash_function + sentry_report(fn, message, contents) + + # Copy crashlog to upload folder + clean_path = path.replace('/', '_') + date = datetime.datetime.now().strftime("%Y-%m-%d--%H-%M-%S") + + new_fn = f"{date}_{get_commit(default='nocommit')[:8]}_{safe_fn(clean_path)}"[:MAX_TOMBSTONE_FN_LEN] + + crashlog_dir = os.path.join(ROOT, "crash") + mkdirs_exists_ok(crashlog_dir) + + # Files could be on different filesystems, copy, then delete + shutil.copy(fn, os.path.join(crashlog_dir, new_fn)) + + try: + os.remove(fn) + except PermissionError: + pass + + +def main(): + clear_apport_folder() # Clear apport folder on start, otherwise duplicate crashes won't register initial_tombstones = set(get_tombstones()) - client = Client('https://d3b175702f62402c91ade04d1c547e68:b20d68c813c74f63a7cdf9c4039d8f56@sentry.io/157615', - install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty}, string_max_length=10000) + sentry_sdk.utils.MAX_STRING_LENGTH = 8192 + sentry_sdk.init("https://a40f22e13cbc4261873333c125fc9d38@o33823.ingest.sentry.io/157615", + default_integrations=False, release=get_version()) + + dongle_id = Params().get("DongleId", encoding='utf-8') + sentry_sdk.set_user({"id": dongle_id}) + sentry_sdk.set_tag("dirty", get_dirty()) + sentry_sdk.set_tag("origin", get_origin()) + sentry_sdk.set_tag("branch", get_branch()) + sentry_sdk.set_tag("commit", get_commit()) + sentry_sdk.set_tag("device", HARDWARE.get_device_type()) - 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}") + if fn.endswith(".crash"): + report_tombstone_apport(fn) + else: + report_tombstone_android(fn) + 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 index 2c850c209048d5..5d656f889ef9c8 100644 --- a/selfdrive/ui/.gitignore +++ b/selfdrive/ui/.gitignore @@ -1 +1,13 @@ -ui +moc_* +*.moc + +watch3 +installer/installers/* +replay/replay +replay/tests/test_replay +qt/text +qt/spinner +qt/setup/setup +qt/setup/reset +qt/setup/wifi +qt/setup/updater diff --git a/selfdrive/ui/Makefile b/selfdrive/ui/Makefile deleted file mode 100644 index c6cce40a5ef636..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 - -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..52e4e0c42cf948 --- /dev/null +++ b/selfdrive/ui/SConscript @@ -0,0 +1,132 @@ +import os +Import('qt_env', 'arch', 'common', 'messaging', 'gpucommon', 'visionipc', + 'cereal', 'transformations') + +base_libs = [gpucommon, common, messaging, cereal, visionipc, transformations, 'zmq', + 'capnp', 'kj', 'm', 'OpenCL', 'ssl', 'crypto', 'pthread'] + qt_env["LIBS"] + +maps = arch in ['larch64', 'x86_64'] + +if arch == 'aarch64': + base_libs += ['log', 'utils', 'gui', 'ui', 'CB', 'gsl', 'adreno_utils', 'cutils', 'uuid'] + +if maps and arch == 'x86_64': + rpath = [Dir(f"#third_party/mapbox-gl-native-qt/{arch}").srcnode().abspath] + qt_env["RPATH"] += rpath + +if arch == "Darwin": + del base_libs[base_libs.index('OpenCL')] + qt_env['FRAMEWORKS'] += ['OpenCL'] + +widgets_src = ["qt/util.cc", "qt/widgets/input.cc", "qt/widgets/drive_stats.cc", + "qt/widgets/ssh_keys.cc", "qt/widgets/toggle.cc", "qt/widgets/controls.cc", + "qt/widgets/offroad_alerts.cc", "qt/widgets/prime.cc", "qt/widgets/keyboard.cc", + "qt/widgets/scrollview.cc", "qt/widgets/cameraview.cc", "#third_party/qrcode/QrCode.cc", "qt/api.cc", + "qt/request_repeater.cc", "qt/qt_window.cc"] + +if arch != 'aarch64': + widgets_src += ["qt/offroad/networking.cc", "qt/offroad/wifiManager.cc"] + +qt_env['CPPDEFINES'] = [] +if maps: + base_libs += ['qmapboxgl'] + widgets_src += ["qt/maps/map_helpers.cc", "qt/maps/map_settings.cc", "qt/maps/map.cc"] + qt_env['CPPDEFINES'] += ["ENABLE_MAPS"] + +widgets = qt_env.Library("qt_widgets", widgets_src, LIBS=base_libs) +qt_libs = [widgets] + base_libs + +# build assets +assets = "#selfdrive/assets/assets.cc" +assets_src = "#selfdrive/assets/assets.qrc" +qt_env.Command(assets, assets_src, f"rcc $SOURCES -o $TARGET") +qt_env.Depends(assets, Glob('#selfdrive/assets/*', exclude=[assets, assets_src, "#selfdrive/assets/assets.o"])) +asset_obj = qt_env.Object("assets", assets) + +# build soundd +qt_env.Program("soundd/_soundd", ["soundd/main.cc", "soundd/sound.cc"], LIBS=qt_libs) +if GetOption('test'): + qt_env.Program("tests/playsound", "tests/playsound.cc", LIBS=base_libs) + qt_env.Program('tests/test_sound', ['tests/test_runner.cc', 'soundd/sound.cc', 'tests/test_sound.cc'], LIBS=[base_libs]) + +qt_env.SharedLibrary("qt/python_helpers", ["qt/qt_window.cc"], LIBS=qt_libs) + +# spinner and text window +qt_env.Program("qt/text", ["qt/text.cc"], LIBS=qt_libs) +qt_env.Program("qt/spinner", ["qt/spinner.cc"], LIBS=qt_libs) + +# build main UI +qt_src = ["main.cc", "ui.cc", "qt/sidebar.cc", "qt/onroad.cc", + "qt/window.cc", "qt/home.cc", "qt/offroad/settings.cc", + "qt/offroad/onboarding.cc", "qt/offroad/driverview.cc"] +qt_env.Program("_ui", qt_src + [asset_obj], LIBS=qt_libs) + + +# setup and factory resetter +if arch != 'aarch64' and GetOption('extras'): + qt_env.Program("qt/setup/reset", ["qt/setup/reset.cc"], LIBS=qt_libs) + qt_env.Program("qt/setup/setup", ["qt/setup/setup.cc", asset_obj], + LIBS=qt_libs + ['curl', 'common', 'json11']) + + +if GetOption('extras'): + # buidl updater UI + qt_env.Program("qt/setup/updater", ["qt/setup/updater.cc", asset_obj], LIBS=qt_libs) + + # build installers + senv = qt_env.Clone() + senv['LINKFLAGS'].append('-Wl,-strip-debug') + + release = "release3" if arch == 'larch64' else "release2" + dashcam = "dashcam3" if arch == 'larch64' else "dashcam" + installers = [ + ("openpilot", release), + ("openpilot_test", f"{release}-staging"), + ("openpilot_nightly", "master-ci"), + ("openpilot_internal", "master"), + ("dashcam", dashcam), + ("dashcam_test", f"{dashcam}-staging"), + ] + + cont = {} + for brand in ("openpilot", "dashcam"): + cont[brand] = senv.Command(f"installer/continue_{brand}.o", f"installer/continue_{brand}.sh", + "ld -r -b binary -o $TARGET $SOURCE") + for name, branch in installers: + brand = "dashcam" if "dashcam" in branch else "openpilot" + d = {'BRANCH': f"'\"{branch}\"'", 'BRAND': f"'\"{brand}\"'"} + if "internal" in name: + d['INTERNAL'] = "1" + + import requests + r = requests.get("https://github.com/commaci2.keys") + r.raise_for_status() + d['SSH_KEYS'] = f'\\"{r.text.strip()}\\"' + obj = senv.Object(f"installer/installers/installer_{name}.o", ["installer/installer.cc"], CPPDEFINES=d) + f = senv.Program(f"installer/installers/installer_{name}", [obj, cont[brand]], LIBS=qt_libs) + # keep installers small + assert f[0].get_size() < 300*1e3 + + +# build headless replay +if arch in ['x86_64', 'Darwin'] or GetOption('extras'): + qt_env['CXXFLAGS'] += ["-Wno-deprecated-declarations"] + + replay_lib_src = ["replay/replay.cc", "replay/camera.cc", "replay/filereader.cc", "replay/logreader.cc", "replay/framereader.cc", "replay/route.cc", "replay/util.cc"] + + replay_lib = qt_env.Library("qt_replay", replay_lib_src, LIBS=base_libs) + replay_libs = [replay_lib, 'avutil', 'avcodec', 'avformat', 'bz2', 'curl', 'yuv'] + qt_libs + qt_env.Program("replay/replay", ["replay/main.cc"], LIBS=replay_libs) + + qt_env.Program("watch3", ["watch3.cc"], LIBS=qt_libs + ['common', 'json11']) + + if GetOption('test'): + qt_env.Program('replay/tests/test_replay', ['replay/tests/test_runner.cc', 'replay/tests/test_replay.cc'], LIBS=[replay_libs]) + +# navd +if maps: + navd_src = ["navd/main.cc", "navd/route_engine.cc", "navd/map_renderer.cc"] + qt_env.Program("navd/_navd", navd_src, LIBS=qt_libs + ['common', 'json11']) + + if GetOption('extras'): + qt_env.SharedLibrary("navd/map_renderer", ["navd/map_renderer.cc"], LIBS=qt_libs + ['common', 'messaging']) diff --git a/selfdrive/ui/main.cc b/selfdrive/ui/main.cc new file mode 100644 index 00000000000000..3d2411b9c67c0c --- /dev/null +++ b/selfdrive/ui/main.cc @@ -0,0 +1,28 @@ +#include + +#include +#include + +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/window.h" + +int main(int argc, char *argv[]) { + setpriority(PRIO_PROCESS, 0, -20); + + qInstallMessageHandler(swagLogMessageHandler); + initApp(); + + if (Hardware::EON()) { + QSslConfiguration ssl = QSslConfiguration::defaultConfiguration(); + ssl.setCaCertificates(QSslCertificate::fromPath("/usr/etc/tls/cert.pem")); + QSslConfiguration::setDefaultConfiguration(ssl); + } + + QApplication a(argc, argv); + MainWindow w; + setMainWindow(&w); + a.installEventFilter(&w); + return a.exec(); +} diff --git a/selfdrive/ui/navd/.gitignore b/selfdrive/ui/navd/.gitignore new file mode 100644 index 00000000000000..0fa7b173e46e4e --- /dev/null +++ b/selfdrive/ui/navd/.gitignore @@ -0,0 +1 @@ +_navd diff --git a/selfdrive/ui/navd/main.cc b/selfdrive/ui/navd/main.cc new file mode 100644 index 00000000000000..7ae0393a476720 --- /dev/null +++ b/selfdrive/ui/navd/main.cc @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include + +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/maps/map_helpers.h" +#include "selfdrive/ui/navd/route_engine.h" +#include "selfdrive/ui/navd/map_renderer.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/common/params.h" + +void sigHandler(int s) { + qInfo() << "Shutting down"; + std::signal(s, SIG_DFL); + + qApp->quit(); +} + + +int main(int argc, char *argv[]) { + qInstallMessageHandler(swagLogMessageHandler); + + QApplication app(argc, argv); + std::signal(SIGINT, sigHandler); + std::signal(SIGTERM, sigHandler); + + QCommandLineParser parser; + parser.setApplicationDescription("Navigation server. Runs stand-alone, or using pre-computer route"); + parser.addHelpOption(); + parser.process(app); + const QStringList args = parser.positionalArguments(); + + + RouteEngine* route_engine = new RouteEngine(); + + if (Params().getBool("NavdRender")) { + MapRenderer * m = new MapRenderer(get_mapbox_settings()); + QObject::connect(route_engine, &RouteEngine::positionUpdated, m, &MapRenderer::updatePosition); + QObject::connect(route_engine, &RouteEngine::routeUpdated, m, &MapRenderer::updateRoute); + } + + return app.exec(); +} diff --git a/selfdrive/ui/navd/map_renderer.cc b/selfdrive/ui/navd/map_renderer.cc new file mode 100644 index 00000000000000..1d78d68dfeb994 --- /dev/null +++ b/selfdrive/ui/navd/map_renderer.cc @@ -0,0 +1,200 @@ +#include "selfdrive/ui/navd/map_renderer.h" + +#include +#include +#include + +#include "selfdrive/ui/qt/maps/map_helpers.h" +#include "selfdrive/common/timing.h" + +const float ZOOM = 13.5; // Don't go below 13 or features will start to disappear +const int WIDTH = 256; +const int HEIGHT = WIDTH; + +const int NUM_VIPC_BUFFERS = 4; + +MapRenderer::MapRenderer(const QMapboxGLSettings &settings, bool enable_vipc) : m_settings(settings) { + QSurfaceFormat fmt; + fmt.setRenderableType(QSurfaceFormat::OpenGLES); + + ctx = std::make_unique(); + ctx->setFormat(fmt); + ctx->create(); + assert(ctx->isValid()); + + surface = std::make_unique(); + surface->setFormat(ctx->format()); + surface->create(); + + ctx->makeCurrent(surface.get()); + assert(QOpenGLContext::currentContext() == ctx.get()); + + gl_functions.reset(ctx->functions()); + gl_functions->initializeOpenGLFunctions(); + + QOpenGLFramebufferObjectFormat fbo_format; + fbo.reset(new QOpenGLFramebufferObject(WIDTH, HEIGHT, fbo_format)); + + m_map.reset(new QMapboxGL(nullptr, m_settings, fbo->size(), 1)); + m_map->setCoordinateZoom(QMapbox::Coordinate(0, 0), ZOOM); + m_map->setStyleUrl("mapbox://styles/commaai/ckvmksrpd4n0a14pfdo5heqzr"); + m_map->createRenderer(); + + m_map->resize(fbo->size()); + m_map->setFramebufferObject(fbo->handle(), fbo->size()); + gl_functions->glViewport(0, 0, WIDTH, HEIGHT); + + if (enable_vipc) { + qWarning() << "Enabling navd map rendering"; + vipc_server.reset(new VisionIpcServer("navd")); + vipc_server->create_buffers(VisionStreamType::VISION_STREAM_RGB_MAP, NUM_VIPC_BUFFERS, true, WIDTH, HEIGHT); + vipc_server->start_listener(); + + pm.reset(new PubMaster({"navThumbnail"})); + } +} + +void MapRenderer::updatePosition(QMapbox::Coordinate position, float bearing) { + if (m_map.isNull()) { + return; + } + + m_map->setCoordinate(position); + m_map->setBearing(bearing); + update(); +} + +bool MapRenderer::loaded() { + return m_map->isFullyLoaded(); +} + +void MapRenderer::update() { + gl_functions->glClear(GL_COLOR_BUFFER_BIT); + m_map->render(); + gl_functions->glFlush(); + + sendVipc(); +} + +void MapRenderer::sendVipc() { + if (!vipc_server || !loaded()) { + return; + } + + QImage cap = fbo->toImage().convertToFormat(QImage::Format_RGB888, Qt::AutoColor); + uint64_t ts = nanos_since_boot(); + VisionBuf* buf = vipc_server->get_buffer(VisionStreamType::VISION_STREAM_RGB_MAP); + VisionIpcBufExtra extra = { + .frame_id = frame_id, + .timestamp_sof = ts, + .timestamp_eof = ts, + }; + + assert(cap.sizeInBytes() == buf->len); + memcpy(buf->addr, cap.bits(), buf->len); + vipc_server->send(buf, &extra); + + if (frame_id % 100 == 0) { + // Write jpeg into buffer + QByteArray buffer_bytes; + QBuffer buffer(&buffer_bytes); + buffer.open(QIODevice::WriteOnly); + cap.save(&buffer, "JPG", 50); + + kj::Array buffer_kj = kj::heapArray((const capnp::byte*)buffer_bytes.constData(), buffer_bytes.size()); + + // Send thumbnail + MessageBuilder msg; + auto thumbnaild = msg.initEvent().initNavThumbnail(); + thumbnaild.setFrameId(frame_id); + thumbnaild.setTimestampEof(ts); + thumbnaild.setThumbnail(buffer_kj); + pm->send("navThumbnail", msg); + } + + frame_id++; +} + +uint8_t* MapRenderer::getImage() { + QImage cap = fbo->toImage().convertToFormat(QImage::Format_RGB888, Qt::AutoColor); + uint8_t* buf = new uint8_t[cap.sizeInBytes()]; + memcpy(buf, cap.bits(), cap.sizeInBytes()); + + return buf; +} + +void MapRenderer::updateRoute(QList coordinates) { + if (m_map.isNull()) return; + initLayers(); + + auto route_points = coordinate_list_to_collection(coordinates); + QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {}); + QVariantMap navSource; + navSource["type"] = "geojson"; + navSource["data"] = QVariant::fromValue(feature); + m_map->updateSource("navSource", navSource); + m_map->setLayoutProperty("navLayer", "visibility", "visible"); +} + +void MapRenderer::initLayers() { + if (!m_map->layerExists("navLayer")) { + QVariantMap nav; + nav["id"] = "navLayer"; + nav["type"] = "line"; + nav["source"] = "navSource"; + m_map->addLayer(nav, "road-intersection"); + m_map->setPaintProperty("navLayer", "line-color", QColor("blue")); + m_map->setPaintProperty("navLayer", "line-width", 3); + m_map->setLayoutProperty("navLayer", "line-cap", "round"); + } +} + +MapRenderer::~MapRenderer() { +} + +extern "C" { + MapRenderer* map_renderer_init() { + char *argv[] = { + (char*)"navd", + nullptr + }; + int argc = 0; + QApplication *app = new QApplication(argc, argv); + assert(app); + + QMapboxGLSettings settings; + settings.setApiBaseUrl(MAPS_HOST); + settings.setAccessToken(get_mapbox_token()); + + return new MapRenderer(settings, false); + } + + void map_renderer_update_position(MapRenderer *inst, float lat, float lon, float bearing) { + inst->updatePosition({lat, lon}, bearing); + QApplication::processEvents(); + } + + void map_renderer_update_route(MapRenderer *inst, char* polyline) { + inst->updateRoute(polyline_to_coordinate_list(QString::fromUtf8(polyline))); + } + + void map_renderer_update(MapRenderer *inst) { + inst->update(); + } + + void map_renderer_process(MapRenderer *inst) { + QApplication::processEvents(); + } + + bool map_renderer_loaded(MapRenderer *inst) { + return inst->loaded(); + } + + uint8_t * map_renderer_get_image(MapRenderer *inst) { + return inst->getImage(); + } + + void map_renderer_free_image(MapRenderer *inst, uint8_t * buf) { + delete[] buf; + } +} diff --git a/selfdrive/ui/navd/map_renderer.h b/selfdrive/ui/navd/map_renderer.h new file mode 100644 index 00000000000000..1746e76695ab30 --- /dev/null +++ b/selfdrive/ui/navd/map_renderer.h @@ -0,0 +1,49 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cereal/visionipc/visionipc_server.h" +#include "cereal/messaging/messaging.h" + + +class MapRenderer : public QObject { + Q_OBJECT + +public: + MapRenderer(const QMapboxGLSettings &, bool enable_vipc=true); + uint8_t* getImage(); + void update(); + bool loaded(); + ~MapRenderer(); + + +private: + std::unique_ptr ctx; + std::unique_ptr surface; + std::unique_ptr gl_functions; + std::unique_ptr fbo; + + std::unique_ptr vipc_server; + std::unique_ptr pm; + void sendVipc(); + + QMapboxGLSettings m_settings; + QScopedPointer m_map; + + void initLayers(); + + uint32_t frame_id = 0; + +public slots: + void updatePosition(QMapbox::Coordinate position, float bearing); + void updateRoute(QList coordinates); +}; diff --git a/selfdrive/ui/navd/navd b/selfdrive/ui/navd/navd new file mode 100755 index 00000000000000..ff3103bd970d30 --- /dev/null +++ b/selfdrive/ui/navd/navd @@ -0,0 +1,4 @@ +#!/bin/sh +cd "$(dirname "$0")" +export QT_PLUGIN_PATH="../../../third_party/qt-plugins/$(uname -m)" +exec ./_navd diff --git a/selfdrive/ui/navd/route_engine.cc b/selfdrive/ui/navd/route_engine.cc new file mode 100644 index 00000000000000..f3cb7df3d94c0d --- /dev/null +++ b/selfdrive/ui/navd/route_engine.cc @@ -0,0 +1,359 @@ +#include "selfdrive/ui/navd/route_engine.h" + +#include + +#include "selfdrive/ui/qt/maps/map.h" +#include "selfdrive/ui/qt/maps/map_helpers.h" +#include "selfdrive/ui/qt/api.h" + +#include "selfdrive/common/params.h" + +const qreal REROUTE_DISTANCE = 25; +const float MANEUVER_TRANSITION_THRESHOLD = 10; + +static float get_time_typical(const QGeoRouteSegment &segment) { + auto maneuver = segment.maneuver(); + auto attrs = maneuver.extendedAttributes(); + return attrs.contains("mapbox.duration_typical") ? attrs["mapbox.duration_typical"].toDouble() : segment.travelTime(); +} + +static cereal::NavInstruction::Direction string_to_direction(QString d) { + if (d.contains("left")) { + return cereal::NavInstruction::Direction::LEFT; + } else if (d.contains("right")) { + return cereal::NavInstruction::Direction::RIGHT; + } else if (d.contains("straight")) { + return cereal::NavInstruction::Direction::STRAIGHT; + } + + return cereal::NavInstruction::Direction::NONE; +} + +static void parse_banner(cereal::NavInstruction::Builder &instruction, const QMap &banner, bool full) { + QString primary_str, secondary_str; + + auto p = banner["primary"].toMap(); + primary_str += p["text"].toString(); + + instruction.setShowFull(full); + + if (p.contains("type")) { + instruction.setManeuverType(p["type"].toString().toStdString()); + } + + if (p.contains("modifier")) { + instruction.setManeuverModifier(p["modifier"].toString().toStdString()); + } + + if (banner.contains("secondary")) { + auto s = banner["secondary"].toMap(); + secondary_str += s["text"].toString(); + } + + instruction.setManeuverPrimaryText(primary_str.toStdString()); + instruction.setManeuverSecondaryText(secondary_str.toStdString()); + + if (banner.contains("sub")) { + auto s = banner["sub"].toMap(); + auto components = s["components"].toList(); + + size_t num_lanes = 0; + for (auto &c : components) { + auto cc = c.toMap(); + if (cc["type"].toString() == "lane") { + num_lanes += 1; + } + } + + auto lanes = instruction.initLanes(num_lanes); + + size_t i = 0; + for (auto &c : components) { + auto cc = c.toMap(); + if (cc["type"].toString() == "lane") { + auto lane = lanes[i]; + lane.setActive(cc["active"].toBool()); + + if (cc.contains("active_direction")) { + lane.setActiveDirection(string_to_direction(cc["active_direction"].toString())); + } + + auto directions = lane.initDirections(cc["directions"].toList().size()); + + size_t j = 0; + for (auto &dir : cc["directions"].toList()) { + directions.set(j, string_to_direction(dir.toString())); + j++; + } + + + i++; + } + } + } +} + +RouteEngine::RouteEngine() { + sm = new SubMaster({"liveLocationKalman", "managerState"}); + pm = new PubMaster({"navInstruction", "navRoute"}); + + // Timers + route_timer = new QTimer(this); + QObject::connect(route_timer, SIGNAL(timeout()), this, SLOT(routeUpdate())); + route_timer->start(1000); + + msg_timer = new QTimer(this); + QObject::connect(msg_timer, SIGNAL(timeout()), this, SLOT(msgUpdate())); + msg_timer->start(50); + + // Build routing engine + QVariantMap parameters; + parameters["mapbox.access_token"] = get_mapbox_token(); + parameters["mapbox.directions_api_url"] = MAPS_HOST + "/directions/v5/mapbox/"; + + geoservice_provider = new QGeoServiceProvider("mapbox", parameters); + routing_manager = geoservice_provider->routingManager(); + if (routing_manager == nullptr) { + qWarning() << geoservice_provider->errorString(); + assert(routing_manager); + } + QObject::connect(routing_manager, &QGeoRoutingManager::finished, this, &RouteEngine::routeCalculated); + + // Get last gps position from params + auto last_gps_position = coordinate_from_param("LastGPSPosition"); + if (last_gps_position) { + last_position = *last_gps_position; + } +} + +void RouteEngine::msgUpdate() { + sm->update(1000); + if (!sm->updated("liveLocationKalman")) { + active = false; + return; + } + + + if (sm->updated("managerState")) { + for (auto const &p : (*sm)["managerState"].getManagerState().getProcesses()) { + if (p.getName() == "ui" && p.getRunning()) { + if (ui_pid && *ui_pid != p.getPid()){ + qWarning() << "UI restarting, sending route"; + QTimer::singleShot(5000, this, &RouteEngine::sendRoute); + } + ui_pid = p.getPid(); + } + } + } + + auto location = (*sm)["liveLocationKalman"].getLiveLocationKalman(); + auto pos = location.getPositionGeodetic(); + auto orientation = location.getCalibratedOrientationNED(); + + gps_ok = location.getGpsOK(); + + localizer_valid = (location.getStatus() == cereal::LiveLocationKalman::Status::VALID) && pos.getValid(); + + if (localizer_valid) { + last_bearing = RAD2DEG(orientation.getValue()[2]); + last_position = QMapbox::Coordinate(pos.getValue()[0], pos.getValue()[1]); + emit positionUpdated(*last_position, *last_bearing); + } + + active = true; +} + +void RouteEngine::routeUpdate() { + if (!active) { + return; + } + + recomputeRoute(); + + MessageBuilder msg; + cereal::Event::Builder evt = msg.initEvent(segment.isValid()); + cereal::NavInstruction::Builder instruction = evt.initNavInstruction(); + + // Show route instructions + if (segment.isValid()) { + auto cur_maneuver = segment.maneuver(); + auto attrs = cur_maneuver.extendedAttributes(); + if (cur_maneuver.isValid() && attrs.contains("mapbox.banner_instructions")) { + float along_geometry = distance_along_geometry(segment.path(), to_QGeoCoordinate(*last_position)); + float distance_to_maneuver_along_geometry = segment.distance() - along_geometry; + + auto banners = attrs["mapbox.banner_instructions"].toList(); + if (banners.size()) { + auto banner = banners[0].toMap(); + + for (auto &b : banners) { + auto bb = b.toMap(); + if (distance_to_maneuver_along_geometry < bb["distance_along_geometry"].toDouble()) { + banner = bb; + } + } + + instruction.setManeuverDistance(distance_to_maneuver_along_geometry); + parse_banner(instruction, banner, distance_to_maneuver_along_geometry < banner["distance_along_geometry"].toDouble()); + + // ETA + float progress = distance_along_geometry(segment.path(), to_QGeoCoordinate(*last_position)) / segment.distance(); + float total_distance = segment.distance() * (1.0 - progress); + float total_time = segment.travelTime() * (1.0 - progress); + float total_time_typical = get_time_typical(segment) * (1.0 - progress); + + auto s = segment.nextRouteSegment(); + while (s.isValid()) { + total_distance += s.distance(); + total_time += s.travelTime(); + total_time_typical += get_time_typical(s); + + s = s.nextRouteSegment(); + } + instruction.setTimeRemaining(total_time); + instruction.setTimeRemainingTypical(total_time_typical); + instruction.setDistanceRemaining(total_distance); + } + + // Transition to next route segment + if (distance_to_maneuver_along_geometry < -MANEUVER_TRANSITION_THRESHOLD) { + auto next_segment = segment.nextRouteSegment(); + if (next_segment.isValid()) { + segment = next_segment; + + recompute_backoff = std::max(0, recompute_backoff - 1); + recompute_countdown = 0; + } else { + qWarning() << "Destination reached"; + Params().remove("NavDestination"); + + // Clear route if driving away from destination + float d = segment.maneuver().position().distanceTo(to_QGeoCoordinate(*last_position)); + if (d > REROUTE_DISTANCE) { + clearRoute(); + } + } + } + } + } + + pm->send("navInstruction", msg); +} + +void RouteEngine::clearRoute() { + route = QGeoRoute(); + segment = QGeoRouteSegment(); + nav_destination = QMapbox::Coordinate(); +} + +bool RouteEngine::shouldRecompute() { + if (!segment.isValid()) { + return true; + } + + // Don't recompute in last segment, assume destination is reached + if (!segment.nextRouteSegment().isValid()) { + return false; + } + + // Compute closest distance to all line segments in the current path + float min_d = REROUTE_DISTANCE + 1; + auto path = segment.path(); + auto cur = to_QGeoCoordinate(*last_position); + for (size_t i = 0; i < path.size() - 1; i++) { + auto a = path[i]; + auto b = path[i+1]; + if (a.distanceTo(b) < 1.0) { + continue; + } + min_d = std::min(min_d, minimum_distance(a, b, cur)); + } + return min_d > REROUTE_DISTANCE; + + // TODO: Check for going wrong way in segment +} + +void RouteEngine::recomputeRoute() { + if (!last_position) { + return; + } + + auto new_destination = coordinate_from_param("NavDestination"); + if (!new_destination) { + clearRoute(); + return; + } + + bool should_recompute = shouldRecompute(); + if (*new_destination != nav_destination) { + qWarning() << "Got new destination from NavDestination param" << *new_destination; + should_recompute = true; + } + + if (!gps_ok && segment.isValid()) return; // Don't recompute when gps drifts in tunnels + + if (recompute_countdown == 0 && should_recompute) { + recompute_countdown = std::pow(2, recompute_backoff); + recompute_backoff = std::min(7, recompute_backoff + 1); + calculateRoute(*new_destination); + } else { + recompute_countdown = std::max(0, recompute_countdown - 1); + } +} + +void RouteEngine::calculateRoute(QMapbox::Coordinate destination) { + qWarning() << "Calculating route" << *last_position << "->" << destination; + + nav_destination = destination; + QGeoRouteRequest request(to_QGeoCoordinate(*last_position), to_QGeoCoordinate(destination)); + request.setFeatureWeight(QGeoRouteRequest::TrafficFeature, QGeoRouteRequest::AvoidFeatureWeight); + + if (last_bearing) { + QVariantMap params; + int bearing = ((int)(*last_bearing) + 360) % 360; + params["bearing"] = bearing; + request.setWaypointsMetadata({params}); + } + + routing_manager->calculateRoute(request); +} + +void RouteEngine::routeCalculated(QGeoRouteReply *reply) { + if (reply->error() == QGeoRouteReply::NoError) { + if (reply->routes().size() != 0) { + qWarning() << "Got route response"; + + route = reply->routes().at(0); + segment = route.firstRouteSegment(); + + auto path = route.path(); + emit routeUpdated(path); + } else { + qWarning() << "Got empty route response"; + } + } else { + qWarning() << "Got error in route reply" << reply->errorString(); + } + + sendRoute(); + + reply->deleteLater(); +} + +void RouteEngine::sendRoute() { + MessageBuilder msg; + cereal::Event::Builder evt = msg.initEvent(); + cereal::NavRoute::Builder nav_route = evt.initNavRoute(); + + auto path = route.path(); + auto coordinates = nav_route.initCoordinates(path.size()); + + size_t i = 0; + for (auto const &c : route.path()) { + coordinates[i].setLatitude(c.latitude()); + coordinates[i].setLongitude(c.longitude()); + i++; + } + + pm->send("navRoute", msg); +} diff --git a/selfdrive/ui/navd/route_engine.h b/selfdrive/ui/navd/route_engine.h new file mode 100644 index 00000000000000..33cbc7910761a6 --- /dev/null +++ b/selfdrive/ui/navd/route_engine.h @@ -0,0 +1,62 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cereal/messaging/messaging.h" + +class RouteEngine : public QObject { + Q_OBJECT + +public: + RouteEngine(); + + SubMaster *sm; + PubMaster *pm; + + QTimer* msg_timer; + QTimer* route_timer; + + std::optional ui_pid; + + // Route + bool gps_ok = false; + QGeoServiceProvider *geoservice_provider; + QGeoRoutingManager *routing_manager; + QGeoRoute route; + QGeoRouteSegment segment; + QMapbox::Coordinate nav_destination; + + // Position + std::optional last_position; + std::optional last_bearing; + bool localizer_valid = false; + + // Route recompute + bool active = false; + int recompute_backoff = 0; + int recompute_countdown = 0; + void calculateRoute(QMapbox::Coordinate destination); + void clearRoute(); + bool shouldRecompute(); + +private slots: + void routeUpdate(); + void msgUpdate(); + void routeCalculated(QGeoRouteReply *reply); + void recomputeRoute(); + void sendRoute(); + +signals: + void positionUpdated(QMapbox::Coordinate position, float bearing); + void routeUpdated(QList coordinates); +}; diff --git a/selfdrive/ui/qt/api.cc b/selfdrive/ui/qt/api.cc new file mode 100644 index 00000000000000..8ac9b4131361d6 --- /dev/null +++ b/selfdrive/ui/qt/api.cc @@ -0,0 +1,143 @@ +#include "selfdrive/ui/qt/api.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/util.h" + +namespace CommaApi { + +QByteArray rsa_sign(const QByteArray &data) { + static std::string key = util::read_file(Path::rsa_file()); + if (key.empty()) { + qDebug() << "No RSA private key found, please run manager.py or registration.py"; + return {}; + } + + BIO* mem = BIO_new_mem_buf(key.data(), key.size()); + assert(mem); + RSA* rsa_private = PEM_read_bio_RSAPrivateKey(mem, NULL, NULL, NULL); + assert(rsa_private); + auto sig = QByteArray(); + sig.resize(RSA_size(rsa_private)); + unsigned int sig_len; + int ret = RSA_sign(NID_sha256, (unsigned char*)data.data(), data.size(), (unsigned char*)sig.data(), &sig_len, rsa_private); + assert(ret == 1); + assert(sig_len == sig.size()); + BIO_free(mem); + RSA_free(rsa_private); + return sig; +} + +QString create_jwt(const QJsonObject &payloads, int expiry) { + QJsonObject header = {{"alg", "RS256"}}; + + auto t = QDateTime::currentSecsSinceEpoch(); + QJsonObject payload = {{"identity", getDongleId().value_or("")}, {"nbf", t}, {"iat", t}, {"exp", t + expiry}}; + for (auto it = payloads.begin(); it != payloads.end(); ++it) { + payload.insert(it.key(), it.value()); + } + + auto b64_opts = QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals; + QString jwt = QJsonDocument(header).toJson(QJsonDocument::Compact).toBase64(b64_opts) + '.' + + QJsonDocument(payload).toJson(QJsonDocument::Compact).toBase64(b64_opts); + + auto hash = QCryptographicHash::hash(jwt.toUtf8(), QCryptographicHash::Sha256); + auto sig = rsa_sign(hash); + jwt += '.' + sig.toBase64(b64_opts); + return jwt; +} + +} // namespace CommaApi + +HttpRequest::HttpRequest(QObject *parent, bool create_jwt, int timeout) : create_jwt(create_jwt), QObject(parent) { + networkTimer = new QTimer(this); + networkTimer->setSingleShot(true); + networkTimer->setInterval(timeout); + connect(networkTimer, &QTimer::timeout, this, &HttpRequest::requestTimeout); +} + +bool HttpRequest::active() const { + return reply != nullptr; +} + +bool HttpRequest::timeout() const { + return reply && reply->error() == QNetworkReply::OperationCanceledError; +} + +void HttpRequest::sendRequest(const QString &requestURL, const HttpRequest::Method method) { + if (active()) { + qDebug() << "HttpRequest is active"; + return; + } + QString token; + if(create_jwt) { + token = CommaApi::create_jwt(); + } else { + QString token_json = QString::fromStdString(util::read_file(util::getenv("HOME") + "/.comma/auth.json")); + QJsonDocument json_d = QJsonDocument::fromJson(token_json.toUtf8()); + token = json_d["access_token"].toString(); + } + + QNetworkRequest request; + request.setUrl(QUrl(requestURL)); + request.setRawHeader("User-Agent", getUserAgent().toUtf8()); + + if (!token.isEmpty()) { + request.setRawHeader(QByteArray("Authorization"), ("JWT " + token).toUtf8()); + } + + if (method == HttpRequest::Method::GET) { + reply = nam()->get(request); + } else if (method == HttpRequest::Method::DELETE) { + reply = nam()->deleteResource(request); + } + + networkTimer->start(); + connect(reply, &QNetworkReply::finished, this, &HttpRequest::requestFinished); +} + +void HttpRequest::requestTimeout() { + reply->abort(); +} + +void HttpRequest::requestFinished() { + networkTimer->stop(); + + if (reply->error() == QNetworkReply::NoError) { + emit requestDone(reply->readAll(), true); + } else { + QString error; + if (reply->error() == QNetworkReply::OperationCanceledError) { + nam()->clearAccessCache(); + nam()->clearConnectionCache(); + error = "Request timed out"; + } else { + if (reply->error() == QNetworkReply::ContentAccessDenied || reply->error() == QNetworkReply::AuthenticationRequiredError) { + qWarning() << ">> Unauthorized. Authenticate with tools/lib/auth.py <<"; + } + error = reply->errorString(); + } + emit requestDone(error, false); + } + + reply->deleteLater(); + reply = nullptr; +} + +QNetworkAccessManager *HttpRequest::nam() { + static QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager(qApp); + return networkAccessManager; +} diff --git a/selfdrive/ui/qt/api.h b/selfdrive/ui/qt/api.h new file mode 100644 index 00000000000000..8f7467810948f7 --- /dev/null +++ b/selfdrive/ui/qt/api.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include + +#include "selfdrive/common/util.h" + +namespace CommaApi { + +const QString BASE_URL = util::getenv("API_HOST", "https://api.commadotai.com").c_str(); +QByteArray rsa_sign(const QByteArray &data); +QString create_jwt(const QJsonObject &payloads = {}, int expiry = 3600); + +} // namespace CommaApi + +/** + * Makes a request to the request endpoint. + */ + +class HttpRequest : public QObject { + Q_OBJECT + +public: + enum class Method {GET, DELETE}; + + explicit HttpRequest(QObject* parent, bool create_jwt = true, int timeout = 20000); + void sendRequest(const QString &requestURL, const Method method = Method::GET); + bool active() const; + bool timeout() const; + +signals: + void requestDone(const QString &response, bool success); + +protected: + QNetworkReply *reply = nullptr; + +private: + static QNetworkAccessManager *nam(); + QTimer *networkTimer = nullptr; + bool create_jwt; + +private slots: + void requestTimeout(); + void requestFinished(); +}; diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc new file mode 100644 index 00000000000000..1e89264952bb34 --- /dev/null +++ b/selfdrive/ui/qt/home.cc @@ -0,0 +1,183 @@ +#include "selfdrive/ui/qt/home.h" + +#include +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/widgets/drive_stats.h" +#include "selfdrive/ui/qt/widgets/prime.h" + +// HomeWindow: the container for the offroad and onroad UIs + +HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { + QHBoxLayout *main_layout = new QHBoxLayout(this); + main_layout->setMargin(0); + main_layout->setSpacing(0); + + sidebar = new Sidebar(this); + main_layout->addWidget(sidebar); + QObject::connect(this, &HomeWindow::update, sidebar, &Sidebar::updateState); + QObject::connect(sidebar, &Sidebar::openSettings, this, &HomeWindow::openSettings); + + slayout = new QStackedLayout(); + main_layout->addLayout(slayout); + + home = new OffroadHome(); + slayout->addWidget(home); + + onroad = new OnroadWindow(this); + slayout->addWidget(onroad); + + QObject::connect(this, &HomeWindow::update, onroad, &OnroadWindow::updateStateSignal); + QObject::connect(this, &HomeWindow::offroadTransitionSignal, onroad, &OnroadWindow::offroadTransitionSignal); + + driver_view = new DriverViewWindow(this); + connect(driver_view, &DriverViewWindow::done, [=] { + showDriverView(false); + }); + slayout->addWidget(driver_view); + setAttribute(Qt::WA_NoSystemBackground); +} + +void HomeWindow::showSidebar(bool show) { + sidebar->setVisible(show); +} + +void HomeWindow::offroadTransition(bool offroad) { + sidebar->setVisible(offroad); + if (offroad) { + slayout->setCurrentWidget(home); + } else { + slayout->setCurrentWidget(onroad); + } + emit offroadTransitionSignal(offroad); +} + +void HomeWindow::showDriverView(bool show) { + if (show) { + emit closeSettings(); + slayout->setCurrentWidget(driver_view); + } else { + slayout->setCurrentWidget(home); + } + sidebar->setVisible(show == false); +} + +void HomeWindow::mousePressEvent(QMouseEvent* e) { + // Handle sidebar collapsing + if (onroad->isVisible() && (!sidebar->isVisible() || e->x() > sidebar->width())) { + sidebar->setVisible(!sidebar->isVisible() && !onroad->isMapVisible()); + } +} + +// OffroadHome: the offroad home page + +OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { + QVBoxLayout* main_layout = new QVBoxLayout(this); + main_layout->setContentsMargins(40, 40, 40, 45); + + // top header + QHBoxLayout* header_layout = new QHBoxLayout(); + header_layout->setContentsMargins(15, 15, 15, 0); + header_layout->setSpacing(16); + + date = new QLabel(); + header_layout->addWidget(date, 1, Qt::AlignHCenter | Qt::AlignLeft); + + update_notif = new QPushButton("UPDATE"); + update_notif->setVisible(false); + update_notif->setStyleSheet("background-color: #364DEF;"); + QObject::connect(update_notif, &QPushButton::clicked, [=]() { center_layout->setCurrentIndex(1); }); + header_layout->addWidget(update_notif, 0, Qt::AlignHCenter | Qt::AlignRight); + + alert_notif = new QPushButton(); + alert_notif->setVisible(false); + alert_notif->setStyleSheet("background-color: #E22C2C;"); + QObject::connect(alert_notif, &QPushButton::clicked, [=] { center_layout->setCurrentIndex(2); }); + header_layout->addWidget(alert_notif, 0, Qt::AlignHCenter | Qt::AlignRight); + + header_layout->addWidget(new QLabel(getBrandVersion()), 0, Qt::AlignHCenter | Qt::AlignRight); + + main_layout->addLayout(header_layout); + + // main content + main_layout->addSpacing(25); + center_layout = new QStackedLayout(); + + QWidget* statsAndSetupWidget = new QWidget(this); + QHBoxLayout* statsAndSetup = new QHBoxLayout(statsAndSetupWidget); + statsAndSetup->setMargin(0); + statsAndSetup->setSpacing(30); + statsAndSetup->addWidget(new DriveStats, 1); + statsAndSetup->addWidget(new SetupWidget); + + center_layout->addWidget(statsAndSetupWidget); + + // add update & alerts widgets + update_widget = new UpdateAlert(); + QObject::connect(update_widget, &UpdateAlert::dismiss, [=]() { center_layout->setCurrentIndex(0); }); + center_layout->addWidget(update_widget); + alerts_widget = new OffroadAlert(); + QObject::connect(alerts_widget, &OffroadAlert::dismiss, [=]() { center_layout->setCurrentIndex(0); }); + center_layout->addWidget(alerts_widget); + + main_layout->addLayout(center_layout, 1); + + // set up refresh timer + timer = new QTimer(this); + timer->callOnTimeout(this, &OffroadHome::refresh); + + setStyleSheet(R"( + * { + color: white; + } + OffroadHome { + background-color: black; + } + OffroadHome > QPushButton { + padding: 15px 30px; + border-radius: 5px; + font-size: 40px; + font-weight: 500; + } + OffroadHome > QLabel { + font-size: 55px; + } + )"); +} + +void OffroadHome::showEvent(QShowEvent *event) { + refresh(); + timer->start(10 * 1000); +} + +void OffroadHome::hideEvent(QHideEvent *event) { + timer->stop(); +} + +void OffroadHome::refresh() { + date->setText(QDateTime::currentDateTime().toString("dddd, MMMM d")); + + bool updateAvailable = update_widget->refresh(); + int alerts = alerts_widget->refresh(); + + // pop-up new notification + int idx = center_layout->currentIndex(); + if (!updateAvailable && !alerts) { + idx = 0; + } else if (updateAvailable && (!update_notif->isVisible() || (!alerts && idx == 2))) { + idx = 1; + } else if (alerts && (!alert_notif->isVisible() || (!updateAvailable && idx == 1))) { + idx = 2; + } + center_layout->setCurrentIndex(idx); + + update_notif->setVisible(updateAvailable); + alert_notif->setVisible(alerts); + if (alerts) { + alert_notif->setText(QString::number(alerts) + (alerts > 1 ? " ALERTS" : " ALERT")); + } +} diff --git a/selfdrive/ui/qt/home.h b/selfdrive/ui/qt/home.h new file mode 100644 index 00000000000000..0e65ef05e9a629 --- /dev/null +++ b/selfdrive/ui/qt/home.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "selfdrive/ui/qt/offroad/driverview.h" +#include "selfdrive/ui/qt/onroad.h" +#include "selfdrive/ui/qt/sidebar.h" +#include "selfdrive/ui/qt/widgets/offroad_alerts.h" +#include "selfdrive/ui/ui.h" + +class OffroadHome : public QFrame { + Q_OBJECT + +public: + explicit OffroadHome(QWidget* parent = 0); + +private: + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; + void refresh(); + + QTimer* timer; + QLabel* date; + QStackedLayout* center_layout; + UpdateAlert *update_widget; + OffroadAlert* alerts_widget; + QPushButton* alert_notif; + QPushButton* update_notif; +}; + +class HomeWindow : public QWidget { + Q_OBJECT + +public: + explicit HomeWindow(QWidget* parent = 0); + +signals: + void openSettings(); + void closeSettings(); + + // forwarded signals + void update(const UIState &s); + void offroadTransitionSignal(bool offroad); + +public slots: + void offroadTransition(bool offroad); + void showDriverView(bool show); + void showSidebar(bool show); + +protected: + void mousePressEvent(QMouseEvent* e) override; + +private: + Sidebar *sidebar; + OffroadHome *home; + OnroadWindow *onroad; + DriverViewWindow *driver_view; + QStackedLayout *slayout; +}; diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc new file mode 100644 index 00000000000000..e1bfe96c8e7ce1 --- /dev/null +++ b/selfdrive/ui/qt/maps/map.cc @@ -0,0 +1,657 @@ +#include "selfdrive/ui/qt/maps/map.h" + +#include + +#include +#include +#include + +#include "selfdrive/common/swaglog.h" +#include "selfdrive/ui/ui.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/maps/map_helpers.h" +#include "selfdrive/ui/qt/request_repeater.h" + + +const int PAN_TIMEOUT = 100; +const float MANEUVER_TRANSITION_THRESHOLD = 10; + +const float MAX_ZOOM = 17; +const float MIN_ZOOM = 14; +const float MAX_PITCH = 50; +const float MIN_PITCH = 0; +const float MAP_SCALE = 2; + +const QString ICON_SUFFIX = ".png"; + +MapWindow::MapWindow(const QMapboxGLSettings &settings) : + m_settings(settings), velocity_filter(0, 10, 0.05) { + sm = new SubMaster({"liveLocationKalman", "navInstruction", "navRoute"}); + + // Connect now, so any navRoutes sent while the map is initializing are not dropped + sm->update(0); + + timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate())); + timer->start(50); + + // Instructions + map_instructions = new MapInstructions(this); + QObject::connect(this, &MapWindow::instructionsChanged, map_instructions, &MapInstructions::updateInstructions); + QObject::connect(this, &MapWindow::distanceChanged, map_instructions, &MapInstructions::updateDistance); + map_instructions->setFixedWidth(width()); + map_instructions->setVisible(false); + + map_eta = new MapETA(this); + QObject::connect(this, &MapWindow::ETAChanged, map_eta, &MapETA::updateETA); + + const int h = 120; + map_eta->setFixedHeight(h); + map_eta->move(25, 1080 - h - bdr_s*2); + map_eta->setVisible(false); + + auto last_gps_position = coordinate_from_param("LastGPSPosition"); + if (last_gps_position) { + last_position = *last_gps_position; + } + + grabGesture(Qt::GestureType::PinchGesture); + qDebug() << "MapWindow initialized"; +} + +MapWindow::~MapWindow() { + makeCurrent(); +} + +void MapWindow::initLayers() { + // This doesn't work from initializeGL + if (!m_map->layerExists("modelPathLayer")) { + qDebug() << "Initializing modelPathLayer"; + QVariantMap modelPath; + modelPath["id"] = "modelPathLayer"; + modelPath["type"] = "line"; + modelPath["source"] = "modelPathSource"; + m_map->addLayer(modelPath); + m_map->setPaintProperty("modelPathLayer", "line-color", QColor("red")); + m_map->setPaintProperty("modelPathLayer", "line-width", 5.0); + m_map->setLayoutProperty("modelPathLayer", "line-cap", "round"); + } + if (!m_map->layerExists("navLayer")) { + qDebug() << "Initializing navLayer"; + QVariantMap nav; + nav["id"] = "navLayer"; + nav["type"] = "line"; + nav["source"] = "navSource"; + m_map->addLayer(nav, "road-intersection"); + m_map->setPaintProperty("navLayer", "line-color", QColor("#31a1ee")); + m_map->setPaintProperty("navLayer", "line-width", 7.5); + m_map->setLayoutProperty("navLayer", "line-cap", "round"); + } + if (!m_map->layerExists("carPosLayer")) { + qDebug() << "Initializing carPosLayer"; + m_map->addImage("label-arrow", QImage("../assets/images/triangle.svg")); + + QVariantMap carPos; + carPos["id"] = "carPosLayer"; + carPos["type"] = "symbol"; + carPos["source"] = "carPosSource"; + m_map->addLayer(carPos); + m_map->setLayoutProperty("carPosLayer", "icon-pitch-alignment", "map"); + m_map->setLayoutProperty("carPosLayer", "icon-image", "label-arrow"); + m_map->setLayoutProperty("carPosLayer", "icon-size", 0.5); + m_map->setLayoutProperty("carPosLayer", "icon-ignore-placement", true); + m_map->setLayoutProperty("carPosLayer", "icon-allow-overlap", true); + m_map->setLayoutProperty("carPosLayer", "symbol-sort-key", 0); + } +} + +void MapWindow::timerUpdate() { + if (!QUIState::ui_state.scene.started) { + return; + } + + update(); + + sm->update(0); + if (sm->updated("liveLocationKalman")) { + auto location = (*sm)["liveLocationKalman"].getLiveLocationKalman(); + auto pos = location.getPositionGeodetic(); + auto orientation = location.getCalibratedOrientationNED(); + + localizer_valid = (location.getStatus() == cereal::LiveLocationKalman::Status::VALID) && pos.getValid(); + + if (localizer_valid) { + float velocity = location.getVelocityCalibrated().getValue()[0]; + float bearing = RAD2DEG(orientation.getValue()[2]); + auto coordinate = QMapbox::Coordinate(pos.getValue()[0], pos.getValue()[1]); + + last_position = coordinate; + last_bearing = bearing; + velocity_filter.update(velocity); + } + } + + if (sm->updated("navRoute")) { + qWarning() << "Got new navRoute from navd. Opening map:" << allow_open; + + // Only open the map on setting destination the first time + if (allow_open) { + setVisible(true); // Show map on destination set/change + allow_open = false; + } + } + + if (m_map.isNull()) { + return; + } + + loaded_once = loaded_once || m_map->isFullyLoaded(); + if (!loaded_once) { + map_instructions->showError("Map Loading"); + return; + } + + initLayers(); + + if (!localizer_valid) { + map_instructions->showError("Waiting for GPS"); + } else { + map_instructions->noError(); + + // Update current location marker + auto point = coordinate_to_collection(*last_position); + QMapbox::Feature feature1(QMapbox::Feature::PointType, point, {}, {}); + QVariantMap carPosSource; + carPosSource["type"] = "geojson"; + carPosSource["data"] = QVariant::fromValue(feature1); + m_map->updateSource("carPosSource", carPosSource); + } + + if (pan_counter == 0) { + if (last_position) m_map->setCoordinate(*last_position); + if (last_bearing) m_map->setBearing(*last_bearing); + } else { + pan_counter--; + } + + if (zoom_counter == 0) { + m_map->setZoom(util::map_val(velocity_filter.x(), 0, 30, MAX_ZOOM, MIN_ZOOM)); + } else { + zoom_counter--; + } + + if (sm->updated("navInstruction")) { + if (sm->valid("navInstruction")) { + auto i = (*sm)["navInstruction"].getNavInstruction(); + emit ETAChanged(i.getTimeRemaining(), i.getTimeRemainingTypical(), i.getDistanceRemaining()); + + if (localizer_valid) { + m_map->setPitch(MAX_PITCH); // TODO: smooth pitching based on maneuver distance + emit distanceChanged(i.getManeuverDistance()); // TODO: combine with instructionsChanged + emit instructionsChanged(i); + } + } else { + m_map->setPitch(MIN_PITCH); + clearRoute(); + } + } + + if (sm->rcv_frame("navRoute") != route_rcv_frame) { + qWarning() << "Updating navLayer with new route"; + auto route = (*sm)["navRoute"].getNavRoute(); + auto route_points = capnp_coordinate_list_to_collection(route.getCoordinates()); + QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {}); + QVariantMap navSource; + navSource["type"] = "geojson"; + navSource["data"] = QVariant::fromValue(feature); + m_map->updateSource("navSource", navSource); + m_map->setLayoutProperty("navLayer", "visibility", "visible"); + + route_rcv_frame = sm->rcv_frame("navRoute"); + } +} + +void MapWindow::resizeGL(int w, int h) { + m_map->resize(size() / MAP_SCALE); + map_instructions->setFixedWidth(width()); +} + +void MapWindow::initializeGL() { + m_map.reset(new QMapboxGL(this, m_settings, size(), 1)); + + if (last_position) { + m_map->setCoordinateZoom(*last_position, MAX_ZOOM); + } else { + m_map->setCoordinateZoom(QMapbox::Coordinate(64.31990695292795, -149.79038934046247), MIN_ZOOM); + } + + m_map->setMargins({0, 350, 0, 50}); + m_map->setPitch(MIN_PITCH); + m_map->setStyleUrl("mapbox://styles/commaai/ckr64tlwp0azb17nqvr9fj13s"); + + QObject::connect(m_map.data(), &QMapboxGL::mapChanged, [=](QMapboxGL::MapChange change) { + if (change == QMapboxGL::MapChange::MapChangeDidFinishLoadingMap) { + loaded_once = true; + } + }); +} + +void MapWindow::paintGL() { + if (!isVisible() || m_map.isNull()) return; + m_map->render(); +} + +void MapWindow::clearRoute() { + if (!m_map.isNull()) { + m_map->setLayoutProperty("navLayer", "visibility", "none"); + m_map->setPitch(MIN_PITCH); + } + + map_instructions->hideIfNoError(); + map_eta->setVisible(false); + allow_open = true; +} + +void MapWindow::mousePressEvent(QMouseEvent *ev) { + m_lastPos = ev->localPos(); + ev->accept(); +} + +void MapWindow::mouseDoubleClickEvent(QMouseEvent *ev) { + if (last_position) m_map->setCoordinate(*last_position); + if (last_bearing) m_map->setBearing(*last_bearing); + m_map->setZoom(util::map_val(velocity_filter.x(), 0, 30, MAX_ZOOM, MIN_ZOOM)); + update(); + + pan_counter = 0; + zoom_counter = 0; +} + +void MapWindow::mouseMoveEvent(QMouseEvent *ev) { + QPointF delta = ev->localPos() - m_lastPos; + + if (!delta.isNull()) { + pan_counter = PAN_TIMEOUT; + m_map->moveBy(delta / MAP_SCALE); + update(); + } + + m_lastPos = ev->localPos(); + ev->accept(); +} + +void MapWindow::wheelEvent(QWheelEvent *ev) { + if (ev->orientation() == Qt::Horizontal) { + return; + } + + float factor = ev->delta() / 1200.; + if (ev->delta() < 0) { + factor = factor > -1 ? factor : 1 / factor; + } + + m_map->scaleBy(1 + factor, ev->pos() / MAP_SCALE); + update(); + + zoom_counter = PAN_TIMEOUT; + ev->accept(); +} + +bool MapWindow::event(QEvent *event) { + if (event->type() == QEvent::Gesture) { + return gestureEvent(static_cast(event)); + } + + return QWidget::event(event); +} + +bool MapWindow::gestureEvent(QGestureEvent *event) { + if (QGesture *pinch = event->gesture(Qt::PinchGesture)) { + pinchTriggered(static_cast(pinch)); + } + return true; +} + +void MapWindow::pinchTriggered(QPinchGesture *gesture) { + QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags(); + if (changeFlags & QPinchGesture::ScaleFactorChanged) { + // TODO: figure out why gesture centerPoint doesn't work + m_map->scaleBy(gesture->scaleFactor(), {width() / 2.0 / MAP_SCALE, height() / 2.0 / MAP_SCALE}); + update(); + zoom_counter = PAN_TIMEOUT; + } +} + +void MapWindow::offroadTransition(bool offroad) { + if (offroad) { + clearRoute(); + } else { + auto dest = coordinate_from_param("NavDestination"); + setVisible(dest.has_value()); + } + last_bearing = {}; +} + +MapInstructions::MapInstructions(QWidget * parent) : QWidget(parent) { + is_rhd = Params().getBool("IsRHD"); + QHBoxLayout *main_layout = new QHBoxLayout(this); + main_layout->setContentsMargins(11, 50, 11, 11); + { + QVBoxLayout *layout = new QVBoxLayout; + icon_01 = new QLabel; + layout->addWidget(icon_01); + layout->addStretch(); + main_layout->addLayout(layout); + } + + { + QVBoxLayout *layout = new QVBoxLayout; + + distance = new QLabel; + distance->setStyleSheet(R"(font-size: 90px;)"); + layout->addWidget(distance); + + primary = new QLabel; + primary->setStyleSheet(R"(font-size: 60px;)"); + primary->setWordWrap(true); + layout->addWidget(primary); + + secondary = new QLabel; + secondary->setStyleSheet(R"(font-size: 50px;)"); + secondary->setWordWrap(true); + layout->addWidget(secondary); + + lane_widget = new QWidget; + lane_widget->setFixedHeight(125); + + lane_layout = new QHBoxLayout(lane_widget); + layout->addWidget(lane_widget); + + main_layout->addLayout(layout); + } + + setStyleSheet(R"( + * { + color: white; + font-family: "Inter"; + } + )"); + + QPalette pal = palette(); + pal.setColor(QPalette::Background, QColor(0, 0, 0, 150)); + setAutoFillBackground(true); + setPalette(pal); +} + +void MapInstructions::updateDistance(float d) { + d = std::max(d, 0.0f); + QString distance_str; + + if (QUIState::ui_state.scene.is_metric) { + if (d > 500) { + distance_str.setNum(d / 1000, 'f', 1); + distance_str += " km"; + } else { + distance_str.setNum(50 * int(d / 50)); + distance_str += " m"; + } + } else { + float miles = d * METER_TO_MILE; + float feet = d * METER_TO_FOOT; + + if (feet > 500) { + distance_str.setNum(miles, 'f', 1); + distance_str += " mi"; + } else { + distance_str.setNum(50 * int(feet / 50)); + distance_str += " ft"; + } + } + + distance->setAlignment(Qt::AlignLeft); + distance->setText(distance_str); +} + +void MapInstructions::showError(QString error_text) { + primary->setText(""); + distance->setText(error_text); + distance->setAlignment(Qt::AlignCenter); + + secondary->setVisible(false); + icon_01->setVisible(false); + + this->error = true; + lane_widget->setVisible(false); + + setVisible(true); +} + +void MapInstructions::noError() { + error = false; +} + +void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruction) { + // Word wrap widgets need fixed width + primary->setFixedWidth(width() - 250); + secondary->setFixedWidth(width() - 250); + + + // Show instruction text + QString primary_str = QString::fromStdString(instruction.getManeuverPrimaryText()); + QString secondary_str = QString::fromStdString(instruction.getManeuverSecondaryText()); + + primary->setText(primary_str); + secondary->setVisible(secondary_str.length() > 0); + secondary->setText(secondary_str); + + // Show arrow with direction + QString type = QString::fromStdString(instruction.getManeuverType()); + QString modifier = QString::fromStdString(instruction.getManeuverModifier()); + if (!type.isEmpty()) { + QString fn = "../assets/navigation/direction_" + type; + if (!modifier.isEmpty()) { + fn += "_" + modifier; + } + fn += ICON_SUFFIX; + fn = fn.replace(' ', '_'); + + // for rhd, reflect direction and then flip + if (is_rhd) { + if (fn.contains("left")) { + fn.replace(QString("left"), QString("right")); + } else if (fn.contains("right")) { + fn.replace(QString("right"), QString("left")); + } + } + + QPixmap pix(fn); + if (is_rhd) { + pix = pix.transformed(QTransform().scale(-1, 1)); + } + icon_01->setPixmap(pix.scaledToWidth(200, Qt::SmoothTransformation)); + icon_01->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + icon_01->setVisible(true); + } + + // Show lanes + bool has_lanes = false; + clearLayout(lane_layout); + for (auto const &lane: instruction.getLanes()) { + has_lanes = true; + bool active = lane.getActive(); + + // TODO: only use active direction if active + bool left = false, straight = false, right = false; + for (auto const &direction: lane.getDirections()) { + left |= direction == cereal::NavInstruction::Direction::LEFT; + right |= direction == cereal::NavInstruction::Direction::RIGHT; + straight |= direction == cereal::NavInstruction::Direction::STRAIGHT; + } + + // TODO: Make more images based on active direction and combined directions + QString fn = "../assets/navigation/direction_"; + if (left) { + fn += "turn_left"; + } else if (right) { + fn += "turn_right"; + } else if (straight) { + fn += "turn_straight"; + } + + QPixmap pix(fn + ICON_SUFFIX); + auto icon = new QLabel; + int wh = active ? 125 : 75; + icon->setPixmap(pix.scaled(wh, wh, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + lane_layout->addWidget(icon); + } + lane_widget->setVisible(has_lanes); + + show(); + resize(sizeHint()); +} + + +void MapInstructions::hideIfNoError() { + if (!error) { + hide(); + } +} + +MapETA::MapETA(QWidget * parent) : QWidget(parent) { + QHBoxLayout *main_layout = new QHBoxLayout(this); + main_layout->setContentsMargins(40, 25, 40, 25); + + { + QHBoxLayout *layout = new QHBoxLayout; + eta = new QLabel; + eta->setAlignment(Qt::AlignCenter); + eta->setStyleSheet("font-weight:600"); + + eta_unit = new QLabel; + eta_unit->setAlignment(Qt::AlignCenter); + + layout->addWidget(eta); + layout->addWidget(eta_unit); + main_layout->addLayout(layout); + } + main_layout->addSpacing(40); + { + QHBoxLayout *layout = new QHBoxLayout; + time = new QLabel; + time->setAlignment(Qt::AlignCenter); + + time_unit = new QLabel; + time_unit->setAlignment(Qt::AlignCenter); + + layout->addWidget(time); + layout->addWidget(time_unit); + main_layout->addLayout(layout); + } + main_layout->addSpacing(40); + { + QHBoxLayout *layout = new QHBoxLayout; + distance = new QLabel; + distance->setAlignment(Qt::AlignCenter); + distance->setStyleSheet("font-weight:600"); + + distance_unit = new QLabel; + distance_unit->setAlignment(Qt::AlignCenter); + + layout->addWidget(distance); + layout->addWidget(distance_unit); + main_layout->addLayout(layout); + } + + setStyleSheet(R"( + * { + color: white; + font-family: "Inter"; + font-size: 70px; + } + )"); + + QPalette pal = palette(); + pal.setColor(QPalette::Background, QColor(0, 0, 0, 150)); + setAutoFillBackground(true); + setPalette(pal); +} + + +void MapETA::updateETA(float s, float s_typical, float d) { + if (d < MANEUVER_TRANSITION_THRESHOLD) { + hide(); + return; + } + + // ETA + auto eta_time = QDateTime::currentDateTime().addSecs(s).time(); + if (params.getBool("NavSettingTime24h")) { + eta->setText(eta_time.toString("HH:mm")); + eta_unit->setText("eta"); + } else { + auto t = eta_time.toString("h:mm a").split(' '); + eta->setText(t[0]); + eta_unit->setText(t[1]); + } + + // Remaining time + if (s < 3600) { + time->setText(QString::number(int(s / 60))); + time_unit->setText("min"); + } else { + int hours = int(s) / 3600; + time->setText(QString::number(hours) + ":" + QString::number(int((s - hours * 3600) / 60)).rightJustified(2, '0')); + time_unit->setText("hr"); + } + + QString color; + if (s / s_typical > 1.5) { + color = "#DA3025"; + } else if (s / s_typical > 1.2) { + color = "#DAA725"; + } else { + color = "#25DA6E"; + } + + time->setStyleSheet(QString(R"(color: %1; font-weight:600;)").arg(color)); + time_unit->setStyleSheet(QString(R"(color: %1;)").arg(color)); + + // Distance + QString distance_str; + float num = 0; + if (QUIState::ui_state.scene.is_metric) { + num = d / 1000.0; + distance_unit->setText("km"); + } else { + num = d * METER_TO_MILE; + distance_unit->setText("mi"); + } + + distance_str.setNum(num, 'f', num < 100 ? 1 : 0); + distance->setText(distance_str); + + show(); + adjustSize(); + repaint(); + adjustSize(); + + // Rounded corners + const int radius = 25; + const auto r = rect(); + + // Top corners rounded + QPainterPath path; + path.setFillRule(Qt::WindingFill); + path.addRoundedRect(r, radius, radius); + + // Bottom corners not rounded + path.addRect(r.marginsRemoved(QMargins(0, radius, 0, 0))); + + // Set clipping mask + QRegion mask = QRegion(path.simplified().toFillPolygon().toPolygon()); + setMask(mask); + + // Center + move(static_cast(parent())->width() / 2 - width() / 2, 1080 - height() - bdr_s*2); +} diff --git a/selfdrive/ui/qt/maps/map.h b/selfdrive/ui/qt/maps/map.h new file mode 100644 index 00000000000000..c62089cb256bd0 --- /dev/null +++ b/selfdrive/ui/qt/maps/map.h @@ -0,0 +1,128 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/common/util.h" +#include "cereal/messaging/messaging.h" + +class MapInstructions : public QWidget { + Q_OBJECT + +private: + QLabel *distance; + QLabel *primary; + QLabel *secondary; + QLabel *icon_01; + QWidget *lane_widget; + QHBoxLayout *lane_layout; + bool error = false; + bool is_rhd = false; + +public: + MapInstructions(QWidget * parent=nullptr); + void showError(QString error); + void noError(); + void hideIfNoError(); + +public slots: + void updateDistance(float d); + void updateInstructions(cereal::NavInstruction::Reader instruction); +}; + +class MapETA : public QWidget { + Q_OBJECT + +private: + QLabel *eta; + QLabel *eta_unit; + QLabel *time; + QLabel *time_unit; + QLabel *distance; + QLabel *distance_unit; + Params params; + +public: + MapETA(QWidget * parent=nullptr); + +public slots: + void updateETA(float seconds, float seconds_typical, float distance); +}; + +class MapWindow : public QOpenGLWidget { + Q_OBJECT + +public: + MapWindow(const QMapboxGLSettings &); + ~MapWindow(); + +private: + void initializeGL() final; + void paintGL() final; + void resizeGL(int w, int h) override; + + QMapboxGLSettings m_settings; + QScopedPointer m_map; + + void initLayers(); + + void mousePressEvent(QMouseEvent *ev) final; + void mouseDoubleClickEvent(QMouseEvent *ev) final; + void mouseMoveEvent(QMouseEvent *ev) final; + void wheelEvent(QWheelEvent *ev) final; + bool event(QEvent *event) final; + bool gestureEvent(QGestureEvent *event); + void pinchTriggered(QPinchGesture *gesture); + + bool m_sourceAdded = false; + SubMaster *sm; + QTimer* timer; + + bool loaded_once = false; + bool allow_open = true; + + // Panning + QPointF m_lastPos; + int pan_counter = 0; + int zoom_counter = 0; + + // Position + std::optional last_position; + std::optional last_bearing; + FirstOrderFilter velocity_filter; + bool localizer_valid = false; + + MapInstructions* map_instructions; + MapETA* map_eta; + + void clearRoute(); + uint64_t route_rcv_frame = 0; + +private slots: + void timerUpdate(); + +public slots: + void offroadTransition(bool offroad); + +signals: + void distanceChanged(float distance); + void instructionsChanged(cereal::NavInstruction::Reader instruction); + void ETAChanged(float seconds, float seconds_typical, float distance); +}; + diff --git a/selfdrive/ui/qt/maps/map_helpers.cc b/selfdrive/ui/qt/maps/map_helpers.cc new file mode 100644 index 00000000000000..f87e80403f0e4d --- /dev/null +++ b/selfdrive/ui/qt/maps/map_helpers.cc @@ -0,0 +1,208 @@ +#include "selfdrive/ui/qt/maps/map_helpers.h" + +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/api.h" + +QString get_mapbox_token() { + // Valid for 4 weeks since we can't swap tokens on the fly + return MAPBOX_TOKEN.isEmpty() ? CommaApi::create_jwt({}, 4 * 7 * 24 * 3600) : MAPBOX_TOKEN; +} + +QMapboxGLSettings get_mapbox_settings() { + QMapboxGLSettings settings; + + if (!Hardware::PC()) { + settings.setCacheDatabasePath(MAPS_CACHE_PATH); + } + settings.setApiBaseUrl(MAPS_HOST); + settings.setAccessToken(get_mapbox_token()); + + return settings; +} + +QGeoCoordinate to_QGeoCoordinate(const QMapbox::Coordinate &in) { + return QGeoCoordinate(in.first, in.second); +} + +QMapbox::CoordinatesCollections model_to_collection( + const cereal::LiveLocationKalman::Measurement::Reader &calibratedOrientationECEF, + const cereal::LiveLocationKalman::Measurement::Reader &positionECEF, + const cereal::ModelDataV2::XYZTData::Reader &line){ + + Eigen::Vector3d ecef(positionECEF.getValue()[0], positionECEF.getValue()[1], positionECEF.getValue()[2]); + Eigen::Vector3d orient(calibratedOrientationECEF.getValue()[0], calibratedOrientationECEF.getValue()[1], calibratedOrientationECEF.getValue()[2]); + Eigen::Matrix3d ecef_from_local = euler2rot(orient); + + QMapbox::Coordinates coordinates; + auto x = line.getX(); + auto y = line.getY(); + auto z = line.getZ(); + for (int i = 0; i < x.size(); i++) { + Eigen::Vector3d point_ecef = ecef_from_local * Eigen::Vector3d(x[i], y[i], z[i]) + ecef; + Geodetic point_geodetic = ecef2geodetic((ECEF){.x = point_ecef[0], .y = point_ecef[1], .z = point_ecef[2]}); + QMapbox::Coordinate coordinate(point_geodetic.lat, point_geodetic.lon); + coordinates.push_back(coordinate); + } + + QMapbox::CoordinatesCollection collection; + collection.push_back(coordinates); + + QMapbox::CoordinatesCollections collections; + collections.push_back(collection); + return collections; +} + +QMapbox::CoordinatesCollections coordinate_to_collection(QMapbox::Coordinate c) { + QMapbox::Coordinates coordinates; + coordinates.push_back(c); + + QMapbox::CoordinatesCollection collection; + collection.push_back(coordinates); + + QMapbox::CoordinatesCollections collections; + collections.push_back(collection); + return collections; +} + +QMapbox::CoordinatesCollections capnp_coordinate_list_to_collection(const capnp::List::Reader& coordinate_list) { + QMapbox::Coordinates coordinates; + + for (auto const &c: coordinate_list) { + QMapbox::Coordinate coordinate(c.getLatitude(), c.getLongitude()); + coordinates.push_back(coordinate); + } + + QMapbox::CoordinatesCollection collection; + collection.push_back(coordinates); + + QMapbox::CoordinatesCollections collections; + collections.push_back(collection); + return collections; + +} + +QMapbox::CoordinatesCollections coordinate_list_to_collection(QList coordinate_list) { + QMapbox::Coordinates coordinates; + + for (auto &c : coordinate_list) { + QMapbox::Coordinate coordinate(c.latitude(), c.longitude()); + coordinates.push_back(coordinate); + } + + QMapbox::CoordinatesCollection collection; + collection.push_back(coordinates); + + QMapbox::CoordinatesCollections collections; + collections.push_back(collection); + return collections; +} + +QList polyline_to_coordinate_list(const QString &polylineString) { + QList path; + if (polylineString.isEmpty()) + return path; + + QByteArray data = polylineString.toLatin1(); + + bool parsingLatitude = true; + + int shift = 0; + int value = 0; + + QGeoCoordinate coord(0, 0); + + for (int i = 0; i < data.length(); ++i) { + unsigned char c = data.at(i) - 63; + + value |= (c & 0x1f) << shift; + shift += 5; + + // another chunk + if (c & 0x20) + continue; + + int diff = (value & 1) ? ~(value >> 1) : (value >> 1); + + if (parsingLatitude) { + coord.setLatitude(coord.latitude() + (double)diff/1e6); + } else { + coord.setLongitude(coord.longitude() + (double)diff/1e6); + path.append(coord); + } + + parsingLatitude = !parsingLatitude; + + value = 0; + shift = 0; + } + + return path; +} + +static QGeoCoordinate sub(QGeoCoordinate v, QGeoCoordinate w) { + return QGeoCoordinate(v.latitude() - w.latitude(), v.longitude() - w.longitude()); +} + +static QGeoCoordinate add(QGeoCoordinate v, QGeoCoordinate w) { + return QGeoCoordinate(v.latitude() + w.latitude(), v.longitude() + w.longitude()); +} + +static QGeoCoordinate mul(QGeoCoordinate v, float c) { + return QGeoCoordinate(c * v.latitude(), c * v.longitude()); +} + +static float dot(QGeoCoordinate v, QGeoCoordinate w) { + return v.latitude() * w.latitude() + v.longitude() * w.longitude(); +} + +float minimum_distance(QGeoCoordinate a, QGeoCoordinate b, QGeoCoordinate p) { + const QGeoCoordinate ap = sub(p, a); + const QGeoCoordinate ab = sub(b, a); + const float t = std::clamp(dot(ap, ab) / dot(ab, ab), 0.0f, 1.0f); + const QGeoCoordinate projection = add(a, mul(ab, t)); + return projection.distanceTo(p); +} + +float distance_along_geometry(QList geometry, QGeoCoordinate pos) { + if (geometry.size() <= 2) { + return geometry[0].distanceTo(pos); + } + + // 1. Find segment that is closest to current position + // 2. Total distance is sum of distance to start of closest segment + // + all previous segments + double total_distance = 0; + double total_distance_closest = 0; + double closest_distance = std::numeric_limits::max(); + + for (int i = 0; i < geometry.size() - 1; i++) { + double d = minimum_distance(geometry[i], geometry[i+1], pos); + if (d < closest_distance) { + closest_distance = d; + total_distance_closest = total_distance + geometry[i].distanceTo(pos); + } + total_distance += geometry[i].distanceTo(geometry[i+1]); + } + + return total_distance_closest; +} + +std::optional coordinate_from_param(std::string param) { + QString json_str = QString::fromStdString(Params().get(param)); + if (json_str.isEmpty()) return {}; + + QJsonDocument doc = QJsonDocument::fromJson(json_str.toUtf8()); + if (doc.isNull()) return {}; + + QJsonObject json = doc.object(); + if (json["latitude"].isDouble() && json["longitude"].isDouble()) { + QMapbox::Coordinate coord(json["latitude"].toDouble(), json["longitude"].toDouble()); + return coord; + } else { + return {}; + } +} diff --git a/selfdrive/ui/qt/maps/map_helpers.h b/selfdrive/ui/qt/maps/map_helpers.h new file mode 100644 index 00000000000000..1c8cacbebc4336 --- /dev/null +++ b/selfdrive/ui/qt/maps/map_helpers.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include +#include + +#include "selfdrive/common/util.h" +#include "common/transformations/coordinates.hpp" +#include "common/transformations/orientation.hpp" +#include "cereal/messaging/messaging.h" + +const QString MAPBOX_TOKEN = util::getenv("MAPBOX_TOKEN").c_str(); +const QString MAPS_HOST = util::getenv("MAPS_HOST", MAPBOX_TOKEN.isEmpty() ? "https://maps.comma.ai" : "https://api.mapbox.com").c_str(); +const QString MAPS_CACHE_PATH = "/data/mbgl-cache-navd.db"; + +QString get_mapbox_token(); +QMapboxGLSettings get_mapbox_settings(); +QGeoCoordinate to_QGeoCoordinate(const QMapbox::Coordinate &in); +QMapbox::CoordinatesCollections model_to_collection( + const cereal::LiveLocationKalman::Measurement::Reader &calibratedOrientationECEF, + const cereal::LiveLocationKalman::Measurement::Reader &positionECEF, + const cereal::ModelDataV2::XYZTData::Reader &line); +QMapbox::CoordinatesCollections coordinate_to_collection(QMapbox::Coordinate c); +QMapbox::CoordinatesCollections capnp_coordinate_list_to_collection(const capnp::List::Reader &coordinate_list); +QMapbox::CoordinatesCollections coordinate_list_to_collection(QList coordinate_list); +QList polyline_to_coordinate_list(const QString &polylineString); + +float minimum_distance(QGeoCoordinate a, QGeoCoordinate b, QGeoCoordinate p); +std::optional coordinate_from_param(std::string param); +float distance_along_geometry(QList geometry, QGeoCoordinate pos); diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc new file mode 100644 index 00000000000000..e130a9a1ec4997 --- /dev/null +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -0,0 +1,293 @@ +#include "map_settings.h" + +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/request_repeater.h" +#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/qt/widgets/scrollview.h" + +static QString shorten(const QString &str, int max_len) { + return str.size() > max_len ? str.left(max_len).trimmed() + "…" : str; +} + +MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { + stack = new QStackedWidget; + + QWidget * main_widget = new QWidget; + QVBoxLayout *main_layout = new QVBoxLayout(main_widget); + const int icon_size = 200; + + // Home + QHBoxLayout *home_layout = new QHBoxLayout; + home_button = new QPushButton; + home_button->setIconSize(QSize(icon_size, icon_size)); + home_layout->addWidget(home_button); + + home_address = new QLabel; + home_address->setWordWrap(true); + home_layout->addSpacing(30); + home_layout->addWidget(home_address); + home_layout->addStretch(); + + // Work + QHBoxLayout *work_layout = new QHBoxLayout; + work_button = new QPushButton; + work_button->setIconSize(QSize(icon_size, icon_size)); + work_layout->addWidget(work_button); + + work_address = new QLabel; + work_address->setWordWrap(true); + work_layout->addSpacing(30); + work_layout->addWidget(work_address); + work_layout->addStretch(); + + // Home & Work layout + QHBoxLayout *home_work_layout = new QHBoxLayout; + home_work_layout->addLayout(home_layout, 1); + home_work_layout->addSpacing(50); + home_work_layout->addLayout(work_layout, 1); + + main_layout->addLayout(home_work_layout); + main_layout->addSpacing(20); + main_layout->addWidget(horizontal_line()); + main_layout->addSpacing(20); + + // Current route + { + current_widget = new QWidget(this); + QVBoxLayout *current_layout = new QVBoxLayout(current_widget); + + QLabel *title = new QLabel("Current Destination"); + title->setStyleSheet("font-size: 55px"); + current_layout->addWidget(title); + + current_route = new ButtonControl("", "CLEAR"); + current_route->setStyleSheet("padding-left: 40px;"); + current_layout->addWidget(current_route); + QObject::connect(current_route, &ButtonControl::clicked, [=]() { + params.remove("NavDestination"); + updateCurrentRoute(); + }); + + current_layout->addSpacing(10); + current_layout->addWidget(horizontal_line()); + current_layout->addSpacing(20); + } + main_layout->addWidget(current_widget); + + // Recents + QLabel *recents_title = new QLabel("Recent Destinations"); + recents_title->setStyleSheet("font-size: 55px"); + main_layout->addWidget(recents_title); + main_layout->addSpacing(20); + + recent_layout = new QVBoxLayout; + QWidget *recent_widget = new LayoutWidget(recent_layout, this); + ScrollView *recent_scroller = new ScrollView(recent_widget, this); + main_layout->addWidget(recent_scroller); + + // No prime upsell + QWidget * no_prime_widget = new QWidget; + { + QVBoxLayout *no_prime_layout = new QVBoxLayout(no_prime_widget); + QLabel *signup_header = new QLabel("Try the Navigation Beta"); + signup_header->setStyleSheet(R"(font-size: 75px; color: white; font-weight:600;)"); + signup_header->setAlignment(Qt::AlignCenter); + + no_prime_layout->addWidget(signup_header); + no_prime_layout->addSpacing(50); + + QLabel *screenshot = new QLabel; + QPixmap pm = QPixmap("../assets/navigation/screenshot.png"); + screenshot->setPixmap(pm.scaledToWidth(1080, Qt::SmoothTransformation)); + no_prime_layout->addWidget(screenshot, 0, Qt::AlignHCenter); + + QLabel *signup = new QLabel("Get turn-by-turn directions displayed and more with a comma \nprime subscription. Sign up now: https://connect.comma.ai"); + signup->setStyleSheet(R"(font-size: 45px; color: white; font-weight:300;)"); + signup->setAlignment(Qt::AlignCenter); + + no_prime_layout->addSpacing(20); + no_prime_layout->addWidget(signup); + no_prime_layout->addStretch(); + } + + stack->addWidget(main_widget); + stack->addWidget(no_prime_widget); + stack->setCurrentIndex(1); + + QVBoxLayout *wrapper = new QVBoxLayout(this); + wrapper->addWidget(stack); + + clear(); + + if (auto dongle_id = getDongleId()) { + // Fetch favorite and recent locations + { + QString url = CommaApi::BASE_URL + "/v1/navigation/" + *dongle_id + "/locations"; + RequestRepeater* repeater = new RequestRepeater(this, url, "ApiCache_NavDestinations", 30, true); + QObject::connect(repeater, &RequestRepeater::requestDone, this, &MapPanel::parseResponse); + } + + // Destination set while offline + { + QString url = CommaApi::BASE_URL + "/v1/navigation/" + *dongle_id + "/next"; + RequestRepeater* repeater = new RequestRepeater(this, url, "", 10, true); + HttpRequest* deleter = new HttpRequest(this); + + QObject::connect(repeater, &RequestRepeater::requestDone, [=](const QString &resp, bool success) { + if (success && resp != "null") { + if (params.get("NavDestination").empty()) { + qWarning() << "Setting NavDestination from /next" << resp; + params.put("NavDestination", resp.toStdString()); + } else { + qWarning() << "Got location from /next, but NavDestination already set"; + } + + // Send DELETE to clear destination server side + deleter->sendRequest(url, HttpRequest::Method::DELETE); + } + }); + } + } +} + +void MapPanel::showEvent(QShowEvent *event) { + updateCurrentRoute(); +} + +void MapPanel::clear() { + home_button->setIcon(QPixmap("../assets/navigation/home_inactive.png")); + home_address->setStyleSheet(R"(font-size: 50px; color: grey;)"); + home_address->setText("No home\nlocation set"); + home_button->disconnect(); + + work_button->setIcon(QPixmap("../assets/navigation/work_inactive.png")); + work_address->setStyleSheet(R"(font-size: 50px; color: grey;)"); + work_address->setText("No work\nlocation set"); + work_button->disconnect(); + + clearLayout(recent_layout); +} + +void MapPanel::updateCurrentRoute() { + auto dest = QString::fromStdString(params.get("NavDestination")); + QJsonDocument doc = QJsonDocument::fromJson(dest.trimmed().toUtf8()); + if (dest.size() && !doc.isNull()) { + auto name = doc["place_name"].toString(); + auto details = doc["place_details"].toString(); + current_route->setTitle(shorten(name + " " + details, 42)); + } + current_widget->setVisible(dest.size() && !doc.isNull()); +} + +void MapPanel::parseResponse(const QString &response, bool success) { + if (!success) { + stack->setCurrentIndex(1); + return; + } + + QJsonDocument doc = QJsonDocument::fromJson(response.trimmed().toUtf8()); + if (doc.isNull()) { + qDebug() << "JSON Parse failed on navigation locations"; + return; + } + + clear(); + + bool has_recents = false; + for (auto &save_type: {"favorite", "recent"}) { + for (auto location : doc.array()) { + auto obj = location.toObject(); + + auto type = obj["save_type"].toString(); + auto label = obj["label"].toString(); + auto name = obj["place_name"].toString(); + auto details = obj["place_details"].toString(); + + if (type != save_type) continue; + + if (type == "favorite" && label == "home") { + home_address->setText(name); + home_address->setStyleSheet(R"(font-size: 50px; color: white;)"); + home_button->setIcon(QPixmap("../assets/navigation/home.png")); + QObject::connect(home_button, &QPushButton::clicked, [=]() { + navigateTo(obj); + emit closeSettings(); + }); + } else if (type == "favorite" && label == "work") { + work_address->setText(name); + work_address->setStyleSheet(R"(font-size: 50px; color: white;)"); + work_button->setIcon(QPixmap("../assets/navigation/work.png")); + QObject::connect(work_button, &QPushButton::clicked, [=]() { + navigateTo(obj); + emit closeSettings(); + }); + } else { + ClickableWidget *widget = new ClickableWidget; + QHBoxLayout *layout = new QHBoxLayout(widget); + layout->setContentsMargins(15, 14, 40, 14); + + QLabel *star = new QLabel("★"); + auto sp = star->sizePolicy(); + sp.setRetainSizeWhenHidden(true); + star->setSizePolicy(sp); + + star->setVisible(type == "favorite"); + star->setStyleSheet(R"(font-size: 60px;)"); + layout->addWidget(star); + layout->addSpacing(10); + + + QLabel *recent_label = new QLabel(shorten(name + " " + details, 45)); + recent_label->setStyleSheet(R"(font-size: 50px;)"); + + layout->addWidget(recent_label); + layout->addStretch(); + + QLabel *arrow = new QLabel("→"); + arrow->setStyleSheet(R"(font-size: 60px;)"); + layout->addWidget(arrow); + + widget->setStyleSheet(R"( + .ClickableWidget { + border-radius: 10px; + border-width: 1px; + border-style: solid; + border-color: gray; + } + QWidget { + background-color: #393939; + color: #9c9c9c; + } + )"); + + QObject::connect(widget, &ClickableWidget::clicked, [=]() { + navigateTo(obj); + emit closeSettings(); + }); + + recent_layout->addWidget(widget); + recent_layout->addSpacing(10); + has_recents = true; + } + } + + } + + if (!has_recents) { + QLabel *no_recents = new QLabel("no recent destinations"); + no_recents->setStyleSheet(R"(font-size: 50px; color: #9c9c9c)"); + recent_layout->addWidget(no_recents); + } + + recent_layout->addStretch(); + stack->setCurrentIndex(0); + repaint(); +} + +void MapPanel::navigateTo(const QJsonObject &place) { + QJsonDocument doc(place); + params.put("NavDestination", doc.toJson().toStdString()); +} diff --git a/selfdrive/ui/qt/maps/map_settings.h b/selfdrive/ui/qt/maps/map_settings.h new file mode 100644 index 00000000000000..03720edee74ba7 --- /dev/null +++ b/selfdrive/ui/qt/maps/map_settings.h @@ -0,0 +1,37 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/ui/qt/widgets/controls.h" + +class MapPanel : public QWidget { + Q_OBJECT +public: + explicit MapPanel(QWidget* parent = nullptr); + + void navigateTo(const QJsonObject &place); + void parseResponse(const QString &response, bool success); + void updateCurrentRoute(); + void clear(); + +private: + void showEvent(QShowEvent *event) override; + + Params params; + QStackedWidget *stack; + QPushButton *home_button, *work_button; + QLabel *home_address, *work_address; + QVBoxLayout *recent_layout; + QWidget *current_widget; + ButtonControl *current_route; + +signals: + void closeSettings(); +}; diff --git a/selfdrive/ui/qt/offroad/driverview.cc b/selfdrive/ui/qt/offroad/driverview.cc new file mode 100644 index 00000000000000..6f03e2ed4a4e2a --- /dev/null +++ b/selfdrive/ui/qt/offroad/driverview.cc @@ -0,0 +1,101 @@ +#include "selfdrive/ui/qt/offroad/driverview.h" + +#include + +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/util.h" + +const int FACE_IMG_SIZE = 130; + +DriverViewWindow::DriverViewWindow(QWidget* parent) : QWidget(parent) { + setAttribute(Qt::WA_OpaquePaintEvent); + layout = new QStackedLayout(this); + layout->setStackingMode(QStackedLayout::StackAll); + + cameraView = new CameraViewWidget("camerad", VISION_STREAM_RGB_FRONT, true, this); + layout->addWidget(cameraView); + + scene = new DriverViewScene(this); + connect(cameraView, &CameraViewWidget::vipcThreadFrameReceived, scene, &DriverViewScene::frameUpdated); + layout->addWidget(scene); + layout->setCurrentWidget(scene); +} + +void DriverViewWindow::mouseReleaseEvent(QMouseEvent* e) { + emit done(); +} + +DriverViewScene::DriverViewScene(QWidget* parent) : sm({"driverState"}), QWidget(parent) { + face_img = QImage("../assets/img_driver_face.png").scaled(FACE_IMG_SIZE, FACE_IMG_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation); +} + +void DriverViewScene::showEvent(QShowEvent* event) { + frame_updated = false; + is_rhd = params.getBool("IsRHD"); + params.putBool("IsDriverViewEnabled", true); +} + +void DriverViewScene::hideEvent(QHideEvent* event) { + params.putBool("IsDriverViewEnabled", false); +} + +void DriverViewScene::frameUpdated() { + frame_updated = true; + sm.update(0); + update(); +} + +void DriverViewScene::paintEvent(QPaintEvent* event) { + QPainter p(this); + + // startup msg + if (!frame_updated) { + p.setPen(Qt::white); + p.setRenderHint(QPainter::TextAntialiasing); + configFont(p, "Inter", 100, "Bold"); + p.drawText(geometry(), Qt::AlignCenter, "camera starting"); + return; + } + + const int width = 4 * height() / 3; + const QRect rect2 = {rect().center().x() - width / 2, rect().top(), width, rect().height()}; + const QRect valid_rect = {is_rhd ? rect2.right() - rect2.height() / 2 : rect2.left(), rect2.top(), rect2.height() / 2, rect2.height()}; + + // blackout + const QColor bg(0, 0, 0, 140); + const QRect& blackout_rect = Hardware::TICI() ? rect() : rect2; + p.fillRect(blackout_rect.adjusted(0, 0, valid_rect.left() - blackout_rect.right(), 0), bg); + p.fillRect(blackout_rect.adjusted(valid_rect.right() - blackout_rect.left(), 0, 0, 0), bg); + if (Hardware::TICI()) { + p.fillRect(blackout_rect.adjusted(valid_rect.left()-blackout_rect.left()+1, 0, valid_rect.right()-blackout_rect.right()-1, -valid_rect.height()*7/10), bg); // top dz + } + + // face bounding box + cereal::DriverState::Reader driver_state = sm["driverState"].getDriverState(); + bool face_detected = driver_state.getFaceProb() > 0.5; + if (face_detected) { + auto fxy_list = driver_state.getFacePosition(); + auto std_list = driver_state.getFaceOrientationStd(); + float face_x = fxy_list[0]; + float face_y = fxy_list[1]; + float face_std = std::max(std_list[0], std_list[1]); + + float alpha = 0.7; + if (face_std > 0.08) { + alpha = std::max(0.7 - (face_std-0.08)*7, 0.0); + } + const int box_size = 0.6 * rect2.height() / 2; + const float rhd_offset = 0.05; // lhd is shifted, so rhd is not mirrored + int fbox_x = valid_rect.center().x() + (is_rhd ? (face_x + rhd_offset) : -face_x) * valid_rect.width(); + int fbox_y = valid_rect.center().y() + face_y * valid_rect.height(); + p.setPen(QPen(QColor(255, 255, 255, alpha * 255), 10)); + p.drawRoundedRect(fbox_x - box_size / 2, fbox_y - box_size / 2, box_size, box_size, 35.0, 35.0); + } + + // icon + const int img_offset = 30; + const int img_x = is_rhd ? rect2.right() - FACE_IMG_SIZE - img_offset : rect2.left() + img_offset; + const int img_y = rect2.bottom() - FACE_IMG_SIZE - img_offset; + p.setOpacity(face_detected ? 1.0 : 0.3); + p.drawImage(img_x, img_y, face_img); +} diff --git a/selfdrive/ui/qt/offroad/driverview.h b/selfdrive/ui/qt/offroad/driverview.h new file mode 100644 index 00000000000000..8eab76a3dd675e --- /dev/null +++ b/selfdrive/ui/qt/offroad/driverview.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/ui/qt/widgets/cameraview.h" + +class DriverViewScene : public QWidget { + Q_OBJECT + +public: + explicit DriverViewScene(QWidget *parent); + +public slots: + void frameUpdated(); + +protected: + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; + void paintEvent(QPaintEvent *event) override; + +private: + Params params; + SubMaster sm; + QImage face_img; + bool is_rhd = false; + bool frame_updated = false; +}; + +class DriverViewWindow : public QWidget { + Q_OBJECT + +public: + explicit DriverViewWindow(QWidget *parent); + +signals: + void done(); + +protected: + void mouseReleaseEvent(QMouseEvent* e) override; + +private: + CameraViewWidget *cameraView; + DriverViewScene *scene; + QStackedLayout *layout; +}; diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc new file mode 100644 index 00000000000000..dd519dd6615124 --- /dev/null +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -0,0 +1,332 @@ +#include "selfdrive/ui/qt/offroad/networking.h" + +#include + +#include +#include +#include +#include +#include + +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/qt/widgets/scrollview.h" + + +// Networking functions + +Networking::Networking(QWidget* parent, bool show_advanced) : QFrame(parent) { + main_layout = new QStackedLayout(this); + + wifi = new WifiManager(this); + connect(wifi, &WifiManager::refreshSignal, this, &Networking::refresh); + connect(wifi, &WifiManager::wrongPassword, this, &Networking::wrongPassword); + + wifiScreen = new QWidget(this); + QVBoxLayout* vlayout = new QVBoxLayout(wifiScreen); + vlayout->setContentsMargins(20, 20, 20, 20); + if (show_advanced) { + QPushButton* advancedSettings = new QPushButton("Advanced"); + advancedSettings->setObjectName("advancedBtn"); + advancedSettings->setStyleSheet("margin-right: 30px;"); + advancedSettings->setFixedSize(350, 100); + connect(advancedSettings, &QPushButton::clicked, [=]() { main_layout->setCurrentWidget(an); }); + vlayout->addSpacing(10); + vlayout->addWidget(advancedSettings, 0, Qt::AlignRight); + vlayout->addSpacing(10); + } + + wifiWidget = new WifiUI(this, wifi); + wifiWidget->setObjectName("wifiWidget"); + connect(wifiWidget, &WifiUI::connectToNetwork, this, &Networking::connectToNetwork); + + ScrollView *wifiScroller = new ScrollView(wifiWidget, this); + wifiScroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + vlayout->addWidget(wifiScroller, 1); + main_layout->addWidget(wifiScreen); + + an = new AdvancedNetworking(this, wifi); + connect(an, &AdvancedNetworking::backPress, [=]() { main_layout->setCurrentWidget(wifiScreen); }); + main_layout->addWidget(an); + + QPalette pal = palette(); + pal.setColor(QPalette::Window, QColor(0x29, 0x29, 0x29)); + setAutoFillBackground(true); + setPalette(pal); + + // TODO: revisit pressed colors + setStyleSheet(R"( + #wifiWidget > QPushButton, #back_btn, #advancedBtn { + font-size: 50px; + margin: 0px; + padding: 15px; + border-width: 0; + border-radius: 30px; + color: #dddddd; + background-color: #444444; + } + )"); + main_layout->setCurrentWidget(wifiScreen); +} + +void Networking::refresh() { + wifiWidget->refresh(); + an->refresh(); +} + +void Networking::connectToNetwork(const Network &n) { + if (wifi->isKnownConnection(n.ssid)) { + wifi->activateWifiConnection(n.ssid); + wifiWidget->refresh(); + } else if (n.security_type == SecurityType::OPEN) { + wifi->connect(n); + } else if (n.security_type == SecurityType::WPA) { + QString pass = InputDialog::getText("Enter password", this, "for \"" + n.ssid + "\"", true, 8); + if (!pass.isEmpty()) { + wifi->connect(n, pass); + } + } +} + +void Networking::wrongPassword(const QString &ssid) { + if (wifi->seenNetworks.contains(ssid)) { + const Network &n = wifi->seenNetworks.value(ssid); + QString pass = InputDialog::getText("Wrong password", this, "for \"" + n.ssid +"\"", true, 8); + if (!pass.isEmpty()) { + wifi->connect(n, pass); + } + } +} + +void Networking::showEvent(QShowEvent* event) { + // Wait to refresh to avoid delay when showing Networking widget + QTimer::singleShot(300, this, [=]() { + if (this->isVisible()) { + wifi->refreshNetworks(); + refresh(); + } + }); +} + +// AdvancedNetworking functions + +AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWidget(parent), wifi(wifi) { + + QVBoxLayout* main_layout = new QVBoxLayout(this); + main_layout->setMargin(40); + main_layout->setSpacing(20); + + // Back button + QPushButton* back = new QPushButton("Back"); + back->setObjectName("back_btn"); + back->setFixedSize(500, 100); + connect(back, &QPushButton::clicked, [=]() { emit backPress(); }); + main_layout->addWidget(back, 0, Qt::AlignLeft); + + ListWidget *list = new ListWidget(this); + // Enable tethering layout + tetheringToggle = new ToggleControl("Enable Tethering", "", "", wifi->isTetheringEnabled()); + list->addItem(tetheringToggle); + QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering); + + // Change tethering password + ButtonControl *editPasswordButton = new ButtonControl("Tethering Password", "EDIT"); + connect(editPasswordButton, &ButtonControl::clicked, [=]() { + QString pass = InputDialog::getText("Enter new tethering password", this, "", true, 8, wifi->getTetheringPassword()); + if (!pass.isEmpty()) { + wifi->changeTetheringPassword(pass); + } + }); + list->addItem(editPasswordButton); + + // IP address + ipLabel = new LabelControl("IP Address", wifi->ipv4_address); + list->addItem(ipLabel); + + // SSH keys + list->addItem(new SshToggle()); + list->addItem(new SshControl()); + + // Roaming toggle + const bool roamingEnabled = params.getBool("GsmRoaming"); + ToggleControl *roamingToggle = new ToggleControl("Enable Roaming", "", "", roamingEnabled); + QObject::connect(roamingToggle, &SshToggle::toggleFlipped, [=](bool state) { + params.putBool("GsmRoaming", state); + wifi->updateGsmSettings(state, QString::fromStdString(params.get("GsmApn"))); + }); + list->addItem(roamingToggle); + + // APN settings + ButtonControl *editApnButton = new ButtonControl("APN settings", "EDIT"); + connect(editApnButton, &ButtonControl::clicked, [=]() { + const bool roamingEnabled = params.getBool("GsmRoaming"); + const QString cur_apn = QString::fromStdString(params.get("GsmApn")); + QString apn = InputDialog::getText("Enter APN", this, "leave blank for automatic configuration", false, -1, cur_apn).trimmed(); + + if (apn.isEmpty()) { + params.remove("GsmApn"); + } else { + params.put("GsmApn", apn.toStdString()); + } + wifi->updateGsmSettings(roamingEnabled, apn); + }); + list->addItem(editApnButton); + + // Set initial config + wifi->updateGsmSettings(roamingEnabled, QString::fromStdString(params.get("GsmApn"))); + + main_layout->addWidget(new ScrollView(list, this)); + main_layout->addStretch(1); +} + +void AdvancedNetworking::refresh() { + ipLabel->setText(wifi->ipv4_address); + tetheringToggle->setEnabled(true); + update(); +} + +void AdvancedNetworking::toggleTethering(bool enabled) { + wifi->setTetheringEnabled(enabled); + tetheringToggle->setEnabled(false); +} + +// WifiUI functions + +WifiUI::WifiUI(QWidget *parent, WifiManager* wifi) : QWidget(parent), wifi(wifi) { + main_layout = new QVBoxLayout(this); + main_layout->setContentsMargins(0, 0, 0, 0); + main_layout->setSpacing(0); + + // load imgs + for (const auto &s : {"low", "medium", "high", "full"}) { + QPixmap pix(ASSET_PATH + "/offroad/icon_wifi_strength_" + s + ".svg"); + strengths.push_back(pix.scaledToHeight(68, Qt::SmoothTransformation)); + } + lock = QPixmap(ASSET_PATH + "offroad/icon_lock_closed.svg").scaledToWidth(49, Qt::SmoothTransformation); + checkmark = QPixmap(ASSET_PATH + "offroad/icon_checkmark.svg").scaledToWidth(49, Qt::SmoothTransformation); + circled_slash = QPixmap(ASSET_PATH + "img_circled_slash.svg").scaledToWidth(49, Qt::SmoothTransformation); + + QLabel *scanning = new QLabel("Scanning for networks..."); + scanning->setStyleSheet("font-size: 65px;"); + main_layout->addWidget(scanning, 0, Qt::AlignCenter); + + setStyleSheet(R"( + QScrollBar::handle:vertical { + min-height: 0px; + border-radius: 4px; + background-color: #8A8A8A; + } + #forgetBtn { + font-size: 32px; + font-weight: 600; + color: #292929; + background-color: #BDBDBD; + border-width: 1px solid #828282; + border-radius: 5px; + padding: 40px; + padding-bottom: 16px; + padding-top: 16px; + } + #connecting { + font-size: 32px; + font-weight: 600; + color: white; + border-radius: 0; + padding: 27px; + padding-left: 43px; + padding-right: 43px; + background-color: black; + } + #ssidLabel { + font-size: 55px; + font-weight: 300; + text-align: left; + border: none; + padding-top: 50px; + padding-bottom: 50px; + } + #ssidLabel[disconnected=false] { + font-weight: 500; + } + #ssidLabel:disabled { + color: #696969; + } + )"); +} + +void WifiUI::refresh() { + // TODO: don't rebuild this every time + clearLayout(main_layout); + + if (wifi->seenNetworks.size() == 0) { + QLabel *scanning = new QLabel("Scanning for networks..."); + scanning->setStyleSheet("font-size: 65px;"); + main_layout->addWidget(scanning, 0, Qt::AlignCenter); + return; + } + QList sortedNetworks = wifi->seenNetworks.values(); + std::sort(sortedNetworks.begin(), sortedNetworks.end(), compare_by_strength); + + // add networks + ListWidget *list = new ListWidget(this); + for (Network &network : sortedNetworks) { + QHBoxLayout *hlayout = new QHBoxLayout; + hlayout->setContentsMargins(44, 0, 73, 0); + hlayout->setSpacing(50); + + // Clickable SSID label + ElidedLabel *ssidLabel = new ElidedLabel(network.ssid); + ssidLabel->setObjectName("ssidLabel"); + ssidLabel->setEnabled(network.security_type != SecurityType::UNSUPPORTED); + ssidLabel->setProperty("disconnected", network.connected == ConnectedType::DISCONNECTED); + if (network.connected == ConnectedType::DISCONNECTED) { + QObject::connect(ssidLabel, &ElidedLabel::clicked, this, [=]() { emit connectToNetwork(network); }); + } + hlayout->addWidget(ssidLabel, network.connected == ConnectedType::CONNECTING ? 0 : 1); + + if (network.connected == ConnectedType::CONNECTING) { + QPushButton *connecting = new QPushButton("CONNECTING..."); + connecting->setObjectName("connecting"); + hlayout->addWidget(connecting, 2, Qt::AlignLeft); + } + + // Forget button + if (wifi->isKnownConnection(network.ssid) && !wifi->isTetheringEnabled()) { + QPushButton *forgetBtn = new QPushButton("FORGET"); + forgetBtn->setObjectName("forgetBtn"); + QObject::connect(forgetBtn, &QPushButton::clicked, [=]() { + if (ConfirmationDialog::confirm("Forget Wi-Fi Network \"" + QString::fromUtf8(network.ssid) + "\"?", this)) { + wifi->forgetConnection(network.ssid); + } + }); + hlayout->addWidget(forgetBtn, 0, Qt::AlignRight); + } + + // Status icon + if (network.connected == ConnectedType::CONNECTED) { + QLabel *connectIcon = new QLabel(); + connectIcon->setPixmap(checkmark); + hlayout->addWidget(connectIcon, 0, Qt::AlignRight); + } else if (network.security_type == SecurityType::UNSUPPORTED) { + QLabel *unsupportedIcon = new QLabel(); + unsupportedIcon->setPixmap(circled_slash); + hlayout->addWidget(unsupportedIcon, 0, Qt::AlignRight); + } else if (network.security_type == SecurityType::WPA) { + QLabel *lockIcon = new QLabel(); + lockIcon->setPixmap(lock); + hlayout->addWidget(lockIcon, 0, Qt::AlignRight); + } else { + hlayout->addSpacing(lock.width() + hlayout->spacing()); + } + + // Strength indicator + QLabel *strength = new QLabel(); + strength->setPixmap(strengths[std::clamp((int)round(network.strength / 33.), 0, 3)]); + hlayout->addWidget(strength, 0, Qt::AlignRight); + + list->addItem(hlayout); + } + main_layout->addWidget(list); + main_layout->addStretch(1); +} diff --git a/selfdrive/ui/qt/offroad/networking.h b/selfdrive/ui/qt/offroad/networking.h new file mode 100644 index 00000000000000..037ef82f6798a2 --- /dev/null +++ b/selfdrive/ui/qt/offroad/networking.h @@ -0,0 +1,75 @@ +#pragma once + +#include +#include +#include + +#include "selfdrive/ui/qt/offroad/wifiManager.h" +#include "selfdrive/ui/qt/widgets/input.h" +#include "selfdrive/ui/qt/widgets/ssh_keys.h" +#include "selfdrive/ui/qt/widgets/toggle.h" + +class WifiUI : public QWidget { + Q_OBJECT + +public: + explicit WifiUI(QWidget *parent = 0, WifiManager* wifi = 0); + +private: + WifiManager *wifi = nullptr; + QVBoxLayout* main_layout; + QPixmap lock; + QPixmap checkmark; + QPixmap circled_slash; + QVector strengths; + +signals: + void connectToNetwork(const Network &n); + +public slots: + void refresh(); +}; + +class AdvancedNetworking : public QWidget { + Q_OBJECT +public: + explicit AdvancedNetworking(QWidget* parent = 0, WifiManager* wifi = 0); + +private: + LabelControl* ipLabel; + ToggleControl* tetheringToggle; + WifiManager* wifi = nullptr; + Params params; + +signals: + void backPress(); + +public slots: + void toggleTethering(bool enabled); + void refresh(); +}; + +class Networking : public QFrame { + Q_OBJECT + +public: + explicit Networking(QWidget* parent = 0, bool show_advanced = true); + WifiManager* wifi = nullptr; + +private: + QStackedLayout* main_layout = nullptr; + QWidget* wifiScreen = nullptr; + AdvancedNetworking* an = nullptr; + + WifiUI* wifiWidget; + +protected: + void showEvent(QShowEvent* event) override; + +public slots: + void refresh(); + +private slots: + void connectToNetwork(const Network &n); + void wrongPassword(const QString &ssid); +}; diff --git a/selfdrive/ui/qt/offroad/networkmanager.h b/selfdrive/ui/qt/offroad/networkmanager.h new file mode 100644 index 00000000000000..52d85c16afffb6 --- /dev/null +++ b/selfdrive/ui/qt/offroad/networkmanager.h @@ -0,0 +1,38 @@ +/** + * 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_NONE = 0x00000000; +const int NM_802_11_AP_FLAGS_PRIVACY = 0x00000001; +const int NM_802_11_AP_FLAGS_WPS = 0x00000002; + +// 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; + +const QString NM_DBUS_PATH = "/org/freedesktop/NetworkManager"; +const QString NM_DBUS_PATH_SETTINGS = "/org/freedesktop/NetworkManager/Settings"; + +const QString NM_DBUS_INTERFACE = "org.freedesktop.NetworkManager"; +const QString NM_DBUS_INTERFACE_PROPERTIES = "org.freedesktop.DBus.Properties"; +const QString NM_DBUS_INTERFACE_SETTINGS = "org.freedesktop.NetworkManager.Settings"; +const QString NM_DBUS_INTERFACE_SETTINGS_CONNECTION = "org.freedesktop.NetworkManager.Settings.Connection"; +const QString NM_DBUS_INTERFACE_DEVICE = "org.freedesktop.NetworkManager.Device"; +const QString NM_DBUS_INTERFACE_DEVICE_WIRELESS = "org.freedesktop.NetworkManager.Device.Wireless"; +const QString NM_DBUS_INTERFACE_ACCESS_POINT = "org.freedesktop.NetworkManager.AccessPoint"; +const QString NM_DBUS_INTERFACE_ACTIVE_CONNECTION = "org.freedesktop.NetworkManager.Connection.Active"; +const QString NM_DBUS_INTERFACE_IP4_CONFIG = "org.freedesktop.NetworkManager.IP4Config"; + +const QString NM_DBUS_SERVICE = "org.freedesktop.NetworkManager"; + +const int NM_DEVICE_STATE_ACTIVATED = 100; +const int NM_DEVICE_STATE_NEED_AUTH = 60; +const int NM_DEVICE_TYPE_WIFI = 2; +const int NM_DEVICE_TYPE_MODEM = 8; +const int NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8; +const int DBUS_TIMEOUT = 100; diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc new file mode 100644 index 00000000000000..458464239e5e5d --- /dev/null +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -0,0 +1,213 @@ +#include "selfdrive/ui/qt/offroad/onboarding.h" + +#include +#include +#include +#include +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/common/params.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/widgets/input.h" + +TrainingGuide::TrainingGuide(QWidget *parent) : QFrame(parent) { + setAttribute(Qt::WA_OpaquePaintEvent); +} + +void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) { + if (click_timer.elapsed() < 250) { + return; + } + click_timer.restart(); + + if (boundingRect[currentIndex].contains(e->x(), e->y())) { + if (currentIndex == 9) { + const QRect yes = QRect(692, 842, 492, 148); + Params().putBool("RecordFront", yes.contains(e->x(), e->y())); + } + currentIndex += 1; + } else if (currentIndex == (boundingRect.size() - 2) && boundingRect.last().contains(e->x(), e->y())) { + currentIndex = 0; + } + + if (currentIndex >= (boundingRect.size() - 1)) { + emit completedTraining(); + } else { + image.load(img_path + "step" + QString::number(currentIndex) + ".png"); + update(); + } +} + +void TrainingGuide::showEvent(QShowEvent *event) { + img_path = width() == WIDE_WIDTH ? "../assets/training_wide/" : "../assets/training/"; + boundingRect = width() == WIDE_WIDTH ? boundingRectWide : boundingRectStandard; + + currentIndex = 0; + image.load(img_path + "step0.png"); + click_timer.start(); +} + +void TrainingGuide::paintEvent(QPaintEvent *event) { + QPainter painter(this); + + QRect bg(0, 0, painter.device()->width(), painter.device()->height()); + painter.fillRect(bg, QColor("#000000")); + + QRect rect(image.rect()); + rect.moveCenter(bg.center()); + painter.drawImage(rect.topLeft(), image); + + // progress bar + if (currentIndex > 0 && currentIndex < (boundingRect.size() - 2)) { + const int h = 20; + const int w = (currentIndex / (float)(boundingRect.size() - 2)) * width(); + painter.fillRect(QRect(0, height() - h, w, h), QColor("#465BEA")); + } +} + +void TermsPage::showEvent(QShowEvent *event) { + // late init, building QML widget takes 200ms + if (layout()) { + return; + } + + QVBoxLayout *main_layout = new QVBoxLayout(this); + main_layout->setContentsMargins(45, 35, 45, 45); + main_layout->setSpacing(0); + + QLabel *title = new QLabel("Terms & Conditions"); + title->setStyleSheet("font-size: 90px; font-weight: 600;"); + main_layout->addWidget(title); + + main_layout->addSpacing(30); + + QQuickWidget *text = new QQuickWidget(this); + text->setResizeMode(QQuickWidget::SizeRootObjectToView); + text->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + text->setAttribute(Qt::WA_AlwaysStackOnTop); + text->setClearColor(QColor("#1B1B1B")); + + QString text_view = util::read_file("../assets/offroad/tc.html").c_str(); + text->rootContext()->setContextProperty("text_view", text_view); + + text->setSource(QUrl::fromLocalFile("qt/offroad/text_view.qml")); + + main_layout->addWidget(text, 1); + main_layout->addSpacing(50); + + QObject *obj = (QObject*)text->rootObject(); + QObject::connect(obj, SIGNAL(scroll()), SLOT(enableAccept())); + + QHBoxLayout* buttons = new QHBoxLayout; + buttons->setMargin(0); + buttons->setSpacing(45); + main_layout->addLayout(buttons); + + QPushButton *decline_btn = new QPushButton("Decline"); + buttons->addWidget(decline_btn); + QObject::connect(decline_btn, &QPushButton::clicked, this, &TermsPage::declinedTerms); + + accept_btn = new QPushButton("Scroll to accept"); + accept_btn->setEnabled(false); + accept_btn->setStyleSheet(R"( + QPushButton { + background-color: #465BEA; + } + QPushButton:disabled { + background-color: #4F4F4F; + } + )"); + buttons->addWidget(accept_btn); + QObject::connect(accept_btn, &QPushButton::clicked, this, &TermsPage::acceptedTerms); +} + +void TermsPage::enableAccept() { + accept_btn->setText("Agree"); + accept_btn->setEnabled(true); +} + +void DeclinePage::showEvent(QShowEvent *event) { + if (layout()) { + return; + } + + QVBoxLayout *main_layout = new QVBoxLayout(this); + main_layout->setMargin(45); + main_layout->setSpacing(40); + + QLabel *text = new QLabel(this); + text->setText("You must accept the Terms and Conditions in order to use openpilot."); + text->setStyleSheet(R"(font-size: 80px; font-weight: 300; margin: 200px;)"); + text->setWordWrap(true); + main_layout->addWidget(text, 0, Qt::AlignCenter); + + QHBoxLayout* buttons = new QHBoxLayout; + buttons->setSpacing(45); + main_layout->addLayout(buttons); + + QPushButton *back_btn = new QPushButton("Back"); + buttons->addWidget(back_btn); + + QObject::connect(back_btn, &QPushButton::clicked, this, &DeclinePage::getBack); + + QPushButton *uninstall_btn = new QPushButton(QString("Decline, uninstall %1").arg(getBrand())); + uninstall_btn->setStyleSheet("background-color: #B73D3D"); + buttons->addWidget(uninstall_btn); + QObject::connect(uninstall_btn, &QPushButton::clicked, [=]() { + Params().putBool("DoUninstall", true); + }); +} + +void OnboardingWindow::updateActiveScreen() { + if (!accepted_terms) { + setCurrentIndex(0); + } else if (!training_done && !params.getBool("Passive")) { + setCurrentIndex(1); + } else { + emit onboardingDone(); + } +} + +OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) { + std::string current_terms_version = params.get("TermsVersion"); + std::string current_training_version = params.get("TrainingVersion"); + accepted_terms = params.get("HasAcceptedTerms") == current_terms_version; + training_done = params.get("CompletedTrainingVersion") == current_training_version; + + TermsPage* terms = new TermsPage(this); + addWidget(terms); + connect(terms, &TermsPage::acceptedTerms, [=]() { + Params().put("HasAcceptedTerms", current_terms_version); + accepted_terms = true; + updateActiveScreen(); + }); + connect(terms, &TermsPage::declinedTerms, [=]() { setCurrentIndex(2); }); + + TrainingGuide* tr = new TrainingGuide(this); + addWidget(tr); + connect(tr, &TrainingGuide::completedTraining, [=]() { + training_done = true; + Params().put("CompletedTrainingVersion", current_training_version); + updateActiveScreen(); + }); + + DeclinePage* declinePage = new DeclinePage(this); + addWidget(declinePage); + connect(declinePage, &DeclinePage::getBack, [=]() { updateActiveScreen(); }); + + setStyleSheet(R"( + * { + color: white; + background-color: black; + } + QPushButton { + height: 160px; + font-size: 55px; + font-weight: 400; + border-radius: 10px; + background-color: #4F4F4F; + } + )"); + updateActiveScreen(); +} diff --git a/selfdrive/ui/qt/offroad/onboarding.h b/selfdrive/ui/qt/offroad/onboarding.h new file mode 100644 index 00000000000000..9424c07d193c70 --- /dev/null +++ b/selfdrive/ui/qt/offroad/onboarding.h @@ -0,0 +1,133 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/ui/qt/qt_window.h" + +class TrainingGuide : public QFrame { + Q_OBJECT + +public: + explicit TrainingGuide(QWidget *parent = 0); + +private: + void showEvent(QShowEvent *event) override; + void paintEvent(QPaintEvent *event) override; + void mouseReleaseEvent(QMouseEvent* e) override; + + QImage image; + int currentIndex = 0; + + // Bounding boxes for each training guide step + const QRect continueBtnStandard = {1610, 0, 310, 1080}; + QVector boundingRectStandard { + QRect(650, 710, 720, 190), + continueBtnStandard, + continueBtnStandard, + QRect(1442, 565, 230, 310), + QRect(1515, 562, 133, 60), + continueBtnStandard, + QRect(1580, 630, 215, 130), + QRect(1210, 0, 485, 590), + QRect(1460, 400, 375, 210), + QRect(166, 842, 1019, 148), + QRect(1460, 210, 300, 310), + continueBtnStandard, + QRect(1375, 80, 545, 1000), + continueBtnStandard, + QRect(1610, 130, 280, 800), + QRect(1385, 485, 400, 270), + continueBtnStandard, + continueBtnStandard, + QRect(1036, 769, 718, 189), + QRect(201, 769, 718, 189), + }; + + const QRect continueBtnWide = {1850, 0, 310, 1080}; + QVector boundingRectWide { + QRect(654, 721, 718, 189), + continueBtnWide, + continueBtnWide, + QRect(1690, 570, 165, 300), + QRect(1690, 560, 133, 60), + continueBtnWide, + QRect(1820, 630, 180, 155), + QRect(1360, 0, 460, 620), + QRect(1570, 400, 375, 215), + QRect(167, 842, 1018, 148), + QRect(1610, 210, 295, 310), + continueBtnWide, + QRect(1555, 90, 610, 990), + continueBtnWide, + QRect(1600, 140, 280, 790), + QRect(1385, 490, 750, 270), + continueBtnWide, + continueBtnWide, + QRect(1138, 755, 718, 189), + QRect(303, 755, 718, 189), + }; + + QString img_path; + QVector boundingRect; + QElapsedTimer click_timer; + +signals: + void completedTraining(); +}; + + +class TermsPage : public QFrame { + Q_OBJECT + +public: + explicit TermsPage(QWidget *parent = 0) : QFrame(parent) {}; + +public slots: + void enableAccept(); + +private: + void showEvent(QShowEvent *event) override; + + QPushButton *accept_btn; + +signals: + void acceptedTerms(); + void declinedTerms(); +}; + +class DeclinePage : public QFrame { + Q_OBJECT + +public: + explicit DeclinePage(QWidget *parent = 0) : QFrame(parent) {}; + +private: + void showEvent(QShowEvent *event) override; + +signals: + void getBack(); +}; + +class OnboardingWindow : public QStackedWidget { + Q_OBJECT + +public: + explicit OnboardingWindow(QWidget *parent = 0); + inline void showTrainingGuide() { setCurrentIndex(1); } + inline bool completed() const { return accepted_terms && training_done; } + +private: + void updateActiveScreen(); + + Params params; + bool accepted_terms = false, training_done = false; + +signals: + void onboardingDone(); +}; diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc new file mode 100644 index 00000000000000..c01da2140c2b12 --- /dev/null +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -0,0 +1,432 @@ +#include "selfdrive/ui/qt/offroad/settings.h" + +#include +#include +#include + +#include + +#ifndef QCOM +#include "selfdrive/ui/qt/offroad/networking.h" +#endif + +#ifdef ENABLE_MAPS +#include "selfdrive/ui/qt/maps/map_settings.h" +#endif + +#include "selfdrive/common/params.h" +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/widgets/controls.h" +#include "selfdrive/ui/qt/widgets/input.h" +#include "selfdrive/ui/qt/widgets/scrollview.h" +#include "selfdrive/ui/qt/widgets/ssh_keys.h" +#include "selfdrive/ui/qt/widgets/toggle.h" +#include "selfdrive/ui/ui.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/qt_window.h" + +TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { + // param, title, desc, icon + std::vector> toggles{ + { + "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", + }, + { + "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", + }, + { + "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", + }, + { + "IsMetric", + "Use Metric System", + "Display speed in km/h instead of mph.", + "../assets/offroad/icon_metric.png", + }, + { + "CommunityFeaturesToggle", + "Enable Community Features", + "Use features, such as community supported hardware, 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. Be extra cautious when using these features", + "../assets/offroad/icon_shell.png", + }, + { + "RecordFront", + "Record and Upload Driver Camera", + "Upload data from the driver facing camera and help improve the driver monitoring algorithm.", + "../assets/offroad/icon_monitoring.png", + }, + { + "EndToEndToggle", + "\U0001f96c Disable use of lanelines (Alpha) \U0001f96c", + "In this mode openpilot will ignore lanelines and just drive how it thinks a human would.", + "../assets/offroad/icon_road.png", + }, +#ifdef ENABLE_MAPS + { + "NavSettingTime24h", + "Show ETA in 24h format", + "Use 24h format instead of am/pm", + "../assets/offroad/icon_metric.png", + }, +#endif + + }; + + Params params; + + if (params.getBool("DisableRadar_Allow")) { + toggles.push_back({ + "DisableRadar", + "openpilot Longitudinal Control", + "openpilot will disable the car's radar and will take over control of gas and brakes. Warning: this disables AEB!", + "../assets/offroad/icon_speed_limit.png", + }); + } + + for (auto &[param, title, desc, icon] : toggles) { + auto toggle = new ParamControl(param, title, desc, icon, this); + bool locked = params.getBool((param + "Lock").toStdString()); + toggle->setEnabled(!locked); + if (!locked) { + connect(parent, &SettingsWindow::offroadTransition, toggle, &ParamControl::setEnabled); + } + addItem(toggle); + } +} + +DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) { + setSpacing(50); + addItem(new LabelControl("Dongle ID", getDongleId().value_or("N/A"))); + addItem(new LabelControl("Serial", params.get("HardwareSerial").c_str())); + + // offroad-only buttons + + auto dcamBtn = new ButtonControl("Driver Camera", "PREVIEW", + "Preview the driver facing camera to help optimize device mounting position for best driver monitoring experience. (vehicle must be off)"); + connect(dcamBtn, &ButtonControl::clicked, [=]() { emit showDriverView(); }); + addItem(dcamBtn); + + auto resetCalibBtn = new ButtonControl("Reset Calibration", "RESET", " "); + connect(resetCalibBtn, &ButtonControl::showDescription, this, &DevicePanel::updateCalibDescription); + connect(resetCalibBtn, &ButtonControl::clicked, [&]() { + if (ConfirmationDialog::confirm("Are you sure you want to reset calibration?", this)) { + params.remove("CalibrationParams"); + } + }); + addItem(resetCalibBtn); + + if (!params.getBool("Passive")) { + auto retrainingBtn = new ButtonControl("Review Training Guide", "REVIEW", "Review the rules, features, and limitations of openpilot"); + connect(retrainingBtn, &ButtonControl::clicked, [=]() { + if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?", this)) { + emit reviewTrainingGuide(); + } + }); + addItem(retrainingBtn); + } + + if (Hardware::TICI()) { + auto regulatoryBtn = new ButtonControl("Regulatory", "VIEW", ""); + connect(regulatoryBtn, &ButtonControl::clicked, [=]() { + const std::string txt = util::read_file("../assets/offroad/fcc.html"); + RichTextDialog::alert(QString::fromStdString(txt), this); + }); + addItem(regulatoryBtn); + } + + QObject::connect(parent, &SettingsWindow::offroadTransition, [=](bool offroad) { + for (auto btn : findChildren()) { + btn->setEnabled(offroad); + } + }); + + // power buttons + QHBoxLayout *power_layout = new QHBoxLayout(); + power_layout->setSpacing(30); + + QPushButton *reboot_btn = new QPushButton("Reboot"); + reboot_btn->setObjectName("reboot_btn"); + power_layout->addWidget(reboot_btn); + QObject::connect(reboot_btn, &QPushButton::clicked, this, &DevicePanel::reboot); + + QPushButton *poweroff_btn = new QPushButton("Power Off"); + poweroff_btn->setObjectName("poweroff_btn"); + power_layout->addWidget(poweroff_btn); + QObject::connect(poweroff_btn, &QPushButton::clicked, this, &DevicePanel::poweroff); + + setStyleSheet(R"( + #reboot_btn { height: 120px; border-radius: 15px; background-color: #393939; } + #reboot_btn:pressed { background-color: #4a4a4a; } + #poweroff_btn { height: 120px; border-radius: 15px; background-color: #E22C2C; } + #poweroff_btn:pressed { background-color: #FF2424; } + )"); + addItem(power_layout); +} + +void DevicePanel::updateCalibDescription() { + QString desc = + "openpilot requires the device to be mounted within 4° left or right and " + "within 5° up or down. openpilot is continuously calibrating, resetting is rarely required."; + std::string calib_bytes = Params().get("CalibrationParams"); + if (!calib_bytes.empty()) { + try { + AlignedBuffer aligned_buf; + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(calib_bytes.data(), calib_bytes.size())); + auto calib = cmsg.getRoot().getLiveCalibration(); + if (calib.getCalStatus() != 0) { + double pitch = calib.getRpyCalib()[1] * (180 / M_PI); + double yaw = calib.getRpyCalib()[2] * (180 / M_PI); + desc += QString(" Your device is pointed %1° %2 and %3° %4.") + .arg(QString::number(std::abs(pitch), 'g', 1), pitch > 0 ? "up" : "down", + QString::number(std::abs(yaw), 'g', 1), yaw > 0 ? "right" : "left"); + } + } catch (kj::Exception) { + qInfo() << "invalid CalibrationParams"; + } + } + qobject_cast(sender())->setDescription(desc); +} + +void DevicePanel::reboot() { + if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) { + if (ConfirmationDialog::confirm("Are you sure you want to reboot?", this)) { + // Check engaged again in case it changed while the dialog was open + if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) { + Params().putBool("DoReboot", true); + } + } + } else { + ConfirmationDialog::alert("Disengage to Reboot", this); + } +} + +void DevicePanel::poweroff() { + if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) { + if (ConfirmationDialog::confirm("Are you sure you want to power off?", this)) { + // Check engaged again in case it changed while the dialog was open + if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) { + Params().putBool("DoShutdown", true); + } + } + } else { + ConfirmationDialog::alert("Disengage to Power Off", this); + } +} + +SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) { + gitBranchLbl = new LabelControl("Git Branch"); + gitCommitLbl = new LabelControl("Git Commit"); + osVersionLbl = new LabelControl("OS Version"); + versionLbl = new LabelControl("Version", "", QString::fromStdString(params.get("ReleaseNotes")).trimmed()); + lastUpdateLbl = new LabelControl("Last Update Check", "", "The last time openpilot successfully checked for an update. The updater only runs while the car is off."); + updateBtn = new ButtonControl("Check for Update", ""); + connect(updateBtn, &ButtonControl::clicked, [=]() { + if (params.getBool("IsOffroad")) { + fs_watch->addPath(QString::fromStdString(params.getParamPath("LastUpdateTime"))); + fs_watch->addPath(QString::fromStdString(params.getParamPath("UpdateFailedCount"))); + updateBtn->setText("CHECKING"); + updateBtn->setEnabled(false); + } + std::system("pkill -1 -f selfdrive.updated"); + }); + + + auto uninstallBtn = new ButtonControl("Uninstall " + getBrand(), "UNINSTALL"); + connect(uninstallBtn, &ButtonControl::clicked, [&]() { + if (ConfirmationDialog::confirm("Are you sure you want to uninstall?", this)) { + params.putBool("DoUninstall", true); + } + }); + connect(parent, SIGNAL(offroadTransition(bool)), uninstallBtn, SLOT(setEnabled(bool))); + + QWidget *widgets[] = {versionLbl, lastUpdateLbl, updateBtn, gitBranchLbl, gitCommitLbl, osVersionLbl, uninstallBtn}; + for (QWidget* w : widgets) { + addItem(w); + } + + fs_watch = new QFileSystemWatcher(this); + QObject::connect(fs_watch, &QFileSystemWatcher::fileChanged, [=](const QString path) { + if (path.contains("UpdateFailedCount") && std::atoi(params.get("UpdateFailedCount").c_str()) > 0) { + lastUpdateLbl->setText("failed to fetch update"); + updateBtn->setText("CHECK"); + updateBtn->setEnabled(true); + } else if (path.contains("LastUpdateTime")) { + updateLabels(); + } + }); +} + +void SoftwarePanel::showEvent(QShowEvent *event) { + updateLabels(); +} + +void SoftwarePanel::updateLabels() { + QString lastUpdate = ""; + auto tm = params.get("LastUpdateTime"); + if (!tm.empty()) { + lastUpdate = timeAgo(QDateTime::fromString(QString::fromStdString(tm + "Z"), Qt::ISODate)); + } + + versionLbl->setText(getBrandVersion()); + lastUpdateLbl->setText(lastUpdate); + updateBtn->setText("CHECK"); + updateBtn->setEnabled(true); + gitBranchLbl->setText(QString::fromStdString(params.get("GitBranch"))); + gitCommitLbl->setText(QString::fromStdString(params.get("GitCommit")).left(10)); + osVersionLbl->setText(QString::fromStdString(Hardware::get_os_version()).trimmed()); +} + +QWidget * network_panel(QWidget * parent) { +#ifdef QCOM + QWidget *w = new QWidget(parent); + QVBoxLayout *layout = new QVBoxLayout(w); + layout->setContentsMargins(50, 0, 50, 0); + + ListWidget *list = new ListWidget(); + list->setSpacing(30); + // wifi + tethering buttons + auto wifiBtn = new ButtonControl("Wi-Fi Settings", "OPEN"); + QObject::connect(wifiBtn, &ButtonControl::clicked, [=]() { HardwareEon::launch_wifi(); }); + list->addItem(wifiBtn); + + auto tetheringBtn = new ButtonControl("Tethering Settings", "OPEN"); + QObject::connect(tetheringBtn, &ButtonControl::clicked, [=]() { HardwareEon::launch_tethering(); }); + list->addItem(tetheringBtn); + + // SSH key management + list->addItem(new SshToggle()); + list->addItem(new SshControl()); + + layout->addWidget(list); + layout->addStretch(1); +#else + Networking *w = new Networking(parent); +#endif + return w; +} + +void SettingsWindow::showEvent(QShowEvent *event) { + panel_widget->setCurrentIndex(0); + nav_btns->buttons()[0]->setChecked(true); +} + +SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { + QHBoxLayout *main_layout = new QHBoxLayout(this); + + // setup two main layouts + sidebar_widget = new QWidget; + sidebar_widget->setFixedWidth(500); + QVBoxLayout *sidebar_layout = new QVBoxLayout(sidebar_widget); + sidebar_layout->setContentsMargins(50, 50, 100, 50); + main_layout->addWidget(sidebar_widget); + + panel_widget = new QStackedWidget(); + panel_widget->setObjectName("panel_widget"); + panel_widget->setContentsMargins(25, 25, 25, 25); + main_layout->addWidget(panel_widget); + + // close button + QPushButton *close_btn = new QPushButton("×"); + close_btn->setObjectName("close_btn"); + close_btn->setFixedSize(200, 200); + sidebar_layout->addSpacing(45); + sidebar_layout->addWidget(close_btn, 0, Qt::AlignCenter); + QObject::connect(close_btn, &QPushButton::clicked, this, &SettingsWindow::closeSettings); + + // setup panels + DevicePanel *device = new DevicePanel(this); + QObject::connect(device, &DevicePanel::reviewTrainingGuide, this, &SettingsWindow::reviewTrainingGuide); + QObject::connect(device, &DevicePanel::showDriverView, this, &SettingsWindow::showDriverView); + + QList> panels = { + {"Device", device}, + {"Network", network_panel(this)}, + {"Toggles", new TogglesPanel(this)}, + {"Software", new SoftwarePanel(this)}, + }; + +#ifdef ENABLE_MAPS + auto map_panel = new MapPanel(this); + panels.push_back({"Navigation", map_panel}); + QObject::connect(map_panel, &MapPanel::closeSettings, this, &SettingsWindow::closeSettings); +#endif + + nav_btns = new QButtonGroup(this); + for (auto &[name, panel] : panels) { + QPushButton *btn = new QPushButton(name); + btn->setCheckable(true); + btn->setChecked(nav_btns->buttons().size() == 0); + btn->setProperty("type", "menu"); + nav_btns->addButton(btn); + sidebar_layout->addWidget(btn, 0, Qt::AlignRight); + + const int lr_margin = name != "Network" ? 25 : 0; // Network panel handles its own margins + panel->setContentsMargins(lr_margin, 0, lr_margin, 0); + + ScrollView *panel_frame = new ScrollView(panel, this); + panel_widget->addWidget(panel_frame); + + QObject::connect(btn, &QPushButton::clicked, [=, w = panel_frame]() { + btn->setChecked(true); + panel_widget->setCurrentWidget(w); + }); + } + + const int padding = panels.size() > 3 ? 25 : 35; + setStyleSheet(QString(R"( + * { + color: white; + font-size: 50px; + } + SettingsWindow { + background-color: black; + } + #panel_widget{ + border-radius: 30px; + background-color: #292929; + } + QPushButton#close_btn { + font-size: 140px; + padding-bottom: 20px; + font-weight: bold; + border 1px grey solid; + border-radius: 100px; + background-color: #292929; + font-weight: 400; + } + QPushButton#close_btn:pressed { + background-color: #3B3B3B; + } + QPushButton[type="menu"] { + color: grey; + border: none; + background: none; + font-size: 65px; + font-weight: 500; + padding-top: %1px; + padding-bottom: %1px; + } + QPushButton[type="menu"]:checked { + color: white; + } + QPushButton[type="menu"]:pressed { + color: #ADADAD; + } + )").arg(padding)); +} + +void SettingsWindow::hideEvent(QHideEvent *event) { +#ifdef QCOM + HardwareEon::close_activities(); +#endif +} diff --git a/selfdrive/ui/qt/offroad/settings.h b/selfdrive/ui/qt/offroad/settings.h new file mode 100644 index 00000000000000..7fc5a8581f6e1e --- /dev/null +++ b/selfdrive/ui/qt/offroad/settings.h @@ -0,0 +1,79 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + + +#include "selfdrive/ui/qt/widgets/controls.h" + +// ********** settings window + top-level panels ********** +class SettingsWindow : public QFrame { + Q_OBJECT + +public: + explicit SettingsWindow(QWidget *parent = 0); + +protected: + void hideEvent(QHideEvent *event) override; + void showEvent(QShowEvent *event) override; + +signals: + void closeSettings(); + void offroadTransition(bool offroad); + void reviewTrainingGuide(); + void showDriverView(); + +private: + QPushButton *sidebar_alert_widget; + QWidget *sidebar_widget; + QButtonGroup *nav_btns; + QStackedWidget *panel_widget; +}; + +class DevicePanel : public ListWidget { + Q_OBJECT +public: + explicit DevicePanel(SettingsWindow *parent); +signals: + void reviewTrainingGuide(); + void showDriverView(); + +private slots: + void poweroff(); + void reboot(); + void updateCalibDescription(); + +private: + Params params; +}; + +class TogglesPanel : public ListWidget { + Q_OBJECT +public: + explicit TogglesPanel(SettingsWindow *parent); +}; + +class SoftwarePanel : public ListWidget { + Q_OBJECT +public: + explicit SoftwarePanel(QWidget* parent = nullptr); + +private: + void showEvent(QShowEvent *event) override; + void updateLabels(); + + LabelControl *gitBranchLbl; + LabelControl *gitCommitLbl; + LabelControl *osVersionLbl; + LabelControl *versionLbl; + LabelControl *lastUpdateLbl; + ButtonControl *updateBtn; + + Params params; + QFileSystemWatcher *fs_watch; +}; diff --git a/selfdrive/ui/qt/offroad/text_view.qml b/selfdrive/ui/qt/offroad/text_view.qml new file mode 100644 index 00000000000000..10b423bacbd09b --- /dev/null +++ b/selfdrive/ui/qt/offroad/text_view.qml @@ -0,0 +1,47 @@ +import QtQuick 2.0 + +Item { + id: root + signal scroll() + + Flickable { + id: flickArea + objectName: "flickArea" + anchors.fill: parent + contentHeight: helpText.height + contentWidth: width - (leftMargin + rightMargin) + bottomMargin: 50 + topMargin: 50 + rightMargin: 50 + leftMargin: 50 + flickableDirection: Flickable.VerticalFlick + flickDeceleration: 7500.0 + maximumFlickVelocity: 10000.0 + pixelAligned: true + + onAtYEndChanged: root.scroll() + + Text { + id: helpText + width: flickArea.contentWidth + font.family: "Inter" + font.weight: "Light" + font.pixelSize: 50 + textFormat: Text.RichText + color: "#C9C9C9" + wrapMode: Text.Wrap + text: text_view + } + } + + Rectangle { + id: scrollbar + anchors.right: flickArea.right + anchors.rightMargin: 20 + y: flickArea.topMargin + flickArea.visibleArea.yPosition * (flickArea.height - flickArea.bottomMargin - flickArea.topMargin) + width: 12 + radius: 6 + height: flickArea.visibleArea.heightRatio * (flickArea.height - flickArea.bottomMargin - flickArea.topMargin) + color: "#808080" + } +} diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc new file mode 100644 index 00000000000000..09701739299ca2 --- /dev/null +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -0,0 +1,566 @@ +#include "selfdrive/ui/qt/offroad/wifiManager.h" + +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/ui/qt/util.h" + +template +T get_response(const QDBusMessage &response) { + QVariant first = response.arguments().at(0); + QDBusVariant dbvFirst = first.value(); + QVariant vFirst = dbvFirst.variant(); + if (vFirst.canConvert()) { + return vFirst.value(); + } else { + LOGE("Variant unpacking failure"); + return T(); + } +} + +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(QWidget* parent) : QWidget(parent) { + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + connecting_to_network = ""; + + // Set tethering ssid as "weedle" + first 4 characters of a dongle id + tethering_ssid = "weedle"; + if (auto dongle_id = getDongleId()) { + tethering_ssid += "-" + dongle_id->left(4); + } + + adapter = getAdapter(); + if (!adapter.isEmpty()) { + setup(); + } else { + bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeviceAdded", this, SLOT(deviceAdded(QDBusObjectPath))); + } + + QTimer* timer = new QTimer(this); + QObject::connect(timer, &QTimer::timeout, this, [=]() { + if (!adapter.isEmpty() && this->isVisible()) { + requestScan(); + } + }); + timer->start(5000); +} + +void WifiManager::setup() { + QDBusInterface nm(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE, bus); + bus.connect(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE, "StateChanged", this, SLOT(stateChange(unsigned int, unsigned int, unsigned int))); + bus.connect(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, "PropertiesChanged", this, SLOT(propertyChange(QString, QVariantMap, QStringList))); + + bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "ConnectionRemoved", this, SLOT(connectionRemoved(QDBusObjectPath))); + bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "NewConnection", this, SLOT(newConnection(QDBusObjectPath))); + + QDBusInterface device_props(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, bus); + device_props.setTimeout(DBUS_TIMEOUT); + QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_DEVICE, "State"); + raw_adapter_state = get_response(response); + + initActiveAp(); + initConnections(); + requestScan(); +} + +void WifiManager::refreshNetworks() { + if (adapter.isEmpty()) { + return; + } + seenNetworks.clear(); + ipv4_address = get_ipv4_address(); + + QDBusInterface nm(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE_WIRELESS, bus); + nm.setTimeout(DBUS_TIMEOUT); + + const QDBusReply> &response = nm.call("GetAllAccessPoints"); + for (const QDBusObjectPath &path : response.value()) { + const QByteArray &ssid = get_property(path.path(), "Ssid"); + unsigned int strength = get_ap_strength(path.path()); + if (ssid.isEmpty() || (seenNetworks.contains(ssid) && + strength <= seenNetworks.value(ssid).strength)) { + continue; + } + SecurityType security = getSecurityType(path.path()); + ConnectedType ctype; + QString activeSsid = (activeAp != "" && activeAp != "/") ? get_property(activeAp, "Ssid") : ""; + if (ssid != activeSsid) { + ctype = ConnectedType::DISCONNECTED; + } else { + if (ssid == connecting_to_network) { + ctype = ConnectedType::CONNECTING; + } else { + ctype = ConnectedType::CONNECTED; + } + } + Network network = {ssid, strength, ctype, security}; + seenNetworks[ssid] = network; + } +} + +QString WifiManager::get_ipv4_address() { + if (raw_adapter_state != NM_DEVICE_STATE_ACTIVATED) { + return ""; + } + QVector conns = get_active_connections(); + for (auto &p : conns) { + QDBusInterface nm(NM_DBUS_SERVICE, p.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); + nm.setTimeout(DBUS_TIMEOUT); + + QDBusObjectPath pth = get_response(nm.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Ip4Config")); + QString ip4config = pth.path(); + + QString type = get_response(nm.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type")); + + if (type == "802-11-wireless") { + QDBusInterface nm2(NM_DBUS_SERVICE, ip4config, NM_DBUS_INTERFACE_PROPERTIES, bus); + nm2.setTimeout(DBUS_TIMEOUT); + + const QDBusArgument &arr = get_response(nm2.call("Get", NM_DBUS_INTERFACE_IP4_CONFIG, "AddressData")); + QMap pth2; + arr.beginArray(); + while (!arr.atEnd()) { + arr >> pth2; + QString ipv4 = pth2.value("address").value(); + arr.endArray(); + return ipv4; + } + arr.endArray(); + } + } + return ""; +} + +SecurityType WifiManager::getSecurityType(const 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 == NM_802_11_AP_FLAGS_NONE) || ((sflag & NM_802_11_AP_FLAGS_WPS) && !(wpa_props & supports_wpa))) { + 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 { + LOGW("Unsupported network! sflag: %d, wpaflag: %d, rsnflag: %d", sflag, wpaflag, rsnflag); + return SecurityType::UNSUPPORTED; + } +} + +void WifiManager::connect(const Network &n) { + return connect(n, "", ""); +} + +void WifiManager::connect(const Network &n, const QString &password) { + return connect(n, "", password); +} + +void WifiManager::connect(const Network &n, const QString &username, const QString &password) { + connecting_to_network = n.ssid; + // disconnect(); + forgetConnection(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(const QByteArray &ssid, const QString &username, const 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["ipv4"]["dns-priority"] = 600; + connection["ipv6"]["method"] = "ignore"; + + QDBusInterface nm_settings(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, bus); + nm_settings.setTimeout(DBUS_TIMEOUT); + + nm_settings.call("AddConnection", QVariant::fromValue(connection)); +} + +void WifiManager::deactivateConnectionBySsid(const QString &ssid) { + for (QDBusObjectPath active_connection_raw : get_active_connections()) { + QString active_connection = active_connection_raw.path(); + QDBusInterface nm(NM_DBUS_SERVICE, active_connection, NM_DBUS_INTERFACE_PROPERTIES, bus); + nm.setTimeout(DBUS_TIMEOUT); + + QDBusObjectPath pth = get_response(nm.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "SpecificObject")); + if (pth.path() != "" && pth.path() != "/") { + QString Ssid = get_property(pth.path(), "Ssid"); + if (Ssid == ssid) { + deactivateConnection(active_connection_raw); + } + } + } +} + +void WifiManager::deactivateConnection(const QDBusObjectPath &path) { + QDBusInterface nm2(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, bus); + nm2.setTimeout(DBUS_TIMEOUT); + nm2.call("DeactivateConnection", QVariant::fromValue(path)); +} + +QVector WifiManager::get_active_connections() { + QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE_PROPERTIES, bus); + nm.setTimeout(DBUS_TIMEOUT); + + QDBusMessage response = nm.call("Get", NM_DBUS_INTERFACE, "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; +} + +bool WifiManager::isKnownConnection(const QString &ssid) { + return !getConnectionPath(ssid).path().isEmpty(); +} + +void WifiManager::forgetConnection(const QString &ssid) { + const QDBusObjectPath &path = getConnectionPath(ssid); + if (!path.path().isEmpty()) { + QDBusInterface nm2(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); + nm2.call("Delete"); + } +} + +uint WifiManager::getAdapterType(const QDBusObjectPath &path) { + QDBusInterface device_props(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); + device_props.setTimeout(DBUS_TIMEOUT); + return get_response(device_props.call("Get", NM_DBUS_INTERFACE_DEVICE, "DeviceType")); +} + +bool WifiManager::isWirelessAdapter(const QDBusObjectPath &path) { + return getAdapterType(path) == NM_DEVICE_TYPE_WIFI; +} + +void WifiManager::requestScan() { + QDBusInterface nm(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE_WIRELESS, bus); + nm.setTimeout(DBUS_TIMEOUT); + nm.call("RequestScan", QVariantMap()); +} + +uint WifiManager::get_wifi_device_state() { + QDBusInterface device_props(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, bus); + device_props.setTimeout(DBUS_TIMEOUT); + + QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_DEVICE, "State"); + uint resp = get_response(response); + return resp; +} + +QByteArray WifiManager::get_property(const QString &network_path , const QString &property) { + QDBusInterface device_props(NM_DBUS_SERVICE, network_path, NM_DBUS_INTERFACE_PROPERTIES, bus); + device_props.setTimeout(DBUS_TIMEOUT); + + QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_ACCESS_POINT, property); + return get_response(response); +} + +unsigned int WifiManager::get_ap_strength(const QString &network_path) { + QDBusInterface device_props(NM_DBUS_SERVICE, network_path, NM_DBUS_INTERFACE_PROPERTIES, bus); + device_props.setTimeout(DBUS_TIMEOUT); + + QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_ACCESS_POINT, "Strength"); + return get_response(response); +} + +QString WifiManager::getAdapter(const uint adapter_type) { + QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, bus); + nm.setTimeout(DBUS_TIMEOUT); + + const QDBusReply> &response = nm.call("GetDevices"); + for (const QDBusObjectPath &path : response.value()) { + if (getAdapterType(path) == adapter_type) { + return path.path(); + } + } + return ""; +} + +void WifiManager::stateChange(unsigned int new_state, unsigned int previous_state, unsigned int change_reason) { + raw_adapter_state = new_state; + if (new_state == NM_DEVICE_STATE_NEED_AUTH && change_reason == NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT && !connecting_to_network.isEmpty()) { + forgetConnection(connecting_to_network); + emit wrongPassword(connecting_to_network); + } else if (new_state == NM_DEVICE_STATE_ACTIVATED) { + connecting_to_network = ""; + if (this->isVisible()) { + refreshNetworks(); + emit refreshSignal(); + } + } +} + +// https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.Device.Wireless.html +void WifiManager::propertyChange(const QString &interface, const QVariantMap &props, const QStringList &invalidated_props) { + if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("LastScan")) { + if (this->isVisible() || firstScan) { + refreshNetworks(); + emit refreshSignal(); + firstScan = false; + } + } else if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("ActiveAccessPoint")) { + const QDBusObjectPath &path = props.value("ActiveAccessPoint").value(); + activeAp = path.path(); + } +} + +void WifiManager::deviceAdded(const QDBusObjectPath &path) { + if (isWirelessAdapter(path) && (adapter.isEmpty() || adapter == "/")) { + adapter = path.path(); + setup(); + } +} + +void WifiManager::connectionRemoved(const QDBusObjectPath &path) { + knownConnections.remove(path); +} + +void WifiManager::newConnection(const QDBusObjectPath &path) { + const Connection &settings = getConnectionSettings(path); + if (settings.value("connection").value("type") == "802-11-wireless") { + knownConnections[path] = settings.value("802-11-wireless").value("ssid").toString(); + if (knownConnections[path] != tethering_ssid) { + activateWifiConnection(knownConnections[path]); + } + } +} + +void WifiManager::disconnect() { + if (activeAp != "" && activeAp != "/") { + deactivateConnectionBySsid(get_property(activeAp, "Ssid")); + } +} + +QDBusObjectPath WifiManager::getConnectionPath(const QString &ssid) { + for (const QString &conn_ssid : knownConnections) { + if (ssid == conn_ssid) { + return knownConnections.key(conn_ssid); + } + } + return QDBusObjectPath(); +} + +Connection WifiManager::getConnectionSettings(const QDBusObjectPath &path) { + QDBusInterface nm(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); + nm.setTimeout(DBUS_TIMEOUT); + return QDBusReply(nm.call("GetSettings")).value(); +} + +void WifiManager::initConnections() { + QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, bus); + nm.setTimeout(DBUS_TIMEOUT); + + const QDBusReply> response = nm.call("ListConnections"); + for (const QDBusObjectPath &path : response.value()) { + const Connection &settings = getConnectionSettings(path); + if (settings.value("connection").value("type") == "802-11-wireless") { + knownConnections[path] = settings.value("802-11-wireless").value("ssid").toString(); + } else if (path.path() != "/") { + lteConnectionPath = path; + } + } +} + +void WifiManager::activateWifiConnection(const QString &ssid) { + const QDBusObjectPath &path = getConnectionPath(ssid); + if (!path.path().isEmpty()) { + connecting_to_network = ssid; + QDBusInterface nm3(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, bus); + nm3.setTimeout(DBUS_TIMEOUT); + nm3.call("ActivateConnection", QVariant::fromValue(path), QVariant::fromValue(QDBusObjectPath(adapter)), QVariant::fromValue(QDBusObjectPath("/"))); + } +} + +void WifiManager::activateModemConnection(const QDBusObjectPath &path) { + QString modem = getAdapter(NM_DEVICE_TYPE_MODEM); + if (!path.path().isEmpty() && !modem.isEmpty()) { + QDBusInterface nm3(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, bus); + nm3.setTimeout(DBUS_TIMEOUT); + nm3.call("ActivateConnection", QVariant::fromValue(path), QVariant::fromValue(QDBusObjectPath(modem)), QVariant::fromValue(QDBusObjectPath("/"))); + } +} + +// function matches tici/hardware.py +NetworkType WifiManager::currentNetworkType() { + QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE_PROPERTIES, bus); + nm.setTimeout(DBUS_TIMEOUT); + const QDBusObjectPath &primary_conn = get_response(nm.call("Get", NM_DBUS_INTERFACE, "PrimaryConnection")); + + QDBusInterface nm2(NM_DBUS_SERVICE, primary_conn.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); + nm.setTimeout(DBUS_TIMEOUT); + const QString &primary_type = get_response(nm2.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type")); + + if (primary_type == "802-3-ethernet") { + return NetworkType::ETHERNET; + } else if (primary_type == "802-11-wireless" && !isTetheringEnabled()) { + return NetworkType::WIFI; + } else { + for (const QDBusObjectPath &conn : get_active_connections()) { + QDBusInterface nm3(NM_DBUS_SERVICE, conn.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); + nm3.setTimeout(DBUS_TIMEOUT); + const QString &type = get_response(nm3.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type")); + if (type == "gsm") { + return NetworkType::CELL; + } + } + } + return NetworkType::NONE; +} + +void WifiManager::updateGsmSettings(bool roaming, QString apn) { + if (!lteConnectionPath.path().isEmpty()) { + QDBusInterface nm(NM_DBUS_SERVICE, lteConnectionPath.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); + nm.setTimeout(DBUS_TIMEOUT); + + bool changes = false; + bool auto_config = apn.isEmpty(); + Connection settings = QDBusReply(nm.call("GetSettings")).value(); + + if (settings.value("gsm").value("auto-config").toBool() != auto_config) { + qWarning() << "Changing gsm.auto-config to" << auto_config; + settings["gsm"]["auto-config"] = auto_config; + changes = true; + } + + if (settings.value("gsm").value("apn").toString() != apn) { + qWarning() << "Changing gsm.apn to" << apn; + settings["gsm"]["apn"] = apn; + changes = true; + } + + if (settings.value("gsm").value("home-only").toBool() == roaming) { + qWarning() << "Changing gsm.home-only to" << !roaming; + settings["gsm"]["home-only"] = !roaming; + changes = true; + } + + if (changes) { + nm.call("UpdateUnsaved", QVariant::fromValue(settings)); // update is temporary + deactivateConnection(lteConnectionPath); + activateModemConnection(lteConnectionPath); + } + } +} + +// Functions for tethering +void WifiManager::addTetheringConnection() { + 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["connection"]["autoconnect"] = false; + + 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"] = defaultTetheringPassword; + + 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["ipv4"]["route-metric"] = 1100; + connection["ipv6"]["method"] = "ignore"; + + QDBusInterface nm_settings(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, bus); + nm_settings.setTimeout(DBUS_TIMEOUT); + nm_settings.call("AddConnection", QVariant::fromValue(connection)); +} + +void WifiManager::setTetheringEnabled(bool enabled) { + if (enabled) { + if (!isKnownConnection(tethering_ssid)) { + addTetheringConnection(); + } + activateWifiConnection(tethering_ssid); + } else { + deactivateConnectionBySsid(tethering_ssid); + } +} + +void WifiManager::initActiveAp() { + QDBusInterface device_props(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, bus); + device_props.setTimeout(DBUS_TIMEOUT); + + const QDBusMessage &response = device_props.call("Get", NM_DBUS_INTERFACE_DEVICE_WIRELESS, "ActiveAccessPoint"); + activeAp = get_response(response).path(); +} + + +bool WifiManager::isTetheringEnabled() { + if (activeAp != "" && activeAp != "/") { + return get_property(activeAp, "Ssid") == tethering_ssid; + } + return false; +} + +QString WifiManager::getTetheringPassword() { + if (!isKnownConnection(tethering_ssid)) { + addTetheringConnection(); + } + const QDBusObjectPath &path = getConnectionPath(tethering_ssid); + if (!path.path().isEmpty()) { + QDBusInterface nm(NM_DBUS_INTERFACE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); + nm.setTimeout(DBUS_TIMEOUT); + + const QDBusReply>> response = nm.call("GetSecrets", "802-11-wireless-security"); + return response.value().value("802-11-wireless-security").value("psk").toString(); + } + return ""; +} + +void WifiManager::changeTetheringPassword(const QString &newPassword) { + const QDBusObjectPath &path = getConnectionPath(tethering_ssid); + if (!path.path().isEmpty()) { + QDBusInterface nm(NM_DBUS_INTERFACE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); + nm.setTimeout(DBUS_TIMEOUT); + + Connection settings = QDBusReply(nm.call("GetSettings")).value(); + settings["802-11-wireless-security"]["psk"] = newPassword; + nm.call("Update", QVariant::fromValue(settings)); + + if (isTetheringEnabled()) { + activateWifiConnection(tethering_ssid); + } + } +} diff --git a/selfdrive/ui/qt/offroad/wifiManager.h b/selfdrive/ui/qt/offroad/wifiManager.h new file mode 100644 index 00000000000000..04defd32dd584c --- /dev/null +++ b/selfdrive/ui/qt/offroad/wifiManager.h @@ -0,0 +1,106 @@ +#pragma once + +#include +#include + +#include "selfdrive/ui/qt/offroad/networkmanager.h" + +enum class SecurityType { + OPEN, + WPA, + UNSUPPORTED +}; +enum class ConnectedType { + DISCONNECTED, + CONNECTING, + CONNECTED +}; +enum class NetworkType { + NONE, + WIFI, + CELL, + ETHERNET +}; + +typedef QMap> Connection; +typedef QVector> IpConfig; + +struct Network { + QByteArray ssid; + unsigned int strength; + ConnectedType connected; + SecurityType security_type; +}; +bool compare_by_strength(const Network &a, const Network &b); + +class WifiManager : public QWidget { + Q_OBJECT + +public: + explicit WifiManager(QWidget* parent); + + void requestScan(); + QMap seenNetworks; + QMap knownConnections; + QDBusObjectPath lteConnectionPath; + QString ipv4_address; + + void refreshNetworks(); + void forgetConnection(const QString &ssid); + bool isKnownConnection(const QString &ssid); + void activateWifiConnection(const QString &ssid); + void activateModemConnection(const QDBusObjectPath &path); + NetworkType currentNetworkType(); + void updateGsmSettings(bool roaming, QString apn); + + void connect(const Network &ssid); + void connect(const Network &ssid, const QString &password); + void connect(const Network &ssid, const QString &username, const QString &password); + void disconnect(); + + // Tethering functions + void setTetheringEnabled(bool enabled); + bool isTetheringEnabled(); + void addTetheringConnection(); + void changeTetheringPassword(const QString &newPassword); + QString getTetheringPassword(); + +private: + 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; + const QString defaultTetheringPassword = "swagswagcomma"; + + bool firstScan = true; + QString getAdapter(const uint = NM_DEVICE_TYPE_WIFI); + uint getAdapterType(const QDBusObjectPath &path); + bool isWirelessAdapter(const QDBusObjectPath &path); + QString get_ipv4_address(); + void connect(const QByteArray &ssid, const QString &username, const QString &password, SecurityType security_type); + QString activeAp; + void initActiveAp(); + void deactivateConnectionBySsid(const QString &ssid); + void deactivateConnection(const QDBusObjectPath &path); + QVector get_active_connections(); + uint get_wifi_device_state(); + QByteArray get_property(const QString &network_path, const QString &property); + unsigned int get_ap_strength(const QString &network_path); + SecurityType getSecurityType(const QString &path); + QDBusObjectPath getConnectionPath(const QString &ssid); + Connection getConnectionSettings(const QDBusObjectPath &path); + void initConnections(); + void setup(); + +signals: + void wrongPassword(const QString &ssid); + void refreshSignal(); + +private slots: + void stateChange(unsigned int new_state, unsigned int previous_state, unsigned int change_reason); + void propertyChange(const QString &interface, const QVariantMap &props, const QStringList &invalidated_props); + void deviceAdded(const QDBusObjectPath &path); + void connectionRemoved(const QDBusObjectPath &path); + void newConnection(const QDBusObjectPath &path); +}; diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc new file mode 100644 index 00000000000000..53cc9636740d72 --- /dev/null +++ b/selfdrive/ui/qt/onroad.cc @@ -0,0 +1,384 @@ +#include "selfdrive/ui/qt/onroad.h" + +#include + +#include + +#include "selfdrive/common/timing.h" +#include "selfdrive/ui/qt/util.h" +#ifdef ENABLE_MAPS +#include "selfdrive/ui/qt/maps/map.h" +#include "selfdrive/ui/qt/maps/map_helpers.h" +#endif + +OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { + QVBoxLayout *main_layout = new QVBoxLayout(this); + main_layout->setMargin(bdr_s); + QStackedLayout *stacked_layout = new QStackedLayout; + stacked_layout->setStackingMode(QStackedLayout::StackAll); + main_layout->addLayout(stacked_layout); + + QStackedLayout *road_view_layout = new QStackedLayout; + road_view_layout->setStackingMode(QStackedLayout::StackAll); + nvg = new NvgWindow(VISION_STREAM_RGB_BACK, this); + road_view_layout->addWidget(nvg); + hud = new OnroadHud(this); + road_view_layout->addWidget(hud); + + QWidget * split_wrapper = new QWidget; + split = new QHBoxLayout(split_wrapper); + split->setContentsMargins(0, 0, 0, 0); + split->setSpacing(0); + split->addLayout(road_view_layout); + + stacked_layout->addWidget(split_wrapper); + + alerts = new OnroadAlerts(this); + alerts->setAttribute(Qt::WA_TransparentForMouseEvents, true); + stacked_layout->addWidget(alerts); + + // setup stacking order + alerts->raise(); + + setAttribute(Qt::WA_OpaquePaintEvent); + QObject::connect(this, &OnroadWindow::updateStateSignal, this, &OnroadWindow::updateState); + QObject::connect(this, &OnroadWindow::offroadTransitionSignal, this, &OnroadWindow::offroadTransition); +} + +void OnroadWindow::updateState(const UIState &s) { + QColor bgColor = bg_colors[s.status]; + Alert alert = Alert::get(*(s.sm), s.scene.started_frame); + if (s.sm->updated("controlsState") || !alert.equal({})) { + if (alert.type == "controlsUnresponsive") { + bgColor = bg_colors[STATUS_ALERT]; + } + alerts->updateAlert(alert, bgColor); + } + + hud->updateState(s); + + if (bg != bgColor) { + // repaint border + bg = bgColor; + update(); + } +} + +void OnroadWindow::mousePressEvent(QMouseEvent* e) { + if (map != nullptr) { + bool sidebarVisible = geometry().x() > 0; + map->setVisible(!sidebarVisible && !map->isVisible()); + } + // propagation event to parent(HomeWindow) + QWidget::mousePressEvent(e); +} + +void OnroadWindow::offroadTransition(bool offroad) { +#ifdef ENABLE_MAPS + if (!offroad) { + if (map == nullptr && (QUIState::ui_state.has_prime || !MAPBOX_TOKEN.isEmpty())) { + MapWindow * m = new MapWindow(get_mapbox_settings()); + m->setFixedWidth(topWidget(this)->width() / 2); + QObject::connect(this, &OnroadWindow::offroadTransitionSignal, m, &MapWindow::offroadTransition); + split->addWidget(m, 0, Qt::AlignRight); + map = m; + } + } +#endif + + alerts->updateAlert({}, bg); + + // update stream type + bool wide_cam = Hardware::TICI() && Params().getBool("EnableWideCamera"); + nvg->setStreamType(wide_cam ? VISION_STREAM_RGB_WIDE : VISION_STREAM_RGB_BACK); +} + +void OnroadWindow::paintEvent(QPaintEvent *event) { + QPainter p(this); + p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 255)); +} + +// ***** onroad widgets ***** + +// OnroadAlerts +void OnroadAlerts::updateAlert(const Alert &a, const QColor &color) { + if (!alert.equal(a) || color != bg) { + alert = a; + bg = color; + update(); + } +} + +void OnroadAlerts::paintEvent(QPaintEvent *event) { + if (alert.size == cereal::ControlsState::AlertSize::NONE) { + return; + } + static std::map alert_sizes = { + {cereal::ControlsState::AlertSize::SMALL, 271}, + {cereal::ControlsState::AlertSize::MID, 420}, + {cereal::ControlsState::AlertSize::FULL, height()}, + }; + int h = alert_sizes[alert.size]; + QRect r = QRect(0, height() - h, width(), h); + + QPainter p(this); + + // draw background + gradient + p.setPen(Qt::NoPen); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + + p.setBrush(QBrush(bg)); + p.drawRect(r); + + QLinearGradient g(0, r.y(), 0, r.bottom()); + g.setColorAt(0, QColor::fromRgbF(0, 0, 0, 0.05)); + g.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0.35)); + + p.setCompositionMode(QPainter::CompositionMode_DestinationOver); + p.setBrush(QBrush(g)); + p.fillRect(r, g); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + + // text + const QPoint c = r.center(); + p.setPen(QColor(0xff, 0xff, 0xff)); + p.setRenderHint(QPainter::TextAntialiasing); + if (alert.size == cereal::ControlsState::AlertSize::SMALL) { + configFont(p, "Open Sans", 74, "SemiBold"); + p.drawText(r, Qt::AlignCenter, alert.text1); + } else if (alert.size == cereal::ControlsState::AlertSize::MID) { + configFont(p, "Open Sans", 88, "Bold"); + p.drawText(QRect(0, c.y() - 125, width(), 150), Qt::AlignHCenter | Qt::AlignTop, alert.text1); + configFont(p, "Open Sans", 66, "Regular"); + p.drawText(QRect(0, c.y() + 21, width(), 90), Qt::AlignHCenter, alert.text2); + } else if (alert.size == cereal::ControlsState::AlertSize::FULL) { + bool l = alert.text1.length() > 15; + configFont(p, "Open Sans", l ? 132 : 177, "Bold"); + p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 600), Qt::AlignHCenter | Qt::TextWordWrap, alert.text1); + configFont(p, "Open Sans", 88, "Regular"); + p.drawText(QRect(0, r.height() - (l ? 361 : 420), width(), 300), Qt::AlignHCenter | Qt::TextWordWrap, alert.text2); + } +} + +// OnroadHud +OnroadHud::OnroadHud(QWidget *parent) : QWidget(parent) { + engage_img = QPixmap("../assets/img_chffr_wheel.png").scaled(img_size, img_size, Qt::KeepAspectRatio, Qt::SmoothTransformation); + dm_img = QPixmap("../assets/img_driver_face.png").scaled(img_size, img_size, Qt::KeepAspectRatio, Qt::SmoothTransformation); + + connect(this, &OnroadHud::valueChanged, [=] { update(); }); +} + +void OnroadHud::updateState(const UIState &s) { + const int SET_SPEED_NA = 255; + const SubMaster &sm = *(s.sm); + const auto cs = sm["controlsState"].getControlsState(); + + float maxspeed = cs.getVCruise(); + bool cruise_set = maxspeed > 0 && (int)maxspeed != SET_SPEED_NA; + if (cruise_set && !s.scene.is_metric) { + maxspeed *= KM_TO_MILE; + } + QString maxspeed_str = cruise_set ? QString::number(std::nearbyint(maxspeed)) : "N/A"; + float cur_speed = std::max(0.0, sm["carState"].getCarState().getVEgo() * (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH)); + + setProperty("is_cruise_set", cruise_set); + setProperty("speed", QString::number(std::nearbyint(cur_speed))); + setProperty("maxSpeed", maxspeed_str); + setProperty("speedUnit", s.scene.is_metric ? "km/h" : "mph"); + setProperty("hideDM", cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE); + setProperty("status", s.status); + + // update engageability and DM icons at 2Hz + if (sm.frame % (UI_FREQ / 2) == 0) { + setProperty("engageable", cs.getEngageable() || cs.getEnabled()); + setProperty("dmActive", sm["driverMonitoringState"].getDriverMonitoringState().getIsActiveMode()); + } +} + +void OnroadHud::paintEvent(QPaintEvent *event) { + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing); + + // Header gradient + QLinearGradient bg(0, header_h - (header_h / 2.5), 0, header_h); + bg.setColorAt(0, QColor::fromRgbF(0, 0, 0, 0.45)); + bg.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0)); + p.fillRect(0, 0, width(), header_h, bg); + + // max speed + QRect rc(bdr_s * 2, bdr_s * 1.5, 184, 202); + p.setPen(QPen(QColor(0xff, 0xff, 0xff, 100), 10)); + p.setBrush(QColor(0, 0, 0, 100)); + p.drawRoundedRect(rc, 20, 20); + p.setPen(Qt::NoPen); + + configFont(p, "Open Sans", 48, "Regular"); + drawText(p, rc.center().x(), 118, "MAX", is_cruise_set ? 200 : 100); + if (is_cruise_set) { + configFont(p, "Open Sans", 88, is_cruise_set ? "Bold" : "SemiBold"); + drawText(p, rc.center().x(), 212, maxSpeed, 255); + } else { + configFont(p, "Open Sans", 80, "SemiBold"); + drawText(p, rc.center().x(), 212, maxSpeed, 100); + } + + // current speed + configFont(p, "Open Sans", 176, "Bold"); + drawText(p, rect().center().x(), 210, speed); + configFont(p, "Open Sans", 66, "Regular"); + drawText(p, rect().center().x(), 290, speedUnit, 200); + + // engage-ability icon + if (engageable) { + drawIcon(p, rect().right() - radius / 2 - bdr_s * 2, radius / 2 + int(bdr_s * 1.5), + engage_img, bg_colors[status], 1.0); + } + + // dm icon + if (!hideDM) { + drawIcon(p, radius / 2 + (bdr_s * 2), rect().bottom() - footer_h / 2, + dm_img, QColor(0, 0, 0, 70), dmActive ? 1.0 : 0.2); + } +} + +void OnroadHud::drawText(QPainter &p, int x, int y, const QString &text, int alpha) { + QFontMetrics fm(p.font()); + QRect init_rect = fm.boundingRect(text); + QRect real_rect = fm.boundingRect(init_rect, 0, text); + real_rect.moveCenter({x, y - real_rect.height() / 2}); + + p.setPen(QColor(0xff, 0xff, 0xff, alpha)); + p.drawText(real_rect.x(), real_rect.bottom(), text); +} + +void OnroadHud::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity) { + p.setPen(Qt::NoPen); + p.setBrush(bg); + p.drawEllipse(x - radius / 2, y - radius / 2, radius, radius); + p.setOpacity(opacity); + p.drawPixmap(x - img_size / 2, y - img_size / 2, img); +} + +// NvgWindow +void NvgWindow::initializeGL() { + CameraViewWidget::initializeGL(); + qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION)); + qInfo() << "OpenGL vendor:" << QString((const char*)glGetString(GL_VENDOR)); + qInfo() << "OpenGL renderer:" << QString((const char*)glGetString(GL_RENDERER)); + qInfo() << "OpenGL language version:" << QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION)); + + prev_draw_t = millis_since_boot(); + setBackgroundColor(bg_colors[STATUS_DISENGAGED]); +} + +void NvgWindow::updateFrameMat(int w, int h) { + CameraViewWidget::updateFrameMat(w, h); + + UIState *s = &QUIState::ui_state; + s->fb_w = w; + s->fb_h = h; + auto intrinsic_matrix = s->wide_camera ? ecam_intrinsic_matrix : fcam_intrinsic_matrix; + float zoom = ZOOM / intrinsic_matrix.v[0]; + if (s->wide_camera) { + zoom *= 0.5; + } + // Apply transformation such that video pixel coordinates match video + // 1) Put (0, 0) in the middle of the video + // 2) Apply same scaling as video + // 3) Put (0, 0) in top left corner of video + s->car_space_transform.reset(); + s->car_space_transform.translate(w / 2, h / 2 + y_offset) + .scale(zoom, zoom) + .translate(-intrinsic_matrix.v[2], -intrinsic_matrix.v[5]); +} + +void NvgWindow::drawLaneLines(QPainter &painter, const UIScene &scene) { + if (!scene.end_to_end) { + // lanelines + for (int i = 0; i < std::size(scene.lane_line_vertices); ++i) { + painter.setBrush(QColor::fromRgbF(1.0, 1.0, 1.0, scene.lane_line_probs[i])); + painter.drawPolygon(scene.lane_line_vertices[i].v, scene.lane_line_vertices[i].cnt); + } + // road edges + for (int i = 0; i < std::size(scene.road_edge_vertices); ++i) { + painter.setBrush(QColor::fromRgbF(1.0, 0, 0, std::clamp(1.0 - scene.road_edge_stds[i], 0.0, 1.0))); + painter.drawPolygon(scene.road_edge_vertices[i].v, scene.road_edge_vertices[i].cnt); + } + } + // paint path + QLinearGradient bg(0, height(), 0, height() / 4); + bg.setColorAt(0, scene.end_to_end ? redColor() : QColor(255, 255, 255)); + bg.setColorAt(1, scene.end_to_end ? redColor(0) : QColor(255, 255, 255, 0)); + painter.setBrush(bg); + painter.drawPolygon(scene.track_vertices.v, scene.track_vertices.cnt); +} + +void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd) { + const float speedBuff = 10.; + const float leadBuff = 40.; + const float d_rel = lead_data.getX()[0]; + const float v_rel = lead_data.getV()[0]; + + float fillAlpha = 0; + 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)); + } + + float sz = std::clamp((25 * 30) / (d_rel / 3 + 30), 15.0f, 30.0f) * 2.35; + float x = std::clamp((float)vd.x(), 0.f, width() - sz / 2); + float y = std::fmin(height() - sz * .6, (float)vd.y()); + + float g_xo = sz / 5; + float g_yo = sz / 10; + + QPointF glow[] = {{x + (sz * 1.35) + g_xo, y + sz + g_yo}, {x, y - g_xo}, {x - (sz * 1.35) - g_xo, y + sz + g_yo}}; + painter.setBrush(QColor(218, 202, 37, 255)); + painter.drawPolygon(glow, std::size(glow)); + + // chevron + QPointF chevron[] = {{x + (sz * 1.25), y + sz}, {x, y}, {x - (sz * 1.25), y + sz}}; + painter.setBrush(redColor(fillAlpha)); + painter.drawPolygon(chevron, std::size(chevron)); +} + +void NvgWindow::paintGL() { + CameraViewWidget::paintGL(); + + UIState *s = &QUIState::ui_state; + if (s->scene.world_objects_visible) { + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(Qt::NoPen); + + drawLaneLines(painter, s->scene); + + if (s->scene.longitudinal_control) { + auto leads = (*s->sm)["modelV2"].getModelV2().getLeadsV3(); + if (leads[0].getProb() > .5) { + drawLead(painter, leads[0], s->scene.lead_vertices[0]); + } + if (leads[1].getProb() > .5 && (std::abs(leads[1].getX()[0] - leads[0].getX()[0]) > 3.0)) { + drawLead(painter, leads[1], s->scene.lead_vertices[1]); + } + } + } + + double cur_draw_t = millis_since_boot(); + double dt = cur_draw_t - prev_draw_t; + if (dt > 66) { + // warn on sub 15fps + LOGW("slow frame time: %.2f", dt); + } + prev_draw_t = cur_draw_t; +} + +void NvgWindow::showEvent(QShowEvent *event) { + CameraViewWidget::showEvent(event); + + ui_update_params(&QUIState::ui_state); + prev_draw_t = millis_since_boot(); +} diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h new file mode 100644 index 00000000000000..37460c8ba6aeff --- /dev/null +++ b/selfdrive/ui/qt/onroad.h @@ -0,0 +1,107 @@ +#pragma once + +#include +#include + +#include "selfdrive/ui/qt/widgets/cameraview.h" +#include "selfdrive/ui/ui.h" + + +// ***** onroad widgets ***** + +class OnroadHud : public QWidget { + Q_OBJECT + Q_PROPERTY(QString speed MEMBER speed NOTIFY valueChanged); + Q_PROPERTY(QString speedUnit MEMBER speedUnit NOTIFY valueChanged); + Q_PROPERTY(QString maxSpeed MEMBER maxSpeed NOTIFY valueChanged); + Q_PROPERTY(bool is_cruise_set MEMBER is_cruise_set NOTIFY valueChanged); + Q_PROPERTY(bool engageable MEMBER engageable NOTIFY valueChanged); + Q_PROPERTY(bool dmActive MEMBER dmActive NOTIFY valueChanged); + Q_PROPERTY(bool hideDM MEMBER hideDM NOTIFY valueChanged); + Q_PROPERTY(int status MEMBER status NOTIFY valueChanged); + +public: + explicit OnroadHud(QWidget *parent); + void updateState(const UIState &s); + +private: + void drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity); + void drawText(QPainter &p, int x, int y, const QString &text, int alpha = 255); + void paintEvent(QPaintEvent *event) override; + + QPixmap engage_img; + QPixmap dm_img; + const int radius = 192; + const int img_size = (radius / 2) * 1.5; + QString speed; + QString speedUnit; + QString maxSpeed; + bool is_cruise_set = false; + bool engageable = false; + bool dmActive = false; + bool hideDM = false; + int status = STATUS_DISENGAGED; + +signals: + void valueChanged(); +}; + +class OnroadAlerts : public QWidget { + Q_OBJECT + +public: + OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {}; + void updateAlert(const Alert &a, const QColor &color); + +protected: + void paintEvent(QPaintEvent*) override; + +private: + QColor bg; + Alert alert = {}; +}; + +// container window for the NVG UI +class NvgWindow : public CameraViewWidget { + Q_OBJECT + +public: + explicit NvgWindow(VisionStreamType type, QWidget* parent = 0) : CameraViewWidget("camerad", type, true, parent) {} + +protected: + void paintGL() override; + void initializeGL() override; + void showEvent(QShowEvent *event) override; + void updateFrameMat(int w, int h) override; + void drawLaneLines(QPainter &painter, const UIScene &scene); + void drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd); + inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); } + double prev_draw_t = 0; +}; + +// container for all onroad widgets +class OnroadWindow : public QWidget { + Q_OBJECT + +public: + OnroadWindow(QWidget* parent = 0); + bool isMapVisible() const { return map && map->isVisible(); } + +private: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent* e) override; + OnroadHud *hud; + OnroadAlerts *alerts; + NvgWindow *nvg; + QColor bg = bg_colors[STATUS_DISENGAGED]; + QWidget *map = nullptr; + QHBoxLayout* split; + +signals: + void updateStateSignal(const UIState &s); + void offroadTransitionSignal(bool offroad); + +private slots: + void offroadTransition(bool offroad); + void updateState(const UIState &s); +}; diff --git a/selfdrive/ui/qt/qt_window.cc b/selfdrive/ui/qt/qt_window.cc new file mode 100644 index 00000000000000..d630b560bb967f --- /dev/null +++ b/selfdrive/ui/qt/qt_window.cc @@ -0,0 +1,30 @@ +#include "selfdrive/ui/qt/qt_window.h" + +void setMainWindow(QWidget *w) { + const QSize sz = QGuiApplication::primaryScreen()->size(); + if (Hardware::PC() && sz.width() <= 1920 && sz.height() <= 1080 && getenv("SCALE") == nullptr) { + w->setMinimumSize(QSize(640, 480)); // allow resize smaller than fullscreen + w->setMaximumSize(QSize(2160, 1080)); + w->resize(sz); + } else { + const float scale = util::getenv("SCALE", 1.0f); + const bool wide = (sz.width() >= WIDE_WIDTH) ^ (getenv("INVERT_WIDTH") != NULL); + w->setFixedSize(QSize(wide ? WIDE_WIDTH : 1920, 1080) * 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 +} + + +extern "C" { + void set_main_window(void *w) { + setMainWindow((QWidget*)w); + } +} diff --git a/selfdrive/ui/qt/qt_window.h b/selfdrive/ui/qt/qt_window.h new file mode 100644 index 00000000000000..2c9a24e55b7eb5 --- /dev/null +++ b/selfdrive/ui/qt/qt_window.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +#include +#include +#include + +#ifdef QCOM2 +#include +#include +#include +#endif + +#include "selfdrive/hardware/hw.h" + +const QString ASSET_PATH = ":/"; + +const int WIDE_WIDTH = 2160; + +void setMainWindow(QWidget *w); diff --git a/selfdrive/ui/qt/request_repeater.cc b/selfdrive/ui/qt/request_repeater.cc new file mode 100644 index 00000000000000..d2c0f9bc30d80b --- /dev/null +++ b/selfdrive/ui/qt/request_repeater.cc @@ -0,0 +1,27 @@ +#include "selfdrive/ui/qt/request_repeater.h" + +RequestRepeater::RequestRepeater(QObject *parent, const QString &requestURL, const QString &cacheKey, + int period, bool while_onroad) : HttpRequest(parent) { + timer = new QTimer(this); + timer->setTimerType(Qt::VeryCoarseTimer); + QObject::connect(timer, &QTimer::timeout, [=]() { + if ((!QUIState::ui_state.scene.started || while_onroad) && QUIState::ui_state.awake && !active()) { + sendRequest(requestURL); + } + }); + + timer->start(period * 1000); + + if (!cacheKey.isEmpty()) { + prevResp = QString::fromStdString(params.get(cacheKey.toStdString())); + if (!prevResp.isEmpty()) { + QTimer::singleShot(500, [=]() { emit requestDone(prevResp, true); }); + } + QObject::connect(this, &HttpRequest::requestDone, [=](const QString &resp, bool success) { + if (success && resp != prevResp) { + params.put(cacheKey.toStdString(), resp.toStdString()); + prevResp = resp; + } + }); + } +} diff --git a/selfdrive/ui/qt/request_repeater.h b/selfdrive/ui/qt/request_repeater.h new file mode 100644 index 00000000000000..fa80100d22dbd6 --- /dev/null +++ b/selfdrive/ui/qt/request_repeater.h @@ -0,0 +1,15 @@ +#pragma once + +#include "selfdrive/common/util.h" +#include "selfdrive/ui/qt/api.h" +#include "selfdrive/ui/ui.h" + +class RequestRepeater : public HttpRequest { +public: + RequestRepeater(QObject *parent, const QString &requestURL, const QString &cacheKey = "", int period = 0, bool while_onroad=false); + +private: + Params params; + QTimer *timer; + QString prevResp; +}; diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc new file mode 100644 index 00000000000000..73c4e2f8ce6b65 --- /dev/null +++ b/selfdrive/ui/qt/sidebar.cc @@ -0,0 +1,113 @@ +#include "selfdrive/ui/qt/sidebar.h" + +#include + +#include "selfdrive/ui/qt/util.h" + +void Sidebar::drawMetric(QPainter &p, const QString &label, QColor c, int y) { + const QRect rect = {30, y, 240, label.contains("\n") ? 124 : 100}; + + p.setPen(Qt::NoPen); + p.setBrush(QBrush(c)); + p.setClipRect(rect.x() + 6, rect.y(), 18, rect.height(), Qt::ClipOperation::ReplaceClip); + p.drawRoundedRect(QRect(rect.x() + 6, rect.y() + 6, 100, rect.height() - 12), 10, 10); + p.setClipping(false); + + QPen pen = QPen(QColor(0xff, 0xff, 0xff, 0x55)); + pen.setWidth(2); + p.setPen(pen); + p.setBrush(Qt::NoBrush); + p.drawRoundedRect(rect, 20, 20); + + p.setPen(QColor(0xff, 0xff, 0xff)); + configFont(p, "Open Sans", 35, "Bold"); + const QRect r = QRect(rect.x() + 30, rect.y(), rect.width() - 40, rect.height()); + p.drawText(r, Qt::AlignCenter, label); +} + +Sidebar::Sidebar(QWidget *parent) : QFrame(parent) { + home_img = QImage("../assets/images/button_home.png").scaled(180, 180, Qt::KeepAspectRatio, Qt::SmoothTransformation); + settings_img = QImage("../assets/images/button_settings.png").scaled(settings_btn.width(), settings_btn.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + + connect(this, &Sidebar::valueChanged, [=] { update(); }); + + setAttribute(Qt::WA_OpaquePaintEvent); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + setFixedWidth(300); +} + +void Sidebar::mouseReleaseEvent(QMouseEvent *event) { + if (settings_btn.contains(event->pos())) { + emit openSettings(); + } +} + +void Sidebar::updateState(const UIState &s) { + if (!isVisible()) return; + + auto &sm = *(s.sm); + + auto deviceState = sm["deviceState"].getDeviceState(); + setProperty("netType", network_type[deviceState.getNetworkType()]); + int strength = (int)deviceState.getNetworkStrength(); + setProperty("netStrength", strength > 0 ? strength + 1 : 0); + + ItemStatus connectStatus; + auto last_ping = deviceState.getLastAthenaPingTime(); + if (last_ping == 0) { + connectStatus = params.getBool("PrimeRedirected") ? ItemStatus{"NO\nPRIME", danger_color} : ItemStatus{"CONNECT\nOFFLINE", warning_color}; + } else { + connectStatus = nanos_since_boot() - last_ping < 80e9 ? ItemStatus{"CONNECT\nONLINE", good_color} : ItemStatus{"CONNECT\nERROR", danger_color}; + } + setProperty("connectStatus", QVariant::fromValue(connectStatus)); + + ItemStatus tempStatus = {"TEMP\nHIGH", danger_color}; + auto ts = deviceState.getThermalStatus(); + if (ts == cereal::DeviceState::ThermalStatus::GREEN) { + tempStatus = {"TEMP\nGOOD", good_color}; + } else if (ts == cereal::DeviceState::ThermalStatus::YELLOW) { + tempStatus = {"TEMP\nOK", warning_color}; + } + setProperty("tempStatus", QVariant::fromValue(tempStatus)); + + ItemStatus pandaStatus = {"VEHICLE\nONLINE", good_color}; + if (s.scene.pandaType == cereal::PandaState::PandaType::UNKNOWN) { + pandaStatus = {"NO\nPANDA", danger_color}; + } else if (s.scene.started && !sm["liveLocationKalman"].getLiveLocationKalman().getGpsOK()) { + pandaStatus = {"GPS\nSEARCHING", warning_color}; + } + setProperty("pandaStatus", QVariant::fromValue(pandaStatus)); +} + +void Sidebar::paintEvent(QPaintEvent *event) { + QPainter p(this); + p.setPen(Qt::NoPen); + p.setRenderHint(QPainter::Antialiasing); + + p.fillRect(rect(), QColor(57, 57, 57)); + + // static imgs + p.setOpacity(0.65); + p.drawImage(settings_btn.x(), settings_btn.y(), settings_img); + p.setOpacity(1.0); + p.drawImage(60, 1080 - 180 - 40, home_img); + + // network + int x = 58; + const QColor gray(0x54, 0x54, 0x54); + for (int i = 0; i < 5; ++i) { + p.setBrush(i < net_strength ? Qt::white : gray); + p.drawEllipse(x, 196, 27, 27); + x += 37; + } + + configFont(p, "Open Sans", 35, "Regular"); + p.setPen(QColor(0xff, 0xff, 0xff)); + const QRect r = QRect(50, 247, 100, 50); + p.drawText(r, Qt::AlignCenter, net_type); + + // metrics + drawMetric(p, temp_status.first, temp_status.second, 338); + drawMetric(p, panda_status.first, panda_status.second, 496); + drawMetric(p, connect_status.first, connect_status.second, 654); +} diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h new file mode 100644 index 00000000000000..6cea9bdb6d9e05 --- /dev/null +++ b/selfdrive/ui/qt/sidebar.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/ui/ui.h" + +typedef QPair ItemStatus; +Q_DECLARE_METATYPE(ItemStatus); + +class Sidebar : public QFrame { + Q_OBJECT + Q_PROPERTY(ItemStatus connectStatus MEMBER connect_status NOTIFY valueChanged); + Q_PROPERTY(ItemStatus pandaStatus MEMBER panda_status NOTIFY valueChanged); + Q_PROPERTY(ItemStatus tempStatus MEMBER temp_status NOTIFY valueChanged); + Q_PROPERTY(QString netType MEMBER net_type NOTIFY valueChanged); + Q_PROPERTY(int netStrength MEMBER net_strength NOTIFY valueChanged); + +public: + explicit Sidebar(QWidget* parent = 0); + +signals: + void openSettings(); + void valueChanged(); + +public slots: + void updateState(const UIState &s); + +protected: + void paintEvent(QPaintEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void drawMetric(QPainter &p, const QString &label, QColor c, int y); + + QImage home_img, settings_img; + const QMap network_type = { + {cereal::DeviceState::NetworkType::NONE, "--"}, + {cereal::DeviceState::NetworkType::WIFI, "Wi-Fi"}, + {cereal::DeviceState::NetworkType::ETHERNET, "ETH"}, + {cereal::DeviceState::NetworkType::CELL2_G, "2G"}, + {cereal::DeviceState::NetworkType::CELL3_G, "3G"}, + {cereal::DeviceState::NetworkType::CELL4_G, "LTE"}, + {cereal::DeviceState::NetworkType::CELL5_G, "5G"} + }; + + const QRect settings_btn = QRect(50, 35, 200, 117); + const QColor good_color = QColor(255, 255, 255); + const QColor warning_color = QColor(218, 202, 37); + const QColor danger_color = QColor(201, 34, 49); + + Params params; + ItemStatus connect_status, panda_status, temp_status; + QString net_type; + int net_strength = 0; +}; diff --git a/selfdrive/ui/qt/spinner.cc b/selfdrive/ui/qt/spinner.cc new file mode 100644 index 00000000000000..8948d2adb77608 --- /dev/null +++ b/selfdrive/ui/qt/spinner.cc @@ -0,0 +1,119 @@ +#include "selfdrive/ui/qt/spinner.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/util.h" + +TrackWidget::TrackWidget(QWidget *parent) : QWidget(parent) { + setAttribute(Qt::WA_OpaquePaintEvent); + setFixedSize(spinner_size); + + // pre-compute all the track imgs. make this a gif instead? + QPixmap comma_img = QPixmap("../assets/img_spinner_comma.png").scaled(spinner_size, Qt::KeepAspectRatio, Qt::SmoothTransformation); + QPixmap track_img = QPixmap("../assets/img_spinner_track.png").scaled(spinner_size, Qt::KeepAspectRatio, Qt::SmoothTransformation); + + QTransform transform(1, 0, 0, 1, width() / 2, height() / 2); + QPixmap pm(spinner_size); + QPainter p(&pm); + p.setRenderHint(QPainter::SmoothPixmapTransform); + for (int i = 0; i < track_imgs.size(); ++i) { + p.resetTransform(); + p.fillRect(0, 0, spinner_size.width(), spinner_size.height(), Qt::black); + p.drawPixmap(0, 0, comma_img); + p.setTransform(transform.rotate(360 / spinner_fps)); + p.drawPixmap(-width() / 2, -height() / 2, track_img); + track_imgs[i] = pm.copy(); + } + + m_anim.setDuration(1000); + m_anim.setStartValue(0); + m_anim.setEndValue(int(track_imgs.size() -1)); + m_anim.setLoopCount(-1); + m_anim.start(); + connect(&m_anim, SIGNAL(valueChanged(QVariant)), SLOT(update())); +} + +void TrackWidget::paintEvent(QPaintEvent *event) { + QPainter painter(this); + painter.drawPixmap(0, 0, track_imgs[m_anim.currentValue().toInt()]); +} + +// Spinner + +Spinner::Spinner(QWidget *parent) : QWidget(parent) { + QGridLayout *main_layout = new QGridLayout(this); + main_layout->setSpacing(0); + main_layout->setMargin(200); + + main_layout->addWidget(new TrackWidget(this), 0, 0, Qt::AlignHCenter | Qt::AlignVCenter); + + text = new QLabel(); + text->setWordWrap(true); + text->setVisible(false); + text->setAlignment(Qt::AlignCenter); + 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); + progress_bar->setFixedHeight(20); + main_layout->addWidget(progress_bar, 1, 0, Qt::AlignHCenter); + + setStyleSheet(R"( + Spinner { + background-color: black; + } + QLabel { + color: white; + font-size: 80px; + background-color: transparent; + } + QProgressBar { + background-color: #373737; + width: 1000px; + border solid white; + border-radius: 10px; + } + QProgressBar::chunk { + border-radius: 10px; + background-color: white; + } + )"); + + notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read); + QObject::connect(notifier, &QSocketNotifier::activated, this, &Spinner::update); +}; + +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[]) { + initApp(); + QApplication a(argc, argv); + Spinner spinner; + setMainWindow(&spinner); + return a.exec(); +} diff --git a/selfdrive/ui/qt/spinner.h b/selfdrive/ui/qt/spinner.h new file mode 100644 index 00000000000000..43d90a75b01036 --- /dev/null +++ b/selfdrive/ui/qt/spinner.h @@ -0,0 +1,37 @@ +#include + +#include +#include +#include +#include +#include +#include + +constexpr int spinner_fps = 30; +constexpr QSize spinner_size = QSize(360, 360); + +class TrackWidget : public QWidget { + Q_OBJECT +public: + TrackWidget(QWidget *parent = nullptr); + +private: + void paintEvent(QPaintEvent *event) override; + std::array track_imgs; + QVariantAnimation m_anim; +}; + +class Spinner : public QWidget { + Q_OBJECT + +public: + explicit Spinner(QWidget *parent = 0); + +private: + QLabel *text; + QProgressBar *progress_bar; + QSocketNotifier *notifier; + +public slots: + void update(int n); +}; diff --git a/selfdrive/ui/qt/spinner_aarch64 b/selfdrive/ui/qt/spinner_aarch64 new file mode 100755 index 00000000000000..71a52bc9f1af55 Binary files /dev/null and b/selfdrive/ui/qt/spinner_aarch64 differ diff --git a/selfdrive/ui/qt/spinner_larch64 b/selfdrive/ui/qt/spinner_larch64 new file mode 100755 index 00000000000000..645bc4430e6773 Binary files /dev/null and b/selfdrive/ui/qt/spinner_larch64 differ diff --git a/selfdrive/ui/qt/text.cc b/selfdrive/ui/qt/text.cc new file mode 100644 index 00000000000000..cb69cc082b8b37 --- /dev/null +++ b/selfdrive/ui/qt/text.cc @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include + +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/widgets/scrollview.h" + +int main(int argc, char *argv[]) { + initApp(); + QApplication a(argc, argv); + QWidget window; + setMainWindow(&window); + + QGridLayout *main_layout = new QGridLayout(&window); + main_layout->setMargin(50); + + QLabel *label = new QLabel(argv[1]); + label->setWordWrap(true); + label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + ScrollView *scroll = new ScrollView(label); + scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + main_layout->addWidget(scroll, 0, 0, Qt::AlignTop); + + // Scroll to the bottom + QObject::connect(scroll->verticalScrollBar(), &QAbstractSlider::rangeChanged, [=]() { + scroll->verticalScrollBar()->setValue(scroll->verticalScrollBar()->maximum()); + }); + + QPushButton *btn = new QPushButton(); +#ifdef __aarch64__ + btn->setText("Reboot"); + QObject::connect(btn, &QPushButton::clicked, [=]() { + Hardware::reboot(); + }); +#else + btn->setText("Exit"); + QObject::connect(btn, &QPushButton::clicked, &a, &QApplication::quit); +#endif + main_layout->addWidget(btn, 0, 0, Qt::AlignRight | Qt::AlignBottom); + + window.setStyleSheet(R"( + * { + outline: none; + color: white; + background-color: black; + font-size: 60px; + } + QPushButton { + padding: 50px; + padding-right: 100px; + padding-left: 100px; + border: 2px solid white; + border-radius: 20px; + margin-right: 40px; + } + )"); + + return a.exec(); +} diff --git a/selfdrive/ui/qt/text_aarch64 b/selfdrive/ui/qt/text_aarch64 new file mode 100755 index 00000000000000..dbce56d59f3661 Binary files /dev/null and b/selfdrive/ui/qt/text_aarch64 differ diff --git a/selfdrive/ui/qt/text_larch64 b/selfdrive/ui/qt/text_larch64 new file mode 100755 index 00000000000000..eb0f535bf3b5d5 Binary files /dev/null and b/selfdrive/ui/qt/text_larch64 differ diff --git a/selfdrive/ui/qt/util.cc b/selfdrive/ui/qt/util.cc new file mode 100644 index 00000000000000..b1defb00816f8a --- /dev/null +++ b/selfdrive/ui/qt/util.cc @@ -0,0 +1,138 @@ +#include "selfdrive/ui/qt/util.h" + +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/hardware/hw.h" + +QString getVersion() { + static QString version = QString::fromStdString(Params().get("Version")); + return version; +} + +QString getBrand() { + return Params().getBool("Passive") ? "dashcam" : "openpilot"; +} + +QString getBrandVersion() { + return getBrand() + " v" + getVersion().left(14).trimmed(); +} + +QString getUserAgent() { + return "openpilot-" + getVersion(); +} + +std::optional getDongleId() { + std::string id = Params().get("DongleId"); + + if (!id.empty() && (id != "UnregisteredDevice")) { + return QString::fromStdString(id); + } else { + return {}; + } +} + +void configFont(QPainter &p, const QString &family, int size, const QString &style) { + QFont f(family); + f.setPixelSize(size); + f.setStyleName(style); + p.setFont(f); +} + +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; + } +} + +QString timeAgo(const QDateTime &date) { + int diff = date.secsTo(QDateTime::currentDateTimeUtc()); + + QString s; + if (diff < 60) { + s = "now"; + } else if (diff < 60 * 60) { + int minutes = diff / 60; + s = QString("%1 minute%2 ago").arg(minutes).arg(minutes > 1 ? "s" : ""); + } else if (diff < 60 * 60 * 24) { + int hours = diff / (60 * 60); + s = QString("%1 hour%2 ago").arg(hours).arg(hours > 1 ? "s" : ""); + } else if (diff < 3600 * 24 * 7) { + int days = diff / (60 * 60 * 24); + s = QString("%1 day%2 ago").arg(days).arg(days > 1 ? "s" : ""); + } else { + s = date.date().toString(); + } + + return s; +} + +void setQtSurfaceFormat() { + QSurfaceFormat fmt; +#ifdef __APPLE__ + fmt.setVersion(3, 2); + fmt.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); + fmt.setRenderableType(QSurfaceFormat::OpenGL); +#else + fmt.setRenderableType(QSurfaceFormat::OpenGLES); +#endif + fmt.setSamples(16); + QSurfaceFormat::setDefaultFormat(fmt); +} + +void initApp() { + Hardware::set_display_power(true); + Hardware::set_brightness(65); + setQtSurfaceFormat(); + if (Hardware::EON()) { + QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + } +} + +ClickableWidget::ClickableWidget(QWidget *parent) : QWidget(parent) { } + +void ClickableWidget::mouseReleaseEvent(QMouseEvent *event) { + emit clicked(); +} + +// Fix stylesheets +void ClickableWidget::paintEvent(QPaintEvent *) { + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} + + +void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + static std::map levels = { + {QtMsgType::QtDebugMsg, CLOUDLOG_DEBUG}, + {QtMsgType::QtInfoMsg, CLOUDLOG_INFO}, + {QtMsgType::QtWarningMsg, CLOUDLOG_WARNING}, + {QtMsgType::QtCriticalMsg, CLOUDLOG_ERROR}, + {QtMsgType::QtSystemMsg, CLOUDLOG_ERROR}, + {QtMsgType::QtFatalMsg, CLOUDLOG_CRITICAL}, + }; + + std::string file, function; + if (context.file != nullptr) file = context.file; + if (context.function != nullptr) function = context.function; + + auto bts = msg.toUtf8(); + cloudlog_e(levels[type], file.c_str(), context.line, function.c_str(), "%s", bts.constData()); +} + + +QWidget* topWidget (QWidget* widget) { + while (widget->parentWidget() != nullptr) widget=widget->parentWidget(); + return widget; +} diff --git a/selfdrive/ui/qt/util.h b/selfdrive/ui/qt/util.h new file mode 100644 index 00000000000000..588dac704ffef6 --- /dev/null +++ b/selfdrive/ui/qt/util.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include + +QString getVersion(); +QString getBrand(); +QString getBrandVersion(); +QString getUserAgent(); +std::optional getDongleId(); +void configFont(QPainter &p, const QString &family, int size, const QString &style); +void clearLayout(QLayout* layout); +void setQtSurfaceFormat(); +QString timeAgo(const QDateTime &date); +void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg); +void initApp(); +QWidget* topWidget (QWidget* widget); + + +// convenience class for wrapping layouts +class LayoutWidget : public QWidget { + Q_OBJECT + +public: + LayoutWidget(QLayout *l, QWidget *parent = nullptr) : QWidget(parent) { + setLayout(l); + }; +}; + +class ClickableWidget : public QWidget { + Q_OBJECT + +public: + ClickableWidget(QWidget *parent = nullptr); + +protected: + void mouseReleaseEvent(QMouseEvent *event) override; + void paintEvent(QPaintEvent *) override; + +signals: + void clicked(); +}; diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc new file mode 100644 index 00000000000000..a238f13c857684 --- /dev/null +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -0,0 +1,314 @@ +#include "selfdrive/ui/qt/widgets/cameraview.h" + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include +#include + +namespace { + +const char frame_vertex_shader[] = +#ifdef __APPLE__ + "#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"; + +const char frame_fragment_shader[] = +#ifdef __APPLE__ + "#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" +#ifdef QCOM + " vec3 dz = vec3(0.0627f, 0.0627f, 0.0627f);\n" + " colorOut.rgb = ((vec3(1.0f, 1.0f, 1.0f) - dz) * colorOut.rgb / vec3(1.0f, 1.0f, 1.0f)) + dz;\n" +#endif + "}\n"; + +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, +}}; + +mat4 get_driver_view_transform(int screen_width, int screen_height, int stream_width, int stream_height) { + const float driver_view_ratio = 1.333; + mat4 transform; + if (stream_width == TICI_CAM_WIDTH) { + const float yscale = stream_height * driver_view_ratio / tici_dm_crop::width; + const float xscale = yscale*screen_height/screen_width*stream_width/stream_height; + transform = (mat4){{ + xscale, 0.0, 0.0, xscale*tici_dm_crop::x_offset/stream_width*2, + 0.0, yscale, 0.0, yscale*tici_dm_crop::y_offset/stream_height*2, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + }}; + } else { + // frame from 4/3 to 16/9 display + transform = (mat4){{ + driver_view_ratio * screen_height / screen_width, 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, + }}; + } + return transform; +} + +mat4 get_fit_view_transform(float widget_aspect_ratio, float frame_aspect_ratio) { + float zx = 1, zy = 1; + if (frame_aspect_ratio > widget_aspect_ratio) { + zy = widget_aspect_ratio / frame_aspect_ratio; + } else { + zx = frame_aspect_ratio / widget_aspect_ratio; + } + + const mat4 frame_transform = {{ + zx, 0.0, 0.0, 0.0, + 0.0, zy, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + }}; + return frame_transform; +} + +} // namespace + +CameraViewWidget::CameraViewWidget(std::string stream_name, VisionStreamType type, bool zoom, QWidget* parent) : + stream_name(stream_name), stream_type(type), zoomed_view(zoom), QOpenGLWidget(parent) { + setAttribute(Qt::WA_OpaquePaintEvent); + connect(this, &CameraViewWidget::vipcThreadConnected, this, &CameraViewWidget::vipcConnected, Qt::BlockingQueuedConnection); +} + +CameraViewWidget::~CameraViewWidget() { + makeCurrent(); + if (isValid()) { + glDeleteVertexArrays(1, &frame_vao); + glDeleteBuffers(1, &frame_vbo); + glDeleteBuffers(1, &frame_ibo); + } + doneCurrent(); +} + +void CameraViewWidget::initializeGL() { + initializeOpenGLFunctions(); + + program = std::make_unique(context()); + bool ret = program->addShaderFromSourceCode(QOpenGLShader::Vertex, frame_vertex_shader); + assert(ret); + ret = program->addShaderFromSourceCode(QOpenGLShader::Fragment, frame_fragment_shader); + assert(ret); + + program->link(); + GLint frame_pos_loc = program->attributeLocation("aPosition"); + GLint frame_texcoord_loc = program->attributeLocation("aTexCoord"); + + auto [x1, x2, y1, y2] = stream_type == VISION_STREAM_RGB_FRONT ? std::tuple(0.f, 1.f, 1.f, 0.f) : std::tuple(1.f, 0.f, 1.f, 0.f); + 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, &frame_vao); + glBindVertexArray(frame_vao); + glGenBuffers(1, &frame_vbo); + glBindBuffer(GL_ARRAY_BUFFER, frame_vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(frame_coords), frame_coords, GL_STATIC_DRAW); + glEnableVertexAttribArray(frame_pos_loc); + glVertexAttribPointer(frame_pos_loc, 2, GL_FLOAT, GL_FALSE, + sizeof(frame_coords[0]), (const void *)0); + glEnableVertexAttribArray(frame_texcoord_loc); + glVertexAttribPointer(frame_texcoord_loc, 2, GL_FLOAT, GL_FALSE, + sizeof(frame_coords[0]), (const void *)(sizeof(float) * 2)); + glGenBuffers(1, &frame_ibo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, frame_ibo); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(frame_indicies), frame_indicies, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); +} + +void CameraViewWidget::showEvent(QShowEvent *event) { + latest_texture_id = -1; + if (!vipc_thread) { + vipc_thread = new QThread(); + connect(vipc_thread, &QThread::started, [=]() { vipcThread(); }); + connect(vipc_thread, &QThread::finished, vipc_thread, &QObject::deleteLater); + vipc_thread->start(); + } +} + +void CameraViewWidget::hideEvent(QHideEvent *event) { + if (vipc_thread) { + vipc_thread->requestInterruption(); + vipc_thread->quit(); + vipc_thread->wait(); + vipc_thread = nullptr; + } +} + +void CameraViewWidget::updateFrameMat(int w, int h) { + if (zoomed_view) { + if (stream_type == VISION_STREAM_RGB_FRONT) { + frame_mat = matmul(device_transform, get_driver_view_transform(w, h, stream_width, stream_height)); + } else { + auto intrinsic_matrix = stream_type == VISION_STREAM_RGB_WIDE ? ecam_intrinsic_matrix : fcam_intrinsic_matrix; + float zoom = ZOOM / intrinsic_matrix.v[0]; + if (stream_type == VISION_STREAM_RGB_WIDE) { + zoom *= 0.5; + } + float zx = zoom * 2 * intrinsic_matrix.v[2] / width(); + float zy = zoom * 2 * intrinsic_matrix.v[5] / height(); + + const mat4 frame_transform = {{ + zx, 0.0, 0.0, 0.0, + 0.0, zy, 0.0, -y_offset / height() * 2, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + }}; + frame_mat = matmul(device_transform, frame_transform); + } + } else if (stream_width > 0 && stream_height > 0) { + // fit frame to widget size + float widget_aspect_ratio = (float)width() / height(); + float frame_aspect_ratio = (float)stream_width / stream_height; + frame_mat = matmul(device_transform, get_fit_view_transform(widget_aspect_ratio, frame_aspect_ratio)); + } +} + +void CameraViewWidget::paintGL() { + if (latest_texture_id == -1) { + glClearColor(bg.redF(), bg.greenF(), bg.blueF(), bg.alphaF()); + glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + return; + } + + glViewport(0, 0, width(), height()); + + glBindVertexArray(frame_vao); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texture[latest_texture_id]->frame_tex); + + glUseProgram(program->programId()); + glUniform1i(program->uniformLocation("uTexture"), 0); + glUniformMatrix4fv(program->uniformLocation("uTransform"), 1, GL_TRUE, frame_mat.v); + + assert(glGetError() == GL_NO_ERROR); + glEnableVertexAttribArray(0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, (const void *)0); + glDisableVertexAttribArray(0); + glBindVertexArray(0); +} + +void CameraViewWidget::vipcConnected(VisionIpcClient *vipc_client) { + makeCurrent(); + for (int i = 0; i < vipc_client->num_buffers; i++) { + texture[i].reset(new EGLImageTexture(&vipc_client->buffers[i])); + + glBindTexture(GL_TEXTURE_2D, texture[i]->frame_tex); + 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); + } + latest_texture_id = -1; + stream_width = vipc_client->buffers[0].width; + stream_height = vipc_client->buffers[0].height; + updateFrameMat(width(), height()); +} + +void CameraViewWidget::vipcThread() { + VisionStreamType cur_stream_type = stream_type; + std::unique_ptr vipc_client; + + std::unique_ptr ctx; + std::unique_ptr surface; + std::unique_ptr gl_buffer; + + if (!Hardware::EON()) { + ctx = std::make_unique(); + ctx->setFormat(context()->format()); + ctx->setShareContext(context()); + ctx->create(); + assert(ctx->isValid()); + + surface = std::make_unique(); + surface->setFormat(ctx->format()); + surface->create(); + ctx->makeCurrent(surface.get()); + assert(QOpenGLContext::currentContext() == ctx.get()); + initializeOpenGLFunctions(); + } + + while (!QThread::currentThread()->isInterruptionRequested()) { + if (!vipc_client || cur_stream_type != stream_type) { + cur_stream_type = stream_type; + vipc_client.reset(new VisionIpcClient(stream_name, cur_stream_type, true)); + } + + if (!vipc_client->connected) { + if (!vipc_client->connect(false)) { + QThread::msleep(100); + continue; + } + + if (!Hardware::EON()) { + gl_buffer.reset(new QOpenGLBuffer(QOpenGLBuffer::PixelUnpackBuffer)); + gl_buffer->create(); + gl_buffer->bind(); + gl_buffer->setUsagePattern(QOpenGLBuffer::StreamDraw); + gl_buffer->allocate(vipc_client->buffers[0].len); + } + + emit vipcThreadConnected(vipc_client.get()); + } + + if (VisionBuf *buf = vipc_client->recv(nullptr, 1000)) { + if (!Hardware::EON()) { + void *texture_buffer = gl_buffer->map(QOpenGLBuffer::WriteOnly); + memcpy(texture_buffer, buf->addr, buf->len); + gl_buffer->unmap(); + + // copy pixels from PBO to texture object + glBindTexture(GL_TEXTURE_2D, texture[buf->idx]->frame_tex); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, buf->width, buf->height, GL_RGB, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, 0); + assert(glGetError() == GL_NO_ERROR); + // use glFinish to ensure that the texture has been uploaded. + glFinish(); + } + latest_texture_id = buf->idx; + // Schedule update. update() will be invoked on the gui thread. + QMetaObject::invokeMethod(this, "update"); + + // TODO: remove later, it's only connected by DriverView. + emit vipcThreadFrameReceived(buf); + } + } +} diff --git a/selfdrive/ui/qt/widgets/cameraview.h b/selfdrive/ui/qt/widgets/cameraview.h new file mode 100644 index 00000000000000..4cfba3c6fb2cae --- /dev/null +++ b/selfdrive/ui/qt/widgets/cameraview.h @@ -0,0 +1,56 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include "cereal/visionipc/visionipc_client.h" +#include "selfdrive/camerad/cameras/camera_common.h" +#include "selfdrive/common/visionimg.h" +#include "selfdrive/ui/ui.h" + +class CameraViewWidget : public QOpenGLWidget, protected QOpenGLFunctions { + Q_OBJECT + +public: + using QOpenGLWidget::QOpenGLWidget; + explicit CameraViewWidget(std::string stream_name, VisionStreamType stream_type, bool zoom, QWidget* parent = nullptr); + ~CameraViewWidget(); + void setStreamType(VisionStreamType type) { stream_type = type; } + void setBackgroundColor(const QColor &color) { bg = color; } + +signals: + void clicked(); + void vipcThreadConnected(VisionIpcClient *); + void vipcThreadFrameReceived(VisionBuf *); + +protected: + void paintGL() override; + void initializeGL() override; + void resizeGL(int w, int h) override { updateFrameMat(w, h); } + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override { emit clicked(); } + virtual void updateFrameMat(int w, int h); + void vipcThread(); + + bool zoomed_view; + std::atomic latest_texture_id = -1; + GLuint frame_vao, frame_vbo, frame_ibo; + mat4 frame_mat; + std::unique_ptr texture[UI_BUF_COUNT]; + std::unique_ptr program; + QColor bg = QColor("#000000"); + + std::string stream_name; + int stream_width = 0; + int stream_height = 0; + std::atomic stream_type; + QThread *vipc_thread = nullptr; + + +protected slots: + void vipcConnected(VisionIpcClient *vipc_client); +}; diff --git a/selfdrive/ui/qt/widgets/controls.cc b/selfdrive/ui/qt/widgets/controls.cc new file mode 100644 index 00000000000000..da4e4d7955a99f --- /dev/null +++ b/selfdrive/ui/qt/widgets/controls.cc @@ -0,0 +1,123 @@ +#include "selfdrive/ui/qt/widgets/controls.h" + +#include +#include + +QFrame *horizontal_line(QWidget *parent) { + QFrame *line = new QFrame(parent); + line->setFrameShape(QFrame::StyledPanel); + line->setStyleSheet(R"( + margin-left: 40px; + margin-right: 40px; + border-width: 1px; + border-bottom-style: solid; + border-color: gray; + )"); + line->setFixedHeight(2); + return line; +} + +AbstractControl::AbstractControl(const QString &title, const QString &desc, const QString &icon, QWidget *parent) : QFrame(parent) { + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); + + QVBoxLayout *main_layout = new QVBoxLayout(this); + main_layout->setMargin(0); + + hlayout = new QHBoxLayout; + hlayout->setMargin(0); + hlayout->setSpacing(20); + + // left icon + if (!icon.isEmpty()) { + QPixmap pix(icon); + QLabel *icon_label = new QLabel(); + icon_label->setPixmap(pix.scaledToWidth(80, Qt::SmoothTransformation)); + icon_label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + hlayout->addWidget(icon_label); + } + + // title + title_label = new QPushButton(title); + title_label->setFixedHeight(120); + title_label->setStyleSheet("border:none; font-size: 50px; font-weight: 400; text-align: left"); + hlayout->addWidget(title_label); + + main_layout->addLayout(hlayout); + + // description + if (!desc.isEmpty()) { + description = new QLabel(desc); + description->setContentsMargins(40, 20, 40, 20); + description->setStyleSheet("font-size: 40px; color: grey"); + description->setWordWrap(true); + description->setVisible(false); + main_layout->addWidget(description); + + connect(title_label, &QPushButton::clicked, [=]() { + if (!description->isVisible()) { + emit showDescription(); + } + description->setVisible(!description->isVisible()); + }); + } + main_layout->addStretch(); +} + +void AbstractControl::hideEvent(QHideEvent *e) { + if(description != nullptr) { + description->hide(); + } +} + +// controls + +ButtonControl::ButtonControl(const QString &title, const QString &text, const QString &desc, QWidget *parent) : AbstractControl(title, desc, "", parent) { + btn.setText(text); + btn.setStyleSheet(R"( + QPushButton { + padding: 0; + border-radius: 50px; + font-size: 35px; + font-weight: 500; + color: #E4E4E4; + background-color: #393939; + } + QPushButton:pressed { + background-color: #4a4a4a; + } + QPushButton:disabled { + color: #33E4E4E4; + } + )"); + btn.setFixedSize(250, 100); + QObject::connect(&btn, &QPushButton::clicked, this, &ButtonControl::clicked); + hlayout->addWidget(&btn); +} + +// ElidedLabel + +ElidedLabel::ElidedLabel(QWidget *parent) : ElidedLabel({}, parent) {} + +ElidedLabel::ElidedLabel(const QString &text, QWidget *parent) : QLabel(text.trimmed(), parent) { + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + setMinimumWidth(1); +} + +void ElidedLabel::resizeEvent(QResizeEvent* event) { + QLabel::resizeEvent(event); + lastText_ = elidedText_ = ""; +} + +void ElidedLabel::paintEvent(QPaintEvent *event) { + const QString curText = text(); + if (curText != lastText_) { + elidedText_ = fontMetrics().elidedText(curText, Qt::ElideRight, contentsRect().width()); + lastText_ = curText; + } + + QPainter painter(this); + drawFrame(&painter); + QStyleOption opt; + opt.initFrom(this); + style()->drawItemText(&painter, contentsRect(), alignment(), opt.palette, isEnabled(), elidedText_, foregroundRole()); +} diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h new file mode 100644 index 00000000000000..b793326056008b --- /dev/null +++ b/selfdrive/ui/qt/widgets/controls.h @@ -0,0 +1,163 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/ui/qt/widgets/toggle.h" + +QFrame *horizontal_line(QWidget *parent = nullptr); + +class ElidedLabel : public QLabel { + Q_OBJECT + +public: + explicit ElidedLabel(QWidget *parent = 0); + explicit ElidedLabel(const QString &text, QWidget *parent = 0); + +signals: + void clicked(); + +protected: + void paintEvent(QPaintEvent *event) override; + void resizeEvent(QResizeEvent* event) override; + void mouseReleaseEvent(QMouseEvent *event) override { emit clicked(); } + QString lastText_, elidedText_; +}; + + +class AbstractControl : public QFrame { + Q_OBJECT + +public: + void setDescription(const QString &desc) { + if (description) description->setText(desc); + } + + void setTitle(const QString &title) { + title_label->setText(title); + } + +signals: + void showDescription(); + +protected: + AbstractControl(const QString &title, const QString &desc = "", const QString &icon = "", QWidget *parent = nullptr); + void hideEvent(QHideEvent *e) override; + + QHBoxLayout *hlayout; + QPushButton *title_label; + QLabel *description = nullptr; +}; + +// widget to display a value +class LabelControl : public AbstractControl { + Q_OBJECT + +public: + LabelControl(const QString &title, const QString &text = "", const QString &desc = "", QWidget *parent = nullptr) : AbstractControl(title, desc, "", parent) { + label.setText(text); + label.setAlignment(Qt::AlignRight | Qt::AlignVCenter); + hlayout->addWidget(&label); + } + void setText(const QString &text) { label.setText(text); } + +private: + ElidedLabel label; +}; + +// widget for a button with a label +class ButtonControl : public AbstractControl { + Q_OBJECT + +public: + ButtonControl(const QString &title, const QString &text, const QString &desc = "", QWidget *parent = nullptr); + inline void setText(const QString &text) { btn.setText(text); } + inline QString text() const { return btn.text(); } + +signals: + void clicked(); + +public slots: + void setEnabled(bool enabled) { btn.setEnabled(enabled); }; + +private: + QPushButton btn; +}; + +class ToggleControl : public AbstractControl { + Q_OBJECT + +public: + ToggleControl(const QString &title, const QString &desc = "", const QString &icon = "", const bool state = false, QWidget *parent = nullptr) : AbstractControl(title, desc, icon, parent) { + toggle.setFixedSize(150, 100); + if (state) { + toggle.togglePosition(); + } + hlayout->addWidget(&toggle); + QObject::connect(&toggle, &Toggle::stateChanged, this, &ToggleControl::toggleFlipped); + } + + void setEnabled(bool enabled) { toggle.setEnabled(enabled); } + +signals: + void toggleFlipped(bool state); + +protected: + Toggle toggle; +}; + +// widget to toggle params +class ParamControl : public ToggleControl { + Q_OBJECT + +public: + ParamControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr) : ToggleControl(title, desc, icon, false, parent) { + key = param.toStdString(); + QObject::connect(this, &ToggleControl::toggleFlipped, [=](bool state) { + params.putBool(key, state); + }); + } + + void showEvent(QShowEvent *event) override { + if (params.getBool(key) != toggle.on) { + toggle.togglePosition(); + } + }; + +private: + std::string key; + Params params; +}; + +class ListWidget : public QWidget { + Q_OBJECT + public: + explicit ListWidget(QWidget *parent = 0) : QWidget(parent), outer_layout(this) { + outer_layout.setMargin(0); + outer_layout.setSpacing(0); + outer_layout.addLayout(&inner_layout); + inner_layout.setMargin(0); + inner_layout.setSpacing(25); // default spacing is 25 + outer_layout.addStretch(); + } + inline void addItem(QWidget *w) { inner_layout.addWidget(w); } + inline void addItem(QLayout *layout) { inner_layout.addLayout(layout); } + inline void setSpacing(int spacing) { inner_layout.setSpacing(spacing); } + +private: + void paintEvent(QPaintEvent *) override { + QPainter p(this); + p.setPen(Qt::gray); + for (int i = 0; i < inner_layout.count() - 1; ++i) { + QRect r = inner_layout.itemAt(i)->geometry(); + int bottom = r.bottom() + inner_layout.spacing() / 2; + p.drawLine(r.left() + 40, bottom, r.right() - 40, bottom); + } + } + QVBoxLayout outer_layout; + QVBoxLayout inner_layout; +}; diff --git a/selfdrive/ui/qt/widgets/drive_stats.cc b/selfdrive/ui/qt/widgets/drive_stats.cc new file mode 100644 index 00000000000000..f4c8f502a36b65 --- /dev/null +++ b/selfdrive/ui/qt/widgets/drive_stats.cc @@ -0,0 +1,97 @@ +#include "selfdrive/ui/qt/widgets/drive_stats.h" + +#include +#include +#include +#include + +#include "selfdrive/common/params.h" +#include "selfdrive/ui/qt/request_repeater.h" +#include "selfdrive/ui/qt/util.h" + +static QLabel* newLabel(const QString& text, const QString &type) { + QLabel* label = new QLabel(text); + label->setProperty("type", type); + return label; +} + +DriveStats::DriveStats(QWidget* parent) : QFrame(parent) { + metric_ = Params().getBool("IsMetric"); + + QVBoxLayout* main_layout = new QVBoxLayout(this); + main_layout->setContentsMargins(50, 50, 50, 60); + + auto add_stats_layouts = [=](const QString &title, StatsLabels& labels) { + QGridLayout* grid_layout = new QGridLayout; + grid_layout->setVerticalSpacing(10); + grid_layout->setContentsMargins(0, 10, 0, 10); + + int row = 0; + grid_layout->addWidget(newLabel(title, "title"), row++, 0, 1, 3); + grid_layout->addItem(new QSpacerItem(0, 50), row++, 0, 1, 1); + + grid_layout->addWidget(labels.routes = newLabel("0", "number"), row, 0, Qt::AlignLeft); + grid_layout->addWidget(labels.distance = newLabel("0", "number"), row, 1, Qt::AlignLeft); + grid_layout->addWidget(labels.hours = newLabel("0", "number"), row, 2, Qt::AlignLeft); + + grid_layout->addWidget(newLabel("Drives", "unit"), row + 1, 0, Qt::AlignLeft); + grid_layout->addWidget(labels.distance_unit = newLabel(getDistanceUnit(), "unit"), row + 1, 1, Qt::AlignLeft); + grid_layout->addWidget(newLabel("Hours ", "unit"), row + 1, 2, Qt::AlignLeft); + + main_layout->addLayout(grid_layout); + }; + + add_stats_layouts("ALL TIME", all_); + main_layout->addStretch(); + add_stats_layouts("PAST WEEK", week_); + + if (auto dongleId = getDongleId()) { + QString url = CommaApi::BASE_URL + "/v1.1/devices/" + *dongleId + "/stats"; + RequestRepeater* repeater = new RequestRepeater(this, url, "ApiCache_DriveStats", 30); + QObject::connect(repeater, &RequestRepeater::requestDone, this, &DriveStats::parseResponse); + } + + setStyleSheet(R"( + DriveStats { + background-color: #333333; + border-radius: 10px; + } + + QLabel[type="title"] { font-size: 51px; font-weight: 500; } + QLabel[type="number"] { font-size: 78px; font-weight: 500; } + QLabel[type="unit"] { font-size: 51px; font-weight: 300; color: #A0A0A0; } + )"); +} + +void DriveStats::updateStats() { + auto update = [=](const QJsonObject& obj, StatsLabels& labels) { + labels.routes->setText(QString::number((int)obj["routes"].toDouble())); + labels.distance->setText(QString::number(int(obj["distance"].toDouble() * (metric_ ? MILE_TO_KM : 1)))); + labels.distance_unit->setText(getDistanceUnit()); + labels.hours->setText(QString::number((int)(obj["minutes"].toDouble() / 60))); + }; + + QJsonObject json = stats_.object(); + update(json["all"].toObject(), all_); + update(json["week"].toObject(), week_); +} + +void DriveStats::parseResponse(const QString& response, bool success) { + if (!success) return; + + QJsonDocument doc = QJsonDocument::fromJson(response.trimmed().toUtf8()); + if (doc.isNull()) { + qDebug() << "JSON Parse failed on getting past drives statistics"; + return; + } + stats_ = doc; + updateStats(); +} + +void DriveStats::showEvent(QShowEvent* event) { + bool metric = Params().getBool("IsMetric"); + if (metric_ != metric) { + metric_ = metric; + updateStats(); + } +} diff --git a/selfdrive/ui/qt/widgets/drive_stats.h b/selfdrive/ui/qt/widgets/drive_stats.h new file mode 100644 index 00000000000000..9446294516be6b --- /dev/null +++ b/selfdrive/ui/qt/widgets/drive_stats.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +class DriveStats : public QFrame { + Q_OBJECT + +public: + explicit DriveStats(QWidget* parent = 0); + +private: + void showEvent(QShowEvent *event) override; + void updateStats(); + inline QString getDistanceUnit() const { return metric_ ? "KM" : "Miles"; } + + bool metric_; + QJsonDocument stats_; + struct StatsLabels { + QLabel *routes, *distance, *distance_unit, *hours; + } all_, week_; + +private slots: + void parseResponse(const QString &response, bool success); +}; diff --git a/selfdrive/ui/qt/widgets/input.cc b/selfdrive/ui/qt/widgets/input.cc new file mode 100644 index 00000000000000..1122faf4c75d0e --- /dev/null +++ b/selfdrive/ui/qt/widgets/input.cc @@ -0,0 +1,259 @@ +#include "selfdrive/ui/qt/widgets/input.h" + +#include + +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/widgets/scrollview.h" + + +QDialogBase::QDialogBase(QWidget *parent) : QDialog(parent) { + Q_ASSERT(parent != nullptr); + parent->installEventFilter(this); + + setStyleSheet(R"( + * { + outline: none; + color: white; + font-family: Inter; + } + QDialogBase { + background-color: black; + } + QPushButton { + height: 160; + font-size: 55px; + font-weight: 400; + border-radius: 10px; + color: white; + background-color: #333333; + } + QPushButton:pressed { + background-color: #444444; + } + )"); +} + +bool QDialogBase::eventFilter(QObject *o, QEvent *e) { + if (o == parent() && e->type() == QEvent::Hide) { + reject(); + } + return QDialog::eventFilter(o, e); +} + +int QDialogBase::exec() { + setMainWindow(this); + return QDialog::exec(); +} + +InputDialog::InputDialog(const QString &title, QWidget *parent, const QString &subtitle, bool secret) : QDialogBase(parent) { + main_layout = new QVBoxLayout(this); + main_layout->setContentsMargins(50, 55, 50, 50); + main_layout->setSpacing(0); + + // build header + QHBoxLayout *header_layout = new QHBoxLayout(); + + QVBoxLayout *vlayout = new QVBoxLayout; + header_layout->addLayout(vlayout); + label = new QLabel(title, this); + label->setStyleSheet("font-size: 90px; font-weight: bold;"); + vlayout->addWidget(label, 1, Qt::AlignTop | Qt::AlignLeft); + + if (!subtitle.isEmpty()) { + sublabel = new QLabel(subtitle, this); + sublabel->setStyleSheet("font-size: 55px; font-weight: light; color: #BDBDBD;"); + vlayout->addWidget(sublabel, 1, Qt::AlignTop | Qt::AlignLeft); + } + + QPushButton* cancel_btn = new QPushButton("Cancel"); + cancel_btn->setFixedSize(386, 125); + cancel_btn->setStyleSheet(R"( + font-size: 48px; + border-radius: 10px; + color: #E4E4E4; + background-color: #444444; + )"); + header_layout->addWidget(cancel_btn, 0, Qt::AlignRight); + QObject::connect(cancel_btn, &QPushButton::clicked, this, &InputDialog::reject); + QObject::connect(cancel_btn, &QPushButton::clicked, this, &InputDialog::cancel); + + main_layout->addLayout(header_layout); + + // text box + main_layout->addStretch(2); + + QWidget *textbox_widget = new QWidget; + textbox_widget->setObjectName("textbox"); + QHBoxLayout *textbox_layout = new QHBoxLayout(textbox_widget); + textbox_layout->setContentsMargins(50, 0, 50, 0); + + textbox_widget->setStyleSheet(R"( + #textbox { + margin-left: 50px; + margin-right: 50px; + border-radius: 0; + border-bottom: 3px solid #BDBDBD; + } + * { + border: none; + font-size: 80px; + font-weight: light; + background-color: transparent; + } + )"); + + line = new QLineEdit(); + line->setStyleSheet("lineedit-password-character: 8226; lineedit-password-mask-delay: 1500;"); + textbox_layout->addWidget(line, 1); + + if (secret) { + eye_btn = new QPushButton(); + eye_btn->setCheckable(true); + eye_btn->setFixedSize(150, 120); + QObject::connect(eye_btn, &QPushButton::toggled, [=](bool checked) { + if (checked) { + eye_btn->setIcon(QIcon(ASSET_PATH + "img_eye_closed.svg")); + eye_btn->setIconSize(QSize(81, 54)); + line->setEchoMode(QLineEdit::Password); + } else { + eye_btn->setIcon(QIcon(ASSET_PATH + "img_eye_open.svg")); + eye_btn->setIconSize(QSize(81, 44)); + line->setEchoMode(QLineEdit::Normal); + } + }); + eye_btn->setChecked(true); + textbox_layout->addWidget(eye_btn); + } + + main_layout->addWidget(textbox_widget, 0, Qt::AlignBottom); + main_layout->addSpacing(25); + + k = new Keyboard(this); + QObject::connect(k, &Keyboard::emitEnter, this, &InputDialog::handleEnter); + QObject::connect(k, &Keyboard::emitBackspace, this, [=]() { + line->backspace(); + }); + QObject::connect(k, &Keyboard::emitKey, this, [=](const QString &key) { + line->insert(key.left(1)); + }); + + main_layout->addWidget(k, 2, Qt::AlignBottom); +} + +QString InputDialog::getText(const QString &prompt, QWidget *parent, const QString &subtitle, + bool secret, int minLength, const QString &defaultText) { + InputDialog d = InputDialog(prompt, parent, subtitle, secret); + d.line->setText(defaultText); + d.setMinLength(minLength); + const int ret = d.exec(); + return ret ? d.text() : QString(); +} + +QString InputDialog::text() { + return line->text(); +} + +void InputDialog::show() { + setMainWindow(this); +} + +void InputDialog::handleEnter() { + if (line->text().length() >= minLength) { + done(QDialog::Accepted); + emitText(line->text()); + } else { + setMessage("Need at least "+QString::number(minLength)+" characters!", false); + } +} + +void InputDialog::setMessage(const QString &message, bool clearInputField) { + label->setText(message); + if (clearInputField) { + line->setText(""); + } +} + +void InputDialog::setMinLength(int length) { + minLength = length; +} + +// ConfirmationDialog + +ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text, + QWidget *parent) : QDialogBase(parent) { + QFrame *container = new QFrame(this); + container->setStyleSheet("QFrame { border-radius: 0; background-color: #ECECEC; }"); + QVBoxLayout *main_layout = new QVBoxLayout(container); + main_layout->setContentsMargins(32, 120, 32, 32); + + QLabel *prompt = new QLabel(prompt_text, this); + prompt->setWordWrap(true); + prompt->setAlignment(Qt::AlignHCenter); + prompt->setStyleSheet("font-size: 70px; font-weight: bold; color: black;"); + main_layout->addWidget(prompt, 1, Qt::AlignTop | Qt::AlignHCenter); + + // cancel + confirm buttons + QHBoxLayout *btn_layout = new QHBoxLayout(); + btn_layout->setSpacing(30); + main_layout->addLayout(btn_layout); + + if (cancel_text.length()) { + QPushButton* cancel_btn = new QPushButton(cancel_text); + btn_layout->addWidget(cancel_btn); + QObject::connect(cancel_btn, &QPushButton::clicked, this, &ConfirmationDialog::reject); + } + + if (confirm_text.length()) { + QPushButton* confirm_btn = new QPushButton(confirm_text); + btn_layout->addWidget(confirm_btn); + QObject::connect(confirm_btn, &QPushButton::clicked, this, &ConfirmationDialog::accept); + } + + QVBoxLayout *outer_layout = new QVBoxLayout(this); + outer_layout->setContentsMargins(210, 170, 210, 170); + outer_layout->addWidget(container); +} + +bool ConfirmationDialog::alert(const QString &prompt_text, QWidget *parent) { + ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "", parent); + return d.exec(); +} + +bool ConfirmationDialog::confirm(const QString &prompt_text, QWidget *parent) { + ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "Cancel", parent); + return d.exec(); +} + + +// RichTextDialog + +RichTextDialog::RichTextDialog(const QString &prompt_text, const QString &btn_text, + QWidget *parent) : QDialogBase(parent) { + QFrame *container = new QFrame(this); + container->setStyleSheet("QFrame { background-color: #1B1B1B; }"); + QVBoxLayout *main_layout = new QVBoxLayout(container); + main_layout->setContentsMargins(32, 32, 32, 32); + + QLabel *prompt = new QLabel(prompt_text, this); + prompt->setWordWrap(true); + prompt->setAlignment(Qt::AlignLeft); + prompt->setTextFormat(Qt::RichText); + prompt->setStyleSheet("font-size: 42px; font-weight: light; color: #C9C9C9; margin: 45px;"); + main_layout->addWidget(new ScrollView(prompt, this), 1, Qt::AlignTop); + + // confirm button + QPushButton* confirm_btn = new QPushButton(btn_text); + main_layout->addWidget(confirm_btn); + QObject::connect(confirm_btn, &QPushButton::clicked, this, &QDialog::accept); + + QVBoxLayout *outer_layout = new QVBoxLayout(this); + outer_layout->setContentsMargins(100, 100, 100, 100); + outer_layout->addWidget(container); +} + +bool RichTextDialog::alert(const QString &prompt_text, QWidget *parent) { + auto d = RichTextDialog(prompt_text, "Ok", parent); + return d.exec(); +} diff --git a/selfdrive/ui/qt/widgets/input.h b/selfdrive/ui/qt/widgets/input.h new file mode 100644 index 00000000000000..f81211d0eed73d --- /dev/null +++ b/selfdrive/ui/qt/widgets/input.h @@ -0,0 +1,70 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "selfdrive/ui/qt/widgets/keyboard.h" + + +class QDialogBase : public QDialog { + Q_OBJECT + +protected: + QDialogBase(QWidget *parent); + bool eventFilter(QObject *o, QEvent *e) override; + +public slots: + int exec() override; +}; + +class InputDialog : public QDialogBase { + Q_OBJECT + +public: + explicit InputDialog(const QString &title, QWidget *parent, const QString &subtitle = "", bool secret = false); + static QString getText(const QString &title, QWidget *parent, const QString &substitle = "", + bool secret = false, int minLength = -1, const QString &defaultText = ""); + QString text(); + void setMessage(const QString &message, bool clearInputField = true); + void setMinLength(int length); + void show(); + +private: + int minLength; + QLineEdit *line; + Keyboard *k; + QLabel *label; + QLabel *sublabel; + QVBoxLayout *main_layout; + QPushButton *eye_btn; + +private slots: + void handleEnter(); + +signals: + void cancel(); + void emitText(const QString &text); +}; + +class ConfirmationDialog : public QDialogBase { + Q_OBJECT + +public: + explicit ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, + const QString &cancel_text, QWidget* parent); + static bool alert(const QString &prompt_text, QWidget *parent); + static bool confirm(const QString &prompt_text, QWidget *parent); +}; + +// larger ConfirmationDialog for rich text +class RichTextDialog : public QDialogBase { + Q_OBJECT + +public: + explicit RichTextDialog(const QString &prompt_text, const QString &btn_text, QWidget* parent); + static bool alert(const QString &prompt_text, QWidget *parent); +}; diff --git a/selfdrive/ui/qt/widgets/keyboard.cc b/selfdrive/ui/qt/widgets/keyboard.cc new file mode 100644 index 00000000000000..1c596865353c85 --- /dev/null +++ b/selfdrive/ui/qt/widgets/keyboard.cc @@ -0,0 +1,160 @@ +#include "selfdrive/ui/qt/widgets/keyboard.h" + +#include + +#include +#include +#include +#include +#include + +const QString BACKSPACE_KEY = "⌫"; +const QString ENTER_KEY = "→"; + +const QMap KEY_STRETCH = {{" ", 5}, {ENTER_KEY, 2}}; + +const QStringList CONTROL_BUTTONS = {"↑", "↓", "ABC", "#+=", "123", BACKSPACE_KEY, ENTER_KEY}; + +const float key_spacing_vertical = 20; +const float key_spacing_horizontal = 15; + +KeyButton::KeyButton(const QString &text, QWidget *parent) : QPushButton(text, parent) { + setAttribute(Qt::WA_AcceptTouchEvents); + setFocusPolicy(Qt::NoFocus); +} + +bool KeyButton::event(QEvent *event) { + if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchEnd) { + QTouchEvent *touchEvent = static_cast(event); + if (!touchEvent->touchPoints().empty()) { + const QEvent::Type mouseType = event->type() == QEvent::TouchBegin ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + QMouseEvent mouseEvent(mouseType, touchEvent->touchPoints().front().pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QPushButton::event(&mouseEvent); + event->accept(); + parentWidget()->update(); + return true; + } + } + return QPushButton::event(event); +} + +KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector>& layout) : QWidget(parent) { + QVBoxLayout* main_layout = new QVBoxLayout(this); + main_layout->setMargin(0); + main_layout->setSpacing(0); + + QButtonGroup* btn_group = new QButtonGroup(this); + QObject::connect(btn_group, SIGNAL(buttonClicked(QAbstractButton*)), parent, SLOT(handleButton(QAbstractButton*))); + + for (const auto &s : layout) { + QHBoxLayout *hlayout = new QHBoxLayout; + hlayout->setSpacing(0); + + if (main_layout->count() == 1) { + hlayout->addSpacing(90); + } + + for (const QString &p : s) { + KeyButton* btn = new KeyButton(p); + if (p == BACKSPACE_KEY) { + btn->setAutoRepeat(true); + } else if (p == ENTER_KEY) { + btn->setStyleSheet("background-color: #465BEA;"); + } + btn->setFixedHeight(135 + key_spacing_vertical); + btn_group->addButton(btn); + hlayout->addWidget(btn, KEY_STRETCH.value(p, 1)); + } + + if (main_layout->count() == 1) { + hlayout->addSpacing(90); + } + + main_layout->addLayout(hlayout); + } + + setStyleSheet(QString(R"( + QPushButton { + font-size: 75px; + margin-left: %1px; + margin-right: %1px; + margin-top: %2px; + margin-bottom: %2px; + padding: 0px; + border-radius: 10px; + color: #dddddd; + background-color: #444444; + } + QPushButton:pressed { + background-color: #333333; + } + )").arg(key_spacing_vertical / 2).arg(key_spacing_horizontal / 2)); +} + +Keyboard::Keyboard(QWidget *parent) : QFrame(parent) { + main_layout = new QStackedLayout(this); + main_layout->setMargin(0); + + // 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",BACKSPACE_KEY}, + {"123"," ",".",ENTER_KEY}, + }; + 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",BACKSPACE_KEY}, + {"123"," ",".",ENTER_KEY}, + }; + main_layout->addWidget(new KeyboardLayout(this, uppercase)); + + // numbers + specials + std::vector> numbers = { + {"1","2","3","4","5","6","7","8","9","0"}, + {"-","/",":",";","(",")","$","&&","@","\""}, + {"#+=",".",",","?","!","`",BACKSPACE_KEY}, + {"ABC"," ",".",ENTER_KEY}, + }; + main_layout->addWidget(new KeyboardLayout(this, numbers)); + + // extra specials + std::vector> specials = { + {"[","]","{","}","#","%","^","*","+","="}, + {"_","\\","|","~","<",">","€","£","Â¥","•"}, + {"123",".",",","?","!","'",BACKSPACE_KEY}, + {"ABC"," ",".",ENTER_KEY}, + }; + main_layout->addWidget(new KeyboardLayout(this, specials)); + + main_layout->setCurrentIndex(0); +} + +void Keyboard::handleButton(QAbstractButton* btn) { + const QString &key = btn->text(); + if (CONTROL_BUTTONS.contains(key)) { + if (key == "↓" || key == "ABC") { + main_layout->setCurrentIndex(0); + } else if (key == "↑") { + main_layout->setCurrentIndex(1); + } else if (key == "123") { + main_layout->setCurrentIndex(2); + } else if (key == "#+=") { + main_layout->setCurrentIndex(3); + } else if (key == ENTER_KEY) { + main_layout->setCurrentIndex(0); + emit emitEnter(); + } else if (key == BACKSPACE_KEY) { + emit emitBackspace(); + } + } else { + if ("A" <= key && key <= "Z") { + main_layout->setCurrentIndex(0); + } + emit emitKey(key); + } +} diff --git a/selfdrive/ui/qt/widgets/keyboard.h b/selfdrive/ui/qt/widgets/keyboard.h new file mode 100644 index 00000000000000..516105719bd712 --- /dev/null +++ b/selfdrive/ui/qt/widgets/keyboard.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +class KeyButton : public QPushButton { + Q_OBJECT + +public: + KeyButton(const QString &text, QWidget *parent = 0); + bool event(QEvent *event) override; +}; + +class KeyboardLayout : public QWidget { + Q_OBJECT + +public: + explicit KeyboardLayout(QWidget* parent, const std::vector>& layout); +}; + +class Keyboard : public QFrame { + Q_OBJECT + +public: + explicit Keyboard(QWidget *parent = 0); + +private: + QStackedLayout* main_layout; + +private slots: + void handleButton(QAbstractButton* m_button); + +signals: + void emitKey(const QString &s); + void emitBackspace(); + void emitEnter(); +}; diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.cc b/selfdrive/ui/qt/widgets/offroad_alerts.cc new file mode 100644 index 00000000000000..2d7ae39c36db36 --- /dev/null +++ b/selfdrive/ui/qt/widgets/offroad_alerts.cc @@ -0,0 +1,118 @@ +#include "selfdrive/ui/qt/widgets/offroad_alerts.h" + +#include +#include +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/widgets/scrollview.h" + +AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent) { + QVBoxLayout *main_layout = new QVBoxLayout(this); + main_layout->setMargin(50); + main_layout->setSpacing(30); + + QWidget *widget = new QWidget; + scrollable_layout = new QVBoxLayout(widget); + widget->setStyleSheet("background-color: transparent;"); + main_layout->addWidget(new ScrollView(widget)); + + // bottom footer, dismiss + reboot buttons + QHBoxLayout *footer_layout = new QHBoxLayout(); + main_layout->addLayout(footer_layout); + + QPushButton *dismiss_btn = new QPushButton("Close"); + dismiss_btn->setFixedSize(400, 125); + footer_layout->addWidget(dismiss_btn, 0, Qt::AlignBottom | Qt::AlignLeft); + QObject::connect(dismiss_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); + + snooze_btn = new QPushButton("Snooze Update"); + snooze_btn->setVisible(false); + snooze_btn->setFixedSize(550, 125); + footer_layout->addWidget(snooze_btn, 0, Qt::AlignBottom | Qt::AlignRight); + QObject::connect(snooze_btn, &QPushButton::clicked, [=]() { + params.putBool("SnoozeUpdate", true); + }); + QObject::connect(snooze_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); + snooze_btn->setStyleSheet(R"(color: white; background-color: #4F4F4F;)"); + + if (hasRebootBtn) { + QPushButton *rebootBtn = new QPushButton("Reboot and Update"); + rebootBtn->setFixedSize(600, 125); + footer_layout->addWidget(rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight); + QObject::connect(rebootBtn, &QPushButton::clicked, [=]() { Hardware::reboot(); }); + } + + setStyleSheet(R"( + * { + font-size: 48px; + color: white; + } + QFrame { + border-radius: 30px; + background-color: #393939; + } + QPushButton { + color: black; + font-weight: 500; + border-radius: 30px; + background-color: white; + } + )"); +} + +int OffroadAlert::refresh() { + // build widgets for each offroad alert on first refresh + if (alerts.empty()) { + QString json = util::read_file("../controls/lib/alerts_offroad.json").c_str(); + QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object(); + + // descending sort labels by severity + std::vector> sorted; + for (auto it = obj.constBegin(); it != obj.constEnd(); ++it) { + sorted.push_back({it.key().toStdString(), it.value()["severity"].toInt()}); + } + std::sort(sorted.begin(), sorted.end(), [=](auto &l, auto &r) { return l.second > r.second; }); + + for (auto &[key, severity] : sorted) { + QLabel *l = new QLabel(this); + alerts[key] = l; + l->setMargin(60); + l->setWordWrap(true); + l->setStyleSheet(QString("background-color: %1").arg(severity ? "#E22C2C" : "#292929")); + scrollable_layout->addWidget(l); + } + scrollable_layout->addStretch(1); + } + + int alertCount = 0; + for (const auto &[key, label] : alerts) { + QString text; + std::string bytes = params.get(key); + if (bytes.size()) { + auto doc_par = QJsonDocument::fromJson(bytes.c_str()); + text = doc_par["text"].toString(); + } + label->setText(text); + label->setVisible(!text.isEmpty()); + alertCount += !text.isEmpty(); + } + snooze_btn->setVisible(!alerts["Offroad_ConnectivityNeeded"]->text().isEmpty()); + return alertCount; +} + +UpdateAlert::UpdateAlert(QWidget *parent) : AbstractAlert(true, parent) { + releaseNotes = new QLabel(this); + releaseNotes->setWordWrap(true); + releaseNotes->setAlignment(Qt::AlignTop); + scrollable_layout->addWidget(releaseNotes); +} + +bool UpdateAlert::refresh() { + bool updateAvailable = params.getBool("UpdateAvailable"); + if (updateAvailable) { + releaseNotes->setText(params.get("ReleaseNotes").c_str()); + } + return updateAvailable; +} diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.h b/selfdrive/ui/qt/widgets/offroad_alerts.h new file mode 100644 index 00000000000000..4110bdaa4efcc0 --- /dev/null +++ b/selfdrive/ui/qt/widgets/offroad_alerts.h @@ -0,0 +1,45 @@ +#pragma once + +#include + +#include +#include +#include + +#include "selfdrive/common/params.h" + +class AbstractAlert : public QFrame { + Q_OBJECT + +protected: + AbstractAlert(bool hasRebootBtn, QWidget *parent = nullptr); + + QPushButton *snooze_btn; + QVBoxLayout *scrollable_layout; + Params params; + +signals: + void dismiss(); +}; + +class UpdateAlert : public AbstractAlert { + Q_OBJECT + +public: + UpdateAlert(QWidget *parent = 0); + bool refresh(); + +private: + QLabel *releaseNotes = nullptr; +}; + +class OffroadAlert : public AbstractAlert { + Q_OBJECT + +public: + explicit OffroadAlert(QWidget *parent = 0) : AbstractAlert(false, parent) {} + int refresh(); + +private: + std::map alerts; +}; diff --git a/selfdrive/ui/qt/widgets/prime.cc b/selfdrive/ui/qt/widgets/prime.cc new file mode 100644 index 00000000000000..ab6dc67d36003d --- /dev/null +++ b/selfdrive/ui/qt/widgets/prime.cc @@ -0,0 +1,328 @@ +#include "selfdrive/ui/qt/widgets/prime.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "selfdrive/ui/qt/request_repeater.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/qt_window.h" + +using qrcodegen::QrCode; + +PairingQRWidget::PairingQRWidget(QWidget* parent) : QWidget(parent) { + QTimer* timer = new QTimer(this); + timer->start(5 * 60 * 1000); + connect(timer, &QTimer::timeout, this, &PairingQRWidget::refresh); +} + +void PairingQRWidget::showEvent(QShowEvent *event) { + refresh(); +} + +void PairingQRWidget::refresh() { + if (isVisible()) { + QString pairToken = CommaApi::create_jwt({{"pair", true}}); + QString qrString = "https://connect.comma.ai/?pair=" + pairToken; + this->updateQrCode(qrString); + } +} + +void PairingQRWidget::updateQrCode(const QString &text) { + QrCode qr = QrCode::encodeText(text.toUtf8().data(), QrCode::Ecc::LOW); + qint32 sz = qr.getSize(); + QImage im(sz, sz, QImage::Format_RGB32); + + QRgb black = qRgb(0, 0, 0); + QRgb white = qRgb(255, 255, 255); + for (int y = 0; y < sz; y++) { + for (int x = 0; x < sz; x++) { + im.setPixel(x, y, qr.getModule(x, y) ? black : white); + } + } + + // Integer division to prevent anti-aliasing + int final_sz = ((width() / sz) - 1) * sz; + img = QPixmap::fromImage(im.scaled(final_sz, final_sz, Qt::KeepAspectRatio), Qt::MonoOnly); +} + +void PairingQRWidget::paintEvent(QPaintEvent *e) { + QPainter p(this); + p.fillRect(rect(), Qt::white); + + QSize s = (size() - img.size()) / 2; + p.drawPixmap(s.width(), s.height(), img); +} + + +PairingPopup::PairingPopup(QWidget *parent) : QDialogBase(parent) { + QHBoxLayout *hlayout = new QHBoxLayout(this); + hlayout->setContentsMargins(0, 0, 0, 0); + hlayout->setSpacing(0); + + setStyleSheet("PairingPopup { background-color: #E0E0E0; }"); + + // text + QVBoxLayout *vlayout = new QVBoxLayout(); + vlayout->setContentsMargins(85, 70, 50, 70); + vlayout->setSpacing(50); + hlayout->addLayout(vlayout, 1); + { + QPushButton *close = new QPushButton(QIcon(":/icons/close.svg"), "", this); + close->setIconSize(QSize(80, 80)); + close->setStyleSheet("border: none;"); + vlayout->addWidget(close, 0, Qt::AlignLeft); + QObject::connect(close, &QPushButton::clicked, this, &QDialog::reject); + + vlayout->addSpacing(30); + + QLabel *title = new QLabel("Pair your device to your comma account", this); + title->setStyleSheet("font-size: 75px; color: black;"); + title->setWordWrap(true); + vlayout->addWidget(title); + + QLabel *instructions = new QLabel(R"( +
      +
    1. Go to https://connect.comma.ai on your phone
    2. +
    3. Click "add new device" and scan the QR code on the right
    4. +
    5. Bookmark connect.comma.ai to your home screen to use it like an app
    6. +
    + )", this); + instructions->setStyleSheet("font-size: 47px; font-weight: bold; color: black;"); + instructions->setWordWrap(true); + vlayout->addWidget(instructions); + + vlayout->addStretch(); + } + + // QR code + PairingQRWidget *qr = new PairingQRWidget(this); + hlayout->addWidget(qr, 1); +} + + +PrimeUserWidget::PrimeUserWidget(QWidget* parent) : QWidget(parent) { + mainLayout = new QVBoxLayout(this); + mainLayout->setMargin(0); + mainLayout->setSpacing(30); + + // subscribed prime layout + QWidget *primeWidget = new QWidget; + primeWidget->setObjectName("primeWidget"); + QVBoxLayout *primeLayout = new QVBoxLayout(primeWidget); + primeLayout->setMargin(0); + primeWidget->setContentsMargins(60, 50, 60, 50); + + QLabel* subscribed = new QLabel("✓ SUBSCRIBED"); + subscribed->setStyleSheet("font-size: 41px; font-weight: bold; color: #86FF4E;"); + primeLayout->addWidget(subscribed, 0, Qt::AlignTop); + + primeLayout->addSpacing(60); + + QLabel* commaPrime = new QLabel("comma prime"); + commaPrime->setStyleSheet("font-size: 75px; font-weight: bold;"); + primeLayout->addWidget(commaPrime, 0, Qt::AlignTop); + + primeLayout->addSpacing(20); + + QLabel* connectUrl = new QLabel("CONNECT.COMMA.AI"); + connectUrl->setStyleSheet("font-size: 41px; font-family: Inter SemiBold; color: #A0A0A0;"); + primeLayout->addWidget(connectUrl, 0, Qt::AlignTop); + + mainLayout->addWidget(primeWidget); + + // comma points layout + QWidget *pointsWidget = new QWidget; + pointsWidget->setObjectName("primeWidget"); + QVBoxLayout *pointsLayout = new QVBoxLayout(pointsWidget); + pointsLayout->setMargin(0); + pointsWidget->setContentsMargins(60, 50, 60, 50); + + QLabel* commaPoints = new QLabel("COMMA POINTS"); + commaPoints->setStyleSheet("font-size: 41px; font-family: Inter SemiBold;"); + pointsLayout->addWidget(commaPoints, 0, Qt::AlignTop); + + points = new QLabel("0"); + points->setStyleSheet("font-size: 91px; font-weight: bold;"); + pointsLayout->addWidget(points, 0, Qt::AlignTop); + + mainLayout->addWidget(pointsWidget); + + mainLayout->addStretch(); + + // set up API requests + if (auto dongleId = getDongleId()) { + QString url = CommaApi::BASE_URL + "/v1/devices/" + *dongleId + "/owner"; + RequestRepeater *repeater = new RequestRepeater(this, url, "ApiCache_Owner", 6); + QObject::connect(repeater, &RequestRepeater::requestDone, this, &PrimeUserWidget::replyFinished); + } +} + +void PrimeUserWidget::replyFinished(const QString &response) { + QJsonDocument doc = QJsonDocument::fromJson(response.toUtf8()); + if (doc.isNull()) { + qDebug() << "JSON Parse failed on getting points"; + return; + } + + QJsonObject json = doc.object(); + points->setText(QString::number(json["points"].toInt())); +} + +PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QFrame(parent) { + QVBoxLayout* main_layout = new QVBoxLayout(this); + main_layout->setContentsMargins(80, 90, 80, 60); + main_layout->setSpacing(0); + + QLabel *upgrade = new QLabel("Upgrade Now"); + upgrade->setStyleSheet("font-size: 75px; font-weight: bold;"); + main_layout->addWidget(upgrade, 0, Qt::AlignTop); + main_layout->addSpacing(50); + + QLabel *description = new QLabel("Become a comma prime member at connect.comma.ai"); + description->setStyleSheet("font-size: 60px; font-weight: light; color: white;"); + description->setWordWrap(true); + main_layout->addWidget(description, 0, Qt::AlignTop); + + main_layout->addStretch(); + + QLabel *features = new QLabel("PRIME FEATURES:"); + features->setStyleSheet("font-size: 41px; font-weight: bold; color: #E5E5E5;"); + main_layout->addWidget(features, 0, Qt::AlignBottom); + main_layout->addSpacing(30); + + QVector bullets = {"Remote access", "14 days of storage", "Developer perks"}; + for (auto &b: bullets) { + const QString check = "✓ "; + QLabel *l = new QLabel(check + b); + l->setAlignment(Qt::AlignLeft); + l->setStyleSheet("font-size: 50px; margin-bottom: 15px;"); + main_layout->addWidget(l, 0, Qt::AlignBottom); + } + + setStyleSheet(R"( + PrimeAdWidget { + border-radius: 10px; + background-color: #333333; + } + )"); +} + + +SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) { + mainLayout = new QStackedWidget; + + // Unpaired, registration prompt layout + + QWidget* finishRegistration = new QWidget; + finishRegistration->setObjectName("primeWidget"); + QVBoxLayout* finishRegistationLayout = new QVBoxLayout(finishRegistration); + finishRegistationLayout->setContentsMargins(30, 75, 30, 45); + finishRegistationLayout->setSpacing(0); + + QLabel* registrationTitle = new QLabel("Finish Setup"); + registrationTitle->setStyleSheet("font-size: 75px; font-weight: bold; margin-left: 55px;"); + finishRegistationLayout->addWidget(registrationTitle); + + finishRegistationLayout->addSpacing(30); + + QLabel* registrationDescription = new QLabel("Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer."); + registrationDescription->setWordWrap(true); + registrationDescription->setStyleSheet("font-size: 55px; font-weight: light; margin-left: 55px;"); + finishRegistationLayout->addWidget(registrationDescription); + + finishRegistationLayout->addStretch(); + + QPushButton* pair = new QPushButton("Pair device"); + pair->setFixedHeight(220); + pair->setStyleSheet(R"( + QPushButton { + font-size: 55px; + font-weight: 400; + border-radius: 10px; + background-color: #465BEA; + } + QPushButton:pressed { + background-color: #3049F4; + } + )"); + finishRegistationLayout->addWidget(pair); + + popup = new PairingPopup(this); + QObject::connect(pair, &QPushButton::clicked, popup, &PairingPopup::exec); + + mainLayout->addWidget(finishRegistration); + + // build stacked layout + QVBoxLayout *outer_layout = new QVBoxLayout(this); + outer_layout->setContentsMargins(0, 0, 0, 0); + outer_layout->addWidget(mainLayout); + + primeAd = new PrimeAdWidget; + mainLayout->addWidget(primeAd); + + primeUser = new PrimeUserWidget; + mainLayout->addWidget(primeUser); + + mainLayout->setCurrentWidget(primeAd); + + setFixedWidth(750); + setStyleSheet(R"( + #primeWidget { + border-radius: 10px; + background-color: #333333; + } + )"); + + // Retain size while hidden + QSizePolicy sp_retain = sizePolicy(); + sp_retain.setRetainSizeWhenHidden(true); + setSizePolicy(sp_retain); + + // set up API requests + if (auto dongleId = getDongleId()) { + QString url = CommaApi::BASE_URL + "/v1.1/devices/" + *dongleId + "/"; + RequestRepeater* repeater = new RequestRepeater(this, url, "ApiCache_Device", 5); + + QObject::connect(repeater, &RequestRepeater::requestDone, this, &SetupWidget::replyFinished); + } + hide(); // Only show when first request comes back +} + +void SetupWidget::replyFinished(const QString &response, bool success) { + show(); + if (!success) return; + + QJsonDocument doc = QJsonDocument::fromJson(response.toUtf8()); + if (doc.isNull()) { + qDebug() << "JSON Parse failed on getting pairing and prime status"; + return; + } + + QJsonObject json = doc.object(); + if (!json["is_paired"].toBool()) { + mainLayout->setCurrentIndex(0); + } else { + popup->reject(); + + bool prime = json["prime"].toBool(); + + if (QUIState::ui_state.has_prime != prime) { + QUIState::ui_state.has_prime = prime; + Params().putBool("HasPrime", prime); + } + + if (prime) { + mainLayout->setCurrentWidget(primeUser); + } else { + mainLayout->setCurrentWidget(primeAd); + } + } +} diff --git a/selfdrive/ui/qt/widgets/prime.h b/selfdrive/ui/qt/widgets/prime.h new file mode 100644 index 00000000000000..f7470fe44173ee --- /dev/null +++ b/selfdrive/ui/qt/widgets/prime.h @@ -0,0 +1,72 @@ +#pragma once + +#include +#include +#include +#include + +#include "selfdrive/ui/qt/widgets/input.h" + +// pairing QR code +class PairingQRWidget : public QWidget { + Q_OBJECT + +public: + explicit PairingQRWidget(QWidget* parent = 0); + void paintEvent(QPaintEvent*) override; + +private: + QPixmap img; + void updateQrCode(const QString &text); + void showEvent(QShowEvent *event) override; + +private slots: + void refresh(); +}; + +// pairing popup widget +class PairingPopup : public QDialogBase { + Q_OBJECT + +public: + explicit PairingPopup(QWidget* parent); +}; + +// widget for paired users with prime +class PrimeUserWidget : public QWidget { + Q_OBJECT +public: + explicit PrimeUserWidget(QWidget* parent = 0); + +private: + QVBoxLayout* mainLayout; + QLabel* points; + +private slots: + void replyFinished(const QString &response); +}; + + +// widget for paired users without prime +class PrimeAdWidget : public QFrame { + Q_OBJECT +public: + explicit PrimeAdWidget(QWidget* parent = 0); +}; + +// container widget +class SetupWidget : public QFrame { + Q_OBJECT + +public: + explicit SetupWidget(QWidget* parent = 0); + +private: + PairingPopup *popup; + QStackedWidget *mainLayout; + PrimeAdWidget *primeAd; + PrimeUserWidget *primeUser; + +private slots: + void replyFinished(const QString &response, bool success); +}; diff --git a/selfdrive/ui/qt/widgets/scrollview.cc b/selfdrive/ui/qt/widgets/scrollview.cc new file mode 100644 index 00000000000000..beb0b7d464b5b8 --- /dev/null +++ b/selfdrive/ui/qt/widgets/scrollview.cc @@ -0,0 +1,52 @@ +#include "selfdrive/ui/qt/widgets/scrollview.h" + +#include +#include + +ScrollView::ScrollView(QWidget *w, QWidget *parent) : QScrollArea(parent) { + QPalette pal = palette(); + pal.setColor(QPalette::Background, QColor(0x29, 0x29, 0x29)); + w->setAutoFillBackground(true); + w->setPalette(pal); + + setWidget(w); + setWidgetResizable(true); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setFrameStyle(QFrame::NoFrame); + + QString style = R"( + QScrollBar:vertical { + border: none; + background: transparent; + width: 10px; + margin: 0; + } + QScrollBar::handle:vertical { + min-height: 0px; + border-radius: 5px; + background-color: white; + } + QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { + height: 0px; + } + QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; + } + )"; + verticalScrollBar()->setStyleSheet(style); + horizontalScrollBar()->setStyleSheet(style); + + QScroller *scroller = QScroller::scroller(this->viewport()); + QScrollerProperties sp = scroller->scrollerProperties(); + + sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff)); + sp.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff)); + + scroller->grabGesture(this->viewport(), QScroller::LeftMouseButtonGesture); + scroller->setScrollerProperties(sp); +} + +void ScrollView::hideEvent(QHideEvent *e) { + verticalScrollBar()->setValue(0); +} diff --git a/selfdrive/ui/qt/widgets/scrollview.h b/selfdrive/ui/qt/widgets/scrollview.h new file mode 100644 index 00000000000000..024331aa39dd2e --- /dev/null +++ b/selfdrive/ui/qt/widgets/scrollview.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +class ScrollView : public QScrollArea { + Q_OBJECT + +public: + explicit ScrollView(QWidget *w = nullptr, QWidget *parent = nullptr); +protected: + void hideEvent(QHideEvent *e) override; +}; diff --git a/selfdrive/ui/qt/widgets/ssh_keys.cc b/selfdrive/ui/qt/widgets/ssh_keys.cc new file mode 100644 index 00000000000000..7630e657317f95 --- /dev/null +++ b/selfdrive/ui/qt/widgets/ssh_keys.cc @@ -0,0 +1,65 @@ +#include "selfdrive/ui/qt/widgets/ssh_keys.h" + +#include "selfdrive/common/params.h" +#include "selfdrive/ui/qt/api.h" +#include "selfdrive/ui/qt/widgets/input.h" + +SshControl::SshControl() : ButtonControl("SSH Keys", "", "Warning: This grants SSH access to all public keys in your GitHub settings. Never enter a GitHub username other than your own. A comma employee will NEVER ask you to add their GitHub username.") { + username_label.setAlignment(Qt::AlignRight | Qt::AlignVCenter); + username_label.setStyleSheet("color: #aaaaaa"); + hlayout->insertWidget(1, &username_label); + + QObject::connect(this, &ButtonControl::clicked, [=]() { + if (text() == "ADD") { + QString username = InputDialog::getText("Enter your GitHub username", this); + if (username.length() > 0) { + setText("LOADING"); + setEnabled(false); + getUserKeys(username); + } + } else { + params.remove("GithubUsername"); + params.remove("GithubSshKeys"); + refresh(); + } + }); + + refresh(); +} + +void SshControl::refresh() { + QString param = QString::fromStdString(params.get("GithubSshKeys")); + if (param.length()) { + username_label.setText(QString::fromStdString(params.get("GithubUsername"))); + setText("REMOVE"); + } else { + username_label.setText(""); + setText("ADD"); + } + setEnabled(true); +} + +void SshControl::getUserKeys(const QString &username) { + HttpRequest *request = new HttpRequest(this, false); + QObject::connect(request, &HttpRequest::requestDone, [=](const QString &resp, bool success) { + if (success) { + if (!resp.isEmpty()) { + params.put("GithubUsername", username.toStdString()); + params.put("GithubSshKeys", resp.toStdString()); + } else { + ConfirmationDialog::alert(QString("Username '%1' has no keys on GitHub").arg(username), this); + } + } else { + if (request->timeout()) { + ConfirmationDialog::alert("Request timed out", this); + } else { + ConfirmationDialog::alert(QString("Username '%1' doesn't exist on GitHub").arg(username), this); + } + } + + refresh(); + request->deleteLater(); + }); + + request->sendRequest("https://github.com/" + username + ".keys"); +} diff --git a/selfdrive/ui/qt/widgets/ssh_keys.h b/selfdrive/ui/qt/widgets/ssh_keys.h new file mode 100644 index 00000000000000..0614e8c1d8b2b0 --- /dev/null +++ b/selfdrive/ui/qt/widgets/ssh_keys.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/widgets/controls.h" + +// SSH enable toggle +class SshToggle : public ToggleControl { + Q_OBJECT + +public: + SshToggle() : ToggleControl("Enable SSH", "", "", Hardware::get_ssh_enabled()) { + QObject::connect(this, &SshToggle::toggleFlipped, [=](bool state) { + Hardware::set_ssh_enabled(state); + }); + } +}; + +// SSH key management widget +class SshControl : public ButtonControl { + Q_OBJECT + +public: + SshControl(); + +private: + Params params; + + QLabel username_label; + + void refresh(); + void getUserKeys(const QString &username); +}; diff --git a/selfdrive/ui/qt/widgets/toggle.cc b/selfdrive/ui/qt/widgets/toggle.cc new file mode 100644 index 00000000000000..82302ad5bc78f3 --- /dev/null +++ b/selfdrive/ui/qt/widgets/toggle.cc @@ -0,0 +1,83 @@ +#include "selfdrive/ui/qt/widgets/toggle.h" + +#include + +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; + circleColor = QColor(0xffffff); // placeholder + green = QColor(0xffffff); // placeholder + setEnabled(true); +} + +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(green); + p.drawRoundedRect(QRect(0, _y_rect, _x_circle + _radius, _height_rect), _height_rect/2, _height_rect/2); + + // Draw toggle background right + p.setBrush(QColor(0x393939)); + 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(circleColor); + p.drawEllipse(QRectF(_x_circle - _radius, _y_circle - _radius, 2 * _radius, 2 * _radius)); +} + +void Toggle::mouseReleaseEvent(QMouseEvent *e) { + if (!enabled) { + return; + } + const int left = _radius; + const int right = width() - _radius; + if ((_x_circle != left && _x_circle != right) || !this->rect().contains(e->localPos().toPoint())) { + // If mouse release isn't in rect or animation is running, don't parse touch events + return; + } + 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 + immediateOffset : right - immediateOffset); + _anim->setEndValue(on ? right : left); + _anim->setDuration(animation_duration); + _anim->start(); + repaint(); +} + +void Toggle::enterEvent(QEvent *e) { + QAbstractButton::enterEvent(e); +} + +bool Toggle::getEnabled() { + return enabled; +} + +void Toggle::setEnabled(bool value) { + enabled = value; + if (value) { + circleColor.setRgb(0xfafafa); + green.setRgb(0x33ab4c); + } else { + circleColor.setRgb(0x888888); + green.setRgb(0x227722); + } +} diff --git a/selfdrive/ui/qt/widgets/toggle.h b/selfdrive/ui/qt/widgets/toggle.h new file mode 100644 index 00000000000000..e7263a008fa183 --- /dev/null +++ b/selfdrive/ui/qt/widgets/toggle.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include +#include + +class Toggle : public QAbstractButton { + Q_OBJECT + Q_PROPERTY(int offset_circle READ offset_circle WRITE set_offset_circle CONSTANT) + +public: + Toggle(QWidget* parent = nullptr); + void togglePosition(); + bool on; + int animation_duration = 150; + int immediateOffset = 0; + int offset_circle() const { + return _x_circle; + } + + void set_offset_circle(int o) { + _x_circle = o; + update(); + } + bool getEnabled(); + void setEnabled(bool value); + +protected: + void paintEvent(QPaintEvent*) override; + void mouseReleaseEvent(QMouseEvent*) override; + void enterEvent(QEvent*) override; + +private: + QColor circleColor; + QColor green; + bool enabled = true; + int _x_circle, _y_circle; + int _height, _radius; + int _height_rect, _y_rect; + QPropertyAnimation *_anim = nullptr; + +signals: + void stateChanged(bool new_state); +}; diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc new file mode 100644 index 00000000000000..7fe87ce698e1c5 --- /dev/null +++ b/selfdrive/ui/qt/window.cc @@ -0,0 +1,105 @@ +#include "selfdrive/ui/qt/window.h" + +#include + +#include "selfdrive/hardware/hw.h" + +MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { + main_layout = new QStackedLayout(this); + main_layout->setMargin(0); + + homeWindow = new HomeWindow(this); + main_layout->addWidget(homeWindow); + QObject::connect(homeWindow, &HomeWindow::openSettings, this, &MainWindow::openSettings); + QObject::connect(homeWindow, &HomeWindow::closeSettings, this, &MainWindow::closeSettings); + QObject::connect(&qs, &QUIState::uiUpdate, homeWindow, &HomeWindow::update); + QObject::connect(&qs, &QUIState::offroadTransition, homeWindow, &HomeWindow::offroadTransition); + QObject::connect(&qs, &QUIState::offroadTransition, homeWindow, &HomeWindow::offroadTransitionSignal); + + settingsWindow = new SettingsWindow(this); + main_layout->addWidget(settingsWindow); + QObject::connect(settingsWindow, &SettingsWindow::closeSettings, this, &MainWindow::closeSettings); + QObject::connect(&qs, &QUIState::offroadTransition, settingsWindow, &SettingsWindow::offroadTransition); + QObject::connect(settingsWindow, &SettingsWindow::reviewTrainingGuide, [=]() { + onboardingWindow->showTrainingGuide(); + main_layout->setCurrentWidget(onboardingWindow); + }); + QObject::connect(settingsWindow, &SettingsWindow::showDriverView, [=] { + homeWindow->showDriverView(true); + }); + + onboardingWindow = new OnboardingWindow(this); + main_layout->addWidget(onboardingWindow); + QObject::connect(onboardingWindow, &OnboardingWindow::onboardingDone, [=]() { + main_layout->setCurrentWidget(homeWindow); + }); + if (!onboardingWindow->completed()) { + main_layout->setCurrentWidget(onboardingWindow); + } + + device.setAwake(true, true); + QObject::connect(&qs, &QUIState::uiUpdate, &device, &Device::update); + QObject::connect(&qs, &QUIState::offroadTransition, [=](bool offroad) { + if (!offroad) { + closeSettings(); + } + }); + QObject::connect(&device, &Device::displayPowerChanged, [=]() { + if(main_layout->currentWidget() != onboardingWindow) { + closeSettings(); + } + }); + + // load fonts + QFontDatabase::addApplicationFont("../assets/fonts/opensans_regular.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/opensans_bold.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/opensans_semibold.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-Black.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-Bold.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-ExtraBold.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-ExtraLight.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-Medium.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-Regular.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-SemiBold.ttf"); + QFontDatabase::addApplicationFont("../assets/fonts/Inter-Thin.ttf"); + + // no outline to prevent the focus rectangle + setStyleSheet(R"( + * { + font-family: Inter; + outline: none; + } + )"); + setAttribute(Qt::WA_NoSystemBackground); +} + +void MainWindow::openSettings() { + main_layout->setCurrentWidget(settingsWindow); +} + +void MainWindow::closeSettings() { + main_layout->setCurrentWidget(homeWindow); + + if (QUIState::ui_state.scene.started) { + homeWindow->showSidebar(false); + } +} + +bool MainWindow::eventFilter(QObject *obj, QEvent *event) { + // wake screen on tap + if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::TouchBegin) { + device.setAwake(true, true); + } + +#ifdef QCOM + // filter out touches while in android activity + const static QSet filter_events({QEvent::MouseButtonPress, QEvent::MouseMove, QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd}); + if (HardwareEon::launched_activity && filter_events.contains(event->type())) { + HardwareEon::check_activity(); + if (HardwareEon::launched_activity) { + return true; + } + } +#endif + return false; +} diff --git a/selfdrive/ui/qt/window.h b/selfdrive/ui/qt/window.h new file mode 100644 index 00000000000000..069831cffec2b1 --- /dev/null +++ b/selfdrive/ui/qt/window.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +#include "selfdrive/ui/qt/home.h" +#include "selfdrive/ui/qt/offroad/onboarding.h" +#include "selfdrive/ui/qt/offroad/settings.h" + +class MainWindow : public QWidget { + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + +private: + bool eventFilter(QObject *obj, QEvent *event) override; + void openSettings(); + void closeSettings(); + + Device device; + QUIState qs; + + QStackedLayout *main_layout; + HomeWindow *homeWindow; + SettingsWindow *settingsWindow; + OnboardingWindow *onboardingWindow; +}; diff --git a/selfdrive/ui/replay/camera.cc b/selfdrive/ui/replay/camera.cc new file mode 100644 index 00000000000000..b37332ae7ea2c5 --- /dev/null +++ b/selfdrive/ui/replay/camera.cc @@ -0,0 +1,88 @@ +#include "selfdrive/ui/replay/camera.h" + +#include +#include + +const int YUV_BUF_COUNT = 50; + +CameraServer::CameraServer(std::pair camera_size[MAX_CAMERAS], bool send_yuv) : send_yuv(send_yuv) { + for (int i = 0; i < MAX_CAMERAS; ++i) { + std::tie(cameras_[i].width, cameras_[i].height) = camera_size[i]; + } + startVipcServer(); +} + +CameraServer::~CameraServer() { + for (auto &cam : cameras_) { + if (cam.thread.joinable()) { + cam.queue.push({}); + cam.thread.join(); + } + } + vipc_server_.reset(nullptr); +} + +void CameraServer::startVipcServer() { + vipc_server_.reset(new VisionIpcServer("camerad")); + for (auto &cam : cameras_) { + if (cam.width > 0 && cam.height > 0) { + std::cout << "camera[" << cam.type << "] frame size " << cam.width << "x" << cam.height << std::endl; + vipc_server_->create_buffers(cam.rgb_type, UI_BUF_COUNT, true, cam.width, cam.height); + if (send_yuv) { + vipc_server_->create_buffers(cam.yuv_type, YUV_BUF_COUNT, false, cam.width, cam.height); + } + if (!cam.thread.joinable()) { + cam.thread = std::thread(&CameraServer::cameraThread, this, std::ref(cam)); + } + } + } + vipc_server_->start_listener(); +} + +void CameraServer::cameraThread(Camera &cam) { + auto read_frame = [&](FrameReader *fr, int frame_id) { + VisionBuf *rgb_buf = vipc_server_->get_buffer(cam.rgb_type); + VisionBuf *yuv_buf = send_yuv ? vipc_server_->get_buffer(cam.yuv_type) : nullptr; + bool ret = fr->get(frame_id, (uint8_t *)rgb_buf->addr, yuv_buf ? (uint8_t *)yuv_buf->addr : nullptr); + return ret ? std::pair{rgb_buf, yuv_buf} : std::pair{nullptr, nullptr}; + }; + + while (true) { + const auto [fr, eidx] = cam.queue.pop(); + if (!fr) break; + + const int id = eidx.getSegmentId(); + bool prefetched = (id == cam.cached_id && eidx.getSegmentNum() == cam.cached_seg); + auto [rgb, yuv] = prefetched ? cam.cached_buf : read_frame(fr, id); + if (rgb || yuv) { + VisionIpcBufExtra extra = { + .frame_id = eidx.getFrameId(), + .timestamp_sof = eidx.getTimestampSof(), + .timestamp_eof = eidx.getTimestampEof(), + }; + if (rgb) vipc_server_->send(rgb, &extra, false); + if (yuv) vipc_server_->send(yuv, &extra, false); + } else { + std::cout << "camera[" << cam.type << "] failed to get frame:" << eidx.getSegmentId() << std::endl; + } + + cam.cached_id = id + 1; + cam.cached_seg = eidx.getSegmentNum(); + cam.cached_buf = read_frame(fr, cam.cached_id); + + --publishing_; + } +} + +void CameraServer::pushFrame(CameraType type, FrameReader *fr, const cereal::EncodeIndex::Reader &eidx) { + auto &cam = cameras_[type]; + if (cam.width != fr->width || cam.height != fr->height) { + cam.width = fr->width; + cam.height = fr->height; + waitFinish(); + startVipcServer(); + } + + ++publishing_; + cam.queue.push({fr, eidx}); +} diff --git a/selfdrive/ui/replay/camera.h b/selfdrive/ui/replay/camera.h new file mode 100644 index 00000000000000..21e02292d558b7 --- /dev/null +++ b/selfdrive/ui/replay/camera.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include "cereal/visionipc/visionipc_server.h" +#include "selfdrive/common/queue.h" +#include "selfdrive/ui/replay/framereader.h" +#include "selfdrive/ui/replay/logreader.h" + +class CameraServer { +public: + CameraServer(std::pair camera_size[MAX_CAMERAS] = nullptr, bool send_yuv = false); + ~CameraServer(); + void pushFrame(CameraType type, FrameReader* fr, const cereal::EncodeIndex::Reader& eidx); + inline void waitFinish() { + while (publishing_ > 0) usleep(0); + } + +protected: + struct Camera { + CameraType type; + VisionStreamType rgb_type; + VisionStreamType yuv_type; + int width; + int height; + std::thread thread; + SafeQueue> queue; + int cached_id = -1; + int cached_seg = -1; + std::pair cached_buf; + }; + void startVipcServer(); + void cameraThread(Camera &cam); + + Camera cameras_[MAX_CAMERAS] = { + {.type = RoadCam, .rgb_type = VISION_STREAM_RGB_BACK, .yuv_type = VISION_STREAM_ROAD}, + {.type = DriverCam, .rgb_type = VISION_STREAM_RGB_FRONT, .yuv_type = VISION_STREAM_DRIVER}, + {.type = WideRoadCam, .rgb_type = VISION_STREAM_RGB_WIDE, .yuv_type = VISION_STREAM_WIDE_ROAD}, + }; + std::atomic publishing_ = 0; + std::unique_ptr vipc_server_; + bool send_yuv; +}; diff --git a/selfdrive/ui/replay/filereader.cc b/selfdrive/ui/replay/filereader.cc new file mode 100644 index 00000000000000..84dc76694ba4c7 --- /dev/null +++ b/selfdrive/ui/replay/filereader.cc @@ -0,0 +1,47 @@ +#include "selfdrive/ui/replay/filereader.h" + +#include +#include + +#include "selfdrive/common/util.h" +#include "selfdrive/ui/replay/util.h" + +std::string cacheFilePath(const std::string &url) { + static std::string cache_path = [] { + const std::string comma_cache = util::getenv("COMMA_CACHE", "/tmp/comma_download_cache/"); + util::create_directories(comma_cache, 0755); + return comma_cache.back() == '/' ? comma_cache : comma_cache + "/"; + }(); + + return cache_path + sha256(getUrlWithoutQuery(url)); +} + +std::string FileReader::read(const std::string &file, std::atomic *abort) { + const bool is_remote = file.find("https://") == 0; + const std::string local_file = is_remote ? cacheFilePath(file) : file; + std::string result; + + if ((!is_remote || cache_to_local_) && util::file_exists(local_file)) { + result = util::read_file(local_file); + } else if (is_remote) { + result = download(file, abort); + if (cache_to_local_ && !result.empty()) { + std::ofstream fs(local_file, std::ios::binary | std::ios::out); + fs.write(result.data(), result.size()); + } + } + return result; +} + +std::string FileReader::download(const std::string &url, std::atomic *abort) { + for (int i = 0; i <= max_retries_ && !(abort && *abort); ++i) { + std::string result = httpGet(url, chunk_size_, abort); + if (!result.empty()) { + return result; + } + if (i != max_retries_) { + std::cout << "download failed, retrying " << i + 1 << std::endl; + } + } + return {}; +} diff --git a/selfdrive/ui/replay/filereader.h b/selfdrive/ui/replay/filereader.h new file mode 100644 index 00000000000000..34aa91e858ecfd --- /dev/null +++ b/selfdrive/ui/replay/filereader.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +class FileReader { +public: + FileReader(bool cache_to_local, size_t chunk_size = 0, int retries = 3) + : cache_to_local_(cache_to_local), chunk_size_(chunk_size), max_retries_(retries) {} + virtual ~FileReader() {} + std::string read(const std::string &file, std::atomic *abort = nullptr); + +private: + std::string download(const std::string &url, std::atomic *abort); + size_t chunk_size_; + int max_retries_; + bool cache_to_local_; +}; + +std::string cacheFilePath(const std::string &url); diff --git a/selfdrive/ui/replay/framereader.cc b/selfdrive/ui/replay/framereader.cc new file mode 100644 index 00000000000000..32af922f1f4aa2 --- /dev/null +++ b/selfdrive/ui/replay/framereader.cc @@ -0,0 +1,236 @@ +#include "selfdrive/ui/replay/framereader.h" + +#include +#include "libyuv.h" + +namespace { + +struct buffer_data { + const uint8_t *data; + int64_t offset; + size_t size; +}; + +int readPacket(void *opaque, uint8_t *buf, int buf_size) { + struct buffer_data *bd = (struct buffer_data *)opaque; + buf_size = std::min((size_t)buf_size, bd->size - bd->offset); + if (!buf_size) return AVERROR_EOF; + + memcpy(buf, bd->data + bd->offset, buf_size); + bd->offset += buf_size; + return buf_size; +} + +enum AVPixelFormat get_hw_format(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts) { + enum AVPixelFormat *hw_pix_fmt = reinterpret_cast(ctx->opaque); + for (const enum AVPixelFormat *p = pix_fmts; *p != -1; p++) { + if (*p == *hw_pix_fmt) return *p; + } + printf("Please run replay with the --no-cuda flag!\n"); + // fallback to YUV420p + *hw_pix_fmt = AV_PIX_FMT_NONE; + return AV_PIX_FMT_YUV420P; +} + +} // namespace + +FrameReader::FrameReader() {} + +FrameReader::~FrameReader() { + for (AVPacket *pkt : packets) { + av_packet_free(&pkt); + } + + if (decoder_ctx) avcodec_free_context(&decoder_ctx); + if (input_ctx) avformat_close_input(&input_ctx); + if (hw_device_ctx) av_buffer_unref(&hw_device_ctx); + + if (avio_ctx_) { + av_freep(&avio_ctx_->buffer); + avio_context_free(&avio_ctx_); + } +} + +bool FrameReader::load(const std::string &url, bool no_cuda, std::atomic *abort, bool local_cache, int chunk_size, int retries) { + FileReader f(local_cache, chunk_size, retries); + std::string data = f.read(url, abort); + if (data.empty()) return false; + + return load((std::byte *)data.data(), data.size(), no_cuda, abort); +} + +bool FrameReader::load(const std::byte *data, size_t size, bool no_cuda, std::atomic *abort) { + input_ctx = avformat_alloc_context(); + if (!input_ctx) return false; + + struct buffer_data bd = { + .data = (const uint8_t*)data, + .offset = 0, + .size = size, + }; + const int avio_ctx_buffer_size = 64 * 1024; + unsigned char *avio_ctx_buffer = (unsigned char *)av_malloc(avio_ctx_buffer_size); + avio_ctx_ = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size, 0, &bd, readPacket, nullptr, nullptr); + input_ctx->pb = avio_ctx_; + + input_ctx->probesize = 10 * 1024 * 1024; // 10MB + int ret = avformat_open_input(&input_ctx, nullptr, nullptr, nullptr); + if (ret != 0) { + char err_str[1024] = {0}; + av_strerror(ret, err_str, std::size(err_str)); + printf("Error loading video - %s\n", err_str); + return false; + } + + ret = avformat_find_stream_info(input_ctx, nullptr); + if (ret < 0) { + printf("cannot find a video stream in the input file\n"); + return false; + } + + AVStream *video = input_ctx->streams[0]; + AVCodec *decoder = avcodec_find_decoder(video->codec->codec_id); + if (!decoder) return false; + + decoder_ctx = avcodec_alloc_context3(decoder); + ret = avcodec_parameters_to_context(decoder_ctx, video->codecpar); + if (ret != 0) return false; + + width = (decoder_ctx->width + 3) & ~3; + height = decoder_ctx->height; + + if (has_cuda_device && !no_cuda) { + if (!initHardwareDecoder(AV_HWDEVICE_TYPE_CUDA)) { + printf("No CUDA capable device was found. fallback to CPU decoding.\n"); + } else { + nv12toyuv_buffer.resize(getYUVSize()); + } + } + + ret = avcodec_open2(decoder_ctx, decoder, nullptr); + if (ret < 0) return false; + + packets.reserve(60 * 20); // 20fps, one minute + while (!(abort && *abort)) { + AVPacket *pkt = av_packet_alloc(); + ret = av_read_frame(input_ctx, pkt); + if (ret < 0) { + av_packet_free(&pkt); + valid_ = (ret == AVERROR_EOF); + break; + } + packets.push_back(pkt); + // some stream seems to contian no keyframes + key_frames_count_ += pkt->flags & AV_PKT_FLAG_KEY; + } + valid_ = valid_ && !packets.empty(); + return valid_; +} + +bool FrameReader::initHardwareDecoder(AVHWDeviceType hw_device_type) { + for (int i = 0;; i++) { + const AVCodecHWConfig *config = avcodec_get_hw_config(decoder_ctx->codec, i); + if (!config) { + printf("decoder %s does not support hw device type %s.\n", + decoder_ctx->codec->name, av_hwdevice_get_type_name(hw_device_type)); + return false; + } + if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX && config->device_type == hw_device_type) { + hw_pix_fmt = config->pix_fmt; + break; + } + } + + int ret = av_hwdevice_ctx_create(&hw_device_ctx, hw_device_type, nullptr, nullptr, 0); + if (ret < 0) { + hw_pix_fmt = AV_PIX_FMT_NONE; + has_cuda_device = false; + printf("Failed to create specified HW device %d.\n", ret); + return false; + } + + decoder_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx); + decoder_ctx->opaque = &hw_pix_fmt; + decoder_ctx->get_format = get_hw_format; + return true; +} + +bool FrameReader::get(int idx, uint8_t *rgb, uint8_t *yuv) { + assert(rgb || yuv); + if (!valid_ || idx < 0 || idx >= packets.size()) { + return false; + } + return decode(idx, rgb, yuv); +} + +bool FrameReader::decode(int idx, uint8_t *rgb, uint8_t *yuv) { + int from_idx = idx; + if (idx != prev_idx + 1 && key_frames_count_ > 1) { + // seeking to the nearest key frame + for (int i = idx; i >= 0; --i) { + if (packets[i]->flags & AV_PKT_FLAG_KEY) { + from_idx = i; + break; + } + } + } + prev_idx = idx; + + for (int i = from_idx; i <= idx; ++i) { + AVFrame *f = decodeFrame(packets[i]); + if (f && i == idx) { + return copyBuffers(f, rgb, yuv); + } + } + return false; +} + +AVFrame *FrameReader::decodeFrame(AVPacket *pkt) { + int ret = avcodec_send_packet(decoder_ctx, pkt); + if (ret < 0) { + printf("Error sending a packet for decoding\n"); + return nullptr; + } + + av_frame_.reset(av_frame_alloc()); + ret = avcodec_receive_frame(decoder_ctx, av_frame_.get()); + if (ret != 0) { + return nullptr; + } + + if (av_frame_->format == hw_pix_fmt) { + hw_frame.reset(av_frame_alloc()); + if ((ret = av_hwframe_transfer_data(hw_frame.get(), av_frame_.get(), 0)) < 0) { + printf("error transferring the data from GPU to CPU\n"); + return nullptr; + } + return hw_frame.get(); + } else { + return av_frame_.get(); + } +} + +bool FrameReader::copyBuffers(AVFrame *f, uint8_t *rgb, uint8_t *yuv) { + if (hw_pix_fmt == AV_PIX_FMT_CUDA) { + uint8_t *y = yuv ? yuv : nv12toyuv_buffer.data(); + uint8_t *u = y + width * height; + uint8_t *v = u + (width / 2) * (height / 2); + libyuv::NV12ToI420(f->data[0], f->linesize[0], f->data[1], f->linesize[1], + y, width, u, width / 2, v, width / 2, width, height); + libyuv::I420ToRGB24(y, width, u, width / 2, v, width / 2, + rgb, width * 3, width, height); + } else { + if (yuv) { + uint8_t *u = yuv + width * height; + uint8_t *v = u + (width / 2) * (height / 2); + memcpy(yuv, f->data[0], width * height); + memcpy(u, f->data[1], width / 2 * height / 2); + memcpy(v, f->data[2], width / 2 * height / 2); + } + libyuv::I420ToRGB24(f->data[0], f->linesize[0], + f->data[1], f->linesize[1], + f->data[2], f->linesize[2], + rgb, width * 3, width, height); + } + return true; +} diff --git a/selfdrive/ui/replay/framereader.h b/selfdrive/ui/replay/framereader.h new file mode 100644 index 00000000000000..d572b727e53828 --- /dev/null +++ b/selfdrive/ui/replay/framereader.h @@ -0,0 +1,51 @@ +#pragma once + +#include +#include +#include + +#include "selfdrive/ui/replay/filereader.h" + +extern "C" { +#include +#include +} + +struct AVFrameDeleter { + void operator()(AVFrame* frame) const { av_frame_free(&frame); } +}; + +class FrameReader { +public: + FrameReader(); + ~FrameReader(); + bool load(const std::string &url, bool no_cuda = false, std::atomic *abort = nullptr, bool local_cache = false, int chunk_size = -1, int retries = 0); + bool load(const std::byte *data, size_t size, bool no_cuda = false, std::atomic *abort = nullptr); + bool get(int idx, uint8_t *rgb, uint8_t *yuv); + int getRGBSize() const { return width * height * 3; } + int getYUVSize() const { return width * height * 3 / 2; } + size_t getFrameCount() const { return packets.size(); } + bool valid() const { return valid_; } + + int width = 0, height = 0; + +private: + bool initHardwareDecoder(AVHWDeviceType hw_device_type); + bool decode(int idx, uint8_t *rgb, uint8_t *yuv); + AVFrame * decodeFrame(AVPacket *pkt); + bool copyBuffers(AVFrame *f, uint8_t *rgb, uint8_t *yuv); + + std::vector packets; + std::unique_ptrav_frame_, hw_frame; + AVFormatContext *input_ctx = nullptr; + AVCodecContext *decoder_ctx = nullptr; + int key_frames_count_ = 0; + bool valid_ = false; + AVIOContext *avio_ctx_ = nullptr; + + AVPixelFormat hw_pix_fmt = AV_PIX_FMT_NONE; + AVBufferRef *hw_device_ctx = nullptr; + std::vector nv12toyuv_buffer; + int prev_idx = -1; + inline static std::atomic has_cuda_device = true; +}; diff --git a/selfdrive/ui/replay/logreader.cc b/selfdrive/ui/replay/logreader.cc new file mode 100644 index 00000000000000..8e2836a4ff755e --- /dev/null +++ b/selfdrive/ui/replay/logreader.cc @@ -0,0 +1,101 @@ +#include "selfdrive/ui/replay/logreader.h" + +#include +#include +#include "selfdrive/ui/replay/util.h" + +Event::Event(const kj::ArrayPtr &amsg, bool frame) : reader(amsg), frame(frame) { + words = kj::ArrayPtr(amsg.begin(), reader.getEnd()); + event = reader.getRoot(); + which = event.which(); + mono_time = event.getLogMonoTime(); + + // 1) Send video data at t=timestampEof/timestampSof + // 2) Send encodeIndex packet at t=logMonoTime + if (frame) { + auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs(); + // C2 only has eof set, and some older routes have neither + uint64_t sof = idx.getTimestampSof(); + uint64_t eof = idx.getTimestampEof(); + if (sof > 0) { + mono_time = sof; + } else if (eof > 0) { + mono_time = eof; + } + } +} + +// class LogReader + +LogReader::LogReader(size_t memory_pool_block_size) { +#ifdef HAS_MEMORY_RESOURCE + const size_t buf_size = sizeof(Event) * memory_pool_block_size; + pool_buffer_ = ::operator new(buf_size); + mbr_ = new std::pmr::monotonic_buffer_resource(pool_buffer_, buf_size); +#endif + events.reserve(memory_pool_block_size); +} + +LogReader::~LogReader() { + for (Event *e : events) { + delete e; + } + +#ifdef HAS_MEMORY_RESOURCE + delete mbr_; + ::operator delete(pool_buffer_); +#endif +} + +bool LogReader::load(const std::string &url, std::atomic *abort, bool local_cache, int chunk_size, int retries) { + FileReader f(local_cache, chunk_size, retries); + std::string data = f.read(url, abort); + if (data.empty()) return false; + + return load((std::byte*)data.data(), data.size(), abort); +} + +bool LogReader::load(const std::byte *data, size_t size, std::atomic *abort) { + raw_ = decompressBZ2(data, size); + if (raw_.empty()) { + std::cout << "failed to decompress log" << std::endl; + return false; + } + + try { + kj::ArrayPtr words((const capnp::word *)raw_.data(), raw_.size() / sizeof(capnp::word)); + while (words.size() > 0) { + +#ifdef HAS_MEMORY_RESOURCE + Event *evt = new (mbr_) Event(words); +#else + Event *evt = new Event(words); +#endif + + // Add encodeIdx packet again as a frame packet for the video stream + if (evt->which == cereal::Event::ROAD_ENCODE_IDX || + evt->which == cereal::Event::DRIVER_ENCODE_IDX || + evt->which == cereal::Event::WIDE_ROAD_ENCODE_IDX) { + +#ifdef HAS_MEMORY_RESOURCE + Event *frame_evt = new (mbr_) Event(words, true); +#else + Event *frame_evt = new Event(words, true); +#endif + + events.push_back(frame_evt); + } + + words = kj::arrayPtr(evt->reader.getEnd(), words.end()); + events.push_back(evt); + } + } catch (const kj::Exception &e) { + std::cout << "failed to parse log : " << e.getDescription().cStr() << std::endl; + if (events.empty()) return false; + + std::cout << "read " << events.size() << " events from corrupt log" << std::endl; + } + + std::sort(events.begin(), events.end(), Event::lessThan()); + return true; +} diff --git a/selfdrive/ui/replay/logreader.h b/selfdrive/ui/replay/logreader.h new file mode 100644 index 00000000000000..33d7ea82f2951f --- /dev/null +++ b/selfdrive/ui/replay/logreader.h @@ -0,0 +1,64 @@ +#pragma once + +#if __has_include() +#define HAS_MEMORY_RESOURCE 1 +#include +#endif + +#include "cereal/gen/cpp/log.capnp.h" +#include "selfdrive/camerad/cameras/camera_common.h" +#include "selfdrive/ui/replay/filereader.h" + +const CameraType ALL_CAMERAS[] = {RoadCam, DriverCam, WideRoadCam}; +const int MAX_CAMERAS = std::size(ALL_CAMERAS); +const int DEFAULT_EVENT_MEMORY_POOL_BLOCK_SIZE = 65000; + +class Event { +public: + Event(cereal::Event::Which which, uint64_t mono_time) : reader(kj::ArrayPtr{}) { + // construct a dummy Event for binary search, e.g std::upper_bound + this->which = which; + this->mono_time = mono_time; + } + Event(const kj::ArrayPtr &amsg, bool frame = false); + inline kj::ArrayPtr bytes() const { return words.asBytes(); } + + struct lessThan { + inline bool operator()(const Event *l, const Event *r) { + return l->mono_time < r->mono_time || (l->mono_time == r->mono_time && l->which < r->which); + } + }; + +#if HAS_MEMORY_RESOURCE + void *operator new(size_t size, std::pmr::monotonic_buffer_resource *mbr) { + return mbr->allocate(size); + } + void operator delete(void *ptr) { + // No-op. memory used by EventMemoryPool increases monotonically until the logReader is destroyed. + } +#endif + + uint64_t mono_time; + cereal::Event::Which which; + cereal::Event::Reader event; + capnp::FlatArrayMessageReader reader; + kj::ArrayPtr words; + bool frame; +}; + +class LogReader { +public: + LogReader(size_t memory_pool_block_size = DEFAULT_EVENT_MEMORY_POOL_BLOCK_SIZE); + ~LogReader(); + bool load(const std::string &url, std::atomic *abort = nullptr, bool local_cache = false, int chunk_size = -1, int retries = 0); + bool load(const std::byte *data, size_t size, std::atomic *abort = nullptr); + + std::vector events; + +private: + std::string raw_; +#ifdef HAS_MEMORY_RESOURCE + std::pmr::monotonic_buffer_resource *mbr_ = nullptr; + void *pool_buffer_ = nullptr; +#endif +}; diff --git a/selfdrive/ui/replay/main.cc b/selfdrive/ui/replay/main.cc new file mode 100644 index 00000000000000..062837885b1c67 --- /dev/null +++ b/selfdrive/ui/replay/main.cc @@ -0,0 +1,149 @@ +#include + +#include +#include +#include +#include +#include +#include + +#include "selfdrive/ui/replay/replay.h" + +const QString DEMO_ROUTE = "4cf7a6ad03080c90|2021-09-29--13-46-36"; +struct termios oldt = {}; +Replay *replay = nullptr; + +void sigHandler(int s) { + std::signal(s, SIG_DFL); + if (oldt.c_lflag) { + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + } + if (replay) { + replay->stop(); + } + qApp->quit(); +} + +int getch() { + int ch; + struct termios newt; + + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + + tcsetattr(STDIN_FILENO, TCSANOW, &newt); + ch = getchar(); + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + + return ch; +} + +void keyboardThread(Replay *replay_) { + char c; + while (true) { + c = getch(); + if (c == '\n') { + printf("Enter seek request: "); + std::string r; + std::cin >> r; + + try { + if (r[0] == '#') { + r.erase(0, 1); + replay_->seekTo(std::stoi(r) * 60, false); + } else { + replay_->seekTo(std::stoi(r), false); + } + } catch (std::invalid_argument) { + qDebug() << "invalid argument"; + } + getch(); // remove \n from entering seek + } else if (c == 'm') { + replay_->seekTo(+60, true); + } else if (c == 'M') { + replay_->seekTo(-60, true); + } else if (c == 's') { + replay_->seekTo(+10, true); + } else if (c == 'S') { + replay_->seekTo(-10, true); + } else if (c == 'G') { + replay_->seekTo(0, true); + } else if (c == ' ') { + replay_->pause(!replay_->isPaused()); + } + } +} + +void replayMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + QByteArray localMsg = msg.toLocal8Bit(); + if (type == QtDebugMsg) { + std::cout << "\033[38;5;248m" << localMsg.constData() << "\033[00m" << std::endl; + } else if (type == QtWarningMsg) { + std::cout << "\033[38;5;227m" << localMsg.constData() << "\033[00m" << std::endl; + } else if (type == QtCriticalMsg) { + std::cout << "\033[38;5;196m" << localMsg.constData() << "\033[00m" << std::endl; + } else { + std::cout << localMsg.constData() << std::endl; + } +} + +int main(int argc, char *argv[]) { + qInstallMessageHandler(replayMessageOutput); + + QApplication app(argc, argv); + std::signal(SIGINT, sigHandler); + std::signal(SIGTERM, sigHandler); + + const std::tuple flags[] = { + {"dcam", REPLAY_FLAG_DCAM, "load driver camera"}, + {"ecam", REPLAY_FLAG_ECAM, "load wide road camera"}, + {"no-loop", REPLAY_FLAG_NO_LOOP, "stop at the end of the route"}, + {"no-cache", REPLAY_FLAG_NO_FILE_CACHE, "turn off local cache"}, + {"qcam", REPLAY_FLAG_QCAMERA, "load qcamera"}, + {"yuv", REPLAY_FLAG_SEND_YUV, "send yuv frame"}, + {"no-cuda", REPLAY_FLAG_NO_CUDA, "disable CUDA"}, + }; + + QCommandLineParser parser; + parser.setApplicationDescription("Mock openpilot components by publishing logged messages."); + parser.addHelpOption(); + parser.addPositionalArgument("route", "the drive to replay. find your drives at connect.comma.ai"); + parser.addOption({{"a", "allow"}, "whitelist of services to send", "allow"}); + parser.addOption({{"b", "block"}, "blacklist of services to send", "block"}); + parser.addOption({{"s", "start"}, "start from ", "seconds"}); + parser.addOption({"demo", "use a demo route instead of providing your own"}); + parser.addOption({"data_dir", "local directory with routes", "data_dir"}); + for (auto &[name, _, desc] : flags) { + parser.addOption({name, desc}); + } + + parser.process(app); + const QStringList args = parser.positionalArguments(); + if (args.empty() && !parser.isSet("demo")) { + parser.showHelp(); + } + + const QString route = args.empty() ? DEMO_ROUTE : args.first(); + QStringList allow = parser.value("allow").isEmpty() ? QStringList{} : parser.value("allow").split(","); + QStringList block = parser.value("block").isEmpty() ? QStringList{} : parser.value("block").split(","); + + uint32_t replay_flags = REPLAY_FLAG_NONE; + for (const auto &[name, flag, _] : flags) { + if (parser.isSet(name)) { + replay_flags |= flag; + } + } + replay = new Replay(route, allow, block, nullptr, replay_flags, parser.value("data_dir"), &app); + if (!replay->load()) { + return 0; + } + replay->start(parser.value("start").toInt()); + // start keyboard control thread + QThread *t = new QThread(); + QObject::connect(t, &QThread::started, [=]() { keyboardThread(replay); }); + QObject::connect(t, &QThread::finished, t, &QThread::deleteLater); + t->start(); + + return app.exec(); +} diff --git a/selfdrive/ui/replay/replay.cc b/selfdrive/ui/replay/replay.cc new file mode 100644 index 00000000000000..8155eb3456744f --- /dev/null +++ b/selfdrive/ui/replay/replay.cc @@ -0,0 +1,343 @@ +#include "selfdrive/ui/replay/replay.h" + +#include +#include + +#include +#include "cereal/services.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/timing.h" +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/replay/util.h" + +Replay::Replay(QString route, QStringList allow, QStringList block, SubMaster *sm_, uint32_t flags, QString data_dir, QObject *parent) + : sm(sm_), flags_(flags), QObject(parent) { + std::vector s; + auto event_struct = capnp::Schema::from().asStruct(); + sockets_.resize(event_struct.getUnionFields().size()); + for (const auto &it : services) { + if ((allow.empty() || allow.contains(it.name)) && !block.contains(it.name)) { + uint16_t which = event_struct.getFieldByName(it.name).getProto().getDiscriminantValue(); + sockets_[which] = it.name; + s.push_back(it.name); + } + } + qDebug() << "services " << s; + + if (sm == nullptr) { + pm = std::make_unique(s); + } + route_ = std::make_unique(route, data_dir); + events_ = std::make_unique>(); + new_events_ = std::make_unique>(); + + connect(this, &Replay::seekTo, this, &Replay::doSeek); + connect(this, &Replay::segmentChanged, this, &Replay::queueSegment); +} + +Replay::~Replay() { + stop(); +} + +void Replay::stop() { + if (!stream_thread_ && segments_.empty()) return; + + qDebug() << "shutdown: in progress..."; + if (stream_thread_ != nullptr) { + exit_ = updating_events_ = true; + stream_cv_.notify_one(); + stream_thread_->quit(); + stream_thread_->wait(); + stream_thread_ = nullptr; + } + segments_.clear(); + camera_server_.reset(nullptr); + qDebug() << "shutdown: done"; +} + +bool Replay::load() { + if (!route_->load()) { + qCritical() << "failed to load route" << route_->name() << "from server"; + return false; + } + + for (auto &[n, f] : route_->segments()) { + if ((!f.rlog.isEmpty() || !f.qlog.isEmpty()) && (!f.road_cam.isEmpty() || !f.qcamera.isEmpty())) { + segments_[n] = nullptr; + } + } + if (segments_.empty()) { + qCritical() << "no valid segments in route" << route_->name(); + return false; + } + qInfo() << "load route" << route_->name() << "with" << segments_.size() << "valid segments"; + return true; +} + +void Replay::start(int seconds) { + seekTo(route_->identifier().segment_id * 60 + seconds, false); +} + +void Replay::updateEvents(const std::function &lambda) { + // set updating_events to true to force stream thread relase the lock and wait for evnets_udpated. + updating_events_ = true; + { + std::unique_lock lk(stream_lock_); + events_updated_ = lambda(); + updating_events_ = false; + } + stream_cv_.notify_one(); +} + +void Replay::doSeek(int seconds, bool relative) { + if (segments_.empty()) return; + + updateEvents([&]() { + if (relative) { + seconds += currentSeconds(); + } + seconds = std::max(0, seconds); + int seg = seconds / 60; + if (segments_.find(seg) == segments_.end()) { + qWarning() << "can't seek to" << seconds << "s, segment" << seg << "is invalid"; + return true; + } + + qInfo() << "seeking to" << seconds << "s, segment" << seg; + current_segment_ = seg; + cur_mono_time_ = route_start_ts_ + seconds * 1e9; + return isSegmentMerged(seg); + }); + queueSegment(); +} + +void Replay::pause(bool pause) { + updateEvents([=]() { + qInfo() << (pause ? "paused..." : "resuming"); + if (pause) { + qInfo() << "at " << currentSeconds() << "s"; + } + paused_ = pause; + return true; + }); +} + +void Replay::setCurrentSegment(int n) { + if (current_segment_.exchange(n) != n) { + emit segmentChanged(); + } +} + +void Replay::segmentLoadFinished(bool success) { + if (!success) { + Segment *seg = qobject_cast(sender()); + qWarning() << "failed to load segment " << seg->seg_num << ", removing it from current replay list"; + segments_.erase(seg->seg_num); + } + queueSegment(); +} + +void Replay::queueSegment() { + if (segments_.empty()) return; + + SegmentMap::iterator cur, end; + cur = end = segments_.lower_bound(std::min(current_segment_.load(), segments_.rbegin()->first)); + for (int i = 0; end != segments_.end() && i <= FORWARD_SEGS; ++i) { + ++end; + } + // load one segment at a time + for (auto it = cur; it != end; ++it) { + if (!it->second) { + if (it == cur || std::prev(it)->second->isLoaded()) { + auto &[n, seg] = *it; + seg = std::make_unique(n, route_->at(n), flags_); + QObject::connect(seg.get(), &Segment::loadFinished, this, &Replay::segmentLoadFinished); + qDebug() << "loading segment" << n << "..."; + } + break; + } + } + const auto &cur_segment = cur->second; + enableHttpLogging(!cur_segment->isLoaded()); + + // merge the previous adjacent segment if it's loaded + auto begin = segments_.find(cur_segment->seg_num - 1); + if (begin == segments_.end() || !(begin->second && begin->second->isLoaded())) { + begin = cur; + } + mergeSegments(begin, end); + + // free segments out of current semgnt window. + std::for_each(segments_.begin(), begin, [](auto &e) { e.second.reset(nullptr); }); + std::for_each(end, segments_.end(), [](auto &e) { e.second.reset(nullptr); }); + + // start stream thread + if (stream_thread_ == nullptr && cur_segment->isLoaded()) { + startStream(cur_segment.get()); + } +} + +void Replay::mergeSegments(const SegmentMap::iterator &begin, const SegmentMap::iterator &end) { + // merge 3 segments in sequence. + std::vector segments_need_merge; + size_t new_events_size = 0; + for (auto it = begin; it != end && it->second->isLoaded() && segments_need_merge.size() < 3; ++it) { + segments_need_merge.push_back(it->first); + new_events_size += it->second->log->events.size(); + } + + if (segments_need_merge != segments_merged_) { + qDebug() << "merge segments" << segments_need_merge; + new_events_->clear(); + new_events_->reserve(new_events_size); + for (int n : segments_need_merge) { + const auto &e = segments_[n]->log->events; + auto middle = new_events_->insert(new_events_->end(), e.begin(), e.end()); + std::inplace_merge(new_events_->begin(), middle, new_events_->end(), Event::lessThan()); + } + + updateEvents([&]() { + events_.swap(new_events_); + segments_merged_ = segments_need_merge; + return true; + }); + } +} + +void Replay::startStream(const Segment *cur_segment) { + const auto &events = cur_segment->log->events; + + // get route start time from initData + auto it = std::find_if(events.begin(), events.end(), [](auto e) { return e->which == cereal::Event::Which::INIT_DATA; }); + route_start_ts_ = it != events.end() ? (*it)->mono_time : events[0]->mono_time; + cur_mono_time_ += route_start_ts_; + + // write CarParams + it = std::find_if(events.begin(), events.end(), [](auto e) { return e->which == cereal::Event::Which::CAR_PARAMS; }); + if (it != events.end()) { + auto bytes = (*it)->bytes(); + Params().put("CarParams", (const char *)bytes.begin(), bytes.size()); + } else { + qWarning() << "failed to read CarParams from current segment"; + } + + // start camera server + std::pair camera_size[MAX_CAMERAS] = {}; + for (auto type : ALL_CAMERAS) { + if (auto &fr = cur_segment->frames[type]) { + camera_size[type] = {fr->width, fr->height}; + } + } + camera_server_ = std::make_unique(camera_size, flags_ & REPLAY_FLAG_SEND_YUV); + + // start stream thread + stream_thread_ = new QThread(); + QObject::connect(stream_thread_, &QThread::started, [=]() { stream(); }); + QObject::connect(stream_thread_, &QThread::finished, stream_thread_, &QThread::deleteLater); + stream_thread_->start(); +} + +void Replay::publishMessage(const Event *e) { + if (sm == nullptr) { + auto bytes = e->bytes(); + int ret = pm->send(sockets_[e->which], (capnp::byte *)bytes.begin(), bytes.size()); + if (ret == -1) { + qDebug() << "stop publishing" << sockets_[e->which] << "due to multiple publishers error"; + sockets_[e->which] = nullptr; + } + } else { + sm->update_msgs(nanos_since_boot(), {{sockets_[e->which], e->event}}); + } +} + +void Replay::publishFrame(const Event *e) { + static const std::map cam_types{ + {cereal::Event::ROAD_ENCODE_IDX, RoadCam}, + {cereal::Event::DRIVER_ENCODE_IDX, DriverCam}, + {cereal::Event::WIDE_ROAD_ENCODE_IDX, WideRoadCam}, + }; + if ((e->which == cereal::Event::DRIVER_ENCODE_IDX && !(flags_ & REPLAY_FLAG_DCAM)) || + (e->which == cereal::Event::WIDE_ROAD_ENCODE_IDX && !(flags_ & REPLAY_FLAG_ECAM))) { + return; + } + auto eidx = capnp::AnyStruct::Reader(e->event).getPointerSection()[0].getAs(); + if (eidx.getType() == cereal::EncodeIndex::Type::FULL_H_E_V_C && isSegmentMerged(eidx.getSegmentNum())) { + CameraType cam = cam_types.at(e->which); + camera_server_->pushFrame(cam, segments_[eidx.getSegmentNum()]->frames[cam].get(), eidx); + } +} + +void Replay::stream() { + float last_print = 0; + cereal::Event::Which cur_which = cereal::Event::Which::INIT_DATA; + + std::unique_lock lk(stream_lock_); + + while (true) { + stream_cv_.wait(lk, [=]() { return exit_ || (events_updated_ && !paused_); }); + events_updated_ = false; + if (exit_) break; + + Event cur_event(cur_which, cur_mono_time_); + auto eit = std::upper_bound(events_->begin(), events_->end(), &cur_event, Event::lessThan()); + if (eit == events_->end()) { + qDebug() << "waiting for events..."; + continue; + } + + uint64_t evt_start_ts = cur_mono_time_; + uint64_t loop_start_ts = nanos_since_boot(); + + for (auto end = events_->end(); !updating_events_ && eit != end; ++eit) { + const Event *evt = (*eit); + cur_which = evt->which; + cur_mono_time_ = evt->mono_time; + const int current_ts = currentSeconds(); + if (last_print > current_ts || (current_ts - last_print) > 5.0) { + last_print = current_ts; + qInfo() << "at " << current_ts << "s"; + } + setCurrentSegment(current_ts / 60); + + // migration for pandaState -> pandaStates to keep UI working for old segments + if (cur_which == cereal::Event::Which::PANDA_STATE_D_E_P_R_E_C_A_T_E_D) { + MessageBuilder msg; + auto ps = msg.initEvent().initPandaStates(1); + ps[0].setIgnitionLine(true); + ps[0].setPandaType(cereal::PandaState::PandaType::DOS); + pm->send(sockets_[cereal::Event::Which::PANDA_STATES], msg); + } + + if (cur_which < sockets_.size() && sockets_[cur_which] != nullptr) { + // keep time + long etime = cur_mono_time_ - evt_start_ts; + long rtime = nanos_since_boot() - loop_start_ts; + long behind_ns = etime - rtime; + // if behind_ns is greater than 1 second, it means that an invalid segemnt is skipped by seeking/replaying + if (behind_ns >= 1 * 1e9) { + // reset start times + evt_start_ts = cur_mono_time_; + loop_start_ts = nanos_since_boot(); + } else if (behind_ns > 0) { + precise_nano_sleep(behind_ns); + } + + if (evt->frame) { + publishFrame(evt); + } else { + publishMessage(evt); + } + } + } + // wait for frame to be sent before unlock.(frameReader may be deleted after unlock) + camera_server_->waitFinish(); + + if (eit == events_->end() && !(flags_ & REPLAY_FLAG_NO_LOOP)) { + int last_segment = segments_.rbegin()->first; + if (current_segment_ >= last_segment && isSegmentMerged(last_segment)) { + qInfo() << "reaches the end of route, restart from beginning"; + emit seekTo(0, false); + } + } + } +} diff --git a/selfdrive/ui/replay/replay.h b/selfdrive/ui/replay/replay.h new file mode 100644 index 00000000000000..a3e6efaadbcb39 --- /dev/null +++ b/selfdrive/ui/replay/replay.h @@ -0,0 +1,83 @@ +#pragma once + +#include + +#include "selfdrive/ui/replay/camera.h" +#include "selfdrive/ui/replay/route.h" + +// one segment uses about 100M of memory +constexpr int FORWARD_SEGS = 5; + +enum REPLAY_FLAGS { + REPLAY_FLAG_NONE = 0x0000, + REPLAY_FLAG_DCAM = 0x0002, + REPLAY_FLAG_ECAM = 0x0004, + REPLAY_FLAG_NO_LOOP = 0x0010, + REPLAY_FLAG_NO_FILE_CACHE = 0x0020, + REPLAY_FLAG_QCAMERA = 0x0040, + REPLAY_FLAG_SEND_YUV = 0x0080, + REPLAY_FLAG_NO_CUDA = 0x0100, +}; + +class Replay : public QObject { + Q_OBJECT + +public: + Replay(QString route, QStringList allow, QStringList block, SubMaster *sm = nullptr, + uint32_t flags = REPLAY_FLAG_NONE, QString data_dir = "", QObject *parent = 0); + ~Replay(); + bool load(); + void start(int seconds = 0); + void stop(); + void pause(bool pause); + bool isPaused() const { return paused_; } + +signals: + void segmentChanged(); + void seekTo(int seconds, bool relative); + +protected slots: + void queueSegment(); + void doSeek(int seconds, bool relative); + void segmentLoadFinished(bool sucess); + +protected: + typedef std::map> SegmentMap; + void startStream(const Segment *cur_segment); + void stream(); + void setCurrentSegment(int n); + void mergeSegments(const SegmentMap::iterator &begin, const SegmentMap::iterator &end); + void updateEvents(const std::function& lambda); + void publishMessage(const Event *e); + void publishFrame(const Event *e); + inline int currentSeconds() const { return (cur_mono_time_ - route_start_ts_) / 1e9; } + inline bool isSegmentMerged(int n) { + return std::find(segments_merged_.begin(), segments_merged_.end(), n) != segments_merged_.end(); + } + + QThread *stream_thread_ = nullptr; + + // logs + std::mutex stream_lock_; + std::condition_variable stream_cv_; + std::atomic updating_events_ = false; + std::atomic current_segment_ = 0; + SegmentMap segments_; + // the following variables must be protected with stream_lock_ + bool exit_ = false; + bool paused_ = false; + bool events_updated_ = false; + uint64_t route_start_ts_ = 0; + uint64_t cur_mono_time_ = 0; + std::unique_ptr> events_; + std::unique_ptr> new_events_; + std::vector segments_merged_; + + // messaging + SubMaster *sm = nullptr; + std::unique_ptr pm; + std::vector sockets_; + std::unique_ptr route_; + std::unique_ptr camera_server_; + uint32_t flags_ = REPLAY_FLAG_NONE; +}; diff --git a/selfdrive/ui/replay/route.cc b/selfdrive/ui/replay/route.cc new file mode 100644 index 00000000000000..23c27073cbc4c7 --- /dev/null +++ b/selfdrive/ui/replay/route.cc @@ -0,0 +1,134 @@ +#include "selfdrive/ui/replay/route.h" + +#include +#include +#include +#include +#include +#include + +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/qt/api.h" +#include "selfdrive/ui/replay/replay.h" +#include "selfdrive/ui/replay/util.h" + +Route::Route(const QString &route, const QString &data_dir) : data_dir_(data_dir) { + route_ = parseRoute(route); +} + +RouteIdentifier Route::parseRoute(const QString &str) { + QRegExp rx(R"(^([a-z0-9]{16})([|_/])(\d{4}-\d{2}-\d{2}--\d{2}-\d{2}-\d{2})(?:(--|/)(\d*))?$)"); + if (rx.indexIn(str) == -1) return {}; + + const QStringList list = rx.capturedTexts(); + return {list[1], list[3], list[5].toInt(), list[1] + "|" + list[3]}; +} + +bool Route::load() { + if (route_.str.isEmpty()) { + qInfo() << "invalid route format"; + return false; + } + return data_dir_.isEmpty() ? loadFromServer() : loadFromLocal(); +} + +bool Route::loadFromServer() { + QEventLoop loop; + HttpRequest http(nullptr, !Hardware::PC()); + QObject::connect(&http, &HttpRequest::requestDone, [&](const QString &json, bool success) { + loop.exit(success ? loadFromJson(json) : 0); + }); + http.sendRequest("https://api.commadotai.com/v1/route/" + route_.str + "/files"); + return loop.exec(); +} + +bool Route::loadFromJson(const QString &json) { + QRegExp rx(R"(\/(\d+)\/)"); + for (const auto &value : QJsonDocument::fromJson(json.trimmed().toUtf8()).object()) { + for (const auto &url : value.toArray()) { + QString url_str = url.toString(); + if (rx.indexIn(url_str) != -1) { + addFileToSegment(rx.cap(1).toInt(), url_str); + } + } + } + return !segments_.empty(); +} + +bool Route::loadFromLocal() { + QDir log_dir(data_dir_); + for (const auto &folder : log_dir.entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot, QDir::NoSort)) { + int pos = folder.lastIndexOf("--"); + if (pos != -1 && folder.left(pos) == route_.timestamp) { + const int seg_num = folder.mid(pos + 2).toInt(); + QDir segment_dir(log_dir.filePath(folder)); + for (const auto &f : segment_dir.entryList(QDir::Files)) { + addFileToSegment(seg_num, segment_dir.absoluteFilePath(f)); + } + } + } + return !segments_.empty(); +} + +void Route::addFileToSegment(int n, const QString &file) { + const QString name = QUrl(file).fileName(); + if (name == "rlog.bz2") { + segments_[n].rlog = file; + } else if (name == "qlog.bz2") { + segments_[n].qlog = file; + } else if (name == "fcamera.hevc") { + segments_[n].road_cam = file; + } else if (name == "dcamera.hevc") { + segments_[n].driver_cam = file; + } else if (name == "ecamera.hevc") { + segments_[n].wide_road_cam = file; + } else if (name == "qcamera.ts") { + segments_[n].qcamera = file; + } +} + +// class Segment + +Segment::Segment(int n, const SegmentFile &files, uint32_t flags) : seg_num(n), flags(flags) { + // [RoadCam, DriverCam, WideRoadCam, log]. fallback to qcamera/qlog + const QString file_list[] = { + (flags & REPLAY_FLAG_QCAMERA) || files.road_cam.isEmpty() ? files.qcamera : files.road_cam, + flags & REPLAY_FLAG_DCAM ? files.driver_cam : "", + flags & REPLAY_FLAG_ECAM ? files.wide_road_cam : "", + files.rlog.isEmpty() ? files.qlog : files.rlog, + }; + for (int i = 0; i < std::size(file_list); i++) { + if (!file_list[i].isEmpty()) { + loading_++; + synchronizer_.addFuture(QtConcurrent::run([=] { loadFile(i, file_list[i].toStdString()); })); + } + } +} + +Segment::~Segment() { + disconnect(); + abort_ = true; + synchronizer_.setCancelOnWait(true); + synchronizer_.waitForFinished(); +} + +void Segment::loadFile(int id, const std::string file) { + const bool local_cache = !(flags & REPLAY_FLAG_NO_FILE_CACHE); + bool success = false; + if (id < MAX_CAMERAS) { + frames[id] = std::make_unique(); + success = frames[id]->load(file, flags & REPLAY_FLAG_NO_CUDA, &abort_, local_cache, 20 * 1024 * 1024, 3); + } else { + log = std::make_unique(); + success = log->load(file, &abort_, local_cache, 0, 3); + } + + if (!success) { + // abort all loading jobs. + abort_ = true; + } + + if (--loading_ == 0) { + emit loadFinished(!abort_); + } +} diff --git a/selfdrive/ui/replay/route.h b/selfdrive/ui/replay/route.h new file mode 100644 index 00000000000000..c39eef7d92ef4c --- /dev/null +++ b/selfdrive/ui/replay/route.h @@ -0,0 +1,67 @@ +#pragma once + +#include + +#include "selfdrive/ui/replay/framereader.h" +#include "selfdrive/ui/replay/logreader.h" +#include "selfdrive/ui/replay/util.h" + +struct RouteIdentifier { + QString dongle_id; + QString timestamp; + int segment_id; + QString str; +}; + +struct SegmentFile { + QString rlog; + QString qlog; + QString road_cam; + QString driver_cam; + QString wide_road_cam; + QString qcamera; +}; + +class Route { +public: + Route(const QString &route, const QString &data_dir = {}); + bool load(); + inline const QString &name() const { return route_.str; } + inline const RouteIdentifier &identifier() const { return route_; } + inline const std::map &segments() const { return segments_; } + inline const SegmentFile &at(int n) { return segments_.at(n); } + static RouteIdentifier parseRoute(const QString &str); + +protected: + bool loadFromLocal(); + bool loadFromServer(); + bool loadFromJson(const QString &json); + void addFileToSegment(int seg_num, const QString &file); + RouteIdentifier route_ = {}; + QString data_dir_; + std::map segments_; +}; + +class Segment : public QObject { + Q_OBJECT + +public: + Segment(int n, const SegmentFile &files, uint32_t flags); + ~Segment(); + inline bool isLoaded() const { return !loading_ && !abort_; } + + const int seg_num = 0; + std::unique_ptr log; + std::unique_ptr frames[MAX_CAMERAS] = {}; + +signals: + void loadFinished(bool success); + +protected: + void loadFile(int id, const std::string file); + + std::atomic abort_ = false; + std::atomic loading_ = 0; + QFutureSynchronizer synchronizer_; + uint32_t flags; +}; diff --git a/selfdrive/ui/replay/util.cc b/selfdrive/ui/replay/util.cc new file mode 100644 index 00000000000000..d6791465f21132 --- /dev/null +++ b/selfdrive/ui/replay/util.cc @@ -0,0 +1,261 @@ +#include "selfdrive/ui/replay/util.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "selfdrive/common/timing.h" +#include "selfdrive/common/util.h" + +namespace { + +static std::atomic enable_http_logging = false; + +struct CURLGlobalInitializer { + CURLGlobalInitializer() { curl_global_init(CURL_GLOBAL_DEFAULT); } + ~CURLGlobalInitializer() { curl_global_cleanup(); } +}; + +template +struct MultiPartWriter { + T *buf; + size_t *total_written; + size_t offset; + size_t end; + + size_t write(char *data, size_t size, size_t count) { + size_t bytes = size * count; + if ((offset + bytes) > end) return 0; + + if constexpr (std::is_same::value) { + memcpy(buf->data() + offset, data, bytes); + } else if constexpr (std::is_same::value) { + buf->seekp(offset); + buf->write(data, bytes); + } + + offset += bytes; + *total_written += bytes; + return bytes; + } +}; + +template +size_t write_cb(char *data, size_t size, size_t count, void *userp) { + auto w = (MultiPartWriter *)userp; + return w->write(data, size, count); +} + +size_t dumy_write_cb(char *data, size_t size, size_t count, void *userp) { return size * count; } + +std::string formattedDataSize(size_t size) { + if (size < 1024) { + return std::to_string(size) + " B"; + } else if (size < 1024 * 1024) { + return util::string_format("%.2f KB", (float)size / 1024); + } else { + return util::string_format("%.2f MB", (float)size / (1024 * 1024)); + } +} + +} // namespace + +size_t getRemoteFileSize(const std::string &url) { + CURL *curl = curl_easy_init(); + if (!curl) return -1; + + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, dumy_write_cb); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + curl_easy_setopt(curl, CURLOPT_NOBODY, 1); + CURLcode res = curl_easy_perform(curl); + double content_length = -1; + if (res == CURLE_OK) { + curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &content_length); + } else { + std::cout << "Download failed: error code: " << res << std::endl; + } + curl_easy_cleanup(curl); + return content_length > 0 ? (size_t)content_length : 0; +} + +std::string getUrlWithoutQuery(const std::string &url) { + size_t idx = url.find("?"); + return (idx == std::string::npos ? url : url.substr(0, idx)); +} + +void enableHttpLogging(bool enable) { + enable_http_logging = enable; +} + +template +bool httpDownload(const std::string &url, T &buf, size_t chunk_size, size_t content_length, std::atomic *abort) { + static CURLGlobalInitializer curl_initializer; + + int parts = 1; + if (chunk_size > 0 && content_length > 10 * 1024 * 1024) { + parts = std::nearbyint(content_length / (float)chunk_size); + parts = std::clamp(parts, 1, 5); + } + + CURLM *cm = curl_multi_init(); + size_t written = 0; + std::map> writers; + const int part_size = content_length / parts; + for (int i = 0; i < parts; ++i) { + CURL *eh = curl_easy_init(); + writers[eh] = { + .buf = &buf, + .total_written = &written, + .offset = (size_t)(i * part_size), + .end = i == parts - 1 ? content_length : (i + 1) * part_size, + }; + curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, write_cb); + curl_easy_setopt(eh, CURLOPT_WRITEDATA, (void *)(&writers[eh])); + curl_easy_setopt(eh, CURLOPT_URL, url.c_str()); + curl_easy_setopt(eh, CURLOPT_RANGE, util::string_format("%d-%d", writers[eh].offset, writers[eh].end - 1).c_str()); + curl_easy_setopt(eh, CURLOPT_HTTPGET, 1); + curl_easy_setopt(eh, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(eh, CURLOPT_FOLLOWLOCATION, 1); + + curl_multi_add_handle(cm, eh); + } + + size_t prev_written = 0; + double last_print = millis_since_boot(); + int still_running = 1; + while (still_running > 0 && !(abort && *abort)) { + curl_multi_wait(cm, nullptr, 0, 1000, nullptr); + curl_multi_perform(cm, &still_running); + + if (enable_http_logging) { + if (double ts = millis_since_boot(); (ts - last_print) > 2 * 1000) { + size_t average = (written - prev_written) / ((ts - last_print) / 1000.); + int progress = std::min(100, 100.0 * (double)written / (double)content_length); + std::cout << "downloading " << getUrlWithoutQuery(url) << " - " << progress + << "% (" << formattedDataSize(average) << "/s)" << std::endl; + last_print = ts; + prev_written = written; + } + } + } + + CURLMsg *msg; + int msgs_left = -1; + int complete = 0; + while ((msg = curl_multi_info_read(cm, &msgs_left)) && !(abort && *abort)) { + if (msg->msg == CURLMSG_DONE) { + if (msg->data.result == CURLE_OK) { + long res_status = 0; + curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &res_status); + if (res_status == 206) { + complete++; + } else { + std::cout << "Download failed: http error code: " << res_status << std::endl; + } + } else { + std::cout << "Download failed: connection failure: " << msg->data.result << std::endl; + } + } + } + + for (const auto &[e, w] : writers) { + curl_multi_remove_handle(cm, e); + curl_easy_cleanup(e); + } + curl_multi_cleanup(cm); + + return complete == parts; +} + +std::string httpGet(const std::string &url, size_t chunk_size, std::atomic *abort) { + size_t size = getRemoteFileSize(url); + if (size == 0) return {}; + + std::string result(size, '\0'); + return httpDownload(url, result, chunk_size, size, abort) ? result : ""; +} + +bool httpDownload(const std::string &url, const std::string &file, size_t chunk_size, std::atomic *abort) { + size_t size = getRemoteFileSize(url); + if (size == 0) return false; + + std::ofstream of(file, std::ios::binary | std::ios::out); + of.seekp(size - 1).write("\0", 1); + return httpDownload(url, of, chunk_size, size, abort); +} + +std::string decompressBZ2(const std::string &in) { + return decompressBZ2((std::byte *)in.data(), in.size()); +} + +std::string decompressBZ2(const std::byte *in, size_t in_size) { + if (in_size == 0) return {}; + + bz_stream strm = {}; + int bzerror = BZ2_bzDecompressInit(&strm, 0, 0); + assert(bzerror == BZ_OK); + + strm.next_in = (char *)in; + strm.avail_in = in_size; + std::string out(in_size * 5, '\0'); + do { + strm.next_out = (char *)(&out[strm.total_out_lo32]); + strm.avail_out = out.size() - strm.total_out_lo32; + + const char *prev_write_pos = strm.next_out; + bzerror = BZ2_bzDecompress(&strm); + if (bzerror == BZ_OK && prev_write_pos == strm.next_out) { + // content is corrupt + bzerror = BZ_STREAM_END; + std::cout << "decompressBZ2 error : content is corrupt" << std::endl; + break; + } + + if (bzerror == BZ_OK && strm.avail_in > 0 && strm.avail_out == 0) { + out.resize(out.size() * 2); + } + } while (bzerror == BZ_OK); + + BZ2_bzDecompressEnd(&strm); + if (bzerror == BZ_STREAM_END) { + out.resize(strm.total_out_lo32); + return out; + } + return {}; +} + +void precise_nano_sleep(long sleep_ns) { + const long estimate_ns = 1 * 1e6; // 1ms + struct timespec req = {.tv_nsec = estimate_ns}; + uint64_t start_sleep = nanos_since_boot(); + while (sleep_ns > estimate_ns) { + nanosleep(&req, nullptr); + uint64_t end_sleep = nanos_since_boot(); + sleep_ns -= (end_sleep - start_sleep); + start_sleep = end_sleep; + } + // spin wait + if (sleep_ns > 0) { + while ((nanos_since_boot() - start_sleep) <= sleep_ns) { + usleep(0); + } + } +} + +std::string sha256(const std::string &str) { + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX sha256; + SHA256_Init(&sha256); + SHA256_Update(&sha256, str.c_str(), str.size()); + SHA256_Final(hash, &sha256); + return util::hexdump(hash, SHA256_DIGEST_LENGTH); +} diff --git a/selfdrive/ui/replay/util.h b/selfdrive/ui/replay/util.h new file mode 100644 index 00000000000000..726e65cb9430a3 --- /dev/null +++ b/selfdrive/ui/replay/util.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +std::string sha256(const std::string &str); +void precise_nano_sleep(long sleep_ns); +std::string decompressBZ2(const std::string &in); +std::string decompressBZ2(const std::byte *in, size_t in_size); +void enableHttpLogging(bool enable); +std::string getUrlWithoutQuery(const std::string &url); +size_t getRemoteFileSize(const std::string &url); +std::string httpGet(const std::string &url, size_t chunk_size = 0, std::atomic *abort = nullptr); +bool httpDownload(const std::string &url, const std::string &file, size_t chunk_size = 0, std::atomic *abort = nullptr); diff --git a/selfdrive/ui/slplay.c b/selfdrive/ui/slplay.c deleted file mode 100644 index 2085057664b521..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/soundd/.gitignore b/selfdrive/ui/soundd/.gitignore new file mode 100644 index 00000000000000..c47f949d377a77 --- /dev/null +++ b/selfdrive/ui/soundd/.gitignore @@ -0,0 +1 @@ +_soundd diff --git a/selfdrive/ui/soundd/main.cc b/selfdrive/ui/soundd/main.cc new file mode 100644 index 00000000000000..64088deff83d21 --- /dev/null +++ b/selfdrive/ui/soundd/main.cc @@ -0,0 +1,22 @@ +#include + +#include + +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/soundd/sound.h" + +void sigHandler(int s) { + qApp->quit(); +} + +int main(int argc, char **argv) { + qInstallMessageHandler(swagLogMessageHandler); + setpriority(PRIO_PROCESS, 0, -20); + + QApplication a(argc, argv); + std::signal(SIGINT, sigHandler); + std::signal(SIGTERM, sigHandler); + + Sound sound; + return a.exec(); +} diff --git a/selfdrive/ui/soundd/sound.cc b/selfdrive/ui/soundd/sound.cc new file mode 100644 index 00000000000000..f303aa92bfdac0 --- /dev/null +++ b/selfdrive/ui/soundd/sound.cc @@ -0,0 +1,81 @@ +#include "selfdrive/ui/soundd/sound.h" + +#include + +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/util.h" + +// TODO: detect when we can't play sounds +// TODO: detect when we can't display the UI + +Sound::Sound(QObject *parent) : sm({"carState", "controlsState", "deviceState"}) { + qInfo() << "default audio device: " << QAudioDeviceInfo::defaultOutputDevice().deviceName(); + + for (auto &[alert, fn, loops] : sound_list) { + QSoundEffect *s = new QSoundEffect(this); + QObject::connect(s, &QSoundEffect::statusChanged, [=]() { + assert(s->status() != QSoundEffect::Error); + }); + s->setVolume(Hardware::MIN_VOLUME); + s->setSource(QUrl::fromLocalFile("../../assets/sounds/" + fn)); + sounds[alert] = {s, loops}; + } + + QTimer *timer = new QTimer(this); + QObject::connect(timer, &QTimer::timeout, this, &Sound::update); + timer->start(1000 / UI_FREQ); +}; + +void Sound::update() { + const bool started_prev = sm["deviceState"].getDeviceState().getStarted(); + sm.update(0); + + const bool started = sm["deviceState"].getDeviceState().getStarted(); + if (started && !started_prev) { + started_frame = sm.frame; + } + + // no sounds while offroad + // also no sounds if nothing is alive in case thermald crashes while offroad + const bool crashed = (sm.frame - std::max(sm.rcv_frame("deviceState"), sm.rcv_frame("controlsState"))) > 10*UI_FREQ; + if (!started || crashed) { + setAlert({}); + return; + } + + // scale volume with speed + if (sm.updated("carState")) { + float volume = util::map_val(sm["carState"].getCarState().getVEgo(), 11.f, 20.f, 0.f, 1.0f); + volume = QAudio::convertVolume(volume, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale); + volume = util::map_val(volume, 0.f, 1.f, Hardware::MIN_VOLUME, Hardware::MAX_VOLUME); + for (auto &[s, loops] : sounds) { + s->setVolume(std::round(100 * volume) / 100); + } + } + + setAlert(Alert::get(sm, started_frame)); +} + +void Sound::setAlert(const Alert &alert) { + if (!current_alert.equal(alert)) { + current_alert = alert; + // stop sounds + for (auto &[s, loops] : sounds) { + // Only stop repeating sounds + if (s->loopsRemaining() > 1 || s->loopsRemaining() == QSoundEffect::Infinite) { + s->stop(); + } + } + + // play sound + if (alert.sound != AudibleAlert::NONE) { + auto &[s, loops] = sounds[alert.sound]; + s->setLoopCount(loops); + s->play(); + } + } +} diff --git a/selfdrive/ui/soundd/sound.h b/selfdrive/ui/soundd/sound.h new file mode 100644 index 00000000000000..b493c3a3d8e0e2 --- /dev/null +++ b/selfdrive/ui/soundd/sound.h @@ -0,0 +1,34 @@ +#include +#include +#include + +#include "selfdrive/hardware/hw.h" +#include "selfdrive/ui/ui.h" + +const std::tuple sound_list[] = { + // AudibleAlert, file name, loop count + {AudibleAlert::ENGAGE, "engage.wav", 0}, + {AudibleAlert::DISENGAGE, "disengage.wav", 0}, + {AudibleAlert::REFUSE, "refuse.wav", 0}, + + {AudibleAlert::PROMPT, "prompt.wav", 0}, + {AudibleAlert::PROMPT_REPEAT, "prompt.wav", QSoundEffect::Infinite}, + {AudibleAlert::PROMPT_DISTRACTED, "prompt_distracted.wav", QSoundEffect::Infinite}, + + {AudibleAlert::WARNING_SOFT, "warning_soft.wav", QSoundEffect::Infinite}, + {AudibleAlert::WARNING_IMMEDIATE, "warning_immediate.wav", 10}, +}; + +class Sound : public QObject { +public: + explicit Sound(QObject *parent = 0); + +protected: + void update(); + void setAlert(const Alert &alert); + + Alert current_alert = {}; + QMap> sounds; + SubMaster sm; + uint64_t started_frame; +}; diff --git a/selfdrive/ui/soundd/soundd b/selfdrive/ui/soundd/soundd new file mode 100755 index 00000000000000..66dda46d5b68ea --- /dev/null +++ b/selfdrive/ui/soundd/soundd @@ -0,0 +1,5 @@ +#!/bin/sh +cd "$(dirname "$0")" +export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +export QT_QPA_PLATFORM="offscreen" +exec ./_soundd diff --git a/selfdrive/ui/spinner b/selfdrive/ui/spinner new file mode 100755 index 00000000000000..4a75ca25a4754e --- /dev/null +++ b/selfdrive/ui/spinner @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ -f /EON ] && [ ! -f qt/spinner ]; then + cp qt/spinner_aarch64 qt/spinner +elif [ -f /TICI ] && [ ! -f qt/spinner ]; then + cp qt/spinner_larch64 qt/spinner +fi + +export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +exec ./qt/spinner "$1" diff --git a/selfdrive/ui/spinner/spinner b/selfdrive/ui/spinner/spinner deleted file mode 100755 index acc86c78cd1229..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 ad74251502155f..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/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/text b/selfdrive/ui/text new file mode 100755 index 00000000000000..a7177c656f6937 --- /dev/null +++ b/selfdrive/ui/text @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ -f /EON ] && [ ! -f qt/text ]; then + cp qt/text_aarch64 qt/text +elif [ -f /TICI ] && [ ! -f qt/text ]; then + cp qt/text_larch64 qt/text +fi + +export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +exec ./qt/text "$1" diff --git a/selfdrive/ui/ui b/selfdrive/ui/ui new file mode 100755 index 00000000000000..68c8c2cad55295 --- /dev/null +++ b/selfdrive/ui/ui @@ -0,0 +1,5 @@ +#!/bin/sh +cd "$(dirname "$0")" +export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +export QT_PLUGIN_PATH="../../third_party/qt-plugins/$(uname -m)" +exec ./_ui diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c deleted file mode 100644 index 6e24c9220b862b..00000000000000 --- a/selfdrive/ui/ui.c +++ /dev/null @@ -1,2353 +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" - -#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 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; - float v_curvature; - bool decel_for_turn; - - 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; - - bool is_playing_alert; -} 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 { - 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 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]; - char alert_sound[64]; - 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 - 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) { - LOGW("awake normal"); - 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); - } - } -} - -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 { - const char* name; - const char* uri; - bool loop; -} sound_file; - -sound_file sound_table[] = { - { "chimeDisengage", "../assets/sounds/disengaged.wav", false }, - { "chimeEngage", "../assets/sounds/engaged.wav", false }, - { "chimeWarning1", "../assets/sounds/warning_1.wav", false }, - { "chimeWarning2", "../assets/sounds/warning_2.wav", false }, - { "chimeWarningRepeat", "../assets/sounds/warning_2.wav", true }, - { "chimeError", "../assets/sounds/error.wav", false }, - { "chimePrompt", "../assets/sounds/error.wav", false }, - { NULL, NULL, false }, -}; - -sound_file* get_sound_file_by_name(const char* name) { - for (sound_file *s = sound_table; s->name != NULL; s++) { - if (strcmp(s->name, name) == 0) { - return s; - } - } - - return NULL; -} - - -void ui_sound_init(char **error) { - slplay_setup(error); - if (*error) return; - - for (sound_file *s = sound_table; s->name != NULL; 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"); - -#ifdef SHOW_SPEEDLIMIT - s->map_data_sock_raw = sub_sock(s->ctx, "tcp://127.0.0.1:8065"); -#endif - - 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/courbd.ttf"); - assert(s->font_courbd >= 0); - s->font_sans_regular = nvgCreateFont(s->vg, "sans-regular", "../assets/OpenSans-Regular.ttf"); - assert(s->font_sans_regular >= 0); - s->font_sans_semibold = nvgCreateFont(s->vg, "sans-semibold", "../assets/OpenSans-SemiBold.ttf"); - assert(s->font_sans_semibold >= 0); - s->font_sans_bold = nvgCreateFont(s->vg, "sans-bold", "../assets/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; - 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); - 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]); - } - - 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; - 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; - -#ifdef SHOW_SPEEDLIMIT - viz_maxspeed_w += viz_maxspeed_xo; - viz_maxspeed_x += viz_maxspeed_w - (viz_maxspeed_xo * 2); -#else - viz_maxspeed_xo = 0; -#endif - - // 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)); - } - 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 (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); - } - -#ifdef DEBUG_TURN - if (s->scene.decel_for_turn && s->scene.engaged){ - int v_curvature = s->scene.v_curvature * 2.2369363 + 0.5; - snprintf(maxspeed_str, sizeof(maxspeed_str), "%d", v_curvature); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgFontSize(s->vg, 25*2.5); - nvgText(s->vg, 200 + viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 148, "TURN", NULL); - nvgFontSize(s->vg, 50*2.5); - nvgText(s->vg, 200 + viz_maxspeed_x+(viz_maxspeed_xo/2)+(viz_maxspeed_w/2), 242, maxspeed_str, NULL); - } -#endif -} - -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), "SPEED", NULL); - nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2 + (is_speedlim_valid ? 6 : 0), viz_speedlim_y + (is_speedlim_valid ? 90 : 85), "LIMIT", 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) { - 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_turn && s->scene.engaged && s->limit_set_speed) { - // 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); - -#ifdef SHOW_SPEEDLIMIT - ui_draw_vision_speedlimit(s); -#endif - 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) { - 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) { - if (s->status != status) { - s->status = status; - // 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(); - 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; - 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.v_curvature = datad.vCurvature; - s->scene.decel_for_turn = datad.decelForTurn; - - if (datad.alertSound.str && datad.alertSound.str[0] != '\0' && strcmp(s->alert_type, datad.alertType.str) != 0) { - char* error = NULL; - if (s->alert_sound[0] != '\0') { - sound_file* active_sound = get_sound_file_by_name(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_by_name(datad.alertSound.str); - slplay_play(sound->uri, sound->loop, &error); - if(error) { - LOGW("error playing sound: %s", error); - } - - snprintf(s->alert_sound, sizeof(s->alert_sound), "%s", datad.alertSound.str); - snprintf(s->alert_type, sizeof(s->alert_type), "%s", datad.alertType.str); - } else if ((!datad.alertSound.str || datad.alertSound.str[0] == '\0') && s->alert_sound[0] != '\0') { - sound_file* sound = get_sound_file_by_name(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[0] = '\0'; - } - - 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; - } 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.speedlimit = datad.speedLimit; - s->scene.speedlimit_valid = datad.speedLimitValid; - 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; - -#ifdef SHOW_SPEEDLIMIT - plus_sock_num++; - num_polls++; - polls[7].socket = s->map_data_sock_raw; - polls[7].events = ZMQ_POLLIN; -#endif - - 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[plus_sock_num].revents) { - // awake on any (old) activity - 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); - if (bg_status == s->status) { - // will always be signaled if it changes? - pthread_cond_wait(&s->bg_cond, &s->lock); - } - bg_status = s->status; - 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); - - 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); - - 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; - - set_volume(s, 13); -#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); - - 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 - int touch_x = -1, touch_y = -1; - int touched = touch_read(&touch, &touch_x, &touch_y); - if (touched == 1) { - set_awake(s, true); - } - } - } else { - // Car started, fetch a new rgb image from ipc and peek for zmq events. - 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; - } - } - // manage wakefulness - if (s->awake_timeout > 0) { - s->awake_timeout--; - } else { - set_awake(s, false); - } - // Don't waste resources on drawing in case screen is off or car is not started. - if (s->awake && s->vision_connected) { - 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(13, 11 + s->scene.v_ego / 15); // up one notch every 15 m/s, starting at 11 - set_volume(s, volume); - } - - 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..38c08eb484f685 --- /dev/null +++ b/selfdrive/ui/ui.cc @@ -0,0 +1,319 @@ +#include "selfdrive/ui/ui.h" + +#include +#include + +#include "common/transformations/orientation.hpp" +#include "selfdrive/common/params.h" +#include "selfdrive/common/swaglog.h" +#include "selfdrive/common/util.h" +#include "selfdrive/common/watchdog.h" +#include "selfdrive/hardware/hw.h" + +#define BACKLIGHT_DT 0.05 +#define BACKLIGHT_TS 10.00 +#define BACKLIGHT_OFFROAD 50 + +// Projects a point in car to space to the corresponding point in full frame +// image space. +static bool calib_frame_to_full_frame(const UIState *s, float in_x, float in_y, float in_z, QPointF *out) { + const float margin = 500.0f; + const QRectF clip_region{-margin, -margin, s->fb_w + 2 * margin, s->fb_h + 2 * margin}; + + const vec3 pt = (vec3){{in_x, in_y, in_z}}; + const vec3 Ep = matvecmul3(s->scene.view_from_calib, pt); + const vec3 KEp = matvecmul3(s->wide_camera ? ecam_intrinsic_matrix : fcam_intrinsic_matrix, Ep); + + // Project. + QPointF point = s->car_space_transform.map(QPointF{KEp.v[0] / KEp.v[2], KEp.v[1] / KEp.v[2]}); + if (clip_region.contains(point)) { + *out = point; + return true; + } + return false; +} + +static int get_path_length_idx(const cereal::ModelDataV2::XYZTData::Reader &line, const float path_height) { + const auto line_x = line.getX(); + int max_idx = 0; + for (int i = 0; i < TRAJECTORY_SIZE && line_x[i] < path_height; ++i) { + max_idx = i; + } + return max_idx; +} + +static void update_leads(UIState *s, const cereal::RadarState::Reader &radar_state, std::optional line) { + for (int i = 0; i < 2; ++i) { + auto lead_data = (i == 0) ? radar_state.getLeadOne() : radar_state.getLeadTwo(); + if (lead_data.getStatus()) { + float z = line ? (*line).getZ()[get_path_length_idx(*line, lead_data.getDRel())] : 0.0; + calib_frame_to_full_frame(s, lead_data.getDRel(), -lead_data.getYRel(), z + 1.22, &s->scene.lead_vertices[i]); + } + } +} + +static void update_line_data(const UIState *s, const cereal::ModelDataV2::XYZTData::Reader &line, + float y_off, float z_off, line_vertices_data *pvd, int max_idx) { + const auto line_x = line.getX(), line_y = line.getY(), line_z = line.getZ(); + QPointF *v = &pvd->v[0]; + for (int i = 0; i <= max_idx; i++) { + v += calib_frame_to_full_frame(s, line_x[i], line_y[i] - y_off, line_z[i] + z_off, v); + } + for (int i = max_idx; i >= 0; i--) { + v += calib_frame_to_full_frame(s, line_x[i], line_y[i] + y_off, line_z[i] + z_off, v); + } + pvd->cnt = v - pvd->v; + assert(pvd->cnt <= std::size(pvd->v)); +} + +static void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) { + UIScene &scene = s->scene; + auto model_position = model.getPosition(); + float max_distance = std::clamp(model_position.getX()[TRAJECTORY_SIZE - 1], + MIN_DRAW_DISTANCE, MAX_DRAW_DISTANCE); + + // update lane lines + const auto lane_lines = model.getLaneLines(); + const auto lane_line_probs = model.getLaneLineProbs(); + int max_idx = get_path_length_idx(lane_lines[0], max_distance); + for (int i = 0; i < std::size(scene.lane_line_vertices); i++) { + scene.lane_line_probs[i] = lane_line_probs[i]; + update_line_data(s, lane_lines[i], 0.025 * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_idx); + } + + // update road edges + const auto road_edges = model.getRoadEdges(); + const auto road_edge_stds = model.getRoadEdgeStds(); + for (int i = 0; i < std::size(scene.road_edge_vertices); i++) { + scene.road_edge_stds[i] = road_edge_stds[i]; + update_line_data(s, road_edges[i], 0.025, 0, &scene.road_edge_vertices[i], max_idx); + } + + // update path + auto lead_one = (*s->sm)["radarState"].getRadarState().getLeadOne(); + if (lead_one.getStatus()) { + const float lead_d = lead_one.getDRel() * 2.; + max_distance = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)), 0.0f, max_distance); + } + max_idx = get_path_length_idx(model_position, max_distance); + update_line_data(s, model_position, 0.5, 1.22, &scene.track_vertices, max_idx); +} + +static void update_sockets(UIState *s) { + s->sm->update(0); +} + +static void update_state(UIState *s) { + SubMaster &sm = *(s->sm); + UIScene &scene = s->scene; + + if (sm.updated("modelV2")) { + update_model(s, sm["modelV2"].getModelV2()); + } + if (sm.updated("radarState")) { + std::optional line; + if (sm.rcv_frame("modelV2") > 0) { + line = sm["modelV2"].getModelV2().getPosition(); + } + update_leads(s, sm["radarState"].getRadarState(), line); + } + if (sm.updated("liveCalibration")) { + scene.world_objects_visible = true; + auto rpy_list = sm["liveCalibration"].getLiveCalibration().getRpyCalib(); + Eigen::Vector3d rpy; + rpy << rpy_list[0], rpy_list[1], rpy_list[2]; + Eigen::Matrix3d device_from_calib = euler2rot(rpy); + Eigen::Matrix3d view_from_device; + view_from_device << 0,1,0, + 0,0,1, + 1,0,0; + Eigen::Matrix3d view_from_calib = view_from_device * device_from_calib; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + scene.view_from_calib.v[i*3 + j] = view_from_calib(i,j); + } + } + } + if (sm.updated("pandaStates")) { + auto pandaStates = sm["pandaStates"].getPandaStates(); + if (pandaStates.size() > 0) { + scene.pandaType = pandaStates[0].getPandaType(); + + if (scene.pandaType != cereal::PandaState::PandaType::UNKNOWN) { + scene.ignition = false; + for (const auto& pandaState : pandaStates) { + scene.ignition |= pandaState.getIgnitionLine() || pandaState.getIgnitionCan(); + } + } + } + } else if ((s->sm->frame - s->sm->rcv_frame("pandaStates")) > 5*UI_FREQ) { + scene.pandaType = cereal::PandaState::PandaType::UNKNOWN; + } + if (sm.updated("carParams")) { + scene.longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl(); + } + if (!scene.started && sm.updated("sensorEvents")) { + for (auto sensor : sm["sensorEvents"].getSensorEvents()) { + if (sensor.which() == cereal::SensorEventData::ACCELERATION) { + auto accel = sensor.getAcceleration().getV(); + if (accel.totalSize().wordCount) { // TODO: sometimes empty lists are received. Figure out why + scene.accel_sensor = accel[2]; + } + } else if (sensor.which() == cereal::SensorEventData::GYRO_UNCALIBRATED) { + auto gyro = sensor.getGyroUncalibrated().getV(); + if (gyro.totalSize().wordCount) { + scene.gyro_sensor = gyro[1]; + } + } + } + } + if (sm.updated("roadCameraState")) { + auto camera_state = sm["roadCameraState"].getRoadCameraState(); + + float max_lines = Hardware::EON() ? 5408 : 1904; + float max_gain = Hardware::EON() ? 1.0: 10.0; + float max_ev = max_lines * max_gain; + + if (Hardware::TICI()) { + max_ev /= 6; + } + + float ev = camera_state.getGain() * float(camera_state.getIntegLines()); + + scene.light_sensor = std::clamp(1.0 - (ev / max_ev), 0.0, 1.0); + } + scene.started = sm["deviceState"].getDeviceState().getStarted() && scene.ignition; +} + +void ui_update_params(UIState *s) { + s->scene.is_metric = Params().getBool("IsMetric"); +} + +static void update_status(UIState *s) { + if (s->scene.started && s->sm->updated("controlsState")) { + auto controls_state = (*s->sm)["controlsState"].getControlsState(); + auto alert_status = controls_state.getAlertStatus(); + if (alert_status == cereal::ControlsState::AlertStatus::USER_PROMPT) { + s->status = STATUS_WARNING; + } else if (alert_status == cereal::ControlsState::AlertStatus::CRITICAL) { + s->status = STATUS_ALERT; + } else { + s->status = controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED; + } + } + + // Handle onroad/offroad transition + static bool started_prev = false; + if (s->scene.started != started_prev) { + if (s->scene.started) { + s->status = STATUS_DISENGAGED; + s->scene.started_frame = s->sm->frame; + s->scene.end_to_end = Params().getBool("EndToEndToggle"); + s->wide_camera = Hardware::TICI() ? Params().getBool("EnableWideCamera") : false; + } + // Invisible until we receive a calibration message. + s->scene.world_objects_visible = false; + } + started_prev = s->scene.started; +} + + +QUIState::QUIState(QObject *parent) : QObject(parent) { + ui_state.sm = std::make_unique>({ + "modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "roadCameraState", + "pandaStates", "carParams", "driverMonitoringState", "sensorEvents", "carState", "liveLocationKalman", + }); + + Params params; + ui_state.wide_camera = Hardware::TICI() ? params.getBool("EnableWideCamera") : false; + ui_state.has_prime = params.getBool("HasPrime"); + + // update timer + timer = new QTimer(this); + QObject::connect(timer, &QTimer::timeout, this, &QUIState::update); + timer->start(1000 / UI_FREQ); +} + +void QUIState::update() { + update_sockets(&ui_state); + update_state(&ui_state); + update_status(&ui_state); + + if (ui_state.scene.started != started_prev || ui_state.sm->frame == 1) { + started_prev = ui_state.scene.started; + emit offroadTransition(!ui_state.scene.started); + } + + if (ui_state.sm->frame % UI_FREQ == 0) { + watchdog_kick(); + } + emit uiUpdate(ui_state); +} + +Device::Device(QObject *parent) : brightness_filter(BACKLIGHT_OFFROAD, BACKLIGHT_TS, BACKLIGHT_DT), QObject(parent) { +} + +void Device::update(const UIState &s) { + updateBrightness(s); + updateWakefulness(s); + + // TODO: remove from UIState and use signals + QUIState::ui_state.awake = awake; +} + +void Device::setAwake(bool on, bool reset) { + if (on != awake) { + awake = on; + Hardware::set_display_power(awake); + LOGD("setting display power %d", awake); + emit displayPowerChanged(awake); + } + + if (reset) { + awake_timeout = 30 * UI_FREQ; + } +} + +void Device::updateBrightness(const UIState &s) { + float clipped_brightness = BACKLIGHT_OFFROAD; + if (s.scene.started) { + // Scale to 0% to 100% + clipped_brightness = 100.0 * s.scene.light_sensor; + + // CIE 1931 - https://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm + if (clipped_brightness <= 8) { + clipped_brightness = (clipped_brightness / 903.3); + } else { + clipped_brightness = std::pow((clipped_brightness + 16.0) / 116.0, 3.0); + } + + // Scale back to 10% to 100% + clipped_brightness = std::clamp(100.0f * clipped_brightness, 10.0f, 100.0f); + } + + int brightness = brightness_filter.update(clipped_brightness); + if (!awake) { + brightness = 0; + } + + if (brightness != last_brightness) { + std::thread{Hardware::set_brightness, brightness}.detach(); + } + last_brightness = brightness; +} + +void Device::updateWakefulness(const UIState &s) { + awake_timeout = std::max(awake_timeout - 1, 0); + + bool should_wake = s.scene.started || s.scene.ignition; + if (!should_wake) { + // tap detection while display is off + bool accel_trigger = abs(s.scene.accel_sensor - accel_prev) > 0.2; + bool gyro_trigger = abs(s.scene.gyro_sensor - gyro_prev) > 0.15; + should_wake = accel_trigger && gyro_trigger; + gyro_prev = s.scene.gyro_sensor; + accel_prev = (accel_prev * (accel_samples - 1) + s.scene.accel_sensor) / accel_samples; + } + + setAwake(awake_timeout, should_wake); +} diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h new file mode 100644 index 00000000000000..4b4ef0bb285714 --- /dev/null +++ b/selfdrive/ui/ui.h @@ -0,0 +1,174 @@ +#pragma once + +#include +#include +#include + +#include +#include +#include +#include + +#include "cereal/messaging/messaging.h" +#include "selfdrive/common/modeldata.h" +#include "selfdrive/common/params.h" +#include "selfdrive/common/timing.h" + +const int bdr_s = 30; +const int header_h = 420; +const int footer_h = 280; + +const int UI_FREQ = 20; // Hz +typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; + +// TODO: this is also hardcoded in common/transformations/camera.py +// TODO: choose based on frame input size +const float y_offset = Hardware::EON() ? 0.0 : 150.0; +const float ZOOM = Hardware::EON() ? 2138.5 : 2912.8; + +struct Alert { + QString text1; + QString text2; + QString type; + cereal::ControlsState::AlertSize size; + AudibleAlert sound; + bool equal(const Alert &a2) { + return text1 == a2.text1 && text2 == a2.text2 && type == a2.type && sound == a2.sound; + } + + static Alert get(const SubMaster &sm, uint64_t started_frame) { + if (sm.updated("controlsState")) { + const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); + return {cs.getAlertText1().cStr(), cs.getAlertText2().cStr(), + cs.getAlertType().cStr(), cs.getAlertSize(), + cs.getAlertSound()}; + } else if ((sm.frame - started_frame) > 5 * UI_FREQ) { + const int CONTROLS_TIMEOUT = 5; + // Handle controls timeout + if (sm.rcv_frame("controlsState") < started_frame) { + // car is started, but controlsState hasn't been seen at all + return {"openpilot Unavailable", "Waiting for controls to start", + "controlsWaiting", cereal::ControlsState::AlertSize::MID, + AudibleAlert::NONE}; + } else if ((nanos_since_boot() - sm.rcv_time("controlsState")) / 1e9 > CONTROLS_TIMEOUT) { + // car is started, but controls is lagging or died + return {"TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", + "controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, + AudibleAlert::WARNING_IMMEDIATE}; + } + } + return {}; + } +}; + +typedef enum UIStatus { + STATUS_DISENGAGED, + STATUS_ENGAGED, + STATUS_WARNING, + STATUS_ALERT, +} UIStatus; + +const QColor bg_colors [] = { + [STATUS_DISENGAGED] = QColor(0x17, 0x33, 0x49, 0xc8), + [STATUS_ENGAGED] = QColor(0x17, 0x86, 0x44, 0xf1), + [STATUS_WARNING] = QColor(0xDA, 0x6F, 0x25, 0xf1), + [STATUS_ALERT] = QColor(0xC9, 0x22, 0x31, 0xf1), +}; + +typedef struct { + QPointF v[TRAJECTORY_SIZE * 2]; + int cnt; +} line_vertices_data; + +typedef struct UIScene { + mat3 view_from_calib; + bool world_objects_visible; + + cereal::PandaState::PandaType pandaType; + + // modelV2 + float lane_line_probs[4]; + float road_edge_stds[2]; + line_vertices_data track_vertices; + line_vertices_data lane_line_vertices[4]; + line_vertices_data road_edge_vertices[2]; + + // lead + QPointF lead_vertices[2]; + + float light_sensor, accel_sensor, gyro_sensor; + bool started, ignition, is_metric, longitudinal_control, end_to_end; + uint64_t started_frame; +} UIScene; + +typedef struct UIState { + int fb_w = 0, fb_h = 0; + + std::unique_ptr sm; + + UIStatus status; + UIScene scene = {}; + + bool awake; + bool has_prime = false; + + QTransform car_space_transform; + bool wide_camera; +} UIState; + + +class QUIState : public QObject { + Q_OBJECT + +public: + QUIState(QObject* parent = 0); + + // TODO: get rid of this, only use signal + inline static UIState ui_state = {0}; + +signals: + void uiUpdate(const UIState &s); + void offroadTransition(bool offroad); + +private slots: + void update(); + +private: + QTimer *timer; + bool started_prev = true; +}; + + +// device management class + +class Device : public QObject { + Q_OBJECT + +public: + Device(QObject *parent = 0); + +private: + // auto brightness + const float accel_samples = 5*UI_FREQ; + + bool awake = false; + int awake_timeout = 0; + float accel_prev = 0; + float gyro_prev = 0; + int last_brightness = 0; + FirstOrderFilter brightness_filter; + + QTimer *timer; + + void updateBrightness(const UIState &s); + void updateWakefulness(const UIState &s); + +signals: + void displayPowerChanged(bool on); + +public slots: + void setAwake(bool on, bool reset); + void update(const UIState &s); +}; + +void ui_update_params(UIState *s); diff --git a/selfdrive/ui/watch3.cc b/selfdrive/ui/watch3.cc new file mode 100644 index 00000000000000..73c8e11318d35f --- /dev/null +++ b/selfdrive/ui/watch3.cc @@ -0,0 +1,36 @@ +#include +#include + +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/util.h" +#include "selfdrive/ui/qt/widgets/cameraview.h" + +int main(int argc, char *argv[]) { + QSurfaceFormat fmt; + fmt.setRenderableType(QSurfaceFormat::OpenGLES); + QSurfaceFormat::setDefaultFormat(fmt); + + QApplication a(argc, argv); + QWidget w; + setMainWindow(&w); + + QVBoxLayout *layout = new QVBoxLayout(&w); + layout->setMargin(0); + layout->setSpacing(0); + + { + QHBoxLayout *hlayout = new QHBoxLayout(); + layout->addLayout(hlayout); + hlayout->addWidget(new CameraViewWidget("navd", VISION_STREAM_RGB_MAP, false)); + hlayout->addWidget(new CameraViewWidget("camerad", VISION_STREAM_RGB_BACK, false)); + } + + { + QHBoxLayout *hlayout = new QHBoxLayout(); + layout->addLayout(hlayout); + hlayout->addWidget(new CameraViewWidget("camerad", VISION_STREAM_RGB_FRONT, false)); + hlayout->addWidget(new CameraViewWidget("camerad", VISION_STREAM_RGB_WIDE, false)); + } + + return a.exec(); +} diff --git a/selfdrive/updated.py b/selfdrive/updated.py index 743eb6f589a33b..2acebf2a4ecf54 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -1,34 +1,473 @@ -#!/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.markdown import parse_markdown +from common.params import Params +from selfdrive.hardware import EON, TICI, HARDWARE from selfdrive.swaglog import cloudlog +from selfdrive.controls.lib.alertmanager import set_offroad_alert +from selfdrive.version import get_tested_branch + +LOCK_FILE = os.getenv("UPDATER_LOCK_FILE", "/tmp/safe_staging_overlay.lock") +STAGING_ROOT = os.getenv("UPDATER_STAGING_ROOT", "/data/safe_staging") + +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") + +DAYS_NO_CONNECTIVITY_MAX = 14 # do not allow to engage after this many days +DAYS_NO_CONNECTIVITY_PROMPT = 10 # send an offroad prompt after this many days + +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: + consistent_file.unlink(missing_ok=True) + os.sync() + + +def set_params(new_version: bool, failed_count: int, exception: Optional[str]) -> None: + params = Params() + + params.put("UpdateFailedCount", str(failed_count)) + + last_update = datetime.datetime.utcnow() + if failed_count == 0: + t = last_update.isoformat() + params.put("LastUpdateTime", t.encode('utf8')) + else: + try: + t = params.get("LastUpdateTime", encoding='utf8') + last_update = datetime.datetime.fromisoformat(t) + except (TypeError, ValueError): + pass + + if exception is None: + params.delete("LastUpdateException") + else: + params.put("LastUpdateException", exception) + + # Write out release notes for new versions + if new_version: + try: + with open(os.path.join(FINALIZED, "RELEASES.md"), "rb") as f: + r = f.read().split(b'\n\n', 1)[0] # Slice latest release notes + try: + params.put("ReleaseNotes", parse_markdown(r.decode("utf-8"))) + except Exception: + params.put("ReleaseNotes", r + b"\n") + except Exception: + params.put("ReleaseNotes", "") + params.put_bool("UpdateAvailable", True) + + # Handle user prompt + for alert in ("Offroad_UpdateFailed", "Offroad_ConnectivityNeeded", "Offroad_ConnectivityNeededPrompt"): + set_offroad_alert(alert, False) + + now = datetime.datetime.utcnow() + dt = now - last_update + if failed_count > 15 and exception is not None: + if get_tested_branch(): + extra_text = "Ensure the software is correctly installed" + else: + extra_text = exception + set_offroad_alert("Offroad_UpdateFailed", True, extra_text=extra_text) + elif dt.days > DAYS_NO_CONNECTIVITY_MAX and failed_count > 1: + set_offroad_alert("Offroad_ConnectivityNeeded", True) + elif dt.days > DAYS_NO_CONNECTIVITY_PROMPT: + remaining = max(DAYS_NO_CONNECTIVITY_MAX - dt.days, 1) + set_offroad_alert("Offroad_ConnectivityNeededPrompt", True, extra_text=f"{remaining} day{'' if remaining == 1 else 's'}.") + + +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 = Params() + params.put_bool("UpdateAvailable", False) + set_consistent_flag(False) + dismount_overlay() + if TICI: + run(["sudo", "rm", "-rf", STAGING_ROOT]) + 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) + + git_diff = run(["git", "diff"], OVERLAY_MERGED, low_priority=True) + params.put("GitDiff", git_diff) + cloudlog.info(f"git diff output:\n{git_diff}") + + +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) + + run(["git", "reset", "--hard"], FINALIZED) + run(["git", "submodule", "foreach", "--recursive", "git", "reset"], FINALIZED) + + set_consistent_flag(True) + cloudlog.info("done finalizing overlay") + -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) +def handle_agnos_update(wait_helper: WaitTimeHelper) -> None: + from selfdrive.hardware.tici.agnos import flash_agnos_update, get_target_slot_number + + cur_version = HARDWARE.get_os_version() + updated_version = run(["bash", "-c", r"unset AGNOS_VERSION && source launch_env.sh && \ + echo -n $AGNOS_VERSION"], OVERLAY_MERGED).strip() + + cloudlog.info(f"AGNOS version check: {cur_version} vs {updated_version}") + if cur_version == updated_version: + return + + # prevent an openpilot getting swapped in with a mismatched or partially downloaded agnos + set_consistent_flag(False) + + cloudlog.info(f"Beginning background installation for AGNOS {updated_version}") + set_offroad_alert("Offroad_NeosUpdate", True) + + manifest_path = os.path.join(OVERLAY_MERGED, "selfdrive/hardware/tici/agnos.json") + target_slot_number = get_target_slot_number() + flash_agnos_update(manifest_path, target_slot_number, cloudlog) + set_offroad_alert("Offroad_NeosUpdate", False) + + +def handle_neos_update(wait_helper: WaitTimeHelper) -> None: + from selfdrive.hardware.eon.neos import download_neos_update + + cur_neos = HARDWARE.get_os_version() + 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) + + update_manifest = os.path.join(OVERLAY_MERGED, "selfdrive/hardware/eon/neos.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: + download_neos_update(update_manifest, cloudlog) + neos_downloaded = True + except Exception: + 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: str) -> bool: + 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) + elif TICI: + handle_agnos_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() + + if params.get_bool("DisableUpdates"): + cloudlog.warning("updates are disabled by the DisableUpdates param") + exit(0) + + 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 instance running?") from e + + # Set low io priority + proc = psutil.Process() + if psutil.LINUX: + proc.ionice(psutil.IOPRIO_CLASS_BE, value=7) + + # Check if we just performed an update + if Path(os.path.join(STAGING_ROOT, "old_openpilot")).is_dir(): + cloudlog.event("update installed") + + if not params.get("InstallDate"): + t = datetime.datetime.utcnow().isoformat() + params.put("InstallDate", t.encode('utf8')) + + overlay_init = Path(os.path.join(BASEDIR, ".overlay_init")) + overlay_init.unlink(missing_ok=True) + + first_run = True + last_fetch_time = 0 + update_failed_count = 0 + + # Set initial params for offroad alerts + set_params(False, 0, None) + + # Wait for IsOffroad to be set before our first update attempt + wait_helper = WaitTimeHelper(proc) + wait_helper.sleep(30) + + # 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() + + # Don't run updater while onroad or if the time's wrong + time_wrong = datetime.datetime.utcnow().year < 2019 + is_onroad = not params.get_bool("IsOffroad") + if is_onroad or time_wrong: + wait_helper.sleep(30) + cloudlog.info("not running updater, not offroad") continue - # download application update + # 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}" + overlay_init.unlink(missing_ok=True) + except Exception as e: + cloudlog.exception("uncaught updated exception, shouldn't happen") + exception = str(e) + overlay_init.unlink(missing_ok=True) + + try: + set_params(new_version, update_failed_count, exception) + except Exception: + cloudlog.exception("uncaught updated exception while setting params, shouldn't happen") + + wait_helper.sleep(60) + + dismount_overlay() - time.sleep(60*60) if __name__ == "__main__": main() - diff --git a/selfdrive/version.py b/selfdrive/version.py index 4acc183502f9f4..2ddfc93c698864 100644 --- a/selfdrive/version.py +++ b/selfdrive/version.py @@ -1,71 +1,133 @@ +#!/usr/bin/env python3 import os import subprocess +from typing import List, Optional +from functools import lru_cache + +from common.basedir import BASEDIR from selfdrive.swaglog import cloudlog -def get_git_commit(): - return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip() +TESTED_BRANCHES = ['devel', 'release2-staging', 'release3-staging', 'dashcam-staging', 'release2', 'release3', 'dashcam'] + +training_version: bytes = b"0.2.0" +terms_version: bytes = b"2" -def get_git_branch(): - return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip() +def cache(user_function, /): + return lru_cache(maxsize=None)(user_function) -def get_git_full_branchname(): - return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]).strip() +def run_cmd(cmd: List[str]) -> str: + return subprocess.check_output(cmd, encoding='utf8').strip() -def get_git_remote(): +def run_cmd_default(cmd: List[str], 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() + return run_cmd(cmd) except subprocess.CalledProcessError: - # Not on a branch, fallback - return subprocess.check_output(["git", "config", "--get", "remote.origin.url"]).strip() + return default + + +@cache +def get_commit(branch: str = "HEAD", default: Optional[str] = None) -> Optional[str]: + return run_cmd_default(["git", "rev-parse", branch], default=default) + + +@cache +def get_short_branch(default: Optional[str] = None) -> Optional[str]: + return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "HEAD"], default=default) + + +@cache +def get_branch(default: Optional[str] = None) -> Optional[str]: + return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], default=default) + + +@cache +def get_origin(default: Optional[str] = None) -> Optional[str]: + try: + 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) + + +@cache +def get_version() -> str: + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "common", "version.h")) as _versionf: + version = _versionf.read().split('"')[1] + return version + +@cache +def get_prebuilt() -> bool: + return os.path.exists(os.path.join(BASEDIR, 'prebuilt')) -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() +@cache +def get_comma_remote() -> bool: + origin = get_origin() + if origin is None: + return False + return origin.startswith('git@github.com:commaai') or origin.startswith('https://github.com/commaai') + + +@cache +def get_tested_branch() -> bool: + return get_short_branch() in TESTED_BRANCHES + + +@cache +def get_dirty() -> bool: + origin = get_origin() + branch = get_branch() + if (origin is None) or (branch is None): + return True + + dirty = False + try: + # Actually check dirty files + if not get_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 - 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 = (subprocess.call(["git", "diff-index", "--quiet", branch, "--"]) != 0) + + # Log dirty files + if dirty and get_comma_remote(): + try: + dirty_files = run_cmd(["git", "diff-index", branch, "--"]) + cloudlog.event("dirty comma branch", version=get_version(), dirty=dirty, origin=origin, branch=branch, + dirty_files=dirty_files, commit=get_commit(), origin_commit=get_commit(branch)) + except subprocess.CalledProcessError: + pass - else: + dirty = dirty or (not get_comma_remote()) + dirty = dirty or ('master' in branch) + + except subprocess.CalledProcessError: + cloudlog.exception("git subprocess failed while checking dirty") dirty = True -except subprocess.CalledProcessError: - try: - cloudlog.exception("git subprocess failed while finding version") - except: - pass - dirty = True -training_version = "0.1.0" + return dirty -if __name__ == "__main__": - print("Dirty: %s" % dirty) - print("Version: %s" % version) - print("Remote: %s" % origin) - try: - print("Branch %s" % branch) - except NameError: - pass +if __name__ == "__main__": + from common.params import Params + + params = Params() + params.put("TermsVersion", terms_version) + params.put("TrainingVersion", training_version) + + print("Dirty: %s" % get_dirty()) + print("Version: %s" % get_version()) + print("Origin: %s" % get_origin()) + print("Branch: %s" % get_branch()) + print("Short branch: %s" % get_short_branch()) + print("Prebuilt: %s" % get_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/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 d9d320cf3bfeaa..00000000000000 --- a/selfdrive/visiond/build_from_src.mk +++ /dev/null @@ -1,222 +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/aarch64/include - ZMQ_LIBS = -l:libczmq.a -l:libzmq.a -lsodium - - OPENCL_LIBS = -lOpenCL - UUID_LIBS = -luuid - - 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/cameras/sensor_i2c.h b/selfdrive/visiond/cameras/sensor_i2c.h deleted file mode 100644 index c33bc3468ae5df..00000000000000 --- a/selfdrive/visiond/cameras/sensor_i2c.h +++ /dev/null @@ -1,1830 +0,0 @@ -static struct msm_camera_i2c_reg_array init_array_imx298[] = { - {0x101,0x0,0}, // IMAGE_ORIENT - {0x601,0x0,0}, // test pattern - //{0xb02,0,0}, // green correction? - // external clock setting - {0x136,0x18,0}, {0x137,0x0,0}, // EXCK_FREQ = Extclk_frequency_mhz - // global setting? - {0x30f4,0x1,0}, - {0x30f5,0x7a,0}, - {0x30f6,0x0,0}, - {0x30f7,0xec,0}, - {0x30fc,0x1,0}, - {0x3101,0x1,0}, - {0x5b2f,0x8,0}, - {0x5d32,0x5,0}, - {0x5d7c,0x0,0}, - {0x5d7d,0x0,0}, - {0x5db9,0x1,0}, - {0x5e43,0x0,0}, - {0x6300,0x0,0}, - {0x6301,0xea,0}, - {0x6302,0x0,0}, - {0x6303,0xb4,0}, - {0x6564,0x0,0}, - {0x6565,0xb6,0}, - {0x6566,0x0,0}, - {0x6567,0xe6,0}, - {0x6714,0x1,0}, - {0x6758,0xb,0}, - {0x6910,0x4,0}, - {0x6916,0x1,0}, - {0x6918,0x4,0}, - {0x691e,0x1,0}, - {0x6931,0x1,0}, - {0x6937,0x2,0}, - {0x693b,0x2,0}, - {0x6d00,0x4a,0}, - {0x6d01,0x41,0}, - {0x6d02,0x23,0}, - {0x6d05,0x4c,0}, - {0x6d06,0x10,0}, - {0x6d08,0x30,0}, - {0x6d09,0x38,0}, - {0x6d0a,0x2c,0}, - {0x6d0b,0x2d,0}, - {0x6d0c,0x34,0}, - {0x6d0d,0x42,0}, - {0x6d19,0x1c,0}, - {0x6d1a,0x71,0}, - {0x6d1b,0xc6,0}, - {0x6d1c,0x94,0}, - {0x6d24,0xe4,0}, - {0x6d30,0xa,0}, - {0x6d31,0x1,0}, - {0x6d33,0xb,0}, - {0x6d34,0x5,0}, - {0x6d35,0x0,0}, - {0x83c2,0x3,0}, - {0x83c3,0x8,0}, - {0x83c4,0x48,0}, - {0x83c7,0x8,0}, - {0x83cb,0x0,0}, - {0xb101,0xff,0}, - {0xb103,0xff,0}, - {0xb105,0xff,0}, - {0xb107,0xff,0}, - {0xb109,0xff,0}, - {0xb10b,0xff,0}, - {0xb10d,0xff,0}, - {0xb10f,0xff,0}, - {0xb111,0xff,0}, - {0xb163,0x3c,0}, - {0xc2a0,0x8,0}, - {0xc2a3,0x3,0}, - {0xc2a5,0x8,0}, - {0xc2a6,0x48,0}, - {0xc2a9,0x0,0}, - {0xf800,0x5e,0}, - {0xf801,0x5e,0}, - {0xf802,0xcd,0}, - {0xf803,0x20,0}, - {0xf804,0x55,0}, - {0xf805,0xd4,0}, - {0xf806,0x1f,0}, - {0xf808,0xf8,0}, - {0xf809,0x3a,0}, - {0xf80a,0xf1,0}, - {0xf80b,0x7e,0}, - {0xf80c,0x55,0}, - {0xf80d,0x38,0}, - {0xf80e,0xe3,0}, - {0xf810,0x74,0}, - {0xf811,0x41,0}, - {0xf812,0xbf,0}, - {0xf844,0x40,0}, - {0xf845,0xba,0}, - {0xf846,0x70,0}, - {0xf847,0x47,0}, - {0xf848,0xc0,0}, - {0xf849,0xba,0}, - {0xf84a,0x70,0}, - {0xf84b,0x47,0}, - {0xf84c,0x82,0}, - {0xf84d,0xf6,0}, - {0xf84e,0x32,0}, - {0xf84f,0xfd,0}, - {0xf851,0xf0,0}, - {0xf852,0x2,0}, - {0xf853,0xf8,0}, - {0xf854,0x81,0}, - {0xf855,0xf6,0}, - {0xf856,0xc0,0}, - {0xf857,0xff,0}, - {0xf858,0x10,0}, - {0xf859,0xb5,0}, - {0xf85a,0xd,0}, - {0xf85b,0x48,0}, - {0xf85c,0x40,0}, - {0xf85d,0x7a,0}, - {0xf85e,0x1,0}, - {0xf85f,0x28,0}, - {0xf860,0x15,0}, - {0xf861,0xd1,0}, - {0xf862,0xc,0}, - {0xf863,0x49,0}, - {0xf864,0xc,0}, - {0xf865,0x46,0}, - {0xf866,0x40,0}, - {0xf867,0x3c,0}, - {0xf868,0x48,0}, - {0xf869,0x8a,0}, - {0xf86a,0x62,0}, - {0xf86b,0x8a,0}, - {0xf86c,0x80,0}, - {0xf86d,0x1a,0}, - {0xf86e,0x8a,0}, - {0xf86f,0x89,0}, - {0xf871,0xb2,0}, - {0xf872,0x10,0}, - {0xf873,0x18,0}, - {0xf874,0xa,0}, - {0xf875,0x46,0}, - {0xf876,0x20,0}, - {0xf877,0x32,0}, - {0xf878,0x12,0}, - {0xf879,0x88,0}, - {0xf87a,0x90,0}, - {0xf87b,0x42,0}, - {0xf87d,0xda,0}, - {0xf87e,0x10,0}, - {0xf87f,0x46,0}, - {0xf880,0x80,0}, - {0xf881,0xb2,0}, - {0xf882,0x88,0}, - {0xf883,0x81,0}, - {0xf884,0x84,0}, - {0xf885,0xf6,0}, - {0xf886,0xd2,0}, - {0xf887,0xf9,0}, - {0xf888,0xe0,0}, - {0xf889,0x67,0}, - {0xf88a,0x85,0}, - {0xf88b,0xf6,0}, - {0xf88c,0xa1,0}, - {0xf88d,0xfc,0}, - {0xf88e,0x10,0}, - {0xf88f,0xbd,0}, - {0xf891,0x18,0}, - {0xf892,0x21,0}, - {0xf893,0x24,0}, - {0xf895,0x18,0}, - {0xf896,0x19,0}, - {0xf897,0xb4,0}, - {0x4e29,0x1,0}, - // PDAF stuff - {0x3166,0x1,0}, //AREA_EN_0 - {0x3167,0x1,0}, - {0x3168,0x1,0}, - {0x3169,0x1,0}, - {0x316a,0x1,0}, - {0x316b,0x1,0}, - {0x316c,0x1,0}, - {0x316d,0x1,0}, - {0x3158,0x2,0}, - {0x3159,0x2,0}, - {0x315a,0x2,0}, - {0x315b,0x3,0}, - {0x3013,0x7,0}, //RMSC_NR_MODE - {0x3035,0x1,0}, - {0x3051,0x0,0}, - {0x3056,0x2,0}, - {0x3057,0x1,0}, - {0x3060,0x0,0}, - {0x8435,0x0,0}, - {0x8455,0x0,0}, - {0x847c,0x0,0}, - {0x84fb,0x1,0}, - {0x9619,0xa0,0}, - {0x961b,0xa0,0}, - {0x961d,0xa0,0}, - {0x961f,0x20,0}, - {0x9621,0x20,0}, - {0x9623,0x20,0}, - {0x9625,0xa0,0}, - {0x9627,0xa0,0}, - {0x9629,0xa0,0}, - {0x962b,0x20,0}, - {0x962d,0x20,0}, - {0x962f,0x20,0}, - {0x9901,0x35,0}, - {0x9903,0x23,0}, - {0x9905,0x23,0}, - {0x9906,0x0,0}, - {0x9907,0x31,0}, - {0x9908,0x0,0}, - {0x9909,0x1b,0}, - {0x990a,0x0,0}, - {0x990b,0x15,0}, - {0x990d,0x3f,0}, - {0x990f,0x3f,0}, - {0x9911,0x3f,0}, - {0x9913,0x64,0}, - {0x9915,0x64,0}, - {0x9917,0x64,0}, - {0x9919,0x50,0}, - {0x991b,0x60,0}, - {0x991d,0x65,0}, - {0x991f,0x1,0}, - {0x9921,0x1,0}, - {0x9923,0x1,0}, - {0x9925,0x23,0}, - {0x9927,0x23,0}, - {0x9929,0x23,0}, - {0x992b,0x2f,0}, - {0x992d,0x1a,0}, - {0x992f,0x14,0}, - {0x9931,0x3f,0}, - {0x9933,0x3f,0}, - {0x9935,0x3f,0}, - {0x9937,0x6b,0}, - {0x9939,0x7c,0}, - {0x993b,0x81,0}, - {0x9943,0xf,0}, - {0x9945,0xf,0}, - {0x9947,0xf,0}, - {0x9949,0xf,0}, - {0x994b,0xf,0}, - {0x994d,0xf,0}, - {0x994f,0x42,0}, - {0x9951,0xf,0}, - {0x9953,0xb,0}, - {0x9955,0x5a,0}, - {0x9957,0x13,0}, - {0x9959,0xc,0}, - {0x995a,0x0,0}, - {0x995b,0x0,0}, - {0x995c,0x0,0}, - {0x996b,0x0,0}, - {0x996d,0x10,0}, - {0x996f,0x10,0}, - {0x9971,0xc8,0}, - {0x9973,0x32,0}, - {0x9975,0x4,0}, - {0x9976,0xa,0}, - {0x9977,0xa,0}, - {0x9978,0xa,0}, - {0x99a4,0x2f,0}, - {0x99a5,0x2f,0}, - {0x99a6,0x2f,0}, - {0x99a7,0xa,0}, - {0x99a8,0xa,0}, - {0x99a9,0xa,0}, - {0x99aa,0x2f,0}, - {0x99ab,0x2f,0}, - {0x99ac,0x2f,0}, - {0x99ad,0x0,0}, - {0x99ae,0x0,0}, - {0x99af,0x0,0}, - {0x99b0,0x40,0}, - {0x99b1,0x40,0}, - {0x99b2,0x40,0}, - {0x99b3,0x30,0}, - {0x99b4,0x30,0}, - {0x99b5,0x30,0}, - {0x99bb,0xa,0}, - {0x99bd,0xa,0}, - {0x99bf,0xa,0}, - {0x99c0,0x9,0}, - {0x99c1,0x9,0}, - {0x99c2,0x9,0}, - {0x99c6,0x3c,0}, - {0x99c7,0x3c,0}, - {0x99c8,0x3c,0}, - {0x99c9,0xff,0}, - {0x99ca,0xff,0}, - {0x99cb,0xff,0}, - {0x9b01,0x35,0}, - {0x9b03,0x14,0}, - {0x9b05,0x14,0}, - {0x9b07,0x31,0}, - {0x9b09,0x1b,0}, - {0x9b0b,0x15,0}, - {0x9b0d,0x1e,0}, - {0x9b0f,0x1e,0}, - {0x9b11,0x1e,0}, - {0x9b13,0x64,0}, - {0x9b15,0x64,0}, - {0x9b17,0x64,0}, - {0x9b19,0x50,0}, - {0x9b1b,0x60,0}, - {0x9b1d,0x65,0}, - {0x9b1f,0x1,0}, - {0x9b21,0x1,0}, - {0x9b23,0x1,0}, - {0x9b25,0x14,0}, - {0x9b27,0x14,0}, - {0x9b29,0x14,0}, - {0x9b2b,0x2f,0}, - {0x9b2d,0x1a,0}, - {0x9b2f,0x14,0}, - {0x9b31,0x1e,0}, - {0x9b33,0x1e,0}, - {0x9b35,0x1e,0}, - {0x9b37,0x6b,0}, - {0x9b39,0x7c,0}, - {0x9b3b,0x81,0}, - {0x9b43,0xf,0}, - {0x9b45,0xf,0}, - {0x9b47,0xf,0}, - {0x9b49,0xf,0}, - {0x9b4b,0xf,0}, - {0x9b4d,0xf,0}, - {0x9b4f,0x2d,0}, - {0x9b51,0xb,0}, - {0x9b53,0x8,0}, - {0x9b55,0x40,0}, - {0x9b57,0xd,0}, - {0x9b59,0x8,0}, - {0x9b5a,0x0,0}, - {0x9b5b,0x0,0}, - {0x9b5c,0x0,0}, - {0x9b6b,0x0,0}, - {0x9b6d,0x10,0}, - {0x9b6f,0x10,0}, - {0x9b71,0xc8,0}, - {0x9b73,0x32,0}, - {0x9b75,0x4,0}, - {0x9bb0,0x40,0}, - {0x9bb1,0x40,0}, - {0x9bb2,0x40,0}, - {0x9bb3,0x30,0}, - {0x9bb4,0x30,0}, - {0x9bb5,0x30,0}, - {0x9bbb,0xa,0}, - {0x9bbd,0xa,0}, - {0x9bbf,0xa,0}, - {0x9bc0,0x9,0}, - {0x9bc1,0x9,0}, - {0x9bc2,0x9,0}, - {0x9bc6,0x18,0}, - {0x9bc7,0x18,0}, - {0x9bc8,0x18,0}, - {0x9bc9,0xff,0}, - {0x9bca,0xff,0}, - {0x9bcb,0xff,0}, - {0xb2b2,0x1,0}, -}; - -static struct msm_camera_i2c_reg_array mode_setting_array_imx298[] = { -// i2c settings for mode 3 -// { -// .x_output = 2328, -// .y_output = 1748, -// .line_length_pclk = 5536, -// .frame_length_lines = 1802, -// .vt_pixel_clk = 299300000, -// .op_pixel_clk = 299300000, -// .binning_factor = 2, -// .min_fps = 15.000000, -// .max_fps = 30.020000, -// .mode = 1, -// .offset_x = 0, -// .offset_y = 0, -// .scale_factor = 1.000000, -// .is_pdaf_supported = 1, -// } - -// mode settings - -// hdr settings -{0x0114, 0x03, 0}, // CSI_LANE_MODE = 4-lane -/*{0x0220, 0x00, 0}, // HDR_MODE = disable -{0x0221, 0x11, 0}, // HDR_RESO_REDU_H/V = Full Pixel -{0x0222, 0x10, 0}, // EXPO_RATIO = 16*/ -{0x0220, 0x01, 0}, // HDR_MODE = enable with combined gain and 16x ratio -{0x0221, 0x22, 0}, // HDR_RESO_REDU_H/V = 2 binning -{0x0222, 0x10, 0}, // EXPO_RATIO = 16 - -{0x0340, 0x07, 0}, {0x0341, 0x0a, 0}, // FRM_LENGTH = frame_length_lines = 1802 -{0x0342, 0x15, 0}, {0x0343, 0xa0, 0}, // LINE_LENGTH = line_length_pclk = 5536 -{0x0344, 0x00, 0}, {0x0345, 0x00, 0}, // x_addr_start -{0x0346, 0x00, 0}, {0x0347, 0x00, 0}, // y_addr_start -{0x0348, 0x12, 0}, {0x0349, 0x2f, 0}, // x_addr_end -{0x034a, 0x0d, 0}, {0x034b, 0xa7, 0}, // y_addr_end -{0x0381, 0x01, 0}, // x_even_inc -{0x0383, 0x01, 0}, // x_odd_inc -{0x0385, 0x01, 0}, // y_even_inc -{0x0387, 0x01, 0}, // y_odd_inc -{0x0900, 0x01, 0}, // BINNING_MODE = enable -{0x0901, 0x22, 0}, // BINING_TYPE_H/V = 2binning -{0x0902, 0x00, 0}, // binning_weighting = average - -{0x0b06, 1, 0}, // SING_DEF_CORR_EN -{0x0b0a, 1, 0}, // combined defect correct - -{0x3010, 0x66, 0}, // HDR_OUTPUT_CTRL = ATR + HDR compose + DPC1D + DCP2D -{0x3011, 0x01, 0}, // HDR_OUTPUT_CTRL2 = PD enable -{0x30c0, 0x11, 0}, // RED_GAIN_CB? -{0x300d, 0x00, 0}, // FORCE_FDSUM = disable -{0x30fd, 0x00, 0}, -{0x8493, 0x00, 0}, -{0x8863, 0x00, 0}, -{0x90d7, 0x19, 0}, - -// set black level -{0x3090, 1, 0}, -{0x3092, 0, 0}, -{0x3093, 0x38, 0}, - -// output size settings -{0x0112, 0x0a, 0}, {0x0113, 0x0a, 0}, // CS_DT_FMT_H = 0x0a0a (RAW10 output) -{0x034c, 0x09, 0}, {0x034d, 0x18, 0}, // X_OUT_SIZE = 2328 (1164*2) -{0x034e, 0x06, 0}, {0x034f, 0xd4, 0}, // Y_OUT_SIZE = 1748 (874*2) -{0x0401, 0x00, 0}, // SCALING_MODE -{0x0404, 0x00, 0}, {0x0405, 0x10, 0}, // SCALE_M -{0x0408, 0x00, 0}, {0x0409, 0x00, 0}, // DCROP_XOFS -{0x040a, 0x00, 0}, {0x040b, 0x00, 0}, // DCROP_YOFS -{0x040c, 0x09, 0}, {0x040d, 0x18, 0}, // DCROP_WIDTH -{0x040e, 0x06, 0}, {0x040f, 0xd4, 0}, // DCROP_HIGT - -// clock settings -// 299300000 -/* -{0x0301, 0x05, 0}, // VT_PIX_CLK_DIV -{0x0303, 0x02, 0}, // VT_SYS_CLK_DIV -{0x0305, 0x04, 0}, // PRE_PLL_CLK_DIV -{0x0306, 0x00, 0}, {0x0307, 0x7d, 0}, // PLL_MULTIPLIER . mode 1: 0xf6 -{0x0309, 0x0a, 0}, // OP_PIX_CLK_DIV -{0x030b, 0x01, 0}, // OP_SYS_CLK_DIV -{0x030d, 0x0f, 0}, // PREPLLCK_OP_DIV -{0x030e, 0x03, 0}, {0x030f, 0x41, 0}, // PLL_OP_MPY -{0x0310, 0x00, 0}, // PLL_MULT_DRIV -*/ -// 600000000 -{0x0301, 0x05, 0}, -{0x0303, 0x02, 0}, -{0x0305, 0x04, 0}, -{0x0306, 0x00, 0}, -{0x0307, 0xfa, 0}, -{0x0309, 0x0a, 0}, -{0x030b, 0x01, 0}, -{0x030d, 0x0f, 0}, -{0x030e, 0x03, 0}, {0x030f, 0x41, 0}, -{0x0310, 0x00, 0}, - -// data rate settings -/*{0x0820, 0x0b, 0}, // requested_link_bit_rate_mbps = 3000 -{0x0821, 0xb8, 0}, -{0x0822, 0x00, 0}, -{0x0823, 0x00, 0},*/ -{0x0820, 0x17, 0}, // requested_link_bit_rate_mbps = 6000 -{0x0821, 0x70, 0}, -{0x0822, 0x00, 0}, -{0x0823, 0x00, 0}, - -//integration time settings -{0x0202, 0x07, 0}, {0x0203, 0x00, 0}, // INTEG_TIME = 1792 -{0x0224, 0x01, 0}, {0x0225, 0xf4, 0}, // ST_COARSE_INTEG_TIME = 506 - -// gain settings -{0x0204, 0x00, 0}, {0x0205, 0x00, 0}, // ANA_GAIN_GLOBAL = 512 / (512 - X) -{0x0216, 0x00, 0}, {0x0217, 0x00, 0}, // ST_ANA_GAIN_GLOBAL[8] -{0x020e, 0x01, 0}, {0x020f, 0x00, 0}, // DIG_GAIN_GR -{0x0210, 0x01, 0}, {0x0211, 0x00, 0}, // DIG_GAIN_R -{0x0212, 0x01, 0}, {0x0213, 0x00, 0}, // DIG_GAIN_B -{0x0214, 0x01, 0}, {0x0215, 0x00, 0}, // DIG_GAIN_GB - -// HDR white balance settings (ABS_GAIN) -{0xb8e, 0x01, 0}, {0xb8f, 0x00, 0}, // GR -{0xb90, 0x02, 0}, {0xb91, 0x2b, 0}, // R -{0xb92, 0x01, 0}, {0xb93, 0xd4, 0}, // B -{0xb94, 0x01, 0}, {0xb95, 0x00, 0}, // GB - -// phase detection settings -{0x3058, 0x00, 0}, // NML_NR_EN -{0x3103, 0x01, 0}, // NML_PD_CAL_ENABLE = enable -{0x3108, 0x00, 0}, {0x3109, 0x2c, 0}, //PD_AREA_X_OFFSET -{0x310a, 0x00, 0}, {0x310b, 0x24, 0}, //PD_AREA_Y_OFFSET -{0x310c, 0x01, 0}, {0x310d, 0xa4, 0}, //PD_AREA_WIDTH -{0x310e, 0x01, 0}, {0x310f, 0xa4, 0}, //PD_AREA_HEIGHT -// whole size is 0x918 x 0x6d4 -{0x3110, 0x03, 0}, // PD_AREA_0 = 0x375-0x4d1, 0x258-0x3b6 -{0x3111, 0x75, 0}, -{0x3112, 0x02, 0}, -{0x3113, 0x58, 0}, -{0x3114, 0x04, 0}, -{0x3115, 0xd1, 0}, -{0x3116, 0x03, 0}, -{0x3117, 0xb6, 0}, -{0x3118, 0x04, 0}, // PD_AREA_1 = 0x446-0x5a2, 0x258-0x3b6 -{0x3119, 0x46, 0}, -{0x311a, 0x02, 0}, -{0x311b, 0x58, 0}, -{0x311c, 0x05, 0}, -{0x311d, 0xa2, 0}, -{0x311e, 0x03, 0}, -{0x311f, 0xb6, 0}, -{0x3120, 0x03, 0}, // PD_AREA_2 = 0x375-0x4d1, 0x32a-0x488 -{0x3121, 0x75, 0}, -{0x3122, 0x03, 0}, -{0x3123, 0x2a, 0}, -{0x3124, 0x04, 0}, -{0x3125, 0xd1, 0}, -{0x3126, 0x04, 0}, -{0x3127, 0x88, 0}, -{0x3128, 0x04, 0}, // PD_AREA_3 = 0x446-0x5a2, 0x32a-0x488 -{0x3129, 0x46, 0}, -{0x312a, 0x03, 0}, -{0x312b, 0x2a, 0}, -{0x312c, 0x05, 0}, -{0x312d, 0xa2, 0}, -{0x312e, 0x04, 0}, -{0x312f, 0x88, 0}, -{0x3130, 0x03, 0}, // PD_AREA_4 = 0x375-0x5a2, 0x258-0x488 -{0x3131, 0x75, 0}, -{0x3132, 0x02, 0}, -{0x3133, 0x58, 0}, -{0x3134, 0x05, 0}, -{0x3135, 0xa2, 0}, -{0x3136, 0x04, 0}, -{0x3137, 0x88, 0}, -{0x3138, 0x02, 0}, // PD_AREA_5 = 0x2ba-0x65d, 0x210-0x4d0 -{0x3139, 0xba, 0}, -{0x313a, 0x02, 0}, -{0x313b, 0x10, 0}, -{0x313c, 0x06, 0}, -{0x313d, 0x5d, 0}, -{0x313e, 0x04, 0}, -{0x313f, 0xd0, 0}, -{0x3140, 0x00, 0}, // PD_AREA_6 = 0xa1-0x876, 0x6b-0x676 -{0x3141, 0xa1, 0}, -{0x3142, 0x00, 0}, -{0x3143, 0x6b, 0}, -{0x3144, 0x08, 0}, -{0x3145, 0x76, 0}, -{0x3146, 0x06, 0}, -{0x3147, 0x76, 0}, -{0x3148, 0x00, 0}, // PD_AREA_7 = 0xa1-0x876, 0x5e-0x34c -{0x3149, 0xa1, 0}, -{0x314a, 0x00, 0}, -{0x314b, 0x5e, 0}, -{0x314c, 0x08, 0}, -{0x314d, 0x76, 0}, -{0x314e, 0x03, 0}, -{0x314f, 0x4c, 0}, -{0x3165, 0x02, 0}, // AREA_EN_0 = free area -}; - -// static struct msm_camera_i2c_reg_array reg_array3[] = { -// // REG_HOLD ON -// {0x104,0x1,0}, -// // from regression -// {0x3002,0x0,0}, -// // FRM_LENGTH, 1802 vs 3554 -// // {0x340,0x7,0}, {0x341,0xa,0}, // camera start {0x340,0xd,0}, {0x341,0xe2,0}, -// // INTEG_TIME aka coarse_int_time_addr aka shutter speed -// {0x202,0x03,0}, {0x203,0xda,0}, -// // global_gain_addr -// {0x204,0x0,0}, {0x205,0x0,0}, - -// //?? -// {0x20e,0x1,0}, {0x20f,0x0,0}, -// {0x210,0x1,0}, {0x211,0x0,0}, -// {0x212,0x1,0}, {0x213,0x0,0}, -// {0x214,0x1,0}, {0x215,0x0,0}, - -// // REG_HOLD: mode setting -// {0x104,0x0,0}, -// }; - -// start, remove standby mode -static struct msm_camera_i2c_reg_array start_reg_array[] = {{0x100,0x1,0}}; - -// stop, enable standby mode -static struct msm_camera_i2c_reg_array stop_reg_array[] = {{0x100,0x0,0}}; - - -/////////////////// - - -static struct msm_camera_i2c_reg_array init_array_imx179[] = { - { 0x100, 0x0, 0}, // MODE_SELECT - { 0x101, 0x0, 0}, // IMAGE_ORIENT - { 0x202, 0x9, 0}, { 0x203, 0xd2, 0}, // COARSE_INTEGRATION_TIME - { 0x301, 0x5, 0}, // vt_pix_clk_div - { 0x303, 0x1, 0}, // vt_sys_clk_div - { 0x305, 0x6, 0}, // pre_pll_clk_div - { 0x309, 0x5, 0}, // op_pix_clk_div - { 0x30b, 0x1, 0}, // op_sys_clk_div - { 0x30c, 0x0, 0}, { 0x30d, 0x9d, 0}, - - { 0x340, 0x9, 0}, { 0x341, 0xd6, 0}, // frame_length_lines - { 0x342, 0xd, 0}, { 0x343, 0x70, 0}, // line_length_pclk - { 0x344, 0x0, 0}, { 0x345, 0x0, 0}, // x_addr_start - { 0x346, 0x0, 0}, { 0x347, 0x0, 0}, // y_addr_start - { 0x348, 0xc, 0}, { 0x349, 0xcf, 0}, // last_pixel / x_addr_end - { 0x34a, 0x9, 0}, { 0x34b, 0x9f, 0}, // last_line / y_addr_end - { 0x34c, 0xc, 0}, { 0x34d, 0xd0, 0}, // pixels_per_line / x_output_size - { 0x34e, 0x9, 0}, { 0x34f, 0xa0, 0}, // lines_per_frame / y_output_size - { 0x383, 0x1, 0}, // x_odd_inc - { 0x387, 0x1, 0}, // y_odd_inc - { 0x390, 0x0, 0}, // binning_mode - { 0x401, 0x0, 0}, // SCALING_MODE - { 0x405, 0x10, 0}, // SCALE_M - - {0x3020, 0x10, 0}, - {0x3041, 0x15, 0}, // READ_MODE? - {0x3042, 0x87, 0}, - {0x3089, 0x4f, 0}, - {0x3309, 0x9a, 0}, - {0x3344, 0x57, 0}, - {0x3345, 0x1f, 0}, - {0x3362, 0xa, 0}, - {0x3363, 0xa, 0}, - {0x3364, 0x0, 0}, - {0x3368, 0x18, 0}, - {0x3369, 0x0, 0}, - {0x3370, 0x6f, 0}, - {0x3371, 0x27, 0}, - {0x3372, 0x4f, 0}, - {0x3373, 0x2f, 0}, - {0x3374, 0x27, 0}, - {0x3375, 0x2f, 0}, - {0x3376, 0x97, 0}, - {0x3377, 0x37, 0}, - {0x33c8, 0x0, 0}, - {0x33d4, 0xc, 0}, - {0x33d5, 0xd0, 0}, - {0x33d6, 0x9, 0}, - {0x33d7, 0xa0, 0}, - // znr - {0x4100, 0xe, 0}, - {0x4108, 0x1, 0}, - {0x4109, 0x7c, 0}, -}; - - - -/////////////// ois stuff /////////////// - -/* -#define _OP_FIRM_DWNLD 0x80 -#define _OP_Periphe_RW 0x82 -#define _OP_Memory__RW 0x84 -#define _OP_AD_TRNSFER 0x86 -#define _OP_COEF_DWNLD 0x88 -#define _OP_PrgMem__RD 0x8A -#define _OP_SpecialCMD 0x8C -*/ - -static struct reg_settings_ois_t ois_init_settings[] = { - { - .reg_addr = 0x8262, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0xbf03, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8263, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x9f05, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8264, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x6040, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8260, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x1130, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8265, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x8000, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8261, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0280, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8261, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0380, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8261, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0988, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x34\x84\x00\x03\xff\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\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", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x00\x03\x00\x10\x7e\x84\x50\x00\x08\x40\x7e\xa0\x00\x03\x00\x10\x7e\x84\x60\x00\x08\x40\x7e\xa0\x00\x03\x00\x90\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x10\x08\x80\x00\xa0\x10\x00\x08\x7f\xff\x11\x8f\x02\x07\x80\x00\x11\x40\xff\xa0\x90\x01\x84\x20\x8f\x08\x40\xfe\x90\x40\xf5", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x08\x80\x01\xa0\x00\x01\x11\x8f\x02\x07\xff\xff\x11\x08\x00\x20\x50\x12\x07\x00\x10\x08\x80\x00\xa0\x10\xff\x84\x20\x0a", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x7f\xff\x21\x08\xfe\x84\x00\x04\x07\x20\x0c\x08\x7f\xff\x21\x08\xfe\x84\x00\x03\x00\x90\x17\x84\x20\x1f\x08\x80\x17\xa0\x10\x10", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x7f\xff\x21\x10\x00\x08\x01\x00\x11\x40\x51\xa0\x90\x17\x84\x20\x0f\x08\x80\x47\xa0\x8d\x0c\x07\x00\x00\x11\x30\x03\x07\x80\x41", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8090, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x50\x00\x08\x40\xfc\x90\x88\x2f\x84\x00\x00\x11\x30\x02\x07\x40\xff\x90\x50\x00\x08\x40\xfd\x90\x40\x7f\xa0\x10\xff\x84\x20\x2c", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x7f\xff\x11\x20\x0d\x08\x80\x0f\x90\x80\x26\xa0\x90\x2e\x84\x00\x10\x08\x90\x26\x84\x00\x10\x08\x80\x1f\xa0\x20\x2e\x08\x40\xed", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8090, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x20\x0f\x08\x80\x0e\x90\x00\x00\x21\x30\x02\x07\x40\xeb\xa0\x50\x00\x08\x40\xfe\x90\x40\x7f\xa0\x04\xeb\x84\x10\x00\x20\x20\x0f", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x80\x00\x21\x60\x04\x07\x40\xff\xa0\x10\x00\x08\x40\xea\x90\x10\x00\x20\x20\x0f\x08\x80\x00\x11\x00\x0b\x07\x08\x00\x20\x60\x0d", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x00\x08\x40\xea\x90\x8f\x06\x07\x04\xff\x84\x20\x09\x60\x10\xfc\x84\x08\xfd\x84\x04\xfe\x84\x00\x03\x00\x00\x10\x08\x80\x37", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x90\x69\x84\x00\x10\x08\x80\x69\xa0\x20\x1a\x08\x40\x64\xa0\x10\x10\x08\x80\x4f\xa0\x20\x1d\x08\x40\x5f\xa0\x20\x1e\x08\x40\x5d", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x00\x08\x80\x68\x90\x40\xfe\xa0\x20\x0e\x07\x50\x00\x08\x40\x7f\xa0\x04\xfe\x84\x00\x04\x00\x10\xf0\x44\x50\x00\x08\x00\x7f", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x20\xf0\x60\x04\x5c\x84\x04\x61\x84\x04\x57\x84\x00\x00\x21\x04\x74\x84\x00\x40\x21\x00\x0b\x07\x04\x74\x84\x00\x00\x21\x10\x57", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x30\x20\x08\x00\x04\x11\x50\x00\x08\x03\xff\x11\x20\xfa\x60\x10\xf0\x44\x50\x20\x08\x00\x7f\x11\x60\x20\x08\x40\x00\x08\x00\x08", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x30\x1a\x07\x50\x00\x08\x07\x00\x11\x9f\x1d\x07\x8b\x1e\x07\x9c\x15\x07\x20\xf8\x60\x10\x28\x44\x60\x00\x08\x01\x00\x11\x20\x28", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8060, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x87\x1b\x07\x40\xf7\xa0\x81\x27\x07\x20\x48\x60\x10\x0a\x44\x10\xf4\x84\x3b\xd4\x00\xe0\x14\x43\x08\x00\x20\x00\x06\x07\x89\x02", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\xae\x90\x81\x04\x07\x40\x2e\x90\x40\x7f\xa0\x10\x2e\x44\x20\x2f\x08\x9f\x02\x07\x00\x00\x11\x10\x00\x20\x00\x00\x08\x40\x67", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x11\x84\x02\x07\x20\xf0\x60\x9f\x03\x07\x40\x7e\xa0\x40\x65\x90\x10\x62\x84\x10\x10\x08\x40\x61\xa0\x20\x1d\x08\x40\x5f", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x20\x1e\x08\x40\x5d\xa0\x10\x00\x08\x40\x5e\x90\x20\x30\x60\x10\xcf\x84\x20\x1c\x08\x7f\xff\x21\x3b\xf7\x00\xc8\x14\x43\x10\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8020, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x08\x40\xb5\x90\x40\xad\xa0\x00\x0a\x07\x10\x4f\x84\x20\x1c\x08\x7f\xff\x21\x3c\x01\x00\x48\x14\x43\x10\x00\x20\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x35\x90\x40\x2d\xa0\x00\x14\x07\x80\x0c\x07\x82\x03\x07\x04\x50\x84\x10\x00\x20\x20\x02\x07\x00\x08\x21\x40\x00\x08\x00\x01", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x50\xa0\x00\x04\x00\x20\x7f\x00\x80\x14\x43\x01\x00\x01\x04\x00\x11\x02\x00\x21\x10\x9f\x84\x10\x20\x08\x40\x97\x90\x10\xbf", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x20\x1d\x08\x40\xc6\xa0\x20\x8e\x08\x40\x72\x90\x40\x16\xa0\x10\x96\x84\x10\x00\x08\x40\x9e\x90\x20\x36\x60\x20\x91\x00\x00\x14", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8043, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x01\x01\x00\x04\x11\x00\x02\x21\x10\x1f\x84\x10\x20\x08\x40\x17\x90\x10\x3f\x84\x20\x1d\x08\x40\x46\xa0\x20\x8e\x08\x40\x70", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8090, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x96\xa0\x10\x16\x84\x10\x00\x08\x40\x1e\x90\x20\x34\x60\x10\x65\x84\x50\x10\x08\x00\x00\x21\x84\x03\x07\x20\xf0\x60\x9f\x03", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x7e\xa0\x00\x10\x08\x40\x65\xa0\x20\x0d\x08\x40\x64\x90\x40\x62\xa0\x00\x04\x00\x04\x1c\x44\x04\x1b\x44\xc3\xff\x21\x87\x04", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x7f\xa0\x10\x42\x84\x20\x1e\x08\x7f\xff\x21\x10\x20\x08\x40\x1c\x90\x10\x07\x84\x10\x00\x08\x40\x06\x90\x40\x55\xa0\x10\xc2", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x20\x1e\x08\x7f\xff\x21\x10\x20\x08\x40\x9c\x90\x10\x87\x84\x10\x00\x08\x40\x86\x90\x40\x56\xa0\x10\x56\x84\x20\x0f\x08\x40\x7b", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8090, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x22\x00\x60\x40\x00\x08\x40\x79\xa0\x00\x08\x11\x10\x55\x84\x20\x0f\x08\x40\x7a\x90\x22\x00\x60\x50\x00\x08\x40\x79\xa0\x00\xff", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x04\x6f\x84\x00\x05\x21\x21\x39\x00\x04\x00\x11\x10\xc1\x84\x20\x0f\x08\x70\x07\x07\x10\x10\x08\x40\xc0\xa0\x20\x0f\x08\x7f\xff", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x8f\x02\x07\x80\x00\x11\x08\x00\x20\x08\xc1\x84\x40\xbd\x90\x9e\x02\x07\x40\x7f\xa0\x40\xec\x90\x04\x6e\x84\x00\x05\x21\x21\x4c", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x04\x11\x10\x41\x84\x20\x0f\x08\x70\x07\x07\x10\x10\x08\x40\x40\xa0\x20\x0f\x08\x7f\xff\x11\x8f\x02\x07\x80\x00\x11\x08\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8020, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x08\x41\x84\x40\x3d\x90\x9e\x02\x07\x40\x7f\xa0\x40\x6d\x90\x10\x2d\x44\x20\xe7\x00\x08\x00\x11\x20\x32\x60\x80\x14\x43\x10\x2c", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8044, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x20\xec\x00\x00\x08\x11\x20\x31\x60\x00\x14\x43\x04\x34\x44\x40\x5b\xa0\x00\x04\x00\x21\x6a\x00\x80\x00\x11\x21\x70\x00\x3f\xff", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x08\xe8\x84\x20\x32\x50\x08\x68\x84\x20\x31\x50\x08\x5e\x84\x20\x30\x50\x0f\xc4\x07\x10\x34\x44\x10\x5b\x84\x6f\xf3\x07\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x02\x00\x21\x40\xfc\x90\x3d\xd4\x00\x04\xfc\x84\x00\x00\x21\x04\xfd\x84\x00\x08\x21\x00\x04\x00\x21\x81\x00\xc0\x00\x11\x04\x5b", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x02\x00\x21\x70\x06\x07\x10\xfe\x84\x30\x20\x08\x00\x03\x11\x10\x00\x08\x40\x59\x90\x04\xff\x84\x40\x58\xa0\x10\x59\x84\x20\x0f", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x59\xa0\x20\x00\x11\x70\x1e\x07\x10\x00\x08\x00\x0b\x11\x0f\xe4\x07\x10\x59\x84\x00\x00\x08\x20\x30\x50\x40\x59\xa0\x70\x06", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x00\x08\x00\x0a\x11\x0f\xec\x07\x08\x34\x44\x02\x10\x11\x10\x58\x84\x20\x0f\x08\x40\x58\xa0\x20\x00\x11\x30\x08\x07\x0f\xf4", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x58\x84\x00\x00\x08\x20\x30\x50\x40\x58\xa0\x70\x06\x07\x10\x00\x08\x00\x05\x11\x00\x04\x00\x10\x5a\x84\x00\x00\x08\x00\x01", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x5a\xa0\x08\x34\x44\x02\x00\x11\x30\x08\x07\x60\x00\x08\x00\x00\x11\x40\x5a\xa0\x8f\x4f\x07\x40\x7e\xa0\x00\x04\x00\x3c\xdd", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x00\x20\xa8\x14\x43\x04\xa7\x84\x20\x8e\x08\x40\xc4\x90\x40\xaf\xa0\x20\x0f\x08\x40\xc5\x90\x40\xa7\xa0\x3c\xe7\x00\x10\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8020, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x28\x14\x43\x04\x27\x84\x20\x8e\x08\x40\x44\x90\x40\x2f\xa0\x20\x0f\x08\x40\x45\x90\x40\x27\xa0\x00\x04\x00\x10\xf0\x44\x50\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\xff\xf7\x11\x93\x04\x07\x20\xf0\x60\x04\x61\x84\x04\x5c\x84\x40\x57\xa0\x00\x04\x00\x10\x61\x84\x00\x20\x08\x20\x1f\x08\x40\xff", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x00\x08\x40\x5c\x90\x40\x57\xa0\x04\x74\x84\x10\x00\x20\x00\x00\x08\x40\x74\xa0\x00\x01\x11\x20\x05\x07\x00\x40\x21\x70\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x7f\xff\x21\x08\xff\x84\x42\x00\x90\x85\x02\x07\x20\xf0\x60\x7f\xff\x11\x60\x20\x08\x00\xd0\x11\x40\x00\x08\x00\x02\x11\x86\x1b", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x74\xa0\x08\x6f\x84\x00\x00\x11\x04\xf1\x84\x00\x40\x21\x21\xf7\x00\x02\x00\x11\x60\x07\x07\x10\x20\x08\x40\xc3\x90\x20\x2f", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x80\x00\x11\x70\x02\x07\x7f\xff\x11\x10\x00\x08\x40\x8d\x90\x40\x85\xa0\x08\x6e\x84\x00\x00\x11\x04\xf0\x84\x00\x40\x21\x22\x07", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x02\x11\x60\x07\x07\x10\x20\x08\x40\x43\x90\x20\x2f\x08\x80\x00\x11\x70\x02\x07\x7f\xff\x11\x10\x00\x08\x40\x0d\x90\x40\x05", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\xec\x84\x00\x10\x08\x10\xe7\x84\x40\xe7\xa0\x20\x0f\x08\x40\xef\xa0\x10\x6d\x84\x00\x10\x08\x10\x6c\x84\x40\x6c\xa0\x20\x0f", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x7d\xa0\x7f\xff\x11\x00\x04\x00\x10\xef\x84\x00\x10\x08\x10\xee\x84\x40\xee\xa0\x20\x0f\x08\x40\xbd\xa0\x10\x7d\x84\x00\x10", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x7c\x84\x40\x7c\xa0\x20\x0f\x08\x40\x3d\xa0\x40\x00\x11\x3e\x9b\x00\xfb\xff\x21\x6f\x14\x43\x3e\x9e\x00\xff\xfb\x21\x6e\x14", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8043, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x3d\x57\x00\x40\xaf\xa0\xa0\x14\x43\x3d\x5a\x00\x40\x2f\xa0\x20\x14\x43\x00\x04\x00\x3d\x5e\x00\x40\xa5\xa0\xb0\x14\x43\x3d\x61", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x25\xa0\x30\x14\x43\x00\x00\x00\x22\x28\x00\x00\x02\x07\x22\x26\x00\x8a\x03\x07\x89\x04\x07\x40\x7e\xa0\x40\xbd\x90\x98\x14", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8043, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x9c\x84\x20\x8f\x08\x40\x9a\x90\x40\x99\xa0\x20\x2e\x08\x40\xbd\x90\x00\x10\x08\x40\x9b\xa0\x20\x0e\x08\x7f\xff\x21\x40\xf5", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8090, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x22\x3c\x00\x00\x02\x07\x22\x3a\x00\x82\x03\x07\x81\x04\x07\x40\x7e\xa0\x40\x3d\x90\x18\x14\x43\x10\x1c\x84\x20\x8f", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8008, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x1a\x90\x40\x19\xa0\x20\x2e\x08\x40\x3d\x90\x00\x10\x08\x40\x1b\xa0\x20\x0e\x08\x7f\xff\x21\x40\xf5\x90\x3d\x8c\x00\xb8\x14", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8043, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\xc2\xa0\x3d\x8f\x00\x38\x14\x43\x40\x42\xa0\x00\x04\x00\x10\x51\x84\x20\x0f\x08\x7f\xc0\x11\x40\x51\xa0\x08\xbb\x84\x08\x3b", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\xcb\x90\x11\x9e\x02\x07\xc7\x00\x11\x40\x7f\xa0\x08\xba\x84\x08\x3a\x84\x74\x70\x11\x9e\x02\x07\x59\x00\x11\x40\x7f\xa0\x3e\xed", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\xfd\xff\x21\xf1\x14\x43\x3e\xf0\x00\xff\xfd\x21\xf0\x14\x43\x00\x04\x00\x04\xb9\x84\x40\xb6\xa0\x04\x39\x84\x40\x36\xa0\x00\x04", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x3e\xc3\x00\x40\x87\xa0\x80\x14\x43\x3e\xc6\x00\x40\x07\xa0\x00\x14\x43\x00\x04\x00\x00\x00\x00\x04\xf5\x84\x00\x00\x21\x70\x03", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\xf5\x84\x10\x00\x08\x40\xf3\x90\x40\xf5\xa0\x3e\xd2\x00\x40\x85\xa0\x88\x14\x43\x3e\xd5\x00\x40\x05\xa0\x08\x14\x43\x00\x04", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8000, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x01\x07\x00\x02\x07\x00\x03\x07\x00\x04\x07\x00\x06\x07\x00\x16\x07\x00\x1e\x07\x00\x24\x07\x00\x3c\x07\x00\x72\x07\x00\x8d", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\xe0\x07\x00\xf6\x07\x01\x9f\x07\x01\xd1\x07\x00\x10\x07\x1f\xff\x07\x20\x03\x60\x0f\x5f\x07\x08\xfa\x84\x04\x11\x44\xff\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x2f\x63\x07\x70\x10\x08\x00\xf0\x21\x50\x00\x08\x00\xf0\x21\x40\xf9\x90\x00\x08\x07\x3e\x79\x00\x0f\x6b\x07\x90\x01\x07\x40\xf9", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x80a0, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x3f\x6e\x07\x70\x00\x08\x00\x7f\x11\x40\xf8\xa0\x9d\x07\x07\x20\x12\x60\x08\xfa\x84\x04\x11\x44\x3e\x54\x00\x00\x16\x07\x48\x80", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x08\x09\x44\x40\x75\x90\x7f\xef\x07\x10\x00\x20\x00\x10\x08\xff\xff\x21\x06\x00\x84\x40\xfb\xa0\x60\x00\x08\x00\x00\x21\x40\xff", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8090, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\xfb\x84\x60\x20\x08\x40\xfb\x90\x30\x00\x08\x00\x08\x11\x3d\xea\x00\x04\xfb\x84\x3d\xec\x00\x04\xff\x84\x40\xf8\xa0\x04\x11", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8044, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x8f\xff\x07\x20\x19\x60\x3e\xd2\x00\x00\x31\x07\x00\x01\x00\x00\x33\x07\x00\x02\x00\x27\x18\x43\x75\x00\x43\x8f\xff\x07\x20\x19", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8060, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x04\xf5\x84\x40\xf2\xa0\x04\x51\x84\x7f\xff\x21\x04\xf5\x84\x00\x00\x21\x04\xf3\x84\x00\x10\x21\x04\xf2\x84\x0c\x00\x21\x04\x72", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8044, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x77\x21\x3f\xfa\x07\x70\x20\x08\x00\x00\x11\x10\x2d\x44\x10\x2c\x44\x00\x20\x08\x10\x00\x11\x00\x00\x08\x00\x00\x11\x80\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8021, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x04\x73\x44\x07\x07\x21\x04\x72\x44\x00\x07\x21\x04\x73\x44\x07\x77\x21\x04\x73\x44\x00\x70\x21\x04\x2e\x44\x04\x2d\x44\x04\x2c", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8044, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x80\x00\x21\x04\x1c\x44\x04\x1b\x44\x0d\x00\x21\x04\x1c\x44\x04\x1b\x44\x0c\x80\x21\x04\x1c\x44\x04\x1b\x44\x1f\x08\x21\x0f\x18", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8043, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x08\x28\x44\x01\x11\x11\x08\x5d\x84\x10\x00\x10\x10\x00\x08\x40\x00\x21\x30\x04\x07\x40\xff\x90\x50\x20\x08\xc0\x00\x11\x10\xff", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x20\x08\x00\x40\x11\x40\x00\x08\x00\x01\x11\x20\x51\x60\x10\x00\x44\x60\x00\x08\x40\x54\x90\x20\x00\x60\x00\x79\x07\x81\x48", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x80\x03\x07\x40\xf8\xa0\x48\xc0\x11\x00\x77\x07\x00\x78\x07\x00\x79\x07\x00\x04\x07\x00\x7b\x07\x00\x7c\x07\x00\x7d\x07\x00\x55", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8007, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x7f\x07\x00\x80\x07\x00\x81\x07\x00\x74\x07\x00\x83\x07\x00\x82\x07\x00\x85\x07\x00\x86\x07\x0f\xef\x07\x1f\xff\x07\xff\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8011, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x10\x00\x20\x30\x10\x08\x00\x01\x21\x50\x00\x08\x00\x0f\x21\x40\xf9\x90\x30\x90\x07\x70\x10\x08\x00\x80\x21\x50\x00\x08\x00\xf0", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8021, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x08\xf9\x84\x04\xf8\x84\x2f\xff\x07\x3e\x59\x00\x04\xf1\x84\x04\xf0\x84\x04\x5a\x84\x00\x00\x21\x04\xf6\x84\x00\x02\x21\x04\xfa", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8084, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x40\x00\x21\x04\xf7\x84\x01\x04\x21\x04\x1c\x44\x04\x1b\x44\x0b\x23\x21\x0f\x18\x43\x04\x70\x44\x06\x66\x21\x04\x3b\x44\x04\x39", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8044, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x80\x21\x04\x3c\x44\x2a\x0a\x21\x04\x2f\x44\x00\x44\x21\x04\x29\x44\x00\x00\x21\x03\x19\x42\x4e\x19\x43\x0c\x59\x43\x27\x18", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8043, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x15\x00\x43\x04\x22\x44\x03\x07\x21\x04\x21\x44\x11\x11\x21\x04\x20\x44\x33\x33\x21\x00\x00\x42\xc0\x3d\x42\x80\x3d\x43\x04\x35", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8044, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x21\x04\x05\x43\x42\xcd\x00", - .reg_data_seq_size = 9, - },{ - .reg_addr = 0x88ef, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x20\x00\x18\x00\x00\x00\x00\xab\x0a\x00\x40\x00\x40\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x27\x83\x64\x7e\xca\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x88b2, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x7f\x59\x7f\xbe\x7f\xfe\x7f\xfe\x7f\xee\x73\x54\x4c\x70\x5a\x00\x6b\x0e\x6b\x1c\x5b\xcb\x32\x8c\x0b\xd2\x13\x07\x28\x01\x49\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x00\xff\x7f\x0b\x97\x14\xae\xf7\x53\x26\x63\x07\x46\x00\x20\x00\x89\x00\x40\x80\x41\x00\x7f\xff\x7f\xd3\x09\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x88ff, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x7f\x00\x00\x00\x00\x90\xcb\x70\x74\xfe\x7f\x52\x09\x00\x00\xfe\x7f\x00\x00\x00\x00\x00\xf2\x00\x40\xf0\x7f\x00\x0c\x00\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x00\x00\x4a\x00\x4a\x00\x24\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x00\x50\x00\x30\x00\x00\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\xa0\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\xff\x7f\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x00\xff\x7f\x00\x78\x00\x08\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x40\x00\x40\x00\x00\x00\x00\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x80\xff\x7f\x1c\x1b\xc5\x07\xc0\x20\x12\xf0\x00\x10\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\xcc\x59\x00\x00\x00\x40\x00\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x0b", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8897, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x14\xae\xf7\x53\x26\x63\x07\x46\x00\x20\x00\x89\x00\x40\x80\x41\x00\x7f\xff\x7f\xd3\x09\x00\x00\xff\x7f\x00\x00\x00\x00\x90\xcb", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8870, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x74\xfe\x7f\x52\x09\x00\x00\xfe\x7f\x00\x00\x00\x00\x00\xf2\x00\x40\xf0\x7f\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4a\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x884a, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x24\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x00\x50\x00\x30\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x00\x00\x03", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8800, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\xff\x7f\x00\x00\x00\x00\x00\x00\xff\x7f\x00", - .reg_data_seq_size = 32, - },{ - .reg_addr = 0x8878, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0000, - .data_type = MSM_CAMERA_I2C_SEQ_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "\x00\x08\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x40\x00\x40", - .reg_data_seq_size = 18, - },{ - .reg_addr = 0x8205, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0c00, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8205, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0d00, - .data_type = MSM_CAMERA_I2C_WORD_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - },{ - .reg_addr = 0x8c01, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .reg_data = 0x0001, - .data_type = MSM_CAMERA_I2C_BYTE_DATA, - .i2c_operation = MSM_OIS_WRITE, - .delay = 0, - .reg_data_seq = "", - .reg_data_seq_size = 0, - } -}; - - -/* -// still mode settings: - {0x847f, 0x0c0c,}, //_M_EQCTL - - {0x8436, 0xfd7f,}, //_M_Kgxdr - {0x8440, 0xf07f,}, //_M_X_LMT - {0x8443, 0xb41e,}, //_M_X_TGT - {0x841b, 0x4001,}, //_M_Kgx10 - - {0x84b6, 0xfd7f,}, //_M_Kgydr - {0x84c0, 0xf07f,}, //_M_Y_LMT - {0x84c3, 0xb41e,}, //_M_Y_TGT - {0x849b, 0x4001,}, //_M_Kgy10 - - {0x8438, 0x2d0f,}, //_M_Kgx11 - {0x84b8, 0x2d0f,}, //_M_Kgy11 - {0x8447, 0x002b,}, //_M_KgxTG - {0x84c7, 0x002b,}, //_M_KgyTG - - {0x847f, 0x0d0d,}, //_M_EQCTL -*/ - -static struct msm_camera_i2c_reg_array init_array_s5k3p8sp[] = { - {0x6028,0x2000,0}, {0x6214,0x7971,0}, {0x6218,0x7150,0}, {0x30e,0x3d,0}, - {0x6028,0x2000,0}, {0x602a,0x2f38,0}, {0x6f12,0x88,0}, {0x6f12,0xd70,0}, - {0x344,0x18,0}, - {0x348,0x1217,0}, // last_pixel = 0x90C*2 - {0x346,0x18,0}, - {0x34a,0xd97,0}, // last_line = 0x6CC*2 - {0x34c,0x900,0}, // width? - {0x34e,0x6c0,0}, // height? - {0x342,0x1400,0}, // line_length_pclk - {0x340,0xe3b,0}, // frame_length_lines - {0x202,0x200,0}, // integ_time - {0x200,0x618,0}, - {0x900,0x122,0}, {0x380,0x1,0}, {0x382,0x3,0}, {0x384,0x3,0}, {0x386,0x1,0}, {0x400,0x0,0}, {0x404,0x10,0}, - {0x3604,0x2,0}, {0x3606,0x103,0}, {0xf496,0x48,0}, {0xf470,0x20,0}, {0xf43a,0x15,0}, {0xf484,0x6,0}, {0xf440,0xaf,0}, {0xf442,0x44c6,0}, - {0xf408,0xfff7,0}, {0x3664,0x19,0}, {0xf494,0x1010,0}, {0x367a,0x100,0}, {0x362a,0x104,0}, {0x362e,0x404,0}, {0x32b2,0x8,0}, {0x3286,0x3,0}, {0x328a,0x5,0}, - {0xf47c,0x1f,0}, {0xf62e,0xc5,0}, {0xf630,0xcd,0}, {0xf632,0xdd,0}, {0xf634,0xe5,0}, {0xf636,0xf5,0}, {0xf638,0xfd,0}, {0xf63a,0x10d,0}, {0xf63c,0x115,0}, {0xf63e,0x125,0}, {0xf640,0x12d,0}, - {0x6028,0x2000,0}, {0x602a,0x1704,0}, {0x6f12,0x8011,0}, {0x3070,0x0,0}, {0xb0e,0x0,0}, {0x317a,0x7,0}, {0x31c0,0xc8,0}, {0x1006,0x4,0}, {0x31a4,0x102,0}, -}; - -static struct msm_camera_i2c_reg_array init_array_ov8865[] = { -// round 1 -//{0x103,0x1,0}, // software reset -{0x100,0x0,0}, // standby on -{0x3638,0xff,0}, -{0x302,0x1e,0}, {0x303,0x0,0}, {0x304,0x3,0}, {0x30d,0x1e,0}, {0x30e,0x0,0}, {0x30f,0x9,0}, {0x312,0x1,0}, {0x31e,0xc,0}, // PLL control -{0x3015,0x1,0}, {0x3018,0x72,0}, {0x3020,0x93,0}, {0x3022,0x1,0}, -{0x3031,0xa,0}, // 10-bit mode -{0x3106,0x1,0}, {0x3305,0xf1,0}, {0x3308,0x0,0}, {0x3309,0x28,0}, {0x330a,0x0,0}, {0x330b,0x20,0}, {0x330c,0x0,0}, {0x330d,0x0,0}, {0x330e,0x0,0}, {0x330f,0x40,0}, {0x3307,0x4,0}, {0x3604,0x4,0}, {0x3602,0x30,0}, {0x3605,0x0,0}, {0x3607,0x20,0}, {0x3608,0x11,0}, {0x3609,0x68,0}, {0x360a,0x40,0}, {0x360c,0xdd,0}, {0x360e,0xc,0}, {0x3610,0x7,0}, {0x3612,0x86,0}, {0x3613,0x58,0}, {0x3614,0x28,0}, {0x3617,0x40,0}, {0x3618,0x5a,0}, {0x3619,0x9b,0}, {0x361c,0x0,0}, {0x361d,0x60,0}, {0x3631,0x60,0}, {0x3633,0x10,0}, {0x3634,0x10,0}, {0x3635,0x10,0}, {0x3636,0x10,0}, {0x3641,0x55,0}, {0x3646,0x86,0}, {0x3647,0x27,0}, {0x364a,0x1b,0}, {0x3500,0x0,0}, {0x3501,0x4c,0}, {0x3502,0x0,0}, {0x3503,0x0,0}, {0x3508,0x2,0}, -{0x3509,0x0,0}, // AEC GAIN -{0x3700,0x24,0}, {0x3701,0xc,0}, {0x3702,0x28,0}, {0x3703,0x19,0}, {0x3704,0x14,0}, {0x3705,0x0,0}, {0x3706,0x38,0}, {0x3707,0x4,0}, {0x3708,0x24,0}, {0x3709,0x40,0}, {0x370a,0x0,0}, {0x370b,0xb8,0}, {0x370c,0x4,0}, {0x3718,0x12,0}, {0x3719,0x31,0}, {0x3712,0x42,0}, {0x3714,0x12,0}, {0x371e,0x19,0}, {0x371f,0x40,0}, {0x3720,0x5,0}, {0x3721,0x5,0}, {0x3724,0x2,0}, {0x3725,0x2,0}, {0x3726,0x6,0}, {0x3728,0x5,0}, {0x3729,0x2,0}, {0x372a,0x3,0}, {0x372b,0x53,0}, {0x372c,0xa3,0}, {0x372d,0x53,0}, {0x372e,0x6,0}, {0x372f,0x10,0}, {0x3730,0x1,0}, {0x3731,0x6,0}, {0x3732,0x14,0}, {0x3733,0x10,0}, {0x3734,0x40,0}, {0x3736,0x20,0}, {0x373a,0x2,0}, {0x373b,0xc,0}, {0x373c,0xa,0}, {0x373e,0x3,0}, {0x3755,0x40,0}, {0x3758,0x0,0}, {0x3759,0x4c,0}, {0x375a,0x6,0}, {0x375b,0x13,0}, {0x375c,0x40,0}, {0x375d,0x2,0}, {0x375e,0x0,0}, {0x375f,0x14,0}, {0x3767,0x1c,0}, {0x3768,0x4,0}, {0x3769,0x20,0}, {0x376c,0xc0,0}, {0x376d,0xc0,0}, {0x376a,0x8,0}, {0x3761,0x0,0}, {0x3762,0x0,0}, {0x3763,0x0,0}, {0x3766,0xff,0}, {0x376b,0x42,0}, {0x3772,0x23,0}, {0x3773,0x2,0}, {0x3774,0x16,0}, {0x3775,0x12,0}, {0x3776,0x8,0}, {0x37a0,0x44,0}, {0x37a1,0x3d,0}, {0x37a2,0x3d,0}, {0x37a3,0x1,0}, {0x37a4,0x0,0}, {0x37a5,0x8,0}, {0x37a6,0x0,0}, {0x37a7,0x44,0}, {0x37a8,0x58,0}, {0x37a9,0x58,0}, {0x3760,0x0,0}, {0x376f,0x1,0}, {0x37aa,0x44,0}, {0x37ab,0x2e,0}, {0x37ac,0x2e,0}, {0x37ad,0x33,0}, {0x37ae,0xd,0}, {0x37af,0xd,0}, {0x37b0,0x0,0}, {0x37b1,0x0,0}, {0x37b2,0x0,0}, {0x37b3,0x42,0}, {0x37b4,0x42,0}, {0x37b5,0x33,0}, {0x37b6,0x0,0}, {0x37b7,0x0,0}, {0x37b8,0x0,0}, {0x37b9,0xff,0}, {0x3800,0x0,0}, {0x3801,0xc,0}, {0x3802,0x0,0}, {0x3803,0xc,0}, -{0x3804,0xc,0}, {0x3805,0xd3,0}, // 3283 -{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) -{0x3810,0x0,0}, {0x3811,0x4,0}, {0x3813,0x4,0}, -{0x3814,0x3,0}, {0x3815,0x1,0}, // H-binning -{0x3820,0x6,0}, // format1 -{0x3821,0x40,0}, // format2 -{0x382a,0x3,0}, {0x382b,0x1,0}, // V-binning -{0x382d,0x7f,0}, {0x3830,0x8,0}, {0x3836,0x2,0}, {0x3837,0x18,0}, -{0x3841,0xff,0}, -{0x3846,0x88,0}, {0x3d85,0x6,0}, {0x3d8c,0x75,0}, {0x3d8d,0xef,0}, {0x3f08,0xb,0}, {0x4000,0xf1,0}, {0x4001,0x14,0}, {0x4005,0x10,0}, {0x4006,0x1,0}, {0x4007,0x1,0}, {0x400b,0xc,0}, {0x400d,0x10,0}, {0x401b,0x0,0}, {0x401d,0x0,0}, {0x4020,0x0,0}, {0x4021,0x0,0}, {0x4022,0x4,0}, {0x4023,0x1f,0}, {0x4024,0x6,0}, {0x4025,0x20,0}, {0x4026,0x6,0}, {0x4027,0x4f,0}, {0x4028,0x0,0}, {0x4029,0x2,0}, {0x402a,0x4,0}, {0x402b,0x4,0}, {0x402c,0x2,0}, {0x402d,0x2,0}, {0x402e,0x8,0}, {0x402f,0x2,0}, {0x401f,0x0,0}, {0x4034,0x3f,0}, {0x4300,0xff,0}, {0x4301,0x0,0}, {0x4302,0xf,0}, {0x4500,0x40,0}, {0x4503,0x10,0}, {0x4601,0x74,0}, {0x481f,0x32,0}, {0x4837,0x15,0}, {0x4850,0x10,0}, {0x4851,0x32,0}, {0x4b00,0x2a,0}, {0x4b0d,0x0,0}, {0x4d00,0x4,0}, {0x4d01,0x18,0}, {0x4d02,0xc3,0}, {0x4d03,0xff,0}, {0x4d04,0xff,0}, {0x4d05,0xff,0}, {0x5000,0x96,0}, {0x5001,0x1,0}, {0x5002,0x8,0}, {0x5901,0x0,0}, -{0x5e00,0x0,0}, -//{0x5e00,0x80,0}, -{0x5e01,0x41,0}, {0x5b00,0x2,0}, {0x5b01,0xd0,0}, {0x5b02,0x3,0}, {0x5b03,0xff,0}, {0x5b05,0x6c,0}, {0x5780,0xfc,0}, {0x5781,0xdf,0}, {0x5782,0x3f,0}, {0x5783,0x8,0}, {0x5784,0xc,0}, {0x5786,0x20,0}, {0x5787,0x40,0}, {0x5788,0x8,0}, {0x5789,0x8,0}, {0x578a,0x2,0}, {0x578b,0x1,0}, {0x578c,0x1,0}, {0x578d,0xc,0}, {0x578e,0x2,0}, {0x578f,0x1,0}, {0x5790,0x1,0}, {0x5800,0x1d,0}, {0x5801,0xe,0}, {0x5802,0xc,0}, {0x5803,0xc,0}, {0x5804,0xf,0}, {0x5805,0x22,0}, {0x5806,0xa,0}, {0x5807,0x6,0}, {0x5808,0x5,0}, {0x5809,0x5,0}, {0x580a,0x7,0}, {0x580b,0xa,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x3,0}, {0x5811,0x7,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x3,0}, {0x5817,0x7,0}, {0x5818,0x9,0}, {0x5819,0x6,0}, {0x581a,0x4,0}, {0x581b,0x4,0}, {0x581c,0x6,0}, {0x581d,0xa,0}, {0x581e,0x19,0}, {0x581f,0xd,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xe,0}, {0x5823,0x22,0}, {0x5824,0x23,0}, {0x5825,0x28,0}, {0x5826,0x29,0}, {0x5827,0x27,0}, {0x5828,0x13,0}, {0x5829,0x26,0}, {0x582a,0x33,0}, {0x582b,0x32,0}, {0x582c,0x33,0}, {0x582d,0x16,0}, {0x582e,0x14,0}, {0x582f,0x30,0}, {0x5830,0x31,0}, {0x5831,0x30,0}, {0x5832,0x15,0}, {0x5833,0x26,0}, {0x5834,0x23,0}, {0x5835,0x21,0}, {0x5836,0x23,0}, {0x5837,0x5,0}, {0x5838,0x36,0}, {0x5839,0x27,0}, {0x583a,0x28,0}, {0x583b,0x26,0}, {0x583c,0x24,0}, {0x583d,0xdf,0}, -//{0x100,0x1,0}, -// round 2 (color calibration) -{0x7010,0x0,0}, {0x7011,0x0,0}, {0x7012,0x0,0}, {0x7013,0x0,0}, {0x7014,0x0,0}, {0x7015,0x0,0}, {0x7016,0x0,0}, {0x7017,0x0,0}, {0x7018,0x0,0}, {0x7019,0x0,0}, {0x701a,0x0,0}, {0x701b,0x0,0}, {0x701c,0x0,0}, {0x701d,0x0,0}, {0x701e,0x0,0}, {0x701f,0x0,0}, {0x7020,0x0,0}, {0x7021,0x0,0}, {0x7022,0x0,0}, {0x7023,0x0,0}, {0x7024,0x0,0}, {0x7025,0x0,0}, {0x7026,0x0,0}, {0x7027,0x0,0}, {0x7028,0x0,0}, {0x7029,0x0,0}, {0x702a,0x0,0}, {0x702b,0x0,0}, {0x702c,0x0,0}, {0x702d,0x0,0}, {0x702e,0x0,0}, {0x702f,0x0,0}, {0x7030,0x0,0}, {0x7031,0x0,0}, {0x7032,0x0,0}, {0x7033,0x0,0}, {0x7034,0x0,0}, {0x7035,0x0,0}, {0x7036,0x0,0}, {0x7037,0x0,0}, {0x7038,0x0,0}, {0x7039,0x0,0}, {0x703a,0x0,0}, {0x703b,0x0,0}, {0x703c,0x0,0}, {0x703d,0x0,0}, {0x703e,0x0,0}, {0x703f,0x0,0}, {0x7040,0x0,0}, {0x7041,0x0,0}, {0x7042,0x0,0}, {0x7043,0x0,0}, {0x7044,0x0,0}, {0x7045,0x0,0}, {0x7046,0x0,0}, {0x7047,0x0,0}, {0x7048,0x0,0}, {0x7049,0x0,0}, {0x704a,0x0,0}, {0x704b,0x0,0}, {0x704c,0x0,0}, {0x704d,0x0,0}, {0x704e,0x0,0}, {0x704f,0x0,0}, {0x7050,0x0,0}, {0x7051,0x0,0}, {0x7052,0x0,0}, {0x7053,0x0,0}, {0x7054,0x0,0}, {0x7055,0x0,0}, {0x7056,0x0,0}, {0x7057,0x0,0}, {0x7058,0x0,0}, {0x7059,0x0,0}, {0x705a,0x0,0}, {0x705b,0x0,0}, {0x705c,0x0,0}, {0x705d,0x0,0}, {0x705e,0x0,0}, {0x705f,0x0,0}, {0x7060,0x0,0}, {0x7061,0x0,0}, {0x7062,0x0,0}, {0x7063,0x0,0}, {0x7064,0x0,0}, {0x7065,0x0,0}, {0x7066,0x0,0}, {0x7067,0x0,0}, {0x7068,0x0,0}, {0x7069,0x0,0}, {0x706a,0x0,0}, {0x706b,0x0,0}, {0x706c,0x0,0}, {0x706d,0x0,0}, {0x706e,0x0,0}, {0x706f,0x0,0}, {0x7070,0x0,0}, {0x7071,0x0,0}, {0x7072,0x0,0}, {0x7073,0x0,0}, {0x7074,0x0,0}, {0x7075,0x0,0}, {0x7076,0x0,0}, {0x7077,0x0,0}, {0x7078,0x0,0}, {0x7079,0x0,0}, {0x707a,0x0,0}, {0x707b,0x0,0}, {0x707c,0x0,0}, {0x707d,0x0,0}, {0x707e,0x0,0}, {0x707f,0x0,0}, {0x7080,0x0,0}, {0x7081,0x0,0}, {0x7082,0x0,0}, {0x7083,0x0,0}, {0x7084,0x0,0}, {0x7085,0x0,0}, {0x7086,0x0,0}, {0x7087,0x0,0}, {0x7088,0x0,0}, {0x7089,0x0,0}, {0x708a,0x0,0}, {0x708b,0x0,0}, {0x708c,0x0,0}, {0x708d,0x0,0}, {0x708e,0x0,0}, {0x708f,0x0,0}, {0x7090,0x0,0}, {0x7091,0x0,0}, {0x7092,0x0,0}, {0x7093,0x0,0}, {0x7094,0x0,0}, {0x7095,0x0,0}, {0x7096,0x0,0}, {0x7097,0x0,0}, {0x7098,0x0,0}, {0x7099,0x0,0}, {0x709a,0x0,0}, {0x709b,0x0,0}, {0x709c,0x0,0}, {0x709d,0x0,0}, {0x709e,0x0,0}, {0x709f,0x0,0}, {0x70a0,0x0,0}, {0x70a1,0x0,0}, {0x70a2,0x0,0}, {0x70a3,0x0,0}, {0x70a4,0x0,0}, {0x70a5,0x0,0}, {0x70a6,0x0,0}, {0x70a7,0x0,0}, {0x70a8,0x0,0}, {0x70a9,0x0,0}, {0x70aa,0x0,0}, {0x70ab,0x0,0}, {0x70ac,0x0,0}, {0x70ad,0x0,0}, {0x70ae,0x0,0}, {0x70af,0x0,0}, {0x70b0,0x0,0}, {0x70b1,0x0,0}, {0x70b2,0x0,0}, {0x70b3,0x0,0}, {0x70b4,0x0,0}, {0x70b5,0x0,0}, {0x70b6,0x0,0}, {0x70b7,0x0,0}, {0x70b8,0x0,0}, {0x70b9,0x0,0}, {0x70ba,0x0,0}, {0x70bb,0x0,0}, {0x70bc,0x0,0}, {0x70bd,0x0,0}, {0x70be,0x0,0}, {0x70bf,0x0,0}, {0x70c0,0x0,0}, {0x70c1,0x0,0}, {0x70c2,0x0,0}, {0x70c3,0x0,0}, {0x70c4,0x0,0}, {0x70c5,0x0,0}, {0x70c6,0x0,0}, {0x70c7,0x0,0}, {0x70c8,0x0,0}, {0x70c9,0x0,0}, {0x70ca,0x0,0}, {0x70cb,0x0,0}, {0x70cc,0x0,0}, {0x70cd,0x0,0}, {0x70ce,0x0,0}, {0x70cf,0x0,0}, {0x70d0,0x0,0}, {0x70d1,0x0,0}, {0x70d2,0x0,0}, {0x70d3,0x0,0}, {0x70d4,0x0,0}, {0x70d5,0x0,0}, {0x70d6,0x0,0}, {0x70d7,0x0,0}, {0x70d8,0x0,0}, {0x70d9,0x0,0}, {0x70da,0x0,0}, {0x70db,0x0,0}, {0x70dc,0x0,0}, {0x70dd,0x0,0}, {0x70de,0x0,0}, {0x70df,0x0,0}, {0x70e0,0x0,0}, {0x70e1,0x0,0}, {0x70e2,0x0,0}, {0x70e3,0x0,0}, {0x70e4,0x0,0}, {0x70e5,0x0,0}, {0x70e6,0x0,0}, {0x70e7,0x0,0}, {0x70e8,0x0,0}, {0x70e9,0x0,0}, {0x70ea,0x0,0}, {0x70eb,0x0,0}, {0x70ec,0x0,0}, {0x70ed,0x0,0}, {0x70ee,0x0,0}, {0x70ef,0x0,0}, {0x70f0,0x0,0}, {0x70f1,0x0,0}, {0x70f2,0x0,0}, {0x70f3,0x0,0}, {0x70f4,0x0,0}, {0x70f5,0x0,0}, {0x70f6,0x0,0}, {0x70f7,0x0,0}, {0x70f8,0x0,0}, {0x70f9,0x0,0}, {0x70fa,0x0,0}, {0x70fb,0x0,0}, {0x70fc,0x0,0}, {0x70fd,0x0,0}, {0x70fe,0x0,0}, {0x70ff,0x0,0}, {0x7100,0x0,0}, {0x7101,0x0,0}, {0x7102,0x0,0}, {0x7103,0x0,0}, {0x7104,0x0,0}, {0x7105,0x0,0}, {0x7106,0x0,0}, {0x7107,0x0,0}, {0x7108,0x0,0}, {0x7109,0x0,0}, {0x710a,0x0,0}, {0x710b,0x0,0}, {0x710c,0x0,0}, {0x710d,0x0,0}, {0x710e,0x0,0}, {0x710f,0x0,0}, {0x7110,0x0,0}, {0x7111,0x0,0}, {0x7112,0x0,0}, {0x7113,0x0,0}, {0x7114,0x0,0}, {0x7115,0x0,0}, {0x7116,0x0,0}, {0x7117,0x0,0}, {0x7118,0x0,0}, {0x7119,0x0,0}, {0x711a,0x0,0}, {0x711b,0x0,0}, {0x711c,0x0,0}, {0x711d,0x0,0}, {0x711e,0x0,0}, {0x711f,0x0,0}, {0x7120,0x0,0}, {0x7121,0x0,0}, {0x7122,0x0,0}, {0x7123,0x0,0}, {0x7124,0x0,0}, {0x7125,0x0,0}, {0x7126,0x0,0}, {0x7127,0x0,0}, {0x7128,0x0,0}, {0x7129,0x0,0}, {0x712a,0x0,0}, {0x712b,0x0,0}, {0x712c,0x0,0}, {0x712d,0x0,0}, {0x712e,0x0,0}, {0x712f,0x0,0}, {0x7130,0x0,0}, {0x7131,0x0,0}, {0x7132,0x0,0}, {0x501a,0x10,0}, {0x501b,0xd,0}, {0x501c,0x10,0}, {0x501d,0x13,0}, {0x5000,0x96,0}, {0x5800,0x14,0}, {0x5801,0xd,0}, {0x5802,0xa,0}, {0x5803,0xa,0}, {0x5804,0xd,0}, {0x5805,0x13,0}, {0x5806,0xa,0}, {0x5807,0x5,0}, {0x5808,0x3,0}, {0x5809,0x3,0}, {0x580a,0x5,0}, {0x580b,0x9,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x2,0}, {0x5811,0x5,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x2,0}, {0x5817,0x5,0}, {0x5818,0xb,0}, {0x5819,0x6,0}, {0x581a,0x3,0}, {0x581b,0x3,0}, {0x581c,0x5,0}, {0x581d,0xa,0}, {0x581e,0x16,0}, {0x581f,0xf,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xf,0}, {0x5823,0x15,0}, {0x5824,0x32,0}, {0x5825,0x23,0}, {0x5826,0x23,0}, {0x5827,0x23,0}, {0x5828,0x22,0}, {0x5829,0x21,0}, {0x582a,0x21,0}, {0x582b,0x22,0}, {0x582c,0x21,0},{0x582d,0x11,0}, {0x582e,0x22,0}, {0x582f,0x31,0}, {0x5830,0x41,0}, {0x5831,0x31,0}, {0x5832,0x1,0}, {0x5833,0x21,0}, {0x5834,0x21,0}, {0x5835,0x21,0}, {0x5836,0x11,0}, {0x5837,0x11,0}, {0x5838,0x22,0}, {0x5839,0x22,0}, {0x583a,0x12,0}, {0x583b,0x22,0}, {0x583c,0x22,0}, {0x583d,0xdf,0}, -}; - 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 c2bb657bb525c9..00000000000000 --- a/selfdrive/visiond/models/commonmodel.c +++ /dev/null @@ -1,166 +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 bf5933f4288ae7..00000000000000 --- a/selfdrive/visiond/models/driving.cc +++ /dev/null @@ -1,141 +0,0 @@ -#include -#include -#include -#include - -#ifdef QCOM - #include -#else - #include -#endif - -#include "common/timing.h" -#include "driving.h" - -#ifdef MEDMODEL - #define MODEL_WIDTH 512 - #define MODEL_HEIGHT 256 - #define MODEL_NAME "driving_model_dlc" -#else - #define MODEL_WIDTH 320 - #define MODEL_HEIGHT 160 - #define MODEL_NAME "driving_model_dlc" -#endif - -#define OUTPUT_SIZE (200 + 2*201 + 26) -#define LEAD_MDN_N 5 - -#ifdef TEMPORAL - #define TEMPORAL_SIZE 512 -#else - #define TEMPORAL_SIZE 0 -#endif - -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; - } 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); - - //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("done \n"); - 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]; - - ModelData model = {0}; - - for (int i=0; i net_outputs.lead[mdn_max_idx*5 + 4]) { - mdn_max_idx = i; - } - } - model.lead.prob = sigmoid(net_outputs.lead[LEAD_MDN_N*5]); - model.lead.dist = net_outputs.lead[mdn_max_idx*5] * max_dist; - model.lead.std = softplus(net_outputs.lead[mdn_max_idx*5 + 2]) * max_dist; - model.lead.rel_v = net_outputs.lead[mdn_max_idx*5 + 1] * max_rel_vel; - model.lead.rel_v_std = softplus(net_outputs.lead[mdn_max_idx*5 + 3]) * max_rel_vel; - 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(); - - // Solve inplace - Eigen::ColPivHouseholderQR > qr(lhs); - p = qr.solve(rhs); -} diff --git a/selfdrive/visiond/models/driving.h b/selfdrive/visiond/models/driving.h deleted file mode 100644 index 2afb205217153e..00000000000000 --- a/selfdrive/visiond/models/driving.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef MODEL_H -#define MODEL_H - -// gate this here -#define MEDMODEL -#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 7b151d0c413ac2..00000000000000 --- a/selfdrive/visiond/models/monitoring.cc +++ /dev/null @@ -1,51 +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.vs, s->output, sizeof(ret.vs)); - ret.std = sqrtf(2.f) / s->output[OUTPUT_SIZE - 1]; - - 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 f9f4516bd8fbd1..00000000000000 --- a/selfdrive/visiond/models/monitoring.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MONITORING_H -#define MONITORING_H - -#include "commonmodel.h" -#include "runners/run.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define OUTPUT_SIZE 8 - -typedef struct MonitoringResult { - float vs[OUTPUT_SIZE - 1]; - float std; -} 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 d92519daf16387..00000000000000 --- a/selfdrive/visiond/runners/run.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef RUN_H -#define RUN_H - -#include "runmodel.h" -#include "snpemodel.h" - -#ifdef QCOM - #define DefaultRunModel SNPEModel -#else - #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.cl b/selfdrive/visiond/transforms/loadyuv.cl deleted file mode 100644 index e015429156ce91..00000000000000 --- a/selfdrive/visiond/transforms/loadyuv.cl +++ /dev/null @@ -1,43 +0,0 @@ -#define UV_SIZE ((TRANSFORMED_WIDTH/2)*(TRANSFORMED_HEIGHT/2)) - -__kernel void loadys(__global uchar8 const * const Y, - __global float * out) -{ - const int gid = get_global_id(0); - const int ois = gid * 8; - const int oy = ois / TRANSFORMED_WIDTH; - 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; - - // 02 - // 13 - - __global float* outy0; - __global float* outy1; - if ((oy & 1) == 0) { - outy0 = out; //y0 - outy1 = out + UV_SIZE*2; //y2 - } else { - outy0 = out + UV_SIZE; //y1 - outy1 = out + UV_SIZE*3; //y3 - } - - vstore4(ysf.s0246, 0, outy0 + (oy/2) * (TRANSFORMED_WIDTH/2) + ox/2); - vstore4(ysf.s1357, 0, outy1 + (oy/2) * (TRANSFORMED_WIDTH/2) + ox/2); -} - -__kernel void loaduv(__global uchar8 const * const in, - __global float8 * out, - int out_offset) -{ - 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; - out[gid + out_offset / 8] = outv; -} 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/rgb_to_yuv.h b/selfdrive/visiond/transforms/rgb_to_yuv.h deleted file mode 100644 index 79895803456d69..00000000000000 --- a/selfdrive/visiond/transforms/rgb_to_yuv.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef RGB_TO_YUV_H -#define RGB_TO_YUV_H - -#include -#include - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int width, height; - cl_kernel rgb_to_yuv_krnl; -} RGBToYUVState; - -void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride); - -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/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/transforms/transform.h b/selfdrive/visiond/transforms/transform.h deleted file mode 100644 index 3854be9da62db6..00000000000000 --- a/selfdrive/visiond/transforms/transform.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef TRANSFORM_H -#define TRANSFORM_H - -#include -#include - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#include "common/mat.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - cl_kernel krnl; - cl_mem m_y_cl, m_uv_cl; -} Transform; - -void transform_init(Transform* s, cl_context ctx, cl_device_id device_id); - -void transform_destroy(Transform* transform); - -void transform_queue(Transform* s, cl_command_queue q, - cl_mem 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); - -#ifdef __cplusplus -} -#endif - -#endif // TRANSFORM_H diff --git a/selfdrive/visiond/visiond.cc b/selfdrive/visiond/visiond.cc deleted file mode 100644 index 530fd68f91ca80..00000000000000 --- a/selfdrive/visiond/visiond.cc +++ /dev/null @@ -1,1401 +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 - -#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); - - // 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); - - kj::ArrayPtr descriptor_vs(&res.vs[0], ARRAYSIZE(res.vs)); - framed.setDescriptor(descriptor_vs); - - framed.setStd(res.std); - - auto words = capnp::messageToFlatArray(msg); - auto bytes = words.asBytes(); - zmq_send(s->monitoring_sock_raw, bytes.begin(), bytes.size(), ZMQ_DONTWAIT); - } - - double 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 - 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); - } -#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); - - 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); -#ifdef MEDMODEL - auto wm2 = event.getLiveCalibration().getWarpMatrixBig(); -#else - auto wm2 = event.getLiveCalibration().getWarpMatrix2(); -#endif - assert(wm2.size() == 3*3); - for (int i=0; i<3*3; i++) { - s->cur_transform.v[i] = wm2[i]; - } - 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..c2914755336b40 --- /dev/null +++ b/site_scons/site_tools/cython.py @@ -0,0 +1,72 @@ +import re +import SCons +from SCons.Action import Action +from SCons.Scanner import Scanner + +pyx_from_import_re = re.compile(r'^from\s+(\S+)\s+cimport', re.M) +pyx_import_re = re.compile(r'^cimport\s+(\S+)', re.M) +cdef_import_re = re.compile(r'^cdef extern from\s+.(\S+).:', re.M) + + +def pyx_scan(node, env, path, arg=None): + contents = node.get_text_contents() + + # from cimport ... + matches = pyx_from_import_re.findall(contents) + # cimport + matches += pyx_import_re.findall(contents) + + # Modules can be either .pxd or .pyx files + files = [m.replace('.', '/') + '.pxd' for m in matches] + files += [m.replace('.', '/') + '.pyx' for m in matches] + + # cdef extern from + files += cdef_import_re.findall(contents) + + # Handle relative imports + cur_dir = str(node.get_dir()) + files = [cur_dir + f if f.startswith('/') else f for f in files] + + # Filter out non-existing files (probably system imports) + files = [f for f in files if env.File(f).exists()] + return env.File(files) + + +pyxscanner = Scanner(function=pyx_scan, skeys=['.pyx', '.pxd'], recursive=True) +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.Append(SCANNERS=pyxscanner) + 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 diff --git a/third_party/SConscript b/third_party/SConscript new file mode 100644 index 00000000000000..5a7a62ae5ada06 --- /dev/null +++ b/third_party/SConscript @@ -0,0 +1,6 @@ +Import('env') + +env.Library('json11', ['json11/json11.cpp']) +env.Append(CPPPATH=[Dir('json11')]) + +env.Library('kaitai', ['kaitai/kaitaistream.cpp'], CPPDEFINES=['KS_STR_ENCODING_NONE']) diff --git a/third_party/acados/aarch64/lib/libacados.so b/third_party/acados/aarch64/lib/libacados.so new file mode 100755 index 00000000000000..fe961d8c5045d4 Binary files /dev/null and b/third_party/acados/aarch64/lib/libacados.so differ diff --git a/third_party/acados/aarch64/lib/libblasfeo.so b/third_party/acados/aarch64/lib/libblasfeo.so new file mode 100755 index 00000000000000..a59f3f79f8b396 Binary files /dev/null and b/third_party/acados/aarch64/lib/libblasfeo.so differ diff --git a/third_party/acados/aarch64/lib/libhpipm.so b/third_party/acados/aarch64/lib/libhpipm.so new file mode 100755 index 00000000000000..6916c9c7139493 Binary files /dev/null and b/third_party/acados/aarch64/lib/libhpipm.so differ diff --git a/third_party/acados/aarch64/lib/libqpOASES_e.so b/third_party/acados/aarch64/lib/libqpOASES_e.so new file mode 120000 index 00000000000000..14048625a1c2d3 --- /dev/null +++ b/third_party/acados/aarch64/lib/libqpOASES_e.so @@ -0,0 +1 @@ +libqpOASES_e.so.3.1 \ No newline at end of file diff --git a/third_party/acados/aarch64/lib/libqpOASES_e.so.3.1 b/third_party/acados/aarch64/lib/libqpOASES_e.so.3.1 new file mode 100755 index 00000000000000..98d8dbfcd1d34b Binary files /dev/null and b/third_party/acados/aarch64/lib/libqpOASES_e.so.3.1 differ diff --git a/third_party/acados/aarch64/t_renderer b/third_party/acados/aarch64/t_renderer new file mode 100755 index 00000000000000..dc3cdf554f793f Binary files /dev/null and b/third_party/acados/aarch64/t_renderer differ diff --git a/third_party/acados/include/acados/dense_qp/dense_qp_common.h b/third_party/acados/include/acados/dense_qp/dense_qp_common.h new file mode 100644 index 00000000000000..f3809c42948fc7 --- /dev/null +++ b/third_party/acados/include/acados/dense_qp/dense_qp_common.h @@ -0,0 +1,150 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_DENSE_QP_DENSE_QP_COMMON_H_ +#define ACADOS_DENSE_QP_DENSE_QP_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// hpipm +#include "hpipm/include/hpipm_d_dense_qp.h" +#include "hpipm/include/hpipm_d_dense_qp_res.h" +#include "hpipm/include/hpipm_d_dense_qp_sol.h" +// acados +#include "acados/utils/types.h" + +typedef struct d_dense_qp_dim dense_qp_dims; +typedef struct d_dense_qp dense_qp_in; +typedef struct d_dense_qp_sol dense_qp_out; +typedef struct d_dense_qp_res dense_qp_res; +typedef struct d_dense_qp_res_ws dense_qp_res_ws; + + + +#ifndef QP_SOLVER_CONFIG_ +#define QP_SOLVER_CONFIG_ +typedef struct +{ + void (*dims_set)(void *config_, void *dims_, const char *field, const int* value); + acados_size_t (*opts_calculate_size)(void *config, void *dims); + void *(*opts_assign)(void *config, void *dims, void *raw_memory); + void (*opts_initialize_default)(void *config, void *dims, void *args); + void (*opts_update)(void *config, void *dims, void *args); + void (*opts_set)(void *config_, void *opts_, const char *field, void* value); + acados_size_t (*memory_calculate_size)(void *config, void *dims, void *args); + void *(*memory_assign)(void *config, void *dims, void *args, void *raw_memory); + void (*memory_get)(void *config_, void *mem_, const char *field, void* value); + acados_size_t (*workspace_calculate_size)(void *config, void *dims, void *args); + int (*evaluate)(void *config, void *qp_in, void *qp_out, void *args, void *mem, void *work); + void (*eval_sens)(void *config, void *qp_in, void *qp_out, void *opts, void *mem, void *work); +} qp_solver_config; +#endif + + + +#ifndef QP_INFO_ +#define QP_INFO_ +typedef struct +{ + double solve_QP_time; + double condensing_time; + double interface_time; + double total_time; + int num_iter; + int t_computed; +} qp_info; +#endif + + + +/* config */ +// +acados_size_t dense_qp_solver_config_calculate_size(); +// +qp_solver_config *dense_qp_solver_config_assign(void *raw_memory); + +/* dims */ +// +acados_size_t dense_qp_dims_calculate_size(); +// +dense_qp_dims *dense_qp_dims_assign(void *raw_memory); +// +void dense_qp_dims_set(void *config_, void *dims_, const char *field, const int* value); +// + +/* in */ +// +acados_size_t dense_qp_in_calculate_size(dense_qp_dims *dims); +// +dense_qp_in *dense_qp_in_assign(dense_qp_dims *dims, void *raw_memory); + +/* out */ +// +acados_size_t dense_qp_out_calculate_size(dense_qp_dims *dims); +// +dense_qp_out *dense_qp_out_assign(dense_qp_dims *dims, void *raw_memory); +// +void dense_qp_out_get(dense_qp_out *out, const char *field, void *value); + +/* res */ +// +acados_size_t dense_qp_res_calculate_size(dense_qp_dims *dims); +// +dense_qp_res *dense_qp_res_assign(dense_qp_dims *dims, void *raw_memory); +// +acados_size_t dense_qp_res_workspace_calculate_size(dense_qp_dims *dims); +// +dense_qp_res_ws *dense_qp_res_workspace_assign(dense_qp_dims *dims, void *raw_memory); +// +void dense_qp_compute_t(dense_qp_in *qp_in, dense_qp_out *qp_out); +// +void dense_qp_res_compute(dense_qp_in *qp_in, dense_qp_out *qp_out, dense_qp_res *qp_res, dense_qp_res_ws *res_ws); +// +void dense_qp_res_compute_nrm_inf(dense_qp_res *qp_res, double res[4]); + +/* misc */ +// +void dense_qp_stack_slacks_dims(dense_qp_dims *in, dense_qp_dims *out); +// +void dense_qp_stack_slacks(dense_qp_in *in, dense_qp_in *out); +// +void dense_qp_unstack_slacks(dense_qp_out *in, dense_qp_in *qp_out, dense_qp_out *out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_DENSE_QP_DENSE_QP_COMMON_H_ diff --git a/third_party/acados/include/acados/dense_qp/dense_qp_hpipm.h b/third_party/acados/include/acados/dense_qp/dense_qp_hpipm.h new file mode 100644 index 00000000000000..20eedc26a2bf33 --- /dev/null +++ b/third_party/acados/include/acados/dense_qp/dense_qp_hpipm.h @@ -0,0 +1,94 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_DENSE_QP_DENSE_QP_HPIPM_H_ +#define ACADOS_DENSE_QP_DENSE_QP_HPIPM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// hpipm +#include "hpipm/include/hpipm_d_dense_qp.h" +#include "hpipm/include/hpipm_d_dense_qp_ipm.h" +#include "hpipm/include/hpipm_d_dense_qp_sol.h" +// acados +#include "acados/dense_qp/dense_qp_common.h" +#include "acados/utils/types.h" + + + +typedef struct dense_qp_hpipm_opts_ +{ + struct d_dense_qp_ipm_arg *hpipm_opts; +} dense_qp_hpipm_opts; + + + +typedef struct dense_qp_hpipm_memory_ +{ + struct d_dense_qp_ipm_ws *hpipm_workspace; + double time_qp_solver_call; + int iter; + +} dense_qp_hpipm_memory; + + + +// +acados_size_t dense_qp_hpipm_opts_calculate_size(void *config, void *dims); +// +void *dense_qp_hpipm_opts_assign(void *config, void *dims, void *raw_memory); +// +void dense_qp_hpipm_opts_initialize_default(void *config, void *dims, void *opts_); +// +void dense_qp_hpipm_opts_update(void *config, void *dims, void *opts_); +// +acados_size_t dense_qp_hpipm_calculate_memory_size(void *dims, void *opts_); +// +void *dense_qp_hpipm_assign_memory(void *dims, void *opts_, void *raw_memory); +// +acados_size_t dense_qp_hpipm_calculate_workspace_size(void *dims, void *opts_); +// +int dense_qp_hpipm(void *config, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void dense_qp_hpipm_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void dense_qp_hpipm_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_DENSE_QP_DENSE_QP_HPIPM_H_ diff --git a/third_party/acados/include/acados/dense_qp/dense_qp_ooqp.h b/third_party/acados/include/acados/dense_qp/dense_qp_ooqp.h new file mode 100644 index 00000000000000..646f11f06f6664 --- /dev/null +++ b/third_party/acados/include/acados/dense_qp/dense_qp_ooqp.h @@ -0,0 +1,128 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_DENSE_QP_DENSE_QP_OOQP_H_ +#define ACADOS_DENSE_QP_DENSE_QP_OOQP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/dense_qp/dense_qp_common.h" +#include "acados/utils/types.h" + +enum dense_qp_ooqp_termination_code +{ + DENSE_SUCCESSFUL_TERMINATION = 0, + DENSE_NOT_FINISHED, + DENSE_MAX_ITS_EXCEEDED, + DENSE_INFEASIBLE, + DENSE_UNKNOWN +}; + +typedef struct dense_qp_ooqp_opts_ +{ + int printLevel; + int useDiagonalWeights; // TODO(dimitris): implement option + int fixHessian; + int fixDynamics; + int fixInequalities; +} dense_qp_ooqp_opts; + +typedef struct dense_qp_ooqp_workspace_ +{ + double *x; + double *gamma; + double *phi; + double *y; + double *z; + double *lambda; + double *pi; + double objectiveValue; +} dense_qp_ooqp_workspace; + +typedef struct dense_qp_ooqp_memory_ +{ + int firstRun; + int nx; + int my; + int mz; + double *c; + double *dQ; + double *xlow; + char *ixlow; + double *xupp; + char *ixupp; + double *dA; + double *bA; + double *dC; + double *clow; + char *iclow; + double *cupp; + char *icupp; + double time_qp_solver_call; + int iter; + +} dense_qp_ooqp_memory; + +// +acados_size_t dense_qp_ooqp_opts_calculate_size(void *config_, dense_qp_dims *dims); +// +void *dense_qp_ooqp_opts_assign(void *config_, dense_qp_dims *dims, void *raw_memory); +// +void dense_qp_ooqp_opts_initialize_default(void *config_, dense_qp_dims *dims, void *opts_); +// +void dense_qp_ooqp_opts_update(void *config_, dense_qp_dims *dims, void *opts_); +// +acados_size_t dense_qp_ooqp_memory_calculate_size(void *config_, dense_qp_dims *dims, void *opts_); +// +void *dense_qp_ooqp_memory_assign(void *config_, dense_qp_dims *dims, void *opts_, + void *raw_memory); +// +acados_size_t dense_qp_ooqp_workspace_calculate_size(void *config_, dense_qp_dims *dims, void *opts_); +// +int dense_qp_ooqp(void *config_, dense_qp_in *qp_in, dense_qp_out *qp_out, void *opts_, + void *memory_, void *work_); +// +void dense_qp_ooqp_destroy(void *mem_, void *work); +// +void dense_qp_ooqp_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void dense_qp_ooqp_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_DENSE_QP_DENSE_QP_OOQP_H_ diff --git a/third_party/acados/include/acados/dense_qp/dense_qp_qore.h b/third_party/acados/include/acados/dense_qp/dense_qp_qore.h new file mode 100644 index 00000000000000..52606fac5def32 --- /dev/null +++ b/third_party/acados/include/acados/dense_qp/dense_qp_qore.h @@ -0,0 +1,127 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_DENSE_QP_DENSE_QP_QORE_H_ +#define ACADOS_DENSE_QP_DENSE_QP_QORE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// qore +#include "qore/QPSOLVER_DENSE/include/qpsolver_dense.h" +// acados +#include "acados/dense_qp/dense_qp_common.h" +#include "acados/utils/types.h" + +typedef struct dense_qp_qore_opts_ +{ + int nsmax; // maximum size of Schur complement + int print_freq; // print frequency, + // prtfreq < 0: disable printing; + // prtfreq == 0: print on each call and include working set changes; + // prtfreq > 0: print on every prtfreq seconds, but do not include working set + // changes; + int warm_start; // warm start with updated matrices H and C + int warm_strategy; // 0: ramp-up from zero homotopy; 1: setup homotopy from the previous + // solution + int hot_start; // hot start with unchanged matrices H and C + int max_iter; // maximum number of iterations + int compute_t; // compute t in qp_out (to have correct residuals in NLP) +} dense_qp_qore_opts; + +typedef struct dense_qp_qore_memory_ +{ + double *H; + double *HH; + double *g; + double *gg; + double *Zl; + double *Zu; + double *zl; + double *zu; + double *A; + double *b; + double *C; + double *CC; + double *Ct; + double *CCt; + double *d_lb0; + double *d_ub0; + double *d_lb; + double *d_ub; + double *d_lg; + double *d_ug; + double *d_ls; + double *d_us; + double *lb; + double *ub; + int *idxb; + int *idxb_stacked; + int *idxs; + double *prim_sol; + double *dual_sol; + QoreProblemDense *QP; + int num_iter; + dense_qp_in *qp_stacked; + double time_qp_solver_call; + int iter; + +} dense_qp_qore_memory; + +acados_size_t dense_qp_qore_opts_calculate_size(void *config, dense_qp_dims *dims); +// +void *dense_qp_qore_opts_assign(void *config, dense_qp_dims *dims, void *raw_memory); +// +void dense_qp_qore_opts_initialize_default(void *config, dense_qp_dims *dims, void *opts_); +// +void dense_qp_qore_opts_update(void *config, dense_qp_dims *dims, void *opts_); +// +acados_size_t dense_qp_qore_memory_calculate_size(void *config, dense_qp_dims *dims, void *opts_); +// +void *dense_qp_qore_memory_assign(void *config, dense_qp_dims *dims, void *opts_, void *raw_memory); +// +acados_size_t dense_qp_qore_workspace_calculate_size(void *config, dense_qp_dims *dims, void *opts_); +// +int dense_qp_qore(void *config, dense_qp_in *qp_in, dense_qp_out *qp_out, void *opts_, void *memory_, void *work_); +// +void dense_qp_qore_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void dense_qp_qore_config_initialize_default(void *config); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_DENSE_QP_DENSE_QP_QORE_H_ diff --git a/third_party/acados/include/acados/dense_qp/dense_qp_qpoases.h b/third_party/acados/include/acados/dense_qp/dense_qp_qpoases.h new file mode 100644 index 00000000000000..8fca17dd175dd7 --- /dev/null +++ b/third_party/acados/include/acados/dense_qp/dense_qp_qpoases.h @@ -0,0 +1,127 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_DENSE_QP_DENSE_QP_QPOASES_H_ +#define ACADOS_DENSE_QP_DENSE_QP_QPOASES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/dense_qp/dense_qp_common.h" +#include "acados/utils/types.h" + +typedef struct dense_qp_qpoases_opts_ +{ + double max_cputime; // maximum cpu time in seconds + int max_nwsr; // maximum number of working set recalculations + int warm_start; // warm start with dual_sol in memory + int use_precomputed_cholesky; + int hotstart; // this option requires constant data matrices! (eg linear MPC, inexact schemes + // with frozen sensitivities) + int set_acado_opts; // use same options as in acado code generation + int compute_t; // compute t in qp_out (to have correct residuals in NLP) + double tolerance; // terminationTolerance +} dense_qp_qpoases_opts; + +typedef struct dense_qp_qpoases_memory_ +{ + double *H; + double *HH; + double *R; + double *g; + double *gg; + double *Zl; + double *Zu; + double *zl; + double *zu; + double *A; + double *b; + double *d_lb0; + double *d_ub0; + double *d_lb; + double *d_ub; + double *C; + double *CC; + double *d_lg0; + double *d_ug0; + double *d_lg; + double *d_ug; + double *d_ls; + double *d_us; + int *idxb; + int *idxb_stacked; + int *idxs; + double *prim_sol; + double *dual_sol; + void *QPB; // NOTE(giaf): cast to QProblemB to use + void *QP; // NOTE(giaf): cast to QProblem to use + double cputime; // cputime of qpoases + int nwsr; // performed number of working set recalculations + int first_it; // to be used with hotstart + dense_qp_in *qp_stacked; + double time_qp_solver_call; // equal to cputime + int iter; + +} dense_qp_qpoases_memory; + +acados_size_t dense_qp_qpoases_opts_calculate_size(void *config, dense_qp_dims *dims); +// +void *dense_qp_qpoases_opts_assign(void *config, dense_qp_dims *dims, void *raw_memory); +// +void dense_qp_qpoases_opts_initialize_default(void *config, dense_qp_dims *dims, void *opts_); +// +void dense_qp_qpoases_opts_update(void *config, dense_qp_dims *dims, void *opts_); +// +acados_size_t dense_qp_qpoases__memorycalculate_size(void *config, dense_qp_dims *dims, void *opts_); +// +void *dense_qp_qpoases_memory_assign(void *config, dense_qp_dims *dims, void *opts_, void *raw_memory); +// +acados_size_t dense_qp_qpoases_workspace_calculate_size(void *config, dense_qp_dims *dims, void *opts_); +// +int dense_qp_qpoases(void *config, dense_qp_in *qp_in, dense_qp_out *qp_out, void *opts_, void *memory_, void *work_); +// +void dense_qp_qpoases_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void dense_qp_qpoases_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_DENSE_QP_DENSE_QP_QPOASES_H_ diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_common.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_common.h new file mode 100644 index 00000000000000..64939b9ed1e61c --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_common.h @@ -0,0 +1,434 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + + +/// \defgroup ocp_nlp ocp_nlp +/// @{ +/// @} + +/// \defgroup ocp_nlp_solver ocp_nlp_solver +/// @{ +/// @} + +/// \ingroup ocp_nlp +/// @{ + +/// \ingroup ocp_nlp_solver +/// @{ + +/// \defgroup ocp_nlp_common ocp_nlp_common +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_COMMON_H_ +#define ACADOS_OCP_NLP_OCP_NLP_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/ocp_nlp/ocp_nlp_constraints_common.h" +#include "acados/ocp_nlp/ocp_nlp_cost_common.h" +#include "acados/ocp_nlp/ocp_nlp_dynamics_common.h" +#include "acados/ocp_nlp/ocp_nlp_reg_common.h" +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/ocp_qp/ocp_qp_xcond_solver.h" +#include "acados/sim/sim_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + + +/************************************************ + * config + ************************************************/ + +typedef struct ocp_nlp_config +{ + int N; // number of stages + + // solver-specific implementations of memory management functions + acados_size_t (*opts_calculate_size)(void *config, void *dims); + void *(*opts_assign)(void *config, void *dims, void *raw_memory); + void (*opts_initialize_default)(void *config, void *dims, void *opts_); + void (*opts_update)(void *config, void *dims, void *opts_); + acados_size_t (*memory_calculate_size)(void *config, void *dims, void *opts_); + void *(*memory_assign)(void *config, void *dims, void *opts_, void *raw_memory); + acados_size_t (*workspace_calculate_size)(void *config, void *dims, void *opts_); + void (*opts_set)(void *config_, void *opts_, const char *field, void* value); + void (*opts_set_at_stage)(void *config_, void *opts_, size_t stage, const char *field, void* value); + // evaluate solver // TODO rename into solve + int (*evaluate)(void *config, void *dims, void *nlp_in, void *nlp_out, void *opts_, void *mem, void *work); + void (*eval_param_sens)(void *config, void *dims, void *opts_, void *mem, void *work, + char *field, int stage, int index, void *sens_nlp_out); + // prepare memory + int (*precompute)(void *config, void *dims, void *nlp_in, void *nlp_out, void *opts_, void *mem, void *work); + // initalize this struct with default values + void (*config_initialize_default)(void *config); + // general getter + void (*get)(void *config_, void *dims, void *mem_, const char *field, void *return_value_); + void (*opts_get)(void *config_, void *dims, void *opts_, const char *field, void *return_value_); + void (*work_get)(void *config_, void *dims, void *work_, const char *field, void *return_value_); + // config structs of submodules + ocp_qp_xcond_solver_config *qp_solver; // TODO rename xcond_solver + ocp_nlp_dynamics_config **dynamics; + ocp_nlp_cost_config **cost; + ocp_nlp_constraints_config **constraints; + ocp_nlp_reg_config *regularize; + +} ocp_nlp_config; + +// +acados_size_t ocp_nlp_config_calculate_size(int N); +// +ocp_nlp_config *ocp_nlp_config_assign(int N, void *raw_memory); + + + +/************************************************ + * dims + ************************************************/ + +/// Structure to store dimensions/number of variables. +typedef struct ocp_nlp_dims +{ + void **cost; + void **dynamics; + void **constraints; + ocp_qp_xcond_solver_dims *qp_solver; // xcond solver instead ?? + ocp_nlp_reg_dims *regularize; + + int *nv; // number of primal variables (states+controls+slacks) + int *nx; // number of differential states + int *nu; // number of inputs + int *ni; // number of two-sided inequality constraints: nb+ng+nh+ns + int *nz; // number of algebraic variables + int *ns; // number of slack variables + int N; // number of shooting nodes + + void *raw_memory; // Pointer to allocated memory, to be used for freeing +} ocp_nlp_dims; + +// +acados_size_t ocp_nlp_dims_calculate_size(void *config); +// +ocp_nlp_dims *ocp_nlp_dims_assign(void *config, void *raw_memory); + +/// Sets the dimension of optimization variables +/// (states, constrols, algebraic variables, slack variables). +/// +/// \param config_ The configuration struct. +/// \param dims_ The dimension struct. +/// \param field The type of optimization variables, either nx, nu, nz, or ns. +/// \param value_array Number of variables for each stage. +void ocp_nlp_dims_set_opt_vars(void *config_, void *dims_, + const char *field, const void* value_array); + +/// Sets the dimensions of constraints functions for a stage +/// (bounds on states, bounds on controls, equality constraints, +/// inequality constraints). +/// +/// \param config_ The configuration struct. +/// \param dims_ The dimension struct. +/// \param stage Stage number. +/// \param field The type of constraint/bound, either nbx, nbu, ng, or nh. +/// \param value_field Number of constraints/bounds for the given stage. +void ocp_nlp_dims_set_constraints(void *config_, void *dims_, int stage, + const char *field, const void* value_field); + +/// Sets the dimensions of the cost terms for a stage. +/// +/// \param config_ The configuration struct. +/// \param dims_ The dimension struct. +/// \param stage Stage number. +/// \param field Type of cost term, can be eiter ny. +/// \param value_field Number of cost terms/residuals for the given stage. +void ocp_nlp_dims_set_cost(void *config_, void *dims_, int stage, const char *field, + const void* value_field); + +/// Sets the dimensions of the dynamics for a stage. +/// +/// \param config_ The configuration struct. +/// \param dims_ The dimension struct. +/// \param stage Stage number. +/// \param field TBD +/// \param value TBD +void ocp_nlp_dims_set_dynamics(void *config_, void *dims_, int stage, const char *field, + const void* value); + +/************************************************ + * Inputs + ************************************************/ + +/// Struct for storing the inputs of an OCP NLP solver +typedef struct ocp_nlp_in +{ + /// Length of sampling intervals/timesteps. + double *Ts; + + /// Pointers to cost functions (TBC). + void **cost; + + /// Pointers to dynamics functions (TBC). + void **dynamics; + + /// Pointers to constraints functions (TBC). + void **constraints; + + /// Pointer to allocated memory, to be used for freeing. + void *raw_memory; + +} ocp_nlp_in; + +// +acados_size_t ocp_nlp_in_calculate_size_self(int N); +// +acados_size_t ocp_nlp_in_calculate_size(ocp_nlp_config *config, ocp_nlp_dims *dims); +// +ocp_nlp_in *ocp_nlp_in_assign_self(int N, void *raw_memory); +// +ocp_nlp_in *ocp_nlp_in_assign(ocp_nlp_config *config, ocp_nlp_dims *dims, void *raw_memory); + + +/************************************************ + * out + ************************************************/ + +typedef struct ocp_nlp_out +{ + struct blasfeo_dvec *ux; // NOTE: this contains [u; x; s_l; s_u]! - rename to uxs? + struct blasfeo_dvec *z; // algebraic vairables + struct blasfeo_dvec *pi; // multipliers for dynamics + struct blasfeo_dvec *lam; // inequality mulitpliers + struct blasfeo_dvec *t; // slack variables corresponding to evaluation of all inequalities (at the solution) + + // NOTE: the inequalities are internally organized in the following order: + // [ lbu lbx lg lh lphi ubu ubx ug uh uphi; lsbu lsbx lsg lsh lsphi usbu usbx usg ush usphi] + + int sqp_iter; + int qp_iter; + double inf_norm_res; + double total_time; + + void *raw_memory; // Pointer to allocated memory, to be used for freeing + +} ocp_nlp_out; + +// +acados_size_t ocp_nlp_out_calculate_size(ocp_nlp_config *config, ocp_nlp_dims *dims); +// +ocp_nlp_out *ocp_nlp_out_assign(ocp_nlp_config *config, ocp_nlp_dims *dims, + void *raw_memory); + + + +/************************************************ + * options + ************************************************/ + +/// Globalization types +typedef enum +{ + FIXED_STEP, + MERIT_BACKTRACKING, +} ocp_nlp_globalization_t; + +typedef struct ocp_nlp_opts +{ + ocp_qp_xcond_solver_opts *qp_solver_opts; // xcond solver opts instead ??? + void *regularize; + void **dynamics; // dynamics_opts + void **cost; // cost_opts + void **constraints; // constraints_opts + double step_length; // step length in case of FIXED_STEP + double levenberg_marquardt; // LM factor to be added to the hessian before regularization + int reuse_workspace; + int num_threads; + + // TODO: move to separate struct? + ocp_nlp_globalization_t globalization; + double alpha_min; + double alpha_reduction; +} ocp_nlp_opts; + +// +acados_size_t ocp_nlp_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_opts_set(void *config_, void *opts_, const char *field, void* value); +// +void ocp_nlp_opts_set_at_stage(void *config, void *opts, int stage, const char *field, void *value); + + +/************************************************ + * residuals + ************************************************/ + +typedef struct ocp_nlp_res +{ + struct blasfeo_dvec *res_stat; // stationarity + struct blasfeo_dvec *res_eq; // dynamics + struct blasfeo_dvec *res_ineq; // inequality constraints + struct blasfeo_dvec *res_comp; // complementarity + double inf_norm_res_stat; + double inf_norm_res_eq; + double inf_norm_res_ineq; + double inf_norm_res_comp; + acados_size_t memsize; +} ocp_nlp_res; + +// +acados_size_t ocp_nlp_res_calculate_size(ocp_nlp_dims *dims); +// +ocp_nlp_res *ocp_nlp_res_assign(ocp_nlp_dims *dims, void *raw_memory); + +/************************************************ + * memory + ************************************************/ + +typedef struct ocp_nlp_memory +{ +// void *qp_solver_mem; // xcond solver mem instead ??? + ocp_qp_xcond_solver_memory *qp_solver_mem; // xcond solver mem instead ??? + void *regularize_mem; + void **dynamics; // dynamics memory + void **cost; // cost memory + void **constraints; // constraints memory + + // residuals + ocp_nlp_res *nlp_res; + + // qp in & out + ocp_qp_in *qp_in; + ocp_qp_out *qp_out; + // QP stuff not entering the qp_in struct + struct blasfeo_dmat *dzduxt; // dzdux transposed + struct blasfeo_dvec *z_alg; // z_alg, output algebraic variables + + struct blasfeo_dvec *cost_grad; + struct blasfeo_dvec *ineq_fun; + struct blasfeo_dvec *ineq_adj; + struct blasfeo_dvec *dyn_fun; + struct blasfeo_dvec *dyn_adj; + + double cost_value; + + bool *set_sim_guess; // indicate if there is new explicitly provided guess for integration variables + struct blasfeo_dvec *sim_guess; + + int *sqp_iter; // pointer to iteration number + +} ocp_nlp_memory; + +// +acados_size_t ocp_nlp_memory_calculate_size(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_opts *opts); +// +ocp_nlp_memory *ocp_nlp_memory_assign(ocp_nlp_config *config, ocp_nlp_dims *dims, + ocp_nlp_opts *opts, void *raw_memory); + + + +/************************************************ + * workspace + ************************************************/ + +typedef struct ocp_nlp_workspace +{ + + void *qp_work; + void **dynamics; // dynamics_workspace + void **cost; // cost_workspace + void **constraints; // constraints_workspace + + ocp_nlp_out *tmp_nlp_out; + ocp_nlp_out *weight_merit_fun; + +} ocp_nlp_workspace; + +// +acados_size_t ocp_nlp_workspace_calculate_size(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_opts *opts); +// +ocp_nlp_workspace *ocp_nlp_workspace_assign(ocp_nlp_config *config, ocp_nlp_dims *dims, + ocp_nlp_opts *opts, ocp_nlp_memory *mem, void *raw_memory); + + + +/************************************************ + * function + ************************************************/ + +// +void ocp_nlp_initialize_qp(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); +// +void ocp_nlp_approximate_qp_matrices(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); +// +void ocp_nlp_approximate_qp_vectors_sqp(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); +// +void ocp_nlp_embed_initial_value(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); +// +void ocp_nlp_update_variables_sqp(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work, double alpha); +// +double ocp_nlp_line_search(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); +// +double ocp_nlp_evaluate_merit_fun(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); +// +void ocp_nlp_initialize_t_slacks(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); +// +void ocp_nlp_res_compute(ocp_nlp_dims *dims, ocp_nlp_in *in, ocp_nlp_out *out, + ocp_nlp_res *res, ocp_nlp_memory *mem); +// +void ocp_nlp_cost_compute(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + ocp_nlp_out *out, ocp_nlp_opts *opts, ocp_nlp_memory *mem, ocp_nlp_workspace *work); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_COMMON_H_ +/// @} +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_bgh.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_bgh.h new file mode 100644 index 00000000000000..7f7a30faf3a6d3 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_bgh.h @@ -0,0 +1,241 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_constraints +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_BGH_H_ +#define ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_BGH_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/ocp_nlp/ocp_nlp_constraints_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + + +/************************************************ + * dims + ************************************************/ + +typedef struct +{ + int nx; + int nu; + int nz; + int nb; // nbx + nbu + int nbu; // number of input box constraints + int nbx; // number of state box constraints + int ng; // number of general linear constraints + int nh; // number of nonlinear path constraints + int ns; // nsbu + nsbx + nsg + nsh + int nsbu; // number of softened input bounds + int nsbx; // number of softened state bounds + int nsg; // number of softened general linear constraints + int nsh; // number of softened nonlinear constraints + int nbue; // number of input box constraints which are equality + int nbxe; // number of state box constraints which are equality + int nge; // number of general linear constraints which are equality + int nhe; // number of nonlinear path constraints which are equality +} ocp_nlp_constraints_bgh_dims; + +// +acados_size_t ocp_nlp_constraints_bgh_dims_calculate_size(void *config); +// +void *ocp_nlp_constraints_bgh_dims_assign(void *config, void *raw_memory); +// +void ocp_nlp_constraints_bgh_dims_initialize(void *config, void *dims, int nx, int nu, int nz, int nbx, + int nbu, int ng, int nh, int dummy0, int ns); +// +void ocp_nlp_constraints_bgh_dims_get(void *config_, void *dims_, const char *field, int* value); +// +void ocp_nlp_constraints_bgh_dims_set(void *config_, void *dims_, + const char *field, const int* value); + + +/************************************************ + * model + ************************************************/ + +typedef struct +{ + int *idxb; + int *idxs; + int *idxe; + struct blasfeo_dvec d; // gathers bounds + struct blasfeo_dmat DCt; // general linear constraint matrix + // lg <= [D, C] * [u; x] <= ug + external_function_generic *nl_constr_h_fun; // nonlinear: lh <= h(x,u) <= uh + external_function_generic *nl_constr_h_fun_jac; // nonlinear: lh <= h(x,u) <= uh + external_function_generic *nl_constr_h_fun_jac_hess; // nonlinear: lh <= h(x,u) <= uh +} ocp_nlp_constraints_bgh_model; + +// +acados_size_t ocp_nlp_constraints_bgh_model_calculate_size(void *config, void *dims); +// +void *ocp_nlp_constraints_bgh_model_assign(void *config, void *dims, void *raw_memory); +// +int ocp_nlp_constraints_bgh_model_set(void *config_, void *dims_, + void *model_, const char *field, void *value); + + + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + int compute_adj; + int compute_hess; +} ocp_nlp_constraints_bgh_opts; + +// +acados_size_t ocp_nlp_constraints_bgh_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_constraints_bgh_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_constraints_bgh_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_constraints_bgh_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_constraints_bgh_opts_set(void *config, void *opts, char *field, void *value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + struct blasfeo_dvec fun; + struct blasfeo_dvec adj; + struct blasfeo_dvec *ux; // pointer to ux in nlp_out + struct blasfeo_dvec *tmp_ux; // pointer to ux in tmp_nlp_out + struct blasfeo_dvec *lam; // pointer to lam in nlp_out + struct blasfeo_dvec *tmp_lam;// pointer to lam in tmp_nlp_out + struct blasfeo_dvec *z_alg; // pointer to z_alg in ocp_nlp memory + struct blasfeo_dmat *DCt; // pointer to DCt in qp_in + struct blasfeo_dmat *RSQrq; // pointer to RSQrq in qp_in + struct blasfeo_dmat *dzduxt; // pointer to dzduxt in ocp_nlp memory + int *idxb; // pointer to idxb[ii] in qp_in + int *idxs_rev; // pointer to idxs_rev[ii] in qp_in + int *idxe; // pointer to idxe[ii] in qp_in +} ocp_nlp_constraints_bgh_memory; + +// +acados_size_t ocp_nlp_constraints_bgh_memory_calculate_size(void *config, void *dims, void *opts); +// +void *ocp_nlp_constraints_bgh_memory_assign(void *config, void *dims, void *opts, void *raw_memory); +// +struct blasfeo_dvec *ocp_nlp_constraints_bgh_memory_get_fun_ptr(void *memory_); +// +struct blasfeo_dvec *ocp_nlp_constraints_bgh_memory_get_adj_ptr(void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_ux_ptr(struct blasfeo_dvec *ux, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_tmp_ux_ptr(struct blasfeo_dvec *tmp_ux, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_lam_ptr(struct blasfeo_dvec *lam, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_tmp_lam_ptr(struct blasfeo_dvec *tmp_lam, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_DCt_ptr(struct blasfeo_dmat *DCt, void *memory); +// +void ocp_nlp_constraints_bgh_memory_set_RSQrq_ptr(struct blasfeo_dmat *RSQrq, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_z_alg_ptr(struct blasfeo_dvec *z_alg, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_dzduxt_ptr(struct blasfeo_dmat *dzduxt, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_idxb_ptr(int *idxb, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_idxs_rev_ptr(int *idxs_rev, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_idxe_ptr(int *idxe, void *memory_); + + + +/************************************************ + * workspace + ************************************************/ + +typedef struct +{ + struct blasfeo_dmat tmp_nv_nv; + struct blasfeo_dmat tmp_nz_nh; + struct blasfeo_dmat tmp_nv_nh; + struct blasfeo_dmat tmp_nz_nv; + struct blasfeo_dmat hess_z; + struct blasfeo_dvec tmp_ni; + struct blasfeo_dvec tmp_nh; +} ocp_nlp_constraints_bgh_workspace; + +// +acados_size_t ocp_nlp_constraints_bgh_workspace_calculate_size(void *config, void *dims, void *opts); + +/* functions */ + +// +void ocp_nlp_constraints_bgh_config_initialize_default(void *config); +// +void ocp_nlp_constraints_bgh_initialize(void *config, void *dims, void *model, void *opts, + void *mem, void *work); +// +void ocp_nlp_constraints_bgh_update_qp_matrices(void *config_, void *dims, void *model_, + void *opts_, void *memory_, void *work_); + +// +void ocp_nlp_constraints_bgh_compute_fun(void *config_, void *dims, void *model_, + void *opts_, void *memory_, void *work_); +// +void ocp_nlp_constraints_bgh_bounds_update(void *config_, void *dims, void *model_, + void *opts_, void *memory_, void *work_); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_BGH_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_bgp.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_bgp.h new file mode 100644 index 00000000000000..beeec784116b82 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_bgp.h @@ -0,0 +1,221 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_constraints +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_BGP_H_ +#define ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_BGP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/ocp_nlp/ocp_nlp_constraints_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + + +/* dims */ + +typedef struct +{ + int nx; + int nu; + int nz; + int nb; // nbx + nbu + int nbu; + int nbx; + int ng; // number of general linear constraints + int nphi; // dimension of convex outer part + int ns; // nsbu + nsbx + nsg + nsphi + int nsbu; // number of softened input bounds + int nsbx; // number of softened state bounds + int nsg; // number of softened general linear constraints + int nsphi; // number of softened nonlinear constraints + int nr; // dimension of nonlinear function in convex_over_nonlinear constraint + int nbue; // number of input box constraints which are equality + int nbxe; // number of state box constraints which are equality + int nge; // number of general linear constraints which are equality + int nphie; // number of nonlinear path constraints which are equality +} ocp_nlp_constraints_bgp_dims; + +// +acados_size_t ocp_nlp_constraints_bgp_dims_calculate_size(void *config); +// +void *ocp_nlp_constraints_bgp_dims_assign(void *config, void *raw_memory); +// +void ocp_nlp_constraints_bgp_dims_initialize(void *config, void *dims, int nx, int nu, int nz, + int nbx, int nbu, int ng, int nphi, int nq, int ns); +// +void ocp_nlp_constraints_bgp_dims_get(void *config_, void *dims_, const char *field, int* value); + + +/* model */ + +typedef struct +{ + // ocp_nlp_constraints_bgp_dims *dims; + int *idxb; + int *idxs; + int *idxe; + struct blasfeo_dvec d; + struct blasfeo_dmat DCt; + external_function_generic *nl_constr_phi_o_r_fun_phi_jac_ux_z_phi_hess_r_jac_ux; + external_function_generic *nl_constr_phi_o_r_fun; + external_function_generic *nl_constr_r_fun_jac; +} ocp_nlp_constraints_bgp_model; + +// +acados_size_t ocp_nlp_constraints_bgp_calculate_size(void *config, void *dims); +// +void *ocp_nlp_constraints_bgp_assign(void *config, void *dims, void *raw_memory); +// +int ocp_nlp_constraints_bgp_model_set(void *config_, void *dims_, + void *model_, const char *field, void *value); + +/* options */ + +typedef struct +{ + int compute_adj; + int compute_hess; +} ocp_nlp_constraints_bgp_opts; + +// +acados_size_t ocp_nlp_constraints_bgp_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_constraints_bgp_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_constraints_bgp_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_constraints_bgp_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_constraints_bgp_opts_set(void *config, void *opts, char *field, void *value); + +/* memory */ + +typedef struct +{ + struct blasfeo_dvec fun; + struct blasfeo_dvec adj; + struct blasfeo_dvec *ux; // pointer to ux in nlp_out + struct blasfeo_dvec *tmp_ux; // pointer to ux in tmp_nlp_out + struct blasfeo_dvec *lam; // pointer to lam in nlp_out + struct blasfeo_dvec *tmp_lam;// pointer to lam in tmp_nlp_out + struct blasfeo_dvec *z_alg; // pointer to z_alg in ocp_nlp memory + struct blasfeo_dmat *DCt; // pointer to DCt in qp_in + struct blasfeo_dmat *RSQrq; // pointer to RSQrq in qp_in + struct blasfeo_dmat *dzduxt; // pointer to dzduxt in ocp_nlp memory + int *idxb; // pointer to idxb[ii] in qp_in + int *idxs_rev; // pointer to idxs_rev[ii] in qp_in + int *idxe; // pointer to idxe[ii] in qp_in +} ocp_nlp_constraints_bgp_memory; + +// +acados_size_t ocp_nlp_constraints_bgp_memory_calculate_size(void *config, void *dims, void *opts); +// +void *ocp_nlp_constraints_bgp_memory_assign(void *config, void *dims, void *opts, + void *raw_memory); +// +struct blasfeo_dvec *ocp_nlp_constraints_bgp_memory_get_fun_ptr(void *memory_); +// +struct blasfeo_dvec *ocp_nlp_constraints_bgp_memory_get_adj_ptr(void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_ux_ptr(struct blasfeo_dvec *ux, void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_tmp_ux_ptr(struct blasfeo_dvec *tmp_ux, void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_lam_ptr(struct blasfeo_dvec *lam, void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_tmp_lam_ptr(struct blasfeo_dvec *tmp_lam, void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_DCt_ptr(struct blasfeo_dmat *DCt, void *memory); +// +void ocp_nlp_constraints_bgp_memory_set_z_alg_ptr(struct blasfeo_dvec *z_alg, void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_dzduxt_ptr(struct blasfeo_dmat *dzduxt, void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_idxb_ptr(int *idxb, void *memory_); +// +void ocp_nlp_constraints_bgp_memory_set_idxs_rev_ptr(int *idxs_rev, void *memory_); +// +void ocp_nlp_constraints_bgh_memory_set_idxe_ptr(int *idxe, void *memory_); + +/* workspace */ + +typedef struct +{ + struct blasfeo_dvec tmp_ni; + struct blasfeo_dmat jac_r_ux_tran; + struct blasfeo_dmat tmp_nr_nphi_nr; + struct blasfeo_dmat tmp_nv_nr; + struct blasfeo_dmat tmp_nv_nphi; + struct blasfeo_dmat tmp_nz_nphi; +} ocp_nlp_constraints_bgp_workspace; + +// +acados_size_t ocp_nlp_constraints_bgp_workspace_calculate_size(void *config, void *dims, void *opts); + +/* functions */ + +// +void ocp_nlp_constraints_bgp_config_initialize_default(void *config); +// +void ocp_nlp_constraints_bgp_initialize(void *config, void *dims, void *model, + void *opts, void *mem, void *work); +// +void ocp_nlp_constraints_bgp_update_qp_matrices(void *config_, void *dims, + void *model_, void *opts_, void *memory_, void *work_); +// +void ocp_nlp_constraints_bgp_compute_fun(void *config_, void *dims, + void *model_, void *opts_, void *memory_, void *work_); +// +void ocp_nlp_constraints_bgp_bounds_update(void *config_, void *dims, void *model_, + void *opts_, void *memory_, void *work_); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_BGP_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_common.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_common.h new file mode 100644 index 00000000000000..7cadecab46b6c7 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_constraints_common.h @@ -0,0 +1,112 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \ingroup ocp_nlp +/// @{ + +/// \defgroup ocp_nlp_constraints ocp_nlp_constraints +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_COMMON_H_ +#define ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + + +/************************************************ + * config + ************************************************/ + +typedef struct +{ + acados_size_t (*dims_calculate_size)(void *config); + void *(*dims_assign)(void *config, void *raw_memory); + void (*dims_initialize)(void *config, void *dims, int nx, int nu, int nz, int nbx, int nbu, int ng, + int nh, int nq, int ns); + acados_size_t (*model_calculate_size)(void *config, void *dims); + void *(*model_assign)(void *config, void *dims, void *raw_memory); + int (*model_set)(void *config_, void *dims_, void *model_, const char *field, void *value); + acados_size_t (*opts_calculate_size)(void *config, void *dims); + void *(*opts_assign)(void *config, void *dims, void *raw_memory); + void (*opts_initialize_default)(void *config, void *dims, void *opts); + void (*opts_update)(void *config, void *dims, void *opts); + void (*opts_set)(void *config, void *opts, char *field, void *value); + acados_size_t (*memory_calculate_size)(void *config, void *dims, void *opts); + struct blasfeo_dvec *(*memory_get_fun_ptr)(void *memory); + struct blasfeo_dvec *(*memory_get_adj_ptr)(void *memory); + void (*memory_set_ux_ptr)(struct blasfeo_dvec *ux, void *memory); + void (*memory_set_tmp_ux_ptr)(struct blasfeo_dvec *tmp_ux, void *memory); + void (*memory_set_lam_ptr)(struct blasfeo_dvec *lam, void *memory); + void (*memory_set_tmp_lam_ptr)(struct blasfeo_dvec *tmp_lam, void *memory); + void (*memory_set_DCt_ptr)(struct blasfeo_dmat *DCt, void *memory); + void (*memory_set_RSQrq_ptr)(struct blasfeo_dmat *RSQrq, void *memory); + void (*memory_set_z_alg_ptr)(struct blasfeo_dvec *z_alg, void *memory); + void (*memory_set_dzdux_tran_ptr)(struct blasfeo_dmat *dzduxt, void *memory); + void (*memory_set_idxb_ptr)(int *idxb, void *memory); + void (*memory_set_idxs_rev_ptr)(int *idxs_rev, void *memory); + void (*memory_set_idxe_ptr)(int *idxe, void *memory); + void *(*memory_assign)(void *config, void *dims, void *opts, void *raw_memory); + acados_size_t (*workspace_calculate_size)(void *config, void *dims, void *opts); + void (*initialize)(void *config, void *dims, void *model, void *opts, void *mem, void *work); + void (*update_qp_matrices)(void *config, void *dims, void *model, void *opts, void *mem, void *work); + void (*compute_fun)(void *config, void *dims, void *model, void *opts, void *mem, void *work); + void (*bounds_update)(void *config, void *dims, void *model, void *opts, void *mem, void *work); + void (*config_initialize_default)(void *config); + // dimension setters + void (*dims_set)(void *config_, void *dims_, const char *field, const int *value); + void (*dims_get)(void *config_, void *dims_, const char *field, int* value); +} ocp_nlp_constraints_config; + +// +acados_size_t ocp_nlp_constraints_config_calculate_size(); +// +ocp_nlp_constraints_config *ocp_nlp_constraints_config_assign(void *raw_memory); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_CONSTRAINTS_COMMON_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_common.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_common.h new file mode 100644 index 00000000000000..c9fbbfb4046033 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_common.h @@ -0,0 +1,109 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// +/// \defgroup ocp_nlp_cost ocp_nlp_cost +/// + +/// \addtogroup ocp_nlp_cost ocp_nlp_cost +/// @{ +/// \addtogroup ocp_nlp_cost_common ocp_nlp_cost_common +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_COST_COMMON_H_ +#define ACADOS_OCP_NLP_OCP_NLP_COST_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + + +/************************************************ + * config + ************************************************/ + +typedef struct +{ + acados_size_t (*dims_calculate_size)(void *config); + void *(*dims_assign)(void *config, void *raw_memory); + void (*dims_initialize)(void *config, void *dims, int nx, int nu, int ny, int ns, int nz); + void (*dims_set)(void *config_, void *dims_, const char *field, int *value); + void (*dims_get)(void *config_, void *dims_, const char *field, int *value); + acados_size_t (*model_calculate_size)(void *config, void *dims); + void *(*model_assign)(void *config, void *dims, void *raw_memory); + int (*model_set)(void *config_, void *dims_, void *model_, const char *field, void *value_); + acados_size_t (*opts_calculate_size)(void *config, void *dims); + void *(*opts_assign)(void *config, void *dims, void *raw_memory); + void (*opts_initialize_default)(void *config, void *dims, void *opts); + void (*opts_update)(void *config, void *dims, void *opts); + void (*opts_set)(void *config, void *opts, const char *field, void *value); + acados_size_t (*memory_calculate_size)(void *config, void *dims, void *opts); + double *(*memory_get_fun_ptr)(void *memory); + struct blasfeo_dvec *(*memory_get_grad_ptr)(void *memory); + void (*memory_set_ux_ptr)(struct blasfeo_dvec *ux, void *memory); + void (*memory_set_tmp_ux_ptr)(struct blasfeo_dvec *tmp_ux, void *memory); + void (*memory_set_z_alg_ptr)(struct blasfeo_dvec *z_alg, void *memory); + void (*memory_set_dzdux_tran_ptr)(struct blasfeo_dmat *dzdux, void *memory); + void (*memory_set_RSQrq_ptr)(struct blasfeo_dmat *RSQrq, void *memory); + void (*memory_set_Z_ptr)(struct blasfeo_dvec *Z, void *memory); + void *(*memory_assign)(void *config, void *dims, void *opts, void *raw_memory); + acados_size_t (*workspace_calculate_size)(void *config, void *dims, void *opts); + void (*initialize)(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); + + // computes the function value, gradient and hessian (approximation) of the cost function + void (*update_qp_matrices)(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); + // computes the cost function value (intended for globalization) + void (*compute_fun)(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); + void (*config_initialize_default)(void *config); +} ocp_nlp_cost_config; + +// +acados_size_t ocp_nlp_cost_config_calculate_size(); +// +ocp_nlp_cost_config *ocp_nlp_cost_config_assign(void *raw_memory); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_COST_COMMON_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_external.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_external.h new file mode 100644 index 00000000000000..f2196dbee79820 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_external.h @@ -0,0 +1,187 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_NLP_OCP_NLP_COST_EXTERNAL_H_ +#define ACADOS_OCP_NLP_OCP_NLP_COST_EXTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_cost_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + +/************************************************ + * dims + ************************************************/ + +typedef struct +{ + int nx; // number of states + int nu; // number of inputs + int ns; // number of slacks +} ocp_nlp_cost_external_dims; + +// +acados_size_t ocp_nlp_cost_external_dims_calculate_size(void *config); +// +void *ocp_nlp_cost_external_dims_assign(void *config, void *raw_memory); +// +void ocp_nlp_cost_external_dims_initialize(void *config, void *dims, int nx, + int nu, int ny, int ns, int nz); +// +void ocp_nlp_cost_external_dims_set(void *config_, void *dims_, const char *field, int* value); +// +void ocp_nlp_cost_external_dims_get(void *config_, void *dims_, const char *field, int* value); + +/************************************************ + * model + ************************************************/ + +typedef struct +{ + external_function_generic *ext_cost_fun; // function + external_function_generic *ext_cost_fun_jac_hess; // function, gradient and hessian + external_function_generic *ext_cost_fun_jac; // function, gradient + struct blasfeo_dvec Z; + struct blasfeo_dvec z; + struct blasfeo_dmat numerical_hessian; // custom hessian approximation + double scaling; +} ocp_nlp_cost_external_model; + +// +acados_size_t ocp_nlp_cost_external_model_calculate_size(void *config, void *dims); +// +void *ocp_nlp_cost_external_model_assign(void *config, void *dims, void *raw_memory); + + + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + int use_numerical_hessian; // > 0 indicating custom hessian is used instead of CasADi evaluation +} ocp_nlp_cost_external_opts; + +// +acados_size_t ocp_nlp_cost_external_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_cost_external_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_cost_external_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_cost_external_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_cost_external_opts_set(void *config, void *opts, const char *field, void *value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + struct blasfeo_dvec grad; // gradient of cost function + struct blasfeo_dvec *ux; // pointer to ux in nlp_out + struct blasfeo_dvec *tmp_ux; // pointer to tmp_ux in nlp_out + struct blasfeo_dmat *RSQrq; // pointer to RSQrq in qp_in + struct blasfeo_dvec *Z; // pointer to Z in qp_in + struct blasfeo_dvec *z_alg; ///< pointer to z in sim_out + struct blasfeo_dmat *dzdux_tran; ///< pointer to sensitivity of a wrt ux in sim_out + double fun; ///< value of the cost function +} ocp_nlp_cost_external_memory; + +// +acados_size_t ocp_nlp_cost_external_memory_calculate_size(void *config, void *dims, void *opts); +// +void *ocp_nlp_cost_external_memory_assign(void *config, void *dims, void *opts, void *raw_memory); +// +double *ocp_nlp_cost_external_memory_get_fun_ptr(void *memory_); +// +struct blasfeo_dvec *ocp_nlp_cost_external_memory_get_grad_ptr(void *memory_); +// +void ocp_nlp_cost_external_memory_set_RSQrq_ptr(struct blasfeo_dmat *RSQrq, void *memory); +// +void ocp_nlp_cost_ls_memory_set_Z_ptr(struct blasfeo_dvec *Z, void *memory); +// +void ocp_nlp_cost_external_memory_set_ux_ptr(struct blasfeo_dvec *ux, void *memory_); +// +void ocp_nlp_cost_external_memory_set_tmp_ux_ptr(struct blasfeo_dvec *tmp_ux, void *memory_); +// +void ocp_nlp_cost_external_memory_set_z_alg_ptr(struct blasfeo_dvec *z_alg, void *memory_); +// +void ocp_nlp_cost_external_memory_set_dzdux_tran_ptr(struct blasfeo_dmat *dzdux_tran, void *memory_); + +/************************************************ + * workspace + ************************************************/ + +typedef struct +{ + struct blasfeo_dmat tmp_nv_nv; + struct blasfeo_dvec tmp_2ns; // temporary vector of dimension 2*ns +} ocp_nlp_cost_external_workspace; + +// +acados_size_t ocp_nlp_cost_external_workspace_calculate_size(void *config, void *dims, void *opts); + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_cost_external_config_initialize_default(void *config); +// +void ocp_nlp_cost_external_initialize(void *config_, void *dims, void *model_, + void *opts_, void *mem_, void *work_); +// +void ocp_nlp_cost_external_update_qp_matrices(void *config_, void *dims, void *model_, + void *opts_, void *memory_, void *work_); +// +void ocp_nlp_cost_external_compute_fun(void *config_, void *dims, void *model_, + void *opts_, void *memory_, void *work_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_COST_EXTERNAL_H_ diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_ls.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_ls.h new file mode 100644 index 00000000000000..3cf759504aba05 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_ls.h @@ -0,0 +1,259 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_cost ocp_nlp_cost +/// @{ +/// \addtogroup ocp_nlp_cost_ls ocp_nlp_cost_ls +/// \brief This module implements linear-least squares costs of the form +/// \f$\min_{x,u,z} \| V_x x + V_u u + V_z z - y_{\text{ref}}\|_W^2\f$. +/// @{ + + + +#ifndef ACADOS_OCP_NLP_OCP_NLP_COST_LS_H_ +#define ACADOS_OCP_NLP_OCP_NLP_COST_LS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_cost_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + +//////////////////////////////////////////////////////////////////////////////// +// dims // +//////////////////////////////////////////////////////////////////////////////// + +typedef struct +{ + int nx; // number of states + int nz; // number of algebraic variables + int nu; // number of inputs + int ny; // number of outputs + int ns; // number of slacks +} ocp_nlp_cost_ls_dims; + + +/// Calculate the size of the ocp_nlp_cost_ls_dims struct +/// +/// \param[in] config_ structure containing configuration of ocp_nlp_cost +/// module +/// \param[out] [] +/// \return \c size of ocp_nlp_dims struct +acados_size_t ocp_nlp_cost_ls_dims_calculate_size(void *config); + + +/// Assign memory pointed to by raw_memory to ocp_nlp-cost_ls dims struct +/// +/// \param[in] config structure containing configuration of ocp_nlp_cost +/// module +/// \param[in] raw_memory pointer to memory location +/// \param[out] [] +/// \return dims +void *ocp_nlp_cost_ls_dims_assign(void *config, void *raw_memory); + + +/// Initialize the dimensions struct of the +/// ocp_nlp-cost_ls component +/// +/// \param[in] config structure containing configuration ocp_nlp-cost_ls component +/// \param[in] nx number of states +/// \param[in] nu number of inputs +/// \param[in] ny number of residuals +/// \param[in] ns number of slacks +/// \param[in] nz number of algebraic variables +/// \param[out] dims +/// \return size +void ocp_nlp_cost_ls_dims_initialize(void *config, void *dims, int nx, + int nu, int ny, int ns, int nz); + +// +void ocp_nlp_cost_ls_dims_set(void *config_, void *dims_, const char *field, int* value); +// +void ocp_nlp_cost_ls_dims_get(void *config_, void *dims_, const char *field, int* value); + + +//////////////////////////////////////////////////////////////////////////////// +// model // +//////////////////////////////////////////////////////////////////////////////// + + +/// structure containing the data describing the linear least-square cost +typedef struct +{ + // slack penalty has the form z^T * s + .5 * s^T * Z * s + struct blasfeo_dmat Cyt; ///< output matrix: Cy * [u,x] = y; in transposed form + struct blasfeo_dmat Vz; ///< Vz in ls cost Vx*x + Vu*u + Vz*z + struct blasfeo_dmat W; ///< ls norm corresponding to this matrix + struct blasfeo_dvec y_ref; ///< yref + struct blasfeo_dvec Z; ///< diagonal Hessian of slacks as vector (lower and upper) + struct blasfeo_dvec z; ///< gradient of slacks as vector (lower and upper) + double scaling; +} ocp_nlp_cost_ls_model; + +// +acados_size_t ocp_nlp_cost_ls_model_calculate_size(void *config, void *dims); +// +void *ocp_nlp_cost_ls_model_assign(void *config, void *dims, void *raw_memory); +// +int ocp_nlp_cost_ls_model_set(void *config_, void *dims_, void *model_, + const char *field, void *value_); + + + +//////////////////////////////////////////////////////////////////////////////// +// options // +//////////////////////////////////////////////////////////////////////////////// + + + +typedef struct +{ + int dummy; // struct can't be void +} ocp_nlp_cost_ls_opts; + +// +acados_size_t ocp_nlp_cost_ls_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_cost_ls_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_cost_ls_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_cost_ls_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_cost_ls_opts_set(void *config, void *opts, const char *field, void *value); + + + +//////////////////////////////////////////////////////////////////////////////// +// memory // +//////////////////////////////////////////////////////////////////////////////// + + + +/// structure containing the memory associated with cost_ls component +/// of the ocp_nlp module +typedef struct +{ + struct blasfeo_dmat hess; ///< hessian of cost function + struct blasfeo_dmat W_chol; ///< cholesky factor of weight matrix + struct blasfeo_dvec res; ///< ls residual r(x) + struct blasfeo_dvec grad; ///< gradient of cost function + struct blasfeo_dvec *ux; ///< pointer to ux in nlp_out + struct blasfeo_dvec *tmp_ux; ///< pointer to ux in tmp_nlp_out + struct blasfeo_dvec *z_alg; ///< pointer to z in sim_out + struct blasfeo_dmat *dzdux_tran; ///< pointer to sensitivity of a wrt ux in sim_out + struct blasfeo_dmat *RSQrq; ///< pointer to RSQrq in qp_in + struct blasfeo_dvec *Z; ///< pointer to Z in qp_in + double fun; ///< value of the cost function +} ocp_nlp_cost_ls_memory; + +// +acados_size_t ocp_nlp_cost_ls_memory_calculate_size(void *config, void *dims, void *opts); +// +void *ocp_nlp_cost_ls_memory_assign(void *config, void *dims, void *opts, void *raw_memory); +// +double *ocp_nlp_cost_ls_memory_get_fun_ptr(void *memory_); +// +struct blasfeo_dvec *ocp_nlp_cost_ls_memory_get_grad_ptr(void *memory_); +// +void ocp_nlp_cost_ls_memory_set_RSQrq_ptr(struct blasfeo_dmat *RSQrq, void *memory); +// +void ocp_nlp_cost_ls_memory_set_Z_ptr(struct blasfeo_dvec *Z, void *memory); +// +void ocp_nlp_cost_ls_memory_set_ux_ptr(struct blasfeo_dvec *ux, void *memory_); +// +void ocp_nlp_cost_ls_memory_set_tmp_ux_ptr(struct blasfeo_dvec *tmp_ux, void *memory_); +// +void ocp_nlp_cost_ls_memory_set_z_alg_ptr(struct blasfeo_dvec *z_alg, void *memory_); +// +void ocp_nlp_cost_ls_memory_set_dzdux_tran_ptr(struct blasfeo_dmat *dzdux_tran, void *memory_); + + + +//////////////////////////////////////////////////////////////////////////////// +// workspace // +//////////////////////////////////////////////////////////////////////////////// + + + +typedef struct +{ + struct blasfeo_dmat tmp_nv_ny; // temporary matrix of dimensions nv, ny + struct blasfeo_dmat Cyt_tilde; // updated Cyt (after z elimination) + struct blasfeo_dmat dzdux_tran; // derivatives of z wrt u and x (tran) + struct blasfeo_dvec tmp_ny; // temporary vector of dimension ny + struct blasfeo_dvec tmp_2ns; // temporary vector of dimension ny + struct blasfeo_dvec tmp_nz; // temporary vector of dimension nz + struct blasfeo_dvec y_ref_tilde; // updated y_ref (after z elimination) +} ocp_nlp_cost_ls_workspace; + +// +acados_size_t ocp_nlp_cost_ls_workspace_calculate_size(void *config, void *dims, void *opts); + + + +//////////////////////////////////////////////////////////////////////////////// +// functions // +//////////////////////////////////////////////////////////////////////////////// + + + +// +void ocp_nlp_cost_ls_config_initialize_default(void *config); +// +void ocp_nlp_cost_ls_initialize(void *config_, void *dims, void *model_, void *opts_, + void *mem_, void *work_); +// +void ocp_nlp_cost_ls_update_qp_matrices(void *config_, void *dims, void *model_, + void *opts_, void *memory_, void *work_); +// +void ocp_nlp_cost_ls_compute_fun(void *config_, void *dims, void *model_, void *opts_, void *memory_, void *work_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_COST_LS_H_ +/// @} +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_nls.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_nls.h new file mode 100644 index 00000000000000..aafb6b35407cfd --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_cost_nls.h @@ -0,0 +1,210 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_cost ocp_nlp_cost +/// @{ +/// \addtogroup ocp_nlp_cost_nls ocp_nlp_cost_nls +/// \brief This module implements nonlinear-least squares costs of the form +/// \f$\min_{x,u} \| r(x,u) - y_{\text{ref}} \|_W^2\f$. +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_COST_NLS_H_ +#define ACADOS_OCP_NLP_OCP_NLP_COST_NLS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_cost_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + + +/************************************************ + * dims + ************************************************/ + +typedef struct +{ + int nx; // number of states + int nu; // number of inputs + int ny; // number of outputs + int ns; // number of slacks +} ocp_nlp_cost_nls_dims; + +// +acados_size_t ocp_nlp_cost_nls_dims_calculate_size(void *config); +// +void *ocp_nlp_cost_nls_dims_assign(void *config, void *raw_memory); +// +void ocp_nlp_cost_nls_dims_initialize(void *config, void *dims, int nx, int nu, int ny, int ns, int nz); +// +void ocp_nlp_cost_nls_dims_set(void *config_, void *dims_, const char *field, int* value); +// +void ocp_nlp_cost_nls_dims_get(void *config_, void *dims_, const char *field, int* value); + + + +/************************************************ + * model + ************************************************/ + +typedef struct +{ + // nonliner function nls_y(x,u) replaces Cy * [x,u] in ls_cost + // slack penalty has the form z^T * s + .5 * s^T * Z * s + external_function_generic *nls_y_fun; // evaluation of nls function + external_function_generic *nls_y_fun_jac; // evaluation nls function and jacobian + external_function_generic *nls_y_hess; // hessian*seeds of nls residuals + struct blasfeo_dmat W; // + struct blasfeo_dvec y_ref; + struct blasfeo_dvec Z; // diagonal Hessian of slacks as vector + struct blasfeo_dvec z; // gradient of slacks as vector + double scaling; +} ocp_nlp_cost_nls_model; + +// +acados_size_t ocp_nlp_cost_nls_model_calculate_size(void *config, void *dims); +// +void *ocp_nlp_cost_nls_model_assign(void *config, void *dims, void *raw_memory); +// +int ocp_nlp_cost_nls_model_set(void *config_, void *dims_, void *model_, const char *field, void *value_); + + + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + bool gauss_newton_hess; // gauss-newton hessian approximation +} ocp_nlp_cost_nls_opts; + +// +acados_size_t ocp_nlp_cost_nls_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_cost_nls_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_cost_nls_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_cost_nls_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_cost_nls_opts_set(void *config, void *opts, const char *field, void *value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + struct blasfeo_dmat W_chol; // cholesky factor of weight matrix + struct blasfeo_dmat Jt; // jacobian of nls fun + struct blasfeo_dvec res; // nls residual r(x) + struct blasfeo_dvec grad; // gradient of cost function + struct blasfeo_dvec *ux; // pointer to ux in nlp_out + struct blasfeo_dvec *tmp_ux; // pointer to ux in tmp_nlp_out + struct blasfeo_dvec *z_alg; ///< pointer to z in sim_out + struct blasfeo_dmat *dzdux_tran; ///< pointer to sensitivity of a wrt ux in sim_out + struct blasfeo_dmat *RSQrq; // pointer to RSQrq in qp_in + struct blasfeo_dvec *Z; // pointer to Z in qp_in + double fun; ///< value of the cost function +} ocp_nlp_cost_nls_memory; + +// +acados_size_t ocp_nlp_cost_nls_memory_calculate_size(void *config, void *dims, void *opts); +// +void *ocp_nlp_cost_nls_memory_assign(void *config, void *dims, void *opts, void *raw_memory); +// +double *ocp_nlp_cost_nls_memory_get_fun_ptr(void *memory_); +// +struct blasfeo_dvec *ocp_nlp_cost_nls_memory_get_grad_ptr(void *memory_); +// +void ocp_nlp_cost_nls_memory_set_RSQrq_ptr(struct blasfeo_dmat *RSQrq, void *memory); +// +void ocp_nlp_cost_nls_memory_set_Z_ptr(struct blasfeo_dvec *Z, void *memory); +// +void ocp_nlp_cost_nls_memory_set_ux_ptr(struct blasfeo_dvec *ux, void *memory_); +// +void ocp_nlp_cost_nls_memory_set_tmp_ux_ptr(struct blasfeo_dvec *tmp_ux, void *memory_); +// +void ocp_nlp_cost_nls_memory_set_z_alg_ptr(struct blasfeo_dvec *z_alg, void *memory_); +// +void ocp_nlp_cost_nls_memory_set_dzdux_tran_ptr(struct blasfeo_dmat *dzdux_tran, void *memory_); + +/************************************************ + * workspace + ************************************************/ + +typedef struct +{ + struct blasfeo_dmat tmp_nv_ny; + struct blasfeo_dmat tmp_nv_nv; + struct blasfeo_dvec tmp_ny; + struct blasfeo_dvec tmp_2ns; // temporary vector of dimension ny +} ocp_nlp_cost_nls_workspace; + +// +acados_size_t ocp_nlp_cost_nls_workspace_calculate_size(void *config, void *dims, void *opts); + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_cost_nls_config_initialize_default(void *config); +// +void ocp_nlp_cost_nls_initialize(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); +// +void ocp_nlp_cost_nls_update_qp_matrices(void *config_, void *dims, void *model_, void *opts_, void *memory_, void *work_); +// +void ocp_nlp_cost_nls_compute_fun(void *config_, void *dims, void *model_, void *opts_, void *memory_, void *work_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_COST_NLS_H_ +/// @} +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_common.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_common.h new file mode 100644 index 00000000000000..45dac20a252204 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_common.h @@ -0,0 +1,122 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \ingroup ocp_nlp +/// @{ + +/// \defgroup ocp_nlp_dynamics ocp_nlp_dynamics +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_COMMON_H_ +#define ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/sim/sim_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + + + +/************************************************ + * config + ************************************************/ + +typedef struct +{ + void (*config_initialize_default)(void *config); + sim_config *sim_solver; + /* dims */ + acados_size_t (*dims_calculate_size)(void *config); + void *(*dims_assign)(void *config, void *raw_memory); + void (*dims_initialize)(void *config, void *dims, int nx, int nu, int nx1, int nu1, int nz); + void (*dims_set)(void *config_, void *dims_, const char *field, int *value); + void (*dims_get)(void *config_, void *dims_, const char *field, int* value); + /* model */ + acados_size_t (*model_calculate_size)(void *config, void *dims); + void *(*model_assign)(void *config, void *dims, void *raw_memory); + void (*model_set)(void *config_, void *dims_, void *model_, const char *field, void *value_); + /* opts */ + acados_size_t (*opts_calculate_size)(void *config, void *dims); + void *(*opts_assign)(void *config, void *dims, void *raw_memory); + void (*opts_initialize_default)(void *config, void *dims, void *opts); + void (*opts_set)(void *config_, void *opts_, const char *field, void *value); + void (*opts_update)(void *config, void *dims, void *opts); + /* memory */ + acados_size_t (*memory_calculate_size)(void *config, void *dims, void *opts); + void *(*memory_assign)(void *config, void *dims, void *opts, void *raw_memory); + struct blasfeo_dvec *(*memory_get_fun_ptr)(void *memory_); + struct blasfeo_dvec *(*memory_get_adj_ptr)(void *memory_); + void (*memory_set_ux_ptr)(struct blasfeo_dvec *ux, void *memory_); + void (*memory_set_tmp_ux_ptr)(struct blasfeo_dvec *tmp_ux, void *memory_); + void (*memory_set_ux1_ptr)(struct blasfeo_dvec *ux1, void *memory_); + void (*memory_set_tmp_ux1_ptr)(struct blasfeo_dvec *tmp_ux1, void *memory_); + void (*memory_set_pi_ptr)(struct blasfeo_dvec *pi, void *memory_); + void (*memory_set_tmp_pi_ptr)(struct blasfeo_dvec *tmp_pi, void *memory_); + void (*memory_set_BAbt_ptr)(struct blasfeo_dmat *BAbt, void *memory_); + void (*memory_set_RSQrq_ptr)(struct blasfeo_dmat *RSQrq, void *memory_); + void (*memory_set_dzduxt_ptr)(struct blasfeo_dmat *mat, void *memory_); + void (*memory_set_sim_guess_ptr)(struct blasfeo_dvec *vec, bool *bool_ptr, void *memory_); + void (*memory_set_z_alg_ptr)(struct blasfeo_dvec *vec, void *memory_); + void (*memory_get)(void *config, void *dims, void *mem, const char *field, void* value); + /* workspace */ + acados_size_t (*workspace_calculate_size)(void *config, void *dims, void *opts); + void (*initialize)(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); + void (*update_qp_matrices)(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); + void (*compute_fun)(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); + int (*precompute)(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); +} ocp_nlp_dynamics_config; + +// +acados_size_t ocp_nlp_dynamics_config_calculate_size(); +// +ocp_nlp_dynamics_config *ocp_nlp_dynamics_config_assign(void *raw_memory); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_COMMON_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_cont.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_cont.h new file mode 100644 index 00000000000000..59a2df4f47a0ee --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_cont.h @@ -0,0 +1,216 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_dynamics +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_CONT_H_ +#define ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_CONT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_dynamics_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" +#include "acados_c/sim_interface.h" + + + +/************************************************ + * dims + ************************************************/ + +typedef struct +{ + void *sim; + int nx; // number of states at the current stage + int nz; // number of algebraic states at the current stage + int nu; // number of inputs at the current stage + int nx1; // number of states at the next stage + int nu1; // number of inputes at the next stage +} ocp_nlp_dynamics_cont_dims; + +// +acados_size_t ocp_nlp_dynamics_cont_dims_calculate_size(void *config); +// +void *ocp_nlp_dynamics_cont_dims_assign(void *config, void *raw_memory); +// +void ocp_nlp_dynamics_cont_dims_initialize(void *config, void *dims, int nx, int nu, int nx1, + int nu1, int nz); + +// +void ocp_nlp_dynamics_cont_dims_set(void *config_, void *dims_, const char *field, int* value); + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + void *sim_solver; + int compute_adj; + int compute_hess; +} ocp_nlp_dynamics_cont_opts; + +// +acados_size_t ocp_nlp_dynamics_cont_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_dynamics_cont_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_dynamics_cont_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_dynamics_cont_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_dynamics_cont_opts_set(void *config, void *opts, const char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + struct blasfeo_dvec fun; + struct blasfeo_dvec adj; + struct blasfeo_dvec *ux; // pointer to ux in nlp_out at current stage + struct blasfeo_dvec *tmp_ux; // pointer to ux in tmp_nlp_out at current stage + struct blasfeo_dvec *ux1; // pointer to ux in nlp_out at next stage + struct blasfeo_dvec *tmp_ux1; // pointer to ux in tmp_nlp_out at next stage + struct blasfeo_dvec *pi; // pointer to pi in nlp_out at current stage + struct blasfeo_dvec *tmp_pi; // pointer to pi in tmp_nlp_out at current stage + struct blasfeo_dmat *BAbt; // pointer to BAbt in qp_in + struct blasfeo_dmat *RSQrq; // pointer to RSQrq in qp_in + struct blasfeo_dvec *z_alg; // pointer to output z at t = 0 + bool *set_sim_guess; // indicate if initialization for integrator is set from outside + struct blasfeo_dvec *sim_guess; // initializations for integrator + // struct blasfeo_dvec *z; // pointer to (input) z in nlp_out at current stage + struct blasfeo_dmat *dzduxt; // pointer to dzdux transposed + void *sim_solver; // sim solver memory +} ocp_nlp_dynamics_cont_memory; + +// +acados_size_t ocp_nlp_dynamics_cont_memory_calculate_size(void *config, void *dims, void *opts); +// +void *ocp_nlp_dynamics_cont_memory_assign(void *config, void *dims, void *opts, void *raw_memory); +// +struct blasfeo_dvec *ocp_nlp_dynamics_cont_memory_get_fun_ptr(void *memory); +// +struct blasfeo_dvec *ocp_nlp_dynamics_cont_memory_get_adj_ptr(void *memory); +// +void ocp_nlp_dynamics_cont_memory_set_ux_ptr(struct blasfeo_dvec *ux, void *memory); +// +void ocp_nlp_dynamics_cont_memory_set_tmp_ux_ptr(struct blasfeo_dvec *tmp_ux, void *memory); +// +void ocp_nlp_dynamics_cont_memory_set_ux1_ptr(struct blasfeo_dvec *ux1, void *memory); +// +void ocp_nlp_dynamics_cont_memory_set_tmp_ux1_ptr(struct blasfeo_dvec *tmp_ux1, void *memory); +// +void ocp_nlp_dynamics_cont_memory_set_pi_ptr(struct blasfeo_dvec *pi, void *memory); +// +void ocp_nlp_dynamics_cont_memory_set_tmp_pi_ptr(struct blasfeo_dvec *tmp_pi, void *memory); +// +void ocp_nlp_dynamics_cont_memory_set_BAbt_ptr(struct blasfeo_dmat *BAbt, void *memory); + + + +/************************************************ + * workspace + ************************************************/ + +typedef struct +{ + struct blasfeo_dmat hess; + sim_in *sim_in; + sim_out *sim_out; + void *sim_solver; // sim solver workspace +} ocp_nlp_dynamics_cont_workspace; + +acados_size_t ocp_nlp_dynamics_cont_workspace_calculate_size(void *config, void *dims, void *opts); + + + +/************************************************ + * model + ************************************************/ + +typedef struct +{ + void *sim_model; + // double *state_transition; // TODO + double T; // simulation time +} ocp_nlp_dynamics_cont_model; + +// +acados_size_t ocp_nlp_dynamics_cont_model_calculate_size(void *config, void *dims); +// +void *ocp_nlp_dynamics_cont_model_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_dynamics_cont_model_set(void *config_, void *dims_, void *model_, const char *field, void *value); + + + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_dynamics_cont_config_initialize_default(void *config); +// +void ocp_nlp_dynamics_cont_initialize(void *config_, void *dims, void *model_, void *opts, void *mem, void *work_); +// +void ocp_nlp_dynamics_cont_update_qp_matrices(void *config_, void *dims, void *model_, void *opts, void *mem, void *work_); +// +void ocp_nlp_dynamics_cont_compute_fun(void *config_, void *dims, void *model_, void *opts, void *mem, void *work_); +// +int ocp_nlp_dynamics_cont_precompute(void *config_, void *dims, void *model_, void *opts_, void *mem_, void *work_); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_CONT_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_disc.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_disc.h new file mode 100644 index 00000000000000..8b2a6177bff78a --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_dynamics_disc.h @@ -0,0 +1,199 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_dynamics +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_DISC_H_ +#define ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_DISC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_dynamics_common.h" +#include "acados/utils/external_function_generic.h" +#include "acados/utils/types.h" + +/************************************************ + * dims + ************************************************/ + +typedef struct +{ + int nx; // number of states at the current stage + int nu; // number of inputs at the current stage + int nx1; // number of states at the next stage + int nu1; // number of inputes at the next stage +} ocp_nlp_dynamics_disc_dims; + +// +acados_size_t ocp_nlp_dynamics_disc_dims_calculate_size(void *config); +// +void *ocp_nlp_dynamics_disc_dims_assign(void *config, void *raw_memory); +// +void ocp_nlp_dynamics_disc_dims_initialize(void *config, void *dims, int nx, int nu, int nx1, + int nu1, int nz); + +// +void ocp_nlp_dynamics_disc_dims_set(void *config_, void *dims_, const char *dim, int* value); + + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + int compute_adj; + int compute_hess; +} ocp_nlp_dynamics_disc_opts; + +// +acados_size_t ocp_nlp_dynamics_disc_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_dynamics_disc_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_dynamics_disc_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_dynamics_disc_opts_update(void *config, void *dims, void *opts); +// +int ocp_nlp_dynamics_disc_precompute(void *config_, void *dims, void *model_, void *opts_, + void *mem_, void *work_); + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + struct blasfeo_dvec fun; + struct blasfeo_dvec adj; + struct blasfeo_dvec *ux; // pointer to ux in nlp_out at current stage + struct blasfeo_dvec *tmp_ux; // pointer to ux in tmp_nlp_out at current stage + struct blasfeo_dvec *ux1; // pointer to ux in nlp_out at next stage + struct blasfeo_dvec *tmp_ux1;// pointer to ux in tmp_nlp_out at next stage + struct blasfeo_dvec *pi; // pointer to pi in nlp_out at current stage + struct blasfeo_dvec *tmp_pi; // pointer to pi in tmp_nlp_out at current stage + struct blasfeo_dmat *BAbt; // pointer to BAbt in qp_in + struct blasfeo_dmat *RSQrq; // pointer to RSQrq in qp_in +} ocp_nlp_dynamics_disc_memory; + +// +acados_size_t ocp_nlp_dynamics_disc_memory_calculate_size(void *config, void *dims, void *opts); +// +void *ocp_nlp_dynamics_disc_memory_assign(void *config, void *dims, void *opts, void *raw_memory); +// +struct blasfeo_dvec *ocp_nlp_dynamics_disc_memory_get_fun_ptr(void *memory); +// +struct blasfeo_dvec *ocp_nlp_dynamics_disc_memory_get_adj_ptr(void *memory); +// +void ocp_nlp_dynamics_disc_memory_set_ux_ptr(struct blasfeo_dvec *ux, void *memory); +// +void ocp_nlp_dynamics_disc_memory_set_tmp_ux_ptr(struct blasfeo_dvec *tmp_ux, void *memory); +// +void ocp_nlp_dynamics_disc_memory_set_ux1_ptr(struct blasfeo_dvec *ux1, void *memory); +// +void ocp_nlp_dynamics_disc_memory_set_tmp_ux1_ptr(struct blasfeo_dvec *tmp_ux1, void *memory); +// +void ocp_nlp_dynamics_disc_memory_set_pi_ptr(struct blasfeo_dvec *pi, void *memory); +// +void ocp_nlp_dynamics_disc_memory_set_tmp_pi_ptr(struct blasfeo_dvec *tmp_pi, void *memory); +// +void ocp_nlp_dynamics_disc_memory_set_BAbt_ptr(struct blasfeo_dmat *BAbt, void *memory); + + + +/************************************************ + * workspace + ************************************************/ + +typedef struct +{ + struct blasfeo_dmat tmp_nv_nv; +} ocp_nlp_dynamics_disc_workspace; + +acados_size_t ocp_nlp_dynamics_disc_workspace_calculate_size(void *config, void *dims, void *opts); + + + +/************************************************ + * model + ************************************************/ + +typedef struct +{ + external_function_generic *disc_dyn_fun; + external_function_generic *disc_dyn_fun_jac; + external_function_generic *disc_dyn_fun_jac_hess; +} ocp_nlp_dynamics_disc_model; + +// +acados_size_t ocp_nlp_dynamics_disc_model_calculate_size(void *config, void *dims); +// +void *ocp_nlp_dynamics_disc_model_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_dynamics_disc_model_set(void *config_, void *dims_, void *model_, const char *field, void *value); + + + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_dynamics_disc_config_initialize_default(void *config); +// +void ocp_nlp_dynamics_disc_initialize(void *config_, void *dims, void *model_, void *opts, void *mem, void *work_); +// +void ocp_nlp_dynamics_disc_update_qp_matrices(void *config_, void *dims, void *model_, void *opts, void *mem, void *work_); +// +void ocp_nlp_dynamics_disc_compute_fun(void *config_, void *dims, void *model_, void *opts, void *mem, void *work_); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_DYNAMICS_DISC_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_common.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_common.h new file mode 100644 index 00000000000000..cd26788a5697d8 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_common.h @@ -0,0 +1,125 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \ingroup ocp_nlp +/// @{ + +/// \defgroup ocp_nlp_reg ocp_nlp_reg +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_REG_COMMON_H_ +#define ACADOS_OCP_NLP_OCP_NLP_REG_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/ocp_qp/ocp_qp_common.h" + + + +/* dims */ + +//typedef ocp_qp_dims ocp_nlp_reg_dims; +typedef struct +{ + int *nx; + int *nu; + int *nbu; + int *nbx; + int *ng; + int N; +} ocp_nlp_reg_dims; + +// +acados_size_t ocp_nlp_reg_dims_calculate_size(int N); +// +ocp_nlp_reg_dims *ocp_nlp_reg_dims_assign(int N, void *raw_memory); +// +void ocp_nlp_reg_dims_set(void *config_, ocp_nlp_reg_dims *dims, int stage, char *field, int* value); + + + +/* config */ + +typedef struct +{ + /* dims */ + acados_size_t (*dims_calculate_size)(int N); + ocp_nlp_reg_dims *(*dims_assign)(int N, void *raw_memory); + void (*dims_set)(void *config, ocp_nlp_reg_dims *dims, int stage, char *field, int *value); + /* opts */ + acados_size_t (*opts_calculate_size)(void); + void *(*opts_assign)(void *raw_memory); + void (*opts_initialize_default)(void *config, ocp_nlp_reg_dims *dims, void *opts); + void (*opts_set)(void *config, ocp_nlp_reg_dims *dims, void *opts, char *field, void* value); + /* memory */ + acados_size_t (*memory_calculate_size)(void *config, ocp_nlp_reg_dims *dims, void *opts); + void *(*memory_assign)(void *config, ocp_nlp_reg_dims *dims, void *opts, void *raw_memory); + void (*memory_set)(void *config, ocp_nlp_reg_dims *dims, void *memory, char *field, void* value); + void (*memory_set_RSQrq_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dmat *mat, void *memory); + void (*memory_set_rq_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dvec *vec, void *memory); + void (*memory_set_BAbt_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dmat *mat, void *memory); + void (*memory_set_b_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dvec *vec, void *memory); + void (*memory_set_idxb_ptr)(ocp_nlp_reg_dims *dims, int **idxb, void *memory); + void (*memory_set_DCt_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dmat *mat, void *memory); + void (*memory_set_ux_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dvec *vec, void *memory); + void (*memory_set_pi_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dvec *vec, void *memory); + void (*memory_set_lam_ptr)(ocp_nlp_reg_dims *dims, struct blasfeo_dvec *vec, void *memory); + /* functions */ + void (*regularize_hessian)(void *config, ocp_nlp_reg_dims *dims, void *opts, void *memory); + void (*correct_dual_sol)(void *config, ocp_nlp_reg_dims *dims, void *opts, void *memory); +} ocp_nlp_reg_config; + +// +acados_size_t ocp_nlp_reg_config_calculate_size(void); +// +void *ocp_nlp_reg_config_assign(void *raw_memory); + + + +/* regularization help functions */ +void acados_reconstruct_A(int dim, double *A, double *V, double *d); +void acados_mirror(int dim, double *A, double *V, double *d, double *e, double epsilon); +void acados_project(int dim, double *A, double *V, double *d, double *e, double epsilon); + + + +#ifdef __cplusplus +} +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_REG_COMMON_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_convexify.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_convexify.h new file mode 100644 index 00000000000000..df313616801e56 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_convexify.h @@ -0,0 +1,149 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_reg +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_REG_CONVEXIFY_H_ +#define ACADOS_OCP_NLP_OCP_NLP_REG_CONVEXIFY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_reg_common.h" + + + +/************************************************ + * dims + ************************************************/ + +// use the functions in ocp_nlp_reg_common + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + double delta; + double epsilon; +// double gamma; // 0.0 +} ocp_nlp_reg_convexify_opts; + +// +acados_size_t ocp_nlp_reg_convexify_opts_calculate_size(void); +// +void *ocp_nlp_reg_convexify_opts_assign(void *raw_memory); +// +void ocp_nlp_reg_convexify_opts_initialize_default(void *config_, ocp_nlp_reg_dims *dims, void *opts_); +// +void ocp_nlp_reg_convexify_opts_set(void *config_, ocp_nlp_reg_dims *dims, void *opts_, char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct { + double *R; + double *V; // TODO move to workspace + double *d; // TODO move to workspace + double *e; // TODO move to workspace + double *reg_hess; // TODO move to workspace + + struct blasfeo_dmat Q_tilde; + struct blasfeo_dmat Q_bar; + struct blasfeo_dmat BAQ; + struct blasfeo_dmat L; + struct blasfeo_dmat delta_eye; + struct blasfeo_dmat St_copy; + + struct blasfeo_dmat *original_RSQrq; + struct blasfeo_dmat tmp_RSQ; + + struct blasfeo_dvec tmp_nuxM; + struct blasfeo_dvec tmp_nbgM; + +// struct blasfeo_dvec grad; +// struct blasfeo_dvec b2; + + // giaf's + struct blasfeo_dmat **RSQrq; // pointer to RSQrq in qp_in + struct blasfeo_dvec **rq; // pointer to rq in qp_in + struct blasfeo_dmat **BAbt; // pointer to BAbt in qp_in + struct blasfeo_dvec **b; // pointer to b in qp_in + struct blasfeo_dmat **DCt; // pointer to DCt in qp_in + struct blasfeo_dvec **ux; // pointer to ux in qp_out + struct blasfeo_dvec **pi; // pointer to pi in qp_out + struct blasfeo_dvec **lam; // pointer to lam in qp_out + int **idxb; // pointer to idxb in qp_in + +} ocp_nlp_reg_convexify_memory; + +// +acados_size_t ocp_nlp_reg_convexify_calculate_memory_size(void *config, ocp_nlp_reg_dims *dims, void *opts); +// +void *ocp_nlp_reg_convexify_assign_memory(void *config, ocp_nlp_reg_dims *dims, void *opts, void *raw_memory); + +/************************************************ + * workspace + ************************************************/ + + // TODO + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_reg_convexify_config_initialize_default(ocp_nlp_reg_config *config); + +#ifdef __cplusplus +} +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_REG_CONVEXIFY_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_mirror.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_mirror.h new file mode 100644 index 00000000000000..f6bd7dcafd2d77 --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_mirror.h @@ -0,0 +1,124 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_reg +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_REG_MIRROR_H_ +#define ACADOS_OCP_NLP_OCP_NLP_REG_MIRROR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_reg_common.h" + + + +/************************************************ + * dims + ************************************************/ + +// use the functions in ocp_nlp_reg_common + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + double epsilon; +} ocp_nlp_reg_mirror_opts; + +// +acados_size_t ocp_nlp_reg_mirror_opts_calculate_size(void); +// +void *ocp_nlp_reg_mirror_opts_assign(void *raw_memory); +// +void ocp_nlp_reg_mirror_opts_initialize_default(void *config_, ocp_nlp_reg_dims *dims, void *opts_); +// +void ocp_nlp_reg_mirror_opts_set(void *config_, ocp_nlp_reg_dims *dims, void *opts_, char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + double *reg_hess; // TODO move to workspace + double *V; // TODO move to workspace + double *d; // TODO move to workspace + double *e; // TODO move to workspace + + // giaf's + struct blasfeo_dmat **RSQrq; // pointer to RSQrq in qp_in +} ocp_nlp_reg_mirror_memory; + +// +acados_size_t ocp_nlp_reg_mirror_memory_calculate_size(void *config, ocp_nlp_reg_dims *dims, void *opts); +// +void *ocp_nlp_reg_mirror_memory_assign(void *config, ocp_nlp_reg_dims *dims, void *opts, void *raw_memory); + +/************************************************ + * workspace + ************************************************/ + + // TODO + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_reg_mirror_config_initialize_default(ocp_nlp_reg_config *config); + + + +#ifdef __cplusplus +} +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_REG_MIRROR_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_noreg.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_noreg.h new file mode 100644 index 00000000000000..8d2b6ecc13896f --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_noreg.h @@ -0,0 +1,120 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_reg +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_REG_NOREG_H_ +#define ACADOS_OCP_NLP_OCP_NLP_REG_NOREG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_reg_common.h" + + + +/************************************************ + * dims + ************************************************/ + +// use the functions in ocp_nlp_reg_common + + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + int dummy; +} ocp_nlp_reg_noreg_opts; + +// +acados_size_t ocp_nlp_reg_noreg_opts_calculate_size(void); +// +void *ocp_nlp_reg_noreg_opts_assign(void *raw_memory); +// +void ocp_nlp_reg_noreg_opts_initialize_default(void *config_, ocp_nlp_reg_dims *dims, void *opts_); +// +void ocp_nlp_reg_noreg_opts_set(void *config_, ocp_nlp_reg_dims *dims, void *opts_, char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + int dummy; +} ocp_nlp_reg_noreg_memory; + +// +acados_size_t ocp_nlp_reg_noreg_memory_calculate_size(void *config, ocp_nlp_reg_dims *dims, void *opts); +// +void *ocp_nlp_reg_noreg_memory_assign(void *config, ocp_nlp_reg_dims *dims, void *opts, void *raw_memory); + +/************************************************ + * workspace + ************************************************/ + +// not needed + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_reg_noreg_config_initialize_default(ocp_nlp_reg_config *config); + + + +#ifdef __cplusplus +} +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_REG_NOREG_H_ + +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_project.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_project.h new file mode 100644 index 00000000000000..104c297207035b --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_project.h @@ -0,0 +1,124 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_reg +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_REG_PROJECT_H_ +#define ACADOS_OCP_NLP_OCP_NLP_REG_PROJECT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_reg_common.h" + + + +/************************************************ + * dims + ************************************************/ + +// use the functions in ocp_nlp_reg_common + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + double epsilon; +} ocp_nlp_reg_project_opts; + +// +acados_size_t ocp_nlp_reg_project_opts_calculate_size(void); +// +void *ocp_nlp_reg_project_opts_assign(void *raw_memory); +// +void ocp_nlp_reg_project_opts_initialize_default(void *config_, ocp_nlp_reg_dims *dims, void *opts_); +// +void ocp_nlp_reg_project_opts_set(void *config_, ocp_nlp_reg_dims *dims, void *opts_, char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + double *reg_hess; // TODO move to workspace + double *V; // TODO move to workspace + double *d; // TODO move to workspace + double *e; // TODO move to workspace + + // giaf's + struct blasfeo_dmat **RSQrq; // pointer to RSQrq in qp_in +} ocp_nlp_reg_project_memory; + +// +acados_size_t ocp_nlp_reg_project_memory_calculate_size(void *config, ocp_nlp_reg_dims *dims, void *opts); +// +void *ocp_nlp_reg_project_memory_assign(void *config, ocp_nlp_reg_dims *dims, void *opts, void *raw_memory); + +/************************************************ + * workspace + ************************************************/ + + // TODO + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_reg_project_config_initialize_default(ocp_nlp_reg_config *config); + + + +#ifdef __cplusplus +} +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_REG_PROJECT_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_project_reduc_hess.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_project_reduc_hess.h new file mode 100644 index 00000000000000..e0b854bc1a1e7f --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_reg_project_reduc_hess.h @@ -0,0 +1,135 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_reg +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_REG_PROJECT_REDUC_HESS_H_ +#define ACADOS_OCP_NLP_OCP_NLP_REG_PROJECT_REDUC_HESS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// blasfeo +#include "blasfeo/include/blasfeo_common.h" + +// acados +#include "acados/ocp_nlp/ocp_nlp_reg_common.h" + + + +/************************************************ + * dims + ************************************************/ + +// use the functions in ocp_nlp_reg_common + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + double thr_eig; + double min_eig; + double min_pivot; + int pivoting; +} ocp_nlp_reg_project_reduc_hess_opts; + +// +acados_size_t ocp_nlp_reg_project_reduc_hess_opts_calculate_size(void); +// +void *ocp_nlp_reg_project_reduc_hess_opts_assign(void *raw_memory); +// +void ocp_nlp_reg_project_reduc_hess_opts_initialize_default(void *config_, ocp_nlp_reg_dims *dims, void *opts_); +// +void ocp_nlp_reg_project_reduc_hess_opts_set(void *config_, ocp_nlp_reg_dims *dims, void *opts_, char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + double *reg_hess; // TODO move to workspace + double *V; // TODO move to workspace + double *d; // TODO move to workspace + double *e; // TODO move to workspace + + // giaf's + struct blasfeo_dmat L; // TODO move to workspace + struct blasfeo_dmat L2; // TODO move to workspace + struct blasfeo_dmat L3; // TODO move to workspace + struct blasfeo_dmat Ls; // TODO move to workspace + struct blasfeo_dmat P; // TODO move to workspace + struct blasfeo_dmat AL; // TODO move to workspace + + struct blasfeo_dmat **RSQrq; // pointer to RSQrq in qp_in + struct blasfeo_dmat **BAbt; // pointer to RSQrq in qp_in +} ocp_nlp_reg_project_reduc_hess_memory; + +// +acados_size_t ocp_nlp_reg_project_reduc_hess_memory_calculate_size(void *config, ocp_nlp_reg_dims *dims, void *opts); +// +void *ocp_nlp_reg_project_reduc_hess_memory_assign(void *config, ocp_nlp_reg_dims *dims, void *opts, void *raw_memory); + +/************************************************ + * workspace + ************************************************/ + + // TODO + +/************************************************ + * functions + ************************************************/ + +// +void ocp_nlp_reg_project_reduc_hess_config_initialize_default(ocp_nlp_reg_config *config); + + + +#ifdef __cplusplus +} +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_REG_PROJECT_REDUC_HESS_H_ +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_sqp.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_sqp.h new file mode 100644 index 00000000000000..81a4afd0305e1e --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_sqp.h @@ -0,0 +1,171 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_solver +/// @{ +/// \addtogroup ocp_nlp_sqp ocp_nlp_sqp +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_SQP_H_ +#define ACADOS_OCP_NLP_OCP_NLP_SQP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/ocp_nlp/ocp_nlp_common.h" +#include "acados/utils/types.h" + + + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + ocp_nlp_opts *nlp_opts; + double tol_stat; // exit tolerance on stationarity condition + double tol_eq; // exit tolerance on equality constraints + double tol_ineq; // exit tolerance on inequality constraints + double tol_comp; // exit tolerance on complementarity condition + int max_iter; + int ext_qp_res; // compute external QP residuals (i.e. at SQP level) at each SQP iteration (for debugging) + int qp_warm_start; // qp_warm_start in all but the first sqp iterations + bool warm_start_first_qp; // to set qp_warm_start in first iteration + int rti_phase; // only phase 0 at the moment + int print_level; // verbosity + int initialize_t_slacks; // 0-false or 1-true + +} ocp_nlp_sqp_opts; + +// +acados_size_t ocp_nlp_sqp_opts_calculate_size(void *config, void *dims); +// +void *ocp_nlp_sqp_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_nlp_sqp_opts_initialize_default(void *config, void *dims, void *opts); +// +void ocp_nlp_sqp_opts_update(void *config, void *dims, void *opts); +// +void ocp_nlp_sqp_opts_set(void *config_, void *opts_, const char *field, void* value); +// +void ocp_nlp_sqp_opts_set_at_stage(void *config_, void *opts_, size_t stage, const char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + // nlp memory + ocp_nlp_memory *nlp_mem; + + double time_qp_sol; + double time_qp_solver_call; + double time_qp_xcond; + double time_lin; + double time_reg; + double time_tot; + double time_glob; + double time_sim; + double time_sim_la; + double time_sim_ad; + + // statistics + double *stat; + int stat_m; + int stat_n; + + int status; + int sqp_iter; + +} ocp_nlp_sqp_memory; + +// +acados_size_t ocp_nlp_sqp_memory_calculate_size(void *config, void *dims, void *opts_); +// +void *ocp_nlp_sqp_memory_assign(void *config, void *dims, void *opts_, void *raw_memory); + + + +/************************************************ + * workspace + ************************************************/ + +typedef struct +{ + ocp_nlp_workspace *nlp_work; + + // temp QP in & out (to be used as workspace in param sens) + ocp_qp_in *tmp_qp_in; + ocp_qp_out *tmp_qp_out; + + // qp residuals + ocp_qp_res *qp_res; + ocp_qp_res_ws *qp_res_ws; + +} ocp_nlp_sqp_workspace; + +// +acados_size_t ocp_nlp_sqp_workspace_calculate_size(void *config, void *dims, void *opts_); + + + +/************************************************ + * functions + ************************************************/ + +// +int ocp_nlp_sqp(void *config, void *dims, void *nlp_in, void *nlp_out, + void *args, void *mem, void *work_); +// +void ocp_nlp_sqp_config_initialize_default(void *config_); +// +int ocp_nlp_sqp_precompute(void *config_, void *dims_, void *nlp_in_, void *nlp_out_, + void *opts_, void *mem_, void *work_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_SQP_H_ +/// @} +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_nlp/ocp_nlp_sqp_rti.h b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_sqp_rti.h new file mode 100644 index 00000000000000..6f16594d2ba48c --- /dev/null +++ b/third_party/acados/include/acados/ocp_nlp/ocp_nlp_sqp_rti.h @@ -0,0 +1,172 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +/// \addtogroup ocp_nlp +/// @{ +/// \addtogroup ocp_nlp_solver +/// @{ +/// \addtogroup ocp_nlp_sqp_rti ocp_nlp_sqp_rti +/// @{ + +#ifndef ACADOS_OCP_NLP_OCP_NLP_SQP_RTI_H_ +#define ACADOS_OCP_NLP_OCP_NLP_SQP_RTI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/ocp_nlp/ocp_nlp_common.h" +#include "acados/utils/types.h" + + + +/************************************************ + * options + ************************************************/ + +typedef struct +{ + ocp_nlp_opts *nlp_opts; + int compute_dual_sol; + int ext_qp_res; // compute external QP residuals (i.e. at SQP level) at each SQP iteration (for debugging) + int qp_warm_start; // NOTE: this is not actually setting the warm_start! Just for compatibility with sqp. + bool warm_start_first_qp; // to set qp_warm_start in first iteration + int rti_phase; // phase of RTI. Possible values 1 (preparation), 2 (feedback) 0 (both) + int print_level; // verbosity + +} ocp_nlp_sqp_rti_opts; + +// +acados_size_t ocp_nlp_sqp_rti_opts_calculate_size(void *config_, void *dims_); +// +void *ocp_nlp_sqp_rti_opts_assign(void *config_, void *dims_, void *raw_memory); +// +void ocp_nlp_sqp_rti_opts_initialize_default(void *config_, void *dims_, void *opts_); +// +void ocp_nlp_sqp_rti_opts_update(void *config_, void *dims_, void *opts_); +// +void ocp_nlp_sqp_rti_opts_set(void *config_, void *opts_, const char *field, void* value); +// +void ocp_nlp_sqp_rti_opts_set_at_stage(void *config_, void *opts_, size_t stage, + const char *field, void* value); + + + +/************************************************ + * memory + ************************************************/ + +typedef struct +{ + // nlp memory + ocp_nlp_memory *nlp_mem; + + double time_qp_sol; + double time_qp_solver_call; + double time_qp_xcond; + double time_lin; + double time_reg; + double time_tot; + double time_glob; + + // statistics + double *stat; + int stat_m; + int stat_n; + + int status; + +} ocp_nlp_sqp_rti_memory; + +// +acados_size_t ocp_nlp_sqp_rti_memory_calculate_size(void *config_, void *dims_, void *opts_); +// +void *ocp_nlp_sqp_rti_memory_assign(void *config_, void *dims_, void *opts_, + void *raw_memory); + + + +/************************************************ + * workspace + ************************************************/ + +typedef struct +{ + ocp_nlp_workspace *nlp_work; + + // temp QP in & out (to be used as workspace in param sens) + ocp_qp_in *tmp_qp_in; + ocp_qp_out *tmp_qp_out; + + // qp residuals + ocp_qp_res *qp_res; + ocp_qp_res_ws *qp_res_ws; + + +} ocp_nlp_sqp_rti_workspace; + +// +acados_size_t ocp_nlp_sqp_rti_workspace_calculate_size(void *config_, void *dims_, void *opts_); + + + +/************************************************ + * functions + ************************************************/ + +void ocp_nlp_sqp_rti_preparation_step(void *config_, void *dims_, + void *nlp_in_, void *nlp_out_, void *opts, void *mem_, void *work_); +// +void ocp_nlp_sqp_rti_feedback_step(void *config_, void *dims_, + void *nlp_in_, void *nlp_out_, void *opts_, void *mem_, void *work_); +// +int ocp_nlp_sqp_rti(void *config_, void *dims_, void *nlp_in_, void *nlp_out_, + void *opts_, void *mem_, void *work_); +// +void ocp_nlp_sqp_rti_config_initialize_default(void *config_); +// +int ocp_nlp_sqp_rti_precompute(void *config_, void *dims_, + void *nlp_in_, void *nlp_out_, void *opts_, void *mem_, void *work_); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_NLP_OCP_NLP_SQP_RTI_H_ +/// @} +/// @} +/// @} diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_common.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_common.h new file mode 100644 index 00000000000000..bba55f8f754903 --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_common.h @@ -0,0 +1,182 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_COMMON_H_ +#define ACADOS_OCP_QP_OCP_QP_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// hpipm +#include "hpipm/include/hpipm_d_ocp_qp.h" +#include "hpipm/include/hpipm_d_ocp_qp_dim.h" +#include "hpipm/include/hpipm_d_ocp_qp_res.h" +#include "hpipm/include/hpipm_d_ocp_qp_sol.h" +// acados +#include "acados/utils/types.h" + + + +typedef struct d_ocp_qp_dim ocp_qp_dims; +typedef struct d_ocp_qp ocp_qp_in; +typedef struct d_ocp_qp_sol ocp_qp_out; +typedef struct d_ocp_qp_res ocp_qp_res; +typedef struct d_ocp_qp_res_ws ocp_qp_res_ws; + + + +#ifndef QP_SOLVER_CONFIG_ +#define QP_SOLVER_CONFIG_ +typedef struct +{ + void (*dims_set)(void *config_, void *dims_, int stage, const char *field, int* value); + acados_size_t (*opts_calculate_size)(void *config, void *dims); + void *(*opts_assign)(void *config, void *dims, void *raw_memory); + void (*opts_initialize_default)(void *config, void *dims, void *opts); + void (*opts_update)(void *config, void *dims, void *opts); + void (*opts_set)(void *config_, void *opts_, const char *field, void* value); + acados_size_t (*memory_calculate_size)(void *config, void *dims, void *opts); + void *(*memory_assign)(void *config, void *dims, void *opts, void *raw_memory); + void (*memory_get)(void *config_, void *mem_, const char *field, void* value); + acados_size_t (*workspace_calculate_size)(void *config, void *dims, void *opts); + int (*evaluate)(void *config, void *qp_in, void *qp_out, void *opts, void *mem, void *work); + void (*eval_sens)(void *config, void *qp_in, void *qp_out, void *opts, void *mem, void *work); +} qp_solver_config; +#endif + + + +typedef struct +{ + acados_size_t (*dims_calculate_size)(void *config, int N); + void *(*dims_assign)(void *config, int N, void *raw_memory); + void (*dims_set)(void *config, void *dims_, int stage, const char *field, int* value); + void (*dims_get)(void *config, void *dims, const char *field, void* value); + // TODO add config everywhere !!!!! + acados_size_t (*opts_calculate_size)(void *dims); + void *(*opts_assign)(void *dims, void *raw_memory); + void (*opts_initialize_default)(void *dims, void *opts); + void (*opts_update)(void *dims, void *opts); + void (*opts_set)(void *opts_, const char *field, void* value); + acados_size_t (*memory_calculate_size)(void *dims, void *opts); + void *(*memory_assign)(void *dims, void *opts, void *raw_memory); + void (*memory_get)(void *config, void *mem, const char *field, void* value); + acados_size_t (*workspace_calculate_size)(void *dims, void *opts); + int (*condensing)(void *qp_in, void *qp_out, void *opts, void *mem, void *work); + int (*condensing_rhs)(void *qp_in, void *qp_out, void *opts, void *mem, void *work); + int (*expansion)(void *qp_in, void *qp_out, void *opts, void *mem, void *work); +} ocp_qp_xcond_config; + + + +/// Struct containing metrics of the qp solver. +#ifndef QP_INFO_ +#define QP_INFO_ +typedef struct +{ + double solve_QP_time; + double condensing_time; + double interface_time; + double total_time; + int num_iter; + int t_computed; +} qp_info; +#endif + + + +/* config */ +// +acados_size_t ocp_qp_solver_config_calculate_size(); +// +qp_solver_config *ocp_qp_solver_config_assign(void *raw_memory); +// +acados_size_t ocp_qp_condensing_config_calculate_size(); +// +ocp_qp_xcond_config *ocp_qp_condensing_config_assign(void *raw_memory); + + +/* dims */ +// +acados_size_t ocp_qp_dims_calculate_size(int N); +// +ocp_qp_dims *ocp_qp_dims_assign(int N, void *raw_memory); +// +void ocp_qp_dims_set(void *config_, void *dims, int stage, const char *field, int* value); +// +void ocp_qp_dims_get(void *config_, void *dims, int stage, const char *field, int* value); + + +/* in */ +// +acados_size_t ocp_qp_in_calculate_size(ocp_qp_dims *dims); +// +ocp_qp_in *ocp_qp_in_assign(ocp_qp_dims *dims, void *raw_memory); + + +/* out */ +// +acados_size_t ocp_qp_out_calculate_size(ocp_qp_dims *dims); +// +ocp_qp_out *ocp_qp_out_assign(ocp_qp_dims *dims, void *raw_memory); + +/* res */ +// +acados_size_t ocp_qp_res_calculate_size(ocp_qp_dims *dims); +// +ocp_qp_res *ocp_qp_res_assign(ocp_qp_dims *dims, void *raw_memory); +// +acados_size_t ocp_qp_res_workspace_calculate_size(ocp_qp_dims *dims); +// +ocp_qp_res_ws *ocp_qp_res_workspace_assign(ocp_qp_dims *dims, void *raw_memory); +// +void ocp_qp_res_compute(ocp_qp_in *qp_in, ocp_qp_out *qp_out, ocp_qp_res *qp_res, ocp_qp_res_ws *res_ws); +// +void ocp_qp_res_compute_nrm_inf(ocp_qp_res *qp_res, double res[4]); + + +/* misc */ +// +void ocp_qp_stack_slacks_dims(ocp_qp_dims *in, ocp_qp_dims *out); +// +void ocp_qp_stack_slacks(ocp_qp_in *in, ocp_qp_in *out); +// +void ocp_qp_compute_t(ocp_qp_in *qp_in, ocp_qp_out *qp_out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_COMMON_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_common_frontend.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_common_frontend.h new file mode 100644 index 00000000000000..50b80850c6a33c --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_common_frontend.h @@ -0,0 +1,121 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_COMMON_FRONTEND_H_ +#define ACADOS_OCP_QP_OCP_QP_COMMON_FRONTEND_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/ocp_qp/ocp_qp_common.h" + +typedef struct +{ + int N; + int *nx; + int *nu; + int *nb; + int *nc; + double **A; + double **B; + double **b; + double **Q; + double **S; + double **R; + double **q; + double **r; + int **idxb; + double **lb; + double **ub; + double **Cx; + double **Cu; + double **lc; + double **uc; +} colmaj_ocp_qp_in; + +typedef struct +{ + double **x; + double **u; + double **pi; + double **lam; +} colmaj_ocp_qp_out; + +typedef struct +{ + double **res_r; + double **res_q; + double **res_ls; + double **res_us; + double **res_b; + double **res_d_lb; + double **res_d_ub; + double **res_d_lg; + double **res_d_ug; + double **res_d_ls; + double **res_d_us; + double **res_m_lb; + double **res_m_ub; + double **res_m_lg; + double **res_m_ug; + double **res_m_ls; + double **res_m_us; + double res_nrm_inf[4]; +} colmaj_ocp_qp_res; + +// +acados_size_t colmaj_ocp_qp_in_calculate_size(ocp_qp_dims *dims); +// +char *assign_colmaj_ocp_qp_in(ocp_qp_dims *dims, colmaj_ocp_qp_in **qp_in, void *ptr); +// +acados_size_t colmaj_ocp_qp_out_calculate_size(ocp_qp_dims *dims); +// +char *assign_colmaj_ocp_qp_out(ocp_qp_dims *dims, colmaj_ocp_qp_out **qp_out, void *ptr); +// +acados_size_t colmaj_ocp_qp_res_calculate_size(ocp_qp_dims *dims); +// +char *assign_colmaj_ocp_qp_res(ocp_qp_dims *dims, colmaj_ocp_qp_res **qp_res, void *ptr); +// +void convert_colmaj_to_ocp_qp_in(colmaj_ocp_qp_in *cm_qp_in, ocp_qp_in *qp_in); +// +void convert_ocp_qp_out_to_colmaj(ocp_qp_out *qp_out, colmaj_ocp_qp_out *cm_qp_out); +// +void convert_ocp_qp_res_to_colmaj(ocp_qp_res *qp_res, colmaj_ocp_qp_res *cm_qp_res); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_COMMON_FRONTEND_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_full_condensing.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_full_condensing.h new file mode 100644 index 00000000000000..14ac97bbf4eace --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_full_condensing.h @@ -0,0 +1,117 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_FULL_CONDENSING_H_ +#define ACADOS_OCP_QP_OCP_QP_FULL_CONDENSING_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// hpipm +#include "hpipm/include/hpipm_d_ocp_qp_red.h" +// acados +#include "acados/dense_qp/dense_qp_common.h" +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/types.h" + + + +typedef struct +{ + ocp_qp_dims *orig_dims; + ocp_qp_dims *red_dims; // dims of reduced qp + dense_qp_dims *fcond_dims; +} ocp_qp_full_condensing_dims; + + + +typedef struct ocp_qp_full_condensing_opts_ +{ + struct d_cond_qp_arg *hpipm_cond_opts; + struct d_ocp_qp_reduce_eq_dof_arg *hpipm_red_opts; +// dense_qp_dims *fcond_dims; // TODO(all): move to dims + int cond_hess; // 0 cond only rhs, 1 cond hess + rhs + int expand_dual_sol; // 0 primal sol only, 1 primal + dual sol + int ric_alg; + int mem_qp_in; // allocate qp_in in memory +} ocp_qp_full_condensing_opts; + + + +typedef struct ocp_qp_full_condensing_memory_ +{ + struct d_cond_qp_ws *hpipm_cond_work; + struct d_ocp_qp_reduce_eq_dof_ws *hpipm_red_work; + // in memory + dense_qp_in *fcond_qp_in; + dense_qp_out *fcond_qp_out; + ocp_qp_in *red_qp; // reduced qp + ocp_qp_out *red_sol; // reduced qp sol + // only pointer + ocp_qp_in *ptr_qp_in; + qp_info *qp_out_info; // info in fcond_qp_in + double time_qp_xcond; +} ocp_qp_full_condensing_memory; + + + +// +acados_size_t ocp_qp_full_condensing_opts_calculate_size(void *dims); +// +void *ocp_qp_full_condensing_opts_assign(void *dims, void *raw_memory); +// +void ocp_qp_full_condensing_opts_initialize_default(void *dims, void *opts_); +// +void ocp_qp_full_condensing_opts_update(void *dims, void *opts_); +// +void ocp_qp_full_condensing_opts_set(void *opts_, const char *field, void* value); +// +acados_size_t ocp_qp_full_condensing_memory_calculate_size(void *dims, void *opts_); +// +void *ocp_qp_full_condensing_memory_assign(void *dims, void *opts_, void *raw_memory); +// +acados_size_t ocp_qp_full_condensing_workspace_calculate_size(void *dims, void *opts_); +// +int ocp_qp_full_condensing(void *in, void *out, void *opts, void *mem, void *work); +// +int ocp_qp_full_expansion(void *in, void *out, void *opts, void *mem, void *work); +// +void ocp_qp_full_condensing_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_FULL_CONDENSING_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_hpipm.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_hpipm.h new file mode 100644 index 00000000000000..84e874863f93f6 --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_hpipm.h @@ -0,0 +1,100 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_HPIPM_H_ +#define ACADOS_OCP_QP_OCP_QP_HPIPM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// hpipm +#include "hpipm/include/hpipm_d_ocp_qp_ipm.h" +// acados +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/types.h" + + + +// struct of arguments to the solver +// TODO(roversch): why not make this a typedef of the underlying struct? +typedef struct ocp_qp_hpipm_opts_ +{ + struct d_ocp_qp_ipm_arg *hpipm_opts; +} ocp_qp_hpipm_opts; + + + +// TODO(roversch): why not make this a typedef of the underlying struct? +// struct of the solver memory +typedef struct ocp_qp_hpipm_memory_ +{ + struct d_ocp_qp_ipm_ws *hpipm_workspace; + double time_qp_solver_call; + int iter; + +} ocp_qp_hpipm_memory; + + + +// +acados_size_t ocp_qp_hpipm_opts_calculate_size(void *config, void *dims); +// +void *ocp_qp_hpipm_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_qp_hpipm_opts_initialize_default(void *config, void *dims, void *opts_); +// +void ocp_qp_hpipm_opts_update(void *config, void *dims, void *opts_); +// +void ocp_qp_hpipm_opts_set(void *config_, void *opts_, const char *field, void *value); +// +acados_size_t ocp_qp_hpipm_memory_calculate_size(void *config, void *dims, void *opts_); +// +void *ocp_qp_hpipm_memory_assign(void *config, void *dims, void *opts_, void *raw_memory); +// +acados_size_t ocp_qp_hpipm_workspace_calculate_size(void *config, void *dims, void *opts_); +// +int ocp_qp_hpipm(void *config, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_hpipm_eval_sens(void *config, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_hpipm_config_initialize_default(void *config); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_HPIPM_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_hpmpc.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_hpmpc.h new file mode 100644 index 00000000000000..37d1c0a337c760 --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_hpmpc.h @@ -0,0 +1,129 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_HPMPC_H_ +#define ACADOS_OCP_QP_OCP_QP_HPMPC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/types.h" + +typedef enum hpmpc_options_t_ { HPMPC_DEFAULT_ARGUMENTS } hpmpc_options_t; + +typedef struct ocp_qp_hpmpc_opts_ +{ + double tol; + int max_iter; + double mu0; + double alpha_min; + int warm_start; + int N2; // horizion length of the partially condensed problem + + // partial tightening + double sigma_mu; + int N; + int M; +} ocp_qp_hpmpc_opts; + +// struct of the solver memory +typedef struct ocp_qp_hpmpc_memory_ +{ + struct blasfeo_dvec *hpi; + double *stats; + + // workspace + void *hpmpc_work; // raw workspace + + // partial tightening-specific (init of extra variables) + struct blasfeo_dvec *lam0; + struct blasfeo_dvec *ux0; + struct blasfeo_dvec *pi0; + struct blasfeo_dvec *t0; + + // 2. workspace + struct blasfeo_dmat *hsL; + struct blasfeo_dmat *hsric_work_mat; + struct blasfeo_dmat sLxM; + struct blasfeo_dmat sPpM; + + struct blasfeo_dvec *hsQx; + struct blasfeo_dvec *hsqx; + struct blasfeo_dvec *hstinv; + struct blasfeo_dvec *hsrq; + struct blasfeo_dvec *hsdux; + + struct blasfeo_dvec *hsdlam; + struct blasfeo_dvec *hsdt; + struct blasfeo_dvec *hsdpi; + struct blasfeo_dvec *hslamt; + + struct blasfeo_dvec *hsPb; + + void *work_ric; + + int out_iter; + + double time_qp_solver_call; + int iter; + +} ocp_qp_hpmpc_memory; + +acados_size_t ocp_qp_hpmpc_opts_calculate_size(void *config_, ocp_qp_dims *dims); +// +void *ocp_qp_hpmpc_opts_assign(void *config_, ocp_qp_dims *dims, void *raw_memory); +// +void ocp_qp_hpmpc_opts_initialize_default(void *config_, ocp_qp_dims *dims, void *opts_); +// +void ocp_qp_hpmpc_opts_update(void *config_, ocp_qp_dims *dims, void *opts_); +// +acados_size_t ocp_qp_hpmpc_memory_calculate_size(void *config_, ocp_qp_dims *dims, void *opts_); +// +void *ocp_qp_hpmpc_memory_assign(void *config_, ocp_qp_dims *dims, void *opts_, void *raw_memory); +// +acados_size_t ocp_qp_hpmpc_workspace_calculate_size(void *config_, ocp_qp_dims *dims, void *opts_); +// +int ocp_qp_hpmpc(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_hpmpc_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_hpmpc_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_HPMPC_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_ooqp.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_ooqp.h new file mode 100644 index 00000000000000..e1b789b96aef75 --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_ooqp.h @@ -0,0 +1,146 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_OOQP_H_ +#define ACADOS_OCP_QP_OCP_QP_OOQP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/types.h" + +enum ocp_qp_ooqp_termination_code +{ + SPARSE_SUCCESSFUL_TERMINATION = 0, + SPARSE_NOT_FINISHED, + SPARSE_MAX_ITS_EXCEEDED, + SPARSE_INFEASIBLE, + SPARSE_UNKNOWN +}; + +typedef struct ocp_qp_ooqp_opts_ +{ + int printLevel; + int useDiagonalWeights; // TODO(dimitris): implement option + int fixHessian; + int fixHessianSparsity; + int fixDynamics; + int fixDynamicsSparsity; + int fixInequalities; + int fixInequalitiesSparsity; +} ocp_qp_ooqp_opts; + +typedef struct ocp_qp_ooqp_workspace_ +{ + double *x; + double *gamma; + double *phi; + double *y; + double *z; + double *lambda; + double *pi; + double objectiveValue; + int *tmpInt; // temporary vector to sort indicies sparse matrices + double *tmpReal; // temporary vector to sort data of sparse matrices + // int ierr; +} ocp_qp_ooqp_workspace; + +typedef struct ocp_qp_ooqp_memory_ +{ + int firstRun; + double *c; + int nx; + int *irowQ; + int nnzQ; + int *jcolQ; + int *orderQ; + double *dQ; + double *xlow; + char *ixlow; + double *xupp; + char *ixupp; + int *irowA; + int nnzA; + int *jcolA; + int *orderA; + double *dA; + double *bA; + int my; + int *irowC; + int nnzC; + int *jcolC; + int *orderC; + double *dC; + double *clow; + int mz; + char *iclow; + double *cupp; + char *icupp; + int nnz; // max(nnzQ, nnzA, nnzC) + double time_qp_solver_call; + int iter; + +} ocp_qp_ooqp_memory; + +// +acados_size_t ocp_qp_ooqp_opts_calculate_size(void *config_, ocp_qp_dims *dims); +// +void *ocp_qp_ooqp_opts_assign(void *config_, ocp_qp_dims *dims, void *raw_memory); +// +void ocp_qp_ooqp_opts_initialize_default(void *config_, ocp_qp_dims *dims, void *opts_); +// +void ocp_qp_ooqp_opts_update(void *config_, ocp_qp_dims *dims, void *opts_); +// +acados_size_t ocp_qp_ooqp_memory_calculate_size(void *config_, ocp_qp_dims *dims, void *opts_); +// +void *ocp_qp_ooqp_memory_assign(void *config_, ocp_qp_dims *dims, void *opts_, void *raw_memory); +// +acados_size_t ocp_qp_ooqp_workspace_calculate_size(void *config_, ocp_qp_dims *dims, void *opts_); +// +int ocp_qp_ooqp(void *config_, ocp_qp_in *qp_in, ocp_qp_out *qp_out, void *opts_, void *memory_, + void *work_); +// +void ocp_qp_ooqp_destroy(void *mem_, void *work); +// +void ocp_qp_ooqp_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_ooqp_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_OOQP_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_osqp.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_osqp.h new file mode 100644 index 00000000000000..55321a46b2a66e --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_osqp.h @@ -0,0 +1,105 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_OSQP_H_ +#define ACADOS_OCP_QP_OCP_QP_OSQP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// osqp +#include "osqp/include/types.h" + +// acados +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/types.h" + +typedef struct ocp_qp_osqp_opts_ +{ + OSQPSettings *osqp_opts; +} ocp_qp_osqp_opts; + + +typedef struct ocp_qp_osqp_memory_ +{ + c_int first_run; + + c_float *q; + c_float *l; + c_float *u; + + c_int P_nnzmax; + c_int *P_i; + c_int *P_p; + c_float *P_x; + + c_int A_nnzmax; + c_int *A_i; + c_int *A_p; + c_float *A_x; + + OSQPData *osqp_data; + OSQPWorkspace *osqp_work; + + double time_qp_solver_call; + int iter; + +} ocp_qp_osqp_memory; + +acados_size_t ocp_qp_osqp_opts_calculate_size(void *config, void *dims); +// +void *ocp_qp_osqp_opts_assign(void *config, void *dims, void *raw_memory); +// +void ocp_qp_osqp_opts_initialize_default(void *config, void *dims, void *opts_); +// +void ocp_qp_osqp_opts_update(void *config, void *dims, void *opts_); +// +acados_size_t ocp_qp_osqp_memory_calculate_size(void *config, void *dims, void *opts_); +// +void *ocp_qp_osqp_memory_assign(void *config, void *dims, void *opts_, void *raw_memory); +// +acados_size_t ocp_qp_osqp_workspace_calculate_size(void *config, void *dims, void *opts_); +// +int ocp_qp_osqp(void *config, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_osqp_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_osqp_config_initialize_default(void *config); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_OSQP_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_partial_condensing.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_partial_condensing.h new file mode 100644 index 00000000000000..b95a11114eb95d --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_partial_condensing.h @@ -0,0 +1,123 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_PARTIAL_CONDENSING_H_ +#define ACADOS_OCP_QP_OCP_QP_PARTIAL_CONDENSING_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// hpipm +#include "hpipm/include/hpipm_d_ocp_qp_red.h" +// acados +#include "acados/ocp_qp/ocp_qp_common.h" + + + +typedef struct +{ + ocp_qp_dims *orig_dims; + ocp_qp_dims *red_dims; // dims of reduced qp + ocp_qp_dims *pcond_dims; + int *block_size; + int N2; + int N2_bkp; +} ocp_qp_partial_condensing_dims; + + + +typedef struct ocp_qp_partial_condensing_opts_ +{ + struct d_part_cond_qp_arg *hpipm_pcond_opts; + struct d_ocp_qp_reduce_eq_dof_arg *hpipm_red_opts; +// ocp_qp_dims *pcond_dims; // TODO(all): move to dims +// int *block_size; + int N2; + int N2_bkp; +// int expand_dual_sol; // 0 primal sol only, 1 primal + dual sol + int ric_alg; + int mem_qp_in; // allocate qp_in in memory +} ocp_qp_partial_condensing_opts; + + + +typedef struct ocp_qp_partial_condensing_memory_ +{ + struct d_part_cond_qp_ws *hpipm_pcond_work; + struct d_ocp_qp_reduce_eq_dof_ws *hpipm_red_work; + // in memory + ocp_qp_in *pcond_qp_in; + ocp_qp_out *pcond_qp_out; + ocp_qp_in *red_qp; // reduced qp + ocp_qp_out *red_sol; // reduced qp sol + // only pointer + ocp_qp_in *ptr_qp_in; + ocp_qp_in *ptr_pcond_qp_in; + qp_info *qp_out_info; // info in pcond_qp_in + double time_qp_xcond; +} ocp_qp_partial_condensing_memory; + + + +// +acados_size_t ocp_qp_partial_condensing_opts_calculate_size(void *dims); +// +void *ocp_qp_partial_condensing_opts_assign(void *dims, void *raw_memory); +// +void ocp_qp_partial_condensing_opts_initialize_default(void *dims, void *opts_); +// +void ocp_qp_partial_condensing_opts_update(void *dims, void *opts_); +// +void ocp_qp_partial_condensing_opts_set(void *opts_, const char *field, void* value); +// +acados_size_t ocp_qp_partial_condensing_memory_calculate_size(void *dims, void *opts_); +// +void *ocp_qp_partial_condensing_memory_assign(void *dims, void *opts, void *raw_memory); +// +acados_size_t ocp_qp_partial_condensing_workspace_calculate_size(void *dims, void *opts_); +// +int ocp_qp_partial_condensing(void *in, void *out, void *opts, void *mem, void *work); +// +int ocp_qp_partial_expansion(void *in, void *out, void *opts, void *mem, void *work); +// +void ocp_qp_partial_condensing_config_initialize_default(void *config_); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_PARTIAL_CONDENSING_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_qpdunes.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_qpdunes.h new file mode 100644 index 00000000000000..348627c676f7e1 --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_qpdunes.h @@ -0,0 +1,121 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_QPDUNES_H_ +#define ACADOS_OCP_QP_OCP_QP_QPDUNES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "qpDUNES.h" + +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/types.h" + +typedef enum qpdunes_options_t_ { + QPDUNES_DEFAULT_ARGUMENTS, + QPDUNES_LINEAR_MPC, // TODO(dimitris): partly implemented + QPDUNES_NONLINEAR_MPC, // TODO(dimitris): not implemented yet + QPDUNES_ACADO_SETTINGS +} qpdunes_options_t; + +typedef enum { QPDUNES_WITH_QPOASES, QPDUNES_WITH_CLIPPING } qpdunes_stage_qp_solver_t; + +typedef struct ocp_qp_qpdunes_opts_ +{ + qpOptions_t options; + qpdunes_stage_qp_solver_t stageQpSolver; + int warmstart; // warmstart = 0: all multipliers set to zero, warmstart = 1: use previous mult. + bool isLinearMPC; +} ocp_qp_qpdunes_opts; + +typedef struct ocp_qp_qpdunes_memory_ +{ + int firstRun; + int nx; + int nu; + int nz; + int nDmax; // max(dims->ng) + qpData_t qpData; + double time_qp_solver_call; + int iter; + +} ocp_qp_qpdunes_memory; + +typedef struct ocp_qp_qpdunes_workspace_ +{ + double *H; + double *Q; + double *R; + double *S; + double *g; + double *ABt; + double *b; + double *Ct; + double *lc; + double *uc; + double *zLow; + double *zUpp; +} ocp_qp_qpdunes_workspace; + +// +acados_size_t ocp_qp_qpdunes_opts_calculate_size(void *config_, ocp_qp_dims *dims); +// +void *ocp_qp_qpdunes_opts_assign(void *config_, ocp_qp_dims *dims, void *raw_memory); +// +void ocp_qp_qpdunes_opts_initialize_default(void *config_, ocp_qp_dims *dims, void *opts_); +// +void ocp_qp_qpdunes_opts_update(void *config_, ocp_qp_dims *dims, void *opts_); +// +acados_size_t ocp_qp_qpdunes_memory_calculate_size(void *config_, ocp_qp_dims *dims, void *opts_); +// +void *ocp_qp_qpdunes_memory_assign(void *config_, ocp_qp_dims *dims, void *opts_, void *raw_memory); +// +acados_size_t ocp_qp_qpdunes_workspace_calculate_size(void *config_, ocp_qp_dims *dims, void *opts_); +// +int ocp_qp_qpdunes(void *config_, ocp_qp_in *qp_in, ocp_qp_out *qp_out, void *opts_, void *memory_, + void *work_); +// +void ocp_qp_qpdunes_free_memory(void *mem_); +// +void ocp_qp_qpdunes_eval_sens(void *config_, void *qp_in, void *qp_out, void *opts_, void *mem_, void *work_); +// +void ocp_qp_qpdunes_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_QPDUNES_H_ diff --git a/third_party/acados/include/acados/ocp_qp/ocp_qp_xcond_solver.h b/third_party/acados/include/acados/ocp_qp/ocp_qp_xcond_solver.h new file mode 100644 index 00000000000000..9d4f309bd9a552 --- /dev/null +++ b/third_party/acados/include/acados/ocp_qp/ocp_qp_xcond_solver.h @@ -0,0 +1,151 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_OCP_QP_OCP_QP_PARTIAL_CONDENSING_SOLVER_H_ +#define ACADOS_OCP_QP_OCP_QP_PARTIAL_CONDENSING_SOLVER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/utils/types.h" + + + +typedef struct +{ + ocp_qp_dims *orig_dims; + void *xcond_dims; +} ocp_qp_xcond_solver_dims; + + + +typedef struct ocp_qp_xcond_solver_opts_ +{ + void *xcond_opts; + void *qp_solver_opts; +} ocp_qp_xcond_solver_opts; + + + +typedef struct ocp_qp_xcond_solver_memory_ +{ + void *xcond_memory; + void *solver_memory; + void *xcond_qp_in; + void *xcond_qp_out; +} ocp_qp_xcond_solver_memory; + + + +typedef struct ocp_qp_xcond_solver_workspace_ +{ + void *xcond_work; + void *qp_solver_work; +} ocp_qp_xcond_solver_workspace; + + + +typedef struct +{ + acados_size_t (*dims_calculate_size)(void *config, int N); + ocp_qp_xcond_solver_dims *(*dims_assign)(void *config, int N, void *raw_memory); + void (*dims_set)(void *config_, ocp_qp_xcond_solver_dims *dims, int stage, const char *field, int* value); + acados_size_t (*opts_calculate_size)(void *config, ocp_qp_xcond_solver_dims *dims); + void *(*opts_assign)(void *config, ocp_qp_xcond_solver_dims *dims, void *raw_memory); + void (*opts_initialize_default)(void *config, ocp_qp_xcond_solver_dims *dims, void *opts); + void (*opts_update)(void *config, ocp_qp_xcond_solver_dims *dims, void *opts); + void (*opts_set)(void *config_, void *opts_, const char *field, void* value); + acados_size_t (*memory_calculate_size)(void *config, ocp_qp_xcond_solver_dims *dims, void *opts); + void *(*memory_assign)(void *config, ocp_qp_xcond_solver_dims *dims, void *opts, void *raw_memory); + void (*memory_get)(void *config_, void *mem_, const char *field, void* value); + acados_size_t (*workspace_calculate_size)(void *config, ocp_qp_xcond_solver_dims *dims, void *opts); + int (*evaluate)(void *config, ocp_qp_xcond_solver_dims *dims, ocp_qp_in *qp_in, ocp_qp_out *qp_out, void *opts, void *mem, void *work); + void (*eval_sens)(void *config, ocp_qp_xcond_solver_dims *dims, ocp_qp_in *param_qp_in, ocp_qp_out *sens_qp_out, void *opts, void *mem, void *work); + qp_solver_config *qp_solver; // either ocp_qp_solver or dense_solver + ocp_qp_xcond_config *xcond; +} ocp_qp_xcond_solver_config; // pcond - partial condensing or fcond - full condensing + + + +/* config */ +// +acados_size_t ocp_qp_xcond_solver_config_calculate_size(); +// +ocp_qp_xcond_solver_config *ocp_qp_xcond_solver_config_assign(void *raw_memory); + +/* dims */ +// +acados_size_t ocp_qp_xcond_solver_dims_calculate_size(void *config, int N); +// +ocp_qp_xcond_solver_dims *ocp_qp_xcond_solver_dims_assign(void *config, int N, void *raw_memory); +// +void ocp_qp_xcond_solver_dims_set_(void *config, ocp_qp_xcond_solver_dims *dims, int stage, const char *field, int* value); + +/* opts */ +// +acados_size_t ocp_qp_xcond_solver_opts_calculate_size(void *config, ocp_qp_xcond_solver_dims *dims); +// +void *ocp_qp_xcond_solver_opts_assign(void *config, ocp_qp_xcond_solver_dims *dims, void *raw_memory); +// +void ocp_qp_xcond_solver_opts_initialize_default(void *config, ocp_qp_xcond_solver_dims *dims, void *opts_); +// +void ocp_qp_xcond_solver_opts_update(void *config, ocp_qp_xcond_solver_dims *dims, void *opts_); +// +void ocp_qp_xcond_solver_opts_set_(void *config_, void *opts_, const char *field, void* value); + +/* memory */ +// +acados_size_t ocp_qp_xcond_solver_memory_calculate_size(void *config, ocp_qp_xcond_solver_dims *dims, void *opts_); +// +void *ocp_qp_xcond_solver_memory_assign(void *config, ocp_qp_xcond_solver_dims *dims, void *opts_, void *raw_memory); + +/* workspace */ +// +acados_size_t ocp_qp_xcond_solver_workspace_calculate_size(void *config, ocp_qp_xcond_solver_dims *dims, void *opts_); + +/* config */ +// +int ocp_qp_xcond_solver(void *config, ocp_qp_xcond_solver_dims *dims, ocp_qp_in *qp_in, ocp_qp_out *qp_out, void *opts_, void *mem_, void *work_); + +// +void ocp_qp_xcond_solver_config_initialize_default(void *config_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_OCP_QP_OCP_QP_PARTIAL_CONDENSING_SOLVER_H_ diff --git a/third_party/acados/include/acados/sim/sim_collocation_utils.h b/third_party/acados/include/acados/sim/sim_collocation_utils.h new file mode 100644 index 00000000000000..40a0b1c0cc103c --- /dev/null +++ b/third_party/acados/include/acados/sim/sim_collocation_utils.h @@ -0,0 +1,100 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_SIM_SIM_COLLOCATION_UTILS_H_ +#define ACADOS_SIM_SIM_COLLOCATION_UTILS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/utils/types.h" + + + +// enum Newton_type_collocation +// { +// exact = 0, +// simplified_in, +// simplified_inis +// }; + + + +// typedef struct +// { +// enum Newton_type_collocation type; +// double *eig; +// double *low_tria; +// bool single; +// bool freeze; + +// double *transf1; +// double *transf2; + +// double *transf1_T; +// double *transf2_T; +// } Newton_scheme; + + +typedef enum +{ + GAUSS_LEGENDRE, + GAUSS_RADAU_IIA, +} sim_collocation_type; + + +// +// acados_size_t gauss_legendre_nodes_work_calculate_size(int ns); +// +// void gauss_legendre_nodes(int ns, double *nodes, void *raw_memory); +// +// acados_size_t gauss_simplified_work_calculate_size(int ns); +// // +// void gauss_simplified(int ns, Newton_scheme *scheme, void *work); +// +acados_size_t butcher_tableau_work_calculate_size(int ns); +// +// void calculate_butcher_tableau_from_nodes(int ns, double *nodes, double *b, double *A, void *work); +// +void calculate_butcher_tableau(int ns, sim_collocation_type collocation_type, double *c_vec, + double *b_vec, double *A_mat, void *work); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_SIM_SIM_COLLOCATION_UTILS_H_ diff --git a/third_party/acados/include/acados/sim/sim_common.h b/third_party/acados/include/acados/sim/sim_common.h new file mode 100644 index 00000000000000..1838d76f819d81 --- /dev/null +++ b/third_party/acados/include/acados/sim/sim_common.h @@ -0,0 +1,222 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_SIM_SIM_COMMON_H_ +#define ACADOS_SIM_SIM_COMMON_H_ + +#include + +#include "acados/sim/sim_collocation_utils.h" +#include "acados/utils/timing.h" +#include "acados/utils/types.h" + +#include "acados/utils/external_function_generic.h" + +// maximum number of integration stages +#define NS_MAX 15 + + + +typedef enum +{ + // ERK and LIFTED_ERK + EXPL_ODE_FUN, + EXPL_ODE_HES, // wrt x and u ??? + EXPL_VDE_FOR, + EXPL_VDE_ADJ, + // IRK + IMPL_ODE_FUN, + IMPL_ODE_FUN_JAC_X_XDOT, + IMPL_ODE_JAC_X_XDOT_U, + IMPL_ODE_FUN_JAC_X_XDOT_U, + IMPL_ODE_HESS, + // gnsf + PHI_FUN, + PHI_FUN_JAC_Y, + PHI_JAC_Y_UHAT, + LO_FUN, + GET_GNSF_MATRICES +} sim_function_t; + + + +typedef struct +{ + void *dims; + + double *x; // x[NX] - initial state value for simulation + double *u; // u[NU] - control - constant over simulation time + + double *S_forw; // forward seed [Sx, Su] + double *S_adj; // backward seed + + bool identity_seed; // indicating if S_forw = [eye(nx), zeros(nx x nu)] + + void *model; + + double T; // simulation time + +} sim_in; + + + +typedef struct +{ + double CPUtime; // in seconds + double LAtime; // in seconds + double ADtime; // in seconds + +} sim_info; + + + +typedef struct +{ + double *xn; // xn[NX] + double *S_forw; // S_forw[NX*(NX+NU)] + double *S_adj; // + double *S_hess; // + + double *zn; // z - algebraic variables - reported at start of simulation interval + double *S_algebraic; // sensitivities of reported value of algebraic variables w.r.t. + // initial stat & control (x_n,u) + + double *grad; // gradient correction + + sim_info *info; + +} sim_out; + + + +typedef struct +{ + int ns; // number of integration stages + + int num_steps; + int num_forw_sens; + + int tableau_size; // check that is consistent with ns + // only update when butcher tableau is changed + // kind of private -> no setter! + double *A_mat; + double *c_vec; + double *b_vec; + + bool sens_forw; + bool sens_adj; + bool sens_hess; + + bool output_z; // 1 -- if zn should be computed + bool sens_algebraic; // 1 -- if S_algebraic should be computed + bool exact_z_output; // 1 -- if z, S_algebraic should be computed exactly, extra Newton iterations + sim_collocation_type collocation_type; + + // for explicit integrators: newton_iter == 0 && scheme == NULL + // && jac_reuse=false + int newton_iter; + bool jac_reuse; + // Newton_scheme *scheme; + + // workspace + void *work; + +} sim_opts; + + + +typedef struct +{ + int (*evaluate)(void *config_, sim_in *in, sim_out *out, void *opts, void *mem, void *work); + int (*precompute)(void *config_, sim_in *in, sim_out *out, void *opts, void *mem, void *work); + // opts + acados_size_t (*opts_calculate_size)(void *config_, void *dims); + void *(*opts_assign)(void *config_, void *dims, void *raw_memory); + void (*opts_initialize_default)(void *config_, void *dims, void *opts); + void (*opts_update)(void *config_, void *dims, void *opts); + void (*opts_set)(void *config_, void *opts_, const char *field, void *value); + void (*opts_get)(void *config_, void *opts_, const char *field, void *value); + // mem + acados_size_t (*memory_calculate_size)(void *config, void *dims, void *opts); + void *(*memory_assign)(void *config, void *dims, void *opts, void *raw_memory); + int (*memory_set)(void *config, void *dims, void *mem, const char *field, void *value); + int (*memory_set_to_zero)(void *config, void *dims, void *opts, void *mem, const char *field); + void (*memory_get)(void *config, void *dims, void *mem, const char *field, void *value); + // work + acados_size_t (*workspace_calculate_size)(void *config, void *dims, void *opts); + // model + acados_size_t (*model_calculate_size)(void *config, void *dims); + void *(*model_assign)(void *config, void *dims, void *raw_memory); + int (*model_set)(void *model, const char *field, void *value); + // config + void (*config_initialize_default)(void *config); + // dims + acados_size_t (*dims_calculate_size)(); + void *(*dims_assign)(void *config, void *raw_memory); + void (*dims_set)(void *config, void *dims, const char *field, const int *value); + void (*dims_get)(void *config, void *dims, const char *field, int *value); + +} sim_config; + + + +/* config */ +// +acados_size_t sim_config_calculate_size(); +// +sim_config *sim_config_assign(void *raw_memory); + +/* in */ +// +acados_size_t sim_in_calculate_size(void *config, void *dims); +// +sim_in *sim_in_assign(void *config, void *dims, void *raw_memory); +// +int sim_in_set_(void *config_, void *dims_, sim_in *in, const char *field, void *value); + +/* out */ +// +acados_size_t sim_out_calculate_size(void *config, void *dims); +// +sim_out *sim_out_assign(void *config, void *dims, void *raw_memory); +// +int sim_out_get_(void *config, void *dims, sim_out *out, const char *field, void *value); + +/* opts */ +// +void sim_opts_set_(sim_opts *opts, const char *field, void *value); +// +void sim_opts_get_(sim_config *config, sim_opts *opts, const char *field, void *value); + +#endif // ACADOS_SIM_SIM_COMMON_H_ diff --git a/third_party/acados/include/acados/sim/sim_erk_integrator.h b/third_party/acados/include/acados/sim/sim_erk_integrator.h new file mode 100644 index 00000000000000..24a00c70774090 --- /dev/null +++ b/third_party/acados/include/acados/sim/sim_erk_integrator.h @@ -0,0 +1,143 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_SIM_SIM_ERK_INTEGRATOR_H_ +#define ACADOS_SIM_SIM_ERK_INTEGRATOR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/sim/sim_common.h" +#include "acados/utils/types.h" + + + +typedef struct +{ + int nx; + int nu; + int nz; +} sim_erk_dims; + + + +typedef struct +{ + /* external functions */ + // explicit ode + external_function_generic *expl_ode_fun; + // hessian explicit ode + external_function_generic *expl_ode_hes; + // forward explicit vde + external_function_generic *expl_vde_for; + // adjoint explicit vde + external_function_generic *expl_vde_adj; + +} erk_model; + + + +typedef struct +{ + // memory + double time_sim; + double time_ad; + double time_la; + + // workspace structs +} sim_erk_memory; + + + +typedef struct +{ + // workspace mem + double *rhs_forw_in; // x + S + p + + double *K_traj; // (stages*nX) or (steps*stages*nX) for adj + double *out_forw_traj; // S or (steps+1)*nX for adj + + double *rhs_adj_in; + double *out_adj_tmp; + double *adj_traj; + +} sim_erk_workspace; + + + +// dims +acados_size_t sim_erk_dims_calculate_size(); +void *sim_erk_dims_assign(void *config_, void *raw_memory); +void sim_erk_dims_set(void *config_, void *dims_, const char *field, const int* value); +void sim_erk_dims_get(void *config_, void *dims_, const char *field, int* value); + +// model +acados_size_t sim_erk_model_calculate_size(void *config, void *dims); +void *sim_erk_model_assign(void *config, void *dims, void *raw_memory); +int sim_erk_model_set(void *model, const char *field, void *value); + +// opts +acados_size_t sim_erk_opts_calculate_size(void *config, void *dims); +// +void sim_erk_opts_update(void *config_, void *dims, void *opts_); +// +void *sim_erk_opts_assign(void *config, void *dims, void *raw_memory); +// +void sim_erk_opts_initialize_default(void *config, void *dims, void *opts_); +// +void sim_erk_opts_set(void *config_, void *opts_, const char *field, void *value); + + +// memory +acados_size_t sim_erk_memory_calculate_size(void *config, void *dims, void *opts_); +// +void *sim_erk_memory_assign(void *config, void *dims, void *opts_, void *raw_memory); +// +int sim_erk_memory_set(void *config_, void *dims_, void *mem_, const char *field, void *value); + + +// workspace +acados_size_t sim_erk_workspace_calculate_size(void *config, void *dims, void *opts_); + +// +int sim_erk(void *config, sim_in *in, sim_out *out, void *opts_, void *mem_, void *work_); +// +void sim_erk_config_initialize_default(void *config); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_SIM_SIM_ERK_INTEGRATOR_H_ diff --git a/third_party/acados/include/acados/sim/sim_gnsf.h b/third_party/acados/include/acados/sim/sim_gnsf.h new file mode 100644 index 00000000000000..5524b384e06c9c --- /dev/null +++ b/third_party/acados/include/acados/sim/sim_gnsf.h @@ -0,0 +1,367 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_SIM_SIM_GNSF_H_ +#define ACADOS_SIM_SIM_GNSF_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "acados/utils/timing.h" +#include "acados/utils/types.h" +#include "acados/sim/sim_common.h" + +#include "blasfeo/include/blasfeo_common.h" +#include "blasfeo/include/blasfeo_d_aux.h" +#include "blasfeo/include/blasfeo_d_aux_ext_dep.h" +#include "blasfeo/include/blasfeo_d_blas.h" +#include "blasfeo/include/blasfeo_d_kernel.h" +#include "blasfeo/include/blasfeo_i_aux_ext_dep.h" +#include "blasfeo/include/blasfeo_target.h" + +/* +GNSF - Generalized Nonlinear Static Feedback Model +has the following form +https://github.com/acados/acados/files/3359595/gnsf_structure_blo.pdf + +Details on the algorithm can be found in master thesis of Jonathan Frey, +which presents a slightly different format without the terms B_LO, c_LO. +https://github.com/acados/acados/files/2318322/gnsf_structure.pdf +https://cdn.syscop.de/publications/Frey2018.pdf +https://cdn.syscop.de/publications/Frey2019.pdf +*/ + +typedef struct +{ + int nx; // total number of differential states + int nu; // total number of inputs + int nz; // total number of algebraic states + int nx1; // number of differential states in NSF part + int nz1; // number of algebraic states in NSF part + int n_out; // output dimension of phi + int ny; // dimension of first input of phi + int nuhat; // dimension of second input of phi + +} sim_gnsf_dims; + + + +typedef struct +{ + /* external functions */ + // phi: nonlinearity function + external_function_generic *phi_fun; + external_function_generic *phi_fun_jac_y; + external_function_generic *phi_jac_y_uhat; + + // f_lo: linear output function + external_function_generic *f_lo_fun_jac_x1_x1dot_u_z; + + // to import model matrices + external_function_generic *get_gnsf_matrices; + + // flag indicating, if model defining matrices are imported via external (casadi) function, + // [default]: true -> auto; + bool auto_import_gnsf; + + // booleans from structure detection + bool nontrivial_f_LO; // indicates if f_LO is constant zero function + bool fully_linear; // indicates if model is fully linear LOS + + /* model defining matrices */ + // TODO: add setters to set manually + double *A; + double *B; + double *C; + double *E; + + double *L_x; + double *L_xdot; + double *L_z; + double *L_u; + + double *A_LO; + double *B_LO; + double *E_LO; + + /* constant vector */ + double *c; + double *c_LO; + + // permutation vector - to have GNSF order of x, z within sim_gnsf only + int *ipiv_x; + int *ipiv_z; + + double *ipiv_x_double; + double *ipiv_z_double; + +} gnsf_model; + + + +// pre_workspace - workspace used in the precomputation phase +typedef struct +{ + struct blasfeo_dmat E11; + struct blasfeo_dmat E12; + struct blasfeo_dmat E21; + struct blasfeo_dmat E22; + + struct blasfeo_dmat A1; + struct blasfeo_dmat A2; + struct blasfeo_dmat B1; + struct blasfeo_dmat B2; + struct blasfeo_dmat C1; + struct blasfeo_dmat C2; + + struct blasfeo_dmat AA1; + struct blasfeo_dmat AA2; + struct blasfeo_dmat BB1; + struct blasfeo_dmat BB2; + struct blasfeo_dmat CC1; + struct blasfeo_dmat CC2; + struct blasfeo_dmat DD1; + struct blasfeo_dmat DD2; + struct blasfeo_dmat EE1; + struct blasfeo_dmat EE2; + + struct blasfeo_dmat QQ1; + + struct blasfeo_dmat LLZ; + struct blasfeo_dmat LLx; + struct blasfeo_dmat LLK; + + int *ipivEE1; // index of pivot vector + int *ipivEE2; + int *ipivQQ1; + + // for algebraic sensitivity propagation + struct blasfeo_dmat Q1; + + // for constant term in NSF + struct blasfeo_dvec cc1; + struct blasfeo_dvec cc2; + +} gnsf_pre_workspace; + + + +// workspace +typedef struct +{ + double *Z_work; // used to perform computations to get out->zn + + int *ipiv; // index of pivot vector + + struct blasfeo_dvec *vv_traj; + struct blasfeo_dvec *yy_traj; + struct blasfeo_dmat *f_LO_jac_traj; + + struct blasfeo_dvec K2_val; + struct blasfeo_dvec x0_traj; + struct blasfeo_dvec res_val; + struct blasfeo_dvec u0; + struct blasfeo_dvec lambda; + struct blasfeo_dvec lambda_old; + + struct blasfeo_dvec yyu; + struct blasfeo_dvec yyss; + + struct blasfeo_dvec K1_val; + struct blasfeo_dvec f_LO_val; + struct blasfeo_dvec x1_stage_val; + struct blasfeo_dvec Z1_val; + + struct blasfeo_dvec K1u; + struct blasfeo_dvec Zu; + struct blasfeo_dvec ALOtimesx02; + struct blasfeo_dvec BLOtimesu0; + + struct blasfeo_dvec uhat; + + struct blasfeo_dmat J_r_vv; + struct blasfeo_dmat J_r_x1u; + + struct blasfeo_dmat dK1_dx1; + struct blasfeo_dmat dK1_du; + struct blasfeo_dmat dZ_dx1; + struct blasfeo_dmat dZ_du; + struct blasfeo_dmat J_G2_K1; + + struct blasfeo_dmat dK2_dx1; + struct blasfeo_dmat dK2_dvv; + struct blasfeo_dmat dxf_dwn; + struct blasfeo_dmat S_forw_new; + struct blasfeo_dmat S_algebraic_aux; + + struct blasfeo_dmat dPsi_dvv; + struct blasfeo_dmat dPsi_dx; + struct blasfeo_dmat dPsi_du; + + struct blasfeo_dmat dPHI_dyuhat; + struct blasfeo_dvec z0; + + // memory only available if (opts->sens_algebraic) + // struct blasfeo_dvec y_one_stage; + // struct blasfeo_dvec x0dot_1; + // struct blasfeo_dmat dz10_dx1u; // (nz1) * (nx1+nu); + // struct blasfeo_dmat dr0_dvv0; // (n_out * n_out) + // struct blasfeo_dmat f_LO_jac0; // (nx2+nz2) * (2*nx1 + nz1 + nu) + // struct blasfeo_dmat sens_z2_rhs; // (nx2 + nz2) * (nx1 + nu) + // int *ipiv_vv0; + +} gnsf_workspace; + + + +// memory +typedef struct +{ + bool first_call; + + // simulation time for one step + double dt; + + // (scaled) butcher table + double *A_dt; + double *b_dt; + double *c_butcher; + + // value used to initialize integration variables - corresponding to value of phi + double *phi_guess; // n_out + + struct blasfeo_dmat S_forw; + struct blasfeo_dmat S_algebraic; + + // precomputed matrices + struct blasfeo_dmat KKv; + struct blasfeo_dmat KKx; + struct blasfeo_dmat KKu; + + struct blasfeo_dmat YYv; + struct blasfeo_dmat YYx; + struct blasfeo_dmat YYu; + + struct blasfeo_dmat ZZv; + struct blasfeo_dmat ZZx; + struct blasfeo_dmat ZZu; + + struct blasfeo_dmat ALO; + struct blasfeo_dmat BLO; + struct blasfeo_dmat M2_LU; + int *ipivM2; + + struct blasfeo_dmat dK2_dx2; + struct blasfeo_dmat dK2_du; + struct blasfeo_dmat dx2f_dx2u; + + struct blasfeo_dmat Lu; + + // precomputed vectors for constant term in NSF + struct blasfeo_dvec KK0; + struct blasfeo_dvec YY0; + struct blasfeo_dvec ZZ0; + + // for algebraic sensitivities only; + // struct blasfeo_dmat *Z0x; + // struct blasfeo_dmat *Z0u; + // struct blasfeo_dmat *Z0v; + + // struct blasfeo_dmat *Y0x; + // struct blasfeo_dmat *Y0u; + // struct blasfeo_dmat *Y0v; + + // struct blasfeo_dmat *K0x; + // struct blasfeo_dmat *K0u; + // struct blasfeo_dmat *K0v; + + // struct blasfeo_dmat *ELO_LU; + // int *ipiv_ELO; + // struct blasfeo_dmat *ELO_inv_ALO; + + // struct blasfeo_dmat *Lx; + // struct blasfeo_dmat *Lxdot; + // struct blasfeo_dmat *Lz; + + double time_sim; + double time_ad; + double time_la; + +} sim_gnsf_memory; + + + +// gnsf dims +acados_size_t sim_gnsf_dims_calculate_size(); +void *sim_gnsf_dims_assign(void *config_, void *raw_memory); + +// get & set functions +void sim_gnsf_dims_set(void *config_, void *dims_, const char *field, const int *value); +void sim_gnsf_dims_get(void *config_, void *dims_, const char *field, int* value); + +// opts +acados_size_t sim_gnsf_opts_calculate_size(void *config, void *dims); +void *sim_gnsf_opts_assign(void *config, void *dims, void *raw_memory); +void sim_gnsf_opts_initialize_default(void *config, void *dims, void *opts_); +void sim_gnsf_opts_update(void *config_, void *dims, void *opts_); +void sim_gnsf_opts_set(void *config_, void *opts_, const char *field, void *value); + +// model +acados_size_t sim_gnsf_model_calculate_size(void *config, void *dims_); +void *sim_gnsf_model_assign(void *config, void *dims_, void *raw_memory); +int sim_gnsf_model_set(void *model_, const char *field, void *value); + +// precomputation +int sim_gnsf_precompute(void *config_, sim_in *in, sim_out *out, void *opts_, void *mem_, + void *work_); + +// workspace & memory +acados_size_t sim_gnsf_workspace_calculate_size(void *config, void *dims_, void *args); +acados_size_t sim_gnsf_memory_calculate_size(void *config, void *dims_, void *opts_); +void *sim_gnsf_memory_assign(void *config, void *dims_, void *opts_, void *raw_memory); + +// interface +void sim_gnsf_config_initialize_default(void *config_); + +// integrator +int sim_gnsf(void *config, sim_in *in, sim_out *out, void *opts, void *mem_, void *work_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_SIM_SIM_GNSF_H_ diff --git a/third_party/acados/include/acados/sim/sim_irk_integrator.h b/third_party/acados/include/acados/sim/sim_irk_integrator.h new file mode 100644 index 00000000000000..6851bacb3a7902 --- /dev/null +++ b/third_party/acados/include/acados/sim/sim_irk_integrator.h @@ -0,0 +1,186 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_SIM_SIM_IRK_INTEGRATOR_H_ +#define ACADOS_SIM_SIM_IRK_INTEGRATOR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/sim/sim_common.h" +#include "acados/utils/types.h" + +#include "blasfeo/include/blasfeo_common.h" + +typedef struct +{ + int nx; + int nu; + int nz; + +} sim_irk_dims; + + + +typedef struct +{ + /* external functions */ + // implicit fun - can either be fully implicit ode or dae + // - i.e. dae has z as additional last argument & nz > 0 + external_function_generic *impl_ode_fun; + // implicit ode & jac_x & jax_xdot & jac_z + external_function_generic *impl_ode_fun_jac_x_xdot_z; + // jax_x & jac_xdot & jac_u & jac_z of implicit ode + external_function_generic *impl_ode_jac_x_xdot_u_z; + // hessian of implicit ode: + external_function_generic *impl_ode_hess; +} irk_model; + + + +typedef struct +{ + struct blasfeo_dvec *rG; // residuals of G (nx*ns) + struct blasfeo_dvec *K; // internal K variables ((nx+nz)*ns) + struct blasfeo_dvec *xt; // temporary x + struct blasfeo_dvec *xn; // x at each integration step + struct blasfeo_dvec xtdot; // temporary xdot + + struct blasfeo_dvec *lambda; // adjoint sensitivities (nx + nu) + struct blasfeo_dvec *lambdaK; // auxiliary variable ((nx+nz)*ns) for adjoint propagation + + struct blasfeo_dmat df_dx; // temporary Jacobian of ode w.r.t x (nx+nz, nx) + struct blasfeo_dmat df_dxdot; // temporary Jacobian of ode w.r.t xdot (nx+nz, nx) + struct blasfeo_dmat df_du; // temporary Jacobian of ode w.r.t u (nx+nz, nu) + struct blasfeo_dmat df_dz; // temporary Jacobian of ode w.r.t z (nx+nz, nu) + + /* NOTE: the memory allocation corresponding to the following fields is CONDITIONAL */ + + // only allocated if (opts->sens_algebraic || opts->output_z) + int *ipiv_one_stage; // index of pivot vector (nx + nz) + double *Z_work; // used to perform computations to get out->zn (ns) + + // df_dxdotz, dk0_dxu, only allocated if (opts->sens_algebraic && opts->exact_z_output) + // used for algebraic sensitivity generation + struct blasfeo_dmat df_dxdotz; // temporary Jacobian of ode w.r.t. xdot,z (nx+nz, nx+nz); + struct blasfeo_dmat dk0_dxu; // intermediate result, (nx+nz, nx+nu) + + // dK_dxu: if (!opts->sens_hess) - single blasfeo_dmat that is reused + // if ( opts->sens_hess) - array of (num_steps) blasfeo_dmat + // to store intermediate results + struct blasfeo_dmat *dK_dxu; // jacobian of (K,Z) over x and u ((nx+nz)*ns, nx+nu); + + // S_forw: if (!opts->sens_hess) - single blasfeo_dmat that is reused + // if ( opts->sens_hess) - array of (num_steps + 1) blasfeo_dmat + // to store intermediate results + struct blasfeo_dmat *S_forw; // forward sensitivities (nx, nx+nu) + + // dG_dxu: if (!opts->sens_hess) - single blasfeo_dmat that is reused + // if ( opts->sens_hess) - array of blasfeo_dmat to store intermediate results + struct blasfeo_dmat *dG_dxu; // jacobian of G over x and u ((nx+nz)*ns, nx+nu) + + // dG_dK: if (!opts->sens_hess) - single blasfeo_dmat that is reused + // if ( opts->sens_hess) - array of blasfeo_dmat to store intermediate results + struct blasfeo_dmat *dG_dK; // jacobian of G over K ((nx+nz)*ns, (nx+nz)*ns) + + // ipiv: index of pivot vector + // if (!opts->sens_hess) - array (ns * (nx + nz)) that is reused + // if ( opts->sens_hess) - array (ns * (nx + nz)) * num_steps, to store all + // pivot vectors for dG_dxu + int *ipiv; // index of pivot vector + + // xn_traj, K_traj only available if( opts->sens_adj || opts->sens_hess ) + struct blasfeo_dvec *xn_traj; // xn trajectory + struct blasfeo_dvec *K_traj; // K trajectory + + /* the following variables are only available if (opts->sens_hess) */ + // For Hessian propagation + struct blasfeo_dmat Hess; // temporary Hessian (nx + nu, nx + nu) + // output of impl_ode_hess + struct blasfeo_dmat f_hess; // size: (nx + nu, nx + nu) + struct blasfeo_dmat dxkzu_dw0; // size (2*nx + nu + nz) x (nx + nu) + struct blasfeo_dmat tmp_dxkzu_dw0; // size (2*nx + nu + nz) x (nx + nu) + +} sim_irk_workspace; + + +typedef struct +{ + double *xdot; // xdot[NX] - initialization for state derivatives k within the integrator + double *z; // z[NZ] - initialization for algebraic variables z + + double time_sim; + double time_ad; + double time_la; +} sim_irk_memory; + + +// get & set functions +void sim_irk_dims_set(void *config_, void *dims_, const char *field, const int *value); +void sim_irk_dims_get(void *config_, void *dims_, const char *field, int* value); + +// dims +acados_size_t sim_irk_dims_calculate_size(); +void *sim_irk_dims_assign(void *config_, void *raw_memory); + +// model +acados_size_t sim_irk_model_calculate_size(void *config, void *dims); +void *sim_irk_model_assign(void *config, void *dims, void *raw_memory); +int sim_irk_model_set(void *model, const char *field, void *value); + +// opts +acados_size_t sim_irk_opts_calculate_size(void *config, void *dims); +void *sim_irk_opts_assign(void *config, void *dims, void *raw_memory); +void sim_irk_opts_initialize_default(void *config, void *dims, void *opts_); +void sim_irk_opts_update(void *config_, void *dims, void *opts_); +void sim_irk_opts_set(void *config_, void *opts_, const char *field, void *value); + +// memory +acados_size_t sim_irk_memory_calculate_size(void *config, void *dims, void *opts_); +void *sim_irk_memory_assign(void *config, void *dims, void *opts_, void *raw_memory); +int sim_irk_memory_set(void *config_, void *dims_, void *mem_, const char *field, void *value); + +// workspace +acados_size_t sim_irk_workspace_calculate_size(void *config, void *dims, void *opts_); +void sim_irk_config_initialize_default(void *config); + +// main +int sim_irk(void *config, sim_in *in, sim_out *out, void *opts_, void *mem_, void *work_); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_SIM_SIM_IRK_INTEGRATOR_H_ diff --git a/third_party/acados/include/acados/sim/sim_lifted_irk_integrator.h b/third_party/acados/include/acados/sim/sim_lifted_irk_integrator.h new file mode 100644 index 00000000000000..8e476b0e27745f --- /dev/null +++ b/third_party/acados/include/acados/sim/sim_lifted_irk_integrator.h @@ -0,0 +1,159 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_SIM_SIM_LIFTED_IRK_INTEGRATOR_H_ +#define ACADOS_SIM_SIM_LIFTED_IRK_INTEGRATOR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/sim/sim_common.h" +#include "acados/utils/types.h" + +typedef struct +{ + int nx; + int nu; + int nz; +} sim_lifted_irk_dims; + + + +typedef struct +{ + /* external functions */ + // implicit ode + external_function_generic *impl_ode_fun; + // implicit ode & jax_x & jac_xdot & jac_u implicit ode + external_function_generic *impl_ode_fun_jac_x_xdot_u; + +} lifted_irk_model; + + + +typedef struct +{ + + struct blasfeo_dmat *J_temp_x; // temporary Jacobian of ode w.r.t x (nx, nx) + struct blasfeo_dmat *J_temp_xdot; // temporary Jacobian of ode w.r.t xdot (nx, nx) + struct blasfeo_dmat *J_temp_u; // temporary Jacobian of ode w.r.t u (nx, nu) + + struct blasfeo_dvec *rG; // residuals of G (nx*ns) + struct blasfeo_dvec *xt; // temporary x + struct blasfeo_dvec *xn; // x at each integration step (for evaluations) + struct blasfeo_dvec *xn_out; // x at each integration step (output) + struct blasfeo_dvec *dxn; // dx at each integration step + struct blasfeo_dvec *w; // stacked x and u + + int *ipiv; // index of pivot vector + +} sim_lifted_irk_workspace; + + + +typedef struct +{ + // memory for lifted integrators + struct blasfeo_dmat *S_forw; // forward sensitivities + struct blasfeo_dmat *JGK; // jacobian of G over K (nx*ns, nx*ns) + struct blasfeo_dmat *JGf; // jacobian of G over x and u (nx*ns, nx+nu); + struct blasfeo_dmat *JKf; // jacobian of K over x and u (nx*ns, nx+nu); + + struct blasfeo_dvec *K; // internal variables (nx*ns) + struct blasfeo_dvec *x; // states (nx) -- for expansion step + struct blasfeo_dvec *u; // controls (nu) -- for expansion step + + int update_sens; + + double time_sim; + double time_ad; + double time_la; + +} sim_lifted_irk_memory; + + + +/* dims */ +void sim_lifted_irk_dims_set(void *config_, void *dims_, const char *field, const int *value); +void sim_lifted_irk_dims_get(void *config_, void *dims_, const char *field, int* value); + +acados_size_t sim_lifted_irk_dims_calculate_size(); +// +void *sim_lifted_irk_dims_assign(void* config_, void *raw_memory); + +/* model */ +// +acados_size_t sim_lifted_irk_model_calculate_size(void *config, void *dims); +// +void *sim_lifted_irk_model_assign(void *config, void *dims, void *raw_memory); +// +int sim_lifted_irk_model_set(void *model_, const char *field, void *value); + +/* opts */ +// +acados_size_t sim_lifted_irk_opts_calculate_size(void *config, void *dims); +// +void *sim_lifted_irk_opts_assign(void *config, void *dims, void *raw_memory); +// +void sim_lifted_irk_opts_initialize_default(void *config, void *dims, void *opts_); +// +void sim_lifted_irk_opts_update(void *config_, void *dims, void *opts_); +// +void sim_lifted_irk_opts_set(void *config_, void *opts_, const char *field, void *value); + +/* memory */ +// +acados_size_t sim_lifted_irk_memory_calculate_size(void *config, void *dims, void *opts_); +// +void *sim_lifted_irk_memory_assign(void *config, void *dims, void *opts_, void *raw_memory); + +/* workspace */ +// +acados_size_t sim_lifted_irk_workspace_calculate_size(void *config, void *dims, void *opts_); +// +void sim_lifted_irk_config_initialize_default(void *config); + +/* solver */ +// +int sim_lifted_irk(void *config, sim_in *in, sim_out *out, void *opts_, + void *mem_, void *work_); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_SIM_SIM_LIFTED_IRK_INTEGRATOR_H_ diff --git a/third_party/acados/include/acados/utils/external_function_generic.h b/third_party/acados/include/acados/utils/external_function_generic.h new file mode 100644 index 00000000000000..021363f26eced3 --- /dev/null +++ b/third_party/acados/include/acados/utils/external_function_generic.h @@ -0,0 +1,245 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_UTILS_EXTERNAL_FUNCTION_GENERIC_H_ +#define ACADOS_UTILS_EXTERNAL_FUNCTION_GENERIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/utils/types.h" + +/************************************************ + * generic external function + ************************************************/ + +// type of arguments +typedef enum { + COLMAJ, + BLASFEO_DMAT, + BLASFEO_DVEC, + COLMAJ_ARGS, + BLASFEO_DMAT_ARGS, + BLASFEO_DVEC_ARGS, + IGNORE_ARGUMENT +} ext_fun_arg_t; + +struct colmaj_args +{ + double *A; + int lda; +}; + +struct blasfeo_dmat_args +{ + struct blasfeo_dmat *A; + int ai; + int aj; +}; + +struct blasfeo_dvec_args +{ + struct blasfeo_dvec *x; + int xi; +}; + +// prototype of an external function +typedef struct +{ + // public members (have to be before private ones) + void (*evaluate)(void *, ext_fun_arg_t *, void **, ext_fun_arg_t *, void **); + // private members + // ..... +} external_function_generic; + + + +/************************************************ + * generic external parametric function + ************************************************/ + +// prototype of a parametric external function +typedef struct +{ + // public members for core (have to be before private ones) + void (*evaluate)(void *, ext_fun_arg_t *, void **, ext_fun_arg_t *, void **); + // public members for interfaces + void (*get_nparam)(void *, int *); + void (*set_param)(void *, double *); + void (*set_param_sparse)(void *, int n_update, int *idx, double *); + // private members + void *ptr_ext_mem; // pointer to external memory + int (*fun)(void **, void **, void *); + double *p; // parameters + int np; // number of parameters + // ..... +} external_function_param_generic; + +// +acados_size_t external_function_param_generic_struct_size(); +// +void external_function_param_generic_set_fun(external_function_param_generic *fun, void *value); +// +acados_size_t external_function_param_generic_calculate_size(external_function_param_generic *fun, int np); +// +void external_function_param_generic_assign(external_function_param_generic *fun, void *mem); +// +void external_function_param_generic_wrapper(void *self, ext_fun_arg_t *type_in, void **in, ext_fun_arg_t *type_out, void **out); +// +void external_function_param_generic_get_nparam(void *self, int *np); +// +void external_function_param_generic_set_param(void *self, double *p); + + +/************************************************ + * casadi external function + ************************************************/ + +typedef struct +{ + // public members (have to be the same as in the prototype, and before the private ones) + void (*evaluate)(void *, ext_fun_arg_t *, void **, ext_fun_arg_t *, void **); + // private members + void *ptr_ext_mem; // pointer to external memory + int (*casadi_fun)(const double **, double **, int *, double *, void *); + int (*casadi_work)(int *, int *, int *, int *); + const int *(*casadi_sparsity_in)(int); + const int *(*casadi_sparsity_out)(int); + int (*casadi_n_in)(); + int (*casadi_n_out)(); + double **args; + double **res; + double *w; + int *iw; + int *args_size; // size of args[i] + int *res_size; // size of res[i] + int args_num; // number of args arrays + int args_size_tot; // total size of args arrays + int res_num; // number of res arrays + int res_size_tot; // total size of res arrays + int in_num; // number of input arrays + int out_num; // number of output arrays + int iw_size; // number of ints for worksapce + int w_size; // number of doubles for workspace +} external_function_casadi; + +// +acados_size_t external_function_casadi_struct_size(); +// +void external_function_casadi_set_fun(external_function_casadi *fun, void *value); +// +void external_function_casadi_set_work(external_function_casadi *fun, void *value); +// +void external_function_casadi_set_sparsity_in(external_function_casadi *fun, void *value); +// +void external_function_casadi_set_sparsity_out(external_function_casadi *fun, void *value); +// +void external_function_casadi_set_n_in(external_function_casadi *fun, void *value); +// +void external_function_casadi_set_n_out(external_function_casadi *fun, void *value); +// +acados_size_t external_function_casadi_calculate_size(external_function_casadi *fun); +// +void external_function_casadi_assign(external_function_casadi *fun, void *mem); +// +void external_function_casadi_wrapper(void *self, ext_fun_arg_t *type_in, void **in, + ext_fun_arg_t *type_out, void **out); + +/************************************************ + * casadi external parametric function + ************************************************/ + +typedef struct +{ + // public members for core (have to be the same as in the prototype, and before the private ones) + void (*evaluate)(void *, ext_fun_arg_t *, void **, ext_fun_arg_t *, void **); + // public members for interfaces + void (*get_nparam)(void *, int *); + void (*set_param)(void *, double *); + void (*set_param_sparse)(void *, int n_update, int *idx, double *); + // private members + void *ptr_ext_mem; // pointer to external memory + int (*casadi_fun)(const double **, double **, int *, double *, void *); + int (*casadi_work)(int *, int *, int *, int *); + const int *(*casadi_sparsity_in)(int); + const int *(*casadi_sparsity_out)(int); + int (*casadi_n_in)(); + int (*casadi_n_out)(); + double **args; + double **res; + double *w; + int *iw; + int *args_size; // size of args[i] + int *res_size; // size of res[i] + int args_num; // number of args arrays + int args_size_tot; // total size of args arrays + int res_num; // number of res arrays + int res_size_tot; // total size of res arrays + int in_num; // number of input arrays + int out_num; // number of output arrays + int iw_size; // number of ints for worksapce + int w_size; // number of doubles for workspace + int np; // number of parameters +} external_function_param_casadi; + +// +acados_size_t external_function_param_casadi_struct_size(); +// +void external_function_param_casadi_set_fun(external_function_param_casadi *fun, void *value); +// +void external_function_param_casadi_set_work(external_function_param_casadi *fun, void *value); +// +void external_function_param_casadi_set_sparsity_in(external_function_param_casadi *fun, void *value); +// +void external_function_param_casadi_set_sparsity_out(external_function_param_casadi *fun, void *value); +// +void external_function_param_casadi_set_n_in(external_function_param_casadi *fun, void *value); +// +void external_function_param_casadi_set_n_out(external_function_param_casadi *fun, void *value); +// +acados_size_t external_function_param_casadi_calculate_size(external_function_param_casadi *fun, int np); +// +void external_function_param_casadi_assign(external_function_param_casadi *fun, void *mem); +// +void external_function_param_casadi_wrapper(void *self, ext_fun_arg_t *type_in, void **in, + ext_fun_arg_t *type_out, void **out); +// +void external_function_param_casadi_get_nparam(void *self, int *np); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_UTILS_EXTERNAL_FUNCTION_GENERIC_H_ diff --git a/third_party/acados/include/acados/utils/math.h b/third_party/acados/include/acados/utils/math.h new file mode 100644 index 00000000000000..fe1da875f6e600 --- /dev/null +++ b/third_party/acados/include/acados/utils/math.h @@ -0,0 +1,105 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + +#ifndef ACADOS_UTILS_MATH_H_ +#define ACADOS_UTILS_MATH_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/utils/types.h" + +#if defined(__MABX2__) +double fmax(double a, double b); +#endif + +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +void dgemm_nn_3l(int m, int n, int k, double *A, int lda, double *B, int ldb, double *C, int ldc); +// void dgemv_n_3l(int m, int n, double *A, int lda, double *x, double *y); +// void dgemv_t_3l(int m, int n, double *A, int lda, double *x, double *y); +// void dcopy_3l(int n, double *x, int incx, double *y, int incy); +void daxpy_3l(int n, double da, double *dx, double *dy); +void dscal_3l(int n, double da, double *dx); +double twonormv(int n, double *ptrv); + +/* copies a matrix into another matrix */ +void dmcopy(int row, int col, double *ptrA, int lda, double *ptrB, int ldb); + +/* solution of a system of linear equations */ +void dgesv_3l(int n, int nrhs, double *A, int lda, int *ipiv, double *B, int ldb, int *info); + +/* matrix exponential */ +void expm(int row, double *A); + +int idamax_3l(int n, double *x); + +void dswap_3l(int n, double *x, int incx, double *y, int incy); + +void dger_3l(int m, int n, double alpha, double *x, int incx, double *y, int incy, double *A, + int lda); + +void dgetf2_3l(int m, int n, double *A, int lda, int *ipiv, int *info); + +void dlaswp_3l(int n, double *A, int lda, int k1, int k2, int *ipiv); + +void dtrsm_l_l_n_u_3l(int m, int n, double *A, int lda, double *B, int ldb); + +void dgetrs_3l(int n, int nrhs, double *A, int lda, int *ipiv, double *B, int ldb); + +void dgesv_3l(int n, int nrhs, double *A, int lda, int *ipiv, double *B, int ldb, int *info); + +double onenorm(int row, int col, double *ptrA); + +// double twonormv(int n, double *ptrv); + +void padeapprox(int m, int row, double *A); + +void expm(int row, double *A); + +// void d_compute_qp_size_ocp2dense_rev(int N, int *nx, int *nu, int *nb, int **hidxb, int *ng, +// int *nvd, int *ned, int *nbd, int *ngd); + +void acados_eigen_decomposition(int dim, double *A, double *V, double *d, double *e); + +double minimum_of_doubles(double *x, int n); + +void neville_algorithm(double xx, int n, double *x, double *Q, double *out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_UTILS_MATH_H_ diff --git a/third_party/acados/include/acados/utils/mem.h b/third_party/acados/include/acados/utils/mem.h new file mode 100644 index 00000000000000..7b9efc5ed8d2a5 --- /dev/null +++ b/third_party/acados/include/acados/utils/mem.h @@ -0,0 +1,113 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_UTILS_MEM_H_ +#define ACADOS_UTILS_MEM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include "types.h" + +// blasfeo +#include "blasfeo/include/blasfeo_d_aux.h" +#include "blasfeo/include/blasfeo_d_aux_ext_dep.h" + +// TODO(dimitris): probably does not belong here +typedef struct +{ + int (*fun)(void *); + acados_size_t (*calculate_args_size)(void *); + void *(*assign_args)(void *); + void (*initialize_default_args)(void *); + acados_size_t (*calculate_memory_size)(void *); + void *(*assign_memory)(void *); + acados_size_t (*calculate_workspace_size)(void *); +} module_solver; + +// make int counter of memory multiple of a number (typically 8 or 64) +void make_int_multiple_of(acados_size_t num, acados_size_t *size); + +// align char pointer to number (typically 8 for pointers and doubles, +// 64 for blasfeo structs) and return offset +int align_char_to(int num, char **c_ptr); + +// switch between malloc and calloc (for valgrinding) +void *acados_malloc(size_t nitems, acados_size_t size); + +// uses always calloc +void *acados_calloc(size_t nitems, acados_size_t size); + +// allocate vector of pointers to vectors of doubles and advance pointer +void assign_and_advance_double_ptrs(int n, double ***v, char **ptr); + +// allocate vector of pointers to vectors of ints and advance pointer +void assign_and_advance_int_ptrs(int n, int ***v, char **ptr); + +// allocate vector of pointers to strvecs and advance pointer +void assign_and_advance_blasfeo_dvec_structs(int n, struct blasfeo_dvec **sv, char **ptr); + +// allocate vector of pointers to strmats and advance pointer +void assign_and_advance_blasfeo_dmat_structs(int n, struct blasfeo_dmat **sm, char **ptr); + +// allocate vector of pointers to vector of pointers to strmats and advance pointer +void assign_and_advance_blasfeo_dmat_ptrs(int n, struct blasfeo_dmat ***sm, char **ptr); + +// allocate vector of chars and advance pointer +void assign_and_advance_char(int n, char **v, char **ptr); + +// allocate vector of ints and advance pointer +void assign_and_advance_int(int n, int **v, char **ptr); + +// allocate vector of bools and advance pointer +void assign_and_advance_bool(int n, bool **v, char **ptr); + +// allocate vector of doubles and advance pointer +void assign_and_advance_double(int n, double **v, char **ptr); + +// allocate strvec and advance pointer +void assign_and_advance_blasfeo_dvec_mem(int n, struct blasfeo_dvec *sv, char **ptr); + +// allocate strmat and advance pointer +void assign_and_advance_blasfeo_dmat_mem(int m, int n, struct blasfeo_dmat *sA, char **ptr); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_UTILS_MEM_H_ diff --git a/third_party/acados/include/acados/utils/print.h b/third_party/acados/include/acados/utils/print.h new file mode 100644 index 00000000000000..2993447dbd746d --- /dev/null +++ b/third_party/acados/include/acados/utils/print.h @@ -0,0 +1,109 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_UTILS_PRINT_H_ +#define ACADOS_UTILS_PRINT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/dense_qp/dense_qp_common.h" +#include "acados/ocp_nlp/ocp_nlp_common.h" +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/ocp_qp/ocp_qp_common_frontend.h" +#include "acados/utils/types.h" + +// void print_matrix(char *file_name, const real_t *matrix, const int_t nrows, const int_t ncols); + +// void print_matrix_name(char *file_name, char *name, const real_t *matrix, const int_t nrows, +// const int_t ncols); + +// void print_int_matrix(char *file_name, const int_t *matrix, const int_t nrows, const int_t ncols); + +// void print_array(char *file_name, real_t *array, int_t size); + +// void print_int_array(char *file_name, const int_t *array, int_t size); + +void read_matrix(const char *file_name, real_t *array, const int_t nrows, const int_t ncols); + +void write_double_vector_to_txt(real_t *vec, int_t n, const char *fname); + +// ocp nlp +// TODO(andrea): inconsistent naming +void ocp_nlp_dims_print(ocp_nlp_dims *dims); +// TODO(andrea): inconsistent naming +void ocp_nlp_out_print(ocp_nlp_dims *dims, ocp_nlp_out *nlp_out); +// TODO(andrea): inconsistent naming +void ocp_nlp_res_print(ocp_nlp_dims *dims, ocp_nlp_res *nlp_res); + +// ocp qp +void print_ocp_qp_dims(ocp_qp_dims *dims); + +// void print_dense_qp_dims(dense_qp_dims *dims); + +void print_ocp_qp_in(ocp_qp_in *qp_in); + +void print_ocp_qp_out(ocp_qp_out *qp_out); + +// void print_ocp_qp_in_to_string(char string_out[], ocp_qp_in *qp_in); + +// void print_ocp_qp_out_to_string(char string_out[], ocp_qp_out *qp_out); + +void print_ocp_qp_res(ocp_qp_res *qp_res); + +// void print_colmaj_ocp_qp_in(colmaj_ocp_qp_in *qp); + +// void print_colmaj_ocp_qp_in_to_file(colmaj_ocp_qp_in *qp); + +// void print_colmaj_ocp_qp_out(char *filename, colmaj_ocp_qp_in *qp, colmaj_ocp_qp_out *out); + +void print_dense_qp_in(dense_qp_in *qp_in); + +void print_qp_info(qp_info *info); + +// void acados_warning(char warning_string[]); + +// void acados_error(char error_string[]); + +// void acados_not_implemented(char feature_string[]); + +// blasfeo +// void print_blasfeo_target(); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_UTILS_PRINT_H_ diff --git a/third_party/acados/include/acados/utils/strsep.h b/third_party/acados/include/acados/utils/strsep.h new file mode 100644 index 00000000000000..02f1835593a244 --- /dev/null +++ b/third_party/acados/include/acados/utils/strsep.h @@ -0,0 +1,72 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_UTILS_STRSEP_H_ +#define ACADOS_UTILS_STRSEP_H_ + +#ifdef __cplusplus +#include +#define STD(x) std::x +namespace std +{ +#else +#include +#define STD(x) x +#endif + +char* strsep_acados(char** stringp, const char* delim) +{ + char* result; + + if ((stringp == NULL) || (*stringp == NULL)) return NULL; + + result = *stringp; + + while (**stringp && !STD(strchr)(delim, **stringp)) ++*stringp; + + if (**stringp) + *(*stringp)++ = '\0'; + else + *stringp = NULL; + + return result; +} + +#ifdef __cplusplus +} // namespace std +#endif + +#undef STD + +#endif // ACADOS_UTILS_STRSEP_H_ diff --git a/third_party/acados/include/acados/utils/timing.h b/third_party/acados/include/acados/utils/timing.h new file mode 100644 index 00000000000000..fe561d38914306 --- /dev/null +++ b/third_party/acados/include/acados/utils/timing.h @@ -0,0 +1,125 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_UTILS_TIMING_H_ +#define ACADOS_UTILS_TIMING_H_ + +#include "acados/utils/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef MEASURE_TIMINGS +#if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) + +/* Use Windows QueryPerformanceCounter for timing. */ +#include + +/** A structure for keeping internal timer data. */ +typedef struct acados_timer_ +{ + LARGE_INTEGER tic; + LARGE_INTEGER toc; + LARGE_INTEGER freq; +} acados_timer; + +#elif defined(__APPLE__) + +#include + +/** A structure for keeping internal timer data. */ +typedef struct acados_timer_ +{ + uint64_t tic; + uint64_t toc; + mach_timebase_info_data_t tinfo; +} acados_timer; + +#elif defined(__MABX2__) + +#include + +typedef struct acados_timer_ +{ + double time; +} acados_timer; + +#else + +/* Use POSIX clock_gettime() for timing on non-Windows machines. */ +#include + +#if (__STDC_VERSION__ >= 199901L) && !(defined __MINGW32__ || defined __MINGW64__) // C99 Mode + +#include +#include + +typedef struct acados_timer_ +{ + struct timeval tic; + struct timeval toc; +} acados_timer; + +#else // ANSI C Mode + +/** A structure for keeping internal timer data. */ +typedef struct acados_timer_ +{ + struct timespec tic; + struct timespec toc; +} acados_timer; + +#endif // __STDC_VERSION__ >= 199901L + +#endif // (defined _WIN32 || defined _WIN64) + +#else + +// Dummy type when timings are off +typedef real_t acados_timer; + +#endif // MEASURE_TIMINGS + +/** A function for measurement of the current time. */ +void acados_tic(acados_timer* t); + +/** A function which returns the elapsed time. */ +real_t acados_toc(acados_timer* t); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_UTILS_TIMING_H_ diff --git a/third_party/acados/include/acados/utils/types.h b/third_party/acados/include/acados/utils/types.h new file mode 100644 index 00000000000000..99ad375fea73ae --- /dev/null +++ b/third_party/acados/include/acados/utils/types.h @@ -0,0 +1,79 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef ACADOS_UTILS_TYPES_H_ +#define ACADOS_UTILS_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define MAX_STR_LEN 256 +#define ACADOS_EPS 1e-12 +#define ACADOS_NEG_INFTY -1.0e9 +#define ACADOS_POS_INFTY +1.0e9 +#define UNUSED(x) ((void)(x)) + + + +typedef double real_t; +typedef int int_t; +typedef size_t acados_size_t; + + +typedef int (*casadi_function_t)(const double** arg, double** res, int* iw, double* w, void* mem); + + + +// enum of return values +enum return_values +{ + ACADOS_SUCCESS, + ACADOS_FAILURE, + ACADOS_MAXITER, + ACADOS_MINSTEP, + ACADOS_QP_FAILURE, + ACADOS_READY, +}; + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // ACADOS_UTILS_TYPES_H_ diff --git a/third_party/acados/include/acados_c/condensing_interface.h b/third_party/acados/include/acados_c/condensing_interface.h new file mode 100644 index 00000000000000..51fe8271279ac5 --- /dev/null +++ b/third_party/acados/include/acados_c/condensing_interface.h @@ -0,0 +1,84 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef INTERFACES_ACADOS_C_CONDENSING_INTERFACE_H_ +#define INTERFACES_ACADOS_C_CONDENSING_INTERFACE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/ocp_qp/ocp_qp_full_condensing.h" +#include "acados/ocp_qp/ocp_qp_partial_condensing.h" + +typedef enum { + PARTIAL_CONDENSING, + FULL_CONDENSING, +} condensing_t; + +typedef struct +{ + condensing_t condensing_type; +} condensing_plan; + +typedef struct +{ + ocp_qp_xcond_config *config; + void *dims; + void *opts; + void *mem; + void *work; +} condensing_module; + +ocp_qp_xcond_config *ocp_qp_condensing_config_create(condensing_plan *plan); +// +void *ocp_qp_condensing_opts_create(ocp_qp_xcond_config *config, void *dims_); +// +acados_size_t ocp_qp_condensing_calculate_size(ocp_qp_xcond_config *config, void *dims_, void *opts_); +// +condensing_module *ocp_qp_condensing_assign(ocp_qp_xcond_config *config, void *dims_, + void *opts_, void *raw_memory); +// +condensing_module *ocp_qp_condensing_create(ocp_qp_xcond_config *config, void *dims_, + void *opts_); +// +int ocp_qp_condense(condensing_module *module, void *qp_in, void *qp_out); +// +int ocp_qp_expand(condensing_module *module, void *qp_in, void *qp_out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // INTERFACES_ACADOS_C_CONDENSING_INTERFACE_H_ diff --git a/third_party/acados/include/acados_c/dense_qp_interface.h b/third_party/acados/include/acados_c/dense_qp_interface.h new file mode 100644 index 00000000000000..4ecc77381d669b --- /dev/null +++ b/third_party/acados/include/acados_c/dense_qp_interface.h @@ -0,0 +1,94 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef INTERFACES_ACADOS_C_DENSE_QP_INTERFACE_H_ +#define INTERFACES_ACADOS_C_DENSE_QP_INTERFACE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/dense_qp/dense_qp_common.h" + +typedef enum { DENSE_QP_HPIPM, DENSE_QP_QORE, DENSE_QP_QPOASES, DENSE_QP_OOQP } dense_qp_solver_t; + +typedef struct +{ + dense_qp_solver_t qp_solver; +} dense_qp_solver_plan; + +typedef struct +{ + qp_solver_config *config; + void *dims; + void *opts; + void *mem; + void *work; +} dense_qp_solver; + +qp_solver_config *dense_qp_config_create(dense_qp_solver_plan *plan); +// +dense_qp_dims *dense_qp_dims_create(); +// +dense_qp_in *dense_qp_in_create(qp_solver_config *config, dense_qp_dims *dims); +// +dense_qp_out *dense_qp_out_create(qp_solver_config *config, dense_qp_dims *dims); +// +void *dense_qp_opts_create(qp_solver_config *config, dense_qp_dims *dims); +// +acados_size_t dense_qp_calculate_size(qp_solver_config *config, dense_qp_dims *dims, void *opts_); +// +dense_qp_solver *dense_qp_assign(qp_solver_config *config, dense_qp_dims *dims, void *opts_, + void *raw_memory); +// +dense_qp_solver *dense_qp_create(qp_solver_config *config, dense_qp_dims *dims, void *opts_); +// +int dense_qp_solve(dense_qp_solver *solver, dense_qp_in *qp_in, dense_qp_out *qp_out); +// +void dense_qp_inf_norm_residuals(dense_qp_dims *dims, dense_qp_in *qp_in, dense_qp_out *qp_out, + double *res); +// +bool dense_qp_set_field_double_array(const char *field, double *arr, dense_qp_in *qp_in); +// +bool dense_qp_set_field_int_array(const char *field, int *arr, dense_qp_in *qp_in); +// +bool dense_qp_get_field_double_array(const char *field, dense_qp_in *qp_in, double *arr); +// +bool dense_qp_get_field_int_array(const char *field, dense_qp_in *qp_in, int *arr); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // INTERFACES_ACADOS_C_DENSE_QP_INTERFACE_H_ diff --git a/third_party/acados/include/acados_c/external_function_interface.h b/third_party/acados/include/acados_c/external_function_interface.h new file mode 100644 index 00000000000000..6838975071476c --- /dev/null +++ b/third_party/acados/include/acados_c/external_function_interface.h @@ -0,0 +1,92 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef INTERFACES_ACADOS_C_EXTERNAL_FUNCTION_INTERFACE_H_ +#define INTERFACES_ACADOS_C_EXTERNAL_FUNCTION_INTERFACE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/utils/external_function_generic.h" + + + +/************************************************ + * generic external parametric function + ************************************************/ + +// +void external_function_param_generic_create(external_function_param_generic *fun, int np); +// +void external_function_param_generic_free(external_function_param_generic *fun); + + + +/************************************************ + * casadi external function + ************************************************/ + +// +void external_function_casadi_create(external_function_casadi *fun); +// +void external_function_casadi_free(external_function_casadi *fun); +// +void external_function_casadi_create_array(int size, external_function_casadi *funs); +// +void external_function_casadi_free_array(int size, external_function_casadi *funs); + + + +/************************************************ + * casadi external parametric function + ************************************************/ + +// +void external_function_param_casadi_create(external_function_param_casadi *fun, int np); +// +void external_function_param_casadi_free(external_function_param_casadi *fun); +// +void external_function_param_casadi_create_array(int size, external_function_param_casadi *funs, + int np); +// +void external_function_param_casadi_free_array(int size, external_function_param_casadi *funs); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // INTERFACES_ACADOS_C_EXTERNAL_FUNCTION_INTERFACE_H_ diff --git a/third_party/acados/include/acados_c/ocp_nlp_interface.h b/third_party/acados/include/acados_c/ocp_nlp_interface.h new file mode 100644 index 00000000000000..b6b893024bb422 --- /dev/null +++ b/third_party/acados/include/acados_c/ocp_nlp_interface.h @@ -0,0 +1,403 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef INTERFACES_ACADOS_C_OCP_NLP_INTERFACE_H_ +#define INTERFACES_ACADOS_C_OCP_NLP_INTERFACE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// acados +#include "acados/ocp_nlp/ocp_nlp_common.h" +#include "acados/ocp_nlp/ocp_nlp_constraints_bgh.h" +#include "acados/sim/sim_erk_integrator.h" +#include "acados/sim/sim_irk_integrator.h" +#include "acados/sim/sim_lifted_irk_integrator.h" +#include "acados/sim/sim_gnsf.h" +// acados_c +#include "acados_c/ocp_qp_interface.h" +#include "acados_c/sim_interface.h" + + +/// Solution methods for optimal control problems. +typedef enum +{ + SQP, + SQP_RTI, + INVALID_NLP_SOLVER, +} ocp_nlp_solver_t; + + +/// Types of the cost function. +typedef enum +{ + LINEAR_LS, + NONLINEAR_LS, + EXTERNAL, + INVALID_COST, +} ocp_nlp_cost_t; + + +/// Types of the system dynamics, discrete or continuous time. +typedef enum +{ + CONTINUOUS_MODEL, + DISCRETE_MODEL, + INVALID_DYNAMICS, +} ocp_nlp_dynamics_t; + + +/// Constraint types +typedef enum +{ + /// Comprises simple bounds, polytopic constraints, + /// general non-linear constraints. + BGH, + + /// Comprises simple bounds, polytopic constraints, + /// general non-linear constraints, and positive definite constraints. + BGP, + + INVALID_CONSTRAINT, +} ocp_nlp_constraints_t; + + +/// Regularization types +typedef enum +{ + NO_REGULARIZE, + MIRROR, + PROJECT, + PROJECT_REDUC_HESS, + CONVEXIFY, + INVALID_REGULARIZE, +} ocp_nlp_reg_t; + + +/// Structure to store the configuration of a non-linear program +typedef struct ocp_nlp_plan +{ + /// QP solver configuration. + ocp_qp_solver_plan ocp_qp_solver_plan; + + /// Simulation solver configuration for each stage. + sim_solver_plan *sim_solver_plan; + + /// Nlp solver type. + ocp_nlp_solver_t nlp_solver; + + /// Regularization type, defaults to no regularization. + ocp_nlp_reg_t regularization; + + /// Cost type for each stage. + ocp_nlp_cost_t *nlp_cost; + + /// Dynamics type for each stage. + ocp_nlp_dynamics_t *nlp_dynamics; + + /// Constraints type for each stage. + ocp_nlp_constraints_t *nlp_constraints; + + /// Horizon length. + int N; + +} ocp_nlp_plan; + + +/// Structure to store the state/configuration for the non-linear programming solver +typedef struct ocp_nlp_solver +{ + ocp_nlp_config *config; + void *dims; + void *opts; + void *mem; + void *work; +} ocp_nlp_solver; + + +/// Constructs an empty plan struct (user nlp configuration), all fields are set to a +/// default/invalid state. +/// +/// \param N Horizon length +ocp_nlp_plan *ocp_nlp_plan_create(int N); + +/// Destructor for plan struct, frees memory. +/// +/// \param plan_ The plan struct to destroy. +void ocp_nlp_plan_destroy(void* plan_); + + +/// Constructs an nlp configuration struct from a plan. +/// +/// \param plan The plan (user nlp configuration). +ocp_nlp_config *ocp_nlp_config_create(ocp_nlp_plan plan); + +/// Desctructor of the nlp configuration. +/// +/// \param config_ The configuration struct. +void ocp_nlp_config_destroy(void *config_); + + +/// Constructs an struct that contains the dimensions of the variables. +/// +/// \param config_ The configuration struct. +ocp_nlp_dims *ocp_nlp_dims_create(void *config_); + +/// Destructor of The dimension struct. +/// +/// \param dims_ The dimension struct. +void ocp_nlp_dims_destroy(void *dims_); + + +/// Constructs an input struct for a non-linear programs. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +ocp_nlp_in *ocp_nlp_in_create(ocp_nlp_config *config, ocp_nlp_dims *dims); + +/// Destructor of the inputs struct. +/// +/// \param in The inputs struct. +void ocp_nlp_in_destroy(void *in); + + +/// Sets the sampling times for the given stage. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param in The inputs struct. +/// \param stage Stage number. +/// \param field Has to be "Ts" (TBC other options). +/// \param value The sampling times (floating point). +void ocp_nlp_in_set(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, int stage, + const char *field, void *value); + + +/// Sets the function pointers to the dynamics functions for the given stage. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param in The inputs struct. +/// \param stage Stage number. +/// \param fun_type The name of the function type, either impl_ode_fun, +/// impl_ode_fun_jac_x_xdot, impl_ode_jac_x_xdot_u (TBC) +/// \param fun_ptr Function pointer to the dynamics function. +int ocp_nlp_dynamics_model_set(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + int stage, const char *fun_type, void *fun_ptr); + + +/// Sets the function pointers to the cost functions for the given stage. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param in The inputs struct. +/// \param stage Stage number. +/// \param field The name of the field, either nls_res_jac, +/// y_ref, W (others TBC) +/// \param value Cost values. +int ocp_nlp_cost_model_set(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, + int stage, const char *field, void *value); + + +/// Sets the function pointers to the constraints functions for the given stage. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param in The inputs struct. +/// \param stage Stage number. +/// \param field The name of the field, either lb, ub (others TBC) +/// \param value Constraints function or values. +int ocp_nlp_constraints_model_set(ocp_nlp_config *config, ocp_nlp_dims *dims, + ocp_nlp_in *in, int stage, const char *field, void *value); + +/* out */ + +/// Constructs an output struct for the non-linear program. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +ocp_nlp_out *ocp_nlp_out_create(ocp_nlp_config *config, ocp_nlp_dims *dims); + +/// Destructor of the output struct. +/// +/// \param out The output struct. +void ocp_nlp_out_destroy(void *out); + + +/// Sets fields in the output struct of an nlp solver, used to initialize the solver. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param out The output struct. +/// \param stage Stage number. +/// \param field The name of the field, either x, u, pi. +/// \param value Initialization values. +void ocp_nlp_out_set(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, void *value); + + +/// Gets values of fields in the output struct of an nlp solver. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param out The output struct. +/// \param stage Stage number. +/// \param field The name of the field, either x, u, z, pi. +/// \param value Pointer to the output memory. +void ocp_nlp_out_get(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, void *value); + +// +void ocp_nlp_get_at_stage(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_solver *solver, + int stage, const char *field, void *value); + +// TODO(andrea): remove this once/if the MATLAB interface uses the new setters below? +int ocp_nlp_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field); + +void ocp_nlp_constraint_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, int *dims_out); + +void ocp_nlp_cost_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, int *dims_out); + +void ocp_nlp_dynamics_dims_get_from_attr(ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, + int stage, const char *field, int *dims_out); + +/* opts */ + +/// Creates an options struct for the non-linear program. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +void *ocp_nlp_solver_opts_create(ocp_nlp_config *config, ocp_nlp_dims *dims); + +/// Destructor of the options. +/// +/// \param opts The options struct. +void ocp_nlp_solver_opts_destroy(void *opts); + +/// Sets an option. +/// +/// \param config The configuration struct. +/// \param opts_ The options struct. +/// \param field Name of the option. +/// \param value Value of the option. +void ocp_nlp_solver_opts_set(ocp_nlp_config *config, void *opts_, const char *field, void* value); + + +void ocp_nlp_solver_opts_set_at_stage(ocp_nlp_config *config, void *opts_, int stage, const char *field, void* value); + + +/// TBC +/// Updates the options. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param opts_ The options struct. +void ocp_nlp_solver_opts_update(ocp_nlp_config *config, ocp_nlp_dims *dims, void *opts_); + + +/* solver */ + +/// Creates an ocp solver. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param opts_ The options struct. +/// \return The solver. +ocp_nlp_solver *ocp_nlp_solver_create(ocp_nlp_config *config, ocp_nlp_dims *dims, void *opts_); + +/// Destructor of the solver. +/// +/// \param solver The solver struct. +void ocp_nlp_solver_destroy(void *solver); + +/// Solves the optimal control problem. Call ocp_nlp_precompute before +/// calling this functions (TBC). +/// +/// \param solver The solver struct. +/// \param nlp_in The inputs struct. +/// \param nlp_out The output struct. +int ocp_nlp_solve(ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out); + +/// Performs precomputations for the solver. Needs to be called before +/// ocl_nlp_solve (TBC). +/// +/// \param solver The solver struct. +/// \param nlp_in The inputs struct. +/// \param nlp_out The output struct. +int ocp_nlp_precompute(ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out); + + +/// Computes cost function value. +/// +/// \param solver The solver struct. +/// \param nlp_in The inputs struct. +/// \param nlp_out The output struct. +void ocp_nlp_eval_cost(ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out); + +// +void ocp_nlp_eval_residuals(ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out); + +// +void ocp_nlp_eval_param_sens(ocp_nlp_solver *solver, char *field, int stage, int index, ocp_nlp_out *sens_nlp_out); + +/* get */ +/// \param config The configuration struct. +/// \param solver The solver struct. +/// \param field Supports "sqp_iter", "status", "nlp_res", "time_tot", ... +/// \param return_value_ Pointer to the output memory. +void ocp_nlp_get(ocp_nlp_config *config, ocp_nlp_solver *solver, + const char *field, void *return_value_); + +/* set */ +/// Sets the initial guesses for the integrator for the given stage. +/// +/// \param config The configuration struct. +/// \param solver The ocp_nlp_solver struct. +/// \param stage Stage number. +/// \param field Supports "z_guess", "xdot_guess" (IRK), "phi_guess" (GNSF-IRK) +/// \param value The initial guess for the algebraic variables in the integrator (if continuous model is used). +void ocp_nlp_set(ocp_nlp_config *config, ocp_nlp_solver *solver, + int stage, const char *field, void *value); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // INTERFACES_ACADOS_C_OCP_NLP_INTERFACE_H_ diff --git a/third_party/acados/include/acados_c/ocp_qp_interface.h b/third_party/acados/include/acados_c/ocp_qp_interface.h new file mode 100644 index 00000000000000..a567ebeb35ba96 --- /dev/null +++ b/third_party/acados/include/acados_c/ocp_qp_interface.h @@ -0,0 +1,261 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef INTERFACES_ACADOS_C_OCP_QP_INTERFACE_H_ +#define INTERFACES_ACADOS_C_OCP_QP_INTERFACE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/ocp_qp/ocp_qp_common.h" +#include "acados/ocp_qp/ocp_qp_xcond_solver.h" + + +/// QP solver types (Enumeration). +/// +/// Full list of fields: +/// PARTIAL_CONDENSING_HPIPM +/// PARTIAL_CONDENSING_HPMPC +/// PARTIAL_CONDENSING_OOQP +/// PARTIAL_CONDENSING_OSQP +/// PARTIAL_CONDENSING_QPDUNES +/// FULL_CONDENSING_HPIPM +/// FULL_CONDENSING_QPOASES +/// FULL_CONDENSING_QORE +/// FULL_CONDENSING_OOQP +/// INVALID_QP_SOLVER +/// +/// Note: In this enumeration the partial condensing solvers have to be +/// specified before the full condensing solvers. +typedef enum { + PARTIAL_CONDENSING_HPIPM, +#ifdef ACADOS_WITH_HPMPC + PARTIAL_CONDENSING_HPMPC, +#else + PARTIAL_CONDENSING_HPMPC_NOT_AVAILABLE, +#endif +#ifdef ACADOS_WITH_OOQP + PARTIAL_CONDENSING_OOQP, +#else + PARTIAL_CONDENSING_OOQP_NOT_AVAILABLE, +#endif +#ifdef ACADOS_WITH_OSQP + PARTIAL_CONDENSING_OSQP, +#else + PARTIAL_CONDENSING_OSQP_NOT_AVAILABLE, +#endif +#ifdef ACADOS_WITH_QPDUNES + PARTIAL_CONDENSING_QPDUNES, +#else + PARTIAL_CONDENSING_QPDUNES_NOT_AVAILABLE, +#endif + FULL_CONDENSING_HPIPM, +#ifdef ACADOS_WITH_QPOASES + FULL_CONDENSING_QPOASES, +#else + FULL_CONDENSING_QPOASES_NOT_AVAILABLE, +#endif +#ifdef ACADOS_WITH_QORE + FULL_CONDENSING_QORE, +#else + FULL_CONDENSING_QORE_NOT_AVAILABLE, +#endif +#ifdef ACADOS_WITH_OOQP + FULL_CONDENSING_OOQP, +#else + FULL_CONDENSING_OOQP_NOT_AVAILABLE, +#endif + INVALID_QP_SOLVER, +} ocp_qp_solver_t; + + +/// Struct containing qp solver +typedef struct +{ + ocp_qp_solver_t qp_solver; +} ocp_qp_solver_plan; + + +/// Linear ocp configuration. +typedef struct +{ + ocp_qp_xcond_solver_config *config; + ocp_qp_xcond_solver_dims *dims; + void *opts; + void *mem; + void *work; +} ocp_qp_solver; + + +/// Initializes the qp solver configuration. +/// TBC should this be private/static - no, used in ocp_nlp +void ocp_qp_xcond_solver_config_initialize_from_plan( + ocp_qp_solver_t solver_name, ocp_qp_xcond_solver_config *solver_config); + +/// Constructs a qp solver config and Initializes with default values. +/// +/// \param plan The qp solver plan struct. +ocp_qp_xcond_solver_config *ocp_qp_xcond_solver_config_create(ocp_qp_solver_plan plan); + +/// Destructor for config struct, frees memory. +/// +/// \param config The config object to destroy. +void ocp_qp_xcond_solver_config_free(ocp_qp_xcond_solver_config *config); + + +/// Constructs a struct that contains the dimensions for the variables of the qp. +/// +/// \param N The number of variables. +ocp_qp_dims *ocp_qp_dims_create(int N); + +/// Destructor of The dimension struct. +/// +/// \param dims The dimension struct. +void ocp_qp_dims_free(void *dims); + +// +ocp_qp_xcond_solver_dims *ocp_qp_xcond_solver_dims_create(ocp_qp_xcond_solver_config *config, int N); +// +ocp_qp_xcond_solver_dims *ocp_qp_xcond_solver_dims_create_from_ocp_qp_dims( + ocp_qp_xcond_solver_config *config, ocp_qp_dims *dims); +// +void ocp_qp_xcond_solver_dims_free(ocp_qp_xcond_solver_dims *dims_); + +void ocp_qp_xcond_solver_dims_set(void *config_, ocp_qp_xcond_solver_dims *dims, + int stage, const char *field, int* value); + + +/// Constructs an input object for the qp. +/// +/// \param dims The dimension struct. +ocp_qp_in *ocp_qp_in_create(ocp_qp_dims *dims); + + +void ocp_qp_in_set(ocp_qp_xcond_solver_config *config, ocp_qp_in *in, + int stage, char *field, void *value); + +/// Destructor of the inputs struct. +/// +/// \param in_ The inputs struct. +void ocp_qp_in_free(void *in_); + + +/// Constructs an outputs object for the qp. +/// +/// \param dims The dimension struct. +ocp_qp_out *ocp_qp_out_create(ocp_qp_dims *dims); + +/// Destructor of the output struct. +/// +/// \param out_ The output struct. +void ocp_qp_out_free(void *out_); + + +/// Getter of output struct +void ocp_qp_out_get(ocp_qp_out *out, const char *field, void *value); + + +/// Constructs an options object for the qp. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +void *ocp_qp_xcond_solver_opts_create(ocp_qp_xcond_solver_config *config, + ocp_qp_xcond_solver_dims *dims); + +/// Destructor of the options struct. +/// +/// \param opts The options struct to destroy. +void ocp_qp_xcond_solver_opts_free(ocp_qp_xcond_solver_opts *opts); + + +/// Setter of the options struct. +/// +/// \param opts The options struct. +void ocp_qp_xcond_solver_opts_set(ocp_qp_xcond_solver_config *config, + ocp_qp_xcond_solver_opts *opts, const char *field, void* value); + +/// TBC Should be private/static? +acados_size_t ocp_qp_calculate_size(ocp_qp_xcond_solver_config *config, ocp_qp_xcond_solver_dims *dims, void *opts_); + + +/// TBC Reserves memory? TBC Should this be private? +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param opts_ The options struct. +/// \param raw_memory Pointer to raw memory to assign to qp solver. +ocp_qp_solver *ocp_qp_assign(ocp_qp_xcond_solver_config *config, ocp_qp_xcond_solver_dims *dims, + void *opts_, void *raw_memory); + +/// Creates a qp solver. Reserves memory. +/// +/// \param config The configuration struct. +/// \param dims The dimension struct. +/// \param opts_ The options struct. +ocp_qp_solver *ocp_qp_create(ocp_qp_xcond_solver_config *config, + ocp_qp_xcond_solver_dims *dims, void *opts_); + + +/// Destroys a qp solver. Frees memory. +/// +/// \param solver The qp solver +void ocp_qp_solver_destroy(ocp_qp_solver *solver); + +void ocp_qp_x_cond_solver_free(ocp_qp_xcond_solver_config *config, + ocp_qp_xcond_solver_dims *dims, void *opts_); + + +/// Solves the qp. +/// +/// \param solver The solver. +/// \param qp_in The inputs struct. +/// \param qp_out The output struct. +int ocp_qp_solve(ocp_qp_solver *solver, ocp_qp_in *qp_in, ocp_qp_out *qp_out); + + +/// Calculates the infinity norm of the residuals. +/// +/// \param dims The dimension struct. +/// \param qp_in The inputs struct. +/// \param qp_out The output struct. +/// \param res Output array for the residuals. +void ocp_qp_inf_norm_residuals(ocp_qp_dims *dims, ocp_qp_in *qp_in, ocp_qp_out *qp_out, + double *res); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // INTERFACES_ACADOS_C_OCP_QP_INTERFACE_H_ diff --git a/third_party/acados/include/acados_c/sim_interface.h b/third_party/acados/include/acados_c/sim_interface.h new file mode 100644 index 00000000000000..cc47b62ed478ce --- /dev/null +++ b/third_party/acados/include/acados_c/sim_interface.h @@ -0,0 +1,140 @@ +/* + * Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, + * Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, + * Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, + * Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl + * + * This file is part of acados. + * + * The 2-Clause BSD License + * + * 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. + * + * 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.; + */ + + +#ifndef INTERFACES_ACADOS_C_SIM_INTERFACE_H_ +#define INTERFACES_ACADOS_C_SIM_INTERFACE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "acados/sim/sim_common.h" + + + +typedef enum +{ + ERK, + IRK, + GNSF, + LIFTED_IRK, + INVALID_SIM_SOLVER, +} sim_solver_t; + + + +typedef struct +{ + sim_solver_t sim_solver; +} sim_solver_plan; + + + +typedef struct +{ + sim_config *config; + void *dims; + void *opts; + void *mem; + void *work; +} sim_solver; + + + +/* config */ +// +sim_config *sim_config_create(sim_solver_plan plan); +// +void sim_config_destroy(void *config); + +/* dims */ +// +void *sim_dims_create(void *config_); +// +void sim_dims_destroy(void *dims); +// +void sim_dims_set(sim_config *config, void *dims, const char *field, const int* value); +// +void sim_dims_get(sim_config *config, void *dims, const char *field, int* value); +// +void sim_dims_get_from_attr(sim_config *config, void *dims, const char *field, int *dims_out); + +/* in */ +// +sim_in *sim_in_create(sim_config *config, void *dims); +// +void sim_in_destroy(void *out); +// +int sim_in_set(void *config_, void *dims_, sim_in *in, const char *field, void *value); + + +/* out */ +// +sim_out *sim_out_create(sim_config *config, void *dims); +// +void sim_out_destroy(void *out); +// +int sim_out_get(void *config, void *dims, sim_out *out, const char *field, void *value); + +/* opts */ +// +void *sim_opts_create(sim_config *config, void *dims); +// +void sim_opts_destroy(void *opts); +// +void sim_opts_set(sim_config *config, void *opts, const char *field, void *value); +// +void sim_opts_get(sim_config *config, void *opts, const char *field, void *value); + +/* solver */ +// +acados_size_t sim_calculate_size(sim_config *config, void *dims, void *opts_); +// +sim_solver *sim_assign(sim_config *config, void *dims, void *opts_, void *raw_memory); +// +sim_solver *sim_solver_create(sim_config *config, void *dims, void *opts_); +// +void sim_solver_destroy(void *solver); +// +int sim_solve(sim_solver *solver, sim_in *in, sim_out *out); +// +int sim_precompute(sim_solver *solver, sim_in *in, sim_out *out); +// +int sim_solver_set(sim_solver *solver, const char *field, void *value); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // INTERFACES_ACADOS_C_SIM_INTERFACE_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo.h b/third_party/acados/include/blasfeo/include/blasfeo.h new file mode 100644 index 00000000000000..c8549181937dee --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo.h @@ -0,0 +1,52 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#include "blasfeo_processor_features.h" +#include "blasfeo_target.h" +#include "blasfeo_block_size.h" +#include "blasfeo_stdlib.h" +#include "blasfeo_common.h" +#include "blasfeo_d_aux.h" +#include "blasfeo_d_aux_ext_dep.h" +#include "blasfeo_d_kernel.h" +#include "blasfeo_d_blas.h" +#include "blasfeo_s_aux.h" +#include "blasfeo_s_aux_ext_dep.h" +#include "blasfeo_s_kernel.h" +#include "blasfeo_s_blas.h" +#include "blasfeo_i_aux_ext_dep.h" +#include "blasfeo_v_aux_ext_dep.h" +#include "blasfeo_timing.h" +#include "blasfeo_memory.h" diff --git a/third_party/acados/include/blasfeo/include/blasfeo_block_size.h b/third_party/acados/include/blasfeo/include/blasfeo_block_size.h new file mode 100644 index 00000000000000..0ccd4f1bba4d15 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_block_size.h @@ -0,0 +1,392 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_BLOCK_SIZE_H_ +#define BLASFEO_BLOCK_SIZE_H_ + + + +#define D_EL_SIZE 8 // double precision +#define S_EL_SIZE 4 // single precision + + + +#if defined( TARGET_X64_INTEL_SKYLAKE_X ) +// common +#define CACHE_LINE_SIZE 64 // data cache size: 64 bytes +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB, 8-way +#define L2_CACHE_SIZE (256*1024) //(1024*1024) // L2 data cache size: 1 MB ; DTLB1 64*4 kB = 256 kB +#define LLC_CACHE_SIZE (6*1024*1024) //(8*1024*1024) // LLC cache size: 8 MB ; TLB 1536*4 kB = 6 MB +// double +#define D_PS 8 // panel size +#define D_PLD 8 // 4 // GCD of panel length +#define D_M_KERNEL 24 // max kernel size +#define D_KC 128 //256 // 192 +#define D_NC 144 //72 //96 //72 // 120 // 512 +#define D_MC 2400 // 6000 +// single +#define S_PS 16 // panel size +#define S_PLD 4 // GCD of panel length TODO probably 16 when writing assebly +#define S_M_KERNEL 32 // max kernel size +#define S_KC 128 //256 +#define S_NC 128 //144 +#define S_MC 3000 + +#elif defined( TARGET_X64_INTEL_HASWELL ) +// common +#define CACHE_LINE_SIZE 64 // data cache size: 64 bytes +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB, 8-way +#define L2_CACHE_SIZE (256*1024) // L2 data cache size: 256 kB ; DTLB1 64*4 kB = 256 kB +#define LLC_CACHE_SIZE (6*1024*1024) // LLC cache size: 6 MB ; TLB 1024*4 kB = 4 MB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 12 // max kernel size +#define D_KC 256 // 192 +#define D_NC 72 //96 //72 // 120 // 512 +#define D_MC 1500 // 6000 +// single +#define S_PS 8 // panel size +#define S_PLD 4 // 2 // GCD of panel length +#define S_M_KERNEL 24 // max kernel size +#define S_KC 256 +#define S_NC 144 +#define S_MC 3000 + +#elif defined( TARGET_X64_INTEL_SANDY_BRIDGE ) +// common +#define CACHE_LINE_SIZE 64 // data cache size: 64 bytes +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB, 8-way +#define L2_CACHE_SIZE (256*1024) // L2 data cache size: 256 kB ; DTLB1 64*4 kB = 256 kB +#define LLC_CACHE_SIZE (4*1024*1024) // LLC cache size: 4 MB ; TLB 1024*4 kB = 4 MB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 8 // max kernel size +#define D_KC 256 //320 //256 //320 +#define D_NC 72 //64 //72 //60 // 120 +#define D_MC 1000 // 800 +// single +#define S_PS 8 // panel size +#define S_PLD 4 // 2 // GCD of panel length +#define S_M_KERNEL 16 // max kernel size +#define S_KC 256 +#define S_NC 144 +#define S_MC 2000 + +#elif defined( TARGET_X64_INTEL_CORE ) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + +#elif defined( TARGET_X64_AMD_BULLDOZER ) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined( TARGET_X86_AMD_JAGUAR ) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined( TARGET_X86_AMD_BARCELONA ) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined(TARGET_ARMV8A_ARM_CORTEX_A76) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (64*1024) // L1 data cache size: 64 kB, 4-way ; DTLB1 48*4 kB = 192 kB +#define LLC_CACHE_SIZE (1*1024*1024) // LLC cache size: 1 MB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 8 // max kernel size +#define D_KC 512 //256 +#define D_NC 128 //256 +#define D_MC 6000 +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 8 // max kernel size +#define S_KC 512 +#define S_NC 256 +#define S_MC 6000 + + +#elif defined(TARGET_ARMV8A_ARM_CORTEX_A73) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 (64?) kB, 4-way, seen as 8-(16-)way ; DTLB1 48*4 kB = 192 kB +#define LLC_CACHE_SIZE (1*1024*1024) // LLC cache size: 1 MB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 8 // max kernel size +#define D_KC 320 +#define D_NC 256 +#define D_MC 6000 +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 8 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined(TARGET_ARMV8A_ARM_CORTEX_A57) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB, 2-way ; DTLB1 32*4 kB = 128 kB +#define LLC_CACHE_SIZE (1*1024*1024) // LLC cache size: 1 MB // 2 MB ??? +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 8 // max kernel size +#define D_KC 224 //256 //192 +#define D_NC 40 //36 //48 +#define D_MC 512 //488 //600 +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 8 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined(TARGET_ARMV8A_ARM_CORTEX_A55) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB, 4-way ; DTLB1 16*4 kB = 64 kB +#define LLC_CACHE_SIZE (512*1024) // LLC cache size: 512 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 12 // max kernel size +#define D_KC 224 +#define D_NC 160 +#define D_MC 6000 +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 8 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined(TARGET_ARMV8A_ARM_CORTEX_A53) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB, 4-way ??? ; DTLB1 10*4 kB = 40 kB +#define LLC_CACHE_SIZE (256*1024) // LLC cache size: 256 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 12 // max kernel size +#define D_KC 160 +#define D_NC 128 +#define D_MC 6000 +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 8 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined( TARGET_ARMV7A_ARM_CORTEX_A15 ) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined( TARGET_ARMV7A_ARM_CORTEX_A7 ) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined( TARGET_ARMV7A_ARM_CORTEX_A9 ) +// common +#define CACHE_LINE_SIZE 32 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#elif defined( TARGET_GENERIC ) +// common +#define CACHE_LINE_SIZE 64 +#define L1_CACHE_SIZE (32*1024) // L1 data cache size: 32 kB +// double +#define D_PS 4 // panel size +#define D_PLD 4 // 2 // GCD of panel length +#define D_M_KERNEL 4 // max kernel size +#define D_KC 256 +#define D_NC 128 // TODO these are just dummy +#define D_MC 3000 // TODO these are just dummy + +// single +#define S_PS 4 +#define S_PLD 4 //2 +#define S_M_KERNEL 4 // max kernel size +#define S_KC 256 +#define S_NC 128 // TODO these are just dummy +#define S_MC 3000 // TODO these are just dummy + + +#else +#error "Unknown architecture" +#endif + + + +#define D_CACHE_LINE_EL (CACHE_LINE_SIZE/D_EL_SIZE) +#define D_L1_CACHE_EL (L1_CACHE_SIZE/D_EL_SIZE) +#define D_L2_CACHE_EL (L2_CACHE_SIZE/D_EL_SIZE) +#define D_LLC_CACHE_EL (LLC_CACHE_SIZE/D_EL_SIZE) + +#define S_CACHE_LINE_EL (CACHE_LINE_SIZE/S_EL_SIZE) +#define S_L1_CACHE_EL (L1_CACHE_SIZE/S_EL_SIZE) +#define S_L2_CACHE_EL (L2_CACHE_SIZE/S_EL_SIZE) +#define S_LLC_CACHE_EL (LLC_CACHE_SIZE/S_EL_SIZE) + + + +#endif // BLASFEO_BLOCK_SIZE_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_common.h b/third_party/acados/include/blasfeo/include/blasfeo_common.h new file mode 100644 index 00000000000000..a648142ba05ed4 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_common.h @@ -0,0 +1,236 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_COMMON_H_ +#define BLASFEO_COMMON_H_ + + + +#include "blasfeo_target.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__INTEL_LLVM_COMPILER) +#define ALIGNED(VEC, BYTES) VEC __attribute__ ((aligned ( BYTES ))) +#elif defined (_MSC_VER) +#define ALIGNED(VEC, BYTES) __declspec(align( BYTES )) VEC +#else +#define ALIGNED(VEC, BYTES) VEC +#endif + + + + +#if ( defined(LA_HIGH_PERFORMANCE) & defined(MF_PANELMAJ) ) | ( defined(LA_REFERENCE) & defined(MF_PANELMAJ) ) + +#include "blasfeo_block_size.h" + +// matrix structure +struct blasfeo_dmat + { + double *mem; // pointer to passed chunk of memory + double *pA; // pointer to a pm*pn array of doubles, the first is aligned to cache line size + double *dA; // pointer to a min(m,n) (or max???) array of doubles + int m; // rows + int n; // cols + int pm; // packed number or rows + int cn; // packed number or cols + int use_dA; // flag to tell if dA can be used + int memsize; // size of needed memory + }; + +struct blasfeo_smat + { + float *mem; // pointer to passed chunk of memory + float *pA; // pointer to a pm*pn array of floats, the first is aligned to cache line size + float *dA; // pointer to a min(m,n) (or max???) array of floats + int m; // rows + int n; // cols + int pm; // packed number or rows + int cn; // packed number or cols + int use_dA; // flag to tell if dA can be used + int memsize; // size of needed memory + }; + +// vector structure +struct blasfeo_dvec + { + double *mem; // pointer to passed chunk of memory + double *pa; // pointer to a pm array of doubles, the first is aligned to cache line size + int m; // size + int pm; // packed size + int memsize; // size of needed memory + }; + +struct blasfeo_svec + { + float *mem; // pointer to passed chunk of memory + float *pa; // pointer to a pm array of floats, the first is aligned to cache line size + int m; // size + int pm; // packed size + int memsize; // size of needed memory + }; + +#define BLASFEO_DMATEL(sA,ai,aj) ((sA)->pA[((ai)-((ai)&(D_PS-1)))*(sA)->cn+(aj)*D_PS+((ai)&(D_PS-1))]) +#define BLASFEO_SMATEL(sA,ai,aj) ((sA)->pA[((ai)-((ai)&(S_PS-1)))*(sA)->cn+(aj)*S_PS+((ai)&(S_PS-1))]) +#define BLASFEO_DVECEL(sa,ai) ((sa)->pa[ai]) +#define BLASFEO_SVECEL(sa,ai) ((sa)->pa[ai]) + +#elif ( defined(LA_HIGH_PERFORMANCE) & defined(MF_COLMAJ) ) | ( defined(LA_REFERENCE) & defined(MF_COLMAJ) ) | defined(LA_EXTERNAL_BLAS_WRAPPER) + +// matrix structure +struct blasfeo_dmat + { + double *mem; // pointer to passed chunk of memory + double *pA; // pointer to a m*n array of doubles + double *dA; // pointer to a min(m,n) (or max???) array of doubles + int m; // rows + int n; // cols + int use_dA; // flag to tell if dA can be used + int memsize; // size of needed memory + }; + +struct blasfeo_smat + { + float *mem; // pointer to passed chunk of memory + float *pA; // pointer to a m*n array of floats + float *dA; // pointer to a min(m,n) (or max???) array of floats + int m; // rows + int n; // cols + int use_dA; // flag to tell if dA can be used + int memsize; // size of needed memory + }; + +// vector structure +struct blasfeo_dvec + { + double *mem; // pointer to passed chunk of memory + double *pa; // pointer to a m array of doubles, the first is aligned to cache line size + int m; // size + int memsize; // size of needed memory + }; + +struct blasfeo_svec + { + float *mem; // pointer to passed chunk of memory + float *pa; // pointer to a m array of floats, the first is aligned to cache line size + int m; // size + int memsize; // size of needed memory + }; + +#define BLASFEO_DMATEL(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m]) +#define BLASFEO_SMATEL(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m]) +#define BLASFEO_DVECEL(sa,ai) ((sa)->pa[ai]) +#define BLASFEO_SVECEL(sa,ai) ((sa)->pa[ai]) + +#else + +#error : wrong LA or MF choice + +#endif + + + +// Explicitly panel-major matrix structure +struct blasfeo_pm_dmat + { + double *mem; // pointer to passed chunk of memory + double *pA; // pointer to a pm*pn array of doubles, the first is aligned to cache line size + double *dA; // pointer to a min(m,n) (or max???) array of doubles + int m; // rows + int n; // cols + int pm; // packed number or rows + int cn; // packed number or cols + int use_dA; // flag to tell if dA can be used + int ps; // panel size + int memsize; // size of needed memory + }; + +struct blasfeo_pm_smat + { + float *mem; // pointer to passed chunk of memory + float *pA; // pointer to a pm*pn array of floats, the first is aligned to cache line size + float *dA; // pointer to a min(m,n) (or max???) array of floats + int m; // rows + int n; // cols + int pm; // packed number or rows + int cn; // packed number or cols + int use_dA; // flag to tell if dA can be used + int ps; // panel size + int memsize; // size of needed memory + }; + +// Explicitly column-major matrix structure +struct blasfeo_cm_dmat + { + double *mem; // pointer to passed chunk of memory + double *pA; // pointer to a m*n array of doubles + double *dA; // pointer to a min(m,n) (or max???) array of doubles + int m; // rows + int n; // cols + int use_dA; // flag to tell if dA can be used + int memsize; // size of needed memory + }; + +struct blasfeo_cm_smat + { + float *mem; // pointer to passed chunk of memory + float *pA; // pointer to a m*n array of floats + float *dA; // pointer to a min(m,n) (or max???) array of floats + int m; // rows + int n; // cols + int use_dA; // flag to tell if dA can be used + int memsize; // size of needed memory + }; + + +#define BLASFEO_PM_DMATEL(sA,ai,aj) ((sA)->pA[((ai)-((ai)&((sA)->ps-1)))*(sA)->cn+(aj)*((sA)->ps)+((ai)&((sA)->ps-1))]) +#define BLASFEO_PM_SMATEL(sA,ai,aj) ((sA)->pA[((ai)-((ai)&((sA)->ps-1)))*(sA)->cn+(aj)*((sA)->ps)+((ai)&((sA)->ps-1))]) +#define BLASFEO_CM_DMATEL(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m]) +#define BLASFEO_CM_SMATEL(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m]) + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_COMMON_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_aux.h b/third_party/acados/include/blasfeo/include/blasfeo_d_aux.h new file mode 100644 index 00000000000000..7a9415a59d60e7 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_aux.h @@ -0,0 +1,239 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +/* + * auxiliary algebra operations header + * + * include/blasfeo_aux_lib*.h + * + */ + +#ifndef BLASFEO_D_AUX_H_ +#define BLASFEO_D_AUX_H_ + + + +#include + +#include "blasfeo_common.h" +#include "blasfeo_d_aux_old.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +// --- memory size calculations +// +// returns the memory size (in bytes) needed for a dmat +size_t blasfeo_memsize_dmat(int m, int n); +// returns the memory size (in bytes) needed for the diagonal of a dmat +size_t blasfeo_memsize_diag_dmat(int m, int n); +// returns the memory size (in bytes) needed for a dvec +size_t blasfeo_memsize_dvec(int m); + +// --- creation +// +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_create_dmat(int m, int n, struct blasfeo_dmat *sA, void *memory); +// create a strvec for a vector of size m by using memory passed by a pointer (pointer is not updated) +void blasfeo_create_dvec(int m, struct blasfeo_dvec *sA, void *memory); + +// --- packing +// pack the column-major matrix A into the matrix struct B +void blasfeo_pack_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// pack the lower-triangular column-major matrix A into the matrix struct B +void blasfeo_pack_l_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// pack the upper-triangular column-major matrix A into the matrix struct B +void blasfeo_pack_u_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// transpose and pack the column-major matrix A into the matrix struct B +void blasfeo_pack_tran_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// pack the vector x into the vector structure y +void blasfeo_pack_dvec(int m, double *x, int xi, struct blasfeo_dvec *sy, int yi); +// unpack the matrix structure A into the column-major matrix B +void blasfeo_unpack_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, double *B, int ldb); +// transpose and unpack the matrix structure A into the column-major matrix B +void blasfeo_unpack_tran_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, double *B, int ldb); +// pack the vector structure x into the vector y +void blasfeo_unpack_dvec(int m, struct blasfeo_dvec *sx, int xi, double *y, int yi); + +// --- cast +// +//void d_cast_mat2strmat(double *A, struct blasfeo_dmat *sA); // TODO +//void d_cast_diag_mat2strmat(double *dA, struct blasfeo_dmat *sA); // TODO +//void d_cast_vec2vecmat(double *a, struct blasfeo_dvec *sx); // TODO + + +// ge +// --- insert/extract +// +// sA[ai, aj] <= a +void blasfeo_dgein1(double a, struct blasfeo_dmat *sA, int ai, int aj); +// <= sA[ai, aj] +double blasfeo_dgeex1(struct blasfeo_dmat *sA, int ai, int aj); + +// --- set +// A <= alpha +void blasfeo_dgese(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj); + +// --- copy / scale +// B <= A +void blasfeo_dgecp(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// A <= alpha*A +void blasfeo_dgesc(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +// B <= alpha*A +void blasfeo_dgecpsc(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// B <= A, A lower triangular +void blasfeo_dtrcp_l(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +void blasfeo_dtrcpsc_l(int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +void blasfeo_dtrsc_l(int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj); + +// --- sum +// B <= B + alpha*A +void blasfeo_dgead(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// y <= y + alpha*x +void blasfeo_dvecad(int m, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); + +// --- traspositions +// B <= A' +void blasfeo_dgetr(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// B <= A', A lower triangular +void blasfeo_dtrtr_l(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// B <= A', A upper triangular +void blasfeo_dtrtr_u(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); + +// dia +// diag(A) += alpha +void blasfeo_ddiare(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +// diag(A) <= alpha*x +void blasfeo_ddiain(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// diag(A)[idx] <= alpha*x +void blasfeo_ddiain_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// x <= diag(A) +void blasfeo_ddiaex(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +// x <= diag(A)[idx] +void blasfeo_ddiaex_sp(int kmax, double alpha, int *idx, struct blasfeo_dmat *sD, int di, int dj, struct blasfeo_dvec *sx, int xi); +// diag(A) += alpha*x +void blasfeo_ddiaad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// diag(A)[idx] += alpha*x +void blasfeo_ddiaad_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// diag(A)[idx] = y + alpha*x +void blasfeo_ddiaadin_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, int *idx, struct blasfeo_dmat *sD, int di, int dj); + +// row +void blasfeo_drowin(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_drowex(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +void blasfeo_drowad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_drowad_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_drowsw(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +void blasfeo_drowpe(int kmax, int *ipiv, struct blasfeo_dmat *sA); +void blasfeo_drowpei(int kmax, int *ipiv, struct blasfeo_dmat *sA); + +// col +void blasfeo_dcolex(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +void blasfeo_dcolin(int kmax, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_dcolad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_dcolsc(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_dcolsw(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +void blasfeo_dcolpe(int kmax, int *ipiv, struct blasfeo_dmat *sA); +void blasfeo_dcolpei(int kmax, int *ipiv, struct blasfeo_dmat *sA); + +// vec +// a <= alpha +void blasfeo_dvecse(int m, double alpha, struct blasfeo_dvec *sx, int xi); +// sx[xi] <= a +void blasfeo_dvecin1(double a, struct blasfeo_dvec *sx, int xi); +// <= sx[xi] +double blasfeo_dvecex1(struct blasfeo_dvec *sx, int xi); +// y <= x +void blasfeo_dveccp(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); +// x <= alpha*x +void blasfeo_dvecsc(int m, double alpha, struct blasfeo_dvec *sx, int xi); +// y <= alpha*x +void blasfeo_dveccpsc(int m, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); +void blasfeo_dvecad_sp(int m, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dvec *sz, int zi); +void blasfeo_dvecin_sp(int m, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dvec *sz, int zi); +void blasfeo_dvecex_sp(int m, double alpha, int *idx, struct blasfeo_dvec *sx, int x, struct blasfeo_dvec *sz, int zi); + +void blasfeo_dveccl(int m, + struct blasfeo_dvec *sxm, int xim, struct blasfeo_dvec *sx, int xi, + struct blasfeo_dvec *sxp, int xip, struct blasfeo_dvec *sz, int zi); + +void blasfeo_dveccl_mask(int m, + struct blasfeo_dvec *sxm, int xim, struct blasfeo_dvec *sx, int xi, + struct blasfeo_dvec *sxp, int xip, struct blasfeo_dvec *sz, int zi, + struct blasfeo_dvec *sm, int mi); + +void blasfeo_dvecze(int m, struct blasfeo_dvec *sm, int mi, struct blasfeo_dvec *sv, int vi, struct blasfeo_dvec *se, int ei); +void blasfeo_dvecnrm_inf(int m, struct blasfeo_dvec *sx, int xi, double *ptr_norm); +void blasfeo_dvecnrm_2(int m, struct blasfeo_dvec *sx, int xi, double *ptr_norm); +void blasfeo_dvecpe(int kmax, int *ipiv, struct blasfeo_dvec *sx, int xi); +void blasfeo_dvecpei(int kmax, int *ipiv, struct blasfeo_dvec *sx, int xi); + + + + + +/* +* Explicitly panel-major matrix format +*/ + +// returns the memory size (in bytes) needed for a dmat +size_t blasfeo_pm_memsize_dmat(int ps, int m, int n); +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_pm_create_dmat(int ps, int m, int n, struct blasfeo_pm_dmat *sA, void *memory); +// print +void blasfeo_pm_print_dmat(int m, int n, struct blasfeo_pm_dmat *sA, int ai, int aj); + + + +/* +* Explicitly panel-major matrix format +*/ + +// returns the memory size (in bytes) needed for a dmat +size_t blasfeo_cm_memsize_dmat(int m, int n); +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_cm_create_dmat(int m, int n, struct blasfeo_pm_dmat *sA, void *memory); + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_AUX_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ext_dep.h b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ext_dep.h new file mode 100644 index 00000000000000..bee9e986f15d8f --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ext_dep.h @@ -0,0 +1,145 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +/* + * auxiliary algebra operation external dependancies header + * + * include/blasfeo_d_aux_ext_dep.h + * + * - dynamic memory allocation + * - print + * + */ + +#ifndef BLASFEO_D_AUX_EXT_DEP_H_ +#define BLASFEO_D_AUX_EXT_DEP_H_ + + + +#include + + + +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifdef EXT_DEP + +/* column-major matrices */ + +// dynamically allocate row*col doubles of memory and set accordingly a pointer to double; set allocated memory to zero +void d_zeros(double **pA, int row, int col); +// dynamically allocate row*col doubles of memory aligned to 64-byte boundaries and set accordingly a pointer to double; set allocated memory to zero +void d_zeros_align(double **pA, int row, int col); +// dynamically allocate size bytes of memory aligned to 64-byte boundaries and set accordingly a pointer to double; set allocated memory to zero +void d_zeros_align_bytes(double **pA, int size); +// free the memory allocated by d_zeros +void d_free(double *pA); +// free the memory allocated by d_zeros_align or d_zeros_align_bytes +void d_free_align(double *pA); +// print a column-major matrix +void d_print_mat(int m, int n, double *A, int lda); +// print the transposed of a column-major matrix +void d_print_tran_mat(int row, int col, double *A, int lda); +// print to file a column-major matrix +void d_print_to_file_mat(FILE *file, int row, int col, double *A, int lda); +// print to file a column-major matrix in exponential format +void d_print_to_file_exp_mat(FILE *file, int row, int col, double *A, int lda); +// print to string a column-major matrix +void d_print_to_string_mat(char **buf_out, int row, int col, double *A, int lda); +// print to file the transposed of a column-major matrix +void d_print_tran_to_file_mat(FILE *file, int row, int col, double *A, int lda); +// print to file the transposed of a column-major matrix in exponential format +void d_print_tran_to_file_exp_mat(FILE *file, int row, int col, double *A, int lda); +// print in exponential notation a column-major matrix +void d_print_exp_mat(int m, int n, double *A, int lda); +// print in exponential notation the transposed of a column-major matrix +void d_print_exp_tran_mat(int row, int col, double *A, int lda); + +/* strmat and strvec */ + +// create a strmat for a matrix of size m*n by dynamically allocating memory +void blasfeo_allocate_dmat(int m, int n, struct blasfeo_dmat *sA); +// create a strvec for a vector of size m by dynamically allocating memory +void blasfeo_allocate_dvec(int m, struct blasfeo_dvec *sa); +// free the memory allocated by blasfeo_allocate_dmat +void blasfeo_free_dmat(struct blasfeo_dmat *sA); +// free the memory allocated by blasfeo_allocate_dvec +void blasfeo_free_dvec(struct blasfeo_dvec *sa); +// print a strmat +void blasfeo_print_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +// print in exponential notation a strmat +void blasfeo_print_exp_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +// print to file a strmat +void blasfeo_print_to_file_dmat(FILE *file, int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +// print to file a strmat in exponential format +void blasfeo_print_to_file_exp_dmat(FILE *file, int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +// print to string a strmat +void blasfeo_print_to_string_dmat(char **buf_out, int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +// print the transposed of a strmat +void blasfeo_print_tran_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +// print a strvec +void blasfeo_print_dvec(int m, struct blasfeo_dvec *sa, int ai); +// print in exponential notation a strvec +void blasfeo_print_exp_dvec(int m, struct blasfeo_dvec *sa, int ai); +// print to file a strvec +void blasfeo_print_to_file_dvec(FILE *file, int m, struct blasfeo_dvec *sa, int ai); +// print to string a strvec +void blasfeo_print_to_string_dvec(char **buf_out, int m, struct blasfeo_dvec *sa, int ai); +// print the transposed of a strvec +void blasfeo_print_tran_dvec(int m, struct blasfeo_dvec *sa, int ai); +// print in exponential notation the transposed of a strvec +void blasfeo_print_exp_tran_dvec(int m, struct blasfeo_dvec *sa, int ai); +// print to file the transposed of a strvec +void blasfeo_print_to_file_tran_dvec(FILE *file, int m, struct blasfeo_dvec *sa, int ai); +// print to string the transposed of a strvec +void blasfeo_print_to_string_tran_dvec(char **buf_out, int m, struct blasfeo_dvec *sa, int ai); + +#endif // EXT_DEP + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_AUX_EXT_DEP_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ext_dep_ref.h b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ext_dep_ref.h new file mode 100644 index 00000000000000..81b811f0325039 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ext_dep_ref.h @@ -0,0 +1,84 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +/* + * auxiliary algebra operation external dependancies header + * + * include/blasfeo_d_aux_ext_dep.h + * + * - dynamic memory allocation + * - print + * + */ + +#ifndef BLASFEO_D_AUX_EXT_DEP_REF_H_ +#define BLASFEO_D_AUX_EXT_DEP_REF_H_ + + +#include + +#include "blasfeo_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// expose reference BLASFEO for testing +// see blasfeo_d_aux_exp_dep.h for help + +void blasfeo_print_dmat_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj); +void blasfeo_allocate_dmat_ref(int m, int n, struct blasfeo_dmat_ref *sA); +void blasfeo_allocate_dvec_ref(int m, struct blasfeo_dvec_ref *sa); +void blasfeo_free_dmat_ref(struct blasfeo_dmat_ref *sA); +void blasfeo_free_dvec_ref(struct blasfeo_dvec_ref *sa); +void blasfeo_print_dmat_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj); +void blasfeo_print_exp_dmat_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj); +void blasfeo_print_to_file_dmat_ref(FILE *file, int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj); +void blasfeo_print_to_file_exp_dmat_ref(FILE *file, int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj); +void blasfeo_print_to_string_dmat_ref(char **buf_out, int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj); +void blasfeo_print_dvec(int m, struct blasfeo_dvec *sa, int ai); +void blasfeo_print_exp_dvec(int m, struct blasfeo_dvec *sa, int ai); +void blasfeo_print_to_file_dvec(FILE *file, int m, struct blasfeo_dvec *sa, int ai); +void blasfeo_print_to_string_dvec(char **buf_out, int m, struct blasfeo_dvec *sa, int ai); +void blasfeo_print_tran_dvec(int m, struct blasfeo_dvec *sa, int ai); +void blasfeo_print_exp_tran_dvec(int m, struct blasfeo_dvec *sa, int ai); +void blasfeo_print_to_file_tran_dvec(FILE *file, int m, struct blasfeo_dvec *sa, int ai); +void blasfeo_print_to_string_tran_dvec(char **buf_out, int m, struct blasfeo_dvec *sa, int ai); + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_AUX_EXT_DEP_REF_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_aux_old.h b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_old.h new file mode 100644 index 00000000000000..3a1847a6a0191d --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_old.h @@ -0,0 +1,75 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +/* + * ----------- TOMOVE + * + * expecting column major matrices + * + */ + +#include "blasfeo_common.h" + + +void dtrcp_l_lib(int m, double alpha, int offsetA, double *A, int sda, int offsetB, double *B, int sdb); +void dgead_lib(int m, int n, double alpha, int offsetA, double *A, int sda, int offsetB, double *B, int sdb); +// TODO remove ??? +void ddiain_sqrt_lib(int kmax, double *x, int offset, double *pD, int sdd); +// TODO ddiaad1 +void ddiareg_lib(int kmax, double reg, int offset, double *pD, int sdd); + + +void dgetr_lib(int m, int n, double alpha, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +void dtrtr_l_lib(int m, double alpha, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +void dtrtr_u_lib(int m, double alpha, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +void ddiaex_lib(int kmax, double alpha, int offset, double *pD, int sdd, double *x); +void ddiaad_lib(int kmax, double alpha, double *x, int offset, double *pD, int sdd); +void ddiain_libsp(int kmax, int *idx, double alpha, double *x, double *pD, int sdd); +void ddiaex_libsp(int kmax, int *idx, double alpha, double *pD, int sdd, double *x); +void ddiaad_libsp(int kmax, int *idx, double alpha, double *x, double *pD, int sdd); +void ddiaadin_libsp(int kmax, int *idx, double alpha, double *x, double *y, double *pD, int sdd); +void drowin_lib(int kmax, double alpha, double *x, double *pD); +void drowex_lib(int kmax, double alpha, double *pD, double *x); +void drowad_lib(int kmax, double alpha, double *x, double *pD); +void drowin_libsp(int kmax, double alpha, int *idx, double *x, double *pD); +void drowad_libsp(int kmax, int *idx, double alpha, double *x, double *pD); +void drowadin_libsp(int kmax, int *idx, double alpha, double *x, double *y, double *pD); +void dcolin_lib(int kmax, double *x, int offset, double *pD, int sdd); +void dcolad_lib(int kmax, double alpha, double *x, int offset, double *pD, int sdd); +void dcolin_libsp(int kmax, int *idx, double *x, double *pD, int sdd); +void dcolad_libsp(int kmax, double alpha, int *idx, double *x, double *pD, int sdd); +void dcolsw_lib(int kmax, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +void dvecin_libsp(int kmax, int *idx, double *x, double *y); +void dvecad_libsp(int kmax, int *idx, double alpha, double *x, double *y); diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ref.h b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ref.h new file mode 100644 index 00000000000000..448234044ac460 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_ref.h @@ -0,0 +1,206 @@ + +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_D_AUX_REF_H_ +#define BLASFEO_D_AUX_REF_H_ + + + +#include + +#include "blasfeo_common.h" +#include "blasfeo_d_aux_old.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +// --- memory calculations +// +// returns the memory size (in bytes) needed for a dmat +size_t blasfeo_ref_memsize_dmat(int m, int n); +// returns the memory size (in bytes) needed for the diagonal of a dmat +size_t blasfeo_ref_memsize_diag_dmat(int m, int n); +// returns the memory size (in bytes) needed for a dvec +size_t blasfeo_ref_memsize_dvec(int m); + +// --- creation +// +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_ref_create_dmat(int m, int n, struct blasfeo_dmat *sA, void *memory); +// create a strvec for a vector of size m by using memory passed by a pointer (pointer is not updated) +void blasfeo_ref_create_dvec(int m, struct blasfeo_dvec *sA, void *memory); + +// --- packing +// pack the column-major matrix A into the matrix struct B +void blasfeo_ref_pack_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// pack the lower-triangular column-major matrix A into the matrix struct B +void blasfeo_ref_pack_l_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// pack the upper-triangular column-major matrix A into the matrix struct B +void blasfeo_ref_pack_u_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// transpose and pack the column-major matrix A into the matrix struct B +void blasfeo_ref_pack_tran_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sB, int bi, int bj); +// pack the vector x into the vector structure y +void blasfeo_ref_pack_dvec(int m, double *x, int xi, struct blasfeo_dvec *sy, int yi); +// unpack the matrix structure A into the column-major matrix B +void blasfeo_ref_unpack_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, double *B, int ldb); +// transpose and unpack the matrix structure A into the column-major matrix B +void blasfeo_ref_unpack_tran_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, double *B, int ldb); +// pack the vector structure x into the vector y +void blasfeo_ref_unpack_dvec(int m, struct blasfeo_dvec *sx, int xi, double *y, int yi); + +// --- cast +// +void ref_d_cast_mat2strmat(double *A, struct blasfeo_dmat *sA); // TODO +void ref_d_cast_diag_mat2strmat(double *dA, struct blasfeo_dmat *sA); // TODO +void ref_d_cast_vec2vecmat(double *a, struct blasfeo_dvec *sx); // TODO + + +// ge +// --- insert/extract +// +// sA[ai, aj] <= a +void blasfeo_ref_dgein1(double a, struct blasfeo_dmat *sA, int ai, int aj); +// <= sA[ai, aj] +double blasfeo_ref_dgeex1(struct blasfeo_dmat *sA, int ai, int aj); + +// --- set +// A <= alpha +void blasfeo_ref_dgese(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj); + +// --- copy / scale +// B <= A +void blasfeo_ref_dgecp(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// A <= alpha*A +void blasfeo_ref_dgesc(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +// B <= alpha*A +void blasfeo_ref_dgecpsc(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// B <= A, A lower triangular +void blasfeo_ref_dtrcp_l(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +void blasfeo_ref_dtrcpsc_l(int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +void blasfeo_ref_dtrsc_l(int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj); + +// --- sum +// B <= B + alpha*A +void blasfeo_ref_dgead(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int yi, int cj); +// y <= y + alpha*x +void blasfeo_ref_dvecad(int m, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); + +// --- traspositions +// B <= A' +void blasfeo_ref_dgetr(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// B <= A', A lower triangular +void blasfeo_ref_dtrtr_l(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); +// B <= A', A upper triangular +void blasfeo_ref_dtrtr_u(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj); + +// dia +// diag(A) += alpha +void blasfeo_ref_ddiare(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +// diag(A) <= alpha*x +void blasfeo_ref_ddiain(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// diag(A)[idx] <= alpha*x +void blasfeo_ref_ddiain_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// x <= diag(A) +void blasfeo_ref_ddiaex(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +// x <= diag(A)[idx] +void blasfeo_ref_ddiaex_sp(int kmax, double alpha, int *idx, struct blasfeo_dmat *sD, int di, int dj, struct blasfeo_dvec *sx, int xi); +// diag(A) += alpha*x +void blasfeo_ref_ddiaad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// diag(A)[idx] += alpha*x +void blasfeo_ref_ddiaad_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// diag(A)[idx] = y + alpha*x +void blasfeo_ref_ddiaadin_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, int *idx, struct blasfeo_dmat *sD, int di, int dj); + +// row +void blasfeo_ref_drowin(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_ref_drowex(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +void blasfeo_ref_drowad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_ref_drowad_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_ref_drowsw(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +void blasfeo_ref_drowpe(int kmax, int *ipiv, struct blasfeo_dmat *sA); +void blasfeo_ref_drowpei(int kmax, int *ipiv, struct blasfeo_dmat *sA); + +// col +void blasfeo_ref_dcolex(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +void blasfeo_ref_dcolin(int kmax, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_ref_dcolad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_ref_dcolsc(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +void blasfeo_ref_dcolsw(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +void blasfeo_ref_dcolpe(int kmax, int *ipiv, struct blasfeo_dmat *sA); +void blasfeo_ref_dcolpei(int kmax, int *ipiv, struct blasfeo_dmat *sA); + +// vec +// a <= alpha +void blasfeo_ref_dvecse(int m, double alpha, struct blasfeo_dvec *sx, int xi); +// sx[xi] <= a +void blasfeo_ref_dvecin1(double a, struct blasfeo_dvec *sx, int xi); +// <= sx[xi] +double blasfeo_ref_dvecex1(struct blasfeo_dvec *sx, int xi); +// y <= x +void blasfeo_ref_dveccp(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); +// x <= alpha*x +void blasfeo_ref_dvecsc(int m, double alpha, struct blasfeo_dvec *sx, int xi); +// y <= alpha*x +void blasfeo_ref_dveccpsc(int m, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); +void blasfeo_ref_dvecad_sp(int m, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dvec *sz, int zi); +void blasfeo_ref_dvecin_sp(int m, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dvec *sz, int zi); +void blasfeo_ref_dvecex_sp(int m, double alpha, int *idx, struct blasfeo_dvec *sx, int x, struct blasfeo_dvec *sz, int zi); + +void blasfeo_ref_dveccl(int m, + struct blasfeo_dvec *sxm, int xim, struct blasfeo_dvec *sx, int xi, + struct blasfeo_dvec *sxp, int xip, struct blasfeo_dvec *sz, int zi); + +void blasfeo_ref_dveccl_mask(int m, + struct blasfeo_dvec *sxm, int xim, struct blasfeo_dvec *sx, int xi, + struct blasfeo_dvec *sxp, int xip, struct blasfeo_dvec *sz, int zi, + struct blasfeo_dvec *sm, int mi); + +void blasfeo_ref_dvecze(int m, struct blasfeo_dvec *sm, int mi, struct blasfeo_dvec *sv, int vi, struct blasfeo_dvec *se, int ei); +void blasfeo_ref_dvecnrm_inf(int m, struct blasfeo_dvec *sx, int xi, double *ptr_norm); +void blasfeo_ref_dvecpe(int kmax, int *ipiv, struct blasfeo_dvec *sx, int xi); +void blasfeo_ref_dvecpei(int kmax, int *ipiv, struct blasfeo_dvec *sx, int xi); + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_AUX_REF_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_aux_test.h b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_test.h new file mode 100644 index 00000000000000..1c61635f3ffbfa --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_aux_test.h @@ -0,0 +1,226 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +/* + * auxiliary algebra operations header + * + * include/blasfeo_aux_lib*.h + * + */ + +#ifndef BLASFEO_D_AUX_TEST_H_ +#define BLASFEO_D_AUX_TEST_H_ + +#include "blasfeo_common.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// --- memory calculations +int test_blasfeo_memsize_dmat(int m, int n); +int test_blasfeo_memsize_diag_dmat(int m, int n); +int test_blasfeo_memsize_dvec(int m); + +// --- creation +void test_blasfeo_create_dmat(int m, int n, struct blasfeo_dmat *sA, void *memory); +void test_blasfeo_create_dvec(int m, struct blasfeo_dvec *sA, void *memory); + +// --- conversion +void test_blasfeo_pack_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sA, int ai, int aj); +void test_blasfeo_pack_dvec(int m, double *x, int xi, struct blasfeo_dvec *sa, int ai); +void test_blasfeo_pack_tran_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sA, int ai, int aj); +void test_blasfeo_unpack_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, double *A, int lda); +void test_blasfeo_unpack_dvec(int m, struct blasfeo_dvec *sa, int ai, double *x, int xi); +void test_blasfeo_unpack_tran_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, double *A, int lda); + +// --- cast +void test_d_cast_mat2strmat(double *A, struct blasfeo_dmat *sA); +void test_d_cast_diag_mat2strmat(double *dA, struct blasfeo_dmat *sA); +void test_d_cast_vec2vecmat(double *a, struct blasfeo_dvec *sa); + +// ------ copy / scale + +// B <= A +void test_blasfeo_dgecp(int m, int n, + struct blasfeo_dmat *sA, int ai, int aj, + struct blasfeo_dmat *sB, int bi, int bj); + +// A <= alpha*A +void test_blasfeo_dgesc(int m, int n, + double alpha, + struct blasfeo_dmat *sA, int ai, int aj); + +// B <= alpha*A +void test_blasfeo_dgecpsc(int m, int n, + double alpha, + struct blasfeo_dmat *sA, int ai, int aj, + struct blasfeo_dmat *sB, int bi, int bj); + +// // --- insert/extract +// // +// // <= sA[ai, aj] +// void test_blasfeo_dgein1(double a, struct blasfeo_dmat *sA, int ai, int aj); +// // <= sA[ai, aj] +// double blasfeo_dgeex1(struct blasfeo_dmat *sA, int ai, int aj); +// // sx[xi] <= a +// void test_blasfeo_dvecin1(double a, struct blasfeo_dvec *sx, int xi); +// // <= sx[xi] +// double blasfeo_dvecex1(struct blasfeo_dvec *sx, int xi); +// // A <= alpha + +// // --- set +// void test_blasfeo_dgese(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +// // a <= alpha +// void test_blasfeo_dvecse(int m, double alpha, struct blasfeo_dvec *sx, int xi); +// // B <= A + + +// // --- vector +// // y <= x +// void test_blasfeo_dveccp(int m, struct blasfeo_dvec *sa, int ai, struct blasfeo_dvec *sc, int ci); +// // x <= alpha*x +// void test_blasfeo_dvecsc(int m, double alpha, struct blasfeo_dvec *sa, int ai); +// // TODO +// // x <= alpha*x +// void test_blasfeo_dveccpsc(int m, double alpha, struct blasfeo_dvec *sa, int ai, struct blasfeo_dvec *sc, int ci); + + +// // B <= A, A lower triangular +// void test_blasfeo_dtrcp_l(int m, +// struct blasfeo_dmat *sA, int ai, int aj, +// struct blasfeo_dmat *sB, int bi, int bj); + +// void test_blasfeo_dtrcpsc_l(int m, double alpha, +// struct blasfeo_dmat *sA, int ai, int aj, +// struct blasfeo_dmat *sB, int bi, int bj); + +// void test_blasfeo_dtrsc_l(int m, double alpha, +// struct blasfeo_dmat *sA, int ai, int aj); + + +// // B <= B + alpha*A +// void test_blasfeo_dgead(int m, int n, double alpha, +// struct blasfeo_dmat *sA, int ai, int aj, +// struct blasfeo_dmat *sC, int ci, int cj); + +// // y <= y + alpha*x +// void test_blasfeo_dvecad(int m, double alpha, +// struct blasfeo_dvec *sa, int ai, +// struct blasfeo_dvec *sc, int ci); + +// // --- traspositions +// void test_dgetr_lib(int m, int n, double alpha, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +// void test_blasfeo_dgetr(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +// void test_dtrtr_l_lib(int m, double alpha, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +// void test_blasfeo_dtrtr_l(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +// void test_dtrtr_u_lib(int m, double alpha, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +// void test_blasfeo_dtrtr_u(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +// void test_blasfeo_ddiare(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj); +// void test_blasfeo_ddiain(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// void test_ddiaex_lib(int kmax, double alpha, int offset, double *pD, int sdd, double *x); +// void test_ddiaad_lib(int kmax, double alpha, double *x, int offset, double *pD, int sdd); +// void test_ddiain_libsp(int kmax, int *idx, double alpha, double *x, double *pD, int sdd); +// void test_blasfeo_ddiain_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// void test_ddiaex_libsp(int kmax, int *idx, double alpha, double *pD, int sdd, double *x); +// void test_blasfeo_ddiaex(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +// void test_blasfeo_ddiaex_sp(int kmax, double alpha, int *idx, struct blasfeo_dmat *sD, int di, int dj, struct blasfeo_dvec *sx, int xi); +// void test_blasfeo_ddiaad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// void test_ddiaad_libsp(int kmax, int *idx, double alpha, double *x, double *pD, int sdd); +// void test_blasfeo_ddiaad_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// void test_ddiaadin_libsp(int kmax, int *idx, double alpha, double *x, double *y, double *pD, int sdd); +// void test_blasfeo_ddiaadin_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// void test_drowin_lib(int kmax, double alpha, double *x, double *pD); +// void test_blasfeo_drowin(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// void test_drowex_lib(int kmax, double alpha, double *pD, double *x); +// void test_blasfeo_drowex(int kmax, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +// void test_drowad_lib(int kmax, double alpha, double *x, double *pD); +// void test_blasfeo_drowad(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// void test_drowin_libsp(int kmax, double alpha, int *idx, double *x, double *pD); +// void test_drowad_libsp(int kmax, int *idx, double alpha, double *x, double *pD); +// void test_blasfeo_drowad_sp(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dmat *sD, int di, int dj); +// void test_drowadin_libsp(int kmax, int *idx, double alpha, double *x, double *y, double *pD); +// void test_drowsw_lib(int kmax, double *pA, double *pC); +// void test_blasfeo_drowsw(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +// void test_blasfeo_drowpe(int kmax, int *ipiv, struct blasfeo_dmat *sA); +// void test_blasfeo_dcolex(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi); +// void test_dcolin_lib(int kmax, double *x, int offset, double *pD, int sdd); +// void test_blasfeo_dcolin(int kmax, struct blasfeo_dvec *sx, int xi, struct blasfeo_dmat *sA, int ai, int aj); +// void test_dcolad_lib(int kmax, double alpha, double *x, int offset, double *pD, int sdd); +// void test_dcolin_libsp(int kmax, int *idx, double *x, double *pD, int sdd); +// void test_dcolad_libsp(int kmax, double alpha, int *idx, double *x, double *pD, int sdd); +// void test_dcolsw_lib(int kmax, int offsetA, double *pA, int sda, int offsetC, double *pC, int sdc); +// void test_blasfeo_dcolsw(int kmax, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sC, int ci, int cj); +// void test_blasfeo_dcolpe(int kmax, int *ipiv, struct blasfeo_dmat *sA); +// void test_dvecin_libsp(int kmax, int *idx, double *x, double *y); +// void test_dvecad_libsp(int kmax, int *idx, double alpha, double *x, double *y); +// void test_blasfeo_dvecad_sp(int m, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dvec *sz, int zi); +// void test_blasfeo_dvecin_sp(int m, double alpha, struct blasfeo_dvec *sx, int xi, int *idx, struct blasfeo_dvec *sz, int zi); +// void test_blasfeo_dvecex_sp(int m, double alpha, int *idx, struct blasfeo_dvec *sx, int x, struct blasfeo_dvec *sz, int zi); +// void test_blasfeo_dveccl(int m, struct blasfeo_dvec *sxm, int xim, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sxp, int xip, struct blasfeo_dvec *sz, int zi); +// void test_blasfeo_dveccl_mask(int m, struct blasfeo_dvec *sxm, int xim, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sxp, int xip, struct blasfeo_dvec *sz, int zi, struct blasfeo_dvec *sm, int mi); +// void test_blasfeo_dvecze(int m, struct blasfeo_dvec *sm, int mi, struct blasfeo_dvec *sv, int vi, struct blasfeo_dvec *se, int ei); +// void test_blasfeo_dvecnrm_inf(int m, struct blasfeo_dvec *sx, int xi, double *ptr_norm); +// void test_blasfeo_dvecpe(int kmax, int *ipiv, struct blasfeo_dvec *sx, int xi); +// void test_blasfeo_dvecpei(int kmax, int *ipiv, struct blasfeo_dvec *sx, int xi); + +// ext_dep + +void test_blasfeo_allocate_dmat(int m, int n, struct blasfeo_dmat *sA); +void test_blasfeo_allocate_dvec(int m, struct blasfeo_dvec *sa); + +void test_blasfeo_free_dmat(struct blasfeo_dmat *sA); +void test_blasfeo_free_dvec(struct blasfeo_dvec *sa); + +void test_blasfeo_print_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +void test_blasfeo_print_dvec(int m, struct blasfeo_dvec *sa, int ai); +void test_blasfeo_print_tran_dvec(int m, struct blasfeo_dvec *sa, int ai); + +void test_blasfeo_print_to_file_dmat(FILE *file, int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +void test_blasfeo_print_to_file_dvec(FILE *file, int m, struct blasfeo_dvec *sa, int ai); +void test_blasfeo_print_to_file_tran_dvec(FILE *file, int m, struct blasfeo_dvec *sa, int ai); + +void test_blasfeo_print_exp_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj); +void test_blasfeo_print_exp_dvec(int m, struct blasfeo_dvec *sa, int ai); +void test_blasfeo_print_exp_tran_dvec(int m, struct blasfeo_dvec *sa, int ai); + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_AUX_TEST_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_blas.h b/third_party/acados/include/blasfeo/include/blasfeo_d_blas.h new file mode 100644 index 00000000000000..ea8d00673128bd --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_blas.h @@ -0,0 +1,46 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_D_BLAS_H_ +#define BLASFEO_D_BLAS_H_ + + + +#include "blasfeo_d_blasfeo_api.h" +#include "blasfeo_d_blas_api.h" + + + +#endif // BLASFEO_D_BLAS_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_blas_api.h b/third_party/acados/include/blasfeo/include/blasfeo_d_blas_api.h new file mode 100644 index 00000000000000..64dd43f6776180 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_blas_api.h @@ -0,0 +1,161 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef BLASFEO_D_BLAS_API_H_ +#define BLASFEO_D_BLAS_API_H_ + + + +#include "blasfeo_target.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifdef BLAS_API + + + +#ifdef FORTRAN_BLAS_API + + + +// BLAS 1 +// +void daxpy_(int *n, double *alpha, double *x, int *incx, double *y, int *incy); +// +void dcopy_(int *n, double *x, int *incx, double *y, int *incy); +// +double ddot_(int *n, double *x, int *incx, double *y, int *incy); + +// BLAS 3 +// +void dgemm_(char *ta, char *tb, int *m, int *n, int *k, double *alpha, double *A, int *lda, double *B, int *ldb, double *beta, double *C, int *ldc); +// +void dsyrk_(char *uplo, char *ta, int *m, int *k, double *alpha, double *A, int *lda, double *beta, double *C, int *ldc); +// +void dtrmm_(char *side, char *uplo, char *transa, char *diag, int *m, int *n, double *alpha, double *A, int *lda, double *B, int *ldb); +// +void dtrsm_(char *side, char *uplo, char *transa, char *diag, int *m, int *n, double *alpha, double *A, int *lda, double *B, int *ldb); + + + +// LAPACK +// +void dgesv_(int *m, int *n, double *A, int *lda, int *ipiv, double *B, int *ldb, int *info); +// +void dgetrf_(int *m, int *n, double *A, int *lda, int *ipiv, int *info); +// +void dgetrf_np_(int *m, int *n, double *A, int *lda, int *info); +// +void dgetrs_(char *trans, int *m, int *n, double *A, int *lda, int *ipiv, double *B, int *ldb, int *info); +// +void dlaswp_(int *n, double *A, int *lda, int *k1, int *k2, int *ipiv, int *incx); +// +void dposv_(char *uplo, int *m, int *n, double *A, int *lda, double *B, int *ldb, int *info); +// +void dpotrf_(char *uplo, int *m, double *A, int *lda, int *info); +// +void dpotrs_(char *uplo, int *m, int *n, double *A, int *lda, double *B, int *ldb, int *info); +// +void dtrtrs_(char *uplo, char *trans, char *diag, int *m, int *n, double *A, int *lda, double *B, int *ldb, int *info); + + + +#else // BLASFEO_API + + + +// BLAS 1 +// +void blas_daxpy(int *n, double *alpha, double *x, int *incx, double *y, int *incy); +// +double blas_ddot(int *n, double *x, int *incx, double *y, int *incy); +// +void blas_dcopy(int *n, double *x, int *incx, double *y, int *incy); + +// BLAS 3 +// +void blas_dgemm(char *ta, char *tb, int *m, int *n, int *k, double *alpha, double *A, int *lda, double *B, int *ldb, double *beta, double *C, int *ldc); +// +void blas_dsyrk(char *uplo, char *ta, int *m, int *k, double *alpha, double *A, int *lda, double *beta, double *C, int *ldc); +// +void blas_dtrmm(char *side, char *uplo, char *transa, char *diag, int *m, int *n, double *alpha, double *A, int *lda, double *B, int *ldb); +// +void blas_dtrsm(char *side, char *uplo, char *transa, char *diag, int *m, int *n, double *alpha, double *A, int *lda, double *B, int *ldb); + + + +// LAPACK +// +void blas_dgesv(int *m, int *n, double *A, int *lda, int *ipiv, double *B, int *ldb, int *info); +// +void blas_dgetrf(int *m, int *n, double *A, int *lda, int *ipiv, int *info); +// +void blas_dgetrf_np(int *m, int *n, double *A, int *lda, int *info); +// +void blas_dgetrs(char *trans, int *m, int *n, double *A, int *lda, int *ipiv, double *B, int *ldb, int *info); +// +void blas_dlaswp(int *n, double *A, int *lda, int *k1, int *k2, int *ipiv, int *incx); +// +void blas_dposv(char *uplo, int *m, int *n, double *A, int *lda, double *B, int *ldb, int *info); +// +void blas_dpotrf(char *uplo, int *m, double *A, int *lda, int *info); +// +void blas_dpotrs(char *uplo, int *m, int *n, double *A, int *lda, double *B, int *ldb, int *info); +// +void blas_dtrtrs(char *uplo, char *trans, char *diag, int *m, int *n, double *A, int *lda, double *B, int *ldb, int *info); + + + +#endif // BLASFEO_API + + + +#endif // BLAS_API + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_BLAS_API_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_api.h b/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_api.h new file mode 100644 index 00000000000000..15915f436fc3b2 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_api.h @@ -0,0 +1,342 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_D_BLASFEO_API_H_ +#define BLASFEO_D_BLASFEO_API_H_ + + + +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +// level 1 BLAS +// + +// z = y + alpha*x +// z[zi:zi+n] = alpha*x[xi:xi+n] + y[yi:yi+n] +// NB: Different arguments semantic compare to equivalent standard BLAS routine +void blasfeo_daxpy(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z = beta*y + alpha*x +void blasfeo_daxpby(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z = x .* y +void blasfeo_dvecmul(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z += x .* y +void blasfeo_dvecmulacc(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z = x .* y, return sum(z) = x^T * y +double blasfeo_dvecmuldot(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// return x^T * y +double blasfeo_ddot(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); +// construct givens plane rotation +void blasfeo_drotg(double a, double b, double *c, double *s); +// apply plane rotation [a b] [c -s; s; c] to the aj0 and aj1 columns of A at row index ai +void blasfeo_dcolrot(int m, struct blasfeo_dmat *sA, int ai, int aj0, int aj1, double c, double s); +// apply plane rotation [c s; -s c] [a; b] to the ai0 and ai1 rows of A at column index aj +void blasfeo_drowrot(int m, struct blasfeo_dmat *sA, int ai0, int ai1, int aj, double c, double s); + + + +// +// level 2 BLAS +// + +// dense + +// z <= beta * y + alpha * A * x +void blasfeo_dgemv_n(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z <= beta * y + alpha * A^T * x +void blasfeo_dgemv_t(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A ) * x, A (m)x(n) +void blasfeo_dtrsv_lnn_mn(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A^T ) * x, A (m)x(n) +void blasfeo_dtrsv_ltn_mn(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, not_unit +void blasfeo_dtrsv_lnn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, unit +void blasfeo_dtrsv_lnu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A^T ) * x, A (m)x(m) lower, transposed, not_unit +void blasfeo_dtrsv_ltn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A^T ) * x, A (m)x(m) lower, transposed, unit +void blasfeo_dtrsv_ltu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A^T ) * x, A (m)x(m) upper, not_transposed, not_unit +void blasfeo_dtrsv_unn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A^T ) * x, A (m)x(m) upper, transposed, not_unit +void blasfeo_dtrsv_utn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A * x ; A lower triangular +void blasfeo_dtrmv_lnn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A * x ; A lower triangular, unit diagonal +void blasfeo_dtrmv_lnu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A^T * x ; A lower triangular +void blasfeo_dtrmv_ltn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A^T * x ; A lower triangular, unit diagonal +void blasfeo_dtrmv_ltu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= beta * y + alpha * A * x ; A upper triangular +void blasfeo_dtrmv_unn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A^T * x ; A upper triangular +void blasfeo_dtrmv_utn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z_n <= beta_n * y_n + alpha_n * A * x_n +// z_t <= beta_t * y_t + alpha_t * A^T * x_t +void blasfeo_dgemv_nt(int m, int n, double alpha_n, double alpha_t, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx_n, int xi_n, struct blasfeo_dvec *sx_t, int xi_t, double beta_n, double beta_t, struct blasfeo_dvec *sy_n, int yi_n, struct blasfeo_dvec *sy_t, int yi_t, struct blasfeo_dvec *sz_n, int zi_n, struct blasfeo_dvec *sz_t, int zi_t); +// z <= beta * y + alpha * A * x, where A is symmetric and only the lower triangular patr of A is accessed +void blasfeo_dsymv_l(int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +void blasfeo_dsymv_l_mn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); + +// diagonal + +// z <= beta * y + alpha * A * x, A diagonal +void blasfeo_dgemv_d(int m, double alpha, struct blasfeo_dvec *sA, int ai, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); + + + +// +// level 3 BLAS +// + +// dense + +// D <= beta * C + alpha * A * B +void blasfeo_dgemm_nn(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T +void blasfeo_dgemm_nt(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B +void blasfeo_dgemm_tn(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B^T +void blasfeo_dgemm_tt(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T ; C, D lower triangular +void blasfeo_dsyrk_ln(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_dsyrk_ln_mn(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#if ( defined(LA_HIGH_PERFORMANCE) & defined(MF_COLMAJ) ) +void blasfeo_dsyrk3_ln(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#endif +// D <= beta * C + alpha * A^T * B ; C, D lower triangular +void blasfeo_dsyrk_lt(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#if ( defined(LA_HIGH_PERFORMANCE) & defined(MF_COLMAJ) ) +void blasfeo_dsyrk3_lt(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#endif +// D <= beta * C + alpha * A * B^T ; C, D upper triangular +void blasfeo_dsyrk_un(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#if ( defined(LA_HIGH_PERFORMANCE) & defined(MF_COLMAJ) ) +void blasfeo_dsyrk3_un(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#endif +// D <= beta * C + alpha * A^T * B ; C, D upper triangular +void blasfeo_dsyrk_ut(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#if ( defined(LA_HIGH_PERFORMANCE) & defined(MF_COLMAJ) ) +void blasfeo_dsyrk3_ut(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +#endif +// D <= alpha * A * B ; A lower triangular +void blasfeo_dtrmm_llnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B ; A lower triangular +void blasfeo_dtrmm_llnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A lower triangular +void blasfeo_dtrmm_lltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A lower triangular +void blasfeo_dtrmm_lltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B ; A upper triangular +void blasfeo_dtrmm_lunn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B ; A upper triangular +void blasfeo_dtrmm_lunu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A upper triangular +void blasfeo_dtrmm_lutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A upper triangular +void blasfeo_dtrmm_lutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A lower triangular +void blasfeo_dtrmm_rlnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A lower triangular +void blasfeo_dtrmm_rlnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A lower triangular +void blasfeo_dtrmm_rltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A lower triangular +void blasfeo_dtrmm_rltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A upper triangular +void blasfeo_dtrmm_runn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A upper triangular +void blasfeo_dtrmm_runu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A upper triangular +void blasfeo_dtrmm_rutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A upper triangular +void blasfeo_dtrmm_rutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular employint explicit inverse of diagonal +// D <= alpha * A^{-1} * B , with A lower triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_llnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular with unit diagonal +void blasfeo_dtrsm_llnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_lltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular with unit diagonal +void blasfeo_dtrsm_lltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_lunn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular with unit diagonal +void blasfeo_dtrsm_lunu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_lutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular with unit diagonal +void blasfeo_dtrsm_lutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_rlnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular with unit diagonal +void blasfeo_dtrsm_rlnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_rltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular with unit diagonal +void blasfeo_dtrsm_rltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_runn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular with unit diagonal +void blasfeo_dtrsm_runu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_dtrsm_rutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular with unit diagonal +void blasfeo_dtrsm_rutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); + +// diagonal + +// D <= alpha * A * B + beta * C, with A diagonal (stored as strvec) +void dgemm_diag_left_lib(int m, int n, double alpha, double *dA, double *pB, int sdb, double beta, double *pC, int sdc, double *pD, int sdd); +void blasfeo_dgemm_dn(int m, int n, double alpha, struct blasfeo_dvec *sA, int ai, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B + beta * C, with B diagonal (stored as strvec) +void blasfeo_dgemm_nd(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sB, int bi, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); + + + +// +// LAPACK +// + +// D <= chol( C ) ; C, D lower triangular +void blasfeo_dpotrf_l(int m, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_dpotrf_l_mn(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= chol( C ) ; C, D upper triangular +void blasfeo_dpotrf_u(int m, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= chol( C + A * B' ) ; C, D lower triangular +// D <= chol( C + A * B^T ) ; C, D lower triangular +void blasfeo_dsyrk_dpotrf_ln(int m, int k, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_dsyrk_dpotrf_ln_mn(int m, int n, int k, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= lu( C ) ; no pivoting +void blasfeo_dgetrf_np(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= lu( C ) ; row pivoting +void blasfeo_dgetrf_rp(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, int *ipiv); +// D <= qr( C ) +int blasfeo_dgeqrf_worksize(int m, int n); // in bytes +void blasfeo_dgeqrf(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +// D <= Q factor, where C is the output of the LQ factorization +int blasfeo_dorglq_worksize(int m, int n, int k); // in bytes +void blasfeo_dorglq(int m, int n, int k, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +// D <= lq( C ) +void blasfeo_dgelqf(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +int blasfeo_dgelqf_worksize(int m, int n); // in bytes +// D <= lq( C ), positive diagonal elements +void blasfeo_dgelqf_pd(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +// [L, A] <= lq( [L, A] ), positive diagonal elements, array of matrices, with +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_dgelqf_pd_la(int m, int n1, struct blasfeo_dmat *sL, int li, int lj, struct blasfeo_dmat *sA, int ai, int aj, void *work); +// [L, L, A] <= lq( [L, L, A] ), positive diagonal elements, array of matrices, with: +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_dgelqf_pd_lla(int m, int n1, struct blasfeo_dmat *sL0, int l0i, int l0j, struct blasfeo_dmat *sL1, int l1i, int l1j, struct blasfeo_dmat *sA, int ai, int aj, void *work); + + + +// +// BLAS API helper functions +// + +#if ( defined(BLAS_API) & defined(MF_PANELMAJ) ) +// BLAS 3 +void blasfeo_cm_dgemm_nn(int m, int n, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dgemm_nt(int m, int n, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dgemm_tn(int m, int n, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dgemm_tt(int m, int n, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk_ln(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk_lt(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk_un(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk_ut(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk3_ln(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk3_lt(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk3_un(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dsyrk3_ut(int m, int k, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, double beta, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_llnn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_llnu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_lltn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_lltu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_lunn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_lunu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_lutn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_lutu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_rlnn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_rlnu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_rltn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_rltu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_runn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_runu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_rutn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrsm_rutu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_llnn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_llnu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_lltn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_lltu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_lunn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_lunu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_lutn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_lutu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_rlnn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_rlnu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_rltn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_rltu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_runn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_runu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_rutn(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dtrmm_rutu(int m, int n, double alpha, struct blasfeo_cm_dmat *sA, int ai, int aj, struct blasfeo_cm_dmat *sB, int bi, int bj, struct blasfeo_cm_dmat *sD, int di, int dj); +// LAPACK +void blasfeo_cm_dpotrf_l(int m, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dpotrf_u(int m, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj); +void blasfeo_cm_dgetrf_rp(int m, int n, struct blasfeo_cm_dmat *sC, int ci, int cj, struct blasfeo_cm_dmat *sD, int di, int dj, int *ipiv); +#endif + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_BLASFEO_API_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_api_ref.h b/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_api_ref.h new file mode 100644 index 00000000000000..141a1f0f06082c --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_api_ref.h @@ -0,0 +1,147 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_D_BLASFEO_API_REF_H_ +#define BLASFEO_D_BLASFEO_API_REF_H_ + +#include "blasfeo_common.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +// expose reference BLASFEO for testing + +// --- level 1 + +void blasfeo_daxpy_ref(int kmax, double alpha, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_daxpby_ref(int kmax, double alpha, struct blasfeo_dvec_ref *sx, int xi, double beta, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dvecmul_ref(int m, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dvecmulacc_ref(int m, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); +double blasfeo_dvecmuldot_ref(int m, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); +double blasfeo_ddot_ref(int m, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sy, int yi); +void blasfeo_drotg_ref(double a, double b, double *c, double *s); +void blasfeo_dcolrot_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj0, int aj1, double c, double s); +void blasfeo_drowrot_ref(int m, struct blasfeo_dmat_ref *sA, int ai0, int ai1, int aj, double c, double s); + + +// --- level 2 + +// dense +void blasfeo_dgemv_n_ref(int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, double beta, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dgemv_t_ref(int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, double beta, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_lnn_mn_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_ltn_mn_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_lnn_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_lnu_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_ltn_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_ltu_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_unn_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrsv_utn_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrmv_unn_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrmv_utn_ref(int m, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrmv_lnn_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrmv_ltn_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrmv_lnu_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dtrmv_ltu_ref(int m, int n, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, struct blasfeo_dvec_ref *sz, int zi); +void blasfeo_dgemv_nt_ref(int m, int n, double alpha_n, double alpha_t, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx_n, int xi_n, struct blasfeo_dvec_ref *sx_t, int xi_t, double beta_n, double beta_t, struct blasfeo_dvec_ref *sy_n, int yi_n, struct blasfeo_dvec_ref *sy_t, int yi_t, struct blasfeo_dvec_ref *sz_n, int zi_n, struct blasfeo_dvec_ref *sz_t, int zi_t); +void blasfeo_dsymv_l_ref(int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sx, int xi, double beta, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); + +// diagonal +void blasfeo_dgemv_d_ref(int m, double alpha, struct blasfeo_dvec_ref *sA, int ai, struct blasfeo_dvec_ref *sx, int xi, double beta, struct blasfeo_dvec_ref *sy, int yi, struct blasfeo_dvec_ref *sz, int zi); + + +// --- level 3 + +// dense +void blasfeo_dgemm_nn_ref( int m, int n, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dgemm_nt_ref( int m, int n, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dgemm_tn_ref(int m, int n, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dgemm_tt_ref(int m, int n, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); + +void blasfeo_dsyrk_ln_mn_ref( int m, int n, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dsyrk_ln_ref( int m, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dsyrk_lt_ref( int m, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dsyrk_un_ref( int m, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dsyrk_ut_ref( int m, int k, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); + +void blasfeo_dtrmm_rutn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrmm_rlnn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); + +void blasfeo_dtrsm_lunu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_lunn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_lutu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_lutn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_llnu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_llnn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_lltu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_lltn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_runu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_runn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_rutu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_rutn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_rlnu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_rlnn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_rltu_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dtrsm_rltn_ref( int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sD, int di, int dj); + +// diagonal +void dgemm_diag_left_lib_ref(int m, int n, double alpha, double *dA, double *pB, int sdb, double beta, double *pC, int sdc, double *pD, int sdd); +void blasfeo_dgemm_dn_ref(int m, int n, double alpha, struct blasfeo_dvec_ref *sA, int ai, struct blasfeo_dmat_ref *sB, int bi, int bj, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dgemm_nd_ref(int m, int n, double alpha, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dvec_ref *sB, int bi, double beta, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); + +// --- lapack + +void blasfeo_dgetrf_nopivot_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dgetrf_rowpivot_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj, int *ipiv); +void blasfeo_dpotrf_l_ref(int m, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dpotrf_l_mn_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dsyrk_dpotrf_ln_ref(int m, int k, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dsyrk_dpotrf_ln_mn_ref(int m, int n, int k, struct blasfeo_dmat_ref *sA, int ai, int aj, struct blasfeo_dmat_ref *sB, int bi, int bj, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dgetrf_nopivot_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj); +void blasfeo_dgetrf_rowpivot_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj, int *ipiv); +void blasfeo_dgeqrf_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj, void *work); +void blasfeo_dgelqf_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj, void *work); +void blasfeo_dgelqf_pd_ref(int m, int n, struct blasfeo_dmat_ref *sC, int ci, int cj, struct blasfeo_dmat_ref *sD, int di, int dj, void *work); +void blasfeo_dgelqf_pd_la_ref(int m, int n1, struct blasfeo_dmat_ref *sL, int li, int lj, struct blasfeo_dmat_ref *sA, int ai, int aj, void *work); +void blasfeo_dgelqf_pd_lla_ref(int m, int n1, struct blasfeo_dmat_ref *sL0, int l0i, int l0j, struct blasfeo_dmat_ref *sL1, int l1i, int l1j, struct blasfeo_dmat_ref *sA, int ai, int aj, void *work); + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_BLASFEO_API_REF_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_ref_api.h b/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_ref_api.h new file mode 100644 index 00000000000000..5773715cfaf246 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_blasfeo_ref_api.h @@ -0,0 +1,271 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_D_BLASFEO_REF_API_H_ +#define BLASFEO_D_BLASFEO_REF_API_H_ + + + +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +// level 1 BLAS +// + +// z = y + alpha*x +// z[zi:zi+n] = alpha*x[xi:xi+n] + y[yi:yi+n] +// NB: Different arguments semantic compare to equivalent standard BLAS routine +void blasfeo_ref_daxpy(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z = beta*y + alpha*x +void blasfeo_ref_daxpby(int kmax, double alpha, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z = x .* y +void blasfeo_ref_dvecmul(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z += x .* y +void blasfeo_ref_dvecmulacc(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z = x .* y, return sum(z) = x^T * y +double blasfeo_ref_dvecmuldot(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// return x^T * y +double blasfeo_ref_ddot(int m, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sy, int yi); +// construct givens plane rotation +void blasfeo_ref_drotg(double a, double b, double *c, double *s); +// apply plane rotation [a b] [c -s; s; c] to the aj0 and aj1 columns of A at row index ai +void blasfeo_ref_dcolrot(int m, struct blasfeo_dmat *sA, int ai, int aj0, int aj1, double c, double s); +// apply plane rotation [c s; -s c] [a; b] to the ai0 and ai1 rows of A at column index aj +void blasfeo_ref_drowrot(int m, struct blasfeo_dmat *sA, int ai0, int ai1, int aj, double c, double s); + + + +// +// level 2 BLAS +// + +// dense + +// z <= beta * y + alpha * A * x +void blasfeo_ref_dgemv_n(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z <= beta * y + alpha * A' * x +void blasfeo_ref_dgemv_t(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A ) * x, A (m)x(n) +void blasfeo_ref_dtrsv_lnn_mn(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(n) +void blasfeo_ref_dtrsv_ltn_mn(int m, int n, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, not_unit +void blasfeo_ref_dtrsv_lnn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, unit +void blasfeo_ref_dtrsv_lnu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) lower, transposed, not_unit +void blasfeo_ref_dtrsv_ltn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) lower, transposed, unit +void blasfeo_ref_dtrsv_ltu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) upper, not_transposed, not_unit +void blasfeo_ref_dtrsv_unn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) upper, transposed, not_unit +void blasfeo_ref_dtrsv_utn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A * x ; A lower triangular +void blasfeo_ref_dtrmv_lnn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A * x ; A lower triangular, unit diagonal +void blasfeo_ref_dtrmv_lnu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A' * x ; A lower triangular +void blasfeo_ref_dtrmv_ltn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A' * x ; A lower triangular, unit diagonal +void blasfeo_ref_dtrmv_ltu(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= beta * y + alpha * A * x ; A upper triangular +void blasfeo_ref_dtrmv_unn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z <= A' * x ; A upper triangular +void blasfeo_ref_dtrmv_utn(int m, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, struct blasfeo_dvec *sz, int zi); +// z_n <= beta_n * y_n + alpha_n * A * x_n +// z_t <= beta_t * y_t + alpha_t * A' * x_t +void blasfeo_ref_dgemv_nt(int m, int n, double alpha_n, double alpha_t, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx_n, int xi_n, struct blasfeo_dvec *sx_t, int xi_t, double beta_n, double beta_t, struct blasfeo_dvec *sy_n, int yi_n, struct blasfeo_dvec *sy_t, int yi_t, struct blasfeo_dvec *sz_n, int zi_n, struct blasfeo_dvec *sz_t, int zi_t); +// z <= beta * y + alpha * A * x, where A is symmetric and only the lower triangular patr of A is accessed +void blasfeo_ref_dsymv_l(int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); +void blasfeo_ref_dsymv_l_mn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); + +// diagonal + +// z <= beta * y + alpha * A * x, A diagonal +void blasfeo_ref_dgemv_d(int m, double alpha, struct blasfeo_dvec *sA, int ai, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); + + + +// +// level 3 BLAS +// + +// dense + +// D <= beta * C + alpha * A * B +void blasfeo_ref_dgemm_nn(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T +void blasfeo_ref_dgemm_nt(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B +void blasfeo_ref_dgemm_tn(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B^T +void blasfeo_ref_dgemm_tt(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T ; C, D lower triangular +void blasfeo_ref_dsyrk_ln(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_ref_dsyrk_ln_mn(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B ; C, D lower triangular +void blasfeo_ref_dsyrk_lt(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T ; C, D upper triangular +void blasfeo_ref_dsyrk_un(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B ; C, D upper triangular +void blasfeo_ref_dsyrk_ut(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B ; A lower triangular +void blasfeo_ref_dtrmm_llnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B ; A lower triangular +void blasfeo_ref_dtrmm_llnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A lower triangular +void blasfeo_ref_dtrmm_lltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A lower triangular +void blasfeo_ref_dtrmm_lltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B ; A upper triangular +void blasfeo_ref_dtrmm_lunn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B ; A upper triangular +void blasfeo_ref_dtrmm_lunu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A upper triangular +void blasfeo_ref_dtrmm_lutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^T * B ; A upper triangular +void blasfeo_ref_dtrmm_lutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A lower triangular +void blasfeo_ref_dtrmm_rlnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A lower triangular +void blasfeo_ref_dtrmm_rlnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A lower triangular +void blasfeo_ref_dtrmm_rltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A lower triangular +void blasfeo_ref_dtrmm_rltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A upper triangular +void blasfeo_ref_dtrmm_runn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A ; A upper triangular +void blasfeo_ref_dtrmm_runu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A upper triangular +void blasfeo_ref_dtrmm_rutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^T ; A upper triangular +void blasfeo_ref_dtrmm_rutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular employint explicit inverse of diagonal +void blasfeo_ref_dtrsm_llnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular with unit diagonal +void blasfeo_ref_dtrsm_llnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular employint explicit inverse of diagonal +void blasfeo_ref_dtrsm_lltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular with unit diagonal +void blasfeo_ref_dtrsm_lltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_dtrsm_lunn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular withunit diagonal +void blasfeo_ref_dtrsm_lunu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_dtrsm_lutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular withunit diagonal +void blasfeo_ref_dtrsm_lutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_ref_dtrsm_rlnn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular with unit diagonal +void blasfeo_ref_dtrsm_rlnu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_ref_dtrsm_rltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular with unit diagonal +void blasfeo_ref_dtrsm_rltu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_dtrsm_runn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular with unit diagonal +void blasfeo_ref_dtrsm_runu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_dtrsm_rutn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular with unit diagonal +void blasfeo_ref_dtrsm_rutu(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); + +// diagonal + +// D <= alpha * A * B + beta * C, with A diagonal (stored as strvec) +void dgemm_diag_left_lib(int m, int n, double alpha, double *dA, double *pB, int sdb, double beta, double *pC, int sdc, double *pD, int sdd); +void blasfeo_ref_dgemm_dn(int m, int n, double alpha, struct blasfeo_dvec *sA, int ai, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= alpha * A * B + beta * C, with B diagonal (stored as strvec) +void blasfeo_ref_dgemm_nd(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sB, int bi, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); + + + +// +// LAPACK +// + +// D <= chol( C ) ; C, D lower triangular +void blasfeo_ref_dpotrf_l(int m, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_ref_dpotrf_l_mn(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= chol( C ) ; C, D upper triangular +void blasfeo_ref_dpotrf_u(int m, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= chol( C + A * B' ) ; C, D lower triangular +void blasfeo_ref_dsyrk_dpotrf_ln(int m, int k, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +void blasfeo_ref_dsyrk_dpotrf_ln_mn(int m, int n, int k, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= lu( C ) ; no pivoting +void blasfeo_ref_dgetrf_np(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); +// D <= lu( C ) ; row pivoting +void blasfeo_ref_dgetrf_rp(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, int *ipiv); +// D <= qr( C ) +int blasfeo_ref_dgeqrf_worksize(int m, int n); // in bytes +void blasfeo_ref_dgeqrf(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +// D <= Q factor, where C is the output of the LQ factorization +int blasfeo_ref_dorglq_worksize(int m, int n, int k); // in bytes +void blasfeo_ref_dorglq(int m, int n, int k, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +// D <= lq( C ) +void blasfeo_ref_dgelqf(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +int blasfeo_ref_dgelqf_worksize(int m, int n); // in bytes +// D <= lq( C ), positive diagonal elements +void blasfeo_ref_dgelqf_pd(int m, int n, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj, void *work); +// [L, A] <= lq( [L, A] ), positive diagonal elements, array of matrices, with +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_ref_dgelqf_pd_la(int m, int n1, struct blasfeo_dmat *sL, int li, int lj, struct blasfeo_dmat *sA, int ai, int aj, void *work); +// [L, L, A] <= lq( [L, L, A] ), positive diagonal elements, array of matrices, with: +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_ref_dgelqf_pd_lla(int m, int n1, struct blasfeo_dmat *sL0, int l0i, int l0j, struct blasfeo_dmat *sL1, int l1i, int l1j, struct blasfeo_dmat *sA, int ai, int aj, void *work); + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_BLASFEO_REF_API_H_ + diff --git a/third_party/acados/include/blasfeo/include/blasfeo_d_kernel.h b/third_party/acados/include/blasfeo/include/blasfeo_d_kernel.h new file mode 100644 index 00000000000000..70948576979857 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_d_kernel.h @@ -0,0 +1,1247 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_D_KERNEL_H_ +#define BLASFEO_D_KERNEL_H_ + + + +#include "blasfeo_target.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// utils +void blasfeo_align_2MB(void *ptr, void **ptr_align); +void blasfeo_align_4096_byte(void *ptr, void **ptr_align); +void blasfeo_align_64_byte(void *ptr, void **ptr_align); + + +// +// lib8 +// + +// 24x8 +void kernel_dgemm_nt_24x8_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nt_24x8_vs_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dtrsm_nt_rl_inv_24x8_lib8(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); // +void kernel_dpotrf_nt_l_24x8_lib8(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dpotrf_nt_l_24x8_vs_lib8(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_24x8_vs_lib8(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int m1, int n1); // +void kernel_dgemm_dtrsm_nt_rl_inv_24x8_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dgemm_dtrsm_nt_rl_inv_24x8_vs_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int m1, int n1); +void kernel_dsyrk_dpotrf_nt_l_24x8_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_24x8_vs_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int m1, int n1); +void kernel_dlarfb8_rn_24_lib8(int kmax, double *pV, double *pT, double *pD, int sdd); +// 16x8 +void kernel_dgemm_nt_16x8_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nt_16x8_vs_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nt_16x8_gen_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, int offC, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dgemm_nn_16x8_lib8(int k, double *alpha, double *A, int sda, int offB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_16x8_vs_lib8(int k, double *alpha, double *A, int sda, int offB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nn_16x8_gen_lib8(int k, double *alpha, double *A, int sda, int offB, double *B, int sdb, double *beta, int offC, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dsyrk_nt_l_16x8_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dsyrk_nt_l_16x8_vs_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dsyrk_nt_l_16x8_gen_lib8(int k, double *alpha, double *A, int sda, double *B, double *beta, int offC, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dtrmm_nn_rl_16x8_lib8(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *D, int sdd); +void kernel_dtrmm_nn_rl_16x8_vs_lib8(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *D, int sdd, int m1, int n1); +void kernel_dtrmm_nn_rl_16x8_gen_lib8(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_dtrsm_nt_rl_inv_16x8_lib8(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); // +void kernel_dtrsm_nt_rl_inv_16x8_vs_lib8(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int m1, int n1); // +void kernel_dpotrf_nt_l_16x8_lib8(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dpotrf_nt_l_16x8_vs_lib8(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int m1, int n1); +void kernel_dgemm_dtrsm_nt_rl_inv_16x8_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dgemm_dtrsm_nt_rl_inv_16x8_vs_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int m1, int n1); +void kernel_dsyrk_dpotrf_nt_l_16x8_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_16x8_vs_lib8(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int m1, int n1); +void kernel_dlarfb8_rn_16_lib8(int kmax, double *pV, double *pT, double *pD, int sdd); +void kernel_dlarfb8_rn_la_16_lib8(int n1, double *pVA, double *pT, double *pD, int sdd, double *pA, int sda); +void kernel_dlarfb8_rn_lla_16_lib8(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, int sdd, double *pL, int sdl, double *pA, int sda); +// 8x16 +void kernel_dgemm_tt_8x16_lib8(int k, double *alpha, int offA, double *A, int sda, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_tt_8x16_vs_lib8(int k, double *alpha, int offA, double *A, int sda, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_tt_8x16_gen_lib8(int k, double *alpha, int offA, double *A, int sda, double *B, int sdb, double *beta, int offC, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dgemm_nt_8x16_lib8(int k, double *alpha, double *A, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nt_8x16_vs_lib8(int k, double *alpha, double *A, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +// 8x8 +void kernel_dgemm_nt_8x8_lib8(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dgemm_nt_8x8_vs_lib8(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_nt_8x8_gen_lib8(int k, double *alpha, double *A, double *B, double *beta, int offC, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dgemm_nn_8x8_lib8(int k, double *alpha, double *A, int offB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nn_8x8_vs_lib8(int k, double *alpha, double *A, int offB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_nn_8x8_gen_lib8(int k, double *alpha, double *A, int offB, double *B, int sdb, double *beta, int offC, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dgemm_tt_8x8_lib8(int k, double *alpha, int offA, double *A, int sda, double *B, double *beta, double *C, double *D); // +void kernel_dgemm_tt_8x8_vs_lib8(int k, double *alpha, int offA, double *A, int sda, double *B, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_tt_8x8_gen_lib8(int k, double *alpha, int offA, double *A, int sda, double *B, double *beta, int offc, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dsyrk_nt_l_8x8_lib8(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dsyrk_nt_l_8x8_vs_lib8(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dsyrk_nt_l_8x8_gen_lib8(int k, double *alpha, double *A, double *B, double *beta, int offC, double *C, int sdc, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dtrmm_nn_rl_8x8_lib8(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *D); +void kernel_dtrmm_nn_rl_8x8_vs_lib8(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *D, int m1, int n1); +void kernel_dtrmm_nn_rl_8x8_gen_lib8(int k, double *alpha, double *A, int offsetB, double *B, int sdb, int offD, double *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_dtrsm_nt_rl_inv_8x8_lib8(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_8x8_vs_lib8(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E, int m1, int n1); +void kernel_dpotrf_nt_l_8x8_lib8(int k, double *A, double *B, double *C, double *D, double *inv_diag_D); +void kernel_dpotrf_nt_l_8x8_vs_lib8(int k, double *A, double *B, double *C, double *D, double *inv_diag_D, int m1, int n1); +void kernel_dgemm_dtrsm_nt_rl_inv_8x8_lib8(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dgemm_dtrsm_nt_rl_inv_8x8_vs_lib8(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *E, double *inv_diag_E, int m1, int n1); +void kernel_dsyrk_dpotrf_nt_l_8x8_lib8(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_8x8_vs_lib8(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D, int m1, int n1); +void kernel_dgelqf_vs_lib8(int m, int n, int k, int offD, double *pD, int sdd, double *dD); +void kernel_dgelqf_pd_vs_lib8(int m, int n, int k, int offD, double *pD, int sdd, double *dD); +void kernel_dgelqf_8_lib8(int kmax, double *pD, double *dD); +void kernel_dgelqf_pd_8_lib8(int kmax, double *pD, double *dD); +void kernel_dlarft_8_lib8(int kmax, double *pD, double *dD, double *pT); +void kernel_dlarfb8_rn_8_lib8(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb8_rn_8_vs_lib8(int kmax, double *pV, double *pT, double *pD, int m1); +void kernel_dlarfb8_rn_1_lib8(int kmax, double *pV, double *pT, double *pD); +void kernel_dgelqf_dlarft8_8_lib8(int kmax, double *pD, double *dD, double *pT); +void kernel_dgelqf_pd_dlarft8_8_lib8(int kmax, double *pD, double *dD, double *pT); +void kernel_dgelqf_pd_la_vs_lib8(int m, int n1, int k, int offD, double *pD, int sdd, double *dD, int offA, double *pA, int sda); +void kernel_dgelqf_pd_la_dlarft8_8_lib8(int kmax, double *pD, double *dD, double *pA, double *pT); +void kernel_dlarft_la_8_lib8(int n1, double *dD, double *pA, double *pT); +void kernel_dlarfb8_rn_la_8_lib8(int n1, double *pVA, double *pT, double *pD, double *pA); +void kernel_dlarfb8_rn_la_8_vs_lib8(int n1, double *pVA, double *pT, double *pD, double *pA, int m1); +void kernel_dlarfb8_rn_la_1_lib8(int n1, double *pVA, double *pT, double *pD, double *pA); +void kernel_dgelqf_pd_lla_vs_lib8(int m, int n0, int n1, int k, int offD, double *pD, int sdd, double *dD, int offL, double *pL, int sdl, int offA, double *pA, int sda); +void kernel_dgelqf_pd_lla_dlarft8_8_lib8(int n0, int n1, double *pD, double *dD, double *pL, double *pA, double *pT); +void kernel_dlarft_lla_8_lib8(int n0, int n1, double *dD, double *pL, double *pA, double *pT); +void kernel_dlarfb8_rn_lla_8_lib8(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, double *pL, double *pA); +void kernel_dlarfb8_rn_lla_8_vs_lib8(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, double *pL, double *pA, int m1); +void kernel_dlarfb8_rn_lla_1_lib8(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, double *pL, double *pA); + +// panel copy / pack +// 24 +void kernel_dpack_nn_24_lib8(int kmax, double *A, int lda, double *C, int sdc); +void kernel_dpack_nn_24_vs_lib8(int kmax, double *A, int lda, double *C, int sdc, int m1); +// 16 +void kernel_dpacp_nn_16_lib8(int kmax, int offsetA, double *A, int sda, double *B, int sdb); +void kernel_dpacp_nn_16_vs_lib8(int kmax, int offsetA, double *A, int sda, double *B, int sdb, int m1); +void kernel_dpack_nn_16_lib8(int kmax, double *A, int lda, double *C, int sdc); +void kernel_dpack_nn_16_vs_lib8(int kmax, double *A, int lda, double *C, int sdc, int m1); +// 8 +void kernel_dpacp_nn_8_lib8(int kmax, int offsetA, double *A, int sda, double *B); +void kernel_dpacp_nn_8_vs_lib8(int kmax, int offsetA, double *A, int sda, double *B, int m1); +void kernel_dpacp_tn_8_lib8(int kmax, int offsetA, double *A, int sda, double *B); +void kernel_dpacp_tn_8_vs_lib8(int kmax, int offsetA, double *A, int sda, double *B, int m1); +void kernel_dpacp_l_nn_8_lib8(int kmax, int offsetA, double *A, int sda, double *B); +void kernel_dpacp_l_nn_8_vs_lib8(int kmax, int offsetA, double *A, int sda, double *B, int m1); +void kernel_dpacp_l_tn_8_lib8(int kmax, int offsetA, double *A, int sda, double *B); +void kernel_dpacp_l_tn_8_vs_lib8(int kmax, int offsetA, double *A, int sda, double *B, int m1); +void kernel_dpaad_nn_8_lib8(int kmax, double *alpha, int offsetA, double *A, int sda, double *B); +void kernel_dpaad_nn_8_vs_lib8(int kmax, double *alpha, int offsetA, double *A, int sda, double *B, int m1); +void kernel_dpack_nn_8_lib8(int kmax, double *A, int lda, double *C); +void kernel_dpack_nn_8_vs_lib8(int kmax, double *A, int lda, double *C, int m1); +void kernel_dpack_tn_8_lib8(int kmax, double *A, int lda, double *C); +void kernel_dpack_tn_8_vs_lib8(int kmax, double *A, int lda, double *C, int m1); +// 4 +void kernel_dpack_tt_4_lib8(int kmax, double *A, int lda, double *C, int sdc); // TODO offsetC +void kernel_dpack_tt_4_vs_lib8(int kmax, double *A, int lda, double *C, int sdc, int m1); // TODO offsetC + +// level 2 BLAS +// 16 +void kernel_dgemv_n_16_lib8(int k, double *alpha, double *A, int sda, double *x, double *beta, double *y, double *z); +// 8 +void kernel_dgemv_n_8_lib8(int k, double *alpha, double *A, double *x, double *beta, double *y, double *z); +void kernel_dgemv_n_8_vs_lib8(int k, double *alpha, double *A, double *x, double *beta, double *y, double *z, int m1); +//void kernel_dgemv_n_8_gen_lib8(int k, double *alpha, double *A, double *x, double *beta, double *y, double *z, int m0, int m1); +void kernel_dgemv_n_8_gen_lib8(int k, double *alpha, int offsetA, double *A, double *x, double *beta, double *y, double *z, int m1); +void kernel_dgemv_t_8_lib8(int k, double *alpha, int offsetA, double *A, int sda, double *x, double *beta, double *y, double *z); +void kernel_dgemv_t_8_vs_lib8(int k, double *alpha, int offsetA, double *A, int sda, double *x, double *beta, double *y, double *z, int n1); +void kernel_dgemv_nt_8_lib8(int kmax, double *alpha_n, double *alpha_t, int offsetA, double *A, int sda, double *x_n, double *x_t, double *beta_t, double *y_t, double *z_n, double *z_t); +void kernel_dgemv_nt_8_vs_lib8(int kmax, double *alpha_n, double *alpha_t, int offsetA, double *A, int sda, double *x_n, double *x_t, double *beta_t, double *y_t, double *z_n, double *z_t, int n1); +void kernel_dsymv_l_8_lib8(int kmax, double *alpha, double *A, int sda, double *x, double *z); +void kernel_dsymv_l_8_vs_lib8(int kmax, double *alpha, double *A, int sda, double *x, double *z, int n1); +void kernel_dsymv_l_8_gen_lib8(int kmax, double *alpha, int offsetA, double *A, int sda, double *x, double *z, int n1); +void kernel_dtrmv_n_ln_8_lib8(int k, double *A, double *x, double *z); +void kernel_dtrmv_n_ln_8_vs_lib8(int k, double *A, double *x, double *z, int m1); +void kernel_dtrmv_n_ln_8_gen_lib8(int k, int offsetA, double *A, double *x, double *z, int m1); +void kernel_dtrmv_t_ln_8_lib8(int k, double *A, int sda, double *x, double *z); +void kernel_dtrmv_t_ln_8_vs_lib8(int k, double *A, int sda, double *x, double *z, int n1); +void kernel_dtrmv_t_ln_8_gen_lib8(int k, int offsetA, double *A, int sda, double *x, double *z, int n1); +void kernel_dtrsv_n_l_inv_8_lib8(int k, double *A, double *inv_diag_A, double *x, double *z); +void kernel_dtrsv_n_l_inv_8_vs_lib8(int k, double *A, double *inv_diag_A, double *x, double *z, int m1, int n1); +void kernel_dtrsv_t_l_inv_8_lib8(int k, double *A, int sda, double *inv_diag_A, double *x, double *z); +void kernel_dtrsv_t_l_inv_8_vs_lib8(int k, double *A, int sda, double *inv_diag_A, double *x, double *z, int m1, int n1); + + + +// +// lib4 +// + +// level 2 BLAS +// 12 +void kernel_dgemv_n_12_lib4(int k, double *alpha, double *A, int sda, double *x, double *beta, double *y, double *z); +void kernel_dgemv_t_12_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *x, double *beta, double *y, double *z); +// 8 +void kernel_dgemv_n_8_lib4(int k, double *alpha, double *A, int sda, double *x, double *beta, double *y, double *z); +void kernel_dgemv_t_8_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *x, double *beta, double *y, double *z); +void kernel_dtrmv_un_8_lib4(int k, double *A, int sda, double *x, double *z); +// 4 +void kernel_dgemv_n_4_lib4(int k, double *alpha, double *A, double *x, double *beta, double *y, double *z); +void kernel_dgemv_n_4_vs_lib4(int k, double *alpha, double *A, double *x, double *beta, double *y, double *z, int k1); +void kernel_dgemv_n_4_gen_lib4(int kmax, double *alpha, double *A, double *x, double *beta, double *y, double *z, int k0, int k1); +void kernel_dgemv_t_4_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *x, double *beta, double *y, double *z); +void kernel_dgemv_t_4_vs_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *x, double *beta, double *y, double *z, int k1); +void kernel_dtrsv_ln_inv_4_lib4(int k, double *A, double *inv_diag_A, double *x, double *y, double *z); +void kernel_dtrsv_ln_inv_4_vs_lib4(int k, double *A, double *inv_diag_A, double *x, double *y, double *z, int km, int kn); +void kernel_dtrsv_lt_inv_4_lib4(int k, double *A, int sda, double *inv_diag_A, double *x, double *y, double *z); +void kernel_dtrsv_lt_inv_3_lib4(int k, double *A, int sda, double *inv_diag_A, double *x, double *y, double *z); +void kernel_dtrsv_lt_inv_2_lib4(int k, double *A, int sda, double *inv_diag_A, double *x, double *y, double *z); +void kernel_dtrsv_lt_inv_1_lib4(int k, double *A, int sda, double *inv_diag_A, double *x, double *y, double *z); +void kernel_dtrsv_lt_one_4_lib4(int k, double *A, int sda, double *x, double *y, double *z); +void kernel_dtrsv_lt_one_3_lib4(int k, double *A, int sda, double *x, double *y, double *z); +void kernel_dtrsv_lt_one_2_lib4(int k, double *A, int sda, double *x, double *y, double *z); +void kernel_dtrsv_lt_one_1_lib4(int k, double *A, int sda, double *x, double *y, double *z); +void kernel_dtrsv_ln_one_4_vs_lib4(int kmax, double *A, double *x, double *y, double *z, int km, int kn); +void kernel_dtrsv_ln_one_4_lib4(int kmax, double *A, double *x, double *y, double *z); +void kernel_dtrsv_un_inv_4_lib4(int kmax, double *A, double *inv_diag_A, double *x, double *y, double *z); +void kernel_dtrsv_ut_inv_4_lib4(int kmax, double *A, int sda, double *inv_diag_A, double *x, double *y, double *z); +void kernel_dtrsv_ut_inv_4_vs_lib4(int kmax, double *A, int sda, double *inv_diag_A, double *x, double *y, double *z, int m1, int n1); +void kernel_dtrmv_un_4_lib4(int k, double *A, double *x, double *z); +void kernel_dtrmv_ut_4_lib4(int k, double *A, int sda, double *x, double *z); +void kernel_dtrmv_ut_4_vs_lib4(int k, double *A, int sda, double *x, double *z, int km); +void kernel_dgemv_nt_6_lib4(int kmax, double *alpha_n, double *alpha_t, double *A, int sda, double *x_n, double *x_t, double *beta_t, double *y_t, double *z_n, double *z_t); +void kernel_dgemv_nt_4_lib4(int kmax, double *alpha_n, double *alpha_t, double *A, int sda, double *x_n, double *x_t, double *beta_t, double *y_t, double *z_n, double *z_t); +void kernel_dgemv_nt_4_vs_lib4(int kmax, double *alpha_n, double *alpha_t, double *A, int sda, double *x_n, double *x_t, double *beta_t, double *y_t, double *z_n, double *z_t, int km); +void kernel_dsymv_l_4_lib4(int kmax, double *alpha, double *A, int sda, double *x, double *z); +void kernel_dsymv_l_4_gen_lib4(int kmax, double *alpha, int offA, double *A, int sda, double *x, double *z, int km); + + + +// level 3 BLAS +// 12x4 +void kernel_dgemm_nt_12x4_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nt_12x4_vs_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // +void kernel_dgemm_nt_12x4_gen_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int k0, int k1); +void kernel_dgemm_nn_12x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_12x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // +void kernel_dgemm_nn_12x4_gen_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dgemm_tt_12x4_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_tt_12x4_vs_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dsyrk_nn_u_12x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dsyrk_nn_u_12x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dsyrk_nt_l_12x4_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dsyrk_nt_l_12x4_vs_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // +void kernel_dtrmm_nt_ru_12x4_lib4(int k, double *alpha, double *A, int sda, double *B, double *D, int sdd); // +void kernel_dtrmm_nt_ru_12x4_vs_lib4(int k, double *alpha, double *A, int sda, double *B, double *D, int sdd, int km, int kn); // +void kernel_dtrmm_nn_rl_12x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *D, int sdd); +void kernel_dtrmm_nn_rl_12x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *D, int sdd, int km, int kn); +void kernel_dtrsm_nt_rl_inv_12x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_12x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nt_rl_one_12x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E); +void kernel_dtrsm_nt_rl_one_12x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, int km, int kn); +void kernel_dtrsm_nt_ru_inv_12x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_ru_inv_12x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nt_ru_one_12x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E); +void kernel_dtrsm_nt_ru_one_12x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, int km, int kn); +void kernel_dtrsm_nn_ru_inv_12x4_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dtrsm_nn_ru_inv_12x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nn_ll_inv_12x4_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E); +void kernel_dtrsm_nn_ll_inv_12x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nn_ll_one_12x4_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde); +void kernel_dtrsm_nn_ll_one_12x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde, int km, int kn); +void kernel_dtrsm_nn_lu_inv_12x4_lib4(int kmax, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E); +void kernel_dtrsm_nn_lu_inv_12x4_vs_lib4(int kmax, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E, int km, int kn); +// 4x12 +void kernel_dgemm_nt_4x12_lib4(int k, double *alpha, double *A, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nt_4x12_vs_lib4(int k, double *alpha, double *A, double *B, int sdb, double *beta, double *C, double *D, int km, int kn); // +void kernel_dgemm_nn_4x12_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nn_4x12_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_tt_4x12_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_tt_4x12_vs_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_tt_4x12_gen_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, int sdb, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dtrsm_nt_rl_inv_4x12_lib4(int k, double *A, double *B, int sdb, double *C, double *D, double *E, int sed, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_4x12_vs_lib4(int k, double *A, double *B, int sdb, double *C, double *D, double *E, int sed, double *inv_diag_E, int km, int kn); +// 8x8 +void kernel_dgemm_nt_8x8l_lib4(int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // computes [A00 *; A10 A11] +void kernel_dgemm_nt_8x8u_lib4(int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // computes [A00 *; A10 A11] +void kernel_dgemm_nt_8x8l_vs_lib4(int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // computes [A00 *; A10 A11] +void kernel_dgemm_nt_8x8u_vs_lib4(int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // computes [A00 *; A10 A11] +void kernel_dsyrk_nn_u_8x8_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dsyrk_nn_u_8x8_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dsyrk_nt_l_8x8_lib4(int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // computes [L00 *; A10 L11] +void kernel_dsyrk_nt_l_8x8_vs_lib4(int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // computes [L00 *; A10 L11] +void kernel_dtrsm_nt_rl_inv_8x8l_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sed, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_8x8l_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sed, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nt_rl_inv_8x8u_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sed, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_8x8u_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sed, double *inv_diag_E, int km, int kn); +// 8x4 +void kernel_dgemm_nt_8x4_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nt_8x4_vs_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // +void kernel_dgemm_nt_8x4_gen_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int k0, int k1); +void kernel_dgemm_nn_8x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_8x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nn_8x4_gen_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dgemm_tt_8x4_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_tt_8x4_vs_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dsyrk_nn_u_8x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dsyrk_nn_u_8x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dsyrk_nt_l_8x4_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dsyrk_nt_l_8x4_vs_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, int km, int kn); // +void kernel_dsyrk_nt_l_8x4_gen_lib4(int k, double *alpha, double *A, int sda, double *B, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int k0, int k1); +void kernel_dtrmm_nt_ru_8x4_lib4(int k, double *alpha, double *A, int sda, double *B, double *D, int sdd); // +void kernel_dtrmm_nt_ru_8x4_vs_lib4(int k, double *alpha, double *A, int sda, double *B, double *D, int sdd, int km, int kn); // +void kernel_dtrmm_nn_rl_8x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *D, int sdd); +void kernel_dtrmm_nn_rl_8x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *D, int sdd, int km, int kn); +void kernel_dtrmm_nn_rl_8x4_gen_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_dtrsm_nt_rl_inv_8x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nt_rl_inv_8x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_rl_one_8x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E); +void kernel_dtrsm_nt_rl_one_8x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, int km, int kn); +void kernel_dtrsm_nt_ru_inv_8x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_ru_inv_8x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nt_ru_one_8x4_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E); +void kernel_dtrsm_nt_ru_one_8x4_vs_lib4(int k, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd, double *E, int km, int kn); +void kernel_dtrsm_nn_ru_inv_8x4_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dtrsm_nn_ru_inv_8x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nn_ll_inv_8x4_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E); +void kernel_dtrsm_nn_ll_inv_8x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nn_ll_one_8x4_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde); +void kernel_dtrsm_nn_ll_one_8x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int sde, int km, int kn); +void kernel_dtrsm_nn_lu_inv_8x4_lib4(int kmax, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E); +void kernel_dtrsm_nn_lu_inv_8x4_vs_lib4(int kmax, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E, int km, int kn); +// 4x8 +void kernel_dgemm_nt_4x8_lib4(int k, double *alpha, double *A, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nt_4x8_vs_lib4(int k, double *alpha, double *A, double *B, int sdb, double *beta, double *C, double *D, int km, int kn); // +void kernel_dgemm_nn_4x8_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nn_4x8_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_tt_4x8_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_tt_4x8_vs_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_tt_4x8_gen_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, int sdb, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dtrsm_nt_rl_inv_4x8_lib4(int k, double *A, double *B, int sdb, double *C, double *D, double *E, int sed, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_4x8_vs_lib4(int k, double *A, double *B, int sdb, double *C, double *D, double *E, int sed, double *inv_diag_E, int km, int kn); +// 8x2 +void kernel_dgemm_nn_8x2_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_8x2_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +// 2x8 +void kernel_dgemm_nn_2x8_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nn_2x8_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +// 10xX +void kernel_dgemm_nn_10x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_10x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nn_10x2_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_10x2_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +// 6xX +void kernel_dgemm_nn_8x6_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_8x6_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nn_6x8_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_6x8_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nn_6x6_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_6x6_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nn_6x4_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_6x4_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +void kernel_dgemm_nn_6x2_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd); // +void kernel_dgemm_nn_6x2_vs_lib4(int k, double *alpha, double *A, int sda, int offsetB, double *B, int sdb, double *beta, double *C, int sdc, double *D, int sdd, int m1, int n1); // +// 4x4 +void kernel_dgemm_nt_4x4_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dgemm_nt_4x4_vs_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int km, int kn); // +void kernel_dgemm_nt_4x4_gen_lib4(int k, double *alpha, double *A, double *B, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_dgemm_nn_4x4_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nn_4x4_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_nn_4x4_gen_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dgemm_tt_4x4_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, double *beta, double *C, double *D); // +void kernel_dgemm_tt_4x4_vs_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_tt_4x4_gen_lib4(int k, double *alpha, int offsetA, double *A, int sda, double *B, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_dsyrk_nn_u_4x4_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dsyrk_nn_u_4x4_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dsyrk_nt_l_4x4_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dsyrk_nt_l_4x4_vs_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int km, int kn); // +void kernel_dsyrk_nt_l_4x4_gen_lib4(int k, double *alpha, double *A, double *B, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_dsyrk_nt_u_4x4_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dsyrk_nt_u_4x4_vs_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int km, int kn); // +void kernel_dsyrk_nt_u_4x4_gen_lib4(int k, double *alpha, double *A, double *B, double *beta, int offsetC, double *C, int sdc, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_dtrmm_nt_ru_4x4_lib4(int k, double *alpha, double *A, double *B, double *D); // +void kernel_dtrmm_nt_ru_4x4_vs_lib4(int k, double *alpha, double *A, double *B, double *D, int km, int kn); // +void kernel_dtrmm_nn_rl_4x4_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *D); +void kernel_dtrmm_nn_rl_4x4_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *D, int m1, int n1); +void kernel_dtrmm_nn_rl_4x4_gen_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, int offsetD, double *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_dtrsm_nt_rl_inv_4x4_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_4x4_vs_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nt_rl_one_4x4_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E); +void kernel_dtrsm_nt_rl_one_4x4_vs_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, int km, int kn); +void kernel_dtrsm_nt_ru_inv_4x4_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_ru_inv_4x4_vs_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nt_ru_one_4x4_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E); +void kernel_dtrsm_nt_ru_one_4x4_vs_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, int km, int kn); +void kernel_dtrsm_nn_ru_inv_4x4_lib4(int k, double *A, double *B, int sdb, double *beta, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dtrsm_nn_ru_inv_4x4_vs_lib4(int k, double *A, double *B, int sdb, double *beta, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nn_ll_inv_4x4_lib4(int k, double *A, double *B, int sdb, double *beta, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dtrsm_nn_ll_inv_4x4_vs_lib4(int k, double *A, double *B, int sdb, double *beta, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nn_ll_one_4x4_lib4(int k, double *A, double *B, int sdb, double *beta, double *C, double *D, double *E); +void kernel_dtrsm_nn_ll_one_4x4_vs_lib4(int k, double *A, double *B, int sdb, double *beta, double *C, double *D, double *E, int km, int kn); +void kernel_dtrsm_nn_lu_inv_4x4_lib4(int kmax, double *A, double *B, int sdb, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dtrsm_nn_lu_inv_4x4_vs_lib4(int kmax, double *A, double *B, int sdb, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +void kernel_dtrsm_nn_lu_one_4x4_lib4(int kmax, double *A, double *B, int sdb, double *C, double *D, double *E); +void kernel_dtrsm_nn_lu_one_4x4_vs_lib4(int kmax, double *A, double *B, int sdb, double *C, double *D, double *E, int km, int kn); +// 4x2 +void kernel_dgemm_nn_4x2_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nn_4x2_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +void kernel_dgemm_nt_4x2_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); +void kernel_dgemm_nt_4x2_vs_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int m1, int n1); +void kernel_dsyrk_nt_l_4x2_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dsyrk_nt_l_4x2_vs_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int km, int kn); // +void kernel_dtrmm_nn_rl_4x2_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *D); +void kernel_dtrmm_nn_rl_4x2_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *D, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_4x2_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dtrsm_nt_rl_inv_4x2_vs_lib4(int k, double *A, double *B, double *beta, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +// 2x4 +void kernel_dgemm_nn_2x4_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dgemm_nn_2x4_vs_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D, int m1, int n1); // +// 2x2 +void kernel_dgemm_nn_2x2_lib4(int k, double *alpha, double *A, int offsetB, double *B, int sdb, double *beta, double *C, double *D); // +void kernel_dsyrk_nt_l_2x2_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dsyrk_nt_l_2x2_vs_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int km, int kn); // +// diag +void kernel_dgemm_diag_right_4_a0_lib4(int kmax, double *alpha, double *A, int sda, double *B, double *D, int sdd); +void kernel_dgemm_diag_right_4_lib4(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); +void kernel_dgemm_diag_right_3_lib4(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); +void kernel_dgemm_diag_right_2_lib4(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); +void kernel_dgemm_diag_right_1_lib4(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int sdd); +void kernel_dgemm_diag_left_4_a0_lib4(int kmax, double *alpha, double *A, double *B, double *D); +void kernel_dgemm_diag_left_4_lib4(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D); +void kernel_dgemm_diag_left_3_lib4(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D); +void kernel_dgemm_diag_left_2_lib4(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D); +void kernel_dgemm_diag_left_1_lib4(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D); +// low rank update +void kernel_dger4_sub_12r_lib4(int k, double *A, int sda, double *B, double *C, int sdc); +void kernel_dger4_sub_12r_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, int km); +void kernel_dger4_sub_8r_lib4(int k, double *A, int sda, double *B, double *C, int sdc); +void kernel_dger4_sub_8r_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, int km); +void kernel_dger4_sub_4r_lib4(int n, double *A, double *B, double *C); +void kernel_dger4_sub_4r_vs_lib4(int n, double *A, double *B, double *C, int km); + + + +// LAPACK +// 12x4 +void kernel_dpotrf_nt_l_12x4_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dpotrf_nt_l_12x4_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nn_l_12x4_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nn_l_12x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nn_m_12x4_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nn_m_12x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nn_r_12x4_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nn_r_12x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nt_l_12x4_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nt_l_12x4_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nt_m_12x4_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nt_m_12x4_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nt_r_12x4_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nt_r_12x4_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +// 8x8 +void kernel_dpotrf_nt_l_8x8_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dpotrf_nt_l_8x8_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +// 8x4 +void kernel_dpotrf_nt_l_8x4_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dpotrf_nt_l_8x4_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nn_l_8x4_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nn_l_8x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nn_r_8x4_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nn_r_8x4_vs_lib4(int k, double *A, int sda, double *B, int sdb, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nt_l_8x4_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nt_l_8x4_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nt_r_8x4_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dgetrf_nt_r_8x4_vs_lib4(int k, double *A, int sda, double *B, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +// 4x4 +void kernel_dpotrf_nt_l_4x4_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D); +void kernel_dpotrf_nt_l_4x4_vs_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D, int km, int kn); +#if defined(TARGET_X64_INTEL_SANDY_BRIDGE) +void kernel_dlauum_nt_4x4_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D); // +void kernel_dlauum_nt_4x4_vs_lib4(int k, double *alpha, double *A, double *B, double *beta, double *C, double *D, int km, int kn); // +#endif +void kernel_dgetrf_nn_4x4_lib4(int k, double *A, double *B, int sdb, double *C, double *D, double *inv_diag_D); +void kernel_dgetrf_nn_4x4_vs_lib4(int k, double *A, double *B, int sdb, double *C, double *D, double *inv_diag_D, int km, int kn); +void kernel_dgetrf_nt_4x4_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D); +void kernel_dgetrf_nt_4x4_vs_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D, int km, int kn); +void kernel_dgeqrf_4_lib4(int m, double *pD, int sdd, double *dD); +void kernel_dgeqrf_vs_lib4(int m, int n, int k, int offD, double *pD, int sdd, double *dD); +void kernel_dlarf_4_lib4(int m, int n, double *pV, int sdv, double *tau, double *pC, int sdc); // rank-4 reflector +void kernel_dlarf_t_4_lib4(int m, int n, double *pD, int sdd, double *pVt, double *dD, double *pC0, int sdc, double *pW); +void kernel_dgelqf_4_lib4(int n, double *pD, double *dD); +void kernel_dgelqf_vs_lib4(int m, int n, int k, int offD, double *pD, int sdd, double *dD); +void kernel_dlarft_4_lib4(int kmax, double *pD, double *dD, double *pT); +void kernel_dlarft_3_lib4(int kmax, double *pD, double *dD, double *pT); +void kernel_dlarft_2_lib4(int kmax, double *pD, double *dD, double *pT); +void kernel_dlarft_1_lib4(int kmax, double *pD, double *dD, double *pT); +void kernel_dgelqf_dlarft12_12_lib4(int n, double *pD, int sdd, double *dD, double *pT); +void kernel_dgelqf_dlarft4_12_lib4(int n, double *pD, int sdd, double *dD, double *pT); +void kernel_dgelqf_dlarft4_8_lib4(int n, double *pD, int sdd, double *dD, double *pT); +void kernel_dgelqf_dlarft4_4_lib4(int n, double *pD, double *dD, double *pT); +void kernel_dlarfb12_rn_12_lib4(int kmax, double *pV, int sdd, double *pT, double *pD, double *pK); +void kernel_dlarfb12_rn_4_lib4(int kmax, double *pV, int sdd, double *pT, double *pD, double *pK, int km); +void kernel_dlarfb4_rn_12_lib4(int kmax, double *pV, double *pT, double *pD, int sdd); +void kernel_dlarfb4_rn_8_lib4(int kmax, double *pV, double *pT, double *pD, int sdd); +void kernel_dlarfb4_rn_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb3_rn_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb2_rn_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb1_rn_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb4_rn_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb3_rn_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb2_rn_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb1_rn_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb4_rt_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb3_rt_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb2_rt_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb1_rt_4_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb4_rt_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb3_rt_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb2_rt_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dlarfb1_rt_1_lib4(int kmax, double *pV, double *pT, double *pD); +void kernel_dgelqf_pd_dlarft12_12_lib4(int n, double *pD, int sdd, double *dD, double *pT); +void kernel_dgelqf_pd_dlarft4_8_lib4(int n, double *pD, int sdd, double *dD, double *pT); +void kernel_dgelqf_pd_dlarft4_4_lib4(int n, double *pD, double *dD, double *pT); +void kernel_dgelqf_pd_4_lib4(int n, double *pD, double *dD); +void kernel_dgelqf_pd_vs_lib4(int m, int n, int k, int offD, double *pD, int sdd, double *dD); +void kernel_dgelqf_pd_la_vs_lib4(int m, int n1, int k, int offD, double *pD, int sdd, double *dD, int offA, double *pA, int sda); +void kernel_dlarft_4_la_lib4(int n1, double *dD, double *pA, double *pT); +void kernel_dlarfb4_rn_12_la_lib4(int n1, double *pVA, double *pT, double *pD, int sdd, double *pA, int sda); +void kernel_dlarfb4_rn_8_la_lib4(int n1, double *pVA, double *pT, double *pD, int sdd, double *pA, int sda); +void kernel_dlarfb4_rn_4_la_lib4(int n1, double *pVA, double *pT, double *pD, double *pA); +void kernel_dlarfb4_rn_1_la_lib4(int n1, double *pVA, double *pT, double *pD, double *pA); +void kernel_dgelqf_pd_lla_vs_lib4(int m, int n0, int n1, int k, int offD, double *pD, int sdd, double *dD, int offL, double *pL, int sdl, int offA, double *pA, int sda); +void kernel_dlarft_4_lla_lib4(int n0, int n1, double *dD, double *pL, double *pA, double *pT); +void kernel_dlarfb4_rn_12_lla_lib4(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, int sdd, double *pL, int sdl, double *pA, int sda); +void kernel_dlarfb4_rn_8_lla_lib4(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, int sdd, double *pL, int sdl, double *pA, int sda); +void kernel_dlarfb4_rn_4_lla_lib4(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, double *pL, double *pA); +void kernel_dlarfb4_rn_1_lla_lib4(int n0, int n1, double *pVL, double *pVA, double *pT, double *pD, double *pL, double *pA); +// 4x2 +void kernel_dpotrf_nt_l_4x2_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D); +void kernel_dpotrf_nt_l_4x2_vs_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D, int km, int kn); +// 2x2 +void kernel_dpotrf_nt_l_2x2_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D); +void kernel_dpotrf_nt_l_2x2_vs_lib4(int k, double *A, double *B, double *C, double *D, double *inv_diag_D, int km, int kn); +// 12 +void kernel_dgetrf_pivot_12_lib4(int m, double *pA, int sda, double *inv_diag_A, int* ipiv); +void kernel_dgetrf_pivot_12_vs_lib4(int m, double *pA, int sda, double *inv_diag_A, int* ipiv, int n); +// 8 +void kernel_dgetrf_pivot_8_lib4(int m, double *pA, int sda, double *inv_diag_A, int* ipiv); +void kernel_dgetrf_pivot_8_vs_lib4(int m, double *pA, int sda, double *inv_diag_A, int* ipiv, int n); +// 4 +void kernel_dgetrf_pivot_4_lib4(int m, double *pA, int sda, double *inv_diag_A, int* ipiv); +void kernel_dgetrf_pivot_4_vs_lib4(int m, double *pA, int sda, double *inv_diag_A, int* ipiv, int n1); +// vector +void kernel_drowsw_lib4(int kmax, double *pA, double *pC); + + + +// merged routines +// 12x4 +void kernel_dgemm_dtrsm_nt_rl_inv_12x4_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dgemm_dtrsm_nt_rl_inv_12x4_vs_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dsyrk_dpotrf_nt_l_12x4_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_12x4_vs_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +// 4x12 +void kernel_dgemm_dtrsm_nt_rl_inv_4x12_vs_lib4(int kp, double *Ap, double *Bp, int sdbp, int km_, double *Am, double *Bm, int sdbm, double *C, double *D, double *E, int sde, double *inv_diag_E, int km, int kn); +// 8x8 +void kernel_dsyrk_dpotrf_nt_l_8x8_lib4(int kp, double *Ap, int sdap, double *Bp, int sdbp, int km_, double *Am, int sdam, double *Bm, int sdbm, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_8x8_vs_lib4(int kp, double *Ap, int sdap, double *Bp, int sdbp, int km_, double *Am, int sdam, double *Bm, int sdbm, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +void kernel_dgemm_dtrsm_nt_rl_inv_8x8l_vs_lib4(int kp, double *Ap, int sdap, double *Bp, int sdb, int km_, double *Am, int sdam, double *Bm, int sdbm, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E, int km, int kn); +void kernel_dgemm_dtrsm_nt_rl_inv_8x8u_vs_lib4(int kp, double *Ap, int sdap, double *Bp, int sdb, int km_, double *Am, int sdam, double *Bm, int sdbm, double *C, int sdc, double *D, int sdd, double *E, int sde, double *inv_diag_E, int km, int kn); +// 8x4 +void kernel_dgemm_dtrsm_nt_rl_inv_8x4_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E); +void kernel_dgemm_dtrsm_nt_rl_inv_8x4_vs_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *E, double *inv_diag_E, int km, int kn); +void kernel_dsyrk_dpotrf_nt_l_8x4_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_8x4_vs_lib4(int kp, double *Ap, int sdap, double *Bp, int km_, double *Am, int sdam, double *Bm, double *C, int sdc, double *D, int sdd, double *inv_diag_D, int km, int kn); +// 4x8 +void kernel_dgemm_dtrsm_nt_rl_inv_4x8_vs_lib4(int kp, double *Ap, double *Bp, int sdbp, int km_, double *Am, double *Bm, int sdbm, double *C, double *D, double *E, int sde, double *inv_diag_E, int km, int kn); +// 4x4 +void kernel_dgemm_dtrsm_nt_rl_inv_4x4_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dgemm_dtrsm_nt_rl_inv_4x4_vs_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +void kernel_dsyrk_dpotrf_nt_l_4x4_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_4x4_vs_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D, int km, int kn); +// 4x2 +void kernel_dgemm_dtrsm_nt_rl_inv_4x2_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *E, double *inv_diag_E); +void kernel_dgemm_dtrsm_nt_rl_inv_4x2_vs_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *E, double *inv_diag_E, int km, int kn); +void kernel_dsyrk_dpotrf_nt_l_4x2_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_4x2_vs_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D, int km, int kn); +// 2x2 +void kernel_dsyrk_dpotrf_nt_l_2x2_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D); +void kernel_dsyrk_dpotrf_nt_l_2x2_vs_lib4(int kp, double *Ap, double *Bp, int km_, double *Am, double *Bm, double *C, double *D, double *inv_diag_D, int km, int kn); + +/* + * + * Auxiliary routines + * + * cpsc copy and scale, scale + * cp copy + * add + * set and scale + * transpose and scale + * set and scale + * + */ + +// copy and scale +void kernel_dgecpsc_8_0_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B, int sdb); +void kernel_dgecpsc_8_1_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B, int sdb); +void kernel_dgecpsc_8_2_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B, int sdb); +void kernel_dgecpsc_8_3_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B, int sdb); + +void kernel_dgecpsc_4_0_lib4(int tri, int kmax, double alpha, double *A, double *B); +void kernel_dgecpsc_4_1_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgecpsc_4_2_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgecpsc_4_3_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B); + +void kernel_dgecpsc_3_0_lib4(int tri, int kmax, double alpha, double *A, double *B); +void kernel_dgecpsc_3_2_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgecpsc_3_3_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B); + +void kernel_dgecpsc_2_0_lib4(int tri, int kmax, double alpha, double *A, double *B); +void kernel_dgecpsc_2_3_lib4(int tri, int kmax, double alpha, double *A0, int sda, double *B); + +void kernel_dgecpsc_1_0_lib4(int tri, int kmax, double alpha, double *A, double *B); + +// copy only +void kernel_dgecp_8_0_lib4(int tri, int kmax, double *A, int sda, double *B, int sdb); + +void kernel_dgecp_4_0_lib4(int tri, int kmax, double *A, double *B); + +// add +void kernel_dgead_8_0_lib4(int kmax, double alpha, double *A0, int sda, double *B, int sdb); +void kernel_dgead_8_1_lib4(int kmax, double alpha, double *A0, int sda, double *B, int sdb); +void kernel_dgead_8_2_lib4(int kmax, double alpha, double *A0, int sda, double *B, int sdb); +void kernel_dgead_8_3_lib4(int kmax, double alpha, double *A0, int sda, double *B, int sdb); +void kernel_dgead_4_0_lib4(int kmax, double alpha, double *A, double *B); +void kernel_dgead_4_1_lib4(int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgead_4_2_lib4(int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgead_4_3_lib4(int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgead_3_0_lib4(int kmax, double alpha, double *A, double *B); +void kernel_dgead_3_2_lib4(int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgead_3_3_lib4(int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgead_2_0_lib4(int kmax, double alpha, double *A, double *B); +void kernel_dgead_2_3_lib4(int kmax, double alpha, double *A0, int sda, double *B); +void kernel_dgead_1_0_lib4(int kmax, double alpha, double *A, double *B); + +// set +void kernel_dgeset_4_lib4(int kmax, double alpha, double *A); +void kernel_dtrset_4_lib4(int kmax, double alpha, double *A); + +// traspose +void kernel_dgetr_8_lib4(int tri, int kmax, int kna, double alpha, double *A, int sda, double *C, int sdc); +void kernel_dgetr_4_lib4(int tri, int kmax, int kna, double alpha, double *A, double *C, int sdc); +void kernel_dgetr_3_lib4(int tri, int kmax, int kna, double alpha, double *A, double *C, int sdc); +void kernel_dgetr_2_lib4(int tri, int kmax, int kna, double alpha, double *A, double *C, int sdc); +void kernel_dgetr_1_lib4(int tri, int kmax, int kna, double alpha, double *A, double *C, int sdc); +void kernel_dgetr_4_0_lib4(int m, double *A, int sda, double *B); + + + +// pack +// 12 +void kernel_dpack_nn_12_lib4(int kmax, double *A, int lda, double *B, int sdb); +void kernel_dpack_nn_12_vs_lib4(int kmax, double *A, int lda, double *B, int sdb, int m1); +void kernel_dpack_tt_12_lib4(int kmax, double *A, int lda, double *B, int sdb); +// 8 +void kernel_dpack_nn_8_lib4(int kmax, double *A, int lda, double *B, int sdb); +void kernel_dpack_nn_8_vs_lib4(int kmax, double *A, int lda, double *B, int sdb, int m1); +void kernel_dpack_tt_8_lib4(int kmax, double *A, int lda, double *B, int sdb); +// 4 +void kernel_dpack_nn_4_lib4(int kmax, double *A, int lda, double *B); +void kernel_dpack_nn_4_vs_lib4(int kmax, double *A, int lda, double *B, int m1); +void kernel_dpack_tn_4_p0_lib4(int kmax, double *A, int lda, double *B); +void kernel_dpack_tn_4_lib4(int kmax, double *A, int lda, double *B); +void kernel_dpack_tn_4_vs_lib4(int kmax, double *A, int lda, double *B, int m1); +void kernel_dpack_tt_4_lib4(int kmax, double *A, int lda, double *B, int sdb); +void kernel_dpack_tt_4_vs_lib4(int kmax, double *A, int lda, double *B, int sdb, int m1); +// unpack +// 12 +void kernel_dunpack_nn_12_lib4(int kmax, double *A, int sda, double *B, int ldb); +void kernel_dunpack_nn_12_vs_lib4(int kmax, double *A, int sda, double *B, int ldb, int m1); +void kernel_dunpack_tt_12_lib4(int kmax, double *A, int sda, double *B, int ldb); +// 8 +void kernel_dunpack_nn_8_lib4(int kmax, double *A, int sda, double *B, int ldb); +void kernel_dunpack_nn_8_vs_lib4(int kmax, double *A, int sda, double *B, int ldb, int m1); +void kernel_dunpack_tt_8_lib4(int kmax, double *A, int sda, double *B, int ldb); +// 4 +void kernel_dunpack_nn_4_lib4(int kmax, double *A, double *B, int ldb); +void kernel_dunpack_nn_4_vs_lib4(int kmax, double *A, double *B, int ldb, int m1); +void kernel_dunpack_nt_4_lib4(int kmax, double *A, double *B, int ldb); +void kernel_dunpack_nt_4_vs_lib4(int kmax, double *A, double *B, int ldb, int m1); +void kernel_dunpack_tt_4_lib4(int kmax, double *A, int sda, double *B, int ldb); + +// panel copy +// 12 +void kernel_dpacp_nn_12_lib4(int kmax, int offsetA, double *A, int sda, double *B, int sdb); +void kernel_dpacp_nn_12_vs_lib4(int kmax, int offsetA, double *A, int sda, double *B, int sdb, int m1); +// 8 +void kernel_dpacp_nn_8_lib4(int kmax, int offsetA, double *A, int sda, double *B, int sdb); +void kernel_dpacp_nn_8_vs_lib4(int kmax, int offsetA, double *A, int sda, double *B, int sdb, int m1); +// 4 +void kernel_dpacp_nt_4_lib4(int kmax, double *A, int offsetB, double *B, int sdb); +void kernel_dpacp_tn_4_lib4(int kmax, int offsetA, double *A, int sda, double *B); +void kernel_dpacp_nn_4_lib4(int kmax, int offsetA, double *A, int sda, double *B); +void kernel_dpacp_nn_4_vs_lib4(int kmax, int offsetA, double *A, int sda, double *B, int m1); + + + +/************************************************ +* BLAS API kernels +************************************************/ + +//#if defined(BLAS_API) + +// A, B panel-major bs=4; C, D column-major +// 12x4 +void kernel_dgemm_nt_12x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_12x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_12x4_p0_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *A_p, double *B_p); +void kernel_dsyrk_nt_l_12x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_l_12x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_u_12x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_u_12x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_12x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_12x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_12x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_12x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_12x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_12x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_12x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_12x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_12x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE); +void kernel_dtrsm_nt_rl_inv_12x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_12x4_lib44ccc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_12x4_vs_lib44ccc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_12x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E); +void kernel_dtrsm_nt_rl_one_12x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_12x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE); +void kernel_dtrsm_nt_ru_inv_12x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_12x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E); +void kernel_dtrsm_nt_ru_one_12x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int m1, int n1); +void kernel_dpotrf_nt_l_12x4_lib44cc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *dD); +void kernel_dpotrf_nt_l_12x4_vs_lib44cc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *dD, int m1, int n1); +// 4x12 +void kernel_dgemm_nt_4x12_lib44cc(int kmax, double *alpha, double *A, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x12_vs_lib44cc(int kmax, double *alpha, double *A, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x12_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x12_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x12_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x12_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x12_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x12_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x12_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x12_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +// 8x8 +void kernel_dsyrk_nt_l_8x8_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_l_8x8_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_u_8x8_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_u_8x8_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dpotrf_nt_l_8x8_lib44cc(int kmax, double *A, int sda, double *B, int sdb, double *C, int ldc, double *D, int ldd, double *dD); +void kernel_dpotrf_nt_l_8x8_vs_lib44cc(int kmax, double *A, int sda, double *B, int sdb, double *C, int ldc, double *D, int ldd, double *dD, int m1, int n1); +// 8x4 +void kernel_dgemm_nt_8x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_8x4_p0_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *A_p, double *B_p); +void kernel_dgemm_nt_8x4_p_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *A_p); +void kernel_dsyrk_nt_l_8x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_l_8x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_u_8x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_u_8x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_8x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_8x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_8x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_8x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_8x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_8x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_8x4_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_8x4_vs_lib44cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_8x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE); +void kernel_dtrsm_nt_rl_inv_8x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_8x4_lib44ccc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_8x4_vs_lib44ccc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_8x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E); +void kernel_dtrsm_nt_rl_one_8x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_8x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE); +void kernel_dtrsm_nt_ru_inv_8x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_8x4_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E); +void kernel_dtrsm_nt_ru_one_8x4_vs_lib44cc4(int kmax, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int m1, int n1); +void kernel_dpotrf_nt_l_8x4_lib44cc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *dD); +void kernel_dpotrf_nt_l_8x4_vs_lib44cc(int kmax, double *A, int sda, double *B, double *C, int ldc, double *D, int ldd, double *dD, int m1, int n1); +// 4x8 +void kernel_dgemm_nt_4x8_lib44cc(int kmax, double *alpha, double *A, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x8_vs_lib44cc(int kmax, double *alpha, double *A, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x8_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x8_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x8_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x8_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x8_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x8_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x8_tran_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x8_tran_vs_lib444c(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +// 4x4 +void kernel_dgemm_nt_4x4_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x4_vs_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_l_4x4_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_l_4x4_vs_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_u_4x4_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_u_4x4_vs_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x4_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x4_vs_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x4_tran_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x4_tran_vs_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x4_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x4_vs_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x4_tran_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x4_tran_vs_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x4_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x4_vs_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x4_tran_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x4_tran_vs_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x4_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x4_vs_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x4_tran_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x4_tran_vs_lib444c(int kmax, double *alpha, double *A, double *B, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_4x4_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE); +void kernel_dtrsm_nt_rl_inv_4x4_vs_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_4x4_lib44ccc(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_4x4_vs_lib44ccc(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_4x4_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E); +void kernel_dtrsm_nt_rl_one_4x4_vs_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_4x4_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE); +void kernel_dtrsm_nt_ru_inv_4x4_vs_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_4x4_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E); +void kernel_dtrsm_nt_ru_one_4x4_vs_lib44cc4(int kmax, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, double *E, int m1, int n1); +void kernel_dpotrf_nt_l_4x4_lib44cc(int kmax, double *A, double *B, double *C, int ldc, double *D, int ldd, double *dD); +void kernel_dpotrf_nt_l_4x4_vs_lib44cc(int kmax, double *A, double *B, double *C, int ldc, double *D, int ldd, double *dD, int m1, int n1); +// 4x2 +void kernel_dgemm_nt_4x2_lib44cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); + +// A panel-major bs=4; B, C, D column-major +// 12x4 +void kernel_dgemm_nn_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_l_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_l_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_rl_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_one_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_rl_one_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_ru_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_one_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_ru_one_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_12x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_12x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrsm_nn_ll_one_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_ll_one_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_rl_inv_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_rl_inv_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_rl_one_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_rl_one_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nt_rl_one_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_ru_inv_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_ru_inv_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_ru_one_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_ru_one_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_ru_inv_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_12x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nt_ru_one_12x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dgetrf_nn_l_12x4_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag); +void kernel_dgetrf_nn_l_12x4_vs_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag, int m1, int n1); +void kernel_dgetrf_nn_m_12x4_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag); +void kernel_dgetrf_nn_m_12x4_vs_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag, int m1, int n1); +void kernel_dgetrf_nn_r_12x4_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag); +void kernel_dgetrf_nn_r_12x4_vs_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag, int m1, int n1); +// 4x12 +void kernel_dgemm_nn_4x12_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_4x12_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_4x12_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x12_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_rl_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_one_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_rl_one_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_ru_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_one_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_ru_one_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x12_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x12_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +// 8x4 +void kernel_dgemm_nn_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_l_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_l_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_rl_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_one_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_rl_one_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_ru_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_one_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_ru_one_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_8x4_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_8x4_vs_lib4ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrsm_nn_ll_one_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_ll_one_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_rl_inv_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_rl_inv_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_rl_one_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_rl_one_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nt_rl_one_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_ru_inv_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_ru_inv_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_ru_one_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_ru_one_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_ru_inv_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_8x4_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nt_ru_one_8x4_vs_lib4cccc(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dgetrf_nn_l_8x4_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag); +void kernel_dgetrf_nn_l_8x4_vs_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag, int m1, int n1); +void kernel_dgetrf_nn_r_8x4_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag); +void kernel_dgetrf_nn_r_8x4_vs_lib4ccc(int kmax, double *A, int sda, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag, int m1, int n1); +// 4x8 +void kernel_dgemm_nn_4x8_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_4x8_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_4x8_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x8_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_rl_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_one_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_rl_one_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_ru_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_one_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nn_ru_one_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x8_tran_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x8_tran_vs_lib4c4c(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int ldd, int m1, int n1); +// 4x4 +void kernel_dgemm_nn_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dsyrk_nt_l_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dsyrk_nt_l_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_rl_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nn_rl_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_one_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_rl_one_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_rl_one_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nn_rl_one_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_ru_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nn_ru_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_one_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nn_ru_one_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nn_ru_one_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nn_ru_one_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_rl_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_rl_one_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_rl_one_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_ru_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x4_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x4_vs_lib4ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dtrmm_nt_ru_one_4x4_tran_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd); +void kernel_dtrmm_nt_ru_one_4x4_tran_vs_lib4c4c(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, double *D, int ldd, int m1, int n1); +void kernel_dtrsm_nn_ll_one_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_ll_one_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_rl_inv_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_rl_inv_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_rl_one_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_rl_one_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nt_rl_one_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_ru_inv_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_ru_inv_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_ru_one_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nn_ru_one_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_ru_inv_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_4x4_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde); +void kernel_dtrsm_nt_ru_one_4x4_vs_lib4cccc(int kmax, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, double *E, int lde, int m1, int n1); +void kernel_dgetrf_nn_4x4_lib4ccc(int kmax, double *A, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag); +void kernel_dgetrf_nn_4x4_vs_lib4ccc(int kmax, double *A, double *B, int ldb, double *C, int ldc, double *D, int ldd, double *diag, int m1, int n1); + +// B panel-major bs=4; A, C, D column-major +// 12x4 +void kernel_dgemm_nt_12x4_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_12x4_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_12x4_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_12x4_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 4x12 +void kernel_dgemm_nt_4x12_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x12_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_4x12_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_4x12_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 8x4 +void kernel_dgemm_nt_8x4_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x4_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_8x4_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_8x4_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 4x8 +void kernel_dgemm_nt_4x8_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x8_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_4x8_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_4x8_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 4x4 +void kernel_dgemm_nt_4x4_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x4_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_4x4_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_4x4_vs_libc4cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); + +// A, C, D panel-major; B, E column-major +// TODO merge with above +// 12x4 +void kernel_dtrsm_nn_rl_inv_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_rl_inv_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_rl_one_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nn_rl_one_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_ru_inv_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_ru_inv_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_ru_one_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nn_ru_one_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nt_rl_one_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_ru_inv_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_12x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nt_ru_one_12x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +// 8x4 +void kernel_dtrsm_nn_rl_inv_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_rl_inv_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_rl_one_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nn_rl_one_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_ru_inv_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nn_ru_inv_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_ru_one_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nn_ru_one_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nt_rl_one_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE); +void kernel_dtrsm_nt_ru_inv_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_8x4_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde); +void kernel_dtrsm_nt_ru_one_8x4_vs_lib4c44c(int kmax, double *A, int sda, double *B, int ldb, double *beta, double *C, int sdc, double *D, int sdd, double *E, int lde, int m1, int n1); +// 4x4 +void kernel_dtrsm_nn_rl_inv_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE); +void kernel_dtrsm_nn_rl_inv_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_rl_one_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde); +void kernel_dtrsm_nn_rl_one_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nn_ru_inv_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE); +void kernel_dtrsm_nn_ru_inv_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nn_ru_one_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde); +void kernel_dtrsm_nn_ru_one_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_rl_inv_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE); +void kernel_dtrsm_nt_rl_inv_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_rl_one_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde); +void kernel_dtrsm_nt_rl_one_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, int m1, int n1); +void kernel_dtrsm_nt_ru_inv_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE); +void kernel_dtrsm_nt_ru_inv_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, double *dE, int m1, int n1); +void kernel_dtrsm_nt_ru_one_4x4_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde); +void kernel_dtrsm_nt_ru_one_4x4_vs_lib4c44c(int kmax, double *A, double *B, int ldb, double *beta, double *C, double *D, double *E, int lde, int m1, int n1); + +// A, B, C, D column-major +// 12x4 +void kernel_dgemm_nn_12x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_12x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_12x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_12x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_12x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_12x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 4x12 +void kernel_dgemm_nn_4x12_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_4x12_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_4x12_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x12_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_4x12_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_4x12_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 8x4 +void kernel_dgemm_nn_8x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_8x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_8x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_8x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_8x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 4x8 +void kernel_dgemm_nn_4x8_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_4x8_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_4x8_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x8_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_4x8_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_4x8_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 4x4 +void kernel_dgemm_nn_4x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_4x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nt_4x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_4x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_4x4_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_4x4_vs_libcccc(int kmax, double *alpha, double *A, int lda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); + +// A column-major +// 12 +void kernel_dgetrf_pivot_12_lib(int m, double *pA, int lda, double *inv_diag_A, int* ipiv); +void kernel_dgetrf_pivot_12_vs_lib(int m, double *pA, int lda, double *inv_diag_A, int* ipiv, int n); +// 8 +void kernel_dgetrf_pivot_8_lib(int m, double *pA, int lda, double *inv_diag_A, int* ipiv); +void kernel_dgetrf_pivot_8_vs_lib(int m, double *pA, int lda, double *inv_diag_A, int* ipiv, int n); +// 4 +void kernel_dgetrf_pivot_4_lib(int m, double *pA, int lda, double *inv_diag_A, int* ipiv); +void kernel_dgetrf_pivot_4_vs_lib(int m, double *pA, int lda, double *inv_diag_A, int* ipiv, int n); + +// vector +void kernel_ddot_11_lib(int n, double *x, double *y, double *res); +void kernel_daxpy_11_lib(int n, double *alpha, double *x, double *y); +void kernel_drowsw_lib(int kmax, double *pA, int lda, double *pC, int ldc); + +//#endif // BLAS_API + + + +// larger kernels +// 12 +void kernel_dgemm_nt_12xn_p0_lib44cc(int n, int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, double *A_p, double *B_p); +void kernel_dgemm_nt_12xn_pl_lib44cc(int n, int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, double *A_p, double *B_p); +// 8 +void kernel_dgemm_nt_8xn_p0_lib44cc(int n, int k, double *alpha, double *A, int sda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, double *A_p, double *B_p); + + + +// A, B panel-major bs=8; C, D column-major +// 24x8 +void kernel_dgemm_nt_24x8_lib88cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_24x8_vs_lib88cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 16x8 +void kernel_dgemm_nt_16x8_lib88cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_16x8_vs_lib88cc(int kmax, double *alpha, double *A, int sda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 8x8 +void kernel_dgemm_nt_8x8_lib88cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x8_vs_lib88cc(int kmax, double *alpha, double *A, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); + +// A, panel-major bs=8; B, C, D column-major +// 24x8 +void kernel_dgemm_nt_24x8_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_24x8_vs_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nn_24x8_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_24x8_vs_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 16x8 +void kernel_dgemm_nt_16x8_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_16x8_vs_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nn_16x8_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_16x8_vs_lib8ccc(int kmax, double *alpha, double *A, int sda, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 8x8 +void kernel_dgemm_nt_8x8_lib8ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x8_vs_lib8ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_nn_8x8_lib8ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nn_8x8_vs_lib8ccc(int kmax, double *alpha, double *A, double *B, int ldb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); + +// B, panel-major bs=8; A, C, D column-major +// 8x24 +void kernel_dgemm_nt_8x24_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x24_vs_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_8x24_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_8x24_vs_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 8x16 +void kernel_dgemm_nt_8x16_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x16_vs_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_8x16_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_8x16_vs_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, int sdb, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +// 8x8 +void kernel_dgemm_nt_8x8_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_nt_8x8_vs_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); +void kernel_dgemm_tt_8x8_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd); +void kernel_dgemm_tt_8x8_vs_libc8cc(int kmax, double *alpha, double *A, int lda, double *B, double *beta, double *C, int ldc, double *D, int ldd, int m1, int n1); + + + +// aux +void kernel_dvecld_inc1(int kmax, double *x); +void kernel_dveccp_inc1(int kmax, double *x, double *y); + + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_D_KERNEL_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_i_aux_ext_dep.h b/third_party/acados/include/blasfeo/include/blasfeo_i_aux_ext_dep.h new file mode 100644 index 00000000000000..74c3fb5c0a22ff --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_i_aux_ext_dep.h @@ -0,0 +1,69 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_I_AUX_EXT_DEP_H_ +#define BLASFEO_I_AUX_EXT_DEP_H_ + + + +#include "blasfeo_target.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifdef EXT_DEP + +// i_aux_extern_depend_lib +void int_zeros(int **pA, int row, int col); +void int_zeros_align(int **pA, int row, int col); +void int_free(int *pA); +void int_free_align(int *pA); +void int_print_mat(int row, int col, int *A, int lda); +int int_print_to_string_mat(char **buf_out, int row, int col, int *A, int lda); + +#endif // EXT_DEP + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_I_AUX_EXT_DEP_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_m_aux.h b/third_party/acados/include/blasfeo/include/blasfeo_m_aux.h new file mode 100644 index 00000000000000..6248853e292fd2 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_m_aux.h @@ -0,0 +1,57 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_M_AUX_H_ +#define BLASFEO_M_AUX_H_ + +#include "blasfeo_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +void blasfeo_cvt_d2s_vec(int m, struct blasfeo_dvec *vd, int vdi, struct blasfeo_svec *vs, int vsi); +void blasfeo_cvt_s2d_vec(int m, struct blasfeo_svec *vs, int vsi, struct blasfeo_dvec *vd, int vdi); +void blasfeo_cvt_d2s_mat(int m, int n, struct blasfeo_dmat *Md, int mid, int nid, struct blasfeo_smat *Ms, int mis, int nis); +void blasfeo_cvt_s2d_mat(int m, int n, struct blasfeo_smat *Ms, int mis, int nis, struct blasfeo_dmat *Md, int mid, int nid); + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_M_AUX_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_memory.h b/third_party/acados/include/blasfeo/include/blasfeo_memory.h new file mode 100644 index 00000000000000..da4e7fa090078a --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_memory.h @@ -0,0 +1,62 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2020 by Gianluca Frison. * +* All rights reserved. * +* * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + +#ifndef BLASFEO_MEMORY_H_ +#define BLASFEO_MEMORY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +int blasfeo_is_init(); +// +void blasfeo_init(); +// +void blasfeo_quit(); +// +void *blasfeo_get_buffer(); + + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_MEMORY_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_naming.h b/third_party/acados/include/blasfeo/include/blasfeo_naming.h new file mode 100644 index 00000000000000..c289443b176793 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_naming.h @@ -0,0 +1,77 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + +/* + * ----------- Naming conventions + * + * (precision)(data) + * + * 1) d(double) + * s(single) + * + * 2) ge(general) + * tr(triangular) + * vec(vector) + * row(row) + * col(column) + * dia(diagonal) + * + * 3) se(set) + * cp(copy) + * sc(scale) + * ad(add) + * tr(transpose) + * in(insert) + * ex(extract) + * pe(premute) + * sw(swap) + * + * f(factorization) + * + * lqf(LQ factorization) + * qrf (factorization) + * trf (LU factorization using partial pivoting with row interchanges.) + * + * 4) _l(lower) / _u(upper) + * _lib8 (hp implementation, 8 rows kernel) + * _lib4 (hp implementation, 4 rows kernel) + * _lib0 (hp interface with reference implentation) + * _lib (reference implementation) + * _libref (reference implementation with dedicated namespace) + * + * 5) _sp(sparse) + * _exp(exponential format) + */ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_processor_features.h b/third_party/acados/include/blasfeo/include/blasfeo_processor_features.h new file mode 100644 index 00000000000000..65a0c7e80a173a --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_processor_features.h @@ -0,0 +1,88 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Ian McInerney * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_PROCESSOR_FEATURES_H_ +#define BLASFEO_PROCESSOR_FEATURES_H_ + +/** + * Flags to indicate the different processor features + */ +enum +{ + // x86-64 CPU features + BLASFEO_PROCESSOR_FEATURE_AVX = 0x0001, /// AVX instruction set + BLASFEO_PROCESSOR_FEATURE_AVX2 = 0x0002, /// AVX2 instruction set + BLASFEO_PROCESSOR_FEATURE_FMA = 0x0004, /// FMA instruction set + BLASFEO_PROCESSOR_FEATURE_SSE3 = 0x0008, /// SSE3 instruction set + + // ARM CPU features + BLASFEO_PROCESSOR_FEATURE_VFPv3 = 0x0100, /// VFPv3 instruction set + BLASFEO_PROCESSOR_FEATURE_NEON = 0x0100, /// NEON instruction set + BLASFEO_PROCESSOR_FEATURE_VFPv4 = 0x0100, /// VFPv4 instruction set + BLASFEO_PROCESSOR_FEATURE_NEONv2 = 0x0100, /// NEONv2 instruction set +} BLASFEO_PROCESSOR_FEATURES; + +/** + * Test the features that this processor provides against what the library was compiled with. + * + * @param features - Pointer to an integer to store the supported feature set (using the flags in the BLASFEO_PROCESSOR_FEATURES enum) + * @return 0 if current processor doesn't support all features required for this library, 1 otherwise + */ +int blasfeo_processor_cpu_features( int* features ); + +/** + * Test the features that this processor provides against what the library was compiled with. + * + * @param features - Pointer to an integer to store the supported feature set (using the flags in the BLASFEO_PROCESSOR_FEATURES enum) + * @return 0 if current processor doesn't support all features required for this library, 1 otherwise + */ +void blasfeo_processor_library_features( int* features ); + +/** + * Create a string listing the features the current processor supports. + * + * @param features - Flags from the BLASFEO_PROCESSOR_FEATURES enum indicating the features supported + * @param featureString - Character array to store the feature string in + */ +void blasfeo_processor_feature_string( int features, char* featureString ); + +/** + * Get a string listing the processor features that this library version needs to run. + * + * @param featureString - Character array to store the feature string in + */ +void blasfeo_processor_library_string( char* featureString ); + +#endif // BLASFEO_PROCESSOR_FEATURES_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_aux.h b/third_party/acados/include/blasfeo/include/blasfeo_s_aux.h new file mode 100644 index 00000000000000..539268849cf3d0 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_aux.h @@ -0,0 +1,166 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_AUX_H_ +#define BLASFEO_S_AUX_H_ + + + +#include + +#include "blasfeo_s_aux_old.h" +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/************************************************ +* d_aux_lib.c +************************************************/ + +// returns the memory size (in bytes) needed for a smat +size_t blasfeo_memsize_smat(int m, int n); +size_t blasfeo_memsize_smat_ps(int ps, int m, int n); +// returns the memory size (in bytes) needed for the diagonal of a smat +size_t blasfeo_memsize_diag_smat(int m, int n); +// returns the memory size (in bytes) needed for a svec +size_t blasfeo_memsize_svec(int m); +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_create_smat(int m, int n, struct blasfeo_smat *sA, void *memory); +void blasfeo_create_smat_ps(int ps, int m, int n, struct blasfeo_smat *sA, void *memory); +// create a strvec for a vector of size m by using memory passed by a pointer (pointer is not updated) +void blasfeo_create_svec(int m, struct blasfeo_svec *sA, void *memory); +void blasfeo_pack_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_pack_l_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_pack_u_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_pack_tran_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_pack_svec(int m, float *x, int xi, struct blasfeo_svec *sa, int ai); +void blasfeo_unpack_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj, float *A, int lda); +void blasfeo_unpack_tran_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj, float *A, int lda); +void blasfeo_unpack_svec(int m, struct blasfeo_svec *sa, int ai, float *x, int xi); +//void s_cast_mat2strmat(float *A, struct blasfeo_smat *sA); +//void s_cast_diag_mat2strmat(float *dA, struct blasfeo_smat *sA); +//void s_cast_vec2vecmat(float *a, struct blasfeo_svec *sa); + +// ge +void blasfeo_sgese(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_sgecpsc(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_sgecp(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_sgesc(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_sgein1(float a, struct blasfeo_smat *sA, int ai, int aj); +float blasfeo_sgeex1(struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_sgead(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_sgetr(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// tr +void blasfeo_strcp_l(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_strtr_l(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_strtr_u(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// dia +void blasfeo_sdiare(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_sdiaex(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +void blasfeo_sdiain(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_sdiain_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_sdiaex_sp(int kmax, float alpha, int *idx, struct blasfeo_smat *sD, int di, int dj, struct blasfeo_svec *sx, int xi); +void blasfeo_sdiaad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_sdiaad_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_sdiaadin_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, int *idx, struct blasfeo_smat *sD, int di, int dj); +// row +void blasfeo_srowin(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_srowex(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +void blasfeo_srowad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_srowad_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_srowsw(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_srowpe(int kmax, int *ipiv, struct blasfeo_smat *sA); +void blasfeo_srowpei(int kmax, int *ipiv, struct blasfeo_smat *sA); +// col +void blasfeo_scolex(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +void blasfeo_scolin(int kmax, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_scolad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_scolsc(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_scolsw(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_scolpe(int kmax, int *ipiv, struct blasfeo_smat *sA); +void blasfeo_scolpei(int kmax, int *ipiv, struct blasfeo_smat *sA); +// vec +void blasfeo_svecse(int m, float alpha, struct blasfeo_svec *sx, int xi); +void blasfeo_sveccp(int m, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); +void blasfeo_svecsc(int m, float alpha, struct blasfeo_svec *sa, int ai); +void blasfeo_sveccpsc(int m, float alpha, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); +void blasfeo_svecad(int m, float alpha, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); +void blasfeo_svecin1(float a, struct blasfeo_svec *sx, int xi); +float blasfeo_svecex1(struct blasfeo_svec *sx, int xi); +void blasfeo_svecad_sp(int m, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_svec *sz, int zi); +void blasfeo_svecin_sp(int m, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_svec *sz, int zi); +void blasfeo_svecex_sp(int m, float alpha, int *idx, struct blasfeo_svec *sx, int x, struct blasfeo_svec *sz, int zi); +void blasfeo_sveccl(int m, struct blasfeo_svec *sxm, int xim, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sxp, int xip, struct blasfeo_svec *sz, int zi); +void blasfeo_sveccl_mask(int m, struct blasfeo_svec *sxm, int xim, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sxp, int xip, struct blasfeo_svec *sz, int zi, struct blasfeo_svec *sm, int mi); +void blasfeo_svecze(int m, struct blasfeo_svec *sm, int mi, struct blasfeo_svec *sv, int vi, struct blasfeo_svec *se, int ei); +void blasfeo_svecnrm_inf(int m, struct blasfeo_svec *sx, int xi, float *ptr_norm); +void blasfeo_svecnrm_2(int m, struct blasfeo_svec *sx, int xi, float *ptr_norm); +void blasfeo_svecpe(int kmax, int *ipiv, struct blasfeo_svec *sx, int xi); +void blasfeo_svecpei(int kmax, int *ipiv, struct blasfeo_svec *sx, int xi); + + + +/* +* Explicitly panel-major matrix format +*/ + +// returns the memory size (in bytes) needed for a dmat +size_t blasfeo_pm_memsize_smat(int ps, int m, int n); +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_pm_create_smat(int ps, int m, int n, struct blasfeo_pm_smat *sA, void *memory); + + + +/* +* Explicitly column-major matrix format +*/ + +// returns the memory size (in bytes) needed for a dmat +size_t blasfeo_cm_memsize_smat(int m, int n); +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_cm_create_smat(int m, int n, struct blasfeo_pm_smat *sA, void *memory); + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_AUX_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ext_dep.h b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ext_dep.h new file mode 100644 index 00000000000000..5209d20d377c21 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ext_dep.h @@ -0,0 +1,141 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_AUX_EXT_DEP_H_ +#define BLASFEO_S_AUX_EXT_DEP_H_ + + + +#include + + + +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifdef EXT_DEP + +/************************************************ +* s_aux_extern_depend_lib.c +************************************************/ + +/* column-major matrices */ + +// dynamically allocate row*col floats of memory and set accordingly a pointer to float; set allocated memory to zero +void s_zeros(float **pA, int row, int col); +// dynamically allocate row*col floats of memory aligned to 64-byte boundaries and set accordingly a pointer to float; set allocated memory to zero +void s_zeros_align(float **pA, int row, int col); +// dynamically allocate size bytes of memory aligned to 64-byte boundaries and set accordingly a pointer to float; set allocated memory to zero +void s_zeros_align_bytes(float **pA, int size); +// free the memory allocated by d_zeros +void s_free(float *pA); +// free the memory allocated by d_zeros_align or d_zeros_align_bytes +void s_free_align(float *pA); +// print a column-major matrix +void s_print_mat(int m, int n, float *A, int lda); +// print the transposed of a column-major matrix +void s_print_tran_mat(int row, int col, float *A, int lda); +// print to file a column-major matrix +void s_print_to_file_mat(FILE *file, int row, int col, float *A, int lda); +// print to file a column-major matrix in exponential format +void s_print_to_file_exp_mat(FILE *file, int row, int col, float *A, int lda); +// print to string a column-major matrix +void s_print_to_string_mat(char **buf_out, int row, int col, float *A, int lda); +// print to file the transposed of a column-major matrix +void s_print_tran_to_file_mat(FILE *file, int row, int col, float *A, int lda); +// print to file the transposed of a column-major matrix in exponential format +void s_print_tran_to_file_exp_mat(FILE *file, int row, int col, float *A, int lda); +// print in exponential notation a column-major matrix +void s_print_exp_mat(int m, int n, float *A, int lda); +// print in exponential notation the transposed of a column-major matrix +void s_print_exp_tran_mat(int row, int col, float *A, int lda); + +/* strmat and strvec */ + +// create a strmat for a matrix of size m*n by dynamically allocating memory +void blasfeo_allocate_smat(int m, int n, struct blasfeo_smat *sA); +// create a strvec for a vector of size m by dynamically allocating memory +void blasfeo_allocate_svec(int m, struct blasfeo_svec *sa); +// free the memory allocated by blasfeo_allocate_dmat +void blasfeo_free_smat(struct blasfeo_smat *sA); +// free the memory allocated by blasfeo_allocate_dvec +void blasfeo_free_svec(struct blasfeo_svec *sa); +// print a strmat +void blasfeo_print_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj); +// print in exponential notation a strmat +void blasfeo_print_exp_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj); +// print to file a strmat +void blasfeo_print_to_file_smat(FILE *file, int m, int n, struct blasfeo_smat *sA, int ai, int aj); +// print to file a strmat in exponential format +void blasfeo_print_to_file_exp_smat(FILE *file, int m, int n, struct blasfeo_smat *sA, int ai, int aj); +// print to string a strmat +void blasfeo_print_to_string_smat(char **buf_out, int m, int n, struct blasfeo_smat *sA, int ai, int aj); +// print the transpose of a strmat +void blasfeo_print_tran_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj); +// print a strvec +void blasfeo_print_svec(int m, struct blasfeo_svec *sa, int ai); +// print in exponential notation a strvec +void blasfeo_print_exp_svec(int m, struct blasfeo_svec *sa, int ai); +// print to file a strvec +void blasfeo_print_to_file_svec(FILE *file, int m, struct blasfeo_svec *sa, int ai); +// print to string a strvec +void blasfeo_print_to_string_svec(char **buf_out, int m, struct blasfeo_svec *sa, int ai); +// print the transposed of a strvec +void blasfeo_print_tran_svec(int m, struct blasfeo_svec *sa, int ai); +// print in exponential notation the transposed of a strvec +void blasfeo_print_exp_tran_svec(int m, struct blasfeo_svec *sa, int ai); +// print to file the transposed of a strvec +void blasfeo_print_to_file_tran_svec(FILE *file, int m, struct blasfeo_svec *sa, int ai); +// print to string the transposed of a strvec +void blasfeo_print_to_string_tran_svec(char **buf_out, int m, struct blasfeo_svec *sa, int ai); + +#endif // EXT_DEP + + + +#ifdef __cplusplus +} +#endif + + + +#endif // BLASFEO_S_AUX_EXT_DEP_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ext_dep_ref.h b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ext_dep_ref.h new file mode 100644 index 00000000000000..6640e20a406c85 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ext_dep_ref.h @@ -0,0 +1,82 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_AUX_EXT_DEP_REF_H_ +#define BLASFEO_S_AUX_EXT_DEP_REF_H_ + +#if defined(EXT_DEP) + + + +#include + +#include "blasfeo_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// expose reference BLASFEO for testing +// see blasfeo_s_aux_exp_dep.h for help + +void blasfeo_print_smat_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj); +void blasfeo_allocate_smat_ref(int m, int n, struct blasfeo_smat_ref *sA); +void blasfeo_allocate_svec_ref(int m, struct blasfeo_svec_ref *sa); +void blasfeo_free_smat_ref(struct blasfeo_smat_ref *sA); +void blasfeo_free_svec_ref(struct blasfeo_svec_ref *sa); +void blasfeo_print_smat_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj); +void blasfeo_print_exp_smat_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj); +void blasfeo_print_to_file_smat_ref(FILE *file, int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj); +void blasfeo_print_to_file_exp_smat_ref(FILE *file, int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj); +void blasfeo_print_to_string_smat_ref(char **buf_out, int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj); +void blasfeo_print_svec(int m, struct blasfeo_svec *sa, int ai); +void blasfeo_print_exp_svec(int m, struct blasfeo_svec *sa, int ai); +void blasfeo_print_to_file_svec(FILE *file, int m, struct blasfeo_svec *sa, int ai); +void blasfeo_print_to_string_svec(char **buf_out, int m, struct blasfeo_svec *sa, int ai); +void blasfeo_print_tran_svec(int m, struct blasfeo_svec *sa, int ai); +void blasfeo_print_exp_tran_svec(int m, struct blasfeo_svec *sa, int ai); +void blasfeo_print_to_file_tran_svec(FILE *file, int m, struct blasfeo_svec *sa, int ai); +void blasfeo_print_to_string_tran_svec(char **buf_out, int m, struct blasfeo_svec *sa, int ai); + + +#ifdef __cplusplus +} +#endif + + + +#endif // EXT_DEP + +#endif // BLASFEO_S_AUX_EXT_DEP_REF_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_aux_old.h b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_old.h new file mode 100644 index 00000000000000..5c6db37bab1b1d --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_old.h @@ -0,0 +1,64 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +// TODO remove +// +void strcp_l_lib(int m, float alpha, int offsetA, float *A, int sda, int offsetB, float *B, int sdb); +void sgead_lib(int m, int n, float alpha, int offsetA, float *A, int sda, int offsetB, float *B, int sdb); +void sgetr_lib(int m, int n, float alpha, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +void strtr_l_lib(int m, float alpha, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +void strtr_u_lib(int m, float alpha, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +void sdiareg_lib(int kmax, float reg, int offset, float *pD, int sdd); +void sdiain_sqrt_lib(int kmax, float *x, int offset, float *pD, int sdd); +void sdiaex_lib(int kmax, float alpha, int offset, float *pD, int sdd, float *x); +void sdiaad_lib(int kmax, float alpha, float *x, int offset, float *pD, int sdd); +void sdiain_libsp(int kmax, int *idx, float alpha, float *x, float *pD, int sdd); +void sdiaex_libsp(int kmax, int *idx, float alpha, float *pD, int sdd, float *x); +void sdiaad_libsp(int kmax, int *idx, float alpha, float *x, float *pD, int sdd); +void sdiaadin_libsp(int kmax, int *idx, float alpha, float *x, float *y, float *pD, int sdd); +void srowin_lib(int kmax, float alpha, float *x, float *pD); +void srowex_lib(int kmax, float alpha, float *pD, float *x); +void srowad_lib(int kmax, float alpha, float *x, float *pD); +void srowin_libsp(int kmax, float alpha, int *idx, float *x, float *pD); +void srowad_libsp(int kmax, int *idx, float alpha, float *x, float *pD); +void srowadin_libsp(int kmax, int *idx, float alpha, float *x, float *y, float *pD); +void srowsw_lib(int kmax, float *pA, float *pC); +void scolin_lib(int kmax, float *x, int offset, float *pD, int sdd); +void scolad_lib(int kmax, float alpha, float *x, int offset, float *pD, int sdd); +void scolin_libsp(int kmax, int *idx, float *x, float *pD, int sdd); +void scolad_libsp(int kmax, float alpha, int *idx, float *x, float *pD, int sdd); +void scolsw_lib(int kmax, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +void svecin_libsp(int kmax, int *idx, float *x, float *y); +void svecad_libsp(int kmax, int *idx, float alpha, float *x, float *y); diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ref.h b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ref.h new file mode 100644 index 00000000000000..f6e16a9577fd4d --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_ref.h @@ -0,0 +1,145 @@ + +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_AUX_REF_H_ +#define BLASFEO_S_AUX_REF_H_ + + + +#include + +#include "blasfeo_s_aux_old.h" +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/************************************************ +* d_aux_lib.c +************************************************/ + +// returns the memory size (in bytes) needed for a smat +size_t blasfeo_ref_memsize_smat(int m, int n); +size_t blasfeo_ref_memsize_smat_ps(int ps, int m, int n); +// returns the memory size (in bytes) needed for the diagonal of a smat +size_t blasfeo_ref_memsize_diag_smat(int m, int n); +// returns the memory size (in bytes) needed for a svec +size_t blasfeo_ref_memsize_svec(int m); +// create a strmat for a matrix of size m*n by using memory passed by a pointer (pointer is not updated) +void blasfeo_ref_create_smat(int m, int n, struct blasfeo_smat *sA, void *memory); +void blasfeo_ref_create_smat_ps(int ps, int m, int n, struct blasfeo_smat *sA, void *memory); +// create a strvec for a vector of size m by using memory passed by a pointer (pointer is not updated) +void blasfeo_ref_create_svec(int m, struct blasfeo_svec *sA, void *memory); +void blasfeo_ref_pack_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_pack_l_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sB, int bi, int bj); +void blasfeo_ref_pack_l_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sB, int bi, int bj); +void blasfeo_ref_pack_tran_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_pack_svec(int m, float *x, int xi, struct blasfeo_svec *sa, int ai); +void blasfeo_ref_unpack_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj, float *A, int lda); +void blasfeo_ref_unpack_tran_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj, float *A, int lda); +void blasfeo_ref_unpack_svec(int m, struct blasfeo_svec *sa, int ai, float *x, int xi); +void ref_s_cast_mat2strmat(float *A, struct blasfeo_smat *sA); +void ref_s_cast_diag_mat2strmat(float *dA, struct blasfeo_smat *sA); +void ref_s_cast_vec2vecmat(float *a, struct blasfeo_svec *sa); + +// ge +void blasfeo_ref_sgese(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_sgecpsc(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_ref_sgecp(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_ref_sgesc(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_sgein1(float a, struct blasfeo_smat *sA, int ai, int aj); +float blasfeo_ref_sgeex1(struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_sgead(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_ref_sgetr(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// tr +void blasfeo_ref_strcp_l(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_ref_strtr_l(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_ref_strtr_u(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// dia +void blasfeo_ref_sdiare(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_sdiaex(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +void blasfeo_ref_sdiain(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_sdiain_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ref_sdiaex_sp(int kmax, float alpha, int *idx, struct blasfeo_smat *sD, int di, int dj, struct blasfeo_svec *sx, int xi); +void blasfeo_ref_sdiaad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_sdiaad_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ref_sdiaadin_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, int *idx, struct blasfeo_smat *sD, int di, int dj); +// row +void blasfeo_ref_srowin(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_srowex(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +void blasfeo_ref_srowad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_srowad_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ref_srowsw(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_ref_srowpe(int kmax, int *ipiv, struct blasfeo_smat *sA); +void blasfeo_ref_srowpei(int kmax, int *ipiv, struct blasfeo_smat *sA); +// col +void blasfeo_ref_scolex(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +void blasfeo_ref_scolin(int kmax, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_scolad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_scolsc(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj); +void blasfeo_ref_scolsw(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void blasfeo_ref_scolpe(int kmax, int *ipiv, struct blasfeo_smat *sA); +void blasfeo_ref_scolpei(int kmax, int *ipiv, struct blasfeo_smat *sA); +// vec +void blasfeo_ref_svecse(int m, float alpha, struct blasfeo_svec *sx, int xi); +void blasfeo_ref_sveccp(int m, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); +void blasfeo_ref_svecsc(int m, float alpha, struct blasfeo_svec *sa, int ai); +void blasfeo_ref_sveccpsc(int m, float alpha, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); +void blasfeo_ref_svecad(int m, float alpha, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); +void blasfeo_ref_svecin1(float a, struct blasfeo_svec *sx, int xi); +float blasfeo_ref_svecex1(struct blasfeo_svec *sx, int xi); +void blasfeo_ref_svecad_sp(int m, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_svec *sz, int zi); +void blasfeo_ref_svecin_sp(int m, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_svec *sz, int zi); +void blasfeo_ref_svecex_sp(int m, float alpha, int *idx, struct blasfeo_svec *sx, int x, struct blasfeo_svec *sz, int zi); +void blasfeo_ref_sveccl(int m, struct blasfeo_svec *sxm, int xim, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sxp, int xip, struct blasfeo_svec *sz, int zi); +void blasfeo_ref_sveccl_mask(int m, struct blasfeo_svec *sxm, int xim, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sxp, int xip, struct blasfeo_svec *sz, int zi, struct blasfeo_svec *sm, int mi); +void blasfeo_ref_svecze(int m, struct blasfeo_svec *sm, int mi, struct blasfeo_svec *sv, int vi, struct blasfeo_svec *se, int ei); +void blasfeo_ref_svecnrm_inf(int m, struct blasfeo_svec *sx, int xi, float *ptr_norm); +void blasfeo_ref_svecpe(int kmax, int *ipiv, struct blasfeo_svec *sx, int xi); +void blasfeo_ref_svecpei(int kmax, int *ipiv, struct blasfeo_svec *sx, int xi); + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_AUX_REF_H_ + diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_aux_test.h b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_test.h new file mode 100644 index 00000000000000..08d9a14a6a7de4 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_aux_test.h @@ -0,0 +1,177 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_AUX_TEST_H_ +#define BLASFEO_S_AUX_TEST_H_ + +#include + +#include "blasfeo_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +/************************************************ +* d_aux_lib.c +************************************************/ + +int test_blasfeo_memsize_smat(int m, int n); +int test_blasfeo_memsize_diag_smat(int m, int n); +int test_blasfeo_memsize_svec(int m); + +void test_blasfeo_create_smat(int m, int n, struct blasfeo_smat *sA, void *memory); +void test_blasfeo_create_svec(int m, struct blasfeo_svec *sA, void *memory); + +void test_blasfeo_pack_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void test_blasfeo_pack_svec(int m, float *x, int xi, struct blasfeo_svec *sa, int ai); +void test_blasfeo_pack_tran_smat(int m, int n, float *A, int lda, struct blasfeo_smat *sA, int ai, int aj); +void test_blasfeo_unpack_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj, float *A, int lda); +void test_blasfeo_unpack_svec(int m, struct blasfeo_svec *sa, int ai, float *x, int xi); +void test_blasfeo_unpack_tran_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj, float *A, int lda); + +void test_s_cast_mat2strmat(float *A, struct blasfeo_smat *sA); +void test_s_cast_diag_mat2strmat(float *dA, struct blasfeo_smat *sA); +void test_s_cast_vec2vecmat(float *a, struct blasfeo_svec *sa); +// copy and scale +void test_blasfeo_sgecpsc(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void test_blasfeo_sgecp(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +void test_blasfeo_sgesc(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj); + +// void test_blasfeo_sgein1(float a, struct blasfeo_smat *sA, int ai, int aj); +// float test_blasfeo_sgeex1(struct blasfeo_smat *sA, int ai, int aj); +// void test_blasfeo_svecin1(float a, struct blasfeo_svec *sx, int xi); +// float test_blasfeo_svecex1(struct blasfeo_svec *sx, int xi); + +// // A <= alpha +// void test_blasfeo_sgese(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj); +// // a <= alpha +// void test_blasfeo_svecse(int m, float alpha, struct blasfeo_svec *sx, int xi); + + +// void test_blasfeo_sveccp(int m, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); +// void test_blasfeo_svecsc(int m, float alpha, struct blasfeo_svec *sa, int ai); + +// void test_strcp_l_lib(int m, float alpha, int offsetA, float *A, int sda, int offsetB, float *B, int sdb); +// void test_blasfeo_strcp_l(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); + +// void test_sgead_lib(int m, int n, float alpha, int offsetA, float *A, int sda, int offsetB, float *B, int sdb); +// void test_blasfeo_sgead(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// void test_blasfeo_svecad(int m, float alpha, struct blasfeo_svec *sa, int ai, struct blasfeo_svec *sc, int ci); + +// void test_sgetr_lib(int m, int n, float alpha, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +// void test_blasfeo_sgetr(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); + +// void test_strtr_l_lib(int m, float alpha, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +// void test_blasfeo_strtr_l(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// void test_strtr_u_lib(int m, float alpha, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +// void test_blasfeo_strtr_u(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); + +// void test_sdiareg_lib(int kmax, float reg, int offset, float *pD, int sdd); +// void test_blasfeo_sdiaex(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +// void test_blasfeo_sdiain(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +// void test_sdiain_sqrt_lib(int kmax, float *x, int offset, float *pD, int sdd); +// void test_sdiaex_lib(int kmax, float alpha, int offset, float *pD, int sdd, float *x); +// void test_sdiaad_lib(int kmax, float alpha, float *x, int offset, float *pD, int sdd); +// void test_sdiain_libsp(int kmax, int *idx, float alpha, float *x, float *pD, int sdd); +// void test_blasfeo_sdiain_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +// void test_sdiaex_libsp(int kmax, int *idx, float alpha, float *pD, int sdd, float *x); +// void test_blasfeo_sdiaex_sp(int kmax, float alpha, int *idx, struct blasfeo_smat *sD, int di, int dj, struct blasfeo_svec *sx, int xi); +// void test_blasfeo_sdiaad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +// void test_sdiaad_libsp(int kmax, int *idx, float alpha, float *x, float *pD, int sdd); +// void test_blasfeo_sdiaad_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +// void test_sdiaadin_libsp(int kmax, int *idx, float alpha, float *x, float *y, float *pD, int sdd); +// void test_blasfeo_sdiaadin_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, int *idx, struct blasfeo_smat *sD, int di, int dj); +// void test_srowin_lib(int kmax, float alpha, float *x, float *pD); +// void test_blasfeo_srowin(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +// void test_srowex_lib(int kmax, float alpha, float *pD, float *x); +// void test_blasfeo_srowex(int kmax, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi); +// void test_srowad_lib(int kmax, float alpha, float *x, float *pD); +// void test_blasfeo_srowad(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +// void test_srowin_libsp(int kmax, float alpha, int *idx, float *x, float *pD); +// void test_srowad_libsp(int kmax, int *idx, float alpha, float *x, float *pD); +// void test_blasfeo_srowad_sp(int kmax, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_smat *sD, int di, int dj); +// void test_srowadin_libsp(int kmax, int *idx, float alpha, float *x, float *y, float *pD); +// void test_srowsw_lib(int kmax, float *pA, float *pC); +// void test_blasfeo_srowsw(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// void test_blasfeo_srowpe(int kmax, int *ipiv, struct blasfeo_smat *sA); +// void test_scolin_lib(int kmax, float *x, int offset, float *pD, int sdd); +// void test_blasfeo_scolin(int kmax, struct blasfeo_svec *sx, int xi, struct blasfeo_smat *sA, int ai, int aj); +// void test_scolad_lib(int kmax, float alpha, float *x, int offset, float *pD, int sdd); +// void test_scolin_libsp(int kmax, int *idx, float *x, float *pD, int sdd); +// void test_scolad_libsp(int kmax, float alpha, int *idx, float *x, float *pD, int sdd); +// void test_scolsw_lib(int kmax, int offsetA, float *pA, int sda, int offsetC, float *pC, int sdc); +// void test_blasfeo_scolsw(int kmax, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sC, int ci, int cj); +// void test_blasfeo_scolpe(int kmax, int *ipiv, struct blasfeo_smat *sA); +// void test_svecin_libsp(int kmax, int *idx, float *x, float *y); +// void test_svecad_libsp(int kmax, int *idx, float alpha, float *x, float *y); +// void test_blasfeo_svecad_sp(int m, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_svec *sz, int zi); +// void test_blasfeo_svecin_sp(int m, float alpha, struct blasfeo_svec *sx, int xi, int *idx, struct blasfeo_svec *sz, int zi); +// void test_blasfeo_svecex_sp(int m, float alpha, int *idx, struct blasfeo_svec *sx, int x, struct blasfeo_svec *sz, int zi); +// void test_blasfeo_sveccl(int m, struct blasfeo_svec *sxm, int xim, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sxp, int xip, struct blasfeo_svec *sz, int zi); +// void test_blasfeo_sveccl_mask(int m, struct blasfeo_svec *sxm, int xim, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sxp, int xip, struct blasfeo_svec *sz, int zi, struct blasfeo_svec *sm, int mi); +// void test_blasfeo_svecze(int m, struct blasfeo_svec *sm, int mi, struct blasfeo_svec *sv, int vi, struct blasfeo_svec *se, int ei); +// void test_blasfeo_svecnrm_inf(int m, struct blasfeo_svec *sx, int xi, float *ptr_norm); +// void test_blasfeo_svecpe(int kmax, int *ipiv, struct blasfeo_svec *sx, int xi); + + +// ext_dep + +void test_blasfeo_allocate_smat(int m, int n, struct blasfeo_smat *sA); +void test_blasfeo_allocate_svec(int m, struct blasfeo_svec *sa); + +void test_blasfeo_free_smat(struct blasfeo_smat *sA); +void test_blasfeo_free_svec(struct blasfeo_svec *sa); + +void test_blasfeo_print_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj); +void test_blasfeo_print_svec(int m, struct blasfeo_svec *sa, int ai); +void test_blasfeo_print_tran_svec(int m, struct blasfeo_svec *sa, int ai); + +void test_blasfeo_print_to_file_smat(FILE *file, int m, int n, struct blasfeo_smat *sA, int ai, int aj); +void test_blasfeo_print_to_file_svec(FILE *file, int m, struct blasfeo_svec *sa, int ai); +void test_blasfeo_print_to_file_tran_svec(FILE *file, int m, struct blasfeo_svec *sa, int ai); + +void test_blasfeo_print_exp_smat(int m, int n, struct blasfeo_smat *sA, int ai, int aj); +void test_blasfeo_print_exp_svec(int m, struct blasfeo_svec *sa, int ai); +void test_blasfeo_print_exp_tran_svec(int m, struct blasfeo_svec *sa, int ai); + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_AUX_TEST_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_blas.h b/third_party/acados/include/blasfeo/include/blasfeo_s_blas.h new file mode 100644 index 00000000000000..200f1f51b1daac --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_blas.h @@ -0,0 +1,46 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_BLAS_H_ +#define BLASFEO_S_BLAS_H_ + + + +#include "blasfeo_s_blasfeo_api.h" +#include "blasfeo_s_blas_api.h" + + + +#endif // BLASFEO_S_BLAS_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_blas_api.h b/third_party/acados/include/blasfeo/include/blasfeo_s_blas_api.h new file mode 100644 index 00000000000000..d0fa2245c5f012 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_blas_api.h @@ -0,0 +1,117 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef BLASFEO_S_BLAS_API_H_ +#define BLASFEO_S_BLAS_API_H_ + + + +#include "blasfeo_target.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifdef BLAS_API + + + +#ifdef FORTRAN_BLAS_API + + + +// BLAS 1 +// +void saxpy_(int *n, float *alpha, float *x, int *incx, float *y, int *incy); +// +float sdot_(int *n, float *x, int *incx, float *y, int *incy); + +// BLAS 3 +// +void sgemm_(char *ta, char *tb, int *m, int *n, int *k, float *alpha, float *A, int *lda, float *B, int *ldb, float *beta, float *C, int *ldc); +// +void strsm_(char *side, char *uplo, char *transa, char *diag, int *m, int *n, float *alpha, float *A, int *lda, float *B, int *ldb); + + + +// LAPACK +// +void spotrf_(char *uplo, int *m, float *A, int *lda, int *info); + + + +#else // BLASFEO_API + + + +// BLAS 1 +// +void blas_saxpy(int *n, float *alpha, float *x, int *incx, float *y, int *incy); +// +float blas_sdot(int *n, float *x, int *incx, float *y, int *incy); + +// BLAS 3 +// +void blas_sgemm(char *ta, char *tb, int *m, int *n, int *k, float *alpha, float *A, int *lda, float *B, int *ldb, float *beta, float *C, int *ldc); +// +void blas_strsm(char *side, char *uplo, char *transa, char *diag, int *m, int *n, float *alpha, float *A, int *lda, float *B, int *ldb); + + + +// LAPACK +// +void blas_spotrf(char *uplo, int *m, float *A, int *lda, int *info); + + + +#endif // BLASFEO_API + + + +#endif // BLAS_API + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_BLAS_API_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_api.h b/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_api.h new file mode 100644 index 00000000000000..24b21ead25f9a5 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_api.h @@ -0,0 +1,272 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_BLASFEO_API_H_ +#define BLASFEO_S_BLASFEO_API_H_ + + + +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +// +// level 1 BLAS +// + +// z = y + alpha*x +void blasfeo_saxpy(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z = beta*y + alpha*x +void blasfeo_saxpby(int kmax, float alpha, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z = x .* y +void blasfeo_svecmul(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z += x .* y +void blasfeo_svecmulacc(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z = x .* y, return sum(z) = x^T * y +float blasfeo_svecmuldot(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// return x^T * y +float blasfeo_sdot(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi); +// construct givens plane rotation +void blasfeo_srotg(float a, float b, float *c, float *s); +// apply plane rotation [a b] [c -s; s; c] to the aj0 and aj1 columns of A at row index ai +void blasfeo_scolrot(int m, struct blasfeo_smat *sA, int ai, int aj0, int aj1, float c, float s); +// apply plane rotation [c s; -s c] [a; b] to the ai0 and ai1 rows of A at column index aj +void blasfeo_srowrot(int m, struct blasfeo_smat *sA, int ai0, int ai1, int aj, float c, float s); + + + +// +// level 2 BLAS +// + +// dense + +// z <= beta * y + alpha * A * x +void blasfeo_sgemv_n(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z <= beta * y + alpha * A' * x +void blasfeo_sgemv_t(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z <= inv( A ) * x, A (m)x(n) +void blasfeo_strsv_lnn_mn(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(n) +void blasfeo_strsv_ltn_mn(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, not_unit +void blasfeo_strsv_lnn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, unit +void blasfeo_strsv_lnu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) lower, transposed, not_unit +void blasfeo_strsv_ltn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) lower, transposed, unit +void blasfeo_strsv_ltu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) upper, not_transposed, not_unit +void blasfeo_strsv_unn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) upper, transposed, not_unit +void blasfeo_strsv_utn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A * x ; A lower triangular +void blasfeo_strmv_lnn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A * x ; A lower triangular, unit diagonal +void blasfeo_strmv_lnu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A' * x ; A lower triangular +void blasfeo_strmv_ltn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A' * x ; A lower triangular, unit diagonal +void blasfeo_strmv_ltu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= beta * y + alpha * A * x ; A upper triangular +void blasfeo_strmv_unn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A' * x ; A upper triangular +void blasfeo_strmv_utn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z_n <= beta_n * y_n + alpha_n * A * x_n +// z_t <= beta_t * y_t + alpha_t * A' * x_t +void blasfeo_sgemv_nt(int m, int n, float alpha_n, float alpha_t, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx_n, int xi_n, struct blasfeo_svec *sx_t, int xi_t, float beta_n, float beta_t, struct blasfeo_svec *sy_n, int yi_n, struct blasfeo_svec *sy_t, int yi_t, struct blasfeo_svec *sz_n, int zi_n, struct blasfeo_svec *sz_t, int zi_t); +// z <= beta * y + alpha * A * x, where A is symmetric and only the lower triangular patr of A is accessed +void blasfeo_ssymv_l(int m, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +void blasfeo_ssymv_l_mn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); + +// diagonal + +// z <= beta * y + alpha * A * x, A diagonal +void blasfeo_sgemv_d(int m, float alpha, struct blasfeo_svec *sA, int ai, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); + + + +// +// level 3 BLAS +// + +// dense + +// D <= beta * C + alpha * A * B +void blasfeo_sgemm_nn(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T +void blasfeo_sgemm_nt(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B +void blasfeo_sgemm_tn(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B +void blasfeo_sgemm_tt(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T ; C, D lower triangular +void blasfeo_ssyrk_ln(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ssyrk_ln_mn(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B ; C, D lower triangular +void blasfeo_ssyrk_lt(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T ; C, D upper triangular +void blasfeo_ssyrk_un(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B ; C, D upper triangular +void blasfeo_ssyrk_ut(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^T ; B upper triangular +void blasfeo_strmm_rutn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A ; A lower triangular +void blasfeo_strmm_rlnn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular employint explicit inverse of diagonal +void blasfeo_strsm_llnn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular with unit diagonal +void blasfeo_strsm_llnu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular employint explicit inverse of diagonal +void blasfeo_strsm_lltn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular with unit diagonal +void blasfeo_strsm_lltu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_strsm_lunn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular withunit diagonal +void blasfeo_strsm_lunu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_strsm_lutn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular withunit diagonal +void blasfeo_strsm_lutu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_strsm_rlnn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular with unit diagonal +void blasfeo_strsm_rlnu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_strsm_rltn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular with unit diagonal +void blasfeo_strsm_rltu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_strsm_runn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular with unit diagonal +void blasfeo_strsm_runu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_strsm_rutn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular with unit diagonal +void blasfeo_strsm_rutu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); + +// diagonal + +// D <= alpha * A * B + beta * C, with A diagonal (stored as strvec) +void sgemm_diag_left_ib(int m, int n, float alpha, float *dA, float *pB, int sdb, float beta, float *pC, int sdc, float *pD, int sdd); +void blasfeo_sgemm_dn(int m, int n, float alpha, struct blasfeo_svec *sA, int ai, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A * B + beta * C, with B diagonal (stored as strvec) +void blasfeo_sgemm_nd(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sB, int bi, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); + + + +// +// LAPACK +// + +// D <= chol( C ) ; C, D lower triangular +void blasfeo_spotrf_l(int m, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_spotrf_l_mn(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= chol( C ) ; C, D upper triangular +void blasfeo_spotrf_u(int m, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= chol( C + A * B' ) ; C, D lower triangular +void blasfeo_ssyrk_spotrf_ln(int m, int k, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ssyrk_spotrf_ln_mn(int m, int n, int k, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= lu( C ) ; no pivoting +void blasfeo_sgetrf_np(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= lu( C ) ; row pivoting +void blasfeo_sgetrf_rp(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, int *ipiv); +// D <= qr( C ) +void blasfeo_sgeqrf(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +int blasfeo_sgeqrf_worksize(int m, int n); // in bytes +// D <= Q factor, where C is the output of the LQ factorization +int blasfeo_sorglq_worksize(int m, int n, int k); // in bytes +void blasfeo_sorglq(int m, int n, int k, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +// D <= lq( C ) +void blasfeo_sgelqf(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +int blasfeo_sgelqf_worksize(int m, int n); // in bytes +// D <= lq( C ), positive diagonal elements +void blasfeo_sgelqf_pd(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +// [L, A] <= lq( [L, A] ), positive diagonal elements, array of matrices, with +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_sgelqf_pd_la(int m, int n1, struct blasfeo_smat *sL, int li, int lj, struct blasfeo_smat *sA, int ai, int aj, void *work); +// [L, L, A] <= lq( [L, L, A] ), positive diagonal elements, array of matrices, with: +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_sgelqf_pd_lla(int m, int n1, struct blasfeo_smat *sL0, int l0i, int l0j, struct blasfeo_smat *sL1, int l1i, int l1j, struct blasfeo_smat *sA, int ai, int aj, void *work); + + + + +// +// BLAS API helper functions +// + +#if ( defined(BLAS_API) & defined(MF_PANELMAJ) ) +// BLAS 3 +void blasfeo_cm_sgemm_nn(int m, int n, int k, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, float beta, struct blasfeo_cm_smat *sC, int ci, int cj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_sgemm_nt(int m, int n, int k, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, float beta, struct blasfeo_cm_smat *sC, int ci, int cj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_sgemm_tn(int m, int n, int k, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, float beta, struct blasfeo_cm_smat *sC, int ci, int cj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_sgemm_tt(int m, int n, int k, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, float beta, struct blasfeo_cm_smat *sC, int ci, int cj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_llnn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_llnu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_lltn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_lltu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_lunn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_lunu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_lutn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_lutu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_rlnn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_rlnu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_rltn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_rltu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_runn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_runu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_rutn(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_strsm_rutu(int m, int n, float alpha, struct blasfeo_cm_smat *sA, int ai, int aj, struct blasfeo_cm_smat *sB, int bi, int bj, struct blasfeo_cm_smat *sD, int di, int dj); +// LAPACK +void blasfeo_cm_spotrf_l(int m, struct blasfeo_cm_smat *sC, int ci, int cj, struct blasfeo_cm_smat *sD, int di, int dj); +void blasfeo_cm_spotrf_u(int m, struct blasfeo_cm_smat *sC, int ci, int cj, struct blasfeo_cm_smat *sD, int di, int dj); +#endif + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_BLASFEO_API_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_api_ref.h b/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_api_ref.h new file mode 100644 index 00000000000000..f429a79dc3f45d --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_api_ref.h @@ -0,0 +1,135 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_BLASFEO_API_REF_H_ +#define BLASFEO_S_BLASFEO_API_REF_H_ + +#include "blasfeo_common.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +// expose reference BLASFEO for testing + +// --- level 1 + +void blasfeo_saxpy_ref(int kmax, float alpha, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_saxpby_ref(int kmax, float alpha, struct blasfeo_svec_ref *sx, int xi, float beta, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_svecmul_ref(int m, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_svecmulacc_ref(int m, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); +float blasfeo_svecmuldot_ref(int m, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); +float blasfeo_sdot_ref(int m, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sy, int yi); +void blasfeo_srotg_ref(float a, float b, float *c, float *s); +void blasfeo_scolrot_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj0, int aj1, float c, float s); +void blasfeo_srowrot_ref(int m, struct blasfeo_smat_ref *sA, int ai0, int ai1, int aj, float c, float s); + + +// --- level 2 + +// dense +void blasfeo_sgemv_n_ref(int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, float beta, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_sgemv_t_ref(int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, float beta, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_lnn_mn_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_ltn_mn_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_lnn_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_lnu_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_ltn_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_ltu_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_unn_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strsv_utn_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strmv_unn_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strmv_utn_ref(int m, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strmv_lnn_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strmv_ltn_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strmv_lnu_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_strmv_ltu_ref(int m, int n, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, struct blasfeo_svec_ref *sz, int zi); +void blasfeo_sgemv_nt_ref(int m, int n, float alpha_n, float alpha_t, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx_n, int xi_n, struct blasfeo_svec_ref *sx_t, int xi_t, float beta_n, float beta_t, struct blasfeo_svec_ref *sy_n, int yi_n, struct blasfeo_svec_ref *sy_t, int yi_t, struct blasfeo_svec_ref *sz_n, int zi_n, struct blasfeo_svec_ref *sz_t, int zi_t); +void blasfeo_ssymv_l_ref(int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sx, int xi, float beta, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); + +// diagonal +void blasfeo_sgemv_d_ref(int m, float alpha, struct blasfeo_svec_ref *sA, int ai, struct blasfeo_svec_ref *sx, int xi, float beta, struct blasfeo_svec_ref *sy, int yi, struct blasfeo_svec_ref *sz, int zi); + + +// --- level 3 + +// dense +void blasfeo_sgemm_nn_ref( int m, int n, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_sgemm_nt_ref( int m, int n, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_sgemm_tn_ref(int m, int n, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_sgemm_tt_ref(int m, int n, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); + +void blasfeo_ssyrk_ln_mn_ref( int m, int n, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_ssyrk_ln_ref( int m, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_ssyrk_lt_ref( int m, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_ssyrk_un_ref( int m, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_ssyrk_ut_ref( int m, int k, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); + +void blasfeo_strmm_rutn_ref( int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_strmm_rlnn_ref( int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_strsm_rltn_ref( int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_strsm_rltu_ref( int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_strsm_rutn_ref( int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_strsm_llnu_ref( int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_strsm_lunn_ref( int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sD, int di, int dj); + +// diagonal +void dgemm_diag_left_lib_ref(int m, int n, float alpha, float *dA, float *pB, int sdb, float beta, float *pC, int sdc, float *pD, int sdd); +void blasfeo_sgemm_dn_ref(int m, int n, float alpha, struct blasfeo_svec_ref *sA, int ai, struct blasfeo_smat_ref *sB, int bi, int bj, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_sgemm_nd_ref(int m, int n, float alpha, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_svec_ref *sB, int bi, float beta, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); + +// --- lapack + +void blasfeo_sgetrf_nopivot_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_sgetrf_rowpivot_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj, int *ipiv); +void blasfeo_spotrf_l_ref(int m, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_spotrf_l_mn_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_ssyrk_dpotrf_ln_ref(int m, int k, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_ssyrk_dpotrf_ln_mn_ref(int m, int n, int k, struct blasfeo_smat_ref *sA, int ai, int aj, struct blasfeo_smat_ref *sB, int bi, int bj, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_sgetrf_nopivot_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj); +void blasfeo_sgetrf_rowpivot_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj, int *ipiv); +void blasfeo_sgeqrf_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj, void *work); +void blasfeo_sgelqf_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj, void *work); +void blasfeo_sgelqf_pd_ref(int m, int n, struct blasfeo_smat_ref *sC, int ci, int cj, struct blasfeo_smat_ref *sD, int di, int dj, void *work); +void blasfeo_sgelqf_pd_la_ref(int m, int n1, struct blasfeo_smat_ref *sL, int li, int lj, struct blasfeo_smat_ref *sA, int ai, int aj, void *work); +void blasfeo_sgelqf_pd_lla_ref(int m, int n1, struct blasfeo_smat_ref *sL0, int l0i, int l0j, struct blasfeo_smat_ref *sL1, int l1i, int l1j, struct blasfeo_smat_ref *sA, int ai, int aj, void *work); + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_BLASFEO_API_REF_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_ref_api.h b/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_ref_api.h new file mode 100644 index 00000000000000..805914cc05ef23 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_blasfeo_ref_api.h @@ -0,0 +1,240 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_BLASFEO_REF_API_H_ +#define BLASFEO_S_BLASFEO_REF_API_H_ + + + +#include "blasfeo_common.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +// +// level 1 BLAS +// + +// z = y + alpha*x +void blasfeo_ref_saxpy(int kmax, float alpha, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z = beta*y + alpha*x +void blasfeo_ref_saxpby(int kmax, float alpha, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z = x .* y +void blasfeo_ref_svecmul(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z += x .* y +void blasfeo_ref_svecmulacc(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z = x .* y, return sum(z) = x^T * y +float blasfeo_ref_svecmuldot(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// return x^T * y +float blasfeo_ref_sdot(int m, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sy, int yi); +// construct givens plane rotation +void blasfeo_ref_srotg(float a, float b, float *c, float *s); +// apply plane rotation [a b] [c -s; s; c] to the aj0 and aj1 columns of A at row index ai +void blasfeo_ref_scolrot(int m, struct blasfeo_smat *sA, int ai, int aj0, int aj1, float c, float s); +// apply plane rotation [c s; -s c] [a; b] to the ai0 and ai1 rows of A at column index aj +void blasfeo_ref_srowrot(int m, struct blasfeo_smat *sA, int ai0, int ai1, int aj, float c, float s); + + + +// +// level 2 BLAS +// + +// dense + +// z <= beta * y + alpha * A * x +void blasfeo_ref_sgemv_n(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z <= beta * y + alpha * A' * x +void blasfeo_ref_sgemv_t(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +// z <= inv( A ) * x, A (m)x(n) +void blasfeo_ref_strsv_lnn_mn(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(n) +void blasfeo_ref_strsv_ltn_mn(int m, int n, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, not_unit +void blasfeo_ref_strsv_lnn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A ) * x, A (m)x(m) lower, not_transposed, unit +void blasfeo_ref_strsv_lnu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) lower, transposed, not_unit +void blasfeo_ref_strsv_ltn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) lower, transposed, unit +void blasfeo_ref_strsv_ltu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) upper, not_transposed, not_unit +void blasfeo_ref_strsv_unn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= inv( A' ) * x, A (m)x(m) upper, transposed, not_unit +void blasfeo_ref_strsv_utn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A * x ; A lower triangular +void blasfeo_ref_strmv_lnn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A * x ; A lower triangular, unit diagonal +void blasfeo_ref_strmv_lnu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A' * x ; A lower triangular +void blasfeo_ref_strmv_ltn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A' * x ; A lower triangular, unit diagonal +void blasfeo_ref_strmv_ltu(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= beta * y + alpha * A * x ; A upper triangular +void blasfeo_ref_strmv_unn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z <= A' * x ; A upper triangular +void blasfeo_ref_strmv_utn(int m, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, struct blasfeo_svec *sz, int zi); +// z_n <= beta_n * y_n + alpha_n * A * x_n +// z_t <= beta_t * y_t + alpha_t * A' * x_t +void blasfeo_ref_sgemv_nt(int m, int n, float alpha_n, float alpha_t, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx_n, int xi_n, struct blasfeo_svec *sx_t, int xi_t, float beta_n, float beta_t, struct blasfeo_svec *sy_n, int yi_n, struct blasfeo_svec *sy_t, int yi_t, struct blasfeo_svec *sz_n, int zi_n, struct blasfeo_svec *sz_t, int zi_t); +// z <= beta * y + alpha * A * x, where A is symmetric and only the lower triangular patr of A is accessed +void blasfeo_ref_ssymv_l(int m, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); +void blasfeo_ref_ssymv_l_mn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); + +// diagonal + +// z <= beta * y + alpha * A * x, A diagonal +void blasfeo_ref_sgemv_d(int m, float alpha, struct blasfeo_svec *sA, int ai, struct blasfeo_svec *sx, int xi, float beta, struct blasfeo_svec *sy, int yi, struct blasfeo_svec *sz, int zi); + + + +// +// level 3 BLAS +// + +// dense + +// D <= beta * C + alpha * A * B +void blasfeo_ref_sgemm_nn(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T +void blasfeo_ref_sgemm_nt(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B +void blasfeo_ref_sgemm_tn(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B +void blasfeo_ref_sgemm_tt(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T ; C, D lower triangular +void blasfeo_ref_ssyrk_ln(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ref_ssyrk_ln_mn(int m, int n, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B ; C, D lower triangular +void blasfeo_ref_ssyrk_lt(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A * B^T ; C, D upper triangular +void blasfeo_ref_ssyrk_un(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= beta * C + alpha * A^T * B ; C, D upper triangular +void blasfeo_ref_ssyrk_ut(int m, int k, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^T ; B upper triangular +void blasfeo_ref_strmm_rutn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A ; A lower triangular +void blasfeo_ref_strmm_rlnn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular employint explicit inverse of diagonal +void blasfeo_ref_strsm_llnn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A lower triangular with unit diagonal +void blasfeo_ref_strsm_llnu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular employint explicit inverse of diagonal +void blasfeo_ref_strsm_lltn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A lower triangular with unit diagonal +void blasfeo_ref_strsm_lltu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_strsm_lunn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-1} * B , with A upper triangular withunit diagonal +void blasfeo_ref_strsm_lunu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_strsm_lutn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A^{-T} * B , with A upper triangular withunit diagonal +void blasfeo_ref_strsm_lutu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_ref_strsm_rlnn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A lower triangular with unit diagonal +void blasfeo_ref_strsm_rlnu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular employing explicit inverse of diagonal +void blasfeo_ref_strsm_rltn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A lower triangular with unit diagonal +void blasfeo_ref_strsm_rltu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_strsm_runn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-1} , with A upper triangular with unit diagonal +void blasfeo_ref_strsm_runu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular employing explicit inverse of diagonal +void blasfeo_ref_strsm_rutn(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * B * A^{-T} , with A upper triangular with unit diagonal +void blasfeo_ref_strsm_rutu(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sD, int di, int dj); + +// diagonal + +// D <= alpha * A * B + beta * C, with A diagonal (stored as strvec) +void sgemm_diag_left_ib(int m, int n, float alpha, float *dA, float *pB, int sdb, float beta, float *pC, int sdc, float *pD, int sdd); +void blasfeo_ref_sgemm_dn(int m, int n, float alpha, struct blasfeo_svec *sA, int ai, struct blasfeo_smat *sB, int bi, int bj, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= alpha * A * B + beta * C, with B diagonal (stored as strvec) +void blasfeo_ref_sgemm_nd(int m, int n, float alpha, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_svec *sB, int bi, float beta, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); + + + +// +// LAPACK +// + +// D <= chol( C ) ; C, D lower triangular +void blasfeo_ref_spotrf_l(int m, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ref_spotrf_l_mn(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= chol( C ) ; C, D upper triangular +void blasfeo_ref_spotrf_u(int m, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= chol( C + A * B' ) ; C, D lower triangular +void blasfeo_ref_ssyrk_spotrf_ln(int m, int k, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +void blasfeo_ref_ssyrk_spotrf_ln_mn(int m, int n, int k, struct blasfeo_smat *sA, int ai, int aj, struct blasfeo_smat *sB, int bi, int bj, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= lu( C ) ; no pivoting +void blasfeo_ref_sgetrf_np(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj); +// D <= lu( C ) ; row pivoting +void blasfeo_ref_sgetrf_rp(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, int *ipiv); +// D <= qr( C ) +void blasfeo_ref_sgeqrf(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +int blasfeo_ref_sgeqrf_worksize(int m, int n); // in bytes +// D <= Q factor, where C is the output of the LQ factorization +int blasfeo_ref_sorglq_worksize(int m, int n, int k); // in bytes +void blasfeo_ref_sorglq(int m, int n, int k, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +// D <= lq( C ) +void blasfeo_ref_sgelqf(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +int blasfeo_ref_sgelqf_worksize(int m, int n); // in bytes +// D <= lq( C ), positive diagonal elements +void blasfeo_ref_sgelqf_pd(int m, int n, struct blasfeo_smat *sC, int ci, int cj, struct blasfeo_smat *sD, int di, int dj, void *work); +// [L, A] <= lq( [L, A] ), positive diagonal elements, array of matrices, with +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_ref_sgelqf_pd_la(int m, int n1, struct blasfeo_smat *sL, int li, int lj, struct blasfeo_smat *sA, int ai, int aj, void *work); +// [L, L, A] <= lq( [L, L, A] ), positive diagonal elements, array of matrices, with: +// L lower triangular, of size (m)x(m) +// A full, of size (m)x(n1) +void blasfeo_ref_sgelqf_pd_lla(int m, int n1, struct blasfeo_smat *sL0, int l0i, int l0j, struct blasfeo_smat *sL1, int l1i, int l1j, struct blasfeo_smat *sA, int ai, int aj, void *work); + + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_BLASFEO_REF_API_H_ + diff --git a/third_party/acados/include/blasfeo/include/blasfeo_s_kernel.h b/third_party/acados/include/blasfeo/include/blasfeo_s_kernel.h new file mode 100644 index 00000000000000..99d2b28c823d57 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_s_kernel.h @@ -0,0 +1,692 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_S_KERNEL_H_ +#define BLASFEO_S_KERNEL_H_ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// utils +void blasfeo_align_2MB(void *ptr, void **ptr_align); +void blasfeo_align_4096_byte(void *ptr, void **ptr_align); +void blasfeo_align_64_byte(void *ptr, void **ptr_align); + + + +// +// lib8 +// + +// 24x4 +void kernel_sgemm_nt_24x4_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_nt_24x4_vs_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_sgemm_nt_24x4_gen_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_sgemm_nn_24x4_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_nn_24x4_vs_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_sgemm_nn_24x4_gen_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_ssyrk_nt_l_24x4_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_ssyrk_nt_l_24x4_vs_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_ssyrk_nt_l_20x4_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_ssyrk_nt_l_20x4_vs_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_spotrf_nt_l_24x4_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_spotrf_nt_l_24x4_vs_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_spotrf_nt_l_20x4_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_spotrf_nt_l_20x4_vs_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_strsm_nt_rl_inv_24x4_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_24x4_vs_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E, int km, int kn); +void kernel_sgemm_strsm_nt_rl_inv_24x4_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E); +void kernel_sgemm_strsm_nt_rl_inv_24x4_vs_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_20x4_vs_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_20x4_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_ssyrk_spotrf_nt_l_24x4_vs_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_24x4_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_strmm_nn_rl_24x4_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *D, int sdd); +void kernel_strmm_nn_rl_24x4_vs_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *D, int sdd, int km, int kn); + +// 16x8 +void kernel_sgemm_nt_16x8_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, float *spil); + +// 16x4 +void kernel_sgemm_nt_16x4_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_nt_16x4_vs_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_sgemm_nt_16x4_gen_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_sgemm_nn_16x4_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_nn_16x4_vs_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_sgemm_nn_16x4_gen_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_ssyrk_nt_l_16x4_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_ssyrk_nt_l_16x4_vs_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_ssyrk_nt_l_12x4_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_ssyrk_nt_l_12x4_vs_lib8(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); +void kernel_spotrf_nt_l_16x4_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_spotrf_nt_l_16x4_vs_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_spotrf_nt_l_12x4_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_spotrf_nt_l_12x4_vs_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_strsm_nt_rl_inv_16x4_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_16x4_vs_lib8(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E, int km, int kn); +void kernel_sgemm_strsm_nt_rl_inv_16x4_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E); +void kernel_sgemm_strsm_nt_rl_inv_16x4_vs_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_12x4_vs_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_12x4_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_ssyrk_spotrf_nt_l_16x4_vs_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_16x4_lib8(int kp, float *Ap, int sdap, float *Bp, int km_, float *Am, int sdam, float *Bm, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_strmm_nn_rl_16x4_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *D, int sdd); +void kernel_strmm_nn_rl_16x4_vs_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *D, int sdd, int km, int kn); +void kernel_strmm_nn_rl_16x4_gen_lib8(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); + +// 8x8 +void kernel_sgemm_nt_8x8_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_sgemm_nt_8x8_vs_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn); +void kernel_sgemm_nt_8x8_gen_lib8(int k, float *alpha, float *A, float *B, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_sgemm_nn_8x8_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D); +void kernel_sgemm_nn_8x8_vs_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D, int km, int kn); +void kernel_sgemm_nn_8x8_gen_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_ssyrk_nt_l_8x8_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_ssyrk_nt_l_8x8_vs_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn); +void kernel_spotrf_nt_l_8x8_lib8(int k, float *A, float *B, float *C, float *D, float *inv_diag_D); +void kernel_spotrf_nt_l_8x8_vs_lib8(int k, float *A, float *B, float *C, float *D, float *inv_diag_D, int km, int kn); +void kernel_strsm_nt_rl_inv_8x8_lib8(int k, float *A, float *B, float *C, float *D, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_8x8_vs_lib8(int k, float *A, float *B, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_sgemm_strsm_nt_rl_inv_8x8_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E); +void kernel_sgemm_strsm_nt_rl_inv_8x8_vs_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_8x8_vs_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_8x8_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D); + +// 8x4 +void kernel_sgemm_nt_8x4_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_sgemm_nt_8x4_vs_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn); +void kernel_sgemm_nt_8x4_gen_lib8(int k, float *alpha, float *A, float *B, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_sgemm_nn_8x4_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D); +void kernel_sgemm_nn_8x4_vs_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D, int km, int kn); +void kernel_sgemm_nn_8x4_gen_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +//void kernel_ssyrk_nt_l_8x4_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_ssyrk_nt_l_8x4_vs_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn); +void kernel_spotrf_nt_l_8x4_lib8(int k, float *A, float *B, float *C, float *D, float *inv_diag_D); +void kernel_spotrf_nt_l_8x4_vs_lib8(int k, float *A, float *B, float *C, float *D, float *inv_diag_D, int km, int kn); +void kernel_strsm_nt_rl_inv_8x4_lib8(int k, float *A, float *B, float *C, float *D, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_8x4_vs_lib8(int k, float *A, float *B, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_sgemm_strsm_nt_rl_inv_8x4_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E); +void kernel_sgemm_strsm_nt_rl_inv_8x4_vs_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_8x4_vs_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_8x4_lib8(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D); +void kernel_strmm_nn_rl_8x4_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *D); +void kernel_strmm_nn_rl_8x4_vs_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *D, int km, int kn); +void kernel_strmm_nn_rl_8x4_gen_lib8(int k, float *alpha, float *A, int offsetB, float *B, int sdb, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_strmm_nt_ru_8x4_lib8(int k, float *alpha, float *A, float *B, float *D); +void kernel_strmm_nt_ru_8x4_vs_lib8(int k, float *alpha, float *A, float *B, float *D, int km, int kn); + +// 4x8 +void kernel_sgemm_nt_4x8_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_sgemm_nt_4x8_vs_lib8(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn); +void kernel_sgemm_nt_4x8_gen_lib8(int k, float *alpha, float *A, float *B, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_strsm_nt_rl_inv_4x8_lib8(int k, float *A, float *B, float *C, float *D, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_4x8_vs_lib8(int k, float *A, float *B, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); + +// 8 +void kernel_sgemv_n_8_lib8(int k, float *alpha, float *A, float *x, float *beta, float *y, float *z); +void kernel_sgemv_n_8_vs_lib8(int k, float *alpha, float *A, float *x, float *beta, float *y, float *z, int k1); +void kernel_sgemv_n_8_gen_lib8(int kmax, float *alpha, float *A, float *x, float *beta, float *y, float *z, int k0, int k1); +void kernel_sgemv_t_8_lib8(int k, float *alpha, int offsetA, float *A, int sda, float *x, float *beta, float *y, float *z); +void kernel_sgemv_t_8_vs_lib8(int k, float *alpha, int offsetA, float *A, int sda, float *x, float *beta, float *y, float *z, int k1); +void kernel_sgemv_t_4_lib8(int k, float *alpha, int offsetA, float *A, int sda, float *x, float *beta, float *y, float *z); +void kernel_sgemv_t_4_vs_lib8(int k, float *alpha, int offsetA, float *A, int sda, float *x, float *beta, float *y, float *z, int k1); +void kernel_strsv_ln_inv_8_lib8(int k, float *A, float *inv_diag_A, float *x, float *y, float *z); +void kernel_strsv_ln_inv_8_vs_lib8(int k, float *A, float *inv_diag_A, float *x, float *y, float *z, int km, int kn); +void kernel_strsv_lt_inv_8_lib8(int k, float *A, int sda, float *inv_diag_A, float *x, float *y, float *z); +void kernel_strsv_lt_inv_8_vs_lib8(int k, float *A, int sda, float *inv_diag_A, float *x, float *y, float *z, int km, int kn); +void kernel_sgemv_nt_4_lib8(int kmax, float *alpha_n, float *alpha_t, float *A, int sda, float *x_n, float *x_t, float *beta_t, float *y_t, float *z_n, float *z_t); +void kernel_sgemv_nt_4_vs_lib8(int kmax, float *alpha_n, float *alpha_t, float *A, int sda, float *x_n, float *x_t, float *beta_t, float *y_t, float *z_n, float *z_t, int km); +void kernel_ssymv_l_4l_lib8(int kmax, float *alpha, float *A, int sda, float *x, float *z); +void kernel_ssymv_l_4r_lib8(int kmax, float *alpha, float *A, int sda, float *x, float *z); +void kernel_ssymv_l_4l_gen_lib8(int kmax, float *alpha, int offA, float *A, int sda, float *x, float *z, int km); +void kernel_ssymv_l_4r_gen_lib8(int kmax, float *alpha, int offA, float *A, int sda, float *x, float *z, int km); + +// -------- aux + +// ---- copy + +// lib4 +// +void kernel_sgecpsc_4_0_lib4(int kmax, float *alpha, float *A, float *B); +void kernel_sgecp_4_0_lib4(int kmax, float *A, float *B); + +void kernel_sgecpsc_4_1_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgecp_4_1_lib4(int kmax, float *A0, int sda, float *B); +void kernel_sgecpsc_4_2_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgecp_4_2_lib4(int kmax, float *A0, int sda, float *B); +void kernel_sgecpsc_4_3_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgecp_4_3_lib4(int kmax, float *A0, int sda, float *B); + +void kernel_sgecpsc_3_0_lib4(int kmax, float *alpha, float *A, float *B); +void kernel_sgecp_3_0_lib4(int kmax, float *A, float *B); +void kernel_sgecpsc_3_2_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgecp_3_2_lib4(int kmax, float *A0, int sda, float *B); +void kernel_sgecpsc_3_3_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgecp_3_3_lib4(int kmax, float *A0, int sda, float *B); + +void kernel_sgecpsc_2_0_lib4(int kmax, float *alpha, float *A, float *B); +void kernel_sgecp_2_0_lib4(int kmax, float *A, float *B); +void kernel_sgecpsc_2_3_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgecp_2_3_lib4(int kmax, float *A0, int sda, float *B); + +void kernel_sgecpsc_1_0_lib4(int kmax, float *alpha, float *A, float *B); +void kernel_sgecp_1_0_lib4(int kmax, float *A, float *B); + +// lib8 +// +void kernel_sgecp_8_0_lib8(int m, float *A, float *B); +void kernel_sgecp_8_0_gen_lib8(int m, float *A, float *B, int m1); +void kernel_sgecp_8_0_gen_u_lib8(int m, float *A, float *B, int m1); + +void kernel_sgesc_8_0_lib8(int m, float *alpha, float *A); +void kernel_sgesc_8_0_gen_lib8(int m, float *alpha, float *A, int m1); +void kernel_sgesc_8_0_gen_u_lib8(int m, float *alpha, float *A, int m1); + +void kernel_sgecpsc_8_0_lib8(int m, float *alpha, float *A, float *B); +void kernel_sgecpsc_8_0_gen_lib8(int m, float *alpha, float *A, float *B, int m1); +void kernel_sgecpsc_8_0_gen_u_lib8(int m, float *alpha, float *A, float *B, int m1); + +void kernel_sgecp_8_1_lib8(int m, float *A, int sda, float *B); +void kernel_sgecp_8_1_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgecpsc_8_1_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgecpsc_8_1_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + +void kernel_sgecp_8_2_lib8(int m, float *A, int sda, float *B); +void kernel_sgecp_8_2_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgecpsc_8_2_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgecpsc_8_2_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + +void kernel_sgecp_8_3_lib8(int m, float *A, int sda, float *B); +void kernel_sgecp_8_3_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgecpsc_8_3_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgecpsc_8_3_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + +void kernel_sgecp_8_4_lib8(int m, float *A, int sda, float *B); +void kernel_sgecp_8_4_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgecpsc_8_4_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgecpsc_8_4_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + +void kernel_sgecp_8_5_lib8(int m, float *A, int sda, float *B); +void kernel_sgecp_8_5_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgecpsc_8_5_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgecpsc_8_5_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + +void kernel_sgecp_8_6_lib8(int m, float *A, int sda, float *B); +void kernel_sgecp_8_6_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgecpsc_8_6_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgecpsc_8_6_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + +void kernel_sgecp_8_7_lib8(int m, float *A, int sda, float *B); +void kernel_sgecp_8_7_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgecpsc_8_7_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgecpsc_8_7_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + +// transpose +// +void kernel_sgetr_8_0_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_0_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgetr_8_1_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_1_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgetr_8_2_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_2_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgetr_8_3_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_3_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgetr_8_4_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_4_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgetr_8_5_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_5_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgetr_8_6_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_6_gen_lib8(int m, float *A, int sda, float *B, int m1); +void kernel_sgetr_8_7_lib8(int m, float *A, int sda, float *B); +void kernel_sgetr_8_7_gen_lib8(int m, float *A, int sda, float *B, int m1); + +// add +// +void kernel_sgead_8_0_lib8(int m, float *alpha, float *A, float *B); +void kernel_sgead_8_0_gen_lib8(int m, float *alpha, float *A, float *B, int m1); +void kernel_sgead_8_1_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgead_8_1_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); +void kernel_sgead_8_2_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgead_8_2_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); +void kernel_sgead_8_3_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgead_8_3_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); +void kernel_sgead_8_4_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgead_8_4_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); +void kernel_sgead_8_5_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgead_8_5_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); +void kernel_sgead_8_6_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgead_8_6_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); +void kernel_sgead_8_7_lib8(int m, float *alpha, float *A, int sda, float *B); +void kernel_sgead_8_7_gen_lib8(int m, float *alpha, float *A, int sda, float *B, int m1); + + +// +// lib4 +// + + + +// level 2 BLAS +// 4 +void kernel_sgemv_n_4_lib4(int k, float *alpha, float *A, float *x, float *beta, float *y, float *z); +void kernel_sgemv_n_4_vs_lib4(int k, float *alpha, float *A, float *x, float *beta, float *y, float *z, int k1); +void kernel_sgemv_n_4_gen_lib4(int kmax, float *alpha, float *A, float *x, float *beta, float *y, float *z, int k0, int k1); +void kernel_sgemv_t_4_lib4(int k, float *alpha, int offsetA, float *A, int sda, float *x, float *beta, float *y, float *z); +void kernel_sgemv_t_4_vs_lib4(int k, float *alpha, int offsetA, float *A, int sda, float *x, float *beta, float *y, float *z, int k1); +void kernel_strsv_ln_inv_4_lib4(int k, float *A, float *inv_diag_A, float *x, float *y, float *z); +void kernel_strsv_ln_inv_4_vs_lib4(int k, float *A, float *inv_diag_A, float *x, float *y, float *z, int km, int kn); +void kernel_strsv_lt_inv_4_lib4(int k, float *A, int sda, float *inv_diag_A, float *x, float *y, float *z); +void kernel_strsv_lt_inv_3_lib4(int k, float *A, int sda, float *inv_diag_A, float *x, float *y, float *z); +void kernel_strsv_lt_inv_2_lib4(int k, float *A, int sda, float *inv_diag_A, float *x, float *y, float *z); +void kernel_strsv_lt_inv_1_lib4(int k, float *A, int sda, float *inv_diag_A, float *x, float *y, float *z); +void kernel_strmv_un_4_lib4(int k, float *A, float *x, float *z); +void kernel_strmv_ut_4_lib4(int k, float *A, int sda, float *x, float *z); +void kernel_strmv_ut_4_vs_lib4(int k, float *A, int sda, float *x, float *z, int km); +void kernel_sgemv_nt_6_lib4(int kmax, float *alpha_n, float *alpha_t, float *A, int sda, float *x_n, float *x_t, float *beta_t, float *y_t, float *z_n, float *z_t); +void kernel_sgemv_nt_4_lib4(int kmax, float *alpha_n, float *alpha_t, float *A, int sda, float *x_n, float *x_t, float *beta_t, float *y_t, float *z_n, float *z_t); +void kernel_sgemv_nt_4_vs_lib4(int kmax, float *alpha_n, float *alpha_t, float *A, int sda, float *x_n, float *x_t, float *beta_t, float *y_t, float *z_n, float *z_t, int km); +void kernel_ssymv_l_4_lib4(int kmax, float *alpha, float *A, int sda, float *x_n, float *z_n); +void kernel_ssymv_l_4_gen_lib4(int kmax, float *alpha, int offA, float *A, int sda, float *x_n, float *z_n, int km); + + + +// level 3 BLAS +// 12x4 +void kernel_sgemm_nt_16x4_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); // +void kernel_sgemm_nt_16x4_vs_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int m1, int n1); // +void kernel_strsm_nt_rl_inv_16x4_lib4(int k, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_16x4_vs_lib4(int k, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E, int m1, int n1); +// 12x4 +void kernel_sgemm_nt_12x4_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); // +void kernel_sgemm_nt_12x4_vs_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int m1, int n1); // +void kernel_strsm_nt_rl_inv_12x4_lib4(int k, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_12x4_vs_lib4(int k, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E, int m1, int n1); +// 8x8 +void kernel_sgemm_nt_8x8_lib4(int k, float *alpha, float *A, int sda, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd); // +void kernel_sgemm_nt_8x8_vs_lib4(int k, float *alpha, float *A, int sda, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd, int m1, int n1); // +void kernel_sgemm_nn_8x8_lib4(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd); // +void kernel_sgemm_nn_8x8_vs_lib4(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd, int m1, int n1); // +// 8x4 +void kernel_sgemm_nt_8x4_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); // +void kernel_sgemm_nt_8x4_vs_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int m1, int n1); // +void kernel_sgemm_nn_8x4_lib4(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd); // +void kernel_sgemm_nn_8x4_vs_lib4(int k, float *alpha, float *A, int sda, int offsetB, float *B, int sdb, float *beta, float *C, int sdc, float *D, int sdd, int m1, int n1); // +void kernel_ssyrk_nt_l_8x4_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); // +void kernel_ssyrk_nt_l_8x4_vs_lib4(int k, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, int km, int kn); // +void kernel_strsm_nt_rl_inv_8x4_lib4(int k, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_8x4_vs_lib4(int k, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd, float *E, float *inv_diag_E, int m1, int n1); +// 4x4 +void kernel_sgemm_nt_4x4_lib4(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D); // +void kernel_sgemm_nt_4x4_vs_lib4(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn); // +void kernel_sgemm_nt_4x4_gen_lib4(int k, float *alpha, float *A, float *B, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int k0, int k1); +void kernel_sgemm_nn_4x4_lib4(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D); // +void kernel_sgemm_nn_4x4_vs_lib4(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D, int km, int kn); // +void kernel_sgemm_nn_4x4_gen_lib4(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); // +void kernel_ssyrk_nt_l_4x4_lib4(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D); // +void kernel_ssyrk_nt_l_4x4_vs_lib4(int k, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn); // +void kernel_ssyrk_nt_l_4x4_gen_lib4(int k, float *alpha, float *A, float *B, float *beta, int offsetC, float *C, int sdc, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_strmm_nt_ru_4x4_lib4(int k, float *alpha, float *A, float *B, float *D); // +void kernel_strmm_nt_ru_4x4_vs_lib4(int k, float *alpha, float *A, float *B, float *D, int km, int kn); // +void kernel_strmm_nn_rl_4x4_lib4(int k, float *alpha, float *A, int offsetB, float *B, int sdb, float *D); +void kernel_strmm_nn_rl_4x4_gen_lib4(int k, float *alpha, float *A, int offsetB, float *B, int sdb, int offsetD, float *D, int sdd, int m0, int m1, int n0, int n1); +void kernel_strsm_nt_rl_inv_4x4_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E); +void kernel_strsm_nt_rl_inv_4x4_vs_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_strsm_nt_rl_one_4x4_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E); +void kernel_strsm_nt_rl_one_4x4_vs_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E, int km, int kn); +void kernel_strsm_nt_ru_inv_4x4_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E); +void kernel_strsm_nt_ru_inv_4x4_vs_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_strsm_nt_ru_one_4x4_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E); +void kernel_strsm_nt_ru_one_4x4_vs_lib4(int k, float *A, float *B, float *beta, float *C, float *D, float *E, int km, int kn); +void kernel_strsm_nn_ru_inv_4x4_lib4(int k, float *A, float *B, int sdb, float *beta, float *C, float *D, float *E, float *inv_diag_E); +void kernel_strsm_nn_ru_inv_4x4_vs_lib4(int k, float *A, float *B, int sdb, float *beta, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_strsm_nn_ll_one_4x4_lib4(int k, float *A, float *B, int sdb, float *C, float *D, float *E); +void kernel_strsm_nn_ll_one_4x4_vs_lib4(int k, float *A, float *B, int sdb, float *C, float *D, float *E, int km, int kn); +void kernel_strsm_nn_lu_inv_4x4_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *E, float *inv_diag_E); +void kernel_strsm_nn_lu_inv_4x4_vs_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +// diag +void kernel_sgemm_diag_right_4_a0_lib4(int kmax, float *alpha, float *A, int sda, float *B, float *D, int sdd); +void kernel_sgemm_diag_right_4_lib4(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_diag_right_3_lib4(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_diag_right_2_lib4(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_diag_right_1_lib4(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int sdc, float *D, int sdd); +void kernel_sgemm_diag_left_4_a0_lib4(int kmax, float *alpha, float *A, float *B, float *D); +void kernel_sgemm_diag_left_4_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_sgemm_diag_left_3_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_sgemm_diag_left_2_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D); +void kernel_sgemm_diag_left_1_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D); + + + +// LAPACK +// 16x4 +void kernel_spotrf_nt_l_16x4_lib4(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_spotrf_nt_l_16x4_vs_lib4(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int m1, int n1); +// 12x4 +void kernel_spotrf_nt_l_12x4_lib4(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_spotrf_nt_l_12x4_vs_lib4(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int m1, int n1); +// 8x4 +void kernel_spotrf_nt_l_8x4_lib4(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D); +void kernel_spotrf_nt_l_8x4_vs_lib4(int k, float *A, int sda, float *B, float *C, int sdc, float *D, int sdd, float *inv_diag_D, int m1, int n1); +// 4x4 +void kernel_spotrf_nt_l_4x4_lib4(int k, float *A, float *B, float *C, float *D, float *inv_diag_D); +void kernel_spotrf_nt_l_4x4_vs_lib4(int k, float *A, float *B, float *C, float *D, float *inv_diag_D, int km, int kn); +void kernel_sgetrf_nn_4x4_lib4(int k, float *A, float *B, int sdb, float *C, float *D, float *inv_diag_D); +void kernel_sgetrf_nn_4x4_vs_lib4(int k, float *A, float *B, int sdb, float *C, float *D, float *inv_diag_D, int km, int kn); +void kernel_sgetrf_pivot_4_lib4(int m, float *pA, int sda, float *inv_diag_A, int* ipiv); +void kernel_sgetrf_pivot_4_vs_lib4(int m, int n, float *pA, int sda, float *inv_diag_A, int* ipiv); + + + +// merged routines +// 4x4 +void kernel_sgemm_strsm_nt_rl_inv_4x4_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E); +void kernel_sgemm_strsm_nt_rl_inv_4x4_vs_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_4x4_vs_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D, int km, int kn); +void kernel_ssyrk_spotrf_nt_l_4x4_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D); + + + +// auxiliary routines +void kernel_strcp_l_4_0_lib4(int kmax, float *A, float *B); +void kernel_strcp_l_4_1_lib4(int kmax, float *A0, int sda, float *B); +void kernel_strcp_l_4_2_lib4(int kmax, float *A0, int sda, float *B); +void kernel_strcp_l_4_3_lib4(int kmax, float *A0, int sda, float *B); +void kernel_strcp_l_3_0_lib4(int kmax, float *A, float *B); +void kernel_strcp_l_3_2_lib4(int kmax, float *A0, int sda, float *B); +void kernel_strcp_l_3_3_lib4(int kmax, float *A0, int sda, float *B); +void kernel_strcp_l_2_0_lib4(int kmax, float *A, float *B); +void kernel_strcp_l_2_3_lib4(int kmax, float *A0, int sda, float *B); +void kernel_strcp_l_1_0_lib4(int kmax, float *A, float *B); +void kernel_sgead_4_0_lib4(int kmax, float *alpha, float *A, float *B); +void kernel_sgead_4_1_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgead_4_2_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgead_4_3_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgead_3_0_lib4(int kmax, float *alpha, float *A, float *B); +void kernel_sgead_3_2_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgead_3_3_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgead_2_0_lib4(int kmax, float *alpha, float *A, float *B); +void kernel_sgead_2_3_lib4(int kmax, float *alpha, float *A0, int sda, float *B); +void kernel_sgead_1_0_lib4(int kmax, float *alpha, float *A, float *B); +// TODO +void kernel_sgeset_4_lib4(int kmax, float alpha, float *A); +void kernel_strset_4_lib4(int kmax, float alpha, float *A); +void kernel_sgetr_4_lib4(int tri, int kmax, int kna, float alpha, float *A, float *C, int sdc); +void kernel_sgetr_3_lib4(int tri, int kmax, int kna, float alpha, float *A, float *C, int sdc); +void kernel_sgetr_2_lib4(int tri, int kmax, int kna, float alpha, float *A, float *C, int sdc); +void kernel_sgetr_1_lib4(int tri, int kmax, int kna, float alpha, float *A, float *C, int sdc); + + + +// pack +// 24 lib 8 +void kernel_spack_nn_24_lib8(int kmax, float *A, int lda, float *B, int sdb); +void kernel_spack_nn_24_vs_lib8(int kmax, float *A, int lda, float *B, int sdb, int m1); +// 16 lib 8 +void kernel_spack_nn_16_lib8(int kmax, float *A, int lda, float *B, int sdb); +void kernel_spack_nn_16_vs_lib8(int kmax, float *A, int lda, float *B, int sdb, int m1); +// 8 lib 8 +void kernel_spack_nn_8_lib8(int kmax, float *A, int lda, float *B); +void kernel_spack_nn_8_vs_lib8(int kmax, float *A, int lda, float *B, int m1); +void kernel_spack_tn_8_lib8(int kmax, float *A, int lda, float *B); +void kernel_spack_tn_8_vs_lib8(int kmax, float *A, int lda, float *B, int m1); +void kernel_spack_tt_8_lib8(int kmax, float *A, int lda, float *B, int sdb); +void kernel_spack_tt_8_vs_lib8(int kmax, float *A, int lda, float *B, int sdb, int m1); +// 8 lib 4 +void kernel_spack_nn_8_lib4(int kmax, float *A, int lda, float *B, int sdb); +void kernel_spack_nn_8_vs_lib4(int kmax, float *A, int lda, float *B, int sdb, int m1); +//void kernel_spack_tt_8_lib4(int kmax, float *A, int lda, float *B, int sdb); +// 4 +void kernel_spack_nn_4_lib4(int kmax, float *A, int lda, float *B); +void kernel_spack_nn_4_vs_lib4(int kmax, float *A, int lda, float *B, int m1); +void kernel_spack_tn_4_lib4(int kmax, float *A, int lda, float *B); +void kernel_spack_tn_4_vs_lib4(int kmax, float *A, int lda, float *B, int m1); +void kernel_spack_tt_4_lib4(int kmax, float *A, int lda, float *B, int sdb); +void kernel_spack_tt_4_vs_lib4(int kmax, float *A, int lda, float *B, int sdb, int m1); +// unpack +// 8 +void kernel_sunpack_nn_8_lib4(int kmax, float *A, int sda, float *B, int ldb); +void kernel_sunpack_nn_8_vs_lib4(int kmax, float *A, int sda, float *B, int ldb, int m1); +//void kernel_sunpack_tt_8_lib4(int kmax, float *A, int sda, float *B, int ldb); +// 4 +void kernel_sunpack_nn_4_lib4(int kmax, float *A, float *B, int ldb); +void kernel_sunpack_nn_4_vs_lib4(int kmax, float *A, float *B, int ldb, int m1); +void kernel_sunpack_nt_4_lib4(int kmax, float *A, float *B, int ldb); +void kernel_sunpack_nt_4_vs_lib4(int kmax, float *A, float *B, int ldb, int m1); +void kernel_sunpack_tt_4_lib4(int kmax, float *A, int sda, float *B, int ldb); + +// panel copy +// 4 +void kernel_spacp_nt_4_lib4(int kmax, float *A, int offsetB, float *B, int sdb); +void kernel_spacp_tn_4_lib4(int kmax, int offsetA, float *A, int sda, float *B); +void kernel_spacp_nn_4_lib4(int kmax, int offsetA, float *A, int sda, float *B); +void kernel_spacp_nn_4_vs_lib4(int kmax, int offsetA, float *A, int sda, float *B, int m1); + + + +/************************************************ +* BLAS API kernels +************************************************/ + +//#if defined(BLAS_API) + +// A, B panel-major bs=8; C, D column-major +// 24x4 +void kernel_sgemm_nt_24x4_lib88cc(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_24x4_vs_lib88cc(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 16x4 +void kernel_sgemm_nt_16x4_lib88cc(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_16x4_vs_lib88cc(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 8x8 +void kernel_sgemm_nt_8x8_lib88cc(int kmax, float *alpha, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x8_vs_lib88cc(int kmax, float *alpha, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_spotrf_nt_l_8x8_lib88cc(int kmax, float *A, float *B, float *C, int ldc, float *D, int ldd, float *dD); +void kernel_spotrf_nt_l_8x8_vs_lib88cc(int kmax, float *A, float *B, float *C, int ldc, float *D, int ldd, float *dD, int m1, int n1); +void kernel_strsm_nt_rl_inv_8x8_lib88ccc(int kmax, float *A, float *B, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE); +void kernel_strsm_nt_rl_inv_8x8_vs_lib88ccc(int kmax, float *A, float *B, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE, int m1, int n1); +// 8x4 +void kernel_sgemm_nt_8x4_lib88cc(int kmax, float *alpha, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x4_vs_lib88cc(int kmax, float *alpha, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); + +// A, B panel-major bs=4; C, D column-major +// 8x8 +void kernel_sgemm_nt_8x8_lib44cc(int kmax, float *alpha, float *A, int sda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +// 8x4 +void kernel_sgemm_nt_8x4_lib44cc(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x4_vs_lib44cc(int kmax, float *alpha, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_spotrf_nt_l_8x4_lib44cc(int kmax, float *A, int sda, float *B, float *C, int ldc, float *D, int ldd, float *dD); +void kernel_strsm_nt_rl_inv_8x4_lib44ccc(int kmax, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE); +void kernel_strsm_nt_rl_inv_8x4_vs_lib44ccc(int kmax, float *A, int sda, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE, int m1, int n1); +// 4x4 +void kernel_sgemm_nt_4x4_lib44cc(int kmax, float *alpha, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x4_vs_lib44cc(int kmax, float *alpha, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_strsm_nt_rl_inv_4x4_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, float *dE); +void kernel_strsm_nt_rl_inv_4x4_vs_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, float *dE, int m1, int n1); +void kernel_strsm_nt_rl_inv_4x4_lib44ccc(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE); +void kernel_strsm_nt_rl_inv_4x4_vs_lib44ccc(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nt_rl_one_4x4_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E); +void kernel_strsm_nt_rl_one_4x4_vs_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, int m1, int n1); +void kernel_strsm_nt_ru_inv_4x4_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, float *dE); +void kernel_strsm_nt_ru_inv_4x4_vs_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, float *dE, int m1, int n1); +void kernel_strsm_nt_ru_one_4x4_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E); +void kernel_strsm_nt_ru_one_4x4_vs_lib44cc4(int kmax, float *A, float *B, float *beta, float *C, int ldc, float *D, int ldd, float *E, int m1, int n1); +void kernel_spotrf_nt_l_4x4_lib44cc(int kmax, float *A, float *B, float *C, int ldc, float *D, int ldd, float *dD); +void kernel_spotrf_nt_l_4x4_vs_lib44cc(int kmax, float *A, float *B, float *C, int ldc, float *D, int ldd, float *dD, int m1, int n1); + +// B panel-major bs=8; A, C, D column-major +// 4x24 +void kernel_sgemm_nt_4x24_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x24_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_4x24_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_4x24_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 4x16 +void kernel_sgemm_nt_4x16_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x16_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_4x16_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_4x16_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 8x8 +void kernel_sgemm_nt_8x8_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x8_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_8x8_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_8x8_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 4x8 +void kernel_sgemm_nt_4x8_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x8_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_4x8_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_4x8_vs_libc8cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); + +// B panel-major bs=4; A, C, D column-major +// 8x8 +void kernel_sgemm_nt_8x8_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x8_vs_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_8x8_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_8x8_vs_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 4x8 +void kernel_sgemm_nt_4x8_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x8_vs_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_4x8_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_4x8_vs_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 4x4 +void kernel_sgemm_nt_4x4_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x4_vs_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_4x4_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_4x4_vs_libc4cc(int kmax, float *alpha, float *A, int lda, float *B, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); + +// A panel-major bs=8; B, C, D column-major +// 24x4 +void kernel_sgemm_nn_24x4_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nn_24x4_vs_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_nt_24x4_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_24x4_vs_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 16x4 +void kernel_sgemm_nn_16x4_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nn_16x4_vs_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_nt_16x4_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_16x4_vs_lib8ccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 8x8 +void kernel_sgemm_nn_8x8_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nn_8x8_vs_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_nt_8x8_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x8_vs_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 8x4 +void kernel_sgemm_nn_8x4_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nn_8x4_vs_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_nt_8x4_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x4_vs_lib8ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); + +// A panel-major bs=4; B, C, D column-major +// 8x8 +void kernel_sgemm_nn_8x8_lib4ccc(int kmax, float *alpha, float *A, int sda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x8_lib4ccc(int kmax, float *alpha, float *A, int sda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +// 8x4 +void kernel_sgemm_nn_8x4_lib4ccc(int kmax, float *alpha, float *A, int sda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nn_8x4_vs_lib4ccc(int kmax, float *alpha, float *A, int sda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_nt_8x4_lib4ccc(int kmax, float *alpha, float *A, int sda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_8x4_vs_lib4ccc(int kmax, float *alpha, float *A, int sda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +// 4x4 +void kernel_sgemm_nn_4x4_lib4ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nn_4x4_vs_lib4ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_nt_4x4_lib4ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x4_vs_lib4ccc(int kmax, float *alpha, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_strsm_nn_rl_inv_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE); +void kernel_strsm_nn_rl_inv_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nn_rl_one_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde); +void kernel_strsm_nn_rl_one_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, int m1, int n1); +void kernel_strsm_nt_rl_inv_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE); +void kernel_strsm_nt_rl_inv_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nt_rl_one_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde); +void kernel_strsm_nt_rl_one_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, int m1, int n1); +void kernel_strsm_nn_ru_inv_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE); +void kernel_strsm_nn_ru_inv_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nn_ru_one_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde); +void kernel_strsm_nn_ru_one_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, int m1, int n1); +void kernel_strsm_nt_ru_inv_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE); +void kernel_strsm_nt_ru_inv_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nt_ru_one_4x4_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde); +void kernel_strsm_nt_ru_one_4x4_vs_lib4cccc(int kmax, float *A, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, float *E, int lde, int m1, int n1); + +// A, C, D panel-major; B, E column-major +// TODO merge with above +// 4x4 +void kernel_strsm_nn_rl_inv_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE); +void kernel_strsm_nn_rl_inv_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nn_rl_one_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde); +void kernel_strsm_nn_rl_one_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, int m1, int n1); +void kernel_strsm_nn_ru_inv_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE); +void kernel_strsm_nn_ru_inv_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nn_ru_one_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde); +void kernel_strsm_nn_ru_one_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, int m1, int n1); +void kernel_strsm_nt_rl_inv_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE); +void kernel_strsm_nt_rl_inv_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nt_rl_one_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde); +void kernel_strsm_nt_rl_one_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, int m1, int n1); +void kernel_strsm_nt_ru_inv_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE); +void kernel_strsm_nt_ru_inv_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, float *dE, int m1, int n1); +void kernel_strsm_nt_ru_one_4x4_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde); +void kernel_strsm_nt_ru_one_4x4_vs_lib4c44c(int kmax, float *A, float *B, int ldb, float *beta, float *C, float *D, float *E, int lde, int m1, int n1); + +// A, B, C, D column-major +void kernel_sgemm_nn_4x4_libcccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nn_4x4_vs_libcccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_nt_4x4_libcccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_nt_4x4_vs_libcccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); +void kernel_sgemm_tt_4x4_libcccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd); +void kernel_sgemm_tt_4x4_vs_libcccc(int kmax, float *alpha, float *A, int lda, float *B, int ldb, float *beta, float *C, int ldc, float *D, int ldd, int m1, int n1); + +// vector +void kernel_sdot_11_lib(int n, float *x, float *y, float *res); +void kernel_saxpy_11_lib(int n, float *alpha, float *x, float *y); + + +//#endif // BLAS_API + + + +// larger kernels +// 24 +void kernel_sgemm_nt_24xn_p0_lib88cc(int n, int k, float *alpha, float *A, int sda, float *B, int sdb, float *beta, float *C, int ldc, float *D, int ldd, float *A_p, float *B_p); + + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_S_KERNEL_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_stdlib.h b/third_party/acados/include/blasfeo/include/blasfeo_stdlib.h new file mode 100644 index 00000000000000..9bd248b1d4f702 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_stdlib.h @@ -0,0 +1,62 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_STDLIB_H_ +#define BLASFEO_STDLIB_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#include + +// +void blasfeo_malloc(void **ptr, size_t size); +// +void blasfeo_malloc_align(void **ptr, size_t size); +// +void blasfeo_free(void *ptr); +// +void blasfeo_free_align(void *ptr); + + + +#ifdef __cplusplus +} +#endif + +#endif // BLASFEO_STDLIB_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_target.h b/third_party/acados/include/blasfeo/include/blasfeo_target.h new file mode 100644 index 00000000000000..51f617a6499273 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_target.h @@ -0,0 +1,73 @@ +#ifndef TARGET_X64_INTEL_HASWELL +#define TARGET_X64_INTEL_HASWELL +#endif + +#ifndef TARGET_NEED_FEATURE_AVX2 +#define TARGET_NEED_FEATURE_AVX2 1 +#endif + +#ifndef TARGET_NEED_FEATURE_FMA +#define TARGET_NEED_FEATURE_FMA 1 +#endif + +#ifndef TARGET_NEED_FEATURE_SSE3 +/* #undef TARGET_NEED_FEATURE_SSE3 */ +#endif + +#ifndef TARGET_NEED_FEATURE_AVX +/* #undef TARGET_NEED_FEATURE_AVX */ +#endif + +#ifndef TARGET_NEED_FEATURE_VFPv3 +/* #undef TARGET_NEED_FEATURE_VFPv3 */ +#endif + +#ifndef TARGET_NEED_FEATURE_NEON +/* #undef TARGET_NEED_FEATURE_NEON */ +#endif + +#ifndef TARGET_NEED_FEATURE_VFPv4 +/* #undef TARGET_NEED_FEATURE_VFPv4 */ +#endif + +#ifndef TARGET_NEED_FEATURE_NEONv2 +/* #undef TARGET_NEED_FEATURE_NEONv2 */ +#endif + +#ifndef LA_HIGH_PERFORMANCE +#define LA_HIGH_PERFORMANCE +#endif + +#ifndef MF_PANELMAJ +#define MF_PANELMAJ +#endif + +#ifndef EXT_DEP +#define ON 1 +#define OFF 0 +#if ON==ON +#define EXT_DEP +#endif +#undef ON +#undef OFF +#endif + +#ifndef BLAS_API +#define ON 1 +#define OFF 0 +#if OFF==ON +#define BLAS_API +#endif +#undef ON +#undef OFF +#endif + +#ifndef FORTRAN_BLAS_API +#define ON 1 +#define OFF 0 +#if OFF==ON +#define FORTRAN_BLAS_API +#endif +#undef ON +#undef OFF +#endif diff --git a/third_party/acados/include/blasfeo/include/blasfeo_timing.h b/third_party/acados/include/blasfeo/include/blasfeo_timing.h new file mode 100644 index 00000000000000..5671b888feec39 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_timing.h @@ -0,0 +1,114 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_TIMING_H_ +#define BLASFEO_TIMING_H_ + +//#include + +#if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) + + /* Use Windows QueryPerformanceCounter for timing. */ + #include + + /** A structure for keeping internal timer data. */ + typedef struct blasfeo_timer_ { + LARGE_INTEGER tic; + LARGE_INTEGER toc; + LARGE_INTEGER freq; + } blasfeo_timer; + +#elif(defined __APPLE__) + + #include + + /** A structure for keeping internal timer data. */ + typedef struct blasfeo_timer_ { + uint64_t tic; + uint64_t toc; + mach_timebase_info_data_t tinfo; + } blasfeo_timer; + +#elif(defined __DSPACE__) + + #include + + typedef struct blasfeo_timer_ { + double time; + } blasfeo_timer; + +#elif(defined __XILINX_NONE_ELF__ || defined __XILINX_ULTRASCALE_NONE_ELF_JAILHOUSE__) + + #include "xtime_l.h" + + typedef struct blasfeo_timer_ { + uint64_t tic; + uint64_t toc; + } blasfeo_timer; + +#else + + /* Use POSIX clock_gettime() for timing on non-Windows machines. */ + #include + + #if __STDC_VERSION__ >= 199901L // C99 Mode + + #include + #include + + typedef struct blasfeo_timer_ { + struct timeval tic; + struct timeval toc; + } blasfeo_timer; + + #else // ANSI C Mode + + /** A structure for keeping internal timer data. */ + typedef struct blasfeo_timer_ { + struct timespec tic; + struct timespec toc; + } blasfeo_timer; + + #endif // __STDC_VERSION__ >= 199901L + +#endif // (defined _WIN32 || defined _WIN64) + +/** A function for measurement of the current time. */ +void blasfeo_tic(blasfeo_timer* t); + +/** A function which returns the elapsed time. */ +double blasfeo_toc(blasfeo_timer* t); + +#endif // BLASFEO_TIMING_H_ diff --git a/third_party/acados/include/blasfeo/include/blasfeo_v_aux_ext_dep.h b/third_party/acados/include/blasfeo/include/blasfeo_v_aux_ext_dep.h new file mode 100644 index 00000000000000..1598551185cc68 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/blasfeo_v_aux_ext_dep.h @@ -0,0 +1,83 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef BLASFEO_V_AUX_EXT_DEP_H_ +#define BLASFEO_V_AUX_EXT_DEP_H_ + + + +#include "blasfeo_target.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/************************************************ +* d_aux_extern_depend_lib.c +************************************************/ + +#ifdef EXT_DEP + +void v_zeros(void **ptrA, int size); +// dynamically allocate size bytes of memory aligned to 64-byte boundaries and set accordingly a pointer to void; set allocated memory to zero +void v_zeros_align(void **ptrA, int size); +// free the memory allocated by v_zeros +void v_free(void *ptrA); +// free the memory allocated by v_zeros_aligned +void v_free_align(void *ptrA); +// dynamically allocate size bytes of memory and set accordingly a pointer to char; set allocated memory to zero +void c_zeros(char **ptrA, int size); +// dynamically allocate size bytes of memory aligned to 64-byte boundaries and set accordingly a pointer to char; set allocated memory to zero +void c_zeros_align(char **ptrA, int size); +// free the memory allocated by c_zeros +void c_free(char *ptrA); +// free the memory allocated by c_zeros_aligned +void c_free_align(char *ptrA); + +#endif // EXT_DEP + + + +#ifdef __cplusplus +} +#endif + + + +#endif // BLASFEO_V_AUX_EXT_DEP_H_ diff --git a/third_party/acados/include/blasfeo/include/d_blas.h b/third_party/acados/include/blasfeo/include/d_blas.h new file mode 100644 index 00000000000000..d6f8786721b115 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/d_blas.h @@ -0,0 +1,77 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// headers to reference BLAS and LAPACK routines employed in BLASFEO WR + +// level 1 +double ddot_(int *m, double *x, int *incx, double *y, int *incy); +void dcopy_(int *m, double *x, int *incx, double *y, int *incy); +void daxpy_(int *m, double *alpha, double *x, int *incx, double *y, int *incy); +void dscal_(int *m, double *alpha, double *x, int *incx); +void drot_(int *m, double *x, int *incx, double *y, int *incy, double *c, double *s); +void drotg_(double *a, double *b, double *c, double *s); + +// level 2 +void dgemv_(char *ta, int *m, int *n, double *alpha, double *A, int *lda, double *x, int *incx, double *beta, double *y, int *incy); +void dsymv_(char *uplo, int *m, double *alpha, double *A, int *lda, double *x, int *incx, double *beta, double *y, int *incy); +void dtrmv_(char *uplo, char *trans, char *diag, int *n, double *A, int *lda, double *x, int *incx); +void dtrsv_(char *uplo, char *trans, char *diag, int *n, double *A, int *lda, double *x, int *incx); +void dger_(int *m, int *n, double *alpha, double *x, int *incx, double *y, int *incy, double *A, int *lda); + +// level 3 +void dgemm_(char *ta, char *tb, int *m, int *n, int *k, double *alpha, double *A, int *lda, double *B, int *ldb, double *beta, double *C, int *ldc); +void dsyrk_(char *uplo, char *trans, int *n, int *k, double *alpha, double *A, int *lda, double *beta, double *C, int *ldc); +void dtrmm_(char *side, char *uplo, char *trans, char *diag, int *m, int *n, double *alpha, double *A, int *lda, double *B, int *ldb); +void dtrsm_(char *side, char *uplo, char *trans, char *diag, int *m, int *n, double *alpha, double *A, int *lda, double *B, int *ldb); + +// lapack +void dpotrf_(char *uplo, int *m, double *A, int *lda, int *info); +void dgetrf_(int *m, int *n, double *A, int *lda, int *ipiv, int *info); +void dgeqrf_(int *m, int *n, double *A, int *lda, double *tau, double *work, int *lwork, int *info); +void dgeqr2_(int *m, int *n, double *A, int *lda, double *tau, double *work, int *info); +void dgelqf_(int *m, int *n, double *A, int *lda, double *tau, double *work, int *lwork, int *info); +void dorglq_(int *m, int *n, int *k, double *A, int *lda, double *tau, double *work, int *lwork, int *info); + + + +#ifdef __cplusplus +} +#endif diff --git a/third_party/acados/include/blasfeo/include/d_blas_64.h b/third_party/acados/include/blasfeo/include/d_blas_64.h new file mode 100644 index 00000000000000..4f40d00dfb3fe8 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/d_blas_64.h @@ -0,0 +1,73 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// headers to reference BLAS and LAPACK routines employed in BLASFEO WR + +// level 1 +double ddot_(long long *m, double *x, long long *incx, double *y, long long *incy); +void dcopy_(long long *m, double *x, long long *incx, double *y, long long *incy); +void daxpy_(long long *m, double *alpha, double *x, long long *incx, double *y, long long *incy); +void dscal_(long long *m, double *alpha, double *x, long long *incx); + +// level 2 +void dgemv_(char *ta, long long *m, long long *n, double *alpha, double *A, long long *lda, double *x, long long *incx, double *beta, double *y, long long *incy); +void dsymv_(char *uplo, long long *m, double *alpha, double *A, long long *lda, double *x, long long *incx, double *beta, double *y, long long *incy); +void dtrmv_(char *uplo, char *trans, char *diag, long long *n, double *A, long long *lda, double *x, long long *incx); +void dtrsv_(char *uplo, char *trans, char *diag, long long *n, double *A, long long *lda, double *x, long long *incx); +void dger_(long long *m, long long *n, double *alpha, double *x, long long *incx, double *y, long long *incy, double *A, long long *lda); + +// level 3 +void dgemm_(char *ta, char *tb, long long *m, long long *n, long long *k, double *alpha, double *A, long long *lda, double *B, long long *ldb, double *beta, double *C, long long *ldc); +void dsyrk_(char *uplo, char *trans, long long *n, long long *k, double *alpha, double *A, long long *lda, double *beta, double *C, long long *ldc); +void dtrmm_(char *side, char *uplo, char *trans, char *diag, long long *m, long long *n, double *alpha, double *A, long long *lda, double *B, long long *ldb); +void dtrsm_(char *side, char *uplo, char *trans, char *diag, long long *m, long long *n, double *alpha, double *A, long long *lda, double *B, long long *ldb); + +// lapack +void dpotrf_(char *uplo, long long *m, double *A, long long *lda, long long *info); +void dgetrf_(long long *m, long long *n, double *A, long long *lda, long long *ipiv, long long *info); +void dgeqrf_(long long *m, long long *n, double *A, long long *lda, double *tau, double *work, long long *lwork, long long *info); +void dgeqr2_(long long *m, long long *n, double *A, long long *lda, double *tau, double *work, long long *info); + + + +#ifdef __cplusplus +} +#endif diff --git a/third_party/acados/include/blasfeo/include/s_blas.h b/third_party/acados/include/blasfeo/include/s_blas.h new file mode 100644 index 00000000000000..58b2bb0a1aa652 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/s_blas.h @@ -0,0 +1,77 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// headers to reference BLAS and LAPACK routines employed in BLASFEO WR + +// level 1 +float sdot_(int *m, float *x, int *incx, float *y, int *incy); +void scopy_(int *m, float *x, int *incx, float *y, int *incy); +void saxpy_(int *m, float *alpha, float *x, int *incx, float *y, int *incy); +void sscal_(int *m, float *alpha, float *x, int *incx); +void srot_(int *m, float *x, int *incx, float *y, int *incy, float *c, float *s); +void srotg_(float *a, float *b, float *c, float *s); + +// level 2 +void sgemv_(char *ta, int *m, int *n, float *alpha, float *A, int *lda, float *x, int *incx, float *beta, float *y, int *incy); +void ssymv_(char *uplo, int *m, float *alpha, float *A, int *lda, float *x, int *incx, float *beta, float *y, int *incy); +void strmv_(char *uplo, char *trans, char *diag, int *n, float *A, int *lda, float *x, int *incx); +void strsv_(char *uplo, char *trans, char *diag, int *n, float *A, int *lda, float *x, int *incx); +void sger_(int *m, int *n, float *alpha, float *x, int *incx, float *y, int *incy, float *A, int *lda); + +// level 3 +void sgemm_(char *ta, char *tb, int *m, int *n, int *k, float *alpha, float *A, int *lda, float *B, int *ldb, float *beta, float *C, int *ldc); +void ssyrk_(char *uplo, char *trans, int *n, int *k, float *alpha, float *A, int *lda, float *beta, float *C, int *ldc); +void strmm_(char *side, char *uplo, char *transa, char *diag, int *m, int *n, float *alpha, float *A, int *lda, float *B, int *ldb); +void strsm_(char *side, char *uplo, char *transa, char *diag, int *m, int *n, float *alpha, float *A, int *lda, float *B, int *ldb); + +// lapack +void spotrf_(char *uplo, int *m, float *A, int *lda, int *info); +void sgetrf_(int *m, int *n, float *A, int *lda, int *ipiv, int *info); +void sgeqrf_(int *m, int *n, float *A, int *lda, float *tau, float *work, int *lwork, int *info); +void sgeqr2_(int *m, int *n, float *A, int *lda, float *tau, float *work, int *info); +void sgelqf_(int *m, int *n, float *A, int *lda, float *tau, float *work, int *lwork, int *info); +void sorglq_(int *m, int *n, int *k, float *A, int *lda, float *tau, float *work, int *lwork, int *info); + + + +#ifdef __cplusplus +} +#endif diff --git a/third_party/acados/include/blasfeo/include/s_blas_64.h b/third_party/acados/include/blasfeo/include/s_blas_64.h new file mode 100644 index 00000000000000..b9efab6c236ed1 --- /dev/null +++ b/third_party/acados/include/blasfeo/include/s_blas_64.h @@ -0,0 +1,73 @@ +/************************************************************************************************** +* * +* This file is part of BLASFEO. * +* * +* BLASFEO -- BLAS For Embedded Optimization. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + + +// headers to reference BLAS and LAPACK routines employed in BLASFEO WR + +// level 1 +float sdot_(long long *m, float *x, long long *incx, float *y, long long *incy); +void scopy_(long long *m, float *x, long long *incx, float *y, long long *incy); +void saxpy_(long long *m, float *alpha, float *x, long long *incx, float *y, long long *incy); +void sscal_(long long *m, float *alpha, float *x, long long *incx); + +// level 2 +void sgemv_(char *ta, long long *m, long long *n, float *alpha, float *A, long long *lda, float *x, long long *incx, float *beta, float *y, long long *incy); +void ssymv_(char *uplo, long long *m, float *alpha, float *A, long long *lda, float *x, long long *incx, float *beta, float *y, long long *incy); +void strmv_(char *uplo, char *trans, char *diag, long long *n, float *A, long long *lda, float *x, long long *incx); +void strsv_(char *uplo, char *trans, char *diag, long long *n, float *A, long long *lda, float *x, long long *incx); +void sger_(long long *m, long long *n, float *alpha, float *x, long long *incx, float *y, long long *incy, float *A, long long *lda); + +// level 3 +void sgemm_(char *ta, char *tb, long long *m, long long *n, long long *k, float *alpha, float *A, long long *lda, float *B, long long *ldb, float *beta, float *C, long long *ldc); +void ssyrk_(char *uplo, char *trans, long long *n, long long *k, float *alpha, float *A, long long *lda, float *beta, float *C, long long *ldc); +void strmm_(char *side, char *uplo, char *transa, char *diag, long long *m, long long *n, float *alpha, float *A, long long *lda, float *B, long long *ldb); +void strsm_(char *side, char *uplo, char *transa, char *diag, long long *m, long long *n, float *alpha, float *A, long long *lda, float *B, long long *ldb); + +// lapack +void spotrf_(char *uplo, long long *m, float *A, long long *lda, long long *info); +void sgetrf_(long long *m, long long *n, float *A, long long *lda, long long *ipiv, long long *info); +void sgeqrf_(long long *m, long long *n, float *A, long long *lda, float *tau, float *work, long long *lwork, long long *info); +void sgeqr2_(long long *m, long long *n, float *A, long long *lda, float *tau, float *work, long long *info); + + + +#ifdef __cplusplus +} +#endif diff --git a/third_party/acados/include/hpipm/include/hpipm_aux_mem.h b/third_party/acados/include/hpipm/include/hpipm_aux_mem.h new file mode 100644 index 00000000000000..7bd3d7e8bc53e9 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_aux_mem.h @@ -0,0 +1,52 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_AUX_MEM_H_ +#define HPIPM_AUX_MEM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void hpipm_zero_memset(hpipm_size_t memsize, void *mem); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_AUX_MEM_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_aux_string.h b/third_party/acados/include/hpipm/include/hpipm_aux_string.h new file mode 100644 index 00000000000000..804cba5dc1a88d --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_aux_string.h @@ -0,0 +1,50 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_AUX_STRING_H_ +#define HPIPM_AUX_STRING_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_STR_LEN 5 +int hpipm_strcmp(char *str1, char *str2); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_AUX_STRING_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_common.h b/third_party/acados/include/hpipm/include/hpipm_common.h new file mode 100644 index 00000000000000..0cc96a7b506568 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_common.h @@ -0,0 +1,76 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_COMMON_H_ +#define HPIPM_COMMON_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef size_t hpipm_size_t; + +enum hpipm_mode + { + SPEED_ABS, // focus on speed, absolute IPM formulation + SPEED, // focus on speed, relative IPM formulation + BALANCE, // balanced mode, relative IPM formulation + ROBUST, // focus on robustness, relative IPM formulation + }; + +enum hpipm_status + { + SUCCESS, // found solution satisfying accuracy tolerance + MAX_ITER, // maximum iteration number reached + MIN_STEP, // minimum step length reached + NAN_SOL, // NaN in solution detected + INCONS_EQ, // unconsistent equality constraints + }; + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_COMMON_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_cast_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_d_cast_qcqp.h new file mode 100644 index 00000000000000..0e4c41f22159ac --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_cast_qcqp.h @@ -0,0 +1,71 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_CAST_QCQP_H_ +#define HPIPM_D_CAST_QCQP_H_ + + + +#include +#include + +#include "hpipm_d_dense_qcqp.h" +#include "hpipm_d_dense_qcqp_sol.h" +#include "hpipm_d_ocp_qcqp.h" +#include "hpipm_d_ocp_qcqp_dim.h" +#include "hpipm_d_ocp_qcqp_sol.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_cast_qcqp_compute_dim(struct d_ocp_qcqp_dim *ocp_dim, struct d_dense_qcqp_dim *dense_dim); +// +void d_cast_qcqp_cond(struct d_ocp_qcqp *ocp_qp, struct d_dense_qcqp *dense_qp); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_CAST_QCQP_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_cond.h b/third_party/acados/include/hpipm/include/hpipm_d_cond.h new file mode 100644 index 00000000000000..5900a2ab10201e --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_cond.h @@ -0,0 +1,135 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_COND_H_ +#define HPIPM_D_COND_H_ + + + +#include +#include + +#include "hpipm_d_dense_qp.h" +#include "hpipm_d_dense_qp_sol.h" +#include "hpipm_d_ocp_qp.h" +#include "hpipm_d_ocp_qp_dim.h" +#include "hpipm_d_ocp_qp_sol.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_cond_qp_arg + { + int cond_last_stage; // condense last stage + int cond_alg; // condensing algorithm: 0 N2-nx3, 1 N3-nx2 + int comp_prim_sol; // primal solution (v) + int comp_dual_sol_eq; // dual solution equality constr (pi) + int comp_dual_sol_ineq; // dual solution inequality constr (lam t) + int square_root_alg; // square root algorithm (faster but requires RSQ>0) + hpipm_size_t memsize; + }; + + + +struct d_cond_qp_ws + { + struct blasfeo_dmat *Gamma; + struct blasfeo_dmat *GammaQ; + struct blasfeo_dmat *L; + struct blasfeo_dmat *Lx; + struct blasfeo_dmat *AL; + struct blasfeo_dvec *Gammab; + struct blasfeo_dvec *l; + struct blasfeo_dvec *tmp_nbgM; + struct blasfeo_dvec *tmp_nuxM; + int bs; // block size + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_cond_qp_arg_memsize(); +// +void d_cond_qp_arg_create(struct d_cond_qp_arg *cond_arg, void *mem); +// +void d_cond_qp_arg_set_default(struct d_cond_qp_arg *cond_arg); +// condensing algorithm: 0 N2-nx3, 1 N3-nx2 +void d_cond_qp_arg_set_cond_alg(int cond_alg, struct d_cond_qp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 square-root +void d_cond_qp_arg_set_ric_alg(int ric_alg, struct d_cond_qp_arg *cond_arg); +// condense last stage: 0 last stage disregarded, 1 last stage condensed too +void d_cond_qp_arg_set_cond_last_stage(int cond_last_stage, struct d_cond_qp_arg *cond_arg); +// +void d_cond_qp_arg_set_comp_prim_sol(int value, struct d_cond_qp_arg *cond_arg); +// +void d_cond_qp_arg_set_comp_dual_sol_eq(int value, struct d_cond_qp_arg *cond_arg); +// +void d_cond_qp_arg_set_comp_dual_sol_ineq(int value, struct d_cond_qp_arg *cond_arg); + +// +void d_cond_qp_compute_dim(struct d_ocp_qp_dim *ocp_dim, struct d_dense_qp_dim *dense_dim); +// +hpipm_size_t d_cond_qp_ws_memsize(struct d_ocp_qp_dim *ocp_dim, struct d_cond_qp_arg *cond_arg); +// +void d_cond_qp_ws_create(struct d_ocp_qp_dim *ocp_dim, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws, void *mem); +// +void d_cond_qp_cond(struct d_ocp_qp *ocp_qp, struct d_dense_qp *dense_qp, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_qp_cond_lhs(struct d_ocp_qp *ocp_qp, struct d_dense_qp *dense_qp, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_qp_cond_rhs(struct d_ocp_qp *ocp_qp, struct d_dense_qp *dense_qp, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_qp_expand_sol(struct d_ocp_qp *ocp_qp, struct d_dense_qp_sol *dense_qp_sol, struct d_ocp_qp_sol *ocp_qp_sol, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// TODO remove +void d_cond_qp_expand_primal_sol(struct d_ocp_qp *ocp_qp, struct d_dense_qp_sol *dense_qp_sol, struct d_ocp_qp_sol *ocp_qp_sol, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); + +// +void d_cond_qp_update(int *idxc, struct d_ocp_qp *ocp_qp, struct d_dense_qp *dense_qp, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_COND_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_cond_aux.h b/third_party/acados/include/hpipm/include/hpipm_d_cond_aux.h new file mode 100644 index 00000000000000..73afba3c7e75e2 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_cond_aux.h @@ -0,0 +1,92 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_COND_AUX_H_ +#define HPIPM_D_COND_AUX_H_ + + + +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_cond_BAbt(struct d_ocp_qp *ocp_qp, struct blasfeo_dmat *BAbt2, struct blasfeo_dvec *b, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_BAt(struct d_ocp_qp *ocp_qp, struct blasfeo_dmat *BAbt2, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_b(struct d_ocp_qp *ocp_qp, struct blasfeo_dvec *b, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_RSQrq(struct d_ocp_qp *ocp_qp, struct blasfeo_dmat *RSQrq2, struct blasfeo_dvec *rq, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_RSQ(struct d_ocp_qp *ocp_qp, struct blasfeo_dmat *RSQrq2, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_rq(struct d_ocp_qp *ocp_qp, struct blasfeo_dvec *rq, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_DCtd(struct d_ocp_qp *ocp_qp, int *idxb2, struct blasfeo_dmat *DCt2, struct blasfeo_dvec *d2, struct blasfeo_dvec *d_mask2, int *idxs_rev2, struct blasfeo_dvec *Z2, struct blasfeo_dvec *z, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_DCt(struct d_ocp_qp *ocp_qp, int *idxb2, struct blasfeo_dmat *DCt2, int *idxs_rev2, struct blasfeo_dvec *Z2, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_cond_d(struct d_ocp_qp *ocp_qp, struct blasfeo_dvec *d2, struct blasfeo_dvec *d_mask2, struct blasfeo_dvec *z, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_expand_sol(struct d_ocp_qp *ocp_qp, struct d_dense_qp_sol *dense_qp_sol, struct d_ocp_qp_sol *ocp_qp_so, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_expand_primal_sol(struct d_ocp_qp *ocp_qp, struct d_dense_qp_sol *dense_qp_sol, struct d_ocp_qp_sol *ocp_qp_so, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); + +// +void d_update_cond_BAbt(int *idxc, struct d_ocp_qp *ocp_qp, struct blasfeo_dmat *BAbt2, struct blasfeo_dvec *b, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_update_cond_RSQrq_N2nx3(int *idxc, struct d_ocp_qp *ocp_qp, struct blasfeo_dmat *RSQrq2, struct blasfeo_dvec *rq, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); +// +void d_update_cond_DCtd(int *idxc, struct d_ocp_qp *ocp_qp, int *idxb2, struct blasfeo_dmat *DCt2, struct blasfeo_dvec *d2, int *idxs2, struct blasfeo_dvec *Z2, struct blasfeo_dvec *z, struct d_cond_qp_arg *cond_arg, struct d_cond_qp_ws *cond_ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_COND_AUX_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_cond_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_d_cond_qcqp.h new file mode 100644 index 00000000000000..266567bb8dfeaf --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_cond_qcqp.h @@ -0,0 +1,129 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_COND_QCQP_H_ +#define HPIPM_D_COND_QCQP_H_ + + + +#include +#include + +#include "hpipm_d_dense_qcqp.h" +#include "hpipm_d_dense_qcqp_sol.h" +#include "hpipm_d_ocp_qcqp.h" +#include "hpipm_d_ocp_qcqp_dim.h" +#include "hpipm_d_ocp_qcqp_sol.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_cond_qcqp_arg + { + struct d_cond_qp_arg *qp_arg; + int cond_last_stage; // condense last stage +// int cond_variant; // TODO + int comp_prim_sol; // primal solution (v) + int comp_dual_sol_eq; // dual solution equality constr (pi) + int comp_dual_sol_ineq; // dual solution equality constr (lam t) + int square_root_alg; // square root algorithm (faster but requires RSQ>0) + hpipm_size_t memsize; + }; + + + +struct d_cond_qcqp_ws + { + struct d_cond_qp_ws *qp_ws; + struct blasfeo_dmat *hess_array; // TODO remove + struct blasfeo_dmat *zero_hess; // TODO remove + struct blasfeo_dvec *grad_array; // TODO remove + struct blasfeo_dvec *zero_grad; // TODO remove + struct blasfeo_dvec *tmp_nvc; + struct blasfeo_dvec *tmp_nuxM; + struct blasfeo_dmat *GammaQ; + struct blasfeo_dmat *tmp_DCt; + struct blasfeo_dmat *tmp_nuM_nxM; +// struct blasfeo_dvec *d_qp; +// struct blasfeo_dvec *d_mask_qp; + hpipm_size_t memsize; + }; + + +// +hpipm_size_t d_cond_qcqp_arg_memsize(); +// +void d_cond_qcqp_arg_create(struct d_cond_qcqp_arg *cond_arg, void *mem); +// +void d_cond_qcqp_arg_set_default(struct d_cond_qcqp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 square-root +void d_cond_qcqp_arg_set_ric_alg(int ric_alg, struct d_cond_qcqp_arg *cond_arg); +// condense last stage: 0 last stage disregarded, 1 last stage condensed too +void d_cond_qcqp_arg_set_cond_last_stage(int cond_last_stage, struct d_cond_qcqp_arg *cond_arg); + +// +void d_cond_qcqp_compute_dim(struct d_ocp_qcqp_dim *ocp_dim, struct d_dense_qcqp_dim *dense_dim); +// +hpipm_size_t d_cond_qcqp_ws_memsize(struct d_ocp_qcqp_dim *ocp_dim, struct d_cond_qcqp_arg *cond_arg); +// +void d_cond_qcqp_ws_create(struct d_ocp_qcqp_dim *ocp_dim, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws, void *mem); +// +void d_cond_qcqp_qc(struct d_ocp_qcqp *ocp_qp, struct blasfeo_dmat *Hq2, int *Hq_nzero2, struct blasfeo_dmat *Ct2, struct blasfeo_dvec *d2, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws); +// +void d_cond_qcqp_qc_lhs(struct d_ocp_qcqp *ocp_qp, struct blasfeo_dmat *Hq2, int *Hq_nzero2, struct blasfeo_dmat *Ct2, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws); +// +void d_cond_qcqp_qc_rhs(struct d_ocp_qcqp *ocp_qp, struct blasfeo_dvec *d2, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws); +// +void d_cond_qcqp_cond(struct d_ocp_qcqp *ocp_qp, struct d_dense_qcqp *dense_qp, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws); +// +void d_cond_qcqp_cond_rhs(struct d_ocp_qcqp *ocp_qp, struct d_dense_qcqp *dense_qp, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws); +// +void d_cond_qcqp_cond_lhs(struct d_ocp_qcqp *ocp_qp, struct d_dense_qcqp *dense_qp, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws); +// +void d_cond_qcqp_expand_sol(struct d_ocp_qcqp *ocp_qp, struct d_dense_qcqp_sol *dense_qp_sol, struct d_ocp_qcqp_sol *ocp_qp_sol, struct d_cond_qcqp_arg *cond_arg, struct d_cond_qcqp_ws *cond_ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_COND_QCQP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_core_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_d_core_qp_ipm.h new file mode 100644 index 00000000000000..f39d9a9b507a92 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_core_qp_ipm.h @@ -0,0 +1,101 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_CORE_QP_IPM_ +#define HPIPM_D_CORE_QP_IPM_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct d_core_qp_ipm_workspace + { + double *v; // primal variables + double *pi; // equality constraints multipliers + double *lam; // inequality constraints multipliers + double *t; // inequality constraints slacks + double *t_inv; // inverse of t + double *v_bkp; // backup of primal variables + double *pi_bkp; // backup of equality constraints multipliers + double *lam_bkp; // backup of inequality constraints multipliers + double *t_bkp; // backup of inequality constraints slacks + double *dv; // step in v + double *dpi; // step in pi + double *dlam; // step in lam + double *dt; // step in t + double *res_g; // q-residuals + double *res_b; // b-residuals + double *res_d; // d-residuals + double *res_m; // m-residuals + double *res_m_bkp; // m-residuals + double *Gamma; // Hessian update + double *gamma; // gradient update + double alpha; // step length + double alpha_prim; // step length + double alpha_dual; // step length + double sigma; // centering XXX + double mu; // duality measuere + double mu_aff; // affine duality measuere + double nc_inv; // 1.0/nc, where nc is the total number of inequality constraints + double nc_mask_inv; // 1.0/nc_mask + double lam_min; // min value in lam vector + double t_min; // min value in t vector + double t_min_inv; // inverse of min value in t vector + double tau_min; // min value of barrier parameter + int nv; // number of primal variables + int ne; // number of equality constraints + int nc; // (twice the) number of (two-sided) inequality constraints + int nc_mask; // total number of ineq constr after masking + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam also in solution, or only in Gamma computation + hpipm_size_t memsize; // memory size (in bytes) of workspace + }; + + + +// +hpipm_size_t d_memsize_core_qp_ipm(int nv, int ne, int nc); +// +void d_create_core_qp_ipm(int nv, int ne, int nc, struct d_core_qp_ipm_workspace *workspace, void *mem); +// +void d_core_qp_ipm(struct d_core_qp_ipm_workspace *workspace); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_D_CORE_QP_IPM_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_core_qp_ipm_aux.h b/third_party/acados/include/hpipm/include/hpipm_d_core_qp_ipm_aux.h new file mode 100644 index 00000000000000..30cc824badba3a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_core_qp_ipm_aux.h @@ -0,0 +1,68 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_CORE_QP_IPM_AUX_ +#define HPIPM_S_CORE_QP_IPM_AUX_ + +#ifdef __cplusplus +extern "C" { +#endif + +// +void d_compute_Gamma_gamma_qp(double *res_d, double *res_m, struct d_core_qp_ipm_workspace *rws); +// +void d_compute_gamma_qp(double *res_d, double *res_m, struct d_core_qp_ipm_workspace *rws); +// +void d_compute_lam_t_qp(double *res_d, double *res_m, double *dlam, double *dt, struct d_core_qp_ipm_workspace *rws); +// +void d_compute_alpha_qp(struct d_core_qp_ipm_workspace *rws); +// +void d_update_var_qp(struct d_core_qp_ipm_workspace *rws); +// +void d_compute_mu_aff_qp(struct d_core_qp_ipm_workspace *rws); +// +void d_backup_res_m(struct d_core_qp_ipm_workspace *rws); +// +void d_compute_centering_correction_qp(struct d_core_qp_ipm_workspace *rws); +// +void d_compute_centering_qp(struct d_core_qp_ipm_workspace *rws); +// +void d_compute_tau_min_qp(struct d_core_qp_ipm_workspace *rws); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_S_CORE_QP_IPM_AUX_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp.h new file mode 100644 index 00000000000000..3da57164937a91 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp.h @@ -0,0 +1,199 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_DENSE_QCQP_H_ +#define HPIPM_D_DENSE_QCQP_H_ + + + +#include +#include + +#include "hpipm_d_dense_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qcqp + { + struct d_dense_qcqp_dim *dim; + struct blasfeo_dmat *Hv; // hessian of cost & vector work space + struct blasfeo_dmat *A; // equality constraint matrix + struct blasfeo_dmat *Ct; // inequality constraints matrix + struct blasfeo_dmat *Hq; // hessians of quadratic constraints + struct blasfeo_dvec *gz; // gradient of cost & gradient of slacks + struct blasfeo_dvec *b; // equality constraint vector + struct blasfeo_dvec *d; // inequality constraints vector + struct blasfeo_dvec *d_mask; // inequality constraints mask vector + struct blasfeo_dvec *m; // rhs of complementarity condition + struct blasfeo_dvec *Z; // (diagonal) hessian of slacks + int *idxb; // indices of box constrained variables within [u; x] + int *idxs_rev; // index of soft constraints (reverse storage) + int *Hq_nzero; // for each int, the last 3 bits ...abc, {a,b,c}=0 => {R,S,Q}=0 + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_dense_qcqp_memsize(struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_create(struct d_dense_qcqp_dim *dim, struct d_dense_qcqp *qp, void *memory); + +// +void d_dense_qcqp_set(char *field, void *value, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_H(double *H, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_g(double *g, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_A(double *A, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_b(double *b, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_idxb(int *idxb, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_lb(double *lb, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_lb_mask(double *lb, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_ub(double *ub, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_ub_mask(double *ub, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_C(double *C, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_lg(double *lg, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_lg_mask(double *lg, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_ug(double *ug, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_ug_mask(double *ug, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_Hq(double *Hq, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_gq(double *gq, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_uq(double *uq, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_uq_mask(double *uq, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_idxs(int *idxs, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_idxs_rev(int *idxs_rev, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_Zl(double *Zl, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_Zu(double *Zu, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_zl(double *zl, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_zu(double *zu, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_ls(double *ls, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_ls_mask(double *ls, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_us(double *us, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_set_us_mask(double *us, struct d_dense_qcqp *qp); + +// getters (COLMAJ) + +void d_dense_qcqp_get_H(struct d_dense_qcqp *qp, double *H); +// +void d_dense_qcqp_get_g(struct d_dense_qcqp *qp, double *g); +// +void d_dense_qcqp_get_A(struct d_dense_qcqp *qp, double *A); +// +void d_dense_qcqp_get_b(struct d_dense_qcqp *qp, double *b); +// +void d_dense_qcqp_get_idxb(struct d_dense_qcqp *qp, int *idxb); +// +void d_dense_qcqp_get_lb(struct d_dense_qcqp *qp, double *lb); +// +void d_dense_qcqp_get_lb_mask(struct d_dense_qcqp *qp, double *lb); +// +void d_dense_qcqp_get_ub(struct d_dense_qcqp *qp, double *ub); +// +void d_dense_qcqp_get_ub_mask(struct d_dense_qcqp *qp, double *ub); +// +void d_dense_qcqp_get_C(struct d_dense_qcqp *qp, double *C); +// +void d_dense_qcqp_get_lg(struct d_dense_qcqp *qp, double *lg); +// +void d_dense_qcqp_get_lg_mask(struct d_dense_qcqp *qp, double *lg); +// +void d_dense_qcqp_get_ug(struct d_dense_qcqp *qp, double *ug); +// +void d_dense_qcqp_get_ug_mask(struct d_dense_qcqp *qp, double *ug); +// +void d_dense_qcqp_get_idxs(struct d_dense_qcqp *qp, int *idxs); +// +void d_dense_qcqp_get_idxs_rev(struct d_dense_qcqp *qp, int *idxs_rev); +// +void d_dense_qcqp_get_Zl(struct d_dense_qcqp *qp, double *Zl); +// +void d_dense_qcqp_get_Zu(struct d_dense_qcqp *qp, double *Zu); +// +void d_dense_qcqp_get_zl(struct d_dense_qcqp *qp, double *zl); +// +void d_dense_qcqp_get_zu(struct d_dense_qcqp *qp, double *zu); +// +void d_dense_qcqp_get_ls(struct d_dense_qcqp *qp, double *ls); +// +void d_dense_qcqp_get_ls_mask(struct d_dense_qcqp *qp, double *ls); +// +void d_dense_qcqp_get_us(struct d_dense_qcqp *qp, double *us); +// +void d_dense_qcqp_get_us_mask(struct d_dense_qcqp *qp, double *us); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_DENSE_QCQP_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_dim.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_dim.h new file mode 100644 index 00000000000000..fa8c574a1ef0e2 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_dim.h @@ -0,0 +1,98 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_DENSE_QCQP_DIM_H_ +#define HPIPM_D_DENSE_QCQP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qcqp_dim + { + struct d_dense_qp_dim *qp_dim; // dim of qp approximation + int nv; // number of variables + int ne; // number of equality constraints + int nb; // number of box constraints + int ng; // number of general constraints + int nq; // number of quadratic constraints + int nsb; // number of softened box constraints + int nsg; // number of softened general constraints + int nsq; // number of softened quadratic constraints + int ns; // number of softened constraints (nsb+nsg+nsq) TODO number of slacks + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_dense_qcqp_dim_memsize(); +// +void d_dense_qcqp_dim_create(struct d_dense_qcqp_dim *dim, void *memory); +// +void d_dense_qcqp_dim_set(char *field_name, int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_nv(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_ne(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_nb(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_ng(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_nq(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_nsb(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_nsg(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_nsq(int value, struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_dim_set_ns(int value, struct d_dense_qcqp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_DENSE_QCQP_DIM_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_ipm.h new file mode 100644 index 00000000000000..fa3f98fa79a6ca --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_ipm.h @@ -0,0 +1,193 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_DENSE_QCQP_IPM_H_ +#define HPIPM_D_DENSE_QCQP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qcqp_ipm_arg + { + struct d_dense_qp_ipm_arg *qp_arg; + double mu0; // initial value for duality measure + double alpha_min; // exit cond on step length + double res_g_max; // exit cond on inf norm of residuals + double res_b_max; // exit cond on inf norm of residuals + double res_d_max; // exit cond on inf norm of residuals + double res_m_max; // exit cond on inf norm of residuals + double reg_prim; // reg of primal hessian + double reg_dual; // reg of dual hessian + double lam_min; // min value in lam vector + double t_min; // min value in t vector + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int scale; // scale hessian + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq + int abs_form; // absolute IPM formulation + int comp_res_exit; // compute residuals on exit (only for abs_form==1) + int comp_res_pred; // compute residuals of prediction + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct d_dense_qcqp_ipm_ws + { + struct d_dense_qp_ipm_ws *qp_ws; + struct d_dense_qp *qp; + struct d_dense_qp_sol *qp_sol; + struct d_dense_qcqp_res_ws *qcqp_res_ws; + struct d_dense_qcqp_res *qcqp_res; + struct blasfeo_dvec *tmp_nv; + int iter; // iteration number + int status; + hpipm_size_t memsize; // memory size (in bytes) of workspace + }; + + + +// +hpipm_size_t d_dense_qcqp_ipm_arg_memsize(struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_ipm_arg_create(struct d_dense_qcqp_dim *dim, struct d_dense_qcqp_ipm_arg *arg, void *mem); +// +void d_dense_qcqp_ipm_arg_set_default(enum hpipm_mode mode, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set(char *field, void *value, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_iter_max(int *iter_max, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_alpha_min(double *alpha_min, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_mu0(double *mu0, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_tol_stat(double *tol_stat, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_tol_eq(double *tol_eq, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_tol_ineq(double *tol_ineq, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_tol_comp(double *tol_comp, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_reg_prim(double *reg, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_reg_dual(double *reg, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_warm_start(int *warm_start, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_pred_corr(int *pred_corr, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_cond_pred_corr(int *cond_pred_corr, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_comp_res_pred(int *comp_res_pred, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_comp_res_exit(int *comp_res_exit, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_lam_min(double *value, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_t_min(double *value, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_split_step(int *value, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_arg_set_t_lam_min(int *value, struct d_dense_qcqp_ipm_arg *arg); + +// +hpipm_size_t d_dense_qcqp_ipm_ws_memsize(struct d_dense_qcqp_dim *qp_dim, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_ipm_ws_create(struct d_dense_qcqp_dim *qp_dim, struct d_dense_qcqp_ipm_arg *arg, struct d_dense_qcqp_ipm_ws *ws, void *mem); +// +void d_dense_qcqp_ipm_get(char *field, struct d_dense_qcqp_ipm_ws *ws, void *value); +// +void d_dense_qcqp_ipm_get_status(struct d_dense_qcqp_ipm_ws *ws, int *status); +// +void d_dense_qcqp_ipm_get_iter(struct d_dense_qcqp_ipm_ws *ws, int *iter); +// +void d_dense_qcqp_ipm_get_max_res_stat(struct d_dense_qcqp_ipm_ws *ws, double *res_stat); +// +void d_dense_qcqp_ipm_get_max_res_eq(struct d_dense_qcqp_ipm_ws *ws, double *res_eq); +// +void d_dense_qcqp_ipm_get_max_res_ineq(struct d_dense_qcqp_ipm_ws *ws, double *res_ineq); +// +void d_dense_qcqp_ipm_get_max_res_comp(struct d_dense_qcqp_ipm_ws *ws, double *res_comp); +// +void d_dense_qcqp_ipm_get_stat(struct d_dense_qcqp_ipm_ws *ws, double **stat); +// +void d_dense_qcqp_ipm_get_stat_m(struct d_dense_qcqp_ipm_ws *ws, int *stat_m); +// +void d_dense_qcqp_init_var(struct d_dense_qcqp *qp, struct d_dense_qcqp_sol *qp_sol, struct d_dense_qcqp_ipm_arg *arg, struct d_dense_qcqp_ipm_ws *ws); +// +void d_dense_qcqp_ipm_solve(struct d_dense_qcqp *qp, struct d_dense_qcqp_sol *qp_sol, struct d_dense_qcqp_ipm_arg *arg, struct d_dense_qcqp_ipm_ws *ws); +#if 0 +// +void d_dense_qcqp_ipm_predict(struct d_dense_qcqp *qp, struct d_dense_qcqp_sol *qp_sol, struct d_dense_qcqp_ipm_arg *arg, struct d_dense_qcqp_ipm_ws *ws); +// +void d_dense_qcqp_ipm_sens(struct d_dense_qcqp *qp, struct d_dense_qcqp_sol *qp_sol, struct d_dense_qcqp_ipm_arg *arg, struct d_dense_qcqp_ipm_ws *ws); +#endif + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_DENSE_QCQP_IPM_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_res.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_res.h new file mode 100644 index 00000000000000..a76f16215e3e45 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_res.h @@ -0,0 +1,107 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_DENSE_QCQP_RES_H_ +#define HPIPM_D_DENSE_QCQP_RES_H_ + + + +#include +#include + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qcqp_res + { + struct d_dense_qcqp_dim *dim; + struct blasfeo_dvec *res_g; // q-residuals + struct blasfeo_dvec *res_b; // b-residuals + struct blasfeo_dvec *res_d; // d-residuals + struct blasfeo_dvec *res_m; // m-residuals + double res_max[4]; // infinity norm of residuals + double res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct d_dense_qcqp_res_ws + { + struct blasfeo_dvec *tmp_nv; // work space of size nv + struct blasfeo_dvec *tmp_nbgq; // work space of size nbM+ngM+nqM + struct blasfeo_dvec *tmp_ns; // work space of size nsM + struct blasfeo_dvec *q_fun; // value for evaluation of quadr constr + struct blasfeo_dvec *q_adj; // value for adjoint of quadr constr + int use_q_fun; // reuse cached value for evaluation of quadr constr + int use_q_adj; // reuse cached value for adjoint of quadr constr + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_dense_qcqp_res_memsize(struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_res_create(struct d_dense_qcqp_dim *dim, struct d_dense_qcqp_res *res, void *mem); +// +hpipm_size_t d_dense_qcqp_res_ws_memsize(struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_res_ws_create(struct d_dense_qcqp_dim *dim, struct d_dense_qcqp_res_ws *workspace, void *mem); +// +void d_dense_qcqp_res_compute(struct d_dense_qcqp *qp, struct d_dense_qcqp_sol *qp_sol, struct d_dense_qcqp_res *res, struct d_dense_qcqp_res_ws *ws); +// +void d_dense_qcqp_res_compute_inf_norm(struct d_dense_qcqp_res *res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_DENSE_QCQP_RES_H_ + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_sol.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_sol.h new file mode 100644 index 00000000000000..6c697a8e693b20 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_sol.h @@ -0,0 +1,85 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_DENSE_QCQP_SOL_H_ +#define HPIPM_D_DENSE_QCQP_SOL_H_ + + + +#include +#include + +#include "hpipm_d_dense_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qcqp_sol + { + struct d_dense_qcqp_dim *dim; + struct blasfeo_dvec *v; + struct blasfeo_dvec *pi; + struct blasfeo_dvec *lam; + struct blasfeo_dvec *t; + void *misc; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_dense_qcqp_sol_memsize(struct d_dense_qcqp_dim *dim); +// +void d_dense_qcqp_sol_create(struct d_dense_qcqp_dim *dim, struct d_dense_qcqp_sol *qp_sol, void *memory); +// +void d_dense_qcqp_sol_get_v(struct d_dense_qcqp_sol *qp_sol, double *v); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_DENSE_QCQP_SOL_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_utils.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_utils.h new file mode 100644 index 00000000000000..a34218bae4831a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qcqp_utils.h @@ -0,0 +1,82 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_DENSE_QCQP_UTILS_H_ +#define HPIPM_D_DENSE_QCQP_UTILS_H_ + + + +#include +#include + +#include "hpipm_d_dense_qcqp_dim.h" +#include "hpipm_d_dense_qcqp.h" +#include "hpipm_d_dense_qcqp_sol.h" +//#include "hpipm_d_dense_qcqp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_dense_qcqp_dim_print(struct d_dense_qcqp_dim *qp_dim); +// +//void d_dense_qcqp_dim_codegen(char *file_name, char *mode, struct d_dense_qcqp_dim *qp_dim); +// +void d_dense_qcqp_print(struct d_dense_qcqp_dim *qp_dim, struct d_dense_qcqp *qp); +// +//void d_dense_qcqp_codegen(char *file_name, char *mode, struct d_dense_qcqp_dim *qp_dim, struct d_dense_qcqp *qp); +// +void d_dense_qcqp_sol_print(struct d_dense_qcqp_dim *qp_dim, struct d_dense_qcqp_sol *dense_qcqp_sol); +// +//void d_dense_qcqp_ipm_arg_codegen(char *file_name, char *mode, struct d_dense_qcqp_dim *qp_dim, struct d_dense_qcqp_ipm_arg *arg); +// +void d_dense_qcqp_res_print(struct d_dense_qcqp_dim *qp_dim, struct d_dense_qcqp_res *dense_qcqp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_DENSE_QCQP_UTILS_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qp.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp.h new file mode 100644 index 00000000000000..02fba5a9229a21 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp.h @@ -0,0 +1,207 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_DENSE_QP_H_ +#define HPIPM_D_DENSE_QP_H_ + + + +#include +#include + +#include "hpipm_d_dense_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qp + { + struct d_dense_qp_dim *dim; + struct blasfeo_dmat *Hv; // hessian of cost & vector work space + struct blasfeo_dmat *A; // equality constraint matrix + struct blasfeo_dmat *Ct; // inequality constraints matrix + struct blasfeo_dvec *gz; // gradient of cost & gradient of slacks + struct blasfeo_dvec *b; // equality constraint vector + struct blasfeo_dvec *d; // inequality constraints vector + struct blasfeo_dvec *d_mask; // inequality constraints mask vector + struct blasfeo_dvec *m; // rhs of complementarity condition + struct blasfeo_dvec *Z; // (diagonal) hessian of slacks + int *idxb; // indices of box constrained variables within [u; x] + int *idxs_rev; // index of soft constraints (reverse storage) + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_dense_qp_memsize(struct d_dense_qp_dim *dim); +// +void d_dense_qp_create(struct d_dense_qp_dim *dim, struct d_dense_qp *qp, void *memory); + +// setters - colmaj +// +void d_dense_qp_set_all(double *H, double *g, double *A, double *b, int *idxb, double *d_lb, double *d_ub, double *C, double *d_lg, double *d_ug, double *Zl, double *Zu, double *zl, double *zu, int *idxs, double *d_ls, double *d_us, struct d_dense_qp *qp); +// +void d_dense_qp_get_all(struct d_dense_qp *qp, double *H, double *g, double *A, double *b, int *idxb, double *d_lb, double *d_ub, double *C, double *d_lg, double *d_ug, double *Zl, double *Zu, double *zl, double *zu, int *idxs, double *d_ls, double *d_us); +// +void d_dense_qp_set(char *field, void *value, struct d_dense_qp *qp); +// +void d_dense_qp_set_H(double *H, struct d_dense_qp *qp); +// +void d_dense_qp_set_g(double *g, struct d_dense_qp *qp); +// +void d_dense_qp_set_A(double *A, struct d_dense_qp *qp); +// +void d_dense_qp_set_b(double *b, struct d_dense_qp *qp); +// +void d_dense_qp_set_idxb(int *idxb, struct d_dense_qp *qp); +// +void d_dense_qp_set_Jb(double *Jb, struct d_dense_qp *qp); +// +void d_dense_qp_set_lb(double *lb, struct d_dense_qp *qp); +// +void d_dense_qp_set_lb_mask(double *lb, struct d_dense_qp *qp); +// +void d_dense_qp_set_ub(double *ub, struct d_dense_qp *qp); +// +void d_dense_qp_set_ub_mask(double *ub, struct d_dense_qp *qp); +// +void d_dense_qp_set_C(double *C, struct d_dense_qp *qp); +// +void d_dense_qp_set_lg(double *lg, struct d_dense_qp *qp); +// +void d_dense_qp_set_lg_mask(double *lg, struct d_dense_qp *qp); +// +void d_dense_qp_set_ug(double *ug, struct d_dense_qp *qp); +// +void d_dense_qp_set_ug_mask(double *ug, struct d_dense_qp *qp); +// +void d_dense_qp_set_idxs(int *idxs, struct d_dense_qp *qp); +// +void d_dense_qp_set_idxs_rev(int *idxs_rev, struct d_dense_qp *qp); +// +void d_dense_qp_set_Jsb(double *Jsb, struct d_dense_qp *qp); +// +void d_dense_qp_set_Jsg(double *Jsg, struct d_dense_qp *qp); +// +void d_dense_qp_set_Zl(double *Zl, struct d_dense_qp *qp); +// +void d_dense_qp_set_Zu(double *Zu, struct d_dense_qp *qp); +// +void d_dense_qp_set_zl(double *zl, struct d_dense_qp *qp); +// +void d_dense_qp_set_zu(double *zu, struct d_dense_qp *qp); +// +void d_dense_qp_set_ls(double *ls, struct d_dense_qp *qp); +// +void d_dense_qp_set_ls_mask(double *ls, struct d_dense_qp *qp); +// +void d_dense_qp_set_us(double *us, struct d_dense_qp *qp); +// +void d_dense_qp_set_us_mask(double *us, struct d_dense_qp *qp); + +// getters - colmaj +// +void d_dense_qp_get_H(struct d_dense_qp *qp, double *H); +// +void d_dense_qp_get_g(struct d_dense_qp *qp, double *g); +// +void d_dense_qp_get_A(struct d_dense_qp *qp, double *A); +// +void d_dense_qp_get_b(struct d_dense_qp *qp, double *b); +// +void d_dense_qp_get_idxb(struct d_dense_qp *qp, int *idxb); +// +void d_dense_qp_get_lb(struct d_dense_qp *qp, double *lb); +// +void d_dense_qp_get_lb_mask(struct d_dense_qp *qp, double *lb); +// +void d_dense_qp_get_ub(struct d_dense_qp *qp, double *ub); +// +void d_dense_qp_get_ub_mask(struct d_dense_qp *qp, double *ub); +// +void d_dense_qp_get_C(struct d_dense_qp *qp, double *C); +// +void d_dense_qp_get_lg(struct d_dense_qp *qp, double *lg); +// +void d_dense_qp_get_lg_mask(struct d_dense_qp *qp, double *lg); +// +void d_dense_qp_get_ug(struct d_dense_qp *qp, double *ug); +// +void d_dense_qp_get_ug_mask(struct d_dense_qp *qp, double *ug); +// +void d_dense_qp_get_idxs(struct d_dense_qp *qp, int *idxs); +// +void d_dense_qp_get_idxs_rev(struct d_dense_qp *qp, int *idxs_rev); +// +void d_dense_qp_get_Zl(struct d_dense_qp *qp, double *Zl); +// +void d_dense_qp_get_Zu(struct d_dense_qp *qp, double *Zu); +// +void d_dense_qp_get_zl(struct d_dense_qp *qp, double *zl); +// +void d_dense_qp_get_zu(struct d_dense_qp *qp, double *zu); +// +void d_dense_qp_get_ls(struct d_dense_qp *qp, double *ls); +// +void d_dense_qp_get_ls_mask(struct d_dense_qp *qp, double *ls); +// +void d_dense_qp_get_us(struct d_dense_qp *qp, double *us); +// +void d_dense_qp_get_us_mask(struct d_dense_qp *qp, double *us); + +// setters - rowmaj +// +void d_dense_qp_set_all_rowmaj(double *H, double *g, double *A, double *b, int *idxb, double *d_lb, double *d_ub, double *C, double *d_lg, double *d_ug, double *Zl, double *Zu, double *zl, double *zu, int *idxs, double *d_ls, double *d_us, struct d_dense_qp *qp); + +// getters - rowmaj +// +void d_dense_qp_get_all_rowmaj(struct d_dense_qp *qp, double *H, double *g, double *A, double *b, int *idxb, double *d_lb, double *d_ub, double *C, double *d_lg, double *d_ug, double *Zl, double *Zu, double *zl, double *zu, int *idxs, double *d_ls, double *d_us); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_DENSE_QP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_dim.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_dim.h new file mode 100644 index 00000000000000..98a551f31258bf --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_dim.h @@ -0,0 +1,92 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_DENSE_QP_DIM_H_ +#define HPIPM_D_DENSE_QP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qp_dim + { + int nv; // number of variables + int ne; // number of equality constraints + int nb; // number of box constraints + int ng; // number of general constraints + int nsb; // number of softened box constraints + int nsg; // number of softened general constraints + int ns; // number of softened constraints (nsb+nsg) + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_dense_qp_dim_memsize(); +// +void d_dense_qp_dim_create(struct d_dense_qp_dim *qp_dim, void *memory); +// +void d_dense_qp_dim_set_all(int nv, int ne, int nb, int ng, int nsb, int nsg, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set(char *field_name, int value, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set_nv(int value, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set_ne(int value, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set_nb(int value, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set_ng(int value, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set_nsb(int value, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set_nsg(int value, struct d_dense_qp_dim *dim); +// +void d_dense_qp_dim_set_ns(int value, struct d_dense_qp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_DENSE_QP_DIM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_ipm.h new file mode 100644 index 00000000000000..e6e5d5d9b5b89a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_ipm.h @@ -0,0 +1,260 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_DENSE_QP_IPM_H_ +#define HPIPM_D_DENSE_QP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qp_ipm_arg + { + double mu0; // initial value for duality measure + double alpha_min; // exit cond on step length + double res_g_max; // exit cond on inf norm of residuals + double res_b_max; // exit cond on inf norm of residuals + double res_d_max; // exit cond on inf norm of residuals + double res_m_max; // exit cond on inf norm of residuals + double reg_prim; // reg of primal hessian + double reg_dual; // reg of dual hessian + double lam_min; // min value in lam vector + double t_min; // min value in t vector + double tau_min; // min value of barrier parameter + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int scale; // scale hessian + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq + int abs_form; // absolute IPM formulation + int comp_res_exit; // compute residuals on exit (only for abs_form==1) + int comp_res_pred; // compute residuals of prediction + int kkt_fact_alg; // 0 null-space, 1 schur-complement + int remove_lin_dep_eq; // 0 do not, 1 do check and remove linearly dependent equality constraints + int compute_obj; // compute obj on exit + int split_step; // use different steps for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct d_dense_qp_ipm_ws + { + struct d_core_qp_ipm_workspace *core_workspace; + struct d_dense_qp_res_ws *res_ws; + struct d_dense_qp_sol *sol_step; + struct d_dense_qp_sol *sol_itref; + struct d_dense_qp *qp_step; + struct d_dense_qp *qp_itref; + struct d_dense_qp_res *res; + struct d_dense_qp_res *res_itref; + struct d_dense_qp_res *res_step; + struct blasfeo_dvec *Gamma; // + struct blasfeo_dvec *gamma; // + struct blasfeo_dvec *Zs_inv; // + struct blasfeo_dmat *Lv; // + struct blasfeo_dmat *AL; // + struct blasfeo_dmat *Le; // + struct blasfeo_dmat *Ctx; // + struct blasfeo_dvec *lv; // + struct blasfeo_dvec *sv; // scale for Lv + struct blasfeo_dvec *se; // scale for Le + struct blasfeo_dvec *tmp_nbg; // work space of size nb+ng + struct blasfeo_dvec *tmp_ns; // work space of size ns + struct blasfeo_dmat *lq0; + struct blasfeo_dmat *lq1; + struct blasfeo_dvec *tmp_m; + struct blasfeo_dmat *A_LQ; + struct blasfeo_dmat *A_Q; + struct blasfeo_dmat *Zt; + struct blasfeo_dmat *ZtH; + struct blasfeo_dmat *ZtHZ; + struct blasfeo_dvec *xy; + struct blasfeo_dvec *Yxy; + struct blasfeo_dvec *xz; + struct blasfeo_dvec *tmp_nv; + struct blasfeo_dvec *tmp_2ns; + struct blasfeo_dvec *tmp_nv2ns; + struct blasfeo_dmat *A_li; // A of linearly independent equality constraints + struct blasfeo_dvec *b_li; // b of linearly independent equality constraints + struct blasfeo_dmat *A_bkp; // pointer to backup A + struct blasfeo_dvec *b_bkp; // pointer to backup b + struct blasfeo_dmat *Ab_LU; + double *stat; // convergence statistics + int *ipiv_v; + int *ipiv_e; + int *ipiv_e1; + void *lq_work0; + void *lq_work1; + void *lq_work_null; + void *orglq_work_null; + int iter; // iteration number + int stat_max; // iterations saved in stat + int stat_m; // numer of recorded stat per ipm iter + int scale; + int use_hess_fact; + int use_A_fact; + int status; + int lq_fact; // cache from arg + int mask_constr; // use constr mask + int ne_li; // number of linearly independent equality constraints + int ne_bkp; // ne backup + hpipm_size_t memsize; // memory size (in bytes) of workspace + }; + + + +// +hpipm_size_t d_dense_qp_ipm_arg_memsize(struct d_dense_qp_dim *dim); +// +void d_dense_qp_ipm_arg_create(struct d_dense_qp_dim *dim, struct d_dense_qp_ipm_arg *arg, void *mem); +// +void d_dense_qp_ipm_arg_set_default(enum hpipm_mode mode, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set(char *field, void *value, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_iter_max(int *iter_max, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_alpha_min(double *alpha_min, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_mu0(double *mu0, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_tol_stat(double *tol_stat, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_tol_eq(double *tol_eq, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_tol_ineq(double *tol_ineq, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_tol_comp(double *tol_comp, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_reg_prim(double *reg, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_reg_dual(double *reg, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_warm_start(int *warm_start, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_pred_corr(int *pred_corr, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_cond_pred_corr(int *cond_pred_corr, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_comp_res_pred(int *comp_res_pred, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_comp_res_exit(int *comp_res_exit, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_lam_min(double *value, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_t_min(double *value, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_tau_min(double *value, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_kkt_fact_alg(int *value, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_remove_lin_dep_eq(int *value, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_compute_obj(int *value, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_arg_set_t_lam_min(int *value, struct d_dense_qp_ipm_arg *arg); + +// +void d_dense_qp_ipm_arg_set_split_step(int *value, struct d_dense_qp_ipm_arg *arg); + +// +hpipm_size_t d_dense_qp_ipm_ws_memsize(struct d_dense_qp_dim *qp_dim, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_ipm_ws_create(struct d_dense_qp_dim *qp_dim, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws, void *mem); +// +void d_dense_qp_ipm_get(char *field, struct d_dense_qp_ipm_ws *ws, void *value); +// +void d_dense_qp_ipm_get_status(struct d_dense_qp_ipm_ws *ws, int *status); +// +void d_dense_qp_ipm_get_iter(struct d_dense_qp_ipm_ws *ws, int *iter); +// +void d_dense_qp_ipm_get_max_res_stat(struct d_dense_qp_ipm_ws *ws, double *res_stat); +// +void d_dense_qp_ipm_get_max_res_eq(struct d_dense_qp_ipm_ws *ws, double *res_eq); +// +void d_dense_qp_ipm_get_max_res_ineq(struct d_dense_qp_ipm_ws *ws, double *res_ineq); +// +void d_dense_qp_ipm_get_max_res_comp(struct d_dense_qp_ipm_ws *ws, double *res_comp); +// +void d_dense_qp_ipm_get_stat(struct d_dense_qp_ipm_ws *ws, double **stat); +// +void d_dense_qp_ipm_get_stat_m(struct d_dense_qp_ipm_ws *ws, int *stat_m); +// +void d_dense_qp_init_var(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_ipm_abs_step(int kk, struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_ipm_delta_step(int kk, struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_ipm_solve(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_ipm_predict(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_ipm_sens(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_compute_step_length(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_DENSE_QP_IPM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_kkt.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_kkt.h new file mode 100644 index 00000000000000..6d05779f4bab57 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_kkt.h @@ -0,0 +1,72 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_DENSE_QP_KKT_H_ +#define HPIPM_D_DENSE_QP_KKT_H_ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_fact_solve_kkt_unconstr_dense_qp(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_fact_solve_kkt_step_dense_qp(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_fact_lq_solve_kkt_step_dense_qp(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_solve_kkt_step_dense_qp(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_remove_lin_dep_eq(struct d_dense_qp *qp, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_restore_lin_dep_eq(struct d_dense_qp *qp, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); +// +void d_dense_qp_compute_obj(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_ipm_arg *arg, struct d_dense_qp_ipm_ws *ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_DENSE_QP_KKT_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_res.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_res.h new file mode 100644 index 00000000000000..7c2023257a3c18 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_res.h @@ -0,0 +1,105 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_DENSE_QP_RES_H_ +#define HPIPM_D_DENSE_QP_RES_H_ + + + +#include +#include + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qp_res + { + struct d_dense_qp_dim *dim; + struct blasfeo_dvec *res_g; // q-residuals + struct blasfeo_dvec *res_b; // b-residuals + struct blasfeo_dvec *res_d; // d-residuals + struct blasfeo_dvec *res_m; // m-residuals + double res_max[4]; // max of residuals + double res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct d_dense_qp_res_ws + { + struct blasfeo_dvec *tmp_nbg; // work space of size nbM+ngM + struct blasfeo_dvec *tmp_ns; // work space of size nsM + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_dense_qp_res_memsize(struct d_dense_qp_dim *dim); +// +void d_dense_qp_res_create(struct d_dense_qp_dim *dim, struct d_dense_qp_res *res, void *mem); +// +hpipm_size_t d_dense_qp_res_ws_memsize(struct d_dense_qp_dim *dim); +// +void d_dense_qp_res_ws_create(struct d_dense_qp_dim *dim, struct d_dense_qp_res_ws *workspace, void *mem); +// +void d_dense_qp_res_compute(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_res *res, struct d_dense_qp_res_ws *ws); +// +void d_dense_qp_res_compute_lin(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_dense_qp_sol *qp_step, struct d_dense_qp_res *res, struct d_dense_qp_res_ws *ws); +// +void d_dense_qp_res_compute_inf_norm(struct d_dense_qp_res *res); +// +void d_dense_qp_res_get_all(struct d_dense_qp_res *res, double *res_g, double *res_ls, double *res_us, double *res_b, double *res_d_lb, double *res_d_ub, double *res_d_lg, double *res_d_ug, double *res_d_ls, double *res_d_us, double *res_m_lb, double *res_m_ub, double *res_m_lg, double *res_m_ug, double *res_m_ls, double *res_m_us); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_DENSE_QP_RES_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_sol.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_sol.h new file mode 100644 index 00000000000000..aaa3fdb0e4904a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_sol.h @@ -0,0 +1,94 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_DENSE_QP_SOL_H_ +#define HPIPM_D_DENSE_QP_SOL_H_ + + + +#include +#include + +#include "hpipm_d_dense_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_dense_qp_sol + { + struct d_dense_qp_dim *dim; + struct blasfeo_dvec *v; + struct blasfeo_dvec *pi; + struct blasfeo_dvec *lam; + struct blasfeo_dvec *t; + void *misc; + double obj; + int valid_obj; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_dense_qp_sol_memsize(struct d_dense_qp_dim *dim); +// +void d_dense_qp_sol_create(struct d_dense_qp_dim *dim, struct d_dense_qp_sol *qp_sol, void *memory); +// +void d_dense_qp_sol_get_all(struct d_dense_qp_sol *qp_sol, double *v, double *ls, double *us, double *pi, double *lam_lb, double *lam_ub, double *lam_lg, double *lam_ug, double *lam_ls, double *lam_us); +// +void d_dense_qp_sol_get(char *field, struct d_dense_qp_sol *sol, void *value); +// +void d_dense_qp_sol_get_v(struct d_dense_qp_sol *sol, double *v); +// +void d_dense_qp_sol_get_valid_obj(struct d_dense_qp_sol *sol, int *valid_obj); +// +void d_dense_qp_sol_get_obj(struct d_dense_qp_sol *sol, double *obj); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_DENSE_QP_SOL_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_utils.h b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_utils.h new file mode 100644 index 00000000000000..ccb77aaca3cee7 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_dense_qp_utils.h @@ -0,0 +1,83 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_DENSE_QP_UTILS_H_ +#define HPIPM_D_DENSE_QP_UTILS_H_ + + + +#include +#include + +#include "hpipm_d_dense_qp_dim.h" +#include "hpipm_d_dense_qp.h" +#include "hpipm_d_dense_qp_sol.h" +#include "hpipm_d_dense_qp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_dense_qp_dim_print(struct d_dense_qp_dim *qp_dim); +// +//void d_dense_qp_dim_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim); +// +void d_dense_qp_print(struct d_dense_qp_dim *qp_dim, struct d_dense_qp *qp); +// +//void d_dense_qp_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim, struct d_dense_qp *qp); +// +void d_dense_qp_sol_print(struct d_dense_qp_dim *qp_dim, struct d_dense_qp_sol *dense_qp_sol); +// +//void d_dense_qp_ipm_arg_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim, struct d_dense_qp_ipm_arg *arg); +// +void d_dense_qp_res_print(struct d_dense_qp_dim *qp_dim, struct d_dense_qp_res *dense_qp_res); +// +void d_dense_qp_arg_print(struct d_dense_qp_dim *qp_dim, struct d_dense_qp_ipm_arg *qp_ipm_arg); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_DENSE_QP_UTILS_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp.h new file mode 100644 index 00000000000000..240c9b04be7578 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp.h @@ -0,0 +1,303 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QCQP_H_ +#define HPIPM_D_OCP_QCQP_H_ + + + +#include +#include + +#include "hpipm_d_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qcqp + { + struct d_ocp_qcqp_dim *dim; + struct blasfeo_dmat *BAbt; // dynamics matrix & vector work space + struct blasfeo_dmat *RSQrq; // hessian of cost & vector work space + struct blasfeo_dmat *DCt; // inequality constraints matrix + struct blasfeo_dmat **Hq; // hessians of quadratic constraints + struct blasfeo_dvec *b; // dynamics vector + struct blasfeo_dvec *rqz; // gradient of cost & gradient of slacks + struct blasfeo_dvec *d; // inequality constraints vector + struct blasfeo_dvec *d_mask; // inequality constraints mask vector + struct blasfeo_dvec *m; // rhs of complementarity condition + struct blasfeo_dvec *Z; // (diagonal) hessian of slacks + int **idxb; // indices of box constrained variables within [u; x] + int **idxs_rev; // index of soft constraints (reverse storage) + int **Hq_nzero; // for each int, the last 3 bits ...abc, {a,b,c}=0 => {R,S,Q}=0 + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_ocp_qcqp_strsize(); +// +hpipm_size_t d_ocp_qcqp_memsize(struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_create(struct d_ocp_qcqp_dim *dim, struct d_ocp_qcqp *qp, void *memory); +// +void d_ocp_qcqp_copy_all(struct d_ocp_qcqp *qp_orig, struct d_ocp_qcqp *qp_dest); + +// setters +// +void d_ocp_qcqp_set_all_zero(struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_rhs_zero(struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set(char *field_name, int stage, void *value, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_el(char *field_name, int stage, int index, void *value, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_A(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_B(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_b(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Q(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_S(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_R(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_q(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_r(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lb(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lb_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ub(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ub_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lbx(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lbx_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_el_lbx(int stage, int index, double *elem, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ubx(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ubx_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_el_ubx(int stage, int index, double *elem, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lbu(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lbu_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ubu(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ubu_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_idxb(int stage, int *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_idxbx(int stage, int *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Jbx(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_idxbu(int stage, int *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Jbu(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_C(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_D(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lg(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lg_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ug(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_ug_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Qq(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Sq(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Rq(int stage, double *mat, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_qq(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_rq(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_uq(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_uq_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Zl(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Zu(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_zl(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_zu(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lls(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lls_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lus(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_lus_mask(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_idxs(int stage, int *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_idxs_rev(int stage, int *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Jsbu(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Jsbx(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Jsg(int stage, double *vec, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_set_Jsq(int stage, double *vec, struct d_ocp_qcqp *qp); + +// getters +// +void d_ocp_qcqp_get(char *field, int stage, struct d_ocp_qcqp *qp, void *value); +// +void d_ocp_qcqp_get_A(int stage, struct d_ocp_qcqp *qp, double *mat); +// +void d_ocp_qcqp_get_B(int stage, struct d_ocp_qcqp *qp, double *mat); +// +void d_ocp_qcqp_get_b(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_Q(int stage, struct d_ocp_qcqp *qp, double *mat); +// +void d_ocp_qcqp_get_S(int stage, struct d_ocp_qcqp *qp, double *mat); +// +void d_ocp_qcqp_get_R(int stage, struct d_ocp_qcqp *qp, double *mat); +// +void d_ocp_qcqp_get_q(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_r(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ub(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ub_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lb(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lb_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lbx(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lbx_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ubx(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ubx_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lbu(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lbu_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ubu(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ubu_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_idxb(int stage, struct d_ocp_qcqp *qp, int *vec); +// +//void d_ocp_qcqp_get_idxbx(int stage, struct d_ocp_qcqp *qp, int *vec); +// +//void d_ocp_qcqp_get_Jbx(int stage, struct d_ocp_qcqp *qp, double *vec); +// +//void d_ocp_qcqp_get_idxbu(int stage, struct d_ocp_qcqp *qp, int *vec); +// +//void d_ocp_qcqp_get_Jbu(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_C(int stage, struct d_ocp_qcqp *qp, double *mat); +// +void d_ocp_qcqp_get_D(int stage, struct d_ocp_qcqp *qp, double *mat); +// +void d_ocp_qcqp_get_lg(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lg_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ug(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_ug_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_Zl(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_Zu(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_zl(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_zu(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lls(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lls_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lus(int stage, struct d_ocp_qcqp *qp, double *vec); +// +void d_ocp_qcqp_get_lus_mask(int stage, struct d_ocp_qcqp *qp, double *vec); +// XXX only valid if there is one slack per softed constraint !!! +void d_ocp_qcqp_get_idxs(int stage, struct d_ocp_qcqp *qp, int *vec); +// +void d_ocp_qcqp_get_idxs_rev(int stage, struct d_ocp_qcqp *qp, int *vec); +// +//void d_ocp_qcqp_get_Jsbu(int stage, struct d_ocp_qcqp *qp, float *vec); +// +//void d_ocp_qcqp_get_Jsbx(int stage, struct d_ocp_qcqp *qp, float *vec); +// +//void d_ocp_qcqp_get_Jsg(int stage, struct d_ocp_qcqp *qp, float *vec); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QCQP_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_dim.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_dim.h new file mode 100644 index 00000000000000..268628a2b2bfc5 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_dim.h @@ -0,0 +1,118 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QCQP_DIM_H_ +#define HPIPM_D_OCP_QCQP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qcqp_dim + { + struct d_ocp_qp_dim *qp_dim; // dim of qp approximation + int *nx; // number of states + int *nu; // number of inputs + int *nb; // number of box constraints + int *nbx; // number of (two-sided) state box constraints + int *nbu; // number of (two-sided) input box constraints + int *ng; // number of (two-sided) general constraints + int *nq; // number of (upper) quadratic constraints + int *ns; // number of soft constraints + int *nsbx; // number of (two-sided) soft state box constraints + int *nsbu; // number of (two-sided) soft input box constraints + int *nsg; // number of (two-sided) soft general constraints + int *nsq; // number of (upper) soft quadratic constraints + int N; // horizon length + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_ocp_qcqp_dim_strsize(); +// +hpipm_size_t d_ocp_qcqp_dim_memsize(int N); +// +void d_ocp_qcqp_dim_create(int N, struct d_ocp_qcqp_dim *qp_dim, void *memory); +// +void d_ocp_qcqp_dim_copy_all(struct d_ocp_qcqp_dim *dim_orig, struct d_ocp_qcqp_dim *dim_dest); +// +void d_ocp_qcqp_dim_set(char *field, int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nx(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nu(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nbx(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nbu(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_ng(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nq(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_ns(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nsbx(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nsbu(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nsg(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_set_nsq(int stage, int value, struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_dim_get(struct d_ocp_qcqp_dim *dim, char *field, int stage, int *value); +// +void d_ocp_qcqp_dim_get_N(struct d_ocp_qcqp_dim *dim, int *value); +// +void d_ocp_qcqp_dim_get_nx(struct d_ocp_qcqp_dim *dim, int stage, int *value); +// +void d_ocp_qcqp_dim_get_nu(struct d_ocp_qcqp_dim *dim, int stage, int *value); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QCQP_DIM_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_ipm.h new file mode 100644 index 00000000000000..99f2329dcc3f16 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_ipm.h @@ -0,0 +1,190 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QCQP_IPM_H_ +#define HPIPM_D_OCP_QCQP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qcqp_ipm_arg + { + struct d_ocp_qp_ipm_arg *qp_arg; + double mu0; // initial value for complementarity slackness + double alpha_min; // exit cond on step length + double res_g_max; // exit cond on inf norm of residuals + double res_b_max; // exit cond on inf norm of residuals + double res_d_max; // exit cond on inf norm of residuals + double res_m_max; // exit cond on inf norm of residuals + double reg_prim; // reg of primal hessian + double lam_min; // min value in lam vector + double t_min; // min value in t vector + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int square_root_alg; // 0 classical Riccati, 1 square-root Riccati + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq (for square_root_alg==1) + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution of equality constrains (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol_eq==1) + int comp_res_pred; // compute residuals of prediction + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct d_ocp_qcqp_ipm_ws + { + struct d_ocp_qp_ipm_ws *qp_ws; + struct d_ocp_qp *qp; + struct d_ocp_qp_sol *qp_sol; + struct d_ocp_qcqp_res_ws *qcqp_res_ws; + struct d_ocp_qcqp_res *qcqp_res; + struct blasfeo_dvec *tmp_nuxM; + int iter; // iteration number + int status; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_ocp_qcqp_ipm_arg_strsize(); +// +hpipm_size_t d_ocp_qcqp_ipm_arg_memsize(struct d_ocp_qcqp_dim *ocp_dim); +// +void d_ocp_qcqp_ipm_arg_create(struct d_ocp_qcqp_dim *ocp_dim, struct d_ocp_qcqp_ipm_arg *arg, void *mem); +// +void d_ocp_qcqp_ipm_arg_set_default(enum hpipm_mode mode, struct d_ocp_qcqp_ipm_arg *arg); +// +void d_ocp_qcqp_ipm_arg_set(char *field, void *value, struct d_ocp_qcqp_ipm_arg *arg); +// set maximum number of iterations +void d_ocp_qcqp_ipm_arg_set_iter_max(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// set minimum step lenght +void d_ocp_qcqp_ipm_arg_set_alpha_min(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// set initial value of barrier parameter +void d_ocp_qcqp_ipm_arg_set_mu0(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on stationarity condition +void d_ocp_qcqp_ipm_arg_set_tol_stat(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on equality constr +void d_ocp_qcqp_ipm_arg_set_tol_eq(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on inequality constr +void d_ocp_qcqp_ipm_arg_set_tol_ineq(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on complementarity condition +void d_ocp_qcqp_ipm_arg_set_tol_comp(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// set regularization of primal variables +void d_ocp_qcqp_ipm_arg_set_reg_prim(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// set warm start: 0 no warm start, 1 primal var +void d_ocp_qcqp_ipm_arg_set_warm_start(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// Mehrotra's predictor-corrector IPM algorithm: 0 no predictor-corrector, 1 use predictor-corrector +void d_ocp_qcqp_ipm_arg_set_pred_corr(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// conditional predictor-corrector: 0 no conditinal predictor-corrector, 1 conditional predictor-corrector +void d_ocp_qcqp_ipm_arg_set_cond_pred_corr(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// set riccati algorithm: 0 classic, 1 square-root +void d_ocp_qcqp_ipm_arg_set_ric_alg(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// compute residuals after solution +void d_ocp_qcqp_ipm_arg_set_comp_res_exit(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// compute residuals of prediction +void d_ocp_qcqp_ipm_arg_set_comp_res_pred(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// min value of lam in the solution +void d_ocp_qcqp_ipm_arg_set_lam_min(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// min value of t in the solution +void d_ocp_qcqp_ipm_arg_set_t_min(double *value, struct d_ocp_qcqp_ipm_arg *arg); +// use different step for primal and dual variables +void d_ocp_qcqp_ipm_arg_set_split_step(int *value, struct d_ocp_qcqp_ipm_arg *arg); +// clip t and lam: 0 no, 1 in Gamma computation, 2 in solution +void d_ocp_qcqp_ipm_arg_set_t_lam_min(int *value, struct d_ocp_qcqp_ipm_arg *arg); + +// +hpipm_size_t d_ocp_qcqp_ipm_ws_strsize(); +// +hpipm_size_t d_ocp_qcqp_ipm_ws_memsize(struct d_ocp_qcqp_dim *ocp_dim, struct d_ocp_qcqp_ipm_arg *arg); +// +void d_ocp_qcqp_ipm_ws_create(struct d_ocp_qcqp_dim *ocp_dim, struct d_ocp_qcqp_ipm_arg *arg, struct d_ocp_qcqp_ipm_ws *ws, void *mem); +// +void d_ocp_qcqp_ipm_get(char *field, struct d_ocp_qcqp_ipm_ws *ws, void *value); +// +void d_ocp_qcqp_ipm_get_status(struct d_ocp_qcqp_ipm_ws *ws, int *status); +// +void d_ocp_qcqp_ipm_get_iter(struct d_ocp_qcqp_ipm_ws *ws, int *iter); +// +void d_ocp_qcqp_ipm_get_max_res_stat(struct d_ocp_qcqp_ipm_ws *ws, double *res_stat); +// +void d_ocp_qcqp_ipm_get_max_res_eq(struct d_ocp_qcqp_ipm_ws *ws, double *res_eq); +// +void d_ocp_qcqp_ipm_get_max_res_ineq(struct d_ocp_qcqp_ipm_ws *ws, double *res_ineq); +// +void d_ocp_qcqp_ipm_get_max_res_comp(struct d_ocp_qcqp_ipm_ws *ws, double *res_comp); +// +void d_ocp_qcqp_ipm_get_stat(struct d_ocp_qcqp_ipm_ws *ws, double **stat); +// +void d_ocp_qcqp_ipm_get_stat_m(struct d_ocp_qcqp_ipm_ws *ws, int *stat_m); +// +void d_ocp_qcqp_init_var(struct d_ocp_qcqp *qp, struct d_ocp_qcqp_sol *qp_sol, struct d_ocp_qcqp_ipm_arg *arg, struct d_ocp_qcqp_ipm_ws *ws); +// +void d_ocp_qcqp_ipm_solve(struct d_ocp_qcqp *qp, struct d_ocp_qcqp_sol *qp_sol, struct d_ocp_qcqp_ipm_arg *arg, struct d_ocp_qcqp_ipm_ws *ws); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_OCP_QCQP_IPM_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_res.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_res.h new file mode 100644 index 00000000000000..077f134677a2cc --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_res.h @@ -0,0 +1,114 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QCQP_RES_H_ +#define HPIPM_D_OCP_QCQP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qcqp_res + { + struct d_ocp_qcqp_dim *dim; + struct blasfeo_dvec *res_g; // q-residuals + struct blasfeo_dvec *res_b; // b-residuals + struct blasfeo_dvec *res_d; // d-residuals + struct blasfeo_dvec *res_m; // m-residuals + double res_max[4]; // max of residuals + double res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct d_ocp_qcqp_res_ws + { + struct blasfeo_dvec *tmp_nuxM; // work space of size nuM+nxM + struct blasfeo_dvec *tmp_nbgqM; // work space of size nbM+ngM+nqM + struct blasfeo_dvec *tmp_nsM; // work space of size nsM + struct blasfeo_dvec *q_fun; // value for evaluation of quadr constr + struct blasfeo_dvec *q_adj; // value for adjoint of quadr constr + int use_q_fun; // reuse cached value for evaluation of quadr constr + int use_q_adj; // reuse cached value for adjoint of quadr constr + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_ocp_qcqp_res_memsize(struct d_ocp_qcqp_dim *ocp_dim); +// +void d_ocp_qcqp_res_create(struct d_ocp_qcqp_dim *ocp_dim, struct d_ocp_qcqp_res *res, void *mem); +// +hpipm_size_t d_ocp_qcqp_res_ws_memsize(struct d_ocp_qcqp_dim *ocp_dim); +// +void d_ocp_qcqp_res_ws_create(struct d_ocp_qcqp_dim *ocp_dim, struct d_ocp_qcqp_res_ws *workspace, void *mem); +// +void d_ocp_qcqp_res_compute(struct d_ocp_qcqp *qp, struct d_ocp_qcqp_sol *qp_sol, struct d_ocp_qcqp_res *res, struct d_ocp_qcqp_res_ws *ws); +// +void d_ocp_qcqp_res_compute_inf_norm(struct d_ocp_qcqp_res *res); +// +void d_ocp_qcqp_res_get_max_res_stat(struct d_ocp_qcqp_res *res, double *value); +// +void d_ocp_qcqp_res_get_max_res_eq(struct d_ocp_qcqp_res *res, double *value); +// +void d_ocp_qcqp_res_get_max_res_ineq(struct d_ocp_qcqp_res *res, double *value); +// +void d_ocp_qcqp_res_get_max_res_comp(struct d_ocp_qcqp_res *res, double *value); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_OCP_QCQP_RES_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_sol.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_sol.h new file mode 100644 index 00000000000000..68adbfce2d0296 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_sol.h @@ -0,0 +1,114 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QCQP_SOL_H_ +#define HPIPM_D_OCP_QCQP_SOL_H_ + + + +#include +#include + +#include "hpipm_d_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qcqp_sol + { + struct d_ocp_qcqp_dim *dim; + struct blasfeo_dvec *ux; + struct blasfeo_dvec *pi; + struct blasfeo_dvec *lam; + struct blasfeo_dvec *t; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_ocp_qcqp_sol_strsize(); +// +hpipm_size_t d_ocp_qcqp_sol_memsize(struct d_ocp_qcqp_dim *dim); +// +void d_ocp_qcqp_sol_create(struct d_ocp_qcqp_dim *dim, struct d_ocp_qcqp_sol *qp_sol, void *memory); +// +void d_ocp_qcqp_sol_copy_all(struct d_ocp_qcqp_sol *qp_sol_orig, struct d_ocp_qcqp_sol *qp_sol_dest); +// +void d_ocp_qcqp_sol_get(char *field, int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_u(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_x(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_sl(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_su(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_pi(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_lam_lb(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_lam_ub(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_lam_lg(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_get_lam_ug(int stage, struct d_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_ocp_qcqp_sol_set(char *field, int stage, double *vec, struct d_ocp_qcqp_sol *qp_sol); +// +void d_ocp_qcqp_sol_set_u(int stage, double *vec, struct d_ocp_qcqp_sol *qp_sol); +// +void d_ocp_qcqp_sol_set_x(int stage, double *vec, struct d_ocp_qcqp_sol *qp_sol); +// +void d_ocp_qcqp_sol_set_sl(int stage, double *vec, struct d_ocp_qcqp_sol *qp_sol); +// +void d_ocp_qcqp_sol_set_su(int stage, double *vec, struct d_ocp_qcqp_sol *qp_sol); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QCQP_SOL_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_utils.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_utils.h new file mode 100644 index 00000000000000..00248f1dbe65e3 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qcqp_utils.h @@ -0,0 +1,81 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QCQP_UTILS_H_ +#define HPIPM_D_OCP_QCQP_UTILS_H_ + + + +#include +#include + +#include "hpipm_d_ocp_qcqp_dim.h" +#include "hpipm_d_ocp_qp.h" +#include "hpipm_d_ocp_qcqp_sol.h" +#include "hpipm_d_ocp_qcqp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_ocp_qcqp_dim_print(struct d_ocp_qcqp_dim *qcqp_dim); +// +void d_ocp_qcqp_dim_codegen(char *file_name, char *mode, struct d_ocp_qcqp_dim *qcqp_dim); +// +void d_ocp_qcqp_print(struct d_ocp_qcqp_dim *qcqp_dim, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_codegen(char *file_name, char *mode, struct d_ocp_qcqp_dim *qcqp_dim, struct d_ocp_qcqp *qp); +// +void d_ocp_qcqp_sol_print(struct d_ocp_qcqp_dim *qcqp_dim, struct d_ocp_qcqp_sol *ocp_qcqp_sol); +// +void d_ocp_qcqp_ipm_arg_codegen(char *file_name, char *mode, struct d_ocp_qcqp_dim *qcqp_dim, struct d_ocp_qcqp_ipm_arg *arg); +// +void d_ocp_qcqp_res_print(struct d_ocp_qcqp_dim *qcqp_dim, struct d_ocp_qcqp_res *ocp_qcqp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QCQP_UTILS_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp.h new file mode 100644 index 00000000000000..ca26cdba3406a1 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp.h @@ -0,0 +1,306 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_H_ +#define HPIPM_D_OCP_QP_H_ + + + +#include +#include + +#include "hpipm_d_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qp + { + struct d_ocp_qp_dim *dim; + struct blasfeo_dmat *BAbt; // dynamics matrix & vector work space + struct blasfeo_dmat *RSQrq; // hessian of cost & vector work space + struct blasfeo_dmat *DCt; // inequality constraints matrix + struct blasfeo_dvec *b; // dynamics vector + struct blasfeo_dvec *rqz; // gradient of cost & gradient of slacks + struct blasfeo_dvec *d; // inequality constraints vector + struct blasfeo_dvec *d_mask; // inequality constraints mask vector + struct blasfeo_dvec *m; // rhs of complementarity condition + struct blasfeo_dvec *Z; // (diagonal) hessian of slacks + int **idxb; // indices of box constrained variables within [u; x] + int **idxs_rev; // index of soft constraints (reverse storage) + int **idxe; // indices of constraints within [bu, bx, g] that are equalities, subset of [0, ..., nbu+nbx+ng-1] + int *diag_H_flag; // flag the fact that Hessian is diagonal + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_ocp_qp_strsize(); +// +hpipm_size_t d_ocp_qp_memsize(struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_create(struct d_ocp_qp_dim *dim, struct d_ocp_qp *qp, void *memory); +// +void d_ocp_qp_copy_all(struct d_ocp_qp *qp_orig, struct d_ocp_qp *qp_dest); + +// setters +// +void d_ocp_qp_set_all_zero(struct d_ocp_qp *qp); +// +void d_ocp_qp_set_rhs_zero(struct d_ocp_qp *qp); +// +void d_ocp_qp_set_all(double **A, double **B, double **b, double **Q, double **S, double **R, double **q, double **r, int **idxbx, double **lbx, double **ubx, int **idxbu, double **lbu, double **ubu, double **C, double **D, double **lg, double **ug, double **Zl, double **Zu, double **zl, double **zu, int **idxs, double **ls, double **us, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_all_rowmaj(double **A, double **B, double **b, double **Q, double **S, double **R, double **q, double **r, int **idxbx, double **lbx, double **ubx, int **idxbu, double **lbu, double **ubu, double **C, double **D, double **lg, double **ug, double **Zl, double **Zu, double **zl, double **zu, int **idxs, double **ls, double **us, struct d_ocp_qp *qp); +// +void d_ocp_qp_set(char *field_name, int stage, void *value, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_el(char *field_name, int stage, int index, void *value, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_A(int stage, double *mat, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_B(int stage, double *mat, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_b(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Q(int stage, double *mat, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_S(int stage, double *mat, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_R(int stage, double *mat, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_q(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_r(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lb(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lb_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ub(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ub_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lbx(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lbx_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_el_lbx(int stage, int index, double *elem, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ubx(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ubx_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_el_ubx(int stage, int index, double *elem, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lbu(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lbu_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ubu(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ubu_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxb(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxbx(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jbx(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxbu(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jbu(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_C(int stage, double *mat, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_D(int stage, double *mat, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lg(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lg_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ug(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_ug_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Zl(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Zu(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_zl(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_zu(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lls(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lls_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lus(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_lus_mask(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxs(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxs_rev(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jsbu(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jsbx(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jsg(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxe(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxbxe(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxbue(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_idxge(int stage, int *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jbxe(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jbue(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_Jge(int stage, double *vec, struct d_ocp_qp *qp); +// +void d_ocp_qp_set_diag_H_flag(int stage, int *value, struct d_ocp_qp *qp); + +// getters +// +void d_ocp_qp_get(char *field, int stage, struct d_ocp_qp *qp, void *value); +// +void d_ocp_qp_get_A(int stage, struct d_ocp_qp *qp, double *mat); +// +void d_ocp_qp_get_B(int stage, struct d_ocp_qp *qp, double *mat); +// +void d_ocp_qp_get_b(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_Q(int stage, struct d_ocp_qp *qp, double *mat); +// +void d_ocp_qp_get_S(int stage, struct d_ocp_qp *qp, double *mat); +// +void d_ocp_qp_get_R(int stage, struct d_ocp_qp *qp, double *mat); +// +void d_ocp_qp_get_q(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_r(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ub(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ub_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lb(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lb_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lbx(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lbx_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ubx(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ubx_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lbu(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lbu_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ubu(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ubu_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_idxb(int stage, struct d_ocp_qp *qp, int *vec); +// +//void d_ocp_qp_get_idxbx(int stage, struct d_ocp_qp *qp, int *vec); +// +//void d_ocp_qp_get_Jbx(int stage, struct d_ocp_qp *qp, double *vec); +// +//void d_ocp_qp_get_idxbu(int stage, struct d_ocp_qp *qp, int *vec); +// +//void d_ocp_qp_get_Jbu(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_C(int stage, struct d_ocp_qp *qp, double *mat); +// +void d_ocp_qp_get_D(int stage, struct d_ocp_qp *qp, double *mat); +// +void d_ocp_qp_get_lg(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lg_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ug(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_ug_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_Zl(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_Zu(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_zl(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_zu(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lls(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lls_mask(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lus(int stage, struct d_ocp_qp *qp, double *vec); +// +void d_ocp_qp_get_lus_mask(int stage, struct d_ocp_qp *qp, double *vec); +// XXX only valid if there is one slack per softed constraint !!! +void d_ocp_qp_get_idxs(int stage, struct d_ocp_qp *qp, int *vec); +// +void d_ocp_qp_get_idxs_rev(int stage, struct d_ocp_qp *qp, int *vec); +// +//void d_ocp_qp_get_Jsbu(int stage, struct d_ocp_qp *qp, float *vec); +// +//void d_ocp_qp_get_Jsbx(int stage, struct d_ocp_qp *qp, float *vec); +// +//void d_ocp_qp_get_Jsg(int stage, struct d_ocp_qp *qp, float *vec); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_dim.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_dim.h new file mode 100644 index 00000000000000..dcfb801d31fdde --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_dim.h @@ -0,0 +1,142 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_DIM_H_ +#define HPIPM_D_OCP_QP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qp_dim + { + int *nx; // number of states + int *nu; // number of inputs + int *nb; // number of box constraints + int *nbx; // number of state box constraints + int *nbu; // number of input box constraints + int *ng; // number of general constraints + int *ns; // number of soft constraints + int *nsbx; // number of soft state box constraints + int *nsbu; // number of soft input box constraints + int *nsg; // number of soft general constraints + int *nbxe; // number of state box constraints which are equality + int *nbue; // number of input box constraints which are equality + int *nge; // number of general constraints which are equality + int N; // horizon length + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_ocp_qp_dim_strsize(); +// +hpipm_size_t d_ocp_qp_dim_memsize(int N); +// +void d_ocp_qp_dim_create(int N, struct d_ocp_qp_dim *qp_dim, void *memory); +// +void d_ocp_qp_dim_copy_all(struct d_ocp_qp_dim *dim_orig, struct d_ocp_qp_dim *dim_dest); +// +void d_ocp_qp_dim_set_all(int *nx, int *nu, int *nbx, int *nbu, int *ng, int *nsbx, int *nsbu, int *nsg, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set(char *field, int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nx(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nu(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nbx(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nbu(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_ng(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_ns(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nsbx(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nsbu(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nsg(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nbxe(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nbue(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_set_nge(int stage, int value, struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_dim_get(struct d_ocp_qp_dim *dim, char *field, int stage, int *value); +// +void d_ocp_qp_dim_get_N(struct d_ocp_qp_dim *dim, int *value); +// +void d_ocp_qp_dim_get_nx(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nu(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nbx(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nbu(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_ng(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_ns(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nsbx(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nsbu(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nsg(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nbxe(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nbue(struct d_ocp_qp_dim *dim, int stage, int *value); +// +void d_ocp_qp_dim_get_nge(struct d_ocp_qp_dim *dim, int stage, int *value); + + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QP_DIM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_ipm.h new file mode 100644 index 00000000000000..d2a2833f224df8 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_ipm.h @@ -0,0 +1,250 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_IPM_H_ +#define HPIPM_D_OCP_QP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qp_ipm_arg + { + double mu0; // initial value for complementarity slackness + double alpha_min; // exit cond on step length + double res_g_max; // exit cond on inf norm of residuals + double res_b_max; // exit cond on inf norm of residuals + double res_d_max; // exit cond on inf norm of residuals + double res_m_max; // exit cond on inf norm of residuals + double reg_prim; // reg of primal hessian + double lam_min; // min value in lam vector + double t_min; // min value in t vector + double tau_min; // min value of barrier parameter + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int square_root_alg; // 0 classical Riccati, 1 square-root Riccati + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq (for square_root_alg==1) + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution of equality constraints (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol_eq==1) + int comp_res_pred; // compute residuals of prediction + int split_step; // use different steps for primal and dual variables + int var_init_scheme; // variables initialization scheme + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct d_ocp_qp_ipm_ws + { + double qp_res[4]; // infinity norm of residuals + struct d_core_qp_ipm_workspace *core_workspace; + struct d_ocp_qp_dim *dim; // cache dim + struct d_ocp_qp_res_ws *res_workspace; + struct d_ocp_qp_sol *sol_step; + struct d_ocp_qp_sol *sol_itref; + struct d_ocp_qp *qp_step; + struct d_ocp_qp *qp_itref; + struct d_ocp_qp_res *res_itref; + struct d_ocp_qp_res *res; + struct blasfeo_dvec *Gamma; // hessian update + struct blasfeo_dvec *gamma; // hessian update + struct blasfeo_dvec *tmp_nuxM; // work space of size nxM + struct blasfeo_dvec *tmp_nbgM; // work space of size nbM+ngM + struct blasfeo_dvec *tmp_nsM; // work space of size nsM + struct blasfeo_dvec *Pb; // Pb + struct blasfeo_dvec *Zs_inv; + struct blasfeo_dvec *tmp_m; + struct blasfeo_dvec *l; // cache linear part for _get_ric_xxx + struct blasfeo_dmat *L; + struct blasfeo_dmat *Ls; + struct blasfeo_dmat *P; + struct blasfeo_dmat *Lh; + struct blasfeo_dmat *AL; + struct blasfeo_dmat *lq0; + struct blasfeo_dmat *tmp_nxM_nxM; + double *stat; // convergence statistics + int *use_hess_fact; + void *lq_work0; + int iter; // iteration number + int stat_max; // iterations saved in stat + int stat_m; // number of recorded stat per IPM iter + int use_Pb; + int status; // solver status + int square_root_alg; // cache from arg + int lq_fact; // cache from arg + int mask_constr; // use constr mask + int valid_ric_vec; // meaningful riccati vectors + int valid_ric_p; // form of riccati p: 0 p*inv(L), 1 p + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_ocp_qp_ipm_arg_strsize(); +// +hpipm_size_t d_ocp_qp_ipm_arg_memsize(struct d_ocp_qp_dim *ocp_dim); +// +void d_ocp_qp_ipm_arg_create(struct d_ocp_qp_dim *ocp_dim, struct d_ocp_qp_ipm_arg *arg, void *mem); +// +void d_ocp_qp_ipm_arg_set_default(enum hpipm_mode mode, struct d_ocp_qp_ipm_arg *arg); +// +void d_ocp_qp_ipm_arg_set(char *field, void *value, struct d_ocp_qp_ipm_arg *arg); +// set maximum number of iterations +void d_ocp_qp_ipm_arg_set_iter_max(int *iter_max, struct d_ocp_qp_ipm_arg *arg); +// set minimum step lenght +void d_ocp_qp_ipm_arg_set_alpha_min(double *alpha_min, struct d_ocp_qp_ipm_arg *arg); +// set initial value of barrier parameter +void d_ocp_qp_ipm_arg_set_mu0(double *mu0, struct d_ocp_qp_ipm_arg *arg); +// set exit tolerance on stationarity condition +void d_ocp_qp_ipm_arg_set_tol_stat(double *tol_stat, struct d_ocp_qp_ipm_arg *arg); +// set exit tolerance on equality constr +void d_ocp_qp_ipm_arg_set_tol_eq(double *tol_eq, struct d_ocp_qp_ipm_arg *arg); +// set exit tolerance on inequality constr +void d_ocp_qp_ipm_arg_set_tol_ineq(double *tol_ineq, struct d_ocp_qp_ipm_arg *arg); +// set exit tolerance on complementarity condition +void d_ocp_qp_ipm_arg_set_tol_comp(double *tol_comp, struct d_ocp_qp_ipm_arg *arg); +// set regularization of primal variables +void d_ocp_qp_ipm_arg_set_reg_prim(double *tol_comp, struct d_ocp_qp_ipm_arg *arg); +// set warm start: 0 no warm start, 1 primal var +void d_ocp_qp_ipm_arg_set_warm_start(int *warm_start, struct d_ocp_qp_ipm_arg *arg); +// Mehrotra's predictor-corrector IPM algorithm: 0 no predictor-corrector, 1 use predictor-corrector +void d_ocp_qp_ipm_arg_set_pred_corr(int *pred_corr, struct d_ocp_qp_ipm_arg *arg); +// conditional predictor-corrector: 0 no conditinal predictor-corrector, 1 conditional predictor-corrector +void d_ocp_qp_ipm_arg_set_cond_pred_corr(int *value, struct d_ocp_qp_ipm_arg *arg); +// set riccati algorithm: 0 classic, 1 square-root +void d_ocp_qp_ipm_arg_set_ric_alg(int *value, struct d_ocp_qp_ipm_arg *arg); +// dual solution of equality constraints (only for abs_form==1) +void d_ocp_qp_ipm_arg_set_comp_dual_sol_eq(int *value, struct d_ocp_qp_ipm_arg *arg); +// compute residuals after solution +void d_ocp_qp_ipm_arg_set_comp_res_exit(int *value, struct d_ocp_qp_ipm_arg *arg); +// compute residuals of prediction +void d_ocp_qp_ipm_arg_set_comp_res_pred(int *value, struct d_ocp_qp_ipm_arg *arg); +// min value of lam in the solution +void d_ocp_qp_ipm_arg_set_lam_min(double *value, struct d_ocp_qp_ipm_arg *arg); +// min value of t in the solution +void d_ocp_qp_ipm_arg_set_t_min(double *value, struct d_ocp_qp_ipm_arg *arg); +// min value of tau in the solution +void d_ocp_qp_ipm_arg_set_tau_min(double *value, struct d_ocp_qp_ipm_arg *arg); +// set split step: 0 same step, 1 different step for primal and dual variables +void d_ocp_qp_ipm_arg_set_split_step(int *value, struct d_ocp_qp_ipm_arg *arg); +// variables initialization scheme +void d_ocp_qp_ipm_arg_set_var_init_scheme(int *value, struct d_ocp_qp_ipm_arg *arg); +// clip t and lam: 0 no, 1 in Gamma computation, 2 in solution +void d_ocp_qp_ipm_arg_set_t_lam_min(int *value, struct d_ocp_qp_ipm_arg *arg); + +// +hpipm_size_t d_ocp_qp_ipm_ws_strsize(); +// +hpipm_size_t d_ocp_qp_ipm_ws_memsize(struct d_ocp_qp_dim *ocp_dim, struct d_ocp_qp_ipm_arg *arg); +// +void d_ocp_qp_ipm_ws_create(struct d_ocp_qp_dim *ocp_dim, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, void *mem); +// +void d_ocp_qp_ipm_get(char *field, struct d_ocp_qp_ipm_ws *ws, void *value); +// +void d_ocp_qp_ipm_get_status(struct d_ocp_qp_ipm_ws *ws, int *status); +// +void d_ocp_qp_ipm_get_iter(struct d_ocp_qp_ipm_ws *ws, int *iter); +// +void d_ocp_qp_ipm_get_max_res_stat(struct d_ocp_qp_ipm_ws *ws, double *res_stat); +// +void d_ocp_qp_ipm_get_max_res_eq(struct d_ocp_qp_ipm_ws *ws, double *res_eq); +// +void d_ocp_qp_ipm_get_max_res_ineq(struct d_ocp_qp_ipm_ws *ws, double *res_ineq); +// +void d_ocp_qp_ipm_get_max_res_comp(struct d_ocp_qp_ipm_ws *ws, double *res_comp); +// +void d_ocp_qp_ipm_get_stat(struct d_ocp_qp_ipm_ws *ws, double **stat); +// +void d_ocp_qp_ipm_get_stat_m(struct d_ocp_qp_ipm_ws *ws, int *stat_m); +// +void d_ocp_qp_ipm_get_ric_Lr(struct d_ocp_qp *qp, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, int stage, double *Lr); +// +void d_ocp_qp_ipm_get_ric_Ls(struct d_ocp_qp *qp, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, int stage, double *Ls); +// +void d_ocp_qp_ipm_get_ric_P(struct d_ocp_qp *qp, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, int stage, double *P); +// +void d_ocp_qp_ipm_get_ric_lr(struct d_ocp_qp *qp, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, int stage, double *lr); +// +void d_ocp_qp_ipm_get_ric_p(struct d_ocp_qp *qp, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, int stage, double *p); +// feedback control gain in the form u = K x + k +void d_ocp_qp_ipm_get_ric_K(struct d_ocp_qp *qp, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, int stage, double *K); +// feedback control gain in the form u = K x + k +void d_ocp_qp_ipm_get_ric_k(struct d_ocp_qp *qp, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws, int stage, double *k); +// +void d_ocp_qp_init_var(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_ipm_abs_step(int kk, struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_ipm_delta_step(int kk, struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_ipm_solve(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_ipm_predict(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_ipm_sens(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); + + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_OCP_QP_IPM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_kkt.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_kkt.h new file mode 100644 index 00000000000000..19dcec32caa974 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_kkt.h @@ -0,0 +1,66 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_KKT_H_ +#define HPIPM_D_OCP_QP_KKT_H_ + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + +// +void d_ocp_qp_fact_solve_kkt_unconstr(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_fact_solve_kkt_step(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_fact_lq_solve_kkt_step(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); +// +void d_ocp_qp_solve_kkt_step(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_ipm_arg *arg, struct d_ocp_qp_ipm_ws *ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // HPIPM_D_OCP_QP_KKT_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_red.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_red.h new file mode 100644 index 00000000000000..f0482b04441eb9 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_red.h @@ -0,0 +1,117 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_RED_H_ +#define HPIPM_D_OCP_QP_RED_H_ + + + +#include +#include + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qp_reduce_eq_dof_arg + { + double lam_min; + double t_min; + int alias_unchanged; // do not keep copy unchanged stage + int comp_prim_sol; // primal solution (v) + int comp_dual_sol_eq; // dual solution equality constr (pi) + int comp_dual_sol_ineq; // dual solution inequality constr (lam t) + hpipm_size_t memsize; // memory size in bytes + }; + + + +struct d_ocp_qp_reduce_eq_dof_ws + { + struct blasfeo_dvec *tmp_nuxM; + struct blasfeo_dvec *tmp_nbgM; + int *e_imask_ux; + int *e_imask_d; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +void d_ocp_qp_dim_reduce_eq_dof(struct d_ocp_qp_dim *dim, struct d_ocp_qp_dim *dim_red); +// +hpipm_size_t d_ocp_qp_reduce_eq_dof_arg_memsize(); +// +void d_ocp_qp_reduce_eq_dof_arg_create(struct d_ocp_qp_reduce_eq_dof_arg *arg, void *mem); +// +void d_ocp_qp_reduce_eq_dof_arg_set_default(struct d_ocp_qp_reduce_eq_dof_arg *arg); +// +void d_ocp_qp_reduce_eq_dof_arg_set_alias_unchanged(struct d_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +void d_ocp_qp_reduce_eq_dof_arg_set_comp_prim_sol(struct d_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +void d_ocp_qp_reduce_eq_dof_arg_set_comp_dual_sol_eq(struct d_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +void d_ocp_qp_reduce_eq_dof_arg_set_comp_dual_sol_ineq(struct d_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +hpipm_size_t d_ocp_qp_reduce_eq_dof_ws_memsize(struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_reduce_eq_dof_ws_create(struct d_ocp_qp_dim *dim, struct d_ocp_qp_reduce_eq_dof_ws *work, void *mem); +// +void d_ocp_qp_reduce_eq_dof(struct d_ocp_qp *qp, struct d_ocp_qp *qp_red, struct d_ocp_qp_reduce_eq_dof_arg *arg, struct d_ocp_qp_reduce_eq_dof_ws *work); +// +void d_ocp_qp_reduce_eq_dof_lhs(struct d_ocp_qp *qp, struct d_ocp_qp *qp_red, struct d_ocp_qp_reduce_eq_dof_arg *arg, struct d_ocp_qp_reduce_eq_dof_ws *work); +// +void d_ocp_qp_reduce_eq_dof_rhs(struct d_ocp_qp *qp, struct d_ocp_qp *qp_red, struct d_ocp_qp_reduce_eq_dof_arg *arg, struct d_ocp_qp_reduce_eq_dof_ws *work); +// +void d_ocp_qp_restore_eq_dof(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol_red, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_reduce_eq_dof_arg *arg, struct d_ocp_qp_reduce_eq_dof_ws *work); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QP_RED_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_res.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_res.h new file mode 100644 index 00000000000000..061c5729cd6e76 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_res.h @@ -0,0 +1,112 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_RES_H_ +#define HPIPM_D_OCP_QP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qp_res + { + struct d_ocp_qp_dim *dim; + struct blasfeo_dvec *res_g; // q-residuals + struct blasfeo_dvec *res_b; // b-residuals + struct blasfeo_dvec *res_d; // d-residuals + struct blasfeo_dvec *res_m; // m-residuals + double res_max[4]; // max of residuals + double res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct d_ocp_qp_res_ws + { + struct blasfeo_dvec *tmp_nbgM; // work space of size nbM+ngM + struct blasfeo_dvec *tmp_nsM; // work space of size nsM + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_ocp_qp_res_memsize(struct d_ocp_qp_dim *ocp_dim); +// +void d_ocp_qp_res_create(struct d_ocp_qp_dim *ocp_dim, struct d_ocp_qp_res *res, void *mem); +// +hpipm_size_t d_ocp_qp_res_ws_memsize(struct d_ocp_qp_dim *ocp_dim); +// +void d_ocp_qp_res_ws_create(struct d_ocp_qp_dim *ocp_dim, struct d_ocp_qp_res_ws *workspace, void *mem); +// +void d_ocp_qp_res_compute(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_res *res, struct d_ocp_qp_res_ws *ws); +// +void d_ocp_qp_res_compute_lin(struct d_ocp_qp *qp, struct d_ocp_qp_sol *qp_sol, struct d_ocp_qp_sol *qp_step, struct d_ocp_qp_res *res, struct d_ocp_qp_res_ws *ws); +// +void d_ocp_qp_res_compute_inf_norm(struct d_ocp_qp_res *res); +// +void d_ocp_qp_res_get_all(struct d_ocp_qp_res *res, double **res_r, double **res_q, double **res_ls, double **res_us, double **res_b, double **res_d_lb, double **res_d_ub, double **res_d_lg, double **res_d_ug, double **res_d_ls, double **res_d_us, double **res_m_lb, double **res_m_ub, double **res_m_lg, double **res_m_ug, double **res_m_ls, double **res_m_us); +// +void d_ocp_qp_res_get_max_res_stat(struct d_ocp_qp_res *res, double *value); +// +void d_ocp_qp_res_get_max_res_eq(struct d_ocp_qp_res *res, double *value); +// +void d_ocp_qp_res_get_max_res_ineq(struct d_ocp_qp_res *res, double *value); +// +void d_ocp_qp_res_get_max_res_comp(struct d_ocp_qp_res *res, double *value); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_OCP_QP_RES_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_sol.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_sol.h new file mode 100644 index 00000000000000..eb91f3a7b1451f --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_sol.h @@ -0,0 +1,128 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_SOL_H_ +#define HPIPM_D_OCP_QP_SOL_H_ + + + +#include +#include + +#include "hpipm_d_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_ocp_qp_sol + { + struct d_ocp_qp_dim *dim; + struct blasfeo_dvec *ux; + struct blasfeo_dvec *pi; + struct blasfeo_dvec *lam; + struct blasfeo_dvec *t; + void *misc; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_ocp_qp_sol_strsize(); +// +hpipm_size_t d_ocp_qp_sol_memsize(struct d_ocp_qp_dim *dim); +// +void d_ocp_qp_sol_create(struct d_ocp_qp_dim *dim, struct d_ocp_qp_sol *qp_sol, void *memory); +// +void d_ocp_qp_sol_copy_all(struct d_ocp_qp_sol *qp_sol_orig, struct d_ocp_qp_sol *qp_sol_dest); +// +void d_ocp_qp_sol_get_all(struct d_ocp_qp_sol *qp_sol, double **u, double **x, double **ls, double **us, double **pi, double **lam_lb, double **lam_ub, double **lam_lg, double **lam_ug, double **lam_ls, double **lam_us); +// +void d_ocp_qp_sol_get_all_rowmaj(struct d_ocp_qp_sol *qp_sol, double **u, double **x, double **ls, double **us, double **pi, double **lam_lb, double **lam_ub, double **lam_lg, double **lam_ug, double **lam_ls, double **lam_us); +// +void d_ocp_qp_sol_set_all(double **u, double **x, double **ls, double **us, double **pi, double **lam_lb, double **lam_ub, double **lam_lg, double **lam_ug, double **lam_ls, double **lam_us, struct d_ocp_qp_sol *qp_sol); +// +void d_ocp_qp_sol_get(char *field, int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_u(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_x(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_sl(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_su(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_pi(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_lb(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_lbu(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_lbx(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_ub(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_ubu(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_ubx(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_lg(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_get_lam_ug(int stage, struct d_ocp_qp_sol *qp_sol, double *vec); +// +void d_ocp_qp_sol_set(char *field, int stage, double *vec, struct d_ocp_qp_sol *qp_sol); +// +void d_ocp_qp_sol_set_u(int stage, double *vec, struct d_ocp_qp_sol *qp_sol); +// +void d_ocp_qp_sol_set_x(int stage, double *vec, struct d_ocp_qp_sol *qp_sol); +// +void d_ocp_qp_sol_set_sl(int stage, double *vec, struct d_ocp_qp_sol *qp_sol); +// +void d_ocp_qp_sol_set_su(int stage, double *vec, struct d_ocp_qp_sol *qp_sol); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QP_SOL_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_utils.h b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_utils.h new file mode 100644 index 00000000000000..217e9d94ae7116 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_ocp_qp_utils.h @@ -0,0 +1,82 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_OCP_QP_UTILS_H_ +#define HPIPM_D_OCP_QP_UTILS_H_ + + + +#include +#include + +#include "hpipm_d_ocp_qp_dim.h" +#include "hpipm_d_ocp_qp.h" +#include "hpipm_d_ocp_qp_sol.h" +#include "hpipm_d_ocp_qp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_ocp_qp_dim_print(struct d_ocp_qp_dim *qp_dim); +// +void d_ocp_qp_dim_codegen(char *file_name, char *mode, struct d_ocp_qp_dim *qp_dim); +// +void d_ocp_qp_print(struct d_ocp_qp_dim *qp_dim, struct d_ocp_qp *qp); +// +void d_ocp_qp_codegen(char *file_name, char *mode, struct d_ocp_qp_dim *qp_dim, struct d_ocp_qp *qp); +// +void d_ocp_qp_sol_print(struct d_ocp_qp_dim *qp_dim, struct d_ocp_qp_sol *ocp_qp_sol); +// +void d_ocp_qp_ipm_arg_print(struct d_ocp_qp_dim *qp_dim, struct d_ocp_qp_ipm_arg *arg); +// +void d_ocp_qp_ipm_arg_codegen(char *file_name, char *mode, struct d_ocp_qp_dim *qp_dim, struct d_ocp_qp_ipm_arg *arg); +// +void d_ocp_qp_res_print(struct d_ocp_qp_dim *qp_dim, struct d_ocp_qp_res *ocp_qp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QP_UTILS_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_part_cond.h b/third_party/acados/include/hpipm/include/hpipm_d_part_cond.h new file mode 100644 index 00000000000000..1c5f7850356a67 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_part_cond.h @@ -0,0 +1,115 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_PART_COND_H_ +#define HPIPM_D_PART_COND_H_ + + + +#include +#include + +#include "hpipm_common.h" +#include "hpipm_d_cond.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_part_cond_qp_arg + { + struct d_cond_qp_arg *cond_arg; + int N2; + hpipm_size_t memsize; + }; + + + +struct d_part_cond_qp_ws + { + struct d_cond_qp_ws *cond_workspace; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_part_cond_qp_arg_memsize(int N2); +// +void d_part_cond_qp_arg_create(int N2, struct d_part_cond_qp_arg *cond_arg, void *mem); +// +void d_part_cond_qp_arg_set_default(struct d_part_cond_qp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 squre-root +void d_part_cond_qp_arg_set_ric_alg(int ric_alg, struct d_part_cond_qp_arg *cond_arg); +// +void d_part_cond_qp_arg_set_comp_prim_sol(int value, struct d_part_cond_qp_arg *cond_arg); +// +void d_part_cond_qp_arg_set_comp_dual_sol_eq(int value, struct d_part_cond_qp_arg *cond_arg); +// +void d_part_cond_qp_arg_set_comp_dual_sol_ineq(int value, struct d_part_cond_qp_arg *cond_arg); + +// +void d_part_cond_qp_compute_block_size(int N, int N2, int *block_size); +// +void d_part_cond_qp_compute_dim(struct d_ocp_qp_dim *ocp_dim, int *block_size, struct d_ocp_qp_dim *part_dense_dim); +// +hpipm_size_t d_part_cond_qp_ws_memsize(struct d_ocp_qp_dim *ocp_dim, int *block_size, struct d_ocp_qp_dim *part_dense_dim, struct d_part_cond_qp_arg *cond_arg); +// +void d_part_cond_qp_ws_create(struct d_ocp_qp_dim *ocp_dim, int *block_size, struct d_ocp_qp_dim *part_dense_dim, struct d_part_cond_qp_arg *cond_arg, struct d_part_cond_qp_ws *cond_ws, void *mem); +// +void d_part_cond_qp_cond(struct d_ocp_qp *ocp_qp, struct d_ocp_qp *part_dense_qp, struct d_part_cond_qp_arg *cond_arg, struct d_part_cond_qp_ws *cond_ws); +// +void d_part_cond_qp_cond_lhs(struct d_ocp_qp *ocp_qp, struct d_ocp_qp *part_dense_qp, struct d_part_cond_qp_arg *cond_arg, struct d_part_cond_qp_ws *cond_ws); +// +void d_part_cond_qp_cond_rhs(struct d_ocp_qp *ocp_qp, struct d_ocp_qp *part_dense_qp, struct d_part_cond_qp_arg *cond_arg, struct d_part_cond_qp_ws *cond_ws); +// +void d_part_cond_qp_expand_sol(struct d_ocp_qp *ocp_qp, struct d_ocp_qp *part_dense_qp, struct d_ocp_qp_sol *part_dense_qp_sol, struct d_ocp_qp_sol *ocp_qp_sol, struct d_part_cond_qp_arg *cond_arg, struct d_part_cond_qp_ws *cond_ws); + +// +void d_part_cond_qp_update(int *idxc, struct d_ocp_qp *ocp_qp, struct d_ocp_qp *part_dense_qp, struct d_part_cond_qp_arg *cond_arg, struct d_part_cond_qp_ws *cond_ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_PART_COND_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_part_cond_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_d_part_cond_qcqp.h new file mode 100644 index 00000000000000..2d6624e5bbd0e6 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_part_cond_qcqp.h @@ -0,0 +1,106 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_PART_COND_QCQP_H_ +#define HPIPM_D_PART_COND_QCQP_H_ + + + +#include +#include + +#include "hpipm_d_cond_qcqp.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_part_cond_qcqp_arg + { + struct d_cond_qcqp_arg *cond_arg; + int N2; + hpipm_size_t memsize; + }; + + + +struct d_part_cond_qcqp_ws + { + struct d_cond_qcqp_ws *cond_ws; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_part_cond_qcqp_arg_memsize(int N2); +// +void d_part_cond_qcqp_arg_create(int N2, struct d_part_cond_qcqp_arg *cond_arg, void *mem); +// +void d_part_cond_qcqp_arg_set_default(struct d_part_cond_qcqp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 squre-root +void d_part_cond_qcqp_arg_set_ric_alg(int ric_alg, struct d_part_cond_qcqp_arg *cond_arg); + +// +void d_part_cond_qcqp_compute_block_size(int N, int N2, int *block_size); +// +void d_part_cond_qcqp_compute_dim(struct d_ocp_qcqp_dim *ocp_dim, int *block_size, struct d_ocp_qcqp_dim *part_dense_dim); +// +hpipm_size_t d_part_cond_qcqp_ws_memsize(struct d_ocp_qcqp_dim *ocp_dim, int *block_size, struct d_ocp_qcqp_dim *part_dense_dim, struct d_part_cond_qcqp_arg *cond_arg); +// +void d_part_cond_qcqp_ws_create(struct d_ocp_qcqp_dim *ocp_dim, int *block_size, struct d_ocp_qcqp_dim *part_dense_dim, struct d_part_cond_qcqp_arg *cond_arg, struct d_part_cond_qcqp_ws *cond_ws, void *mem); +// +void d_part_cond_qcqp_cond(struct d_ocp_qcqp *ocp_qp, struct d_ocp_qcqp *part_dense_qp, struct d_part_cond_qcqp_arg *cond_arg, struct d_part_cond_qcqp_ws *cond_ws); +// +void d_part_cond_qcqp_cond_lhs(struct d_ocp_qcqp *ocp_qp, struct d_ocp_qcqp *part_dense_qp, struct d_part_cond_qcqp_arg *cond_arg, struct d_part_cond_qcqp_ws *cond_ws); +// +void d_part_cond_qcqp_cond_rhs(struct d_ocp_qcqp *ocp_qp, struct d_ocp_qcqp *part_dense_qp, struct d_part_cond_qcqp_arg *cond_arg, struct d_part_cond_qcqp_ws *cond_ws); +// +void d_part_cond_qcqp_expand_sol(struct d_ocp_qcqp *ocp_qp, struct d_ocp_qcqp *part_dense_qp, struct d_ocp_qcqp_sol *part_dense_qp_sol, struct d_ocp_qcqp_sol *ocp_qp_sol, struct d_part_cond_qcqp_arg *cond_arg, struct d_part_cond_qcqp_ws *cond_ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_PART_COND_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_sim_erk.h b/third_party/acados/include/hpipm/include/hpipm_d_sim_erk.h new file mode 100644 index 00000000000000..320b66bb28c201 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_sim_erk.h @@ -0,0 +1,122 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_SIM_ERK_H_ +#define HPIPM_D_SIM_ERK_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct d_sim_erk_arg + { + struct d_sim_rk_data *rk_data; // integrator data + double h; // step size + int steps; // number of steps +// int for_sens; // compute adjoint sensitivities +// int adj_sens; // compute adjoint sensitivities + hpipm_size_t memsize; + }; + + + +struct d_sim_erk_ws + { + void (*ode)(int t, double *x, double *p, void *ode_args, double *xdot); // function pointer to ode + void (*vde_for)(int t, double *x, double *p, void *ode_args, double *xdot); // function pointer to forward vde + void (*vde_adj)(int t, double *adj_in, void *ode_args, double *adj_out); // function pointer to adjoint vde + void *ode_args; // pointer to ode args + struct d_sim_erk_arg *erk_arg; // erk arg + double *K; // internal variables + double *x_for; // states and forward sensitivities + double *x_traj; // states at all steps + double *l; // adjoint sensitivities + double *p; // parameter + double *x_tmp; // temporary states and forward sensitivities + double *adj_in; + double *adj_tmp; + int nx; // number of states + int np; // number of parameters + int nf; // number of forward sensitivities + int na; // number of adjoint sensitivities + int nf_max; // max number of forward sensitivities + int na_max; // max number of adjoint sensitivities + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_sim_erk_arg_memsize(); +// +void d_sim_erk_arg_create(struct d_sim_erk_arg *erk_arg, void *mem); +// +void d_sim_erk_arg_set_all(struct d_sim_rk_data *rk_data, double h, int steps, struct d_sim_erk_arg *erk_arg); + +// +hpipm_size_t d_sim_erk_ws_memsize(struct d_sim_erk_arg *erk_arg, int nx, int np, int nf_max, int na_max); +// +void d_sim_erk_ws_create(struct d_sim_erk_arg *erk_arg, int nx, int np, int nf_max, int na_max, struct d_sim_erk_ws *work, void *memory); +// +void d_sim_erk_ws_set_all(int nf, int na, double *x, double *fs, double *bs, double *p, void (*ode)(int t, double *x, double *p, void *ode_args, double *xdot), void (*vde_for)(int t, double *x, double *p, void *ode_args, double *xdot), void (*vde_adj)(int t, double *adj_in, void *ode_args, double *adj_out), void *ode_args, struct d_sim_erk_ws *work); +// number of directions for forward sensitivities +void d_sim_erk_ws_set_nf(int *nf, struct d_sim_erk_ws *work); +// parameters (e.g. inputs) +void d_sim_erk_ws_set_p(double *p, struct d_sim_erk_ws *work); +// state +void d_sim_erk_ws_set_x(double *x, struct d_sim_erk_ws *work); +// forward sensitivities +void d_sim_erk_ws_set_fs(double *fs, struct d_sim_erk_ws *work); +// ode funtion +void d_sim_erk_ws_set_ode(void (*ode)(int t, double *x, double *p, void *ode_args, double *xdot), struct d_sim_erk_ws *work); +// forward vde function +void d_sim_erk_ws_set_vde_for(void (*ode)(int t, double *x, double *p, void *ode_args, double *xdot), struct d_sim_erk_ws *work); +// ode_args, passed straight to the ode/vde_for/vde_adj functions +void d_sim_erk_ws_set_ode_args(void *ode_args, struct d_sim_erk_ws *work); +// state +void d_sim_erk_ws_get_x(struct d_sim_erk_ws *work, double *x); +// forward sensitivities +void d_sim_erk_ws_get_fs(struct d_sim_erk_ws *work, double *fs); +// +void d_sim_erk_solve(struct d_sim_erk_arg *arg, struct d_sim_erk_ws *work); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_D_SIM_ERK_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_sim_rk.h b/third_party/acados/include/hpipm/include/hpipm_d_sim_rk.h new file mode 100644 index 00000000000000..a50dcbb491ceea --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_sim_rk.h @@ -0,0 +1,71 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_SIM_RK_H_ +#define HPIPM_D_SIM_RK_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct d_sim_rk_data + { + double *A_rk; // A in butcher tableau + double *B_rk; // b in butcher tableau + double *C_rk; // c in butcher tableau + int expl; // erk vs irk + int ns; // number of stages + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_sim_rk_data_memsize(int ns); +// +void d_sim_rk_data_create(int ns, struct d_sim_rk_data *rk_data, void *memory); +// +void d_sim_rk_data_init_default(char *field, struct d_sim_rk_data *rk_data); +// +void d_sim_rk_data_set_all(int expl, double *A_rk, double *B_rk, double *C_rk, struct d_sim_rk_data *rk_data); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_D_SIM_RK_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp.h new file mode 100644 index 00000000000000..f36b51a06433f1 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp.h @@ -0,0 +1,213 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QCQP_H_ +#define HPIPM_D_TREE_OCP_QCQP_H_ + + + +#include +#include + +#include "hpipm_common.h" +#include "hpipm_d_tree_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qcqp + { + struct d_tree_ocp_qcqp_dim *dim; + struct blasfeo_dmat *BAbt; // Nn-1 + struct blasfeo_dmat *RSQrq; // Nn + struct blasfeo_dmat *DCt; // Nn + struct blasfeo_dmat **Hq; // Nn + struct blasfeo_dvec *b; // Nn-1 + struct blasfeo_dvec *rqz; // Nn + struct blasfeo_dvec *d; // Nn + struct blasfeo_dvec *d_mask; // Nn + struct blasfeo_dvec *m; // Nn + struct blasfeo_dvec *Z; // Nn + int **idxb; // indices of box constrained variables within [u; x] // Nn + int **idxs_rev; // index of soft constraints + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_tree_ocp_qcqp_memsize(struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_create(struct d_tree_ocp_qcqp_dim *dim, struct d_tree_ocp_qcqp *qp, void *memory); +// +void d_tree_ocp_qcqp_set_all(double **A, double **B, double **b, double **Q, double **S, double **R, double **q, double **r, int **idxb, double **d_lb, double **d_ub, double **C, double **D, double **d_lg, double **d_ug, double **Zl, double **Zu, double **zl, double **zu, int **idxs, double **d_ls, double **d_us, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set(char *field_name, int node_edge, void *value, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_A(int edge, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_B(int edge, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_b(int edge, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Q(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_S(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_R(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_q(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_r(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lb(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lb_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ub(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ub_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lbx(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lbx_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ubx(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ubx_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lbu(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lbu_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ubu(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ubu_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_idxb(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_idxbx(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Jbx(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_idxbu(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Jbu(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_C(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_D(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lg(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lg_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ug(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_ug_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Qq(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Sq(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Rq(int node, double *mat, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_qq(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_rq(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_uq(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_uq_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Zl(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Zu(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_zl(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_zu(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lls(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lls_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lus(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_lus_mask(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_idxs(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_idxs_rev(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Jsbu(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Jsbx(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Jsg(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_set_Jsq(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_idxe(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_idxbxe(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_idxbue(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_idxge(int node, int *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_Jbxe(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_Jbue(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_Jge(int node, double *vec, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_set_diag_H_flag(int node, int *value, struct d_tree_ocp_qcqp *qp); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_TREE_OCP_QCQP_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_dim.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_dim.h new file mode 100644 index 00000000000000..257b82b2522bfe --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_dim.h @@ -0,0 +1,117 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QCQP_DIM_H_ +#define HPIPM_D_TREE_OCP_QCQP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qcqp_dim + { + struct d_tree_ocp_qp_dim *qp_dim; // dim of qp approximation + struct tree *ttree; // tree describing node conndection + int *nx; // number of states // Nn + int *nu; // number of inputs // Nn + int *nb; // number of box constraints // Nn + int *nbx; // number of state box constraints // Nn + int *nbu; // number of input box constraints // Nn + int *ng; // number of general constraints // Nn + int *nq; // number of (upper) quadratic constraints + int *ns; // number of soft constraints // Nn + int *nsbx; // number of soft state box constraints + int *nsbu; // number of soft input box constraints + int *nsg; // number of soft general constraints + int *nsq; // number of (upper) soft quadratic constraints + int Nn; // number of nodes + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_tree_ocp_qcqp_dim_strsize(); +// +hpipm_size_t d_tree_ocp_qcqp_dim_memsize(int Nn); +// +void d_tree_ocp_qcqp_dim_create(int Nn, struct d_tree_ocp_qcqp_dim *qp_dim, void *memory); +// +void d_tree_ocp_qcqp_dim_set_tree(struct tree *ttree, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set(char *field, int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nx(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nu(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nbx(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nbu(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_ng(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nq(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_ns(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nsbx(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nsbu(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nsg(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_dim_set_nsq(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +//void d_tree_ocp_qcqp_dim_set_nbxe(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +//void d_tree_ocp_qcqp_dim_set_nbue(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); +// +//void d_tree_ocp_qcqp_dim_set_nge(int stage, int value, struct d_tree_ocp_qcqp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_TREE_OCP_QCQP_DIM_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_ipm.h new file mode 100644 index 00000000000000..4a0fed1067aac8 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_ipm.h @@ -0,0 +1,191 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QCQP_IPM_H_ +#define HPIPM_D_TREE_OCP_QCQP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qcqp_ipm_arg + { + struct d_tree_ocp_qp_ipm_arg *qp_arg; + double mu0; // initial value for complementarity slackness + double alpha_min; // exit cond on step length + double res_g_max; // exit cond on inf norm of residuals + double res_b_max; // exit cond on inf norm of residuals + double res_d_max; // exit cond on inf norm of residuals + double res_m_max; // exit cond on inf norm of residuals + double reg_prim; // reg of primal hessian + double lam_min; // min value in lam vector + double t_min; // min value in t vector + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol +// int square_root_alg; // 0 classical Riccati, 1 square-root Riccati + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq (for square_root_alg==1) + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution of equality constrains (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol_eq==1) +// int comp_res_pred; // compute residuals of prediction + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct d_tree_ocp_qcqp_ipm_ws + { + struct d_tree_ocp_qp_ipm_ws *qp_ws; + struct d_tree_ocp_qp *qp; + struct d_tree_ocp_qp_sol *qp_sol; + struct d_tree_ocp_qcqp_res_ws *qcqp_res_ws; + struct d_tree_ocp_qcqp_res *qcqp_res; + struct blasfeo_dvec *tmp_nuxM; + int iter; // iteration number + int status; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_tree_ocp_qcqp_ipm_arg_strsize(); +// +hpipm_size_t d_tree_ocp_qcqp_ipm_arg_memsize(struct d_tree_ocp_qcqp_dim *ocp_dim); +// +void d_tree_ocp_qcqp_ipm_arg_create(struct d_tree_ocp_qcqp_dim *ocp_dim, struct d_tree_ocp_qcqp_ipm_arg *arg, void *mem); +// +void d_tree_ocp_qcqp_ipm_arg_set_default(enum hpipm_mode mode, struct d_tree_ocp_qcqp_ipm_arg *arg); +// +void d_tree_ocp_qcqp_ipm_arg_set(char *field, void *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set maximum number of iterations +void d_tree_ocp_qcqp_ipm_arg_set_iter_max(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set minimum step lenght +void d_tree_ocp_qcqp_ipm_arg_set_alpha_min(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set initial value of barrier parameter +void d_tree_ocp_qcqp_ipm_arg_set_mu0(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on stationarity condition +void d_tree_ocp_qcqp_ipm_arg_set_tol_stat(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on equality constr +void d_tree_ocp_qcqp_ipm_arg_set_tol_eq(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on inequality constr +void d_tree_ocp_qcqp_ipm_arg_set_tol_ineq(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on complementarity condition +void d_tree_ocp_qcqp_ipm_arg_set_tol_comp(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set regularization of primal variables +void d_tree_ocp_qcqp_ipm_arg_set_reg_prim(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set warm start: 0 no warm start, 1 primal var +void d_tree_ocp_qcqp_ipm_arg_set_warm_start(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// Mehrotra's predictor-corrector IPM algorithm: 0 no predictor-corrector, 1 use predictor-corrector +void d_tree_ocp_qcqp_ipm_arg_set_pred_corr(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// conditional predictor-corrector: 0 no conditinal predictor-corrector, 1 conditional predictor-corrector +void d_tree_ocp_qcqp_ipm_arg_set_cond_pred_corr(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// set riccati algorithm: 0 classic, 1 square-root +//void d_tree_ocp_qcqp_ipm_arg_set_ric_alg(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// compute residuals after solution +void d_tree_ocp_qcqp_ipm_arg_set_comp_res_exit(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// compute residuals of prediction +//void d_tree_ocp_qcqp_ipm_arg_set_comp_res_pred(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// min value of lam in the solution +void d_tree_ocp_qcqp_ipm_arg_set_lam_min(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// min value of t in the solution +void d_tree_ocp_qcqp_ipm_arg_set_t_min(double *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// use different step for primal and dual variables +void d_tree_ocp_qcqp_ipm_arg_set_split_step(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); +// clip t and lam: 0 no, 1 in Gamma computation, 2 in solution +void d_tree_ocp_qcqp_ipm_arg_set_t_lam_min(int *value, struct d_tree_ocp_qcqp_ipm_arg *arg); + +// +hpipm_size_t d_tree_ocp_qcqp_ipm_ws_strsize(); +// +hpipm_size_t d_tree_ocp_qcqp_ipm_ws_memsize(struct d_tree_ocp_qcqp_dim *ocp_dim, struct d_tree_ocp_qcqp_ipm_arg *arg); +// +void d_tree_ocp_qcqp_ipm_ws_create(struct d_tree_ocp_qcqp_dim *ocp_dim, struct d_tree_ocp_qcqp_ipm_arg *arg, struct d_tree_ocp_qcqp_ipm_ws *ws, void *mem); +// +void d_tree_ocp_qcqp_ipm_get(char *field, struct d_tree_ocp_qcqp_ipm_ws *ws, void *value); +// +void d_tree_ocp_qcqp_ipm_get_status(struct d_tree_ocp_qcqp_ipm_ws *ws, int *status); +// +void d_tree_ocp_qcqp_ipm_get_iter(struct d_tree_ocp_qcqp_ipm_ws *ws, int *iter); +// +void d_tree_ocp_qcqp_ipm_get_max_res_stat(struct d_tree_ocp_qcqp_ipm_ws *ws, double *res_stat); +// +void d_tree_ocp_qcqp_ipm_get_max_res_eq(struct d_tree_ocp_qcqp_ipm_ws *ws, double *res_eq); +// +void d_tree_ocp_qcqp_ipm_get_max_res_ineq(struct d_tree_ocp_qcqp_ipm_ws *ws, double *res_ineq); +// +void d_tree_ocp_qcqp_ipm_get_max_res_comp(struct d_tree_ocp_qcqp_ipm_ws *ws, double *res_comp); +// +void d_tree_ocp_qcqp_ipm_get_stat(struct d_tree_ocp_qcqp_ipm_ws *ws, double **stat); +// +void d_tree_ocp_qcqp_ipm_get_stat_m(struct d_tree_ocp_qcqp_ipm_ws *ws, int *stat_m); +// +void d_tree_ocp_qcqp_init_var(struct d_tree_ocp_qcqp *qp, struct d_tree_ocp_qcqp_sol *qp_sol, struct d_tree_ocp_qcqp_ipm_arg *arg, struct d_tree_ocp_qcqp_ipm_ws *ws); +// +void d_tree_ocp_qcqp_ipm_solve(struct d_tree_ocp_qcqp *qp, struct d_tree_ocp_qcqp_sol *qp_sol, struct d_tree_ocp_qcqp_ipm_arg *arg, struct d_tree_ocp_qcqp_ipm_ws *ws); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_TREE_OCP_QCQP_IPM_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_res.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_res.h new file mode 100644 index 00000000000000..69eebb1ba4d674 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_res.h @@ -0,0 +1,108 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QCQP_RES_H_ +#define HPIPM_D_TREE_OCP_QCQP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qcqp_res + { + struct d_tree_ocp_qcqp_dim *dim; + struct blasfeo_dvec *res_g; // q-residuals + struct blasfeo_dvec *res_b; // b-residuals + struct blasfeo_dvec *res_d; // d-residuals + struct blasfeo_dvec *res_m; // m-residuals + double res_max[4]; // max of residuals + double res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct d_tree_ocp_qcqp_res_ws + { + struct blasfeo_dvec *tmp_nuxM; // work space of size nuM+nxM + struct blasfeo_dvec *tmp_nbgqM; // work space of size nbM+ngM+nqM + struct blasfeo_dvec *tmp_nsM; // work space of size nsM + struct blasfeo_dvec *q_fun; // value for evaluation of quadr constr + struct blasfeo_dvec *q_adj; // value for adjoint of quadr constr + int use_q_fun; // reuse cached value for evaluation of quadr constr + int use_q_adj; // reuse cached value for adjoint of quadr constr + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_tree_ocp_qcqp_res_memsize(struct d_tree_ocp_qcqp_dim *ocp_dim); +// +void d_tree_ocp_qcqp_res_create(struct d_tree_ocp_qcqp_dim *ocp_dim, struct d_tree_ocp_qcqp_res *res, void *mem); +// +hpipm_size_t d_tree_ocp_qcqp_res_ws_memsize(struct d_tree_ocp_qcqp_dim *ocp_dim); +// +void d_tree_ocp_qcqp_res_ws_create(struct d_tree_ocp_qcqp_dim *ocp_dim, struct d_tree_ocp_qcqp_res_ws *ws, void *mem); +// +void d_tree_ocp_qcqp_res_compute(struct d_tree_ocp_qcqp *qp, struct d_tree_ocp_qcqp_sol *qp_sol, struct d_tree_ocp_qcqp_res *res, struct d_tree_ocp_qcqp_res_ws *ws); +// +void d_tree_ocp_qcqp_res_compute_inf_norm(struct d_tree_ocp_qcqp_res *res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_TREE_OCP_QCQP_RES_H_ + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_sol.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_sol.h new file mode 100644 index 00000000000000..cde8de5c51b769 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_sol.h @@ -0,0 +1,99 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QCQP_SOL_H_ +#define HPIPM_D_TREE_OCP_QCQP_SOL_H_ + + + +#include +#include + +#include "hpipm_d_tree_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +struct d_tree_ocp_qcqp_sol + { + struct d_tree_ocp_qcqp_dim *dim; + struct blasfeo_dvec *ux; + struct blasfeo_dvec *pi; + struct blasfeo_dvec *lam; + struct blasfeo_dvec *t; + void *misc; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_tree_ocp_qcqp_sol_memsize(struct d_tree_ocp_qcqp_dim *dim); +// +void d_tree_ocp_qcqp_sol_create(struct d_tree_ocp_qcqp_dim *dim, struct d_tree_ocp_qcqp_sol *qp_sol, void *memory); +// +void d_tree_ocp_qcqp_sol_get(char *field, int node_edge, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_u(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_x(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_sl(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_su(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_pi(int edge, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_lam_lb(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_lam_ub(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_lam_lg(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qcqp_sol_get_lam_ug(int node, struct d_tree_ocp_qcqp_sol *qp_sol, double *vec); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_TREE_OCP_QCQP_SOL_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_utils.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_utils.h new file mode 100644 index 00000000000000..5ef04fcf66fc56 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qcqp_utils.h @@ -0,0 +1,84 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QP_UTILS_H_ +#define HPIPM_D_TREE_OCP_QP_UTILS_H_ + + + +#include +#include + +#include "hpipm_d_tree_ocp_qcqp_dim.h" +#include "hpipm_d_tree_ocp_qcqp.h" +#include "hpipm_d_tree_ocp_qcqp_sol.h" +#include "hpipm_d_tree_ocp_qcqp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_tree_ocp_qcqp_dim_print(struct d_tree_ocp_qcqp_dim *qp_dim); +// +//void d_tree_ocp_qcqp_dim_codegen(char *file_name, char *mode, struct d_tree_ocp_qcqp_dim *qp_dim); +// +void d_tree_ocp_qcqp_print(struct d_tree_ocp_qcqp_dim *qp_dim, struct d_tree_ocp_qcqp *qp); +// +//void d_tree_ocp_qcqp_codegen(char *file_name, char *mode, struct d_tree_ocp_qcqp_dim *qp_dim, struct d_tree_ocp_qcqp *qp); +// +void d_tree_ocp_qcqp_sol_print(struct d_tree_ocp_qcqp_dim *qp_dim, struct d_tree_ocp_qcqp_sol *ocp_qcqp_sol); +// +void d_tree_ocp_qcqp_ipm_arg_print(struct d_tree_ocp_qcqp_dim *qp_dim, struct d_tree_ocp_qcqp_ipm_arg *arg); +// +//void d_tree_ocp_qcqp_ipm_arg_codegen(char *file_name, char *mode, struct d_tree_ocp_qcqp_dim *qp_dim, struct d_tree_ocp_qcqp_ipm_arg *arg); +// +void d_tree_ocp_qcqp_res_print(struct d_tree_ocp_qcqp_dim *qp_dim, struct d_tree_ocp_qcqp_res *ocp_qcqp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_TREE_OCP_QP_UTILS_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp.h new file mode 100644 index 00000000000000..1666ad7c71bc3a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp.h @@ -0,0 +1,195 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QP_H_ +#define HPIPM_D_TREE_OCP_QP_H_ + + + +#include +#include + +#include "hpipm_d_tree_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qp + { + struct d_tree_ocp_qp_dim *dim; + struct blasfeo_dmat *BAbt; // Nn-1 + struct blasfeo_dmat *RSQrq; // Nn + struct blasfeo_dmat *DCt; // Nn + struct blasfeo_dvec *b; // Nn-1 + struct blasfeo_dvec *rqz; // Nn + struct blasfeo_dvec *d; // Nn + struct blasfeo_dvec *d_mask; // Nn + struct blasfeo_dvec *m; // Nn + struct blasfeo_dvec *Z; // Nn + int **idxb; // indices of box constrained variables within [u; x] // Nn +// int **idxs; // index of soft constraints + int **idxs_rev; // index of soft constraints + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_tree_ocp_qp_memsize(struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_create(struct d_tree_ocp_qp_dim *dim, struct d_tree_ocp_qp *qp, void *memory); +// +void d_tree_ocp_qp_set_all(double **A, double **B, double **b, double **Q, double **S, double **R, double **q, double **r, int **idxb, double **d_lb, double **d_ub, double **C, double **D, double **d_lg, double **d_ug, double **Zl, double **Zu, double **zl, double **zu, int **idxs, double **d_ls, double **d_us, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set(char *field_name, int node_edge, void *value, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_A(int edge, double *mat, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_B(int edge, double *mat, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_b(int edge, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Q(int node, double *mat, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_S(int node, double *mat, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_R(int node, double *mat, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_q(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_r(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lb(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lb_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ub(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ub_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lbx(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lbx_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ubx(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ubx_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lbu(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lbu_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ubu(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ubu_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_idxb(int node, int *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_idxbx(int node, int *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Jbx(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_idxbu(int node, int *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Jbu(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_C(int node, double *mat, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_D(int node, double *mat, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lg(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lg_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ug(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_ug_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Zl(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Zu(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_zl(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_zu(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lls(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lls_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lus(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_lus_mask(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_idxs(int node, int *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_idxs_rev(int node, int *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Jsbu(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Jsbx(int node, double *vec, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_set_Jsg(int node, double *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_idxe(int node, int *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_idxbxe(int node, int *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_idxbue(int node, int *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_idxge(int node, int *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_Jbxe(int node, double *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_Jbue(int node, double *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_Jge(int node, double *vec, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_set_diag_H_flag(int node, int *value, struct d_tree_ocp_qp *qp); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_TREE_OCP_QP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_dim.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_dim.h new file mode 100644 index 00000000000000..659b664594263e --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_dim.h @@ -0,0 +1,111 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QP_DIM_H_ +#define HPIPM_D_TREE_OCP_QP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qp_dim + { + struct tree *ttree; // tree describing node conndection + int *nx; // number of states // Nn + int *nu; // number of inputs // Nn + int *nb; // number of box constraints // Nn + int *nbx; // number of state box constraints // Nn + int *nbu; // number of input box constraints // Nn + int *ng; // number of general constraints // Nn + int *ns; // number of soft constraints // Nn + int *nsbx; // number of soft state box constraints + int *nsbu; // number of soft input box constraints + int *nsg; // number of soft general constraints + int Nn; // number of nodes + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_tree_ocp_qp_dim_strsize(); +// +hpipm_size_t d_tree_ocp_qp_dim_memsize(int Nn); +// +void d_tree_ocp_qp_dim_create(int Nn, struct d_tree_ocp_qp_dim *qp_dim, void *memory); +// +void d_tree_ocp_qp_dim_set_all(struct tree *ttree, int *nx, int *nu, int *nbx, int *nbu, int *ng, int *nsbx, int *nsbu, int *nsg, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_tree(struct tree *ttree, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set(char *field, int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nx(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nu(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nbx(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nbu(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_ng(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_ns(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nsbx(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nsbu(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nsg(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nbxe(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nbue(int stage, int value, struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_dim_set_nge(int stage, int value, struct d_tree_ocp_qp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_TREE_OCP_QP_DIM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_ipm.h new file mode 100644 index 00000000000000..fb634208ce8845 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_ipm.h @@ -0,0 +1,209 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_D_TREE_OCP_QP_IPM_H_ +#define HPIPM_D_TREE_OCP_QP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qp_ipm_arg + { + double mu0; // initial value for duality measure + double alpha_min; // exit cond on step length + double res_g_max; // exit cond on inf norm of residuals + double res_b_max; // exit cond on inf norm of residuals + double res_d_max; // exit cond on inf norm of residuals + double res_m_max; // exit cond on inf norm of residuals + double reg_prim; // reg of primal hessian + double lam_min; // min value in lam vector + double t_min; // min value in t vector + double tau_min; // min value of barrier parameter + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol==1) + int split_step; // use different steps for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct d_tree_ocp_qp_ipm_ws + { + struct d_core_qp_ipm_workspace *core_workspace; + struct d_tree_ocp_qp_res_ws *res_workspace; + struct d_tree_ocp_qp_sol *sol_step; + struct d_tree_ocp_qp_sol *sol_itref; + struct d_tree_ocp_qp *qp_step; + struct d_tree_ocp_qp *qp_itref; + struct d_tree_ocp_qp_res *res_itref; + struct d_tree_ocp_qp_res *res; + struct blasfeo_dvec *Gamma; // hessian update + struct blasfeo_dvec *gamma; // hessian update + struct blasfeo_dvec *tmp_nxM; // work space of size nxM + struct blasfeo_dvec *tmp_nbgM; // work space of size nbgM + struct blasfeo_dvec *tmp_nsM; // work space of size nsM + struct blasfeo_dvec *Pb; // Pb + struct blasfeo_dvec *Zs_inv; + struct blasfeo_dmat *L; + struct blasfeo_dmat *Lh; + struct blasfeo_dmat *AL; + struct blasfeo_dmat *lq0; + struct blasfeo_dvec *tmp_m; + double *stat; // convergence statistics + int *use_hess_fact; + void *lq_work0; + double qp_res[4]; // infinity norm of residuals + int iter; // iteration number + int stat_max; // iterations saved in stat + int stat_m; // number of recorded stat per IPM iter + int use_Pb; + int status; // solver status + int lq_fact; // cache from arg + int mask_constr; // use constr mask + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_tree_ocp_qp_ipm_arg_memsize(struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_ipm_arg_create(struct d_tree_ocp_qp_dim *dim, struct d_tree_ocp_qp_ipm_arg *arg, void *mem); +// +void d_tree_ocp_qp_ipm_arg_set_default(enum hpipm_mode mode, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_iter_max(int *iter_max, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_alpha_min(double *alpha_min, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_mu0(double *mu0, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_tol_stat(double *tol_stat, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_tol_eq(double *tol_eq, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_tol_ineq(double *tol_ineq, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_tol_comp(double *tol_comp, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_reg_prim(double *reg, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_warm_start(int *warm_start, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_pred_corr(int *pred_corr, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_cond_pred_corr(int *value, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_comp_dual_sol_eq(int *value, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_comp_res_exit(int *value, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_lam_min(double *value, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_t_min(double *value, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_tau_min(double *value, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_split_step(int *value, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_arg_set_t_lam_min(int *value, struct d_tree_ocp_qp_ipm_arg *arg); + +// +hpipm_size_t d_tree_ocp_qp_ipm_ws_memsize(struct d_tree_ocp_qp_dim *dim, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_ipm_ws_create(struct d_tree_ocp_qp_dim *dim, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws, void *mem); +// +void d_tree_ocp_qp_ipm_get_status(struct d_tree_ocp_qp_ipm_ws *ws, int *status); +// +void d_tree_ocp_qp_ipm_get_iter(struct d_tree_ocp_qp_ipm_ws *ws, int *iter); +// +void d_tree_ocp_qp_ipm_get_max_res_stat(struct d_tree_ocp_qp_ipm_ws *ws, double *res_stat); +// +void d_tree_ocp_qp_ipm_get_max_res_eq(struct d_tree_ocp_qp_ipm_ws *ws, double *res_eq); +// +void d_tree_ocp_qp_ipm_get_max_res_ineq(struct d_tree_ocp_qp_ipm_ws *ws, double *res_ineq); +// +void d_tree_ocp_qp_ipm_get_max_res_comp(struct d_tree_ocp_qp_ipm_ws *ws, double *res_comp); +// +void d_tree_ocp_qp_ipm_get_stat(struct d_tree_ocp_qp_ipm_ws *ws, double **stat); +// +void d_tree_ocp_qp_ipm_get_stat_m(struct d_tree_ocp_qp_ipm_ws *ws, int *stat_m); +// +void d_tree_ocp_qp_init_var(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); +// +void d_tree_ocp_qp_ipm_abs_step(int kk, struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); +// +void d_tree_ocp_qp_ipm_delta_step(int kk, struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); +// +void d_tree_ocp_qp_ipm_solve(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_TREE_OCP_QP_IPM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_kkt.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_kkt.h new file mode 100644 index 00000000000000..4afd52fe4bf1cc --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_kkt.h @@ -0,0 +1,52 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + +// +void d_tree_ocp_qp_fact_solve_kkt_unconstr(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); +// +void d_tree_ocp_qp_fact_solve_kkt_step(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); +// +void d_tree_ocp_qp_fact_lq_solve_kkt_step(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); +// +void d_tree_ocp_qp_solve_kkt_step(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_ipm_arg *arg, struct d_tree_ocp_qp_ipm_ws *ws); + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_res.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_res.h new file mode 100644 index 00000000000000..fe499080ea89a3 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_res.h @@ -0,0 +1,106 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QP_RES_H_ +#define HPIPM_D_TREE_OCP_QP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct d_tree_ocp_qp_res + { + struct d_tree_ocp_qp_dim *dim; + struct blasfeo_dvec *res_g; // q-residuals + struct blasfeo_dvec *res_b; // b-residuals + struct blasfeo_dvec *res_d; // d-residuals + struct blasfeo_dvec *res_m; // m-residuals + double res_max[4]; // max of residuals + double res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct d_tree_ocp_qp_res_ws + { + struct blasfeo_dvec *tmp_nbgM; // work space of size nbM+ngM + struct blasfeo_dvec *tmp_nsM; // work space of size nsM + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t d_tree_ocp_qp_res_memsize(struct d_tree_ocp_qp_dim *ocp_dim); +// +void d_tree_ocp_qp_res_create(struct d_tree_ocp_qp_dim *ocp_dim, struct d_tree_ocp_qp_res *res, void *mem); +// +hpipm_size_t d_tree_ocp_qp_res_ws_memsize(struct d_tree_ocp_qp_dim *ocp_dim); +// +void d_tree_ocp_qp_res_ws_create(struct d_tree_ocp_qp_dim *ocp_dim, struct d_tree_ocp_qp_res_ws *ws, void *mem); +// +void d_tree_ocp_qp_res_get_all(struct d_tree_ocp_qp_res *res, double **res_r, double **res_q, double **res_ls, double **res_us, double **res_b, double **res_d_lb, double **res_d_ub, double **res_d_lg, double **res_d_ug, double **res_d_ls, double **res_d_us, double **res_m_lb, double **res_m_ub, double **res_m_lg, double **res_m_ug, double **res_m_ls, double **res_m_us); +// +void d_tree_ocp_qp_res_compute(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_res *res, struct d_tree_ocp_qp_res_ws *ws); +// +void d_tree_ocp_qp_res_compute_lin(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, struct d_tree_ocp_qp_sol *qp_step, struct d_tree_ocp_qp_res *res, struct d_tree_ocp_qp_res_ws *ws); +// +void d_tree_ocp_qp_res_compute_inf_norm(struct d_tree_ocp_qp_res *res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_TREE_OCP_QP_RES_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_sol.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_sol.h new file mode 100644 index 00000000000000..343d5e8ca6a171 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_sol.h @@ -0,0 +1,100 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QP_SOL_H_ +#define HPIPM_D_TREE_OCP_QP_SOL_H_ + + + +#include +#include + +#include "hpipm_d_tree_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +struct d_tree_ocp_qp_sol + { + struct d_tree_ocp_qp_dim *dim; + struct blasfeo_dvec *ux; + struct blasfeo_dvec *pi; + struct blasfeo_dvec *lam; + struct blasfeo_dvec *t; + void *misc; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t d_tree_ocp_qp_sol_memsize(struct d_tree_ocp_qp_dim *dim); +// +void d_tree_ocp_qp_sol_create(struct d_tree_ocp_qp_dim *dim, struct d_tree_ocp_qp_sol *qp_sol, void *memory); +// +void d_tree_ocp_qp_sol_get_all(struct d_tree_ocp_qp *qp, struct d_tree_ocp_qp_sol *qp_sol, double **u, double **x, double **ls, double **us, double **pi, double **lam_lb, double **lam_ub, double **lam_lg, double **lam_ug, double **lam_ls, double **lam_us); +// +void d_tree_ocp_qp_sol_get(char *field, int node_edge, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_u(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_x(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_sl(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_su(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_pi(int edge, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_lam_lb(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_lam_ub(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_lam_lg(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); +// +void d_tree_ocp_qp_sol_get_lam_ug(int node, struct d_tree_ocp_qp_sol *qp_sol, double *vec); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_TREE_OCP_QP_SOL_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_utils.h b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_utils.h new file mode 100644 index 00000000000000..b689fdc0fa2d59 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_d_tree_ocp_qp_utils.h @@ -0,0 +1,83 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_D_TREE_OCP_QP_UTILS_H_ +#define HPIPM_D_TREE_OCP_QP_UTILS_H_ + + + +#include +#include + +#include "hpipm_d_tree_ocp_qp_dim.h" +#include "hpipm_d_tree_ocp_qp.h" +#include "hpipm_d_tree_ocp_qp_sol.h" +#include "hpipm_d_tree_ocp_qp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void d_tree_ocp_qp_dim_print(struct d_tree_ocp_qp_dim *qp_dim); +// +//void d_tree_ocp_qp_dim_codegen(char *file_name, char *mode, struct d_tree_ocp_qp_dim *qp_dim); +// +void d_tree_ocp_qp_print(struct d_tree_ocp_qp_dim *qp_dim, struct d_tree_ocp_qp *qp); +// +//void d_tree_ocp_qp_codegen(char *file_name, char *mode, struct d_tree_ocp_qp_dim *qp_dim, struct d_tree_ocp_qp *qp); +// +void d_tree_ocp_qp_sol_print(struct d_tree_ocp_qp_dim *qp_dim, struct d_tree_ocp_qp_sol *ocp_qp_sol); +// +void d_tree_ocp_qp_ipm_arg_print(struct d_tree_ocp_qp_dim *qp_dim, struct d_tree_ocp_qp_ipm_arg *arg); +// +//void d_tree_ocp_qp_ipm_arg_codegen(char *file_name, char *mode, struct d_tree_ocp_qp_dim *qp_dim, struct d_tree_ocp_qp_ipm_arg *arg); +// +void d_tree_ocp_qp_res_print(struct d_tree_ocp_qp_dim *qp_dim, struct d_tree_ocp_qp_res *ocp_qp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_TREE_OCP_QP_UTILS_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_m_dense_qp.h b/third_party/acados/include/hpipm/include/hpipm_m_dense_qp.h new file mode 100644 index 00000000000000..8bc101003e208a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_m_dense_qp.h @@ -0,0 +1,68 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + + +#ifndef HPIPM_M_DENSE_QP_H_ +#define HPIPM_M_DENSE_QP_H_ + + + +#include +#include + +#include "hpipm_d_dense_qp.h" +#include "hpipm_s_dense_qp.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +void cvt_d2s_dense_qp(struct d_dense_qp *qpd, struct s_dense_qp *qps); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_M_DENSE_QP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_m_dense_qp_dim.h b/third_party/acados/include/hpipm/include/hpipm_m_dense_qp_dim.h new file mode 100644 index 00000000000000..4610321b970c9e --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_m_dense_qp_dim.h @@ -0,0 +1,68 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + + +#ifndef HPIPM_M_DENSE_QP_DIM_H_ +#define HPIPM_M_DENSE_QP_DIM_H_ + + + +#include +#include + +#include "hpipm_d_dense_qp_dim.h" +#include "hpipm_s_dense_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +void cvt_d2s_dense_qp_dim(struct d_dense_qp_dim *qpd, struct s_dense_qp_dim *qps); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_M_DENSE_QP_DIM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp.h b/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp.h new file mode 100644 index 00000000000000..95c3dad1aa02be --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp.h @@ -0,0 +1,49 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void m_cvt_d_ocp_qp_to_s_ocp_qp(struct d_ocp_qp *d_qp, struct s_ocp_qp *s_qp); + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp_ipm_hard.h b/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp_ipm_hard.h new file mode 100644 index 00000000000000..1c44acee2e8497 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp_ipm_hard.h @@ -0,0 +1,115 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +struct m_ipm_hard_ocp_qp_workspace + { + struct d_ipm_hard_core_qp_workspace *core_workspace; + struct blasfeo_dvec *dux; + struct blasfeo_dvec *dpi; + struct blasfeo_dvec *dt_lb; + struct blasfeo_dvec *dt_lg; + struct blasfeo_svec *sdux; // XXX + struct blasfeo_svec *sdpi; // XXX + struct blasfeo_dvec *res_g; // q-residuals + struct blasfeo_dvec *res_b; // b-residuals + struct blasfeo_dvec *res_d; // d-residuals XXX remove ??? + struct blasfeo_dvec *res_d_lb; // d-residuals + struct blasfeo_dvec *res_d_ub; // d-residuals + struct blasfeo_dvec *res_d_lg; // d-residuals + struct blasfeo_dvec *res_d_ug; // d-residuals + struct blasfeo_dvec *res_m; // m-residuals + struct blasfeo_dvec *res_m_lb; // m-residuals + struct blasfeo_dvec *res_m_ub; // m-residuals + struct blasfeo_dvec *res_m_lg; // m-residuals + struct blasfeo_dvec *res_m_ug; // m-residuals + struct blasfeo_svec *sres_g; // q-residuals // XXX + struct blasfeo_svec *sres_b; // b-residuals // XXX + struct blasfeo_dvec *Qx_lb; // hessian update + struct blasfeo_dvec *Qx_lg; // hessian update + struct blasfeo_dvec *qx_lb; // gradient update + struct blasfeo_dvec *qx_lg; // gradient update + struct blasfeo_svec *sQx_lb; // hessian update // XXX + struct blasfeo_svec *sQx_lg; // hessian update // XXX + struct blasfeo_svec *sqx_lb; // gradient update // XXX + struct blasfeo_svec *sqx_lg; // gradient update // XXX + struct blasfeo_dvec *tmp_nbM; // work space of size nbM + struct blasfeo_svec *tmp_nxM; // work space of size nxM // XXX + struct blasfeo_dvec *tmp_ngM; // work space of size ngM + struct blasfeo_svec *Pb; // Pb // XXX + struct blasfeo_smat *L; // XXX + struct blasfeo_smat *AL; // XXX + struct blasfeo_svec *sSx; // scaling + struct blasfeo_svec *sSi; // scaling inverted + double *stat; // convergence statistics + double res_mu; // mu-residual + int iter; // iteration number + int compute_Pb; + int scale; + }; + + + +struct m_ipm_hard_ocp_qp_arg + { + double alpha_min; // exit cond on step length + double mu_max; // exit cond on duality measure + double mu0; // initial value for duality measure + int iter_max; // exit cond in iter number + }; + + + +// +hpipm_size_t m_memsize_ipm_hard_ocp_qp(struct d_ocp_qp *d_qp, struct s_ocp_qp *s_qp, struct m_ipm_hard_ocp_qp_arg *arg); +// +void m_create_ipm_hard_ocp_qp(struct d_ocp_qp *d_qp, struct s_ocp_qp *s_qp, struct m_ipm_hard_ocp_qp_arg *arg, struct m_ipm_hard_ocp_qp_workspace *ws, void *mem); +// +void m_solve_ipm_hard_ocp_qp(struct d_ocp_qp *d_qp, struct s_ocp_qp *s_qp, struct d_ocp_qp_sol *qp_sol, struct m_ipm_hard_ocp_qp_workspace *ws); +// +void m_solve_ipm2_hard_ocp_qp(struct d_ocp_qp *d_qp, struct s_ocp_qp *s_qp, struct d_ocp_qp_sol *qp_sol, struct m_ipm_hard_ocp_qp_workspace *ws); + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp_kkt.h b/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp_kkt.h new file mode 100644 index 00000000000000..032fe95b1f9897 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_m_ocp_qp_kkt.h @@ -0,0 +1,45 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +void m_fact_solve_kkt_step_hard_ocp_qp(struct d_ocp_qp *d_qp, struct s_ocp_qp *s_qp, struct m_ipm_hard_ocp_qp_workspace *ws); +void m_solve_kkt_step_hard_ocp_qp(struct d_ocp_qp *d_qp, struct s_ocp_qp *s_qp, struct m_ipm_hard_ocp_qp_workspace *ws); + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/third_party/acados/include/hpipm/include/hpipm_s_cast_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_s_cast_qcqp.h new file mode 100644 index 00000000000000..ba01ecb3bd437e --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_cast_qcqp.h @@ -0,0 +1,72 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_CAST_QCQP_H_ +#define HPIPM_S_CAST_QCQP_H_ + + + +#include +#include + +#include "hpipm_s_dense_qcqp.h" +#include "hpipm_s_dense_qcqp_sol.h" +#include "hpipm_s_ocp_qcqp.h" +#include "hpipm_s_ocp_qcqp_dim.h" +#include "hpipm_s_ocp_qcqp_sol.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_cast_qcqp_compute_dim(struct s_ocp_qcqp_dim *ocp_dim, struct s_dense_qcqp_dim *dense_dim); +// +void s_cast_qcqp_cond(struct s_ocp_qcqp *ocp_qp, struct s_dense_qcqp *dense_qp); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_CAST_QCQP_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_cond.h b/third_party/acados/include/hpipm/include/hpipm_s_cond.h new file mode 100644 index 00000000000000..30116798b77599 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_cond.h @@ -0,0 +1,137 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_COND_H_ +#define HPIPM_S_COND_H_ + + + +#include +#include + +#include "hpipm_s_dense_qp.h" +#include "hpipm_s_dense_qp_sol.h" +#include "hpipm_s_ocp_qp.h" +#include "hpipm_s_ocp_qp_dim.h" +#include "hpipm_s_ocp_qp_sol.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_cond_qp_arg + { + int cond_last_stage; // condense last stage + int cond_alg; // condensing algorithm: 0 N2-nx3, 1 N3-nx2 + int comp_prim_sol; // primal solution (v) + int comp_dual_sol_eq; // dual solution equality constr (pi) + int comp_dual_sol_ineq; // dual solution inequality constr (lam t) + int square_root_alg; // square root algorithm (faster but requires RSQ>0) + hpipm_size_t memsize; + }; + + + +struct s_cond_qp_ws + { + struct blasfeo_smat *Gamma; + struct blasfeo_smat *GammaQ; + struct blasfeo_smat *L; + struct blasfeo_smat *Lx; + struct blasfeo_smat *AL; + struct blasfeo_svec *Gammab; + struct blasfeo_svec *l; + struct blasfeo_svec *tmp_nbgM; + struct blasfeo_svec *tmp_nuxM; + int bs; // block size + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_cond_qp_arg_memsize(); +// +void s_cond_qp_arg_create(struct s_cond_qp_arg *cond_arg, void *mem); +// +void s_cond_qp_arg_set_default(struct s_cond_qp_arg *cond_arg); +// condensing algorithm: 0 N2-nx3, 1 N3-nx2 +void s_cond_qp_arg_set_cond_alg(int cond_alg, struct s_cond_qp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 square-root +void s_cond_qp_arg_set_ric_alg(int ric_alg, struct s_cond_qp_arg *cond_arg); +// condense last stage: 0 last stage disregarded, 1 last stage condensed too +void s_cond_qp_arg_set_cond_last_stage(int cond_last_stage, struct s_cond_qp_arg *cond_arg); +// +void s_cond_qp_arg_set_comp_prim_sol(int value, struct s_cond_qp_arg *cond_arg); +// +void s_cond_qp_arg_set_comp_dual_sol_eq(int value, struct s_cond_qp_arg *cond_arg); +// +void s_cond_qp_arg_set_comp_dual_sol_ineq(int value, struct s_cond_qp_arg *cond_arg); + +// +void s_cond_qp_compute_dim(struct s_ocp_qp_dim *ocp_dim, struct s_dense_qp_dim *dense_dim); +// +hpipm_size_t s_cond_qp_ws_memsize(struct s_ocp_qp_dim *ocp_dim, struct s_cond_qp_arg *cond_arg); +// +void s_cond_qp_ws_create(struct s_ocp_qp_dim *ocp_dim, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws, void *mem); +// +void s_cond_qp_cond(struct s_ocp_qp *ocp_qp, struct s_dense_qp *dense_qp, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_qp_cond_lhs(struct s_ocp_qp *ocp_qp, struct s_dense_qp *dense_qp, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_qp_cond_rhs(struct s_ocp_qp *ocp_qp, struct s_dense_qp *dense_qp, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_qp_expand_sol(struct s_ocp_qp *ocp_qp, struct s_dense_qp_sol *dense_qp_sol, struct s_ocp_qp_sol *ocp_qp_sol, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// TODO remove +void s_cond_qp_expand_primal_sol(struct s_ocp_qp *ocp_qp, struct s_dense_qp_sol *dense_qp_sol, struct s_ocp_qp_sol *ocp_qp_sol, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); + +// +void s_cond_qp_update(int *idxc, struct s_ocp_qp *ocp_qp, struct s_dense_qp *dense_qp, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_COND_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_cond_aux.h b/third_party/acados/include/hpipm/include/hpipm_s_cond_aux.h new file mode 100644 index 00000000000000..003472ab9f3069 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_cond_aux.h @@ -0,0 +1,92 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_COND_AUX_H_ +#define HPIPM_S_COND_AUX_H_ + + + +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_cond_BAbt(struct s_ocp_qp *ocp_qp, struct blasfeo_smat *BAbt2, struct blasfeo_svec *b2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_BAt(struct s_ocp_qp *ocp_qp, struct blasfeo_smat *BAbt2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_b(struct s_ocp_qp *ocp_qp, struct blasfeo_svec *b2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_RSQrq(struct s_ocp_qp *ocp_qp, struct blasfeo_smat *RSQrq2, struct blasfeo_svec *rq2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_RSQ(struct s_ocp_qp *ocp_qp, struct blasfeo_smat *RSQrq2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_rq(struct s_ocp_qp *ocp_qp, struct blasfeo_svec *rq2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_DCtd(struct s_ocp_qp *ocp_qp, int *idxb2, struct blasfeo_smat *DCt2, struct blasfeo_svec *d2, struct blasfeo_svec *d_mask2, int *idxs_rev2, struct blasfeo_svec *Z2, struct blasfeo_svec *z2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_DCt(struct s_ocp_qp *ocp_qp, int *idxb2, struct blasfeo_smat *DCt2, int *idxs_rev2, struct blasfeo_svec *Z2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_cond_d(struct s_ocp_qp *ocp_qp, struct blasfeo_svec *d2, struct blasfeo_svec *d_mask2, struct blasfeo_svec *z2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_expand_sol(struct s_ocp_qp *ocp_qp, struct s_dense_qp_sol *dense_qp_sol, struct s_ocp_qp_sol *ocp_qp_sol, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_expand_primal_sol(struct s_ocp_qp *ocp_qp, struct s_dense_qp_sol *dense_qp_sol, struct s_ocp_qp_sol *ocp_qp_sol, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); + +// +void s_update_cond_BAbt(int *idxc, struct s_ocp_qp *ocp_qp, struct blasfeo_smat *BAbt2, struct blasfeo_svec *b2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_update_cond_RSQrq_N2nx3(int *idxc, struct s_ocp_qp *ocp_qp, struct blasfeo_smat *RSQrq2, struct blasfeo_svec *rq2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); +// +void s_update_cond_DCtd(int *idxc, struct s_ocp_qp *ocp_qp, int *idxb2, struct blasfeo_smat *DCt2, struct blasfeo_svec *d2, int *idxs2, struct blasfeo_svec *Z2, struct blasfeo_svec *z2, struct s_cond_qp_arg *cond_arg, struct s_cond_qp_ws *cond_ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_COND_AUX_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_cond_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_s_cond_qcqp.h new file mode 100644 index 00000000000000..c36678abd55953 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_cond_qcqp.h @@ -0,0 +1,130 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_COND_QCQP_H_ +#define HPIPM_S_COND_QCQP_H_ + + + +#include +#include + +#include "hpipm_s_dense_qcqp.h" +#include "hpipm_s_dense_qcqp_sol.h" +#include "hpipm_s_ocp_qcqp.h" +#include "hpipm_s_ocp_qcqp_dim.h" +#include "hpipm_s_ocp_qcqp_sol.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_cond_qcqp_arg + { + struct s_cond_qp_arg *qp_arg; + int cond_last_stage; // condense last stage +// int cond_variant; // TODO + int comp_prim_sol; // primal solution (v) + int comp_dual_sol_eq; // dual solution equality constr (pi) + int comp_dual_sol_ineq; // dual solution equality constr (lam t) + int square_root_alg; // square root algorithm (faster but requires RSQ>0) + hpipm_size_t memsize; + }; + + + +struct s_cond_qcqp_ws + { + struct s_cond_qp_ws *qp_ws; + struct blasfeo_smat *hess_array; // TODO remove + struct blasfeo_smat *zero_hess; // TODO remove + struct blasfeo_svec *zero_grad; // TODO remove + struct blasfeo_svec *grad_array; // TODO remove + struct blasfeo_svec *tmp_nvc; + struct blasfeo_svec *tmp_nuxM; + struct blasfeo_smat *GammaQ; + struct blasfeo_smat *tmp_DCt; + struct blasfeo_smat *tmp_nuM_nxM; +// struct blasfeo_svec *d_qp; +// struct blasfeo_svec *d_mask_qp; + hpipm_size_t memsize; + }; + + +// +hpipm_size_t s_cond_qcqp_arg_memsize(); +// +void s_cond_qcqp_arg_create(struct s_cond_qcqp_arg *cond_arg, void *mem); +// +void s_cond_qcqp_arg_set_default(struct s_cond_qcqp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 square-root +void s_cond_qcqp_arg_set_ric_alg(int ric_alg, struct s_cond_qcqp_arg *cond_arg); +// condense last stage: 0 last stage disregarded, 1 last stage condensed too +void s_cond_qcqp_arg_set_cond_last_stage(int cond_last_stage, struct s_cond_qcqp_arg *cond_arg); + +// +void s_cond_qcqp_compute_dim(struct s_ocp_qcqp_dim *ocp_dim, struct s_dense_qcqp_dim *dense_dim); +// +hpipm_size_t s_cond_qcqp_ws_memsize(struct s_ocp_qcqp_dim *ocp_dim, struct s_cond_qcqp_arg *cond_arg); +// +void s_cond_qcqp_ws_create(struct s_ocp_qcqp_dim *ocp_dim, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws, void *mem); +// +void s_cond_qcqp_qc(struct s_ocp_qcqp *ocp_qp, struct blasfeo_smat *Hq2, int *Hq_nzero2, struct blasfeo_smat *Ct2, struct blasfeo_svec *d2, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws); +// +void s_cond_qcqp_qc_lhs(struct s_ocp_qcqp *ocp_qp, struct blasfeo_smat *Hq2, int *Hq_nzero2, struct blasfeo_smat *Ct2, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws); +// +void s_cond_qcqp_qc_rhs(struct s_ocp_qcqp *ocp_qp, struct blasfeo_svec *d2, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws); +// +void s_cond_qcqp_cond(struct s_ocp_qcqp *ocp_qp, struct s_dense_qcqp *dense_qp, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws); +// +void s_cond_qcqp_cond_rhs(struct s_ocp_qcqp *ocp_qp, struct s_dense_qcqp *dense_qp, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws); +// +void s_cond_qcqp_cond_lhs(struct s_ocp_qcqp *ocp_qp, struct s_dense_qcqp *dense_qp, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws); +// +void s_cond_qcqp_expand_sol(struct s_ocp_qcqp *ocp_qp, struct s_dense_qcqp_sol *dense_qp_sol, struct s_ocp_qcqp_sol *ocp_qp_sol, struct s_cond_qcqp_arg *cond_arg, struct s_cond_qcqp_ws *cond_ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_COND_QCQP_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_core_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_s_core_qp_ipm.h new file mode 100644 index 00000000000000..480392c7d91f11 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_core_qp_ipm.h @@ -0,0 +1,101 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_CORE_QP_IPM_ +#define HPIPM_S_CORE_QP_IPM_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct s_core_qp_ipm_workspace + { + float *v; // primal variables + float *pi; // equality constraints multipliers + float *lam; // inequality constraints multipliers + float *t; // inequality constraints slacks + float *t_inv; // inverse of t + float *v_bkp; // backup of primal variables + float *pi_bkp; // backup of equality constraints multipliers + float *lam_bkp; // backup of inequality constraints multipliers + float *t_bkp; // backup of inequality constraints slacks + float *dv; // step in v + float *dpi; // step in pi + float *dlam; // step in lam + float *dt; // step in t + float *res_g; // q-residuals + float *res_b; // b-residuals + float *res_d; // d-residuals + float *res_m; // m-residuals + float *res_m_bkp; // m-residuals + float *Gamma; // Hessian update + float *gamma; // gradient update + float alpha_prim; // step length + float alpha_dual; // step length + float alpha; // step length + float sigma; // centering XXX + float mu; // duality measuere + float mu_aff; // affine duality measuere + float nc_inv; // 1.0/nc, where nc is the total number of constraints + float nc_mask_inv; // 1.0/nc_mask + float lam_min; // min value in lam vector + float t_min; // min value in t vector + float t_min_inv; // inverse of min value in t vector + float tau_min; // min value of barrier parameter + int nv; // number of primal variables + int ne; // number of equality constraints + int nc; // (twice the) number of (two-sided) inequality constraints + int nc_mask; // total number of ineq constr after masking + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam also in solution, or only in Gamma computation + hpipm_size_t memsize; // memory size (in bytes) of workspace + }; + + + +// +hpipm_size_t s_memsize_core_qp_ipm(int nv, int ne, int nc); +// +void s_create_core_qp_ipm(int nv, int ne, int nc, struct s_core_qp_ipm_workspace *workspace, void *mem); +// +void s_core_qp_ipm(struct s_core_qp_ipm_workspace *workspace); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_S_CORE_QP_IPM_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_core_qp_ipm_aux.h b/third_party/acados/include/hpipm/include/hpipm_s_core_qp_ipm_aux.h new file mode 100644 index 00000000000000..1ac3d7ede9bba8 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_core_qp_ipm_aux.h @@ -0,0 +1,68 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_CORE_QP_IPM_AUX_ +#define HPIPM_S_CORE_QP_IPM_AUX_ + +#ifdef __cplusplus +extern "C" { +#endif + +// +void s_compute_Gamma_gamma_qp(float *res_d, float *res_m, struct s_core_qp_ipm_workspace *rws); +// +void s_compute_gamma_qp(float *res_d, float *res_m, struct s_core_qp_ipm_workspace *rws); +// +void s_compute_lam_t_qp(float *res_d, float *res_m, float *dlam, float *dt, struct s_core_qp_ipm_workspace *rws); +// +void s_compute_alpha_qp(struct s_core_qp_ipm_workspace *rws); +// +void s_update_var_qp(struct s_core_qp_ipm_workspace *rws); +// +void s_compute_mu_aff_qp(struct s_core_qp_ipm_workspace *rws); +// +void s_backup_res_m(struct s_core_qp_ipm_workspace *rws); +// +void s_compute_centering_correction_qp(struct s_core_qp_ipm_workspace *rws); +// +void s_compute_centering_qp(struct s_core_qp_ipm_workspace *rws); +// +void s_compute_tau_min_qp(struct s_core_qp_ipm_workspace *rws); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_S_CORE_QP_IPM_AUX_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp.h new file mode 100644 index 00000000000000..d03c065375f323 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp.h @@ -0,0 +1,200 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_DENSE_QCQP_H_ +#define HPIPM_S_DENSE_QCQP_H_ + + + +#include +#include + +#include "hpipm_s_dense_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qcqp + { + struct s_dense_qcqp_dim *dim; + struct blasfeo_smat *Hv; // hessian of cost & vector work space + struct blasfeo_smat *A; // equality constraint matrix + struct blasfeo_smat *Ct; // inequality constraints matrix + struct blasfeo_smat *Hq; // hessians of quadratic constraints + struct blasfeo_svec *gz; // gradient of cost & gradient of slacks + struct blasfeo_svec *b; // equality constraint vector + struct blasfeo_svec *d; // inequality constraints vector + struct blasfeo_svec *d_mask; // inequality constraints mask vector + struct blasfeo_svec *m; // rhs of complementarity condition + struct blasfeo_svec *Z; // (diagonal) hessian of slacks + int *idxb; // indices of box constrained variables within [u; x] + int *idxs_rev; // index of soft constraints (reverse storage) + int *Hq_nzero; // for each int, the last 3 bits ...abc, {a,b,c}=0 => {R,S,Q}=0 + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_dense_qcqp_memsize(struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_create(struct s_dense_qcqp_dim *dim, struct s_dense_qcqp *qp, void *memory); + +// +void s_dense_qcqp_set(char *field, void *value, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_H(float *H, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_g(float *g, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_A(float *A, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_b(float *b, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_idxb(int *idxb, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_lb(float *lb, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_lb_mask(float *lb, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_ub(float *ub, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_ub_mask(float *ub, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_C(float *C, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_lg(float *lg, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_lg_mask(float *lg, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_ug(float *ug, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_ug_mask(float *ug, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_Hq(float *Hq, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_gq(float *gq, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_uq(float *uq, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_uq_mask(float *uq, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_idxs(int *idxs, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_idxs_rev(int *idxs_rev, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_Zl(float *Zl, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_Zu(float *Zu, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_zl(float *zl, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_zu(float *zu, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_ls(float *ls, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_ls_mask(float *ls, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_us(float *us, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_set_us_mask(float *us, struct s_dense_qcqp *qp); + +// getters (COLMAJ) + +void s_dense_qcqp_get_H(struct s_dense_qcqp *qp, float *H); +// +void s_dense_qcqp_get_g(struct s_dense_qcqp *qp, float *g); +// +void s_dense_qcqp_get_A(struct s_dense_qcqp *qp, float *A); +// +void s_dense_qcqp_get_b(struct s_dense_qcqp *qp, float *b); +// +void s_dense_qcqp_get_idxb(struct s_dense_qcqp *qp, int *idxb); +// +void s_dense_qcqp_get_lb(struct s_dense_qcqp *qp, float *lb); +// +void s_dense_qcqp_get_lb_mask(struct s_dense_qcqp *qp, float *lb); +// +void s_dense_qcqp_get_ub(struct s_dense_qcqp *qp, float *ub); +// +void s_dense_qcqp_get_ub_mask(struct s_dense_qcqp *qp, float *ub); +// +void s_dense_qcqp_get_C(struct s_dense_qcqp *qp, float *C); +// +void s_dense_qcqp_get_lg(struct s_dense_qcqp *qp, float *lg); +// +void s_dense_qcqp_get_lg_mask(struct s_dense_qcqp *qp, float *lg); +// +void s_dense_qcqp_get_ug(struct s_dense_qcqp *qp, float *ug); +// +void s_dense_qcqp_get_ug_mask(struct s_dense_qcqp *qp, float *ug); +// +void s_dense_qcqp_get_idxs(struct s_dense_qcqp *qp, int *idxs); +// +void s_dense_qcqp_get_idxs_rev(struct s_dense_qcqp *qp, int *idxs_rev); +// +void s_dense_qcqp_get_Zl(struct s_dense_qcqp *qp, float *Zl); +// +void s_dense_qcqp_get_Zu(struct s_dense_qcqp *qp, float *Zu); +// +void s_dense_qcqp_get_zl(struct s_dense_qcqp *qp, float *zl); +// +void s_dense_qcqp_get_zu(struct s_dense_qcqp *qp, float *zu); +// +void s_dense_qcqp_get_ls(struct s_dense_qcqp *qp, float *ls); +// +void s_dense_qcqp_get_ls_mask(struct s_dense_qcqp *qp, float *ls); +// +void s_dense_qcqp_get_us(struct s_dense_qcqp *qp, float *us); +// +void s_dense_qcqp_get_us_mask(struct s_dense_qcqp *qp, float *us); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_DENSE_QCQP_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_dim.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_dim.h new file mode 100644 index 00000000000000..04908c2c3ad97f --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_dim.h @@ -0,0 +1,99 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_DENSE_QCQP_DIM_H_ +#define HPIPM_S_DENSE_QCQP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qcqp_dim + { + struct s_dense_qp_dim *qp_dim; // dim of qp approximation + int nv; // number of variables + int ne; // number of equality constraints + int nb; // number of box constraints + int ng; // number of general constraints + int nq; // number of quadratic constraints + int nsb; // number of softened box constraints + int nsg; // number of softened general constraints + int nsq; // number of softened quadratic constraints + int ns; // number of softened constraints (nsb+nsg+nsq) TODO number of slacks + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_dense_qcqp_dim_memsize(); +// +void s_dense_qcqp_dim_create(struct s_dense_qcqp_dim *dim, void *memory); +// +void s_dense_qcqp_dim_set(char *fiels_name, int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_nv(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_ne(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_nb(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_ng(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_nq(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_nsb(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_nsg(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_nsq(int value, struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_dim_set_ns(int value, struct s_dense_qcqp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_DENSE_QCQP_DIM_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_ipm.h new file mode 100644 index 00000000000000..8f85768ee3d777 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_ipm.h @@ -0,0 +1,204 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_DENSE_QCQP_IPM_H_ +#define HPIPM_S_DENSE_QCQP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qcqp_ipm_arg + { + struct s_dense_qp_ipm_arg *qp_arg; + float mu0; // initial value for duality measure + float alpha_min; // exit cond on step length + float res_g_max; // exit cond on inf norm of residuals + float res_b_max; // exit cond on inf norm of residuals + float res_d_max; // exit cond on inf norm of residuals + float res_m_max; // exit cond on inf norm of residuals + float reg_prim; // reg of primal hessian + float reg_dual; // reg of dual hessian + float lam_min; // min value in lam vector + float t_min; // min value in t vector + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int scale; // scale hessian + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq + int abs_form; // absolute IPM formulation + int comp_res_exit; // compute residuals on exit (only for abs_form==1) + int comp_res_pred; // compute residuals of prediction + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct s_dense_qcqp_ipm_ws + { +// float qp_res[4]; // infinity norm of residuals + struct s_dense_qp_ipm_ws *qp_ws; + struct s_dense_qp *qp; + struct s_dense_qp_sol *qp_sol; + struct s_dense_qcqp_res_ws *qcqp_res_ws; + struct s_dense_qcqp_res *qcqp_res; + struct blasfeo_svec *tmp_nv; +// float *stat; // convergence statistics +// void *lq_work0; +// void *lq_work1; + int iter; // iteration number +// int stat_max; // iterations saved in stat +// int stat_m; // numer of recorded stat per ipm iter +// int scale; +// int use_hess_fact; + int status; + hpipm_size_t memsize; // memory size (in bytes) of workspace + }; + + + +// +hpipm_size_t s_dense_qcqp_ipm_arg_memsize(struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_ipm_arg_create(struct s_dense_qcqp_dim *dim, struct s_dense_qcqp_ipm_arg *arg, void *mem); +// +void s_dense_qcqp_ipm_arg_set_default(enum hpipm_mode mode, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set(char *field, void *value, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_iter_max(int *iter_max, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_alpha_min(float *alpha_min, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_mu0(float *mu0, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_tol_stat(float *tol_stat, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_tol_eq(float *tol_eq, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_tol_ineq(float *tol_ineq, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_tol_comp(float *tol_comp, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_reg_prim(float *reg, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_reg_dual(float *reg, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_warm_start(int *warm_start, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_pred_corr(int *pred_corr, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_cond_pred_corr(int *cond_pred_corr, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_comp_res_pred(int *comp_res_pred, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_comp_res_exit(int *comp_res_exit, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_lam_min(float *value, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_t_min(float *value, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_split_step(int *value, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_arg_set_t_lam_min(int *value, struct s_dense_qcqp_ipm_arg *arg); + +// +hpipm_size_t s_dense_qcqp_ipm_ws_memsize(struct s_dense_qcqp_dim *qp_dim, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_ipm_ws_create(struct s_dense_qcqp_dim *qp_dim, struct s_dense_qcqp_ipm_arg *arg, struct s_dense_qcqp_ipm_ws *ws, void *mem); +// +void s_dense_qcqp_ipm_get(char *field, struct s_dense_qcqp_ipm_ws *ws, void *value); +// +void s_dense_qcqp_ipm_get_status(struct s_dense_qcqp_ipm_ws *ws, int *status); +// +void s_dense_qcqp_ipm_get_iter(struct s_dense_qcqp_ipm_ws *ws, int *iter); +// +void s_dense_qcqp_ipm_get_max_res_stat(struct s_dense_qcqp_ipm_ws *ws, float *res_stat); +// +void s_dense_qcqp_ipm_get_max_res_eq(struct s_dense_qcqp_ipm_ws *ws, float *res_eq); +// +void s_dense_qcqp_ipm_get_max_res_ineq(struct s_dense_qcqp_ipm_ws *ws, float *res_ineq); +// +void s_dense_qcqp_ipm_get_max_res_comp(struct s_dense_qcqp_ipm_ws *ws, float *res_comp); +// +void s_dense_qcqp_ipm_get_stat(struct s_dense_qcqp_ipm_ws *ws, float **stat); +// +void s_dense_qcqp_ipm_get_stat_m(struct s_dense_qcqp_ipm_ws *ws, int *stat_m); +#if 0 +// +void s_dense_qcqp_init_var(struct s_dense_qcqp *qp, struct s_dense_qcqp_sol *qp_sol, struct s_dense_qcqp_ipm_arg *arg, struct s_dense_qcqp_ipm_ws *ws); +#endif +// +void s_dense_qcqp_ipm_solve(struct s_dense_qcqp *qp, struct s_dense_qcqp_sol *qp_sol, struct s_dense_qcqp_ipm_arg *arg, struct s_dense_qcqp_ipm_ws *ws); +#if 0 +// +void s_dense_qcqp_ipm_predict(struct s_dense_qcqp *qp, struct s_dense_qcqp_sol *qp_sol, struct s_dense_qcqp_ipm_arg *arg, struct s_dense_qcqp_ipm_ws *ws); +// +void s_dense_qcqp_ipm_sens(struct s_dense_qcqp *qp, struct s_dense_qcqp_sol *qp_sol, struct s_dense_qcqp_ipm_arg *arg, struct s_dense_qcqp_ipm_ws *ws); +#endif + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_DENSE_QCQP_IPM_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_res.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_res.h new file mode 100644 index 00000000000000..779658cc8f8b0a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_res.h @@ -0,0 +1,108 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_DENSE_QCQP_RES_H_ +#define HPIPM_S_DENSE_QCQP_RES_H_ + + + +#include +#include + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qcqp_res + { + struct s_dense_qcqp_dim *dim; + struct blasfeo_svec *res_g; // q-residuals + struct blasfeo_svec *res_b; // b-residuals + struct blasfeo_svec *res_d; // d-residuals + struct blasfeo_svec *res_m; // m-residuals + float res_max[4]; // infinity norm of residuals + float res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct s_dense_qcqp_res_ws + { + struct blasfeo_svec *tmp_nv; // work space of size nv + struct blasfeo_svec *tmp_nbgq; // work space of size nbM+ngM+nqM + struct blasfeo_svec *tmp_ns; // work space of size nsM + struct blasfeo_svec *q_fun; // value for evaluation of quadr constr + struct blasfeo_svec *q_adj; // value for adjoint of quadr constr + int use_q_fun; // reuse cached value for evaluation of quadr constr + int use_q_adj; // reuse cached value for adjoint of quadr constr + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_dense_qcqp_res_memsize(struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_res_create(struct s_dense_qcqp_dim *dim, struct s_dense_qcqp_res *res, void *mem); +// +hpipm_size_t s_dense_qcqp_res_ws_memsize(struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_res_ws_create(struct s_dense_qcqp_dim *dim, struct s_dense_qcqp_res_ws *workspace, void *mem); +// +void s_dense_qcqp_res_compute(struct s_dense_qcqp *qp, struct s_dense_qcqp_sol *qp_sol, struct s_dense_qcqp_res *res, struct s_dense_qcqp_res_ws *ws); +// +void s_dense_qcqp_res_compute_inf_norm(struct s_dense_qcqp_res *res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_S_DENSE_QCQP_RES_H_ + + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_sol.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_sol.h new file mode 100644 index 00000000000000..197a690e520ffa --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_sol.h @@ -0,0 +1,86 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_DENSE_QCQP_SOL_H_ +#define HPIPM_S_DENSE_QCQP_SOL_H_ + + + +#include +#include + +#include "hpipm_s_dense_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qcqp_sol + { + struct s_dense_qcqp_dim *dim; + struct blasfeo_svec *v; + struct blasfeo_svec *pi; + struct blasfeo_svec *lam; + struct blasfeo_svec *t; + void *misc; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_dense_qcqp_sol_memsize(struct s_dense_qcqp_dim *dim); +// +void s_dense_qcqp_sol_create(struct s_dense_qcqp_dim *dim, struct s_dense_qcqp_sol *qp_sol, void *memory); +// +void s_dense_qcqp_sol_get_v(struct s_dense_qcqp_sol *qp_sol, float *v); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_DENSE_QCQP_SOL_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_utils.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_utils.h new file mode 100644 index 00000000000000..4f5aae26eb1aba --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qcqp_utils.h @@ -0,0 +1,83 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_DENSE_QCQP_UTILS_H_ +#define HPIPM_S_DENSE_QCQP_UTILS_H_ + + + +#include +#include + +#include "hpipm_s_dense_qcqp_dim.h" +#include "hpipm_s_dense_qcqp.h" +#include "hpipm_s_dense_qcqp_sol.h" +//#include "hpipm_s_dense_qcqp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_dense_qcqp_dim_print(struct s_dense_qcqp_dim *qp_dim); +// +//void s_dense_qcqp_dim_codegen(char *file_name, char *mode, struct s_dense_qcqp_dim *qp_dim); +// +void s_dense_qcqp_print(struct s_dense_qcqp_dim *qp_dim, struct s_dense_qcqp *qp); +// +//void s_dense_qcqp_codegen(char *file_name, char *mode, struct s_dense_qcqp_dim *qp_dim, struct s_dense_qcqp *qp); +// +void s_dense_qcqp_sol_print(struct s_dense_qcqp_dim *qp_dim, struct s_dense_qcqp_sol *dense_qcqp_sol); +// +//void s_dense_qcqp_ipm_arg_codegen(char *file_name, char *mode, struct s_dense_qcqp_dim *qp_dim, struct s_dense_qcqp_ipm_arg *arg); +// +void s_dense_qcqp_res_print(struct s_dense_qcqp_dim *qp_dim, struct s_dense_qcqp_res *dense_qcqp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_DENSE_QCQP_UTILS_H_ + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qp.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp.h new file mode 100644 index 00000000000000..3c2517fe1b76fc --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp.h @@ -0,0 +1,207 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_DENSE_QP_H_ +#define HPIPM_S_DENSE_QP_H_ + + + +#include +#include + +#include "hpipm_s_dense_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qp + { + struct s_dense_qp_dim *dim; + struct blasfeo_smat *Hv; // hessian & gradient + struct blasfeo_smat *A; // dynamics matrix + struct blasfeo_smat *Ct; // constraints matrix + struct blasfeo_svec *gz; // gradient & gradient of slacks + struct blasfeo_svec *b; // dynamics vector + struct blasfeo_svec *d; // constraints vector + struct blasfeo_svec *d_mask; // inequality constraints mask vector + struct blasfeo_svec *m; // rhs of complementarity condition + struct blasfeo_svec *Z; // (diagonal) hessian of slacks + int *idxb; // indices of box constrained variables within [u; x] + int *idxs_rev; // index of soft constraints (reverse storage) + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_dense_qp_memsize(struct s_dense_qp_dim *dim); +// +void s_dense_qp_create(struct s_dense_qp_dim *dim, struct s_dense_qp *qp, void *memory); + +// setters - colmaj +// +void s_dense_qp_set_all(float *H, float *g, float *A, float *b, int *idxb, float *d_lb, float *d_ub, float *C, float *d_lg, float *d_ug, float *Zl, float *Zu, float *zl, float *zu, int *idxs, float *d_ls, float *d_us, struct s_dense_qp *qp); +// +void s_dense_qp_get_all(struct s_dense_qp *qp, float *H, float *g, float *A, float *b, int *idxb, float *d_lb, float *d_ub, float *C, float *d_lg, float *d_ug, float *Zl, float *Zu, float *zl, float *zu, int *idxs, float *d_ls, float *d_us); +// +void s_dense_qp_set(char *field, void *value, struct s_dense_qp *qp); +// +void s_dense_qp_set_H(float *H, struct s_dense_qp *qp); +// +void s_dense_qp_set_g(float *g, struct s_dense_qp *qp); +// +void s_dense_qp_set_A(float *A, struct s_dense_qp *qp); +// +void s_dense_qp_set_b(float *b, struct s_dense_qp *qp); +// +void s_dense_qp_set_idxb(int *idxb, struct s_dense_qp *qp); +// +void s_dense_qp_set_Jb(float *Jb, struct s_dense_qp *qp); +// +void s_dense_qp_set_lb(float *lb, struct s_dense_qp *qp); +// +void s_dense_qp_set_lb_mask(float *lb, struct s_dense_qp *qp); +// +void s_dense_qp_set_ub(float *ub, struct s_dense_qp *qp); +// +void s_dense_qp_set_ub_mask(float *ub, struct s_dense_qp *qp); +// +void s_dense_qp_set_C(float *C, struct s_dense_qp *qp); +// +void s_dense_qp_set_lg(float *lg, struct s_dense_qp *qp); +// +void s_dense_qp_set_lg_mask(float *lg, struct s_dense_qp *qp); +// +void s_dense_qp_set_ug(float *ug, struct s_dense_qp *qp); +// +void s_dense_qp_set_ug_mask(float *ug, struct s_dense_qp *qp); +// +void s_dense_qp_set_idxs(int *idxs, struct s_dense_qp *qp); +// +void s_dense_qp_set_idxs_rev(int *idxs_rev, struct s_dense_qp *qp); +// +void s_dense_qp_set_Jsb(float *Jsb, struct s_dense_qp *qp); +// +void s_dense_qp_set_Jsg(float *Jsg, struct s_dense_qp *qp); +// +void s_dense_qp_set_Zl(float *Zl, struct s_dense_qp *qp); +// +void s_dense_qp_set_Zu(float *Zu, struct s_dense_qp *qp); +// +void s_dense_qp_set_zl(float *zl, struct s_dense_qp *qp); +// +void s_dense_qp_set_zu(float *zu, struct s_dense_qp *qp); +// +void s_dense_qp_set_ls(float *ls, struct s_dense_qp *qp); +// +void s_dense_qp_set_ls_mask(float *ls, struct s_dense_qp *qp); +// +void s_dense_qp_set_us(float *us, struct s_dense_qp *qp); +// +void s_dense_qp_set_us_mask(float *us, struct s_dense_qp *qp); + +// getters - colmaj +// +void s_dense_qp_get_H(struct s_dense_qp *qp, float *H); +// +void s_dense_qp_get_g(struct s_dense_qp *qp, float *g); +// +void s_dense_qp_get_A(struct s_dense_qp *qp, float *A); +// +void s_dense_qp_get_b(struct s_dense_qp *qp, float *b); +// +void s_dense_qp_get_idxb(struct s_dense_qp *qp, int *idxb); +// +void s_dense_qp_get_lb(struct s_dense_qp *qp, float *lb); +// +void s_dense_qp_get_lb_mask(struct s_dense_qp *qp, float *lb); +// +void s_dense_qp_get_ub(struct s_dense_qp *qp, float *ub); +// +void s_dense_qp_get_ub_mask(struct s_dense_qp *qp, float *ub); +// +void s_dense_qp_get_C(struct s_dense_qp *qp, float *C); +// +void s_dense_qp_get_lg(struct s_dense_qp *qp, float *lg); +// +void s_dense_qp_get_lg_mask(struct s_dense_qp *qp, float *lg); +// +void s_dense_qp_get_ug(struct s_dense_qp *qp, float *ug); +// +void s_dense_qp_get_ug_mask(struct s_dense_qp *qp, float *ug); +// +void s_dense_qp_get_idxs(struct s_dense_qp *qp, int *idxs); +// +void s_dense_qp_get_idxs_rev(struct s_dense_qp *qp, int *idxs_rev); +// +void s_dense_qp_get_Zl(struct s_dense_qp *qp, float *Zl); +// +void s_dense_qp_get_Zu(struct s_dense_qp *qp, float *Zu); +// +void s_dense_qp_get_zl(struct s_dense_qp *qp, float *zl); +// +void s_dense_qp_get_zu(struct s_dense_qp *qp, float *zu); +// +void s_dense_qp_get_ls(struct s_dense_qp *qp, float *ls); +// +void s_dense_qp_get_ls_mask(struct s_dense_qp *qp, float *ls); +// +void s_dense_qp_get_us(struct s_dense_qp *qp, float *us); +// +void s_dense_qp_get_us_mask(struct s_dense_qp *qp, float *us); + +// setters - rowmaj +// +void s_dense_qp_set_all_rowmaj(float *H, float *g, float *A, float *b, int *idxb, float *d_lb, float *d_ub, float *C, float *d_lg, float *d_ug, float *Zl, float *Zu, float *zl, float *zu, int *idxs, float *d_ls, float *d_us, struct s_dense_qp *qp); + +// getters - rowmaj +// +void s_dense_qp_get_all_rowmaj(struct s_dense_qp *qp, float *H, float *g, float *A, float *b, int *idxb, float *d_lb, float *d_ub, float *C, float *d_lg, float *d_ug, float *Zl, float *Zu, float *zl, float *zu, int *idxs, float *d_ls, float *d_us); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_DENSE_QP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_dim.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_dim.h new file mode 100644 index 00000000000000..b979d24432a9ee --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_dim.h @@ -0,0 +1,94 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_DENSE_QP_DIM_H_ +#define HPIPM_S_DENSE_QP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qp_dim + { + int nv; // number of variables + int ne; // number of equality constraints + int nb; // number of box constraints + int ng; // number of general constraints + int nsb; // number of softened box constraints + int nsg; // number of softened general constraints + int ns; // number of softened constraints (nsb+nsg) + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_dense_qp_dim_memsize(); +// +void s_dense_qp_dim_create(struct s_dense_qp_dim *qp_dim, void *memory); +// +void s_dense_qp_dim_set_all(int nv, int ne, int nb, int ng, int nsb, int nsg, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set(char *fiels_name, int value, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set_nv(int value, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set_ne(int value, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set_nb(int value, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set_ng(int value, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set_nsb(int value, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set_nsg(int value, struct s_dense_qp_dim *dim); +// +void s_dense_qp_dim_set_ns(int value, struct s_dense_qp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_DENSE_QP_DIM_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_ipm.h new file mode 100644 index 00000000000000..f2d56d45299574 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_ipm.h @@ -0,0 +1,260 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_DENSE_QP_IPM_H_ +#define HPIPM_S_DENSE_QP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qp_ipm_arg + { + float mu0; // initial value for duality measure + float alpha_min; // exit cond on step length + float res_g_max; // exit cond on inf norm of residuals + float res_b_max; // exit cond on inf norm of residuals + float res_d_max; // exit cond on inf norm of residuals + float res_m_max; // exit cond on inf norm of residuals + float reg_prim; // reg of primal hessian + float reg_dual; // reg of dual hessian + float lam_min; // min value in lam vector + float t_min; // min value in t vector + float tau_min; // min value of barrier parameter + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int scale; // scale hessian + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq + int abs_form; // absolute IPM formulation + int comp_res_exit; // compute residuals on exit (only for abs_form==1) + int comp_res_pred; // compute residuals of prediction + int kkt_fact_alg; // 0 null-space, 1 schur-complement + int remove_lin_dep_eq; // 0 do not, 1 do check and remove linearly dependent equality constraints + int compute_obj; // compute obj on exit + int split_step; // use different steps for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct s_dense_qp_ipm_ws + { + struct s_core_qp_ipm_workspace *core_workspace; + struct s_dense_qp_res_ws *res_ws; + struct s_dense_qp_sol *sol_step; + struct s_dense_qp_sol *sol_itref; + struct s_dense_qp *qp_step; + struct s_dense_qp *qp_itref; + struct s_dense_qp_res *res; + struct s_dense_qp_res *res_itref; + struct s_dense_qp_res *res_step; + struct blasfeo_svec *Gamma; // + struct blasfeo_svec *gamma; // + struct blasfeo_svec *Zs_inv; // + struct blasfeo_smat *Lv; // + struct blasfeo_smat *AL; // + struct blasfeo_smat *Le; // + struct blasfeo_smat *Ctx; // + struct blasfeo_svec *lv; // + struct blasfeo_svec *sv; // scale for Lv + struct blasfeo_svec *se; // scale for Le + struct blasfeo_svec *tmp_nbg; // work space of size nb+ng + struct blasfeo_svec *tmp_ns; // work space of size ns + struct blasfeo_smat *lq0; + struct blasfeo_smat *lq1; + struct blasfeo_svec *tmp_m; + struct blasfeo_smat *A_LQ; + struct blasfeo_smat *A_Q; + struct blasfeo_smat *Zt; + struct blasfeo_smat *ZtH; + struct blasfeo_smat *ZtHZ; + struct blasfeo_svec *xy; + struct blasfeo_svec *Yxy; + struct blasfeo_svec *xz; + struct blasfeo_svec *tmp_nv; + struct blasfeo_svec *tmp_2ns; + struct blasfeo_svec *tmp_nv2ns; + struct blasfeo_smat *A_li; // A of linearly independent equality constraints + struct blasfeo_svec *b_li; // b of linearly independent equality constraints + struct blasfeo_smat *A_bkp; // pointer to backup A + struct blasfeo_svec *b_bkp; // pointer to backup b + struct blasfeo_smat *Ab_LU; + float *stat; // convergence statistics + int *ipiv_v; + int *ipiv_e; + int *ipiv_e1; + void *lq_work0; + void *lq_work1; + void *lq_work_null; + void *orglq_work_null; + int iter; // iteration number + int stat_max; // iterations saved in stat + int stat_m; // numer of recorded stat per ipm iter + int scale; + int use_hess_fact; + int use_A_fact; + int status; + int lq_fact; // cache from arg + int mask_constr; // use constr mask + int ne_li; // number of linearly independent equality constraints + int ne_bkp; // ne backup + hpipm_size_t memsize; // memory size (in bytes) of workspace + }; + + + +// +hpipm_size_t s_dense_qp_ipm_arg_memsize(struct s_dense_qp_dim *qp_dim); +// +void s_dense_qp_ipm_arg_create(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_ipm_arg *arg, void *mem); +// +void s_dense_qp_ipm_arg_set_default(enum hpipm_mode mode, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set(char *field, void *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_iter_max(int *iter_max, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_alpha_min(float *alpha_min, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_mu0(float *mu0, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_tol_stat(float *tol_stat, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_tol_eq(float *tol_eq, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_tol_ineq(float *tol_ineq, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_tol_comp(float *tol_comp, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_reg_prim(float *reg, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_reg_dual(float *reg, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_warm_start(int *warm_start, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_pred_corr(int *pred_corr, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_cond_pred_corr(int *cond_pred_corr, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_comp_res_pred(int *comp_res_pred, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_comp_res_exit(int *comp_res_exit, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_lam_min(float *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_t_min(float *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_tau_min(float *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_kkt_fact_alg(int *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_remove_lin_dep_eq(int *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_compute_obj(int *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_split_step(int *value, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_arg_set_t_lam_min(int *value, struct s_dense_qp_ipm_arg *arg); + +// +hpipm_size_t s_dense_qp_ipm_ws_memsize(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_ipm_ws_create(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws, void *mem); +// +void s_dense_qp_ipm_get(char *field, struct s_dense_qp_ipm_ws *ws, void *value); +// +void s_dense_qp_ipm_get_status(struct s_dense_qp_ipm_ws *ws, int *status); +// +void s_dense_qp_ipm_get_iter(struct s_dense_qp_ipm_ws *ws, int *iter); +// +void s_dense_qp_ipm_get_max_res_stat(struct s_dense_qp_ipm_ws *ws, float *res_stat); +// +void s_dense_qp_ipm_get_max_res_eq(struct s_dense_qp_ipm_ws *ws, float *res_eq); +// +void s_dense_qp_ipm_get_max_res_ineq(struct s_dense_qp_ipm_ws *ws, float *res_ineq); +// +void s_dense_qp_ipm_get_max_res_comp(struct s_dense_qp_ipm_ws *ws, float *res_comp); +// +void s_dense_qp_ipm_get_stat(struct s_dense_qp_ipm_ws *ws, float **stat); +// +void s_dense_qp_ipm_get_stat_m(struct s_dense_qp_ipm_ws *ws, int *stat_m); +// +void s_dense_qp_init_var(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_ipm_abs_step(int kk, struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_ipm_delta_step(int kk, struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_ipm_solve(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_ipm_predict(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_ipm_sens(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_compute_step_length(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_DENSE_QP_IPM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_kkt.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_kkt.h new file mode 100644 index 00000000000000..260dc0ab21d5ef --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_kkt.h @@ -0,0 +1,72 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_DENSE_QP_KKT_H_ +#define HPIPM_S_DENSE_QP_KKT_H_ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_fact_solve_kkt_unconstr_dense_qp(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_fact_solve_kkt_step_dense_qp(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_fact_lq_solve_kkt_step_dense_qp(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_solve_kkt_step_dense_qp(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_remove_lin_dep_eq(struct s_dense_qp *qp, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_restore_lin_dep_eq(struct s_dense_qp *qp, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); +// +void s_dense_qp_compute_obj(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_ipm_arg *arg, struct s_dense_qp_ipm_ws *ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_DENSE_QP_KKT_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_res.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_res.h new file mode 100644 index 00000000000000..06b609c537cb1e --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_res.h @@ -0,0 +1,106 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_DENSE_QP_RES_H_ +#define HPIPM_S_DENSE_QP_RES_H_ + + + +#include +#include + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qp_res + { + struct s_dense_qp_dim *dim; + struct blasfeo_svec *res_g; // q-residuals + struct blasfeo_svec *res_b; // b-residuals + struct blasfeo_svec *res_d; // d-residuals + struct blasfeo_svec *res_m; // m-residuals + float res_max[4]; // max of residuals + float res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct s_dense_qp_res_ws + { + struct blasfeo_svec *tmp_nbg; // work space of size nbM+ngM + struct blasfeo_svec *tmp_ns; // work space of size nsM + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_dense_qp_res_memsize(struct s_dense_qp_dim *dim); +// +void s_dense_qp_res_create(struct s_dense_qp_dim *dim, struct s_dense_qp_res *res, void *mem); +// +hpipm_size_t s_dense_qp_res_ws_memsize(struct s_dense_qp_dim *dim); +// +void s_dense_qp_res_ws_create(struct s_dense_qp_dim *dim, struct s_dense_qp_res_ws *workspace, void *mem); +// +void s_dense_qp_res_compute(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_res *res, struct s_dense_qp_res_ws *ws); +// +void s_dense_qp_res_compute_lin(struct s_dense_qp *qp, struct s_dense_qp_sol *qp_sol, struct s_dense_qp_sol *qp_step, struct s_dense_qp_res *res, struct s_dense_qp_res_ws *ws); +// +void s_dense_qp_res_compute_inf_norm(struct s_dense_qp_res *res); +// +void s_dense_qp_res_get_all(struct s_dense_qp_res *res, float *res_g, float *res_ls, float *res_us, float *res_b, float *res_d_lb, float *res_d_ub, float *res_d_lg, float *res_d_ug, float *res_d_ls, float *res_d_us, float *res_m_lb, float *res_m_ub, float *res_m_lg, float *res_m_ug, float *res_m_ls, float *res_m_us); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_D_DENSE_QP_RES_H_ + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_sol.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_sol.h new file mode 100644 index 00000000000000..1f40076378d833 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_sol.h @@ -0,0 +1,94 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_DENSE_QP_SOL_H_ +#define HPIPM_S_DENSE_QP_SOL_H_ + + + +#include +#include + +#include "hpipm_s_dense_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_dense_qp_sol + { + struct s_dense_qp_dim *dim; + struct blasfeo_svec *v; + struct blasfeo_svec *pi; + struct blasfeo_svec *lam; + struct blasfeo_svec *t; + void *misc; + float obj; + int valid_obj; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_dense_qp_sol_memsize(struct s_dense_qp_dim *dim); +// +void s_dense_qp_sol_create(struct s_dense_qp_dim *dim, struct s_dense_qp_sol *qp_sol, void *memory); +// +void s_dense_qp_sol_get_all(struct s_dense_qp_sol *qp_sol, float *v, float *ls, float *us, float *pi, float *lam_lb, float *lam_ub, float *lam_lg, float *lam_ug, float *lam_ls, float *lam_us); +// +void s_dense_qp_sol_get(char *field, struct s_dense_qp_sol *sol, void *value); +// +void s_dense_qp_sol_get_v(struct s_dense_qp_sol *sol, float *v); +// +void s_dense_qp_sol_get_valid_obj(struct s_dense_qp_sol *sol, int *valid_obj); +// +void s_dense_qp_sol_get_obj(struct s_dense_qp_sol *sol, float *obj); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_DENSE_QP_SOL_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_utils.h b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_utils.h new file mode 100644 index 00000000000000..3dd93259a55a58 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_dense_qp_utils.h @@ -0,0 +1,84 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_DENSE_QP_UTILS_H_ +#define HPIPM_S_DENSE_QP_UTILS_H_ + + + +#include +#include + +#include "hpipm_s_dense_qp_dim.h" +#include "hpipm_s_dense_qp.h" +#include "hpipm_s_dense_qp_sol.h" +#include "hpipm_s_dense_qp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_dense_qp_dim_print(struct s_dense_qp_dim *qp_dim); +// +//void s_dense_qp_dim_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim); +// +void s_dense_qp_print(struct s_dense_qp_dim *qp_dim, struct s_dense_qp *qp); +// +//void s_dense_qp_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim, struct s_dense_qp *qp); +// +void s_dense_qp_sol_print(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_sol *dense_qp_sol); +// +//void s_dense_qp_ipm_arg_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim, struct s_dense_qp_ipm_arg *arg); +// +void s_dense_qp_res_print(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_res *dense_qp_res); +// +void s_dense_qp_arg_print(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_ipm_arg *qp_ipm_arg); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_DENSE_QP_UTILS_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp.h new file mode 100644 index 00000000000000..b90b2ac6337580 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp.h @@ -0,0 +1,303 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QCQP_H_ +#define HPIPM_S_OCP_QCQP_H_ + + + +#include +#include + +#include "hpipm_s_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qcqp + { + struct s_ocp_qcqp_dim *dim; + struct blasfeo_smat *BAbt; // dynamics matrix & vector work space + struct blasfeo_smat *RSQrq; // hessian of cost & vector work space + struct blasfeo_smat *DCt; // inequality constraints matrix + struct blasfeo_smat **Hq; // hessians of quadratic constraints + struct blasfeo_svec *b; // dynamics vector + struct blasfeo_svec *rqz; // gradient of cost & gradient of slacks + struct blasfeo_svec *d; // inequality constraints vector + struct blasfeo_svec *d_mask; // inequality constraints mask vector + struct blasfeo_svec *m; // rhs of complementarity condition + struct blasfeo_svec *Z; // (diagonal) hessian of slacks + int **idxb; // indices of box constrained variables within [u; x] + int **idxs_rev; // index of soft constraints (reverse storage) + int **Hq_nzero; // for each int, the last 3 bits ...abc, {a,b,c}=0 => {R,S,Q}=0 + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_ocp_qcqp_strsize(); +// +hpipm_size_t s_ocp_qcqp_memsize(struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_create(struct s_ocp_qcqp_dim *dim, struct s_ocp_qcqp *qp, void *memory); +// +void s_ocp_qcqp_copy_all(struct s_ocp_qcqp *qp_orig, struct s_ocp_qcqp *qp_dest); + +// setters +// +void s_ocp_qcqp_set_all_zero(struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_rhs_zero(struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set(char *fiels_name, int stage, void *value, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_el(char *fiels_name, int stage, int index, void *value, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_A(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_B(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_b(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Q(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_S(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_R(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_q(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_r(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lb(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lb_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ub(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ub_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lbx(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lbx_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_el_lbx(int stage, int index, float *elem, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ubx(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ubx_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_el_ubx(int stage, int index, float *elem, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lbu(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lbu_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ubu(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ubu_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_idxb(int stage, int *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_idxbx(int stage, int *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Jbx(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_idxbu(int stage, int *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Jbu(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_C(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_D(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lg(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lg_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ug(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_ug_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Qq(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Sq(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Rq(int stage, float *mat, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_qq(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_rq(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_uq(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_uq_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Zl(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Zu(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_zl(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_zu(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lls(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lls_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lus(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_lus_mask(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_idxs(int stage, int *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_idxs_rev(int stage, int *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Jsbu(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Jsbx(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Jsg(int stage, float *vec, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_set_Jsq(int stage, float *vec, struct s_ocp_qcqp *qp); + +// getters +// +void s_ocp_qcqp_get(char *field, int stage, struct s_ocp_qcqp *qp, void *value); +// +void s_ocp_qcqp_get_A(int stage, struct s_ocp_qcqp *qp, float *mat); +// +void s_ocp_qcqp_get_B(int stage, struct s_ocp_qcqp *qp, float *mat); +// +void s_ocp_qcqp_get_b(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_Q(int stage, struct s_ocp_qcqp *qp, float *mat); +// +void s_ocp_qcqp_get_S(int stage, struct s_ocp_qcqp *qp, float *mat); +// +void s_ocp_qcqp_get_R(int stage, struct s_ocp_qcqp *qp, float *mat); +// +void s_ocp_qcqp_get_q(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_r(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ub(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ub_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lb(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lb_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lbx(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lbx_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ubx(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ubx_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lbu(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lbu_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ubu(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ubu_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_idxb(int stage, struct s_ocp_qcqp *qp, int *vec); +// +//void s_ocp_qcqp_get_idxbx(int stage, struct s_ocp_qcqp *qp, int *vec); +// +//void s_ocp_qcqp_get_Jbx(int stage, struct s_ocp_qcqp *qp, float *vec); +// +//void s_ocp_qcqp_get_idxbu(int stage, struct s_ocp_qcqp *qp, int *vec); +// +//void s_ocp_qcqp_get_Jbu(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_C(int stage, struct s_ocp_qcqp *qp, float *mat); +// +void s_ocp_qcqp_get_D(int stage, struct s_ocp_qcqp *qp, float *mat); +// +void s_ocp_qcqp_get_lg(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lg_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ug(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_ug_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_Zl(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_Zu(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_zl(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_zu(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lls(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lls_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lus(int stage, struct s_ocp_qcqp *qp, float *vec); +// +void s_ocp_qcqp_get_lus_mask(int stage, struct s_ocp_qcqp *qp, float *vec); +// XXX only valid if there is one slack per softed constraint !!! +void s_ocp_qcqp_get_idxs(int stage, struct s_ocp_qcqp *qp, int *vec); +// +void s_ocp_qcqp_get_idxs_rev(int stage, struct s_ocp_qcqp *qp, int *vec); +// +//void s_ocp_qcqp_get_Jsbu(int stage, struct s_ocp_qcqp *qp, float *vec); +// +//void s_ocp_qcqp_get_Jsbx(int stage, struct s_ocp_qcqp *qp, float *vec); +// +//void s_ocp_qcqp_get_Jsg(int stage, struct s_ocp_qcqp *qp, float *vec); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_OCP_QCQP_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_dim.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_dim.h new file mode 100644 index 00000000000000..c09903f07448ea --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_dim.h @@ -0,0 +1,119 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QCQP_DIM_H_ +#define HPIPM_S_OCP_QCQP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qcqp_dim + { + struct s_ocp_qp_dim *qp_dim; // dim of qp approximation + int *nx; // number of states + int *nu; // number of inputs + int *nb; // number of box constraints + int *nbx; // number of (two-sided) state box constraints + int *nbu; // number of (two-sided) input box constraints + int *ng; // number of (two-sided) general constraints + int *nq; // number of (upper) quadratic constraints + int *ns; // number of soft constraints + int *nsbx; // number of (two-sided) soft state box constraints + int *nsbu; // number of (two-sided) soft input box constraints + int *nsg; // number of (two-sided) soft general constraints + int *nsq; // number of (upper) soft quadratic constraints + int N; // horizon length + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_ocp_qcqp_dim_strsize(); +// +hpipm_size_t s_ocp_qcqp_dim_memsize(int N); +// +void s_ocp_qcqp_dim_create(int N, struct s_ocp_qcqp_dim *qp_dim, void *memory); +// +void s_ocp_qcqp_dim_copy_all(struct s_ocp_qcqp_dim *dim_orig, struct s_ocp_qcqp_dim *dim_dest); +// +void s_ocp_qcqp_dim_set(char *field, int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nx(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nu(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nbx(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nbu(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_ng(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nq(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_ns(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nsbx(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nsbu(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nsg(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_set_nsq(int stage, int value, struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_dim_get(struct s_ocp_qcqp_dim *dim, char *field, int stage, int *value); +// +void s_ocp_qcqp_dim_get_N(struct s_ocp_qcqp_dim *dim, int *value); +// +void s_ocp_qcqp_dim_get_nx(struct s_ocp_qcqp_dim *dim, int stage, int *value); +// +void s_ocp_qcqp_dim_get_nu(struct s_ocp_qcqp_dim *dim, int stage, int *value); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_OCP_QCQP_DIM_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_ipm.h new file mode 100644 index 00000000000000..c14fc1c9fd27a9 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_ipm.h @@ -0,0 +1,191 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QCQP_IPM_H_ +#define HPIPM_S_OCP_QCQP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qcqp_ipm_arg + { + struct s_ocp_qp_ipm_arg *qp_arg; + float mu0; // initial value for complementarity slackness + float alpha_min; // exit cond on step length + float res_g_max; // exit cond on inf norm of residuals + float res_b_max; // exit cond on inf norm of residuals + float res_d_max; // exit cond on inf norm of residuals + float res_m_max; // exit cond on inf norm of residuals + float reg_prim; // reg of primal hessian + float lam_min; // min value in lam vector + float t_min; // min value in t vector + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int square_root_alg; // 0 classical Riccati, 1 square-root Riccati + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq (for square_root_alg==1) + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution of equality constraints (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol_eq==1) + int comp_res_pred; // compute residuals of prediction + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct s_ocp_qcqp_ipm_ws + { + struct s_ocp_qp_ipm_ws *qp_ws; + struct s_ocp_qp *qp; + struct s_ocp_qp_sol *qp_sol; + struct s_ocp_qcqp_res_ws *qcqp_res_ws; + struct s_ocp_qcqp_res *qcqp_res; + struct blasfeo_svec *tmp_nuxM; + int iter; // iteration number + int status; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_ocp_qcqp_ipm_arg_strsize(); +// +hpipm_size_t s_ocp_qcqp_ipm_arg_memsize(struct s_ocp_qcqp_dim *ocp_dim); +// +void s_ocp_qcqp_ipm_arg_create(struct s_ocp_qcqp_dim *ocp_dim, struct s_ocp_qcqp_ipm_arg *arg, void *mem); +// +void s_ocp_qcqp_ipm_arg_set_default(enum hpipm_mode mode, struct s_ocp_qcqp_ipm_arg *arg); +// +void s_ocp_qcqp_ipm_arg_set(char *field, void *value, struct s_ocp_qcqp_ipm_arg *arg); +// set maximum number of iterations +void s_ocp_qcqp_ipm_arg_set_iter_max(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// set minimum step lenght +void s_ocp_qcqp_ipm_arg_set_alpha_min(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// set initial value of barrier parameter +void s_ocp_qcqp_ipm_arg_set_mu0(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on stationarity condition +void s_ocp_qcqp_ipm_arg_set_tol_stat(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on equality constr +void s_ocp_qcqp_ipm_arg_set_tol_eq(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on inequality constr +void s_ocp_qcqp_ipm_arg_set_tol_ineq(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on complementarity condition +void s_ocp_qcqp_ipm_arg_set_tol_comp(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// set regularization of primal variables +void s_ocp_qcqp_ipm_arg_set_reg_prim(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// set warm start: 0 no warm start, 1 primal var +void s_ocp_qcqp_ipm_arg_set_warm_start(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// Mehrotra's predictor-corrector IPM algorithm: 0 no predictor-corrector, 1 use predictor-corrector +void s_ocp_qcqp_ipm_arg_set_pred_corr(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// conditional predictor-corrector: 0 no conditinal predictor-corrector, 1 conditional predictor-corrector +void s_ocp_qcqp_ipm_arg_set_cond_pred_corr(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// set riccati algorithm: 0 classic, 1 square-root +void s_ocp_qcqp_ipm_arg_set_ric_alg(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// compute residuals after solution +void s_ocp_qcqp_ipm_arg_set_comp_res_exit(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// compute residuals of prediction +void s_ocp_qcqp_ipm_arg_set_comp_res_pred(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// min value of lam in the solution +void s_ocp_qcqp_ipm_arg_set_lam_min(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// min value of t in the solution +void s_ocp_qcqp_ipm_arg_set_t_min(float *value, struct s_ocp_qcqp_ipm_arg *arg); +// use different step for primal and dual variables +void s_ocp_qcqp_ipm_arg_set_split_step(int *value, struct s_ocp_qcqp_ipm_arg *arg); +// clip t and lam: 0 no, 1 in Gamma computation, 2 in solution +void s_ocp_qcqp_ipm_arg_set_t_lam_min(int *value, struct s_ocp_qcqp_ipm_arg *arg); + +// +hpipm_size_t s_ocp_qcqp_ipm_ws_strsize(); +// +hpipm_size_t s_ocp_qcqp_ipm_ws_memsize(struct s_ocp_qcqp_dim *ocp_dim, struct s_ocp_qcqp_ipm_arg *arg); +// +void s_ocp_qcqp_ipm_ws_create(struct s_ocp_qcqp_dim *ocp_dim, struct s_ocp_qcqp_ipm_arg *arg, struct s_ocp_qcqp_ipm_ws *ws, void *mem); +// +void s_ocp_qcqp_ipm_get(char *field, struct s_ocp_qcqp_ipm_ws *ws, void *value); +// +void s_ocp_qcqp_ipm_get_status(struct s_ocp_qcqp_ipm_ws *ws, int *status); +// +void s_ocp_qcqp_ipm_get_iter(struct s_ocp_qcqp_ipm_ws *ws, int *iter); +// +void s_ocp_qcqp_ipm_get_max_res_stat(struct s_ocp_qcqp_ipm_ws *ws, float *res_stat); +// +void s_ocp_qcqp_ipm_get_max_res_eq(struct s_ocp_qcqp_ipm_ws *ws, float *res_eq); +// +void s_ocp_qcqp_ipm_get_max_res_ineq(struct s_ocp_qcqp_ipm_ws *ws, float *res_ineq); +// +void s_ocp_qcqp_ipm_get_max_res_comp(struct s_ocp_qcqp_ipm_ws *ws, float *res_comp); +// +void s_ocp_qcqp_ipm_get_stat(struct s_ocp_qcqp_ipm_ws *ws, float **stat); +// +void s_ocp_qcqp_ipm_get_stat_m(struct s_ocp_qcqp_ipm_ws *ws, int *stat_m); +// +void s_ocp_qcqp_init_var(struct s_ocp_qcqp *qp, struct s_ocp_qcqp_sol *qp_sol, struct s_ocp_qcqp_ipm_arg *arg, struct s_ocp_qcqp_ipm_ws *ws); +// +void s_ocp_qcqp_ipm_solve(struct s_ocp_qcqp *qp, struct s_ocp_qcqp_sol *qp_sol, struct s_ocp_qcqp_ipm_arg *arg, struct s_ocp_qcqp_ipm_ws *ws); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_S_OCP_QCQP_IPM_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_res.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_res.h new file mode 100644 index 00000000000000..1ceeec93b7ec5c --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_res.h @@ -0,0 +1,115 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QCQP_RES_H_ +#define HPIPM_S_OCP_QCQP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qcqp_res + { + struct s_ocp_qcqp_dim *dim; + struct blasfeo_svec *res_g; // q-residuals + struct blasfeo_svec *res_b; // b-residuals + struct blasfeo_svec *res_d; // d-residuals + struct blasfeo_svec *res_m; // m-residuals + float res_max[4]; // max of residuals + float res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct s_ocp_qcqp_res_ws + { + struct blasfeo_svec *tmp_nuxM; // work space of size nuM+nxM + struct blasfeo_svec *tmp_nbgqM; // work space of size nbM+ngM+nqM + struct blasfeo_svec *tmp_nsM; // work space of size nsM + struct blasfeo_svec *q_fun; // value for evaluation of quadr constr + struct blasfeo_svec *q_adj; // value for adjoint of quadr constr + int use_q_fun; // reuse cached value for evaluation of quadr constr + int use_q_adj; // reuse cached value for adjoint of quadr constr + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_ocp_qcqp_res_memsize(struct s_ocp_qcqp_dim *ocp_dim); +// +void s_ocp_qcqp_res_create(struct s_ocp_qcqp_dim *ocp_dim, struct s_ocp_qcqp_res *res, void *mem); +// +hpipm_size_t s_ocp_qcqp_res_ws_memsize(struct s_ocp_qcqp_dim *ocp_dim); +// +void s_ocp_qcqp_res_ws_create(struct s_ocp_qcqp_dim *ocp_dim, struct s_ocp_qcqp_res_ws *workspace, void *mem); +// +void s_ocp_qcqp_res_compute(struct s_ocp_qcqp *qp, struct s_ocp_qcqp_sol *qp_sol, struct s_ocp_qcqp_res *res, struct s_ocp_qcqp_res_ws *ws); +// +void s_ocp_qcqp_res_compute_inf_norm(struct s_ocp_qcqp_res *res); +// +void s_ocp_qcqp_res_get_max_res_stat(struct s_ocp_qcqp_res *res, float *value); +// +void s_ocp_qcqp_res_get_max_res_eq(struct s_ocp_qcqp_res *res, float *value); +// +void s_ocp_qcqp_res_get_max_res_ineq(struct s_ocp_qcqp_res *res, float *value); +// +void s_ocp_qcqp_res_get_max_res_comp(struct s_ocp_qcqp_res *res, float *value); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_S_OCP_QCQP_RES_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_sol.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_sol.h new file mode 100644 index 00000000000000..3d58022cc9c8ff --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_sol.h @@ -0,0 +1,115 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QCQP_SOL_H_ +#define HPIPM_S_OCP_QCQP_SOL_H_ + + + +#include +#include + +#include "hpipm_s_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qcqp_sol + { + struct s_ocp_qcqp_dim *dim; + struct blasfeo_svec *ux; + struct blasfeo_svec *pi; + struct blasfeo_svec *lam; + struct blasfeo_svec *t; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_ocp_qcqp_sol_strsize(); +// +hpipm_size_t s_ocp_qcqp_sol_memsize(struct s_ocp_qcqp_dim *dim); +// +void s_ocp_qcqp_sol_create(struct s_ocp_qcqp_dim *dim, struct s_ocp_qcqp_sol *qp_sol, void *memory); +// +void s_ocp_qcqp_sol_copy_all(struct s_ocp_qcqp_sol *qp_sol_orig, struct s_ocp_qcqp_sol *qp_sol_dest); +// +void s_ocp_qcqp_sol_get(char *field, int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_u(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_x(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_sl(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_su(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_pi(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_lam_lb(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_lam_ub(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_lam_lg(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_get_lam_ug(int stage, struct s_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_ocp_qcqp_sol_set(char *field, int stage, float *vec, struct s_ocp_qcqp_sol *qp_sol); +// +void s_ocp_qcqp_sol_set_u(int stage, float *vec, struct s_ocp_qcqp_sol *qp_sol); +// +void s_ocp_qcqp_sol_set_x(int stage, float *vec, struct s_ocp_qcqp_sol *qp_sol); +// +void s_ocp_qcqp_sol_set_sl(int stage, float *vec, struct s_ocp_qcqp_sol *qp_sol); +// +void s_ocp_qcqp_sol_set_su(int stage, float *vec, struct s_ocp_qcqp_sol *qp_sol); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_OCP_QCQP_SOL_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_utils.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_utils.h new file mode 100644 index 00000000000000..d64e3aabe73742 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qcqp_utils.h @@ -0,0 +1,82 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QCQP_UTILS_H_ +#define HPIPM_S_OCP_QCQP_UTILS_H_ + + + +#include +#include + +#include "hpipm_s_ocp_qcqp_dim.h" +#include "hpipm_s_ocp_qp.h" +#include "hpipm_s_ocp_qcqp_sol.h" +#include "hpipm_s_ocp_qcqp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_ocp_qcqp_dim_print(struct s_ocp_qcqp_dim *qcqp_dim); +// +void s_ocp_qcqp_dim_codegen(char *file_name, char *mode, struct s_ocp_qcqp_dim *qcqp_dim); +// +void s_ocp_qcqp_print(struct s_ocp_qcqp_dim *qcqp_dim, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_codegen(char *file_name, char *mode, struct s_ocp_qcqp_dim *qcqp_dim, struct s_ocp_qcqp *qp); +// +void s_ocp_qcqp_sol_print(struct s_ocp_qcqp_dim *qcqp_dim, struct s_ocp_qcqp_sol *ocp_qcqp_sol); +// +void s_ocp_qcqp_ipm_arg_codegen(char *file_name, char *mode, struct s_ocp_qcqp_dim *qcqp_dim, struct s_ocp_qcqp_ipm_arg *arg); +// +void s_ocp_qcqp_res_print(struct s_ocp_qcqp_dim *qcqp_dim, struct s_ocp_qcqp_res *ocp_qcqp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_OCP_QCQP_UTILS_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp.h new file mode 100644 index 00000000000000..b49191f192d83c --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp.h @@ -0,0 +1,306 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QP_H_ +#define HPIPM_S_OCP_QP_H_ + + + +#include +#include + +#include "hpipm_s_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qp + { + struct s_ocp_qp_dim *dim; + struct blasfeo_smat *BAbt; // dynamics matrix & vector work space + struct blasfeo_smat *RSQrq; // hessian of cost & vector work space + struct blasfeo_smat *DCt; // inequality constraints matrix + struct blasfeo_svec *b; // dynamics vector + struct blasfeo_svec *rqz; // gradient of cost & gradient of slacks + struct blasfeo_svec *d; // inequality constraints vector + struct blasfeo_svec *d_mask; // inequality constraints mask vector + struct blasfeo_svec *m; // rhs of complementarity condition + struct blasfeo_svec *Z; // (diagonal) hessian of slacks + int **idxb; // indices of box constrained variables within [u; x] + int **idxs_rev; // index of soft constraints (reverse storage) + int **idxe; // indices of constraints within [bu, bx, g] that are equalities, subset of [0, ..., nbu+nbx+ng-1] + int *diag_H_flag; // flag the fact that Hessian is diagonal + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_ocp_qp_strsize(); +// +hpipm_size_t s_ocp_qp_memsize(struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_create(struct s_ocp_qp_dim *dim, struct s_ocp_qp *qp, void *memory); +// +void s_ocp_qp_copy_all(struct s_ocp_qp *qp_orig, struct s_ocp_qp *qp_dest); + +// setters +// +void s_ocp_qp_set_all_zero(struct s_ocp_qp *qp); +// +void s_ocp_qp_set_rhs_zero(struct s_ocp_qp *qp); +// +void s_ocp_qp_set_all(float **A, float **B, float **b, float **Q, float **S, float **R, float **q, float **r, int **idxbx, float **lbx, float **ubx, int **idxbu, float **lbu, float **ubu, float **C, float **D, float **lg, float **ug, float **Zl, float **Zu, float **zl, float **zu, int **idxs, float **ls, float **us, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_all_rowmaj(float **A, float **B, float **b, float **Q, float **S, float **R, float **q, float **r, int **idxbx, float **lbx, float **ubx, int **idxbu, float **lbu, float **ubu, float **C, float **D, float **lg, float **ug, float **Zl, float **Zu, float **zl, float **zu, int **idxs, float **ls, float **us, struct s_ocp_qp *qp); +// +void s_ocp_qp_set(char *fiels_name, int stage, void *value, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_el(char *fiels_name, int stage, int index, void *value, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_A(int stage, float *mat, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_B(int stage, float *mat, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_b(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Q(int stage, float *mat, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_S(int stage, float *mat, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_R(int stage, float *mat, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_q(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_r(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lb(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lb_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ub(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ub_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lbx(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lbx_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_el_lbx(int stage, int index, float *elem, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ubx(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ubx_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_el_ubx(int stage, int index, float *elem, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lbu(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lbu_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ubu(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ubu_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxb(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxbx(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jbx(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxbu(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jbu(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_C(int stage, float *mat, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_D(int stage, float *mat, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lg(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lg_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ug(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_ug_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Zl(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Zu(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_zl(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_zu(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lls(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lls_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lus(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_lus_mask(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxs(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxs_rev(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jsbu(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jsbx(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jsg(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxe(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxbxe(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxbue(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_idxge(int stage, int *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jbxe(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jbue(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_Jge(int stage, float *vec, struct s_ocp_qp *qp); +// +void s_ocp_qp_set_diag_H_flag(int stage, int *value, struct s_ocp_qp *qp); + +// getters +// +void s_ocp_qp_get(char *field, int stage, struct s_ocp_qp *qp, void *value); +// +void s_ocp_qp_get_A(int stage, struct s_ocp_qp *qp, float *mat); +// +void s_ocp_qp_get_B(int stage, struct s_ocp_qp *qp, float *mat); +// +void s_ocp_qp_get_b(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_Q(int stage, struct s_ocp_qp *qp, float *mat); +// +void s_ocp_qp_get_S(int stage, struct s_ocp_qp *qp, float *mat); +// +void s_ocp_qp_get_R(int stage, struct s_ocp_qp *qp, float *mat); +// +void s_ocp_qp_get_q(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_r(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ub(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ub_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lb(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lb_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lbx(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lbx_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ubx(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ubx_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lbu(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lbu_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ubu(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ubu_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_idxb(int stage, struct s_ocp_qp *qp, int *vec); +// +//void s_ocp_qp_get_idxbx(int stage, struct s_ocp_qp *qp, int *vec); +// +//void s_ocp_qp_get_Jbx(int stage, struct s_ocp_qp *qp, float *vec); +// +//void s_ocp_qp_get_idxbu(int stage, struct s_ocp_qp *qp, int *vec); +// +//void s_ocp_qp_get_Jbu(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_C(int stage, struct s_ocp_qp *qp, float *mat); +// +void s_ocp_qp_get_D(int stage, struct s_ocp_qp *qp, float *mat); +// +void s_ocp_qp_get_lg(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lg_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ug(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_ug_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_Zl(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_Zu(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_zl(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_zu(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lls(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lls_mask(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lus(int stage, struct s_ocp_qp *qp, float *vec); +// +void s_ocp_qp_get_lus_mask(int stage, struct s_ocp_qp *qp, float *vec); +// XXX only valid if there is one slack per softed constraint !!! +void s_ocp_qp_get_idxs(int stage, struct s_ocp_qp *qp, int *vec); +// +void s_ocp_qp_get_idxs_rev(int stage, struct s_ocp_qp *qp, int *vec); +// +//void s_ocp_qp_get_Jsbu(int stage, struct s_ocp_qp *qp, float *vec); +// +//void s_ocp_qp_get_Jsbx(int stage, struct s_ocp_qp *qp, float *vec); +// +//void s_ocp_qp_get_Jsg(int stage, struct s_ocp_qp *qp, float *vec); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_OCP_QP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_dim.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_dim.h new file mode 100644 index 00000000000000..bce80243b3eb2e --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_dim.h @@ -0,0 +1,141 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QP_DIM_H_ +#define HPIPM_S_OCP_QP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qp_dim + { + int *nx; // number of states + int *nu; // number of inputs + int *nb; // number of box constraints + int *nbx; // number of state box constraints + int *nbu; // number of input box constraints + int *ng; // number of general constraints + int *ns; // number of soft constraints + int *nsbx; // number of soft state box constraints + int *nsbu; // number of soft input box constraints + int *nsg; // number of soft general constraints + int *nbxe; // number of state box constraints which are equality + int *nbue; // number of input box constraints which are equality + int *nge; // number of general constraints which are equality + int N; // horizon length + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_ocp_qp_dim_strsize(); +// +hpipm_size_t s_ocp_qp_dim_memsize(int N); +// +void s_ocp_qp_dim_create(int N, struct s_ocp_qp_dim *qp_dim, void *memory); +// +void s_ocp_qp_dim_copy_all(struct s_ocp_qp_dim *dim_orig, struct s_ocp_qp_dim *dim_dest); +// +void s_ocp_qp_dim_set_all(int *nx, int *nu, int *nbx, int *nbu, int *ng, int *nsbx, int *nsbu, int *nsg, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set(char *field, int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nx(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nu(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nbx(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nbu(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_ng(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_ns(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nsbx(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nsbu(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nsg(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nbxe(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nbue(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_set_nge(int stage, int value, struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_dim_get(struct s_ocp_qp_dim *dim, char *field, int stage, int *value); +// +void s_ocp_qp_dim_get_N(struct s_ocp_qp_dim *dim, int *value); +// +void s_ocp_qp_dim_get_nx(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nu(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nbx(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nbu(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_ng(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_ns(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nsbx(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nsbu(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nsg(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nbxe(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nbue(struct s_ocp_qp_dim *dim, int stage, int *value); +// +void s_ocp_qp_dim_get_nge(struct s_ocp_qp_dim *dim, int stage, int *value); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_OCP_QP_DIM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_ipm.h new file mode 100644 index 00000000000000..11f3c47be6ecd2 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_ipm.h @@ -0,0 +1,250 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QP_IPM_H_ +#define HPIPM_S_OCP_QP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qp_ipm_arg + { + float mu0; // initial value for complementarity slackness + float alpha_min; // exit cond on step length + float res_g_max; // exit cond on inf norm of residuals + float res_b_max; // exit cond on inf norm of residuals + float res_d_max; // exit cond on inf norm of residuals + float res_m_max; // exit cond on inf norm of residuals + float reg_prim; // reg of primal hessian + float lam_min; // min value in lam vector + float t_min; // min value in t vector + float tau_min; // min value of barrier parameter + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int square_root_alg; // 0 classical Riccati, 1 square-root Riccati + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq (for square_root_alg==1) + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution of equality constraints (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol_eq==1) + int comp_res_pred; // compute residuals of prediction + int split_step; // use different steps for primal and dual variables + int var_init_scheme; // variables initialization scheme + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct s_ocp_qp_ipm_ws + { + struct s_core_qp_ipm_workspace *core_workspace; + struct s_ocp_qp_res_ws *res_workspace; + struct s_ocp_qp_dim *dim; // cache dim + struct s_ocp_qp_sol *sol_step; + struct s_ocp_qp_sol *sol_itref; + struct s_ocp_qp *qp_step; + struct s_ocp_qp *qp_itref; + struct s_ocp_qp_res *res; + struct s_ocp_qp_res *res_itref; + struct blasfeo_svec *Gamma; // hessian update + struct blasfeo_svec *gamma; // hessian update + struct blasfeo_svec *tmp_nuxM; // work space of size nxM + struct blasfeo_svec *tmp_nbgM; // work space of size nbM+ngM + struct blasfeo_svec *tmp_nsM; // work space of size nsM + struct blasfeo_svec *Pb; // Pb + struct blasfeo_svec *Zs_inv; + struct blasfeo_svec *tmp_m; + struct blasfeo_svec *l; // cache linear part for _get_ric_xxx + struct blasfeo_smat *L; + struct blasfeo_smat *Ls; + struct blasfeo_smat *P; + struct blasfeo_smat *Lh; + struct blasfeo_smat *AL; + struct blasfeo_smat *lq0; + struct blasfeo_smat *tmp_nxM_nxM; + float *stat; // convergence statistics + int *use_hess_fact; + void *lq_work0; + float qp_res[4]; // infinity norm of residuals + int iter; // iteration number + int stat_max; // iterations saved in stat + int stat_m; // number of recorded stat per IPM iter + int use_Pb; + int status; // solver status + int square_root_alg; // cache from arg + int lq_fact; // cache from arg + int mask_constr; // use constr mask + int valid_ric_vec; // meaningful riccati vectors + int valid_ric_p; // form of riccati p: 0 p*inv(L), 1 p + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_ocp_qp_ipm_arg_strsize(); +// +hpipm_size_t s_ocp_qp_ipm_arg_memsize(struct s_ocp_qp_dim *ocp_dim); +// +void s_ocp_qp_ipm_arg_create(struct s_ocp_qp_dim *ocp_dim, struct s_ocp_qp_ipm_arg *arg, void *mem); +// +void s_ocp_qp_ipm_arg_set_default(enum hpipm_mode mode, struct s_ocp_qp_ipm_arg *arg); +// +void s_ocp_qp_ipm_arg_set(char *field, void *value, struct s_ocp_qp_ipm_arg *arg); +// set maximum number of iterations +void s_ocp_qp_ipm_arg_set_iter_max(int *iter_max, struct s_ocp_qp_ipm_arg *arg); +// set minimum step lenght +void s_ocp_qp_ipm_arg_set_alpha_min(float *alpha_min, struct s_ocp_qp_ipm_arg *arg); +// set initial value of barrier parameter +void s_ocp_qp_ipm_arg_set_mu0(float *mu0, struct s_ocp_qp_ipm_arg *arg); +// set exit tolerance on stationarity condition +void s_ocp_qp_ipm_arg_set_tol_stat(float *tol_stat, struct s_ocp_qp_ipm_arg *arg); +// set exit tolerance on equality constr +void s_ocp_qp_ipm_arg_set_tol_eq(float *tol_eq, struct s_ocp_qp_ipm_arg *arg); +// set exit tolerance on inequality constr +void s_ocp_qp_ipm_arg_set_tol_ineq(float *tol_ineq, struct s_ocp_qp_ipm_arg *arg); +// set exit tolerance on complementarity condition +void s_ocp_qp_ipm_arg_set_tol_comp(float *tol_comp, struct s_ocp_qp_ipm_arg *arg); +// set regularization of primal variables +void s_ocp_qp_ipm_arg_set_reg_prim(float *tol_comp, struct s_ocp_qp_ipm_arg *arg); +// set warm start: 0 no warm start, 1 primal var +void s_ocp_qp_ipm_arg_set_warm_start(int *warm_start, struct s_ocp_qp_ipm_arg *arg); +// Mehrotra's predictor-corrector IPM algorithm: 0 no predictor-corrector, 1 use predictor-corrector +void s_ocp_qp_ipm_arg_set_pred_corr(int *pred_corr, struct s_ocp_qp_ipm_arg *arg); +// conditional predictor-corrector: 0 no conditinal predictor-corrector, 1 conditional predictor-corrector +void s_ocp_qp_ipm_arg_set_cond_pred_corr(int *value, struct s_ocp_qp_ipm_arg *arg); +// set riccati algorithm: 0 classic, 1 square-root +void s_ocp_qp_ipm_arg_set_ric_alg(int *alg, struct s_ocp_qp_ipm_arg *arg); +// dual solution of equality constraints (only for abs_form==1) +void s_ocp_qp_ipm_arg_set_comp_dual_sol_eq(int *value, struct s_ocp_qp_ipm_arg *arg); +// compute residuals after solution +void s_ocp_qp_ipm_arg_set_comp_res_exit(int *value, struct s_ocp_qp_ipm_arg *arg); +// compute residuals of prediction +void s_ocp_qp_ipm_arg_set_comp_res_pred(int *alg, struct s_ocp_qp_ipm_arg *arg); +// min value of lam in the solution +void s_ocp_qp_ipm_arg_set_lam_min(float *value, struct s_ocp_qp_ipm_arg *arg); +// min value of t in the solution +void s_ocp_qp_ipm_arg_set_t_min(float *value, struct s_ocp_qp_ipm_arg *arg); +// min value of tau in the solution +void s_ocp_qp_ipm_arg_set_tau_min(float *value, struct s_ocp_qp_ipm_arg *arg); +// set split step: 0 same step, 1 different step for primal and dual variables +void s_ocp_qp_ipm_arg_set_split_step(int *value, struct s_ocp_qp_ipm_arg *arg); +// variables initialization scheme +void s_ocp_qp_ipm_arg_set_var_init_scheme(int *value, struct s_ocp_qp_ipm_arg *arg); +// clip t and lam: 0 no, 1 in Gamma computation, 2 in solution +void s_ocp_qp_ipm_arg_set_t_lam_min(int *value, struct s_ocp_qp_ipm_arg *arg); + +// +hpipm_size_t s_ocp_qp_ipm_ws_strsize(); +// +hpipm_size_t s_ocp_qp_ipm_ws_memsize(struct s_ocp_qp_dim *ocp_dim, struct s_ocp_qp_ipm_arg *arg); +// +void s_ocp_qp_ipm_ws_create(struct s_ocp_qp_dim *ocp_dim, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, void *mem); +// +void s_ocp_qp_ipm_get(char *field, struct s_ocp_qp_ipm_ws *ws, void *value); +// +void s_ocp_qp_ipm_get_status(struct s_ocp_qp_ipm_ws *ws, int *status); +// +void s_ocp_qp_ipm_get_iter(struct s_ocp_qp_ipm_ws *ws, int *iter); +// +void s_ocp_qp_ipm_get_max_res_stat(struct s_ocp_qp_ipm_ws *ws, float *res_stat); +// +void s_ocp_qp_ipm_get_max_res_eq(struct s_ocp_qp_ipm_ws *ws, float *res_eq); +// +void s_ocp_qp_ipm_get_max_res_ineq(struct s_ocp_qp_ipm_ws *ws, float *res_ineq); +// +void s_ocp_qp_ipm_get_max_res_comp(struct s_ocp_qp_ipm_ws *ws, float *res_comp); +// +void s_ocp_qp_ipm_get_stat(struct s_ocp_qp_ipm_ws *ws, float **stat); +// +void s_ocp_qp_ipm_get_stat_m(struct s_ocp_qp_ipm_ws *ws, int *stat_m); +// +void s_ocp_qp_ipm_get_ric_Lr(struct s_ocp_qp *qp, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, int stage, float *Lr); +// +void s_ocp_qp_ipm_get_ric_Ls(struct s_ocp_qp *qp, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, int stage, float *Ls); +// +void s_ocp_qp_ipm_get_ric_P(struct s_ocp_qp *qp, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, int stage, float *P); +// +void s_ocp_qp_ipm_get_ric_lr(struct s_ocp_qp *qp, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, int stage, float *lr); +// +void s_ocp_qp_ipm_get_ric_p(struct s_ocp_qp *qp, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, int stage, float *p); +// feedback control gain in the form u = K x + k +void s_ocp_qp_ipm_get_ric_K(struct s_ocp_qp *qp, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, int stage, float *K); +// feedback control gain in the form u = K x + k +void s_ocp_qp_ipm_get_ric_k(struct s_ocp_qp *qp, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws, int stage, float *k); +// +void s_ocp_qp_init_var(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_ipm_abs_step(int kk, struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_ipm_delta_step(int kk, struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_ipm_solve(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_ipm_predict(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_ipm_sens(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_OCP_QP_IPM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_kkt.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_kkt.h new file mode 100644 index 00000000000000..3eb1f4aae878d0 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_kkt.h @@ -0,0 +1,66 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + +#ifndef HPIPM_S_OCP_QP_KKT_H_ +#define HPIPM_S_OCP_QP_KKT_H_ + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + +// +void s_ocp_qp_fact_solve_kkt_unconstr(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_fact_solve_kkt_step(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_fact_lq_solve_kkt_step(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); +// +void s_ocp_qp_solve_kkt_step(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_ipm_arg *arg, struct s_ocp_qp_ipm_ws *ws); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif // HPIPM_S_OCP_QP_KKT_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_red.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_red.h new file mode 100644 index 00000000000000..5a7b3b070302b0 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_red.h @@ -0,0 +1,118 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QP_RED_H_ +#define HPIPM_S_OCP_QP_RED_H_ + + + +#include +#include + +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qp_reduce_eq_dof_arg + { + float lam_min; + float t_min; + int alias_unchanged; // do not keep copy unchanged stage + int comp_prim_sol; // primal solution (v) + int comp_dual_sol_eq; // dual solution equality constr (pi) + int comp_dual_sol_ineq; // dual solution inequality constr (lam t) + hpipm_size_t memsize; // memory size in bytes + }; + + + +struct s_ocp_qp_reduce_eq_dof_ws + { + struct blasfeo_svec *tmp_nuxM; + struct blasfeo_svec *tmp_nbgM; + int *e_imask_ux; + int *e_imask_d; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +void s_ocp_qp_dim_reduce_eq_dof(struct s_ocp_qp_dim *dim, struct s_ocp_qp_dim *dim_red); +// +hpipm_size_t s_ocp_qp_reduce_eq_dof_arg_memsize(); +// +void s_ocp_qp_reduce_eq_dof_arg_create(struct s_ocp_qp_reduce_eq_dof_arg *arg, void *mem); +// +void s_ocp_qp_reduce_eq_dof_arg_set_default(struct s_ocp_qp_reduce_eq_dof_arg *arg); +// +void s_ocp_qp_reduce_eq_dof_arg_set_alias_unchanged(struct s_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +void s_ocp_qp_reduce_eq_dof_arg_set_comp_prim_sol(struct s_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +void s_ocp_qp_reduce_eq_dof_arg_set_comp_dual_sol_eq(struct s_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +void s_ocp_qp_reduce_eq_dof_arg_set_comp_dual_sol_ineq(struct s_ocp_qp_reduce_eq_dof_arg *arg, int value); +// +hpipm_size_t s_ocp_qp_reduce_eq_dof_ws_memsize(struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_reduce_eq_dof_ws_create(struct s_ocp_qp_dim *dim, struct s_ocp_qp_reduce_eq_dof_ws *work, void *mem); +// +void s_ocp_qp_reduce_eq_dof(struct s_ocp_qp *qp, struct s_ocp_qp *qp_red, struct s_ocp_qp_reduce_eq_dof_arg *arg, struct s_ocp_qp_reduce_eq_dof_ws *work); +// +void s_ocp_qp_reduce_eq_dof_lhs(struct s_ocp_qp *qp, struct s_ocp_qp *qp_red, struct s_ocp_qp_reduce_eq_dof_arg *arg, struct s_ocp_qp_reduce_eq_dof_ws *work); +// +void s_ocp_qp_reduce_eq_dof_rhs(struct s_ocp_qp *qp, struct s_ocp_qp *qp_red, struct s_ocp_qp_reduce_eq_dof_arg *arg, struct s_ocp_qp_reduce_eq_dof_ws *work); +// +void s_ocp_qp_restore_eq_dof(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol_red, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_reduce_eq_dof_arg *arg, struct s_ocp_qp_reduce_eq_dof_ws *work); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_OCP_QP_RED_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_res.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_res.h new file mode 100644 index 00000000000000..821585da6583dd --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_res.h @@ -0,0 +1,114 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QP_RES_H_ +#define HPIPM_S_OCP_QP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qp_res + { + struct s_ocp_qp_dim *dim; + struct blasfeo_svec *res_g; // q-residuals + struct blasfeo_svec *res_b; // b-residuals + struct blasfeo_svec *res_d; // d-residuals + struct blasfeo_svec *res_m; // m-residuals + float res_max[4]; // max of residuals + float res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct s_ocp_qp_res_ws + { + struct blasfeo_svec *tmp_nbgM; // work space of size nbM+ngM + struct blasfeo_svec *tmp_nsM; // work space of size nsM + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_ocp_qp_res_memsize(struct s_ocp_qp_dim *ocp_dim); +// +void s_ocp_qp_res_create(struct s_ocp_qp_dim *ocp_dim, struct s_ocp_qp_res *res, void *mem); +// +hpipm_size_t s_ocp_qp_res_ws_memsize(struct s_ocp_qp_dim *ocp_dim); +// +void s_ocp_qp_res_ws_create(struct s_ocp_qp_dim *ocp_dim, struct s_ocp_qp_res_ws *workspace, void *mem); +// +void s_ocp_qp_res_compute(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_res *res, struct s_ocp_qp_res_ws *ws); +// +void s_ocp_qp_res_compute_lin(struct s_ocp_qp *qp, struct s_ocp_qp_sol *qp_sol, struct s_ocp_qp_sol *qp_step, struct s_ocp_qp_res *res, struct s_ocp_qp_res_ws *ws); +// +void s_ocp_qp_res_compute_inf_norm(struct s_ocp_qp_res *res); +// +void s_ocp_qp_res_get_all(struct s_ocp_qp_res *res, float **res_r, float **res_q, float **res_ls, float **res_us, float **res_b, float **res_d_lb, float **res_d_ub, float **res_d_lg, float **res_d_ug, float **res_d_ls, float **res_d_us, float **res_m_lb, float **res_m_ub, float **res_m_lg, float **res_m_ug, float **res_m_ls, float **res_m_us); +// +void s_ocp_qp_res_get_max_res_stat(struct s_ocp_qp_res *res, float *value); +// +void s_ocp_qp_res_get_max_res_eq(struct s_ocp_qp_res *res, float *value); +// +void s_ocp_qp_res_get_max_res_ineq(struct s_ocp_qp_res *res, float *value); +// +void s_ocp_qp_res_get_max_res_comp(struct s_ocp_qp_res *res, float *value); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_S_OCP_QP_RES_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_sol.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_sol.h new file mode 100644 index 00000000000000..94dfa0d003b5d2 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_sol.h @@ -0,0 +1,128 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QP_SOL_H_ +#define HPIPM_S_OCP_QP_SOL_H_ + + + +#include +#include + +#include "hpipm_s_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_ocp_qp_sol + { + struct s_ocp_qp_dim *dim; + struct blasfeo_svec *ux; + struct blasfeo_svec *pi; + struct blasfeo_svec *lam; + struct blasfeo_svec *t; + void *misc; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_ocp_qp_sol_strsize(); +// +hpipm_size_t s_ocp_qp_sol_memsize(struct s_ocp_qp_dim *dim); +// +void s_ocp_qp_sol_create(struct s_ocp_qp_dim *dim, struct s_ocp_qp_sol *qp_sol, void *memory); +// +void s_ocp_qp_sol_copy_all(struct s_ocp_qp_sol *qp_sol_orig, struct s_ocp_qp_sol *qp_sol_dest); +// +void s_qp_sol_get_all(struct s_ocp_qp_sol *qp_sol, float **u, float **x, float **ls, float **us, float **pi, float **lam_lb, float **lam_ub, float **lam_lg, float **lam_ug, float **lam_ls, float **lam_us); +// +void s_qp_sol_get_all_rowmaj(struct s_ocp_qp_sol *qp_sol, float **u, float **x, float **ls, float **us, float **pi, float **lam_lb, float **lam_ub, float **lam_lg, float **lam_ug, float **lam_ls, float **lam_us); +// +void s_ocp_qp_sol_set_all(float **u, float **x, float **ls, float **us, float **pi, float **lam_lb, float **lam_ub, float **lam_lg, float **lam_ug, float **lam_ls, float **lam_us, struct s_ocp_qp_sol *qp_sol); +// +void s_ocp_qp_sol_get(char *field, int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_u(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_x(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_sl(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_su(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_pi(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_lb(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_lbu(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_lbx(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_ub(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_ubu(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_ubx(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_lg(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_get_lam_ug(int stage, struct s_ocp_qp_sol *qp_sol, float *vec); +// +void s_ocp_qp_sol_set(char *field, int stage, float *vec, struct s_ocp_qp_sol *qp_sol); +// +void s_ocp_qp_sol_set_u(int stage, float *vec, struct s_ocp_qp_sol *qp_sol); +// +void s_ocp_qp_sol_set_x(int stage, float *vec, struct s_ocp_qp_sol *qp_sol); +// +void s_ocp_qp_sol_set_sl(int stage, float *vec, struct s_ocp_qp_sol *qp_sol); +// +void s_ocp_qp_sol_set_su(int stage, float *vec, struct s_ocp_qp_sol *qp_sol); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_OCP_QP_SOL_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_utils.h b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_utils.h new file mode 100644 index 00000000000000..a4f832a5eac05b --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_ocp_qp_utils.h @@ -0,0 +1,83 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_OCP_QP_UTILS_H_ +#define HPIPM_S_OCP_QP_UTILS_H_ + + + +#include +#include + +#include "hpipm_s_ocp_qp_dim.h" +#include "hpipm_s_ocp_qp.h" +#include "hpipm_s_ocp_qp_sol.h" +#include "hpipm_s_ocp_qp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_ocp_qp_dim_print(struct s_ocp_qp_dim *qp_dim); +// +void s_ocp_qp_dim_codegen(char *file_name, char *mode, struct s_ocp_qp_dim *qp_dim); +// +void s_ocp_qp_print(struct s_ocp_qp_dim *qp_dim, struct s_ocp_qp *qp); +// +void s_ocp_qp_codegen(char *file_name, char *mode, struct s_ocp_qp_dim *qp_dim, struct s_ocp_qp *qp); +// +void s_ocp_qp_sol_print(struct s_ocp_qp_dim *qp_dim, struct s_ocp_qp_sol *ocp_qp_sol); +// +void s_ocp_qp_ipm_arg_print(struct s_ocp_qp_dim *qp_dim, struct s_ocp_qp_ipm_arg *arg); +// +void s_ocp_qp_ipm_arg_codegen(char *file_name, char *mode, struct s_ocp_qp_dim *qp_dim, struct s_ocp_qp_ipm_arg *arg); +// +void s_ocp_qp_res_print(struct s_ocp_qp_dim *qp_dim, struct s_ocp_qp_res *ocp_qp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_D_OCP_QP_UTILS_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_part_cond.h b/third_party/acados/include/hpipm/include/hpipm_s_part_cond.h new file mode 100644 index 00000000000000..e40511e69f0c12 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_part_cond.h @@ -0,0 +1,115 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_PART_COND_H_ +#define HPIPM_S_PART_COND_H_ + + + +#include +#include + +#include "hpipm_s_cond.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_part_cond_qp_arg + { + struct s_cond_qp_arg *cond_arg; + int N2; + hpipm_size_t memsize; + }; + + + +struct s_part_cond_qp_ws + { + struct s_cond_qp_ws *cond_workspace; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_part_cond_qp_arg_memsize(int N2); +// +void s_part_cond_qp_arg_create(int N2, struct s_part_cond_qp_arg *cond_arg, void *mem); +// +void s_part_cond_qp_arg_set_default(struct s_part_cond_qp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 squre-root +void s_part_cond_qp_arg_set_ric_alg(int ric_alg, struct s_part_cond_qp_arg *cond_arg); +// +void s_part_cond_qp_arg_set_comp_prim_sol(int value, struct s_part_cond_qp_arg *cond_arg); +// +void s_part_cond_qp_arg_set_comp_dual_sol_eq(int value, struct s_part_cond_qp_arg *cond_arg); +// +void s_part_cond_qp_arg_set_comp_dual_sol_ineq(int value, struct s_part_cond_qp_arg *cond_arg); + +// +void s_part_cond_qp_compute_block_size(int N, int N2, int *block_size); +// +void s_part_cond_qp_compute_dim(struct s_ocp_qp_dim *ocp_dim, int *block_size, struct s_ocp_qp_dim *part_dense_dim); +// +hpipm_size_t s_part_cond_qp_ws_memsize(struct s_ocp_qp_dim *ocp_dim, int *block_size, struct s_ocp_qp_dim *part_dense_dim, struct s_part_cond_qp_arg *cond_arg); +// +void s_part_cond_qp_ws_create(struct s_ocp_qp_dim *ocp_dim, int *block_size, struct s_ocp_qp_dim *part_dense_dim, struct s_part_cond_qp_arg *cond_arg, struct s_part_cond_qp_ws *cond_ws, void *mem); +// +void s_part_cond_qp_cond(struct s_ocp_qp *ocp_qp, struct s_ocp_qp *part_dense_qp, struct s_part_cond_qp_arg *cond_arg, struct s_part_cond_qp_ws *cond_ws); +// +void s_part_cond_qp_cond_lhs(struct s_ocp_qp *ocp_qp, struct s_ocp_qp *part_dense_qp, struct s_part_cond_qp_arg *cond_arg, struct s_part_cond_qp_ws *cond_ws); +// +void s_part_cond_qp_cond_rhs(struct s_ocp_qp *ocp_qp, struct s_ocp_qp *part_dense_qp, struct s_part_cond_qp_arg *cond_arg, struct s_part_cond_qp_ws *cond_ws); +// +void s_part_cond_qp_expand_sol(struct s_ocp_qp *ocp_qp, struct s_ocp_qp *part_dense_qp, struct s_ocp_qp_sol *part_dense_qp_sol, struct s_ocp_qp_sol *ocp_qp_sol, struct s_part_cond_qp_arg *cond_arg, struct s_part_cond_qp_ws *cond_ws); + +// +void s_part_cond_qp_update(int *idxc, struct s_ocp_qp *ocp_qp, struct s_ocp_qp *part_dense_qp, struct s_part_cond_qp_arg *cond_arg, struct s_part_cond_qp_ws *cond_ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_PART_COND_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_part_cond_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_s_part_cond_qcqp.h new file mode 100644 index 00000000000000..311f7000bf28ac --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_part_cond_qcqp.h @@ -0,0 +1,107 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_PART_COND_QCQP_H_ +#define HPIPM_S_PART_COND_QCQP_H_ + + + +#include +#include + +#include "hpipm_s_cond_qcqp.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_part_cond_qcqp_arg + { + struct s_cond_qcqp_arg *cond_arg; + int N2; + hpipm_size_t memsize; + }; + + + +struct s_part_cond_qcqp_ws + { + struct s_cond_qcqp_ws *cond_ws; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_part_cond_qcqp_arg_memsize(int N2); +// +void s_part_cond_qcqp_arg_create(int N2, struct s_part_cond_qcqp_arg *cond_arg, void *mem); +// +void s_part_cond_qcqp_arg_set_default(struct s_part_cond_qcqp_arg *cond_arg); +// set riccati-like algorithm: 0 classical, 1 squre-root +void s_part_cond_qcqp_arg_set_ric_alg(int ric_alg, struct s_part_cond_qcqp_arg *cond_arg); + +// +void s_part_cond_qcqp_compute_block_size(int N, int N2, int *block_size); +// +void s_part_cond_qcqp_compute_dim(struct s_ocp_qcqp_dim *ocp_dim, int *block_size, struct s_ocp_qcqp_dim *part_dense_dim); +// +hpipm_size_t s_part_cond_qcqp_ws_memsize(struct s_ocp_qcqp_dim *ocp_dim, int *block_size, struct s_ocp_qcqp_dim *part_dense_dim, struct s_part_cond_qcqp_arg *cond_arg); +// +void s_part_cond_qcqp_ws_create(struct s_ocp_qcqp_dim *ocp_dim, int *block_size, struct s_ocp_qcqp_dim *part_dense_dim, struct s_part_cond_qcqp_arg *cond_arg, struct s_part_cond_qcqp_ws *cond_ws, void *mem); +// +void s_part_cond_qcqp_cond(struct s_ocp_qcqp *ocp_qp, struct s_ocp_qcqp *part_dense_qp, struct s_part_cond_qcqp_arg *cond_arg, struct s_part_cond_qcqp_ws *cond_ws); +// +void s_part_cond_qcqp_cond_lhs(struct s_ocp_qcqp *ocp_qp, struct s_ocp_qcqp *part_dense_qp, struct s_part_cond_qcqp_arg *cond_arg, struct s_part_cond_qcqp_ws *cond_ws); +// +void s_part_cond_qcqp_cond_rhs(struct s_ocp_qcqp *ocp_qp, struct s_ocp_qcqp *part_dense_qp, struct s_part_cond_qcqp_arg *cond_arg, struct s_part_cond_qcqp_ws *cond_ws); +// +void s_part_cond_qcqp_expand_sol(struct s_ocp_qcqp *ocp_qp, struct s_ocp_qcqp *part_dense_qp, struct s_ocp_qcqp_sol *part_dense_qp_sol, struct s_ocp_qcqp_sol *ocp_qp_sol, struct s_part_cond_qcqp_arg *cond_arg, struct s_part_cond_qcqp_ws *cond_ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_D_PART_COND_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_sim_erk.h b/third_party/acados/include/hpipm/include/hpipm_s_sim_erk.h new file mode 100644 index 00000000000000..1a05ad1a283f85 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_sim_erk.h @@ -0,0 +1,121 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_SIM_ERK_H_ +#define HPIPM_S_SIM_ERK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +struct s_sim_erk_arg + { + struct s_sim_rk_data *rk_data; // integrator data + float h; // step size + int steps; // number of steps +// int for_sens; // compute adjoint sensitivities +// int adj_sens; // compute adjoint sensitivities + hpipm_size_t memsize; + }; + + + +struct s_sim_erk_ws + { + void (*ode)(int t, float *x, float *p, void *ode_args, float *xdot); // function pointer to ode + void (*vde_for)(int t, float *x, float *p, void *ode_args, float *xdot); // function pointer to forward vde + void (*vde_adj)(int t, float *adj_in, void *ode_args, float *adj_out); // function pointer to adjoint vde + void *ode_args; // pointer to ode args + struct s_sim_erk_arg *erk_arg; // erk arg + float *K; // internal variables + float *x_for; // states and forward sensitivities + float *x_traj; // states at all steps + float *l; // adjoint sensitivities + float *p; // parameter + float *x_tmp; // temporary states and forward sensitivities + float *adj_in; + float *adj_tmp; + int nx; // number of states + int np; // number of parameters + int nf; // number of forward sensitivities + int na; // number of adjoint sensitivities + int nf_max; // max number of forward sensitivities + int na_max; // max number of adjoint sensitivities + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_sim_erk_arg_memsize(); +// +void s_sim_erk_arg_create(struct s_sim_erk_arg *erk_arg, void *mem); +// +void s_sim_erk_arg_set_all(struct s_sim_rk_data *rk_data, float h, int steps, struct s_sim_erk_arg *erk_arg); + +// +hpipm_size_t s_sim_erk_ws_memsize(struct s_sim_erk_arg *erk_arg, int nx, int np, int nf_max, int na_max); +// +void s_sim_erk_ws_create(struct s_sim_erk_arg *erk_arg, int nx, int np, int nf_max, int na_max, struct s_sim_erk_ws *work, void *memory); +// +void s_sim_erk_ws_set_all(int nf, int na, float *x, float *fs, float *bs, float *p, void (*ode)(int t, float *x, float *p, void *ode_args, float *xdot), void (*vde_for)(int t, float *x, float *p, void *ode_args, float *xdot), void (*vde_adj)(int t, float *adj_in, void *ode_args, float *adj_out), void *ode_args, struct s_sim_erk_ws *work); +// number of directions for forward sensitivities +void s_sim_erk_ws_set_nf(int *nf, struct s_sim_erk_ws *work); +// parameters (e.g. inputs) +void s_sim_erk_ws_set_p(float *p, struct s_sim_erk_ws *work); +// state +void s_sim_erk_ws_set_x(float *x, struct s_sim_erk_ws *work); +// forward sensitivities +void s_sim_erk_ws_set_fs(float *fs, struct s_sim_erk_ws *work); +// ode funtion +void s_sim_erk_ws_set_ode(void (*ode)(int t, float *x, float *p, void *ode_args, float *xdot), struct s_sim_erk_ws *work); +// forward vde function +void s_sim_erk_ws_set_vde_for(void (*ode)(int t, float *x, float *p, void *ode_args, float *xdot), struct s_sim_erk_ws *work); +// ode_args, passed straight to the ode/vde_for/vde_adj functions +void s_sim_erk_ws_set_ode_args(void *ode_args, struct s_sim_erk_ws *work); +// state +void s_sim_erk_ws_get_x(struct s_sim_erk_ws *work, float *x); +// forward sensitivities +void s_sim_erk_ws_get_fs(struct s_sim_erk_ws *work, float *fs); +// +void s_sim_erk_solve(struct s_sim_erk_arg *arg, struct s_sim_erk_ws *work); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_D_SIM_ERK_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_sim_rk.h b/third_party/acados/include/hpipm/include/hpipm_s_sim_rk.h new file mode 100644 index 00000000000000..53acd71498f033 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_sim_rk.h @@ -0,0 +1,72 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_SIM_RK_H_ +#define HPIPM_S_SIM_RK_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct s_sim_rk_data + { + float *A_rk; // A in butcher tableau + float *B_rk; // b in butcher tableau + float *C_rk; // c in butcher tableau + int expl; // erk vs irk + int ns; // number of stages + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_sim_rk_data_memsize(int ns); +// +void s_sim_rk_data_create(int ns, struct s_sim_rk_data *rk_data, void *memory); +// +void s_sim_rk_data_init_default(char *field, struct s_sim_rk_data *rk_data); +// +void s_sim_rk_data_set_all(int expl, float *A_rk, float *B_rk, float *C_rk, struct s_sim_rk_data *rk_data); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_S_SIM_RK_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp.h new file mode 100644 index 00000000000000..450e992624b22b --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp.h @@ -0,0 +1,213 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QCQP_H_ +#define HPIPM_S_TREE_OCP_QCQP_H_ + + + +#include +#include + +#include "hpipm_s_tree_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qcqp + { + struct s_tree_ocp_qcqp_dim *dim; + struct blasfeo_smat *BAbt; // Nn-1 + struct blasfeo_smat *RSQrq; // Nn + struct blasfeo_smat *DCt; // Nn + struct blasfeo_smat **Hq; // Nn + struct blasfeo_svec *b; // Nn-1 + struct blasfeo_svec *rqz; // Nn + struct blasfeo_svec *d; // Nn + struct blasfeo_svec *d_mask; // Nn + struct blasfeo_svec *m; // Nn + struct blasfeo_svec *Z; // Nn + int **idxb; // indices of box constrained variables within [u; x] // Nn + int **idxs_rev; // index of soft constraints + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_tree_ocp_qcqp_memsize(struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_create(struct s_tree_ocp_qcqp_dim *dim, struct s_tree_ocp_qcqp *qp, void *memory); +// +void s_tree_ocp_qcqp_set_all(float **A, float **B, float **b, float **Q, float **S, float **R, float **q, float **r, int **idxb, float **d_lb, float **d_ub, float **C, float **D, float **d_lg, float **d_ug, float **Zl, float **Zu, float **zl, float **zu, int **idxs, float **d_ls, float **d_us, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set(char *field_name, int node_edge, void *value, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_A(int edge, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_B(int edge, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_b(int edge, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Q(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_S(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_R(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_q(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_r(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lb(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lb_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ub(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ub_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lbx(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lbx_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ubx(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ubx_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lbu(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lbu_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ubu(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ubu_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_idxb(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_idxbx(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Jbx(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_idxbu(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Jbu(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_C(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_D(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lg(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lg_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ug(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_ug_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Qq(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Sq(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Rq(int node, float *mat, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_qq(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_rq(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_uq(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_uq_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Zl(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Zu(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_zl(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_zu(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lls(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lls_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lus(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_lus_mask(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_idxs(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_idxs_rev(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Jsbu(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Jsbx(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Jsg(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_set_Jsq(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_idxe(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_idxbxe(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_idxbue(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_idxge(int node, int *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_Jbxe(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_Jbue(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_Jge(int node, float *vec, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_set_diag_H_flag(int node, int *value, struct s_tree_ocp_qcqp *qp); + + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_TREE_OCP_QCQP_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_dim.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_dim.h new file mode 100644 index 00000000000000..7a49d519959afb --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_dim.h @@ -0,0 +1,118 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QCQP_DIM_H_ +#define HPIPM_S_TREE_OCP_QCQP_DIM_H_ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qcqp_dim + { + struct s_tree_ocp_qp_dim *qp_dim; // dim of qp approximation + struct tree *ttree; // tree describing node conndection + int *nx; // number of states // Nn + int *nu; // number of inputs // Nn + int *nb; // number of box constraints // Nn + int *nbx; // number of state box constraints // Nn + int *nbu; // number of input box constraints // Nn + int *ng; // number of general constraints // Nn + int *nq; // number of (upper) quadratic constraints + int *ns; // number of soft constraints // Nn + int *nsbx; // number of soft state box constraints + int *nsbu; // number of soft input box constraints + int *nsg; // number of soft general constraints + int *nsq; // number of (upper) soft quadratic constraints + int Nn; // number of nodes + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_tree_ocp_qcqp_dim_strsize(); +// +hpipm_size_t s_tree_ocp_qcqp_dim_memsize(int Nn); +// +void s_tree_ocp_qcqp_dim_create(int Nn, struct s_tree_ocp_qcqp_dim *qp_dim, void *memory); +// +void s_tree_ocp_qcqp_dim_set_tree(struct tree *ttree, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set(char *field, int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nx(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nu(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nbx(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nbu(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_ng(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nq(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_ns(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nsbx(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nsbu(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nsg(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_dim_set_nsq(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +//void s_tree_ocp_qcqp_dim_set_nbxe(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +//void s_tree_ocp_qcqp_dim_set_nbue(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); +// +//void s_tree_ocp_qcqp_dim_set_nge(int stage, int value, struct s_tree_ocp_qcqp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_TREE_OCP_QCQP_DIM_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_ipm.h new file mode 100644 index 00000000000000..69d65914c527c4 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_ipm.h @@ -0,0 +1,192 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QCQP_IPM_H_ +#define HPIPM_S_TREE_OCP_QCQP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qcqp_ipm_arg + { + struct s_tree_ocp_qp_ipm_arg *qp_arg; + float mu0; // initial value for complementarity slackness + float alpha_min; // exit cond on step length + float res_g_max; // exit cond on inf norm of residuals + float res_b_max; // exit cond on inf norm of residuals + float res_d_max; // exit cond on inf norm of residuals + float res_m_max; // exit cond on inf norm of residuals + float reg_prim; // reg of primal hessian + float lam_min; // min value in lam vector + float t_min; // min value in t vector + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol +// int square_root_alg; // 0 classical Riccati, 1 square-root Riccati + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq (for square_root_alg==1) + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution of equality constraints (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol_eq==1) +// int comp_res_pred; // compute residuals of prediction + int split_step; // use different step for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct s_tree_ocp_qcqp_ipm_ws + { + struct s_tree_ocp_qp_ipm_ws *qp_ws; + struct s_tree_ocp_qp *qp; + struct s_tree_ocp_qp_sol *qp_sol; + struct s_tree_ocp_qcqp_res_ws *qcqp_res_ws; + struct s_tree_ocp_qcqp_res *qcqp_res; + struct blasfeo_svec *tmp_nuxM; + int iter; // iteration number + int status; + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_tree_ocp_qcqp_ipm_arg_strsize(); +// +hpipm_size_t s_tree_ocp_qcqp_ipm_arg_memsize(struct s_tree_ocp_qcqp_dim *ocp_dim); +// +void s_tree_ocp_qcqp_ipm_arg_create(struct s_tree_ocp_qcqp_dim *ocp_dim, struct s_tree_ocp_qcqp_ipm_arg *arg, void *mem); +// +void s_tree_ocp_qcqp_ipm_arg_set_default(enum hpipm_mode mode, struct s_tree_ocp_qcqp_ipm_arg *arg); +// +void s_tree_ocp_qcqp_ipm_arg_set(char *field, void *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set maximum number of iterations +void s_tree_ocp_qcqp_ipm_arg_set_iter_max(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set minimum step lenght +void s_tree_ocp_qcqp_ipm_arg_set_alpha_min(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set initial value of barrier parameter +void s_tree_ocp_qcqp_ipm_arg_set_mu0(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on stationarity condition +void s_tree_ocp_qcqp_ipm_arg_set_tol_stat(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on equality constr +void s_tree_ocp_qcqp_ipm_arg_set_tol_eq(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on inequality constr +void s_tree_ocp_qcqp_ipm_arg_set_tol_ineq(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set exit tolerance on complementarity condition +void s_tree_ocp_qcqp_ipm_arg_set_tol_comp(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set regularization of primal variables +void s_tree_ocp_qcqp_ipm_arg_set_reg_prim(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set warm start: 0 no warm start, 1 primal var +void s_tree_ocp_qcqp_ipm_arg_set_warm_start(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// Mehrotra's predictor-corrector IPM algorithm: 0 no predictor-corrector, 1 use predictor-corrector +void s_tree_ocp_qcqp_ipm_arg_set_pred_corr(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// conditional predictor-corrector: 0 no conditinal predictor-corrector, 1 conditional predictor-corrector +void s_tree_ocp_qcqp_ipm_arg_set_cond_pred_corr(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// set riccati algorithm: 0 classic, 1 square-root +//void s_tree_ocp_qcqp_ipm_arg_set_ric_alg(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// compute residuals after solution +void s_tree_ocp_qcqp_ipm_arg_set_comp_res_exit(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// compute residuals of prediction +//void s_tree_ocp_qcqp_ipm_arg_set_comp_res_pred(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// min value of lam in the solution +void s_tree_ocp_qcqp_ipm_arg_set_lam_min(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// min value of t in the solution +void s_tree_ocp_qcqp_ipm_arg_set_t_min(float *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// use different step for primal and dual variables +void s_tree_ocp_qcqp_ipm_arg_set_split_step(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); +// clip t and lam: 0 no, 1 in Gamma computation, 2 in solution +void s_tree_ocp_qcqp_ipm_arg_set_t_lam_min(int *value, struct s_tree_ocp_qcqp_ipm_arg *arg); + +// +hpipm_size_t s_tree_ocp_qcqp_ipm_ws_strsize(); +// +hpipm_size_t s_tree_ocp_qcqp_ipm_ws_memsize(struct s_tree_ocp_qcqp_dim *ocp_dim, struct s_tree_ocp_qcqp_ipm_arg *arg); +// +void s_tree_ocp_qcqp_ipm_ws_create(struct s_tree_ocp_qcqp_dim *ocp_dim, struct s_tree_ocp_qcqp_ipm_arg *arg, struct s_tree_ocp_qcqp_ipm_ws *ws, void *mem); +// +void s_tree_ocp_qcqp_ipm_get(char *field, struct s_tree_ocp_qcqp_ipm_ws *ws, void *value); +// +void s_tree_ocp_qcqp_ipm_get_status(struct s_tree_ocp_qcqp_ipm_ws *ws, int *status); +// +void s_tree_ocp_qcqp_ipm_get_iter(struct s_tree_ocp_qcqp_ipm_ws *ws, int *iter); +// +void s_tree_ocp_qcqp_ipm_get_max_res_stat(struct s_tree_ocp_qcqp_ipm_ws *ws, float *res_stat); +// +void s_tree_ocp_qcqp_ipm_get_max_res_eq(struct s_tree_ocp_qcqp_ipm_ws *ws, float *res_eq); +// +void s_tree_ocp_qcqp_ipm_get_max_res_ineq(struct s_tree_ocp_qcqp_ipm_ws *ws, float *res_ineq); +// +void s_tree_ocp_qcqp_ipm_get_max_res_comp(struct s_tree_ocp_qcqp_ipm_ws *ws, float *res_comp); +// +void s_tree_ocp_qcqp_ipm_get_stat(struct s_tree_ocp_qcqp_ipm_ws *ws, float **stat); +// +void s_tree_ocp_qcqp_ipm_get_stat_m(struct s_tree_ocp_qcqp_ipm_ws *ws, int *stat_m); +// +void s_tree_ocp_qcqp_init_var(struct s_tree_ocp_qcqp *qp, struct s_tree_ocp_qcqp_sol *qp_sol, struct s_tree_ocp_qcqp_ipm_arg *arg, struct s_tree_ocp_qcqp_ipm_ws *ws); +// +void s_tree_ocp_qcqp_ipm_solve(struct s_tree_ocp_qcqp *qp, struct s_tree_ocp_qcqp_sol *qp_sol, struct s_tree_ocp_qcqp_ipm_arg *arg, struct s_tree_ocp_qcqp_ipm_ws *ws); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_S_TREE_OCP_QCQP_IPM_H_ + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_res.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_res.h new file mode 100644 index 00000000000000..d0d84a6f23952f --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_res.h @@ -0,0 +1,109 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QCQP_RES_H_ +#define HPIPM_S_TREE_OCP_QCQP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qcqp_res + { + struct s_tree_ocp_qcqp_dim *dim; + struct blasfeo_svec *res_g; // q-residuals + struct blasfeo_svec *res_b; // b-residuals + struct blasfeo_svec *res_d; // d-residuals + struct blasfeo_svec *res_m; // m-residuals + float res_max[4]; // max of residuals + float res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct s_tree_ocp_qcqp_res_ws + { + struct blasfeo_svec *tmp_nuxM; // work space of size nuM+nxM + struct blasfeo_svec *tmp_nbgqM; // work space of size nbM+ngM+nqM + struct blasfeo_svec *tmp_nsM; // work space of size nsM + struct blasfeo_svec *q_fun; // value for evaluation of quadr constr + struct blasfeo_svec *q_adj; // value for adjoint of quadr constr + int use_q_fun; // reuse cached value for evaluation of quadr constr + int use_q_adj; // reuse cached value for adjoint of quadr constr + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_tree_ocp_qcqp_res_memsize(struct s_tree_ocp_qcqp_dim *ocp_dim); +// +void s_tree_ocp_qcqp_res_create(struct s_tree_ocp_qcqp_dim *ocp_dim, struct s_tree_ocp_qcqp_res *res, void *mem); +// +hpipm_size_t s_tree_ocp_qcqp_res_ws_memsize(struct s_tree_ocp_qcqp_dim *ocp_dim); +// +void s_tree_ocp_qcqp_res_ws_create(struct s_tree_ocp_qcqp_dim *ocp_dim, struct s_tree_ocp_qcqp_res_ws *ws, void *mem); +// +void s_tree_ocp_qcqp_res_compute(struct s_tree_ocp_qcqp *qp, struct s_tree_ocp_qcqp_sol *qp_sol, struct s_tree_ocp_qcqp_res *res, struct s_tree_ocp_qcqp_res_ws *ws); +// +void s_tree_ocp_qcqp_res_compute_inf_norm(struct s_tree_ocp_qcqp_res *res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_S_TREE_OCP_QCQP_RES_H_ + + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_sol.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_sol.h new file mode 100644 index 00000000000000..47f038c6b3dfe5 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_sol.h @@ -0,0 +1,97 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QCQP_SOL_H_ +#define HPIPM_S_TREE_OCP_QCQP_SOL_H_ + + + +#include +#include + +#include "hpipm_s_tree_ocp_qcqp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +struct s_tree_ocp_qcqp_sol + { + struct s_tree_ocp_qcqp_dim *dim; + struct blasfeo_svec *ux; + struct blasfeo_svec *pi; + struct blasfeo_svec *lam; + struct blasfeo_svec *t; + void *misc; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_tree_ocp_qcqp_sol_memsize(struct s_tree_ocp_qcqp_dim *dim); +// +void s_tree_ocp_qcqp_sol_create(struct s_tree_ocp_qcqp_dim *dim, struct s_tree_ocp_qcqp_sol *qp_sol, void *memory); +// +void s_tree_ocp_qcqp_sol_get_u(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_x(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_sl(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_su(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_pi(int edge, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_lam_lb(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_lam_ub(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_lam_lg(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qcqp_sol_get_lam_ug(int node, struct s_tree_ocp_qcqp_sol *qp_sol, float *vec); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_TREE_OCP_QCQP_SOL_H_ + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_utils.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_utils.h new file mode 100644 index 00000000000000..79528de1ce74fa --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qcqp_utils.h @@ -0,0 +1,85 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QCQP_UTILS_H_ +#define HPIPM_S_TREE_OCP_QCQP_UTILS_H_ + + + +#include +#include + +#include "hpipm_s_tree_ocp_qcqp_dim.h" +#include "hpipm_s_tree_ocp_qcqp.h" +#include "hpipm_s_tree_ocp_qcqp_sol.h" +#include "hpipm_s_tree_ocp_qcqp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_tree_ocp_qcqp_dim_print(struct s_tree_ocp_qcqp_dim *qp_dim); +// +//void s_tree_ocp_qcqp_dim_codegen(char *file_name, char *mode, struct s_tree_ocp_qcqp_dim *qp_dim); +// +void s_tree_ocp_qcqp_print(struct s_tree_ocp_qcqp_dim *qp_dim, struct s_tree_ocp_qcqp *qp); +// +//void s_tree_ocp_qcqp_codegen(char *file_name, char *mode, struct s_tree_ocp_qcqp_dim *qp_dim, struct s_tree_ocp_qcqp *qp); +// +void s_tree_ocp_qcqp_sol_print(struct s_tree_ocp_qcqp_dim *qp_dim, struct s_tree_ocp_qcqp_sol *ocp_qcqp_sol); +// +void s_tree_ocp_qcqp_ipm_arg_print(struct s_tree_ocp_qcqp_dim *qp_dim, struct s_tree_ocp_qcqp_ipm_arg *arg); +// +//void s_tree_ocp_qcqp_ipm_arg_codegen(char *file_name, char *mode, struct s_tree_ocp_qcqp_dim *qp_dim, struct s_tree_ocp_qcqp_ipm_arg *arg); +// +void s_tree_ocp_qcqp_res_print(struct s_tree_ocp_qcqp_dim *qp_dim, struct s_tree_ocp_qcqp_res *ocp_qcqp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_TREE_OCP_QCQP_UTILS_H_ + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp.h new file mode 100644 index 00000000000000..722b930b9a45c8 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp.h @@ -0,0 +1,196 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QP_H_ +#define HPIPM_S_TREE_OCP_QP_H_ + + + +#include +#include + +#include "hpipm_s_tree_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qp + { + struct s_tree_ocp_qp_dim *dim; + struct blasfeo_smat *BAbt; // Nn-1 + struct blasfeo_smat *RSQrq; // Nn + struct blasfeo_smat *DCt; // Nn + struct blasfeo_svec *b; // Nn-1 + struct blasfeo_svec *rqz; // Nn + struct blasfeo_svec *d; // Nn + struct blasfeo_svec *d_mask; // Nn + struct blasfeo_svec *m; // Nn + struct blasfeo_svec *Z; // Nn + int **idxb; // indices of box constrained variables within [u; x] // Nn +// int **idxs; // index of soft constraints + int **idxs_rev; // index of soft constraints + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_tree_ocp_qp_memsize(struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_create(struct s_tree_ocp_qp_dim *dim, struct s_tree_ocp_qp *qp, void *memory); +// +void s_tree_ocp_qp_set_all(float **A, float **B, float **b, float **Q, float **S, float **R, float **q, float **r, int **idxb, float **d_lb, float **d_ub, float **C, float **D, float **d_lg, float **d_ug, float **Zl, float **Zu, float **zl, float **zu, int **idxs, float **d_ls, float **d_us, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set(char *field_name, int node_edge, void *value, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_A(int edge, float *mat, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_B(int edge, float *mat, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_b(int edge, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Q(int node, float *mat, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_S(int node, float *mat, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_R(int node, float *mat, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_q(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_r(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lb(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lb_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ub(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ub_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lbx(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lbx_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ubx(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ubx_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lbu(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lbu_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ubu(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ubu_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_idxb(int node, int *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_idxbx(int node, int *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Jbx(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_idxbu(int node, int *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Jbu(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_C(int node, float *mat, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_D(int node, float *mat, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lg(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lg_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ug(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_ug_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Zl(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Zu(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_zl(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_zu(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lls(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lls_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lus(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_lus_mask(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_idxs(int node, int *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_idxs_rev(int node, int *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Jsbu(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Jsbx(int node, float *vec, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_set_Jsg(int node, float *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_idxe(int node, int *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_idxbxe(int node, int *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_idxbue(int node, int *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_idxge(int node, int *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_Jbxe(int node, float *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_Jbue(int node, float *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_Jge(int node, float *vec, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_set_diag_H_flag(int node, int *value, struct s_tree_ocp_qp *qp); + + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_TREE_OCP_QP_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_dim.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_dim.h new file mode 100644 index 00000000000000..90df57182b7993 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_dim.h @@ -0,0 +1,111 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QP_DIM_H_ +#define HPIPM_S_TREE_OCP_QP_DIM_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qp_dim + { + struct tree *ttree; // tree describing node conndection + int *nx; // number of states // Nn + int *nu; // number of inputs // Nn + int *nb; // number of box constraints // Nn + int *nbx; // number of state box constraints // Nn + int *nbu; // number of input box constraints // Nn + int *ng; // number of general constraints // Nn + int *ns; // number of soft constraints // Nn + int *nsbx; // number of soft state box constraints + int *nsbu; // number of soft input box constraints + int *nsg; // number of soft general constraints + int Nn; // number of nodes + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_tree_ocp_qp_dim_strsize(); +// +hpipm_size_t s_tree_ocp_qp_dim_memsize(int Nn); +// +void s_tree_ocp_qp_dim_create(int Nn, struct s_tree_ocp_qp_dim *qp_dim, void *memory); +// +void s_tree_ocp_qp_dim_set_all(struct tree *ttree, int *nx, int *nu, int *nbx, int *nbu, int *ng, int *nsbx, int *nsbu, int *nsg, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_tree(struct tree *ttree, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set(char *field, int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nx(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nu(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nbx(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nbu(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_ng(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_ns(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nsbx(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nsbu(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nsg(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nbxe(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nbue(int stage, int value, struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_dim_set_nge(int stage, int value, struct s_tree_ocp_qp_dim *dim); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_TREE_OCP_QP_DIM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_ipm.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_ipm.h new file mode 100644 index 00000000000000..f8c26d31737f0d --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_ipm.h @@ -0,0 +1,208 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + + +#ifndef HPIPM_S_TREE_OCP_QP_IPM_H_ +#define HPIPM_S_TREE_OCP_QP_IPM_H_ + + + +#include +#include + +#include +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qp_ipm_arg + { + float mu0; // initial value for duality measure + float alpha_min; // exit cond on step length + float res_g_max; // exit cond on inf norm of residuals + float res_b_max; // exit cond on inf norm of residuals + float res_d_max; // exit cond on inf norm of residuals + float res_m_max; // exit cond on inf norm of residuals + float reg_prim; // reg of primal hessian + float lam_min; // min value in lam vector + float t_min; // min value in t vector + float tau_min; // min value of barrier parameter + int iter_max; // exit cond in iter number + int stat_max; // iterations saved in stat + int stat_m; // number of recorded stat per IPM iter + int pred_corr; // use Mehrotra's predictor-corrector IPM algirthm + int cond_pred_corr; // conditional Mehrotra's predictor-corrector + int itref_pred_max; // max number of iterative refinement steps for predictor step + int itref_corr_max; // max number of iterative refinement steps for corrector step + int warm_start; // 0 no warm start, 1 warm start primal sol, 2 warm start primal and dual sol + int lq_fact; // 0 syrk+potrf, 1 mix, 2 lq + int abs_form; // absolute IPM formulation + int comp_dual_sol_eq; // dual solution (only for abs_form==1) + int comp_res_exit; // compute residuals on exit (only for abs_form==1 and comp_dual_sol==1) + int split_step; // use different steps for primal and dual variables + int t_lam_min; // clip t and lam: 0 no, 1 in Gamma computation, 2 in solution + int mode; + hpipm_size_t memsize; + }; + + + +struct s_tree_ocp_qp_ipm_ws + { + struct s_core_qp_ipm_workspace *core_workspace; + struct s_tree_ocp_qp_res_ws *res_workspace; + struct s_tree_ocp_qp_sol *sol_step; + struct s_tree_ocp_qp_sol *sol_itref; + struct s_tree_ocp_qp *qp_step; + struct s_tree_ocp_qp *qp_itref; + struct s_tree_ocp_qp_res *res_itref; + struct s_tree_ocp_qp_res *res; + struct blasfeo_svec *Gamma; // hessian update + struct blasfeo_svec *gamma; // hessian update + struct blasfeo_svec *tmp_nxM; // work space of size nxM + struct blasfeo_svec *tmp_nbgM; // work space of size nbgM + struct blasfeo_svec *tmp_nsM; // work space of size nsM + struct blasfeo_svec *Pb; // Pb + struct blasfeo_svec *Zs_inv; + struct blasfeo_smat *L; + struct blasfeo_smat *Lh; + struct blasfeo_smat *AL; + struct blasfeo_smat *lq0; + struct blasfeo_svec *tmp_m; + float *stat; // convergence statistics + int *use_hess_fact; + void *lq_work0; + float qp_res[4]; // infinity norm of residuals + int iter; // iteration number + int stat_max; // iterations saved in stat + int stat_m; // number of recorded stat per IPM iter + int use_Pb; + int status; // solver status + int lq_fact; // cache from arg + int mask_constr; // use constr mask + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_tree_ocp_qp_ipm_arg_memsize(struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_ipm_arg_create(struct s_tree_ocp_qp_dim *dim, struct s_tree_ocp_qp_ipm_arg *arg, void *mem); +// +void s_tree_ocp_qp_ipm_arg_set_default(enum hpipm_mode mode, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_iter_max(int *iter_max, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_alpha_min(float *alpha_min, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_mu0(float *mu0, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_tol_stat(float *tol_stat, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_tol_eq(float *tol_eq, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_tol_ineq(float *tol_ineq, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_tol_comp(float *tol_comp, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_reg_prim(float *reg, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_warm_start(int *warm_start, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_pred_corr(int *pred_corr, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_cond_pred_corr(int *value, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_comp_dual_sol_eq(int *value, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_comp_res_exit(int *value, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_lam_min(float *value, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_t_min(float *value, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_tau_min(float *value, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_split_step(int *value, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_arg_set_t_lam_min(int *value, struct s_tree_ocp_qp_ipm_arg *arg); + +// +hpipm_size_t s_tree_ocp_qp_ipm_ws_memsize(struct s_tree_ocp_qp_dim *dim, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_ipm_ws_create(struct s_tree_ocp_qp_dim *dim, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws, void *mem); +// +void s_tree_ocp_qp_ipm_get_status(struct s_tree_ocp_qp_ipm_ws *ws, int *status); +// +void s_tree_ocp_qp_ipm_get_iter(struct s_tree_ocp_qp_ipm_ws *ws, int *iter); +// +void s_tree_ocp_qp_ipm_get_max_res_stat(struct s_tree_ocp_qp_ipm_ws *ws, float *res_stat); +// +void s_tree_ocp_qp_ipm_get_max_res_eq(struct s_tree_ocp_qp_ipm_ws *ws, float *res_eq); +// +void s_tree_ocp_qp_ipm_get_max_res_ineq(struct s_tree_ocp_qp_ipm_ws *ws, float *res_ineq); +// +void s_tree_ocp_qp_ipm_get_max_res_comp(struct s_tree_ocp_qp_ipm_ws *ws, float *res_comp); +// +void s_tree_ocp_qp_ipm_get_stat(struct s_tree_ocp_qp_ipm_ws *ws, float **stat); +// +void s_tree_ocp_qp_ipm_get_stat_m(struct s_tree_ocp_qp_ipm_ws *ws, int *stat_m); +// +void s_tree_ocp_qp_init_var(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); +// +void s_tree_ocp_qp_ipm_abs_step(int kk, struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); +// +void s_tree_ocp_qp_ipm_delta_step(int kk, struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); +// +void s_tree_ocp_qp_ipm_solve(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_TREE_OCP_QP_IPM_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_kkt.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_kkt.h new file mode 100644 index 00000000000000..bcf7354783d2c3 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_kkt.h @@ -0,0 +1,54 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + +#ifdef __cplusplus +extern "C" { +#endif + +// +void s_tree_ocp_qp_fact_solve_kkt_unconstr(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); +// +void s_tree_ocp_qp_fact_solve_kkt_step(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); +// +void s_tree_ocp_qp_fact_lq_solve_kkt_step(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); +// +void s_tree_ocp_qp_solve_kkt_step(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_ipm_arg *arg, struct s_tree_ocp_qp_ipm_ws *ws); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_res.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_res.h new file mode 100644 index 00000000000000..5c6797204f847a --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_res.h @@ -0,0 +1,107 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QP_RES_H_ +#define HPIPM_S_TREE_OCP_QP_RES_H_ + + + +#include +#include + +#include +#include +#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct s_tree_ocp_qp_res + { + struct s_tree_ocp_qp_dim *dim; + struct blasfeo_svec *res_g; // q-residuals + struct blasfeo_svec *res_b; // b-residuals + struct blasfeo_svec *res_d; // d-residuals + struct blasfeo_svec *res_m; // m-residuals + float res_max[4]; // max of residuals + float res_mu; // mu-residual + hpipm_size_t memsize; + }; + + + +struct s_tree_ocp_qp_res_ws + { + struct blasfeo_svec *tmp_nbgM; // work space of size nbM+ngM + struct blasfeo_svec *tmp_nsM; // work space of size nsM + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t s_tree_ocp_qp_res_memsize(struct s_tree_ocp_qp_dim *ocp_dim); +// +void s_tree_ocp_qp_res_create(struct s_tree_ocp_qp_dim *ocp_dim, struct s_tree_ocp_qp_res *res, void *mem); +// +hpipm_size_t s_tree_ocp_qp_res_ws_memsize(struct s_tree_ocp_qp_dim *ocp_dim); +// +void s_tree_ocp_qp_res_ws_create(struct s_tree_ocp_qp_dim *ocp_dim, struct s_tree_ocp_qp_res_ws *ws, void *mem); +// +void s_tree_ocp_qp_res_get_all(struct s_tree_ocp_qp_res *res, float **res_r, float **res_q, float **res_ls, float **res_us, float **res_b, float **res_d_lb, float **res_d_ub, float **res_d_lg, float **res_d_ug, float **res_d_ls, float **res_d_us, float **res_m_lb, float **res_m_ub, float **res_m_lg, float **res_m_ug, float **res_m_ls, float **res_m_us); +// +void s_tree_ocp_qp_res_compute(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_res *res, struct s_tree_ocp_qp_res_ws *ws); +// +void s_tree_ocp_qp_res_compute_lin(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, struct s_tree_ocp_qp_sol *qp_step, struct s_tree_ocp_qp_res *res, struct s_tree_ocp_qp_res_ws *ws); +// +void s_tree_ocp_qp_res_compute_inf_norm(struct s_tree_ocp_qp_res *res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_S_TREE_OCP_QP_RES_H_ + + + diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_sol.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_sol.h new file mode 100644 index 00000000000000..71e887675bc3d0 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_sol.h @@ -0,0 +1,98 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QP_SOL_H_ +#define HPIPM_S_TREE_OCP_QP_SOL_H_ + + + +#include +#include + +#include "hpipm_s_tree_ocp_qp_dim.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +struct s_tree_ocp_qp_sol + { + struct s_tree_ocp_qp_dim *dim; + struct blasfeo_svec *ux; + struct blasfeo_svec *pi; + struct blasfeo_svec *lam; + struct blasfeo_svec *t; + void *misc; + hpipm_size_t memsize; // memory size in bytes + }; + + + +// +hpipm_size_t s_tree_ocp_qp_sol_memsize(struct s_tree_ocp_qp_dim *dim); +// +void s_tree_ocp_qp_sol_create(struct s_tree_ocp_qp_dim *dim, struct s_tree_ocp_qp_sol *qp_sol, void *memory); +// +void s_tree_ocp_qp_sol_get_all(struct s_tree_ocp_qp *qp, struct s_tree_ocp_qp_sol *qp_sol, float **u, float **x, float **ls, float **us, float **pi, float **lam_lb, float **lam_ub, float **lam_lg, float **lam_ug, float **lam_ls, float **lam_us); +// +void s_tree_ocp_qp_sol_get_u(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_x(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_sl(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_su(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_pi(int edge, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_lam_lb(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_lam_ub(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_lam_lg(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); +// +void s_tree_ocp_qp_sol_get_lam_ug(int node, struct s_tree_ocp_qp_sol *qp_sol, float *vec); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + + +#endif // HPIPM_S_TREE_OCP_QP_SOL_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_utils.h b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_utils.h new file mode 100644 index 00000000000000..ec1747568f08a8 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_s_tree_ocp_qp_utils.h @@ -0,0 +1,84 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_S_TREE_OCP_QP_UTILS_H_ +#define HPIPM_S_TREE_OCP_QP_UTILS_H_ + + + +#include +#include + +#include "hpipm_s_tree_ocp_qp_dim.h" +#include "hpipm_s_tree_ocp_qp.h" +#include "hpipm_s_tree_ocp_qp_sol.h" +#include "hpipm_s_tree_ocp_qp_ipm.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// +void s_tree_ocp_qp_dim_print(struct s_tree_ocp_qp_dim *qp_dim); +// +//void s_tree_ocp_qp_dim_codegen(char *file_name, char *mode, struct s_tree_ocp_qp_dim *qp_dim); +// +void s_tree_ocp_qp_print(struct s_tree_ocp_qp_dim *qp_dim, struct s_tree_ocp_qp *qp); +// +//void s_tree_ocp_qp_codegen(char *file_name, char *mode, struct s_tree_ocp_qp_dim *qp_dim, struct s_tree_ocp_qp *qp); +// +void s_tree_ocp_qp_sol_print(struct s_tree_ocp_qp_dim *qp_dim, struct s_tree_ocp_qp_sol *ocp_qp_sol); +// +void s_tree_ocp_qp_ipm_arg_print(struct s_tree_ocp_qp_dim *qp_dim, struct s_tree_ocp_qp_ipm_arg *arg); +// +//void s_tree_ocp_qp_ipm_arg_codegen(char *file_name, char *mode, struct s_tree_ocp_qp_dim *qp_dim, struct s_tree_ocp_qp_ipm_arg *arg); +// +void s_tree_ocp_qp_res_print(struct s_tree_ocp_qp_dim *qp_dim, struct s_tree_ocp_qp_res *ocp_qp_res); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + + +#endif // HPIPM_S_TREE_OCP_QP_UTILS_H_ + + diff --git a/third_party/acados/include/hpipm/include/hpipm_scenario_tree.h b/third_party/acados/include/hpipm/include/hpipm_scenario_tree.h new file mode 100644 index 00000000000000..a3c77a670a1d02 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_scenario_tree.h @@ -0,0 +1,70 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_SCENARIO_TREE_H_ +#define HPIPM_SCENARIO_TREE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct sctree + { + struct node *root; // pointer to root + int *kids; // pointer to array of kids + int Nn; // numer of nodes + int md; // number of realizations + int Nr; // robust horizion + int Nh; // control horizion + hpipm_size_t memsize; + }; + + + +// +hpipm_size_t sctree_memsize(int md, int Nr, int Nh); +// +void sctree_create(int md, int Nr, int Nh, struct sctree *st, void *memory); +// +void sctree_cast_to_tree(struct sctree *st, struct tree *tt); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_SCENARIO_TREE_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_timing.h b/third_party/acados/include/hpipm/include/hpipm_timing.h new file mode 100644 index 00000000000000..bd0f2dbcb34c5f --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_timing.h @@ -0,0 +1,67 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + +#ifndef HPIPM_TIMING_H_ +#define HPIPM_TIMING_H_ + + + +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +typedef blasfeo_timer hpipm_timer; + + + +// +void hpipm_tic(hpipm_timer *t); +// +double hpipm_toc(hpipm_timer *t); + + + +#ifdef __cplusplus +} // #extern "C" +#endif + + +#endif // HPIPM_TIMING_H_ diff --git a/third_party/acados/include/hpipm/include/hpipm_tree.h b/third_party/acados/include/hpipm/include/hpipm_tree.h new file mode 100644 index 00000000000000..f9d69ecdddda74 --- /dev/null +++ b/third_party/acados/include/hpipm/include/hpipm_tree.h @@ -0,0 +1,76 @@ +/************************************************************************************************** +* * +* This file is part of HPIPM. * +* * +* HPIPM -- High-Performance Interior Point Method. * +* Copyright (C) 2019 by Gianluca Frison. * +* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * +* All rights reserved. * +* * +* The 2-Clause BSD License * +* * +* 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. * +* * +* 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 OWNER 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. * +* * +* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * +* * +**************************************************************************************************/ + + +#ifndef HPIPM_TREE_H_ +#define HPIPM_TREE_H_ + +#include "hpipm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +struct node + { + int *kids; // 64 bits + int idx; // 32 bits + int dad; // 32 bits + int nkids; // 32 bits + int stage; // 32 bits + int real; // 32 bits + int idxkid; // 32 bits // XXX needed ??? + // total 256 bits + }; + + + +struct tree + { + struct node *root; // pointer to root + int *kids; // pointer to array of kids + int Nn; // numer of nodes + hpipm_size_t memsize; + }; + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HPIPM_TREE_H_ diff --git a/third_party/acados/include/qpOASES_e/Bounds.h b/third_party/acados/include/qpOASES_e/Bounds.h new file mode 100644 index 00000000000000..4e41c1d163b63d --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Bounds.h @@ -0,0 +1,543 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Bounds.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of the Bounds class designed to manage working sets of + * bounds within a QProblem. + */ + + +#ifndef QPOASES_BOUNDS_H +#define QPOASES_BOUNDS_H + + +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** + * \brief Manages working sets of bounds (= box constraints). + * + * This class manages working sets of bounds (= box constraints) + * by storing index sets and other status information. + * + * \author Hans Joachim Ferreau + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + Indexlist *freee; /**< Index list of free variables. */ + Indexlist *fixed; /**< Index list of fixed variables. */ + + Indexlist *shiftedFreee; /**< Memory for shifting free variables. */ + Indexlist *shiftedFixed; /**< Memory for shifting fixed variables. */ + + Indexlist *rotatedFreee; /**< Memory for rotating free variables. */ + Indexlist *rotatedFixed; /**< Memory for rotating fixed variables. */ + + SubjectToType *type; /**< Type of bounds. */ + SubjectToStatus *status; /**< Status of bounds. */ + + SubjectToType *typeTmp; /**< Temp memory for type of bounds. */ + SubjectToStatus *statusTmp; /**< Temp memory for status of 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. */ + + int n; /**< Total number of bounds. */ +} Bounds; + +int Bounds_calculateMemorySize( int n); + +char *Bounds_assignMemory(int n, Bounds **mem, void *raw_memory); + +Bounds *Bounds_createMemory( int n ); + +/** Constructor which takes the number of bounds. */ +void BoundsCON( Bounds* _THIS, + int _n /**< Number of bounds. */ + ); + +/** Copies all members from given rhs object. + * \return SUCCESSFUL_RETURN */ +void BoundsCPY( Bounds* FROM, + Bounds* TO + ); + + +/** Initialises object with given number of bounds. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ +returnValue Bounds_init( Bounds* _THIS, + 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 Bounds_setupBound( Bounds* _THIS, + 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 Bounds_setupAllFree( Bounds* _THIS + ); + +/** Initially adds all numbers of new (i.e. not yet in the list) bounds to + * to the index set of fixed bounds (on their lower bounds); + * the order depends on the SujectToType of each index. + * \return SUCCESSFUL_RETURN \n + RET_SETUP_BOUND_FAILED */ +returnValue Bounds_setupAllLower( Bounds* _THIS + ); + +/** Initially adds all numbers of new (i.e. not yet in the list) bounds to + * to the index set of fixed bounds (on their upper bounds); + * the order depends on the SujectToType of each index. + * \return SUCCESSFUL_RETURN \n + RET_SETUP_BOUND_FAILED */ +returnValue Bounds_setupAllUpper( Bounds* _THIS + ); + + +/** 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 Bounds_moveFixedToFree( Bounds* _THIS, + 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 Bounds_moveFreeToFixed( Bounds* _THIS, + int number, /**< Number of bound to be fixed. */ + SubjectToStatus _status /**< Status of bound to be fixed. */ + ); + +/** Flip fixed bound. + * \return SUCCESSFUL_RETURN \n + RET_MOVING_BOUND_FAILED \n + RET_INDEX_OUT_OF_BOUNDS */ +returnValue Bounds_flipFixed( Bounds* _THIS, + int number + ); + +/** Swaps the indices of two free bounds within the index set. + * \return SUCCESSFUL_RETURN \n + RET_SWAPINDEX_FAILED */ +returnValue Bounds_swapFree( Bounds* _THIS, + int number1, /**< Number of first bound. */ + int number2 /**< Number of second bound. */ + ); + + +/** Returns number of variables. + * \return Number of variables. */ +static inline int Bounds_getNV( Bounds* _THIS + ); + +/** Returns number of implicitly fixed variables. + * \return Number of implicitly fixed variables. */ +static inline int Bounds_getNFV( Bounds* _THIS + ); + +/** Returns number of bounded (but possibly free) variables. + * \return Number of bounded (but possibly free) variables. */ +static inline int Bounds_getNBV( Bounds* _THIS + ); + +/** Returns number of unbounded variables. + * \return Number of unbounded variables. */ +static inline int Bounds_getNUV( Bounds* _THIS + ); + +/** Returns number of free variables. + * \return Number of free variables. */ +static inline int Bounds_getNFR( Bounds* _THIS + ); + +/** Returns number of fixed variables. + * \return Number of fixed variables. */ +static inline int Bounds_getNFX( Bounds* _THIS + ); + + +/** Returns a pointer to free variables index list. + * \return Pointer to free variables index list. */ +static inline Indexlist* Bounds_getFree( Bounds* _THIS + ); + +/** Returns a pointer to fixed variables index list. + * \return Pointer to fixed variables index list. */ +static inline Indexlist* Bounds_getFixed( Bounds* _THIS + ); + + +/** Returns number of bounds with given SubjectTo type. + * \return Number of bounds with given type. */ +static inline int Bounds_getNumberOfType( Bounds* _THIS, + SubjectToType _type /**< Type of bound. */ + ); + + +/** Returns type of bound. + * \return Type of bound \n + RET_INDEX_OUT_OF_BOUNDS */ +static inline SubjectToType Bounds_getType( Bounds* _THIS, + int i /**< Number of bound. */ + ); + +/** Returns status of bound. + * \return Status of bound \n + ST_UNDEFINED */ +static inline SubjectToStatus Bounds_getStatus( Bounds* _THIS, + int i /**< Number of bound. */ + ); + + +/** Sets type of bound. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ +static inline returnValue Bounds_setType( Bounds* _THIS, + int i, /**< Number of bound. */ + SubjectToType value /**< Type of bound. */ + ); + +/** Sets status of bound. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ +static inline returnValue Bounds_setStatus( Bounds* _THIS, + int i, /**< Number of bound. */ + SubjectToStatus value /**< Status of bound. */ + ); + + +/** Sets status of lower bounds. */ +static inline void Bounds_setNoLower( Bounds* _THIS, + BooleanType _status /**< Status of lower bounds. */ + ); + +/** Sets status of upper bounds. */ +static inline void Bounds_setNoUpper( Bounds* _THIS, + BooleanType _status /**< Status of upper bounds. */ + ); + + +/** Returns status of lower bounds. + * \return BT_TRUE if there is no lower bound on any variable. */ +static inline BooleanType Bounds_hasNoLower( Bounds* _THIS + ); + +/** Returns status of upper bounds. + * \return BT_TRUE if there is no upper bound on any variable. */ +static inline BooleanType Bounds_hasNoUpper( Bounds* _THIS + ); + + +/** Shifts forward type and status of all bounds by a given + * offset. This offset has to lie within the range [0,n/2] and has to + * be an integer divisor of the total number of bounds n. + * Type and status of the first \ bounds is thrown away, + * type and status of the last \ bounds is doubled, + * e.g. for offset = 2: \n + * shift( {b1,b2,b3,b4,b5,b6} ) = {b3,b4,b5,b6,b5,b6} + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS \n + RET_INVALID_ARGUMENTS \n + RET_SHIFTING_FAILED */ +returnValue Bounds_shift( Bounds* _THIS, + int offset /**< Shift offset within the range [0,n/2] and integer divisor of n. */ + ); + +/** Rotates forward type and status of all bounds by a given + * offset. This offset has to lie within the range [0,n]. + * Example for offset = 2: \n + * rotate( {b1,b2,b3,b4,b5,b6} ) = {b3,b4,b5,b6,b1,b2} + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS \n + RET_ROTATING_FAILED */ +returnValue Bounds_rotate( Bounds* _THIS, + int offset /**< Rotation offset within the range [0,n]. */ + ); + + +/** Prints information on bounds object + * (in particular, lists of free and fixed bounds. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_CORRUPTED */ +returnValue Bounds_print( Bounds* _THIS + ); + + +/** Initially adds all numbers of new (i.e. not yet in the list) bounds to + * to the index set corresponding to the desired status; + * the order depends on the SujectToType of each index. + * \return SUCCESSFUL_RETURN \n + RET_SETUP_BOUND_FAILED */ +returnValue Bounds_setupAll( Bounds* _THIS, + SubjectToStatus _status /**< Desired initial status for all bounds. */ + ); + + +/** Adds the index of a new bound to index set. + * \return SUCCESSFUL_RETURN \n + RET_ADDINDEX_FAILED \n + RET_INVALID_ARGUMENTS */ +returnValue Bounds_addIndex( Bounds* _THIS, + Indexlist* const indexlist, /**< Index list to which the new index shall be added. */ + int newnumber, /**< Number of new bound. */ + SubjectToStatus newstatus /**< Status of new bound. */ + ); + +/** Removes the index of a bound from index set. + * \return SUCCESSFUL_RETURN \n + RET_REMOVEINDEX_FAILED \n + RET_INVALID_ARGUMENTS */ +returnValue Bounds_removeIndex( Bounds* _THIS, + Indexlist* const indexlist, /**< Index list from which the new index shall be removed. */ + int removenumber /**< Number of bound to be removed. */ + ); + +/** Swaps the indices of two constraints or bounds within the index set. + * \return SUCCESSFUL_RETURN \n + RET_SWAPINDEX_FAILED \n + RET_INVALID_ARGUMENTS */ +returnValue Bounds_swapIndex( Bounds* _THIS, + Indexlist* const indexlist, /**< Index list in which the indices shold be swapped. */ + int number1, /**< Number of first bound. */ + int number2 /**< Number of second bound. */ + ); + + + +/* + * g e t N u m b e r O f T y p e + */ +static inline int Bounds_getNumberOfType( Bounds* _THIS, SubjectToType _type ) +{ + int i; + int numberOfType = 0; + + if ( _THIS->type != 0 ) + { + for( i=0; i<_THIS->n; ++i ) + if ( _THIS->type[i] == _type ) + ++numberOfType; + } + + return numberOfType; +} + + +/* + * g e t T y p e + */ +static inline SubjectToType Bounds_getType( Bounds* _THIS, int i ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + return _THIS->type[i]; + + return ST_UNKNOWN; +} + + +/* + * g e t S t a t u s + */ +static inline SubjectToStatus Bounds_getStatus( Bounds* _THIS, int i ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + return _THIS->status[i]; + + return ST_UNDEFINED; +} + + +/* + * s e t T y p e + */ +static inline returnValue Bounds_setType( Bounds* _THIS, int i, SubjectToType value ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + { + _THIS->type[i] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t S t a t u s + */ +static inline returnValue Bounds_setStatus( Bounds* _THIS, int i, SubjectToStatus value ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + { + _THIS->status[i] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t N o L o w e r + */ +static inline void Bounds_setNoLower( Bounds* _THIS, BooleanType _status ) +{ + _THIS->noLower = _status; +} + + +/* + * s e t N o U p p e r + */ +static inline void Bounds_setNoUpper( Bounds* _THIS, BooleanType _status ) +{ + _THIS->noUpper = _status; +} + + +/* + * h a s N o L o w e r + */ +static inline BooleanType Bounds_hasNoLower( Bounds* _THIS ) +{ + return _THIS->noLower; +} + + +/* + * h a s N o U p p p e r + */ +static inline BooleanType Bounds_hasNoUpper( Bounds* _THIS ) +{ + return _THIS->noUpper; +} + + + +/* + * g e t N V + */ +static inline int Bounds_getNV( Bounds* _THIS ) +{ + return _THIS->n; +} + + +/* + * g e t N F V + */ +static inline int Bounds_getNFV( Bounds* _THIS ) +{ + return Bounds_getNumberOfType( _THIS,ST_EQUALITY ); +} + + +/* + * g e t N B V + */ +static inline int Bounds_getNBV( Bounds* _THIS ) +{ + return Bounds_getNumberOfType( _THIS,ST_BOUNDED ); +} + + +/* + * g e t N U V + */ +static inline int Bounds_getNUV( Bounds* _THIS ) +{ + return Bounds_getNumberOfType( _THIS,ST_UNBOUNDED ); +} + + +/* + * g e t N F R + */ +static inline int Bounds_getNFR( Bounds* _THIS ) +{ + return Indexlist_getLength( _THIS->freee ); +} + + +/* + * g e t N F X + */ +static inline int Bounds_getNFX( Bounds* _THIS ) +{ + return Indexlist_getLength( _THIS->fixed ); +} + + +/* + * g e t F r e e + */ +static inline Indexlist* Bounds_getFree( Bounds* _THIS ) +{ + return _THIS->freee; +} + + +/* + * g e t F i x e d + */ +static inline Indexlist* Bounds_getFixed( Bounds* _THIS ) +{ + return _THIS->fixed; +} + + +END_NAMESPACE_QPOASES + +#endif /* QPOASES_BOUNDS_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/Constants.h b/third_party/acados/include/qpOASES_e/Constants.h new file mode 100644 index 00000000000000..0e3dcd19f4452f --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Constants.h @@ -0,0 +1,134 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Constants.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Definition of all global constants. + */ + + +#ifndef QPOASES_CONSTANTS_H +#define QPOASES_CONSTANTS_H + + +#include + +#ifdef __CODE_GENERATION__ + + #define CONVERTTOSTRINGAUX(x) #x + #define CONVERTTOSTRING(x) CONVERTTOSTRINGAUX(x) + + #ifndef QPOASES_CUSTOM_INTERFACE + #include "acado_qpoases3_interface.h" + #else + #include CONVERTTOSTRING(QPOASES_CUSTOM_INTERFACE) + #endif + +#endif + + +BEGIN_NAMESPACE_QPOASES + + +#ifndef __EXTERNAL_DIMENSIONS__ + + /*#define QPOASES_NVMAX 50 + #define QPOASES_NCMAX 100*/ + #define QPOASES_NVMAX 287 + #define QPOASES_NCMAX 709 + +#endif /* __EXTERNAL_DIMENSIONS__ */ + + +/** Maximum number of variables within a QP formulation. + * Note: this value has to be positive! */ +#define NVMAX QPOASES_NVMAX + +/** Maximum number of constraints within a QP formulation. + * Note: this value has to be positive! */ +#define NCMAX QPOASES_NCMAX + +#if ( QPOASES_NVMAX > QPOASES_NCMAX ) +#define NVCMAX QPOASES_NVMAX +#else +#define NVCMAX QPOASES_NCMAX +#endif + +#if ( QPOASES_NVMAX > QPOASES_NCMAX ) +#define NVCMIN QPOASES_NCMAX +#else +#define NVCMIN QPOASES_NVMAX +#endif + + +/** Maximum number of QPs in a sequence solved by means of the OQP interface. + * Note: this value has to be positive! */ +#define NQPMAX 1000 + + +/** Numerical value of machine precision (min eps, s.t. 1+eps > 1). + * Note: this value has to be positive! */ +#ifndef __CODE_GENERATION__ + + #ifdef __USE_SINGLE_PRECISION__ + static const real_t QPOASES_EPS = 1.193e-07; + #else + static const real_t QPOASES_EPS = 2.221e-16; + #endif /* __USE_SINGLE_PRECISION__ */ + +#endif /* __CODE_GENERATION__ */ + + +/** Numerical value of zero (for situations in which it would be + * unreasonable to compare with 0.0). + * Note: this value has to be positive! */ +static const real_t QPOASES_ZERO = 1.0e-25; + +/** Numerical value of infinity (e.g. for non-existing bounds). + * Note: this value has to be positive! */ +static const real_t QPOASES_INFTY = 1.0e20; + +/** Tolerance to used for isEqual, isZero etc. + * Note: this value has to be positive! */ +static const real_t QPOASES_TOL = 1.0e-25; + + +/** Maximum number of characters within a string. + * Note: this value should be at least 41! */ +#define QPOASES_MAX_STRING_LENGTH 160 + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_CONSTANTS_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/ConstraintProduct.h b/third_party/acados/include/qpOASES_e/ConstraintProduct.h new file mode 100644 index 00000000000000..ddfcfbe5dcd96a --- /dev/null +++ b/third_party/acados/include/qpOASES_e/ConstraintProduct.h @@ -0,0 +1,62 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/ConstraintProduct.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches (thanks to D. Kwame Minde Kufoalor) + * \version 3.1embedded + * \date 2009-2015 + * + * Declaration of the ConstraintProduct interface which allows to specify a + * user-defined function for evaluating the constraint product at the + * current iterate to speed-up QP solution in case of a specially structured + * constraint matrix. + */ + + + +#ifndef QPOASES_CONSTRAINT_PRODUCT_H +#define QPOASES_CONSTRAINT_PRODUCT_H + + +BEGIN_NAMESPACE_QPOASES + + +/** + * \brief Interface for specifying user-defined evaluations of constraint products. + * + * An interface which allows to specify a user-defined function for evaluating the + * constraint product at the current iterate to speed-up QP solution in case + * of a specially structured constraint matrix. + * + * \author Hans Joachim Ferreau (thanks to Kwame Minde Kufoalor) + * \version 3.1embedded + * \date 2009-2015 + */ +typedef int(*ConstraintProduct)( int, const real_t* const, real_t* const ); + + +END_NAMESPACE_QPOASES + +#endif /* QPOASES_CONSTRAINT_PRODUCT_H */ diff --git a/third_party/acados/include/qpOASES_e/Constraints.h b/third_party/acados/include/qpOASES_e/Constraints.h new file mode 100644 index 00000000000000..8aca10d5d979a8 --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Constraints.h @@ -0,0 +1,535 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Constraints.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of the Constraints class designed to manage working sets of + * constraints within a QProblem. + */ + + +#ifndef QPOASES_CONSTRAINTS_H +#define QPOASES_CONSTRAINTS_H + + +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** + * \brief Manages working sets of constraints. + * + * This class manages working sets of constraints by storing + * index sets and other status information. + * + * \author Hans Joachim Ferreau + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + Indexlist *active; /**< Index list of active constraints. */ + Indexlist *inactive; /**< Index list of inactive constraints. */ + + Indexlist *shiftedActive; /**< Memory for shifting active constraints. */ + Indexlist *shiftedInactive; /**< Memory for shifting inactive constraints. */ + + Indexlist *rotatedActive; /**< Memory for rotating active constraints. */ + Indexlist *rotatedInactive; /**< Memory for rotating inactive constraints. */ + + SubjectToType *type; /**< Type of constraints. */ + SubjectToStatus *status; /**< Status of constraints. */ + + SubjectToType *typeTmp; /**< Temp memory for type of constraints. */ + SubjectToStatus *statusTmp; /**< Temp memory for status of constraints. */ + + 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. */ + + int n; /**< Total number of constraints. */ +} Constraints; + +int Constraints_calculateMemorySize( int n); + +char *Constraints_assignMemory(int n, Constraints **mem, void *raw_memory); + +Constraints *Constraints_createMemory( int n ); + +/** Constructor which takes the number of constraints. */ +void ConstraintsCON( Constraints* _THIS, + int _n /**< Number of constraints. */ + ); + +/** Copies all members from given rhs object. + * \return SUCCESSFUL_RETURN */ +void ConstraintsCPY( Constraints* FROM, + Constraints* TO + ); + + +/** Initialises object with given number of constraints. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ +returnValue Constraints_init( Constraints* _THIS, + 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 Constraints_setupConstraint( Constraints* _THIS, + 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 Constraints_setupAllInactive( Constraints* _THIS + ); + +/** Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to + * to the index set of active constraints (on their lower bounds); 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 Constraints_setupAllLower( Constraints* _THIS + ); + +/** Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to + * to the index set of active constraints (on their upper bounds); 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 Constraints_setupAllUpper( Constraints* _THIS + ); + + +/** Moves index of a constraint from index list of active to that of inactive constraints. + * \return SUCCESSFUL_RETURN \n + RET_MOVING_CONSTRAINT_FAILED */ +returnValue Constraints_moveActiveToInactive( Constraints* _THIS, + 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 Constraints_moveInactiveToActive( Constraints* _THIS, + int number, /**< Number of constraint to become active. */ + SubjectToStatus _status /**< Status of constraint to become active. */ + ); + +/** Flip fixed constraint. + * \return SUCCESSFUL_RETURN \n + RET_MOVING_CONSTRAINT_FAILED \n + RET_INDEX_OUT_OF_BOUNDS */ +returnValue Constraints_flipFixed( Constraints* _THIS, + int number + ); + + +/** Returns the number of constraints. + * \return Number of constraints. */ +static inline int Constraints_getNC( Constraints* _THIS + ); + +/** Returns the number of implicit equality constraints. + * \return Number of implicit equality constraints. */ +static inline int Constraints_getNEC( Constraints* _THIS + ); + +/** Returns the number of "real" inequality constraints. + * \return Number of "real" inequality constraints. */ +static inline int Constraints_getNIC( Constraints* _THIS + ); + +/** Returns the number of unbounded constraints (i.e. without any bounds). + * \return Number of unbounded constraints (i.e. without any bounds). */ +static inline int Constraints_getNUC( Constraints* _THIS + ); + +/** Returns the number of active constraints. + * \return Number of active constraints. */ +static inline int Constraints_getNAC( Constraints* _THIS + ); + +/** Returns the number of inactive constraints. + * \return Number of inactive constraints. */ +static inline int Constraints_getNIAC( Constraints* _THIS + ); + + +/** Returns a pointer to active constraints index list. + * \return Pointer to active constraints index list. */ +static inline Indexlist* Constraints_getActive( Constraints* _THIS + ); + +/** Returns a pointer to inactive constraints index list. + * \return Pointer to inactive constraints index list. */ +static inline Indexlist* Constraints_getInactive( Constraints* _THIS + ); + + +/** Returns number of constraints with given SubjectTo type. + * \return Number of constraints with given type. */ +static inline int Constraints_getNumberOfType( Constraints* _THIS, + SubjectToType _type /**< Type of constraints' bound. */ + ); + + +/** Returns type of constraints' bound. + * \return Type of constraints' bound \n + RET_INDEX_OUT_OF_BOUNDS */ +static inline SubjectToType Constraints_getType( Constraints* _THIS, + int i /**< Number of constraints' bound. */ + ); + +/** Returns status of constraints' bound. + * \return Status of constraints' bound \n + ST_UNDEFINED */ +static inline SubjectToStatus Constraints_getStatus( Constraints* _THIS, + int i /**< Number of constraints' bound. */ + ); + + +/** Sets type of constraints' bound. + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS */ +static inline returnValue Constraints_setType( Constraints* _THIS, + 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 */ +static inline returnValue Constraints_setStatus( Constraints* _THIS, + int i, /**< Number of constraints' bound. */ + SubjectToStatus value /**< Status of constraints' bound. */ + ); + + +/** Sets status of lower constraints' bounds. */ +static inline void Constraints_setNoLower( Constraints* _THIS, + BooleanType _status /**< Status of lower constraints' bounds. */ + ); + +/** Sets status of upper constraints' bounds. */ +static inline void Constraints_setNoUpper( Constraints* _THIS, + 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. */ +static inline BooleanType Constraints_hasNoLower( Constraints* _THIS + ); + +/** Returns status of upper bounds. + * \return BT_TRUE if there is no upper constraints' bound on any variable. */ +static inline BooleanType Constraints_hasNoUpper( Constraints* _THIS + ); + + +/** Shifts forward type and status of all constraints by a given + * offset. This offset has to lie within the range [0,n/2] and has to + * be an integer divisor of the total number of constraints n. + * Type and status of the first \ constraints is thrown away, + * type and status of the last \ constraints is doubled, + * e.g. for offset = 2: \n + * shift( {c/b1,c/b2,c/b3,c/b4,c/b5,c/b6} ) = {c/b3,c/b4,c/b5,c/b6,c/b5,c/b6} + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS \n + RET_INVALID_ARGUMENTS \n + RET_SHIFTING_FAILED */ +returnValue Constraints_shift( Constraints* _THIS, + int offset /**< Shift offset within the range [0,n/2] and integer divisor of n. */ + ); + +/** Rotates forward type and status of all constraints by a given + * offset. This offset has to lie within the range [0,n]. + * Example for offset = 2: \n + * rotate( {c1,c2,c3,c4,c5,c6} ) = {c3,c4,c5,c6,c1,c2} + * \return SUCCESSFUL_RETURN \n + RET_INDEX_OUT_OF_BOUNDS \n + RET_ROTATING_FAILED */ +returnValue Constraints_rotate( Constraints* _THIS, + int offset /**< Rotation offset within the range [0,n]. */ + ); + + +/** Prints information on constraints object + * (in particular, lists of inactive and active constraints. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_CORRUPTED */ +returnValue Constraints_print( Constraints* _THIS + ); + + +/** Initially adds all numbers of new (i.e. not yet in the list) bounds to + * to the index set corresponding to the desired status; + * the order depends on the SujectToType of each index. + * \return SUCCESSFUL_RETURN \n + RET_SETUP_CONSTRAINT_FAILED */ +returnValue Constraints_setupAll( Constraints* _THIS, + SubjectToStatus _status /**< Desired initial status for all bounds. */ + ); + + +/** Adds the index of a new constraint to index set. + * \return SUCCESSFUL_RETURN \n + RET_ADDINDEX_FAILED \n + RET_INVALID_ARGUMENTS */ +returnValue Constraints_addIndex( Constraints* _THIS, + Indexlist* const indexlist, /**< Index list to which the new index shall be added. */ + int newnumber, /**< Number of new constraint. */ + SubjectToStatus newstatus /**< Status of new constraint. */ + ); + +/** Removes the index of a constraint from index set. + * \return SUCCESSFUL_RETURN \n + RET_REMOVEINDEX_FAILED \n + RET_INVALID_ARGUMENTS */ +returnValue Constraints_removeIndex( Constraints* _THIS, + Indexlist* const indexlist, /**< Index list from which the new index shall be removed. */ + int removenumber /**< Number of constraint to be removed. */ + ); + +/** Swaps the indices of two constraints or bounds within the index set. + * \return SUCCESSFUL_RETURN \n + RET_SWAPINDEX_FAILED \n + RET_INVALID_ARGUMENTS */ +returnValue Constraints_swapIndex( Constraints* _THIS, + Indexlist* const indexlist, /**< Index list in which the indices shold be swapped. */ + int number1, /**< Number of first constraint. */ + int number2 /**< Number of second constraint. */ + ); + + + +/* + * g e t N u m b e r O f T y p e + */ +static inline int Constraints_getNumberOfType( Constraints* _THIS, SubjectToType _type ) +{ + int i; + int numberOfType = 0; + + if ( _THIS->type != 0 ) + { + for( i=0; i<_THIS->n; ++i ) + if ( _THIS->type[i] == _type ) + ++numberOfType; + } + + return numberOfType; +} + + +/* + * g e t T y p e + */ +static inline SubjectToType Constraints_getType( Constraints* _THIS, int i ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + return _THIS->type[i]; + + return ST_UNKNOWN; +} + + +/* + * g e t S t a t u s + */ +static inline SubjectToStatus Constraints_getStatus( Constraints* _THIS, int i ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + return _THIS->status[i]; + + return ST_UNDEFINED; +} + + +/* + * s e t T y p e + */ +static inline returnValue Constraints_setType( Constraints* _THIS, int i, SubjectToType value ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + { + _THIS->type[i] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t S t a t u s + */ +static inline returnValue Constraints_setStatus( Constraints* _THIS, int i, SubjectToStatus value ) +{ + if ( ( i >= 0 ) && ( i < _THIS->n ) ) + { + _THIS->status[i] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t N o L o w e r + */ +static inline void Constraints_setNoLower( Constraints* _THIS, BooleanType _status ) +{ + _THIS->noLower = _status; +} + + +/* + * s e t N o U p p e r + */ +static inline void Constraints_setNoUpper( Constraints* _THIS, BooleanType _status ) +{ + _THIS->noUpper = _status; +} + + +/* + * h a s N o L o w e r + */ +static inline BooleanType Constraints_hasNoLower( Constraints* _THIS ) +{ + return _THIS->noLower; +} + + +/* + * h a s N o U p p p e r + */ +static inline BooleanType Constraints_hasNoUpper( Constraints* _THIS ) +{ + return _THIS->noUpper; +} + + + +/* + * g e t N C + */ +static inline int Constraints_getNC( Constraints* _THIS ) +{ + return _THIS->n; +} + + +/* + * g e t N E C + */ +static inline int Constraints_getNEC( Constraints* _THIS ) +{ + return Constraints_getNumberOfType( _THIS,ST_EQUALITY ); +} + + +/* + * g e t N I C + */ +static inline int Constraints_getNIC( Constraints* _THIS ) +{ + return Constraints_getNumberOfType( _THIS,ST_BOUNDED ); +} + + +/* + * g e t N U C + */ +static inline int Constraints_getNUC( Constraints* _THIS ) +{ + return Constraints_getNumberOfType( _THIS,ST_UNBOUNDED ); +} + + +/* + * g e t N A C + */ +static inline int Constraints_getNAC( Constraints* _THIS ) +{ + return Indexlist_getLength( _THIS->active ); +} + + +/* + * g e t N I A C + */ +static inline int Constraints_getNIAC( Constraints* _THIS ) +{ + return Indexlist_getLength( _THIS->inactive ); +} + + + +/* + * g e t A c t i v e + */ +static inline Indexlist* Constraints_getActive( Constraints* _THIS ) +{ + return _THIS->active; +} + + +/* + * g e t I n a c t i v e + */ +static inline Indexlist* Constraints_getInactive( Constraints* _THIS ) +{ + return _THIS->inactive; +} + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_CONSTRAINTS_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/Flipper.h b/third_party/acados/include/qpOASES_e/Flipper.h new file mode 100644 index 00000000000000..63526a30f368e4 --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Flipper.h @@ -0,0 +1,129 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Flipper.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of the Options class designed to manage user-specified + * options for solving a QProblem. + */ + + +#ifndef QPOASES_FLIPPER_H +#define QPOASES_FLIPPER_H + + +#include +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** + * \brief Auxiliary class for storing a copy of the current matrix factorisations. + * + * This auxiliary class stores a copy of the current matrix factorisations. It + * is used by the classe QProblemB and QProblem in case flipping bounds are enabled. + * + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + Bounds *bounds; /**< Data structure for problem's bounds. */ + Constraints *constraints; /**< Data structure for problem's constraints. */ + + real_t *R; /**< Cholesky factor of H (i.e. H = R^T*R). */ + real_t *Q; /**< Orthonormal quadratic matrix, A = [0 T]*Q'. */ + real_t *T; /**< Reverse triangular matrix, A = [0 T]*Q'. */ + + unsigned int nV; /**< Number of variables. */ + unsigned int nC; /**< Number of constraints. */ +} Flipper; + +int Flipper_calculateMemorySize( unsigned int nV, unsigned int nC ); + +char *Flipper_assignMemory( unsigned int nV, unsigned int nC, Flipper **mem, void *raw_memory ); + +Flipper *Flipper_createMemory( unsigned int nV, unsigned int nC ); + +/** Constructor which takes the number of bounds and constraints. */ +void FlipperCON( Flipper* _THIS, + unsigned int _nV, /**< Number of bounds. */ + unsigned int _nC /**< Number of constraints. */ + ); + +/** Copy constructor (deep copy). */ +void FlipperCPY( Flipper* FROM, + Flipper* TO + ); + +/** Initialises object with given number of bounds and constraints. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ +returnValue Flipper_init( Flipper* _THIS, + unsigned int _nV, /**< Number of bounds. */ + unsigned int _nC /**< Number of constraints. */ + ); + + +/** Copies current values to non-null arguments (assumed to be allocated with consistent size). + * \return SUCCESSFUL_RETURN */ +returnValue Flipper_get( Flipper* _THIS, + Bounds* const _bounds, /**< Pointer to new bounds. */ + real_t* const R, /**< New matrix R. */ + Constraints* const _constraints, /**< Pointer to new constraints. */ + real_t* const _Q, /**< New matrix Q. */ + real_t* const _T /**< New matrix T. */ + ); + +/** Assigns new values to non-null arguments. + * \return SUCCESSFUL_RETURN */ +returnValue Flipper_set( Flipper* _THIS, + const Bounds* const _bounds, /**< Pointer to new bounds. */ + const real_t* const _R, /**< New matrix R. */ + const Constraints* const _constraints, /**< Pointer to new constraints. */ + const real_t* const _Q, /**< New matrix Q. */ + const real_t* const _T /**< New matrix T. */ + ); + +/** Returns dimension of matrix T. + * \return Dimension of matrix T. */ +unsigned int Flipper_getDimT( Flipper* _THIS ); + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_FLIPPER_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/Indexlist.h b/third_party/acados/include/qpOASES_e/Indexlist.h new file mode 100644 index 00000000000000..c3026a7ffc29a3 --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Indexlist.h @@ -0,0 +1,221 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Indexlist.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of the Indexlist class designed to manage index lists of + * constraints and bounds within a SubjectTo object. + */ + + +#ifndef QPOASES_INDEXLIST_H +#define QPOASES_INDEXLIST_H + + +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** + * \brief Stores and manages index lists. + * + * This class manages index lists of active/inactive bounds/constraints. + * + * \author Hans Joachim Ferreau + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + int *number; /**< Array to store numbers of constraints or bounds. */ + int *iSort; /**< Index list to sort vector \a number */ + + 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. */ +} Indexlist; + +int Indexlist_calculateMemorySize( int n); + +char *Indexlist_assignMemory(int n, Indexlist **mem, void *raw_memory); + +Indexlist *Indexlist_createMemory( int n ); + +/** Constructor which takes the desired physical length of the index list. */ +void IndexlistCON( Indexlist* _THIS, + int n /**< Physical length of index list. */ + ); + +/** Copies all members from given rhs object. + * \return SUCCESSFUL_RETURN */ +void IndexlistCPY( Indexlist* FROM, + Indexlist* TO + ); + +/** Initialises index list of desired physical length. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ +returnValue Indexlist_init( Indexlist* _THIS, + int n /**< Physical length of index list. */ + ); + +/** Creates an array of all numbers within the index set in correct order. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_CORRUPTED */ +returnValue Indexlist_getNumberArray( Indexlist* _THIS, + int** const numberarray /**< Output: Array of numbers (NULL on error). */ + ); + +/** Creates an array of all numbers within the index set in correct order. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_CORRUPTED */ +returnValue Indexlist_getISortArray( Indexlist* _THIS, + int** const iSortArray /**< Output: iSort Array. */ + ); + + +/** Determines the index within the index list at which a given number is stored. + * \return >= 0: Index of given number. \n + -1: Number not found. */ +int Indexlist_getIndex( Indexlist* _THIS, + int givennumber /**< Number whose index shall be determined. */ + ); + +/** Returns the number stored at a given physical index. + * \return >= 0: Number stored at given physical index. \n + -RET_INDEXLIST_OUTOFBOUNDS */ +static inline int Indexlist_getNumber( Indexlist* _THIS, + int physicalindex /**< Physical index of the number to be returned. */ + ); + + +/** Returns the current length of the index list. + * \return Current length of the index list. */ +static inline int Indexlist_getLength( Indexlist* _THIS + ); + +/** Returns last number within the index list. + * \return Last number within the index list. */ +static inline int Indexlist_getLastNumber( Indexlist* _THIS + ); + + +/** Adds number to index list. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_MUST_BE_REORDERD \n + RET_INDEXLIST_EXCEEDS_MAX_LENGTH */ +returnValue Indexlist_addNumber( Indexlist* _THIS, + int addnumber /**< Number to be added. */ + ); + +/** Removes number from index list. + * \return SUCCESSFUL_RETURN */ +returnValue Indexlist_removeNumber( Indexlist* _THIS, + int removenumber /**< Number to be removed. */ + ); + +/** Swaps two numbers within index list. + * \return SUCCESSFUL_RETURN */ +returnValue Indexlist_swapNumbers( Indexlist* _THIS, + 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 */ +static inline BooleanType Indexlist_isMember( Indexlist* _THIS, + int _number /**< Number to be tested for membership. */ + ); + + +/** Find first index j between -1 and length in sorted list of indices + * iSort such that numbers[iSort[j]] <= i < numbers[iSort[j+1]]. Uses + * bisection. + * \return j. */ +int Indexlist_findInsert( Indexlist* _THIS, + int i + ); + + + +/* + * g e t N u m b e r + */ +static inline int Indexlist_getNumber( Indexlist* _THIS, int physicalindex ) +{ + /* consistency check */ + if ( ( physicalindex < 0 ) || ( physicalindex > _THIS->length ) ) + return -RET_INDEXLIST_OUTOFBOUNDS; + + return _THIS->number[physicalindex]; +} + + +/* + * g e t L e n g t h + */ +static inline int Indexlist_getLength( Indexlist* _THIS ) +{ + return _THIS->length; +} + + +/* + * g e t L a s t N u m b e r + */ +static inline int Indexlist_getLastNumber( Indexlist* _THIS ) +{ + return _THIS->number[_THIS->length-1]; +} + + +/* + * g e t L a s t N u m b e r + */ +static inline BooleanType Indexlist_isMember( Indexlist* _THIS, int _number ) +{ + if ( Indexlist_getIndex( _THIS,_number ) >= 0 ) + return BT_TRUE; + else + return BT_FALSE; +} + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_INDEXLIST_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/Matrices.h b/third_party/acados/include/qpOASES_e/Matrices.h new file mode 100644 index 00000000000000..1d6da8c3c17822 --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Matrices.h @@ -0,0 +1,287 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Matrices.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2009-2015 + * + * Various matrix classes: Abstract base matrix class, dense and sparse matrices, + * including symmetry exploiting specializations. + */ + + + +#ifndef QPOASES_MATRICES_H +#define QPOASES_MATRICES_H + +#ifdef __USE_SINGLE_PRECISION__ + + // single precision + #define GEMM sgemm_ + #define GEMV sgemv_ +// #define SYR ssyr_ +// #define SYR2 ssyr2_ + #define POTRF spotrf_ + +#else + + // double precision + #define GEMM dgemm_ + #define GEMV dgemv_ +// #define SYR dsyr_ +// #define SYR2 dsyr2_ + #define POTRF dpotrf_ + +#endif /* __USE_SINGLE_PRECISION__ */ + + +#ifdef EXTERNAL_BLAS + // double precision + void dgemm_(char *ta, char *tb, int *m, int *n, int *k, double *alpha, double *A, int *lda, double *B, int ldb, double *beta, double *C, int *ldc); + void dgemv_(char *ta, int *m, int *n, double *alpha, double *A, int *lda, double *x, int *incx, double *beta, double *y, int *incy); + void dpotrf_(char *uplo, int *m, double *A, int *lda, int *info); + // single precision + void sgemm_(char *ta, char *tb, int *m, int *n, int *k, float *alpha, float *A, int *lda, float *B, int ldb, float *beta, float *C, int *ldc); + void sgemv_(char *ta, int *m, int *n, float *alpha, float *A, int *lda, float *x, int *incx, float *beta, float *y, int *incy); + void spotrf_(char *uplo, int *m, float *A, int *lda, int *info); +#else + /** Performs one of the matrix-matrix operation in double precision. */ + void dgemm_ ( const char*, const char*, const unsigned long*, const unsigned long*, const unsigned long*, + const double*, const double*, const unsigned long*, const double*, const unsigned long*, + const double*, double*, const unsigned long* ); + /** Performs one of the matrix-matrix operation in single precision. */ + void sgemm_ ( const char*, const char*, const unsigned long*, const unsigned long*, const unsigned long*, + const float*, const float*, const unsigned long*, const float*, const unsigned long*, + const float*, float*, const unsigned long* ); + + /** Calculates the Cholesky factorization of a real symmetric positive definite matrix in double precision. */ + void dpotrf_ ( const char *, const unsigned long *, double *, const unsigned long *, long * ); + /** Calculates the Cholesky factorization of a real symmetric positive definite matrix in single precision. */ + void spotrf_ ( const char *, const unsigned long *, float *, const unsigned long *, long * ); + +#endif + + /** Performs a symmetric rank 1 operation in double precision. */ +// void dsyr_ ( const char *, const unsigned long *, const double *, const double *, +// const unsigned long *, double *, const unsigned long *); + /** Performs a symmetric rank 1 operation in single precision. */ +// void ssyr_ ( const char *, const unsigned long *, const float *, const float *, +// const unsigned long *, float *, const unsigned long *); + + /** Performs a symmetric rank 2 operation in double precision. */ +// void dsyr2_ ( const char *, const unsigned long *, const double *, const double *, +// const unsigned long *, const double *, const unsigned long *, double *, const unsigned long *); + /** Performs a symmetric rank 2 operation in single precision. */ +// void ssyr2_ ( const char *, const unsigned long *, const float *, const float *, +// const unsigned long *, const float *, const unsigned long *, float *, const unsigned long *); + + +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** + * \brief Interfaces matrix-vector operations tailored to general dense matrices. + * + * Dense matrix class (row major format). + * + * \author Andreas Potschka, Christian Kirches, Hans Joachim Ferreau + * \version 3.1embedded + * \date 2011-2015 + */ +typedef struct +{ + real_t *val; /**< Vector of entries. */ + int nRows; /**< Number of rows. */ + int nCols; /**< Number of columns. */ + int leaDim; /**< Leading dimension. */ +} DenseMatrix; + +int DenseMatrix_calculateMemorySize( int m, int n ); + +char *DenseMatrix_assignMemory( int m, int n, DenseMatrix **mem, void *raw_memory ); + +DenseMatrix *DenseMatrix_createMemory( int m, int n ); + +/** Constructor from vector of values. + * Caution: Data pointer must be valid throughout lifetime + */ +void DenseMatrixCON( DenseMatrix* _THIS, + int m, /**< Number of rows. */ + int n, /**< Number of columns. */ + int lD, /**< Leading dimension. */ + real_t *v /**< Values. */ + ); + +void DenseMatrixCPY( DenseMatrix* FROM, + DenseMatrix* TO + ); + + +/** Frees all internal memory. */ +void DenseMatrix_free( DenseMatrix* _THIS ); + +/** Constructor from vector of values. + * Caution: Data pointer must be valid throughout lifetime + */ +returnValue DenseMatrix_init( DenseMatrix* _THIS, + int m, /**< Number of rows. */ + int n, /**< Number of columns. */ + int lD, /**< Leading dimension. */ + real_t *v /**< Values. */ + ); + + +/** Returns i-th diagonal entry. + * \return i-th diagonal entry */ +real_t DenseMatrix_diag( DenseMatrix* _THIS, + int i /**< Index. */ + ); + +/** Checks whether matrix is square and diagonal. + * \return BT_TRUE iff matrix is square and diagonal; \n + * BT_FALSE otherwise. */ +BooleanType DenseMatrix_isDiag( DenseMatrix* _THIS ); + +/** Get the N-norm of the matrix + * \return N-norm of the matrix + */ +real_t DenseMatrix_getNorm( DenseMatrix* _THIS, + int type /**< Norm type, 1: one-norm, 2: Euclidean norm. */ + ); + +/** Get the N-norm of a row + * \return N-norm of row \a rNum + */ +real_t DenseMatrix_getRowNorm( DenseMatrix* _THIS, + int rNum, /**< Row number. */ + int type /**< Norm type, 1: one-norm, 2: Euclidean norm. */ + ); + +/** Retrieve indexed entries of matrix row multiplied by alpha. + * \return SUCCESSFUL_RETURN */ +returnValue DenseMatrix_getRow( DenseMatrix* _THIS, + int rNum, /**< Row number. */ + const Indexlist* const icols, /**< Index list specifying columns. */ + real_t alpha, /**< Scalar factor. */ + real_t *row /**< Output row vector. */ + ); + +/** Retrieve indexed entries of matrix column multiplied by alpha. + * \return SUCCESSFUL_RETURN */ + returnValue DenseMatrix_getCol( DenseMatrix* _THIS, + int cNum, /**< Column number. */ + const Indexlist* const irows, /**< Index list specifying rows. */ + real_t alpha, /**< Scalar factor. */ + real_t *col /**< Output column vector. */ + ); + +/** Evaluate Y=alpha*A*X + beta*Y. + * \return SUCCESSFUL_RETURN. */ +returnValue DenseMatrix_times( DenseMatrix* _THIS, + int xN, /**< Number of vectors to multiply. */ + real_t alpha, /**< Scalar factor for matrix vector product. */ + const real_t *x, /**< Input vector to be multiplied. */ + int xLD, /**< Leading dimension of input x. */ + real_t beta, /**< Scalar factor for y. */ + real_t *y, /**< Output vector of results. */ + int yLD /**< Leading dimension of output y. */ + ); + +/** Evaluate Y=alpha*A'*X + beta*Y. + * \return SUCCESSFUL_RETURN. */ +returnValue DenseMatrix_transTimes( DenseMatrix* _THIS, + int xN, /**< Number of vectors to multiply. */ + real_t alpha, /**< Scalar factor for matrix vector product. */ + const real_t *x, /**< Input vector to be multiplied. */ + int xLD, /**< Leading dimension of input x. */ + real_t beta, /**< Scalar factor for y. */ + real_t *y, /**< Output vector of results. */ + int yLD /**< Leading dimension of output y. */ + ); + +/** Evaluate matrix vector product with submatrix given by Indexlist. + * \return SUCCESSFUL_RETURN */ + returnValue DenseMatrix_subTimes( DenseMatrix* _THIS, + const Indexlist* const irows, /**< Index list specifying rows. */ + const Indexlist* const icols, /**< Index list specifying columns. */ + int xN, /**< Number of vectors to multiply. */ + real_t alpha, /**< Scalar factor for matrix vector product. */ + const real_t *x, /**< Input vector to be multiplied. */ + int xLD, /**< Leading dimension of input x. */ + real_t beta, /**< Scalar factor for y. */ + real_t *y, /**< Output vector of results. */ + int yLD, /**< Leading dimension of output y. */ + BooleanType yCompr /**< Compressed storage for y. */ + ); + +/** Evaluate matrix transpose vector product. + * \return SUCCESSFUL_RETURN */ +returnValue DenseMatrix_subTransTimes( DenseMatrix* _THIS, + const Indexlist* const irows, /**< Index list specifying rows. */ + const Indexlist* const icols, /**< Index list specifying columns. */ + int xN, /**< Number of vectors to multiply. */ + real_t alpha, /**< Scalar factor for matrix vector product. */ + const real_t *x, /**< Input vector to be multiplied. */ + int xLD, /**< Leading dimension of input x. */ + real_t beta, /**< Scalar factor for y. */ + real_t *y, /**< Output vector of results. */ + int yLD /**< Leading dimension of output y. */ + ); + +/** Adds given offset to diagonal of matrix. + * \return SUCCESSFUL_RETURN \n + RET_NO_DIAGONAL_AVAILABLE */ +returnValue DenseMatrix_addToDiag( DenseMatrix* _THIS, + real_t alpha /**< Diagonal offset. */ + ); + +/** Prints matrix to screen. + * \return SUCCESSFUL_RETURN */ +returnValue DenseMatrix_print( DenseMatrix* _THIS + ); + +static inline real_t* DenseMatrix_getVal( DenseMatrix* _THIS ) { return _THIS->val; } + +/** Compute bilinear form y = x'*H*x using submatrix given by index list. + * \return SUCCESSFUL_RETURN */ +returnValue DenseMatrix_bilinear( DenseMatrix* _THIS, + const Indexlist* const icols, /**< Index list specifying columns of x. */ + int xN, /**< Number of vectors to multiply. */ + const real_t *x, /**< Input vector to be multiplied (uncompressed). */ + int xLD, /**< Leading dimension of input x. */ + real_t *y, /**< Output vector of results (compressed). */ + int yLD /**< Leading dimension of output y. */ + ); + + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_MATRICES_H */ diff --git a/third_party/acados/include/qpOASES_e/MessageHandling.h b/third_party/acados/include/qpOASES_e/MessageHandling.h new file mode 100644 index 00000000000000..fe5524948a8b2c --- /dev/null +++ b/third_party/acados/include/qpOASES_e/MessageHandling.h @@ -0,0 +1,544 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/MessageHandling.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches (thanks to Leonard Wirsching) + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of the MessageHandling class including global return values. + */ + + +#ifndef QPOASES_MESSAGEHANDLING_H +#define QPOASES_MESSAGEHANDLING_H + + +#include +#include +#include +#include + +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** Default file to display messages. */ +#define stdFile stderr + + +/** + * \brief Defines all symbols for global return values. + * + * The enumeration returnValueType defines all symbols for global return values. + * Important: All return values are assumed to be nonnegative! + * + * \author Hans Joachim Ferreau + */ +typedef enum +{ +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 occurred is not yet known. */ +RET_PRINTLEVEL_CHANGED, /**< Print level changed. (10) */ +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. (18) */ +RET_ADDINDEX_FAILED, /**< Adding index to index set failed. */ +RET_REMOVEINDEX_FAILED, /**< Removing index from index set failed. (20) */ +RET_SWAPINDEX_FAILED, /**< Cannot swap between different indexsets. */ +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. */ +RET_SHIFTING_FAILED, /**< Shifting of bounds/constraints failed. */ +RET_ROTATING_FAILED, /**< Rotating of bounds/constraints failed. */ +/* QProblem */ +RET_QPOBJECT_NOT_SETUP, /**< The QP object has not been setup correctly, use another constructor. */ +RET_QP_ALREADY_INITIALISED, /**< QProblem has already been initialised. (30) */ +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, /**< 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_FAILED_REGULARISATION, /**< Initialisation failed as Hessian matrix could not be regularised. */ +RET_INIT_SUCCESSFUL, /**< Initialisation done. (40) */ +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_CHOLESKY_WITH_INITIAL_GUESS, /**< Externally computed Cholesky factor cannot be combined with an initial guess. */ +RET_NO_EXTERN_SOLVER, /**< No extern QP solver available. */ +RET_QP_UNBOUNDED, /**< QP is unbounded. */ +RET_QP_INFEASIBLE, /**< QP is infeasible. */ +RET_QP_NOT_SOLVED, /**< Problems occurred while solving QP with standard solver. */ +RET_QP_SOLVED, /**< QP successfully solved. */ +RET_UNABLE_TO_SOLVE_QP, /**< Problems occurred while solving QP. (50) */ +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, /**< 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. (60) */ +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, /**< 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. (70) */ +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, /**< 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. (80) */ +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, /**< 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 constraint matrix successfully resolved. (90) */ +RET_ENSURELI_FAILED, /**< Failed to ensure linear independence of active constraint matrix. */ +RET_ENSURELI_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ +RET_ENSURELI_FAILED_NOINDEX, /**< QP is infeasible. */ +RET_ENSURELI_FAILED_CYCLING, /**< QP is infeasible. */ +RET_BOUND_ALREADY_ACTIVE, /**< Bound is already active. */ +RET_ALL_BOUNDS_ACTIVE, /**< 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_HESSIAN_INDEFINITE, /**< Hessian matrix is indefinite. (100) */ +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. */ +RET_DISABLECONSTRAINTS_FAILED, /**< Unable to disbable constraints. */ +RET_ENABLECONSTRAINTS_FAILED, /**< Unable to enbable constraints. */ +RET_ALREADY_ENABLED, /**< Bound or constraint is already enabled. */ +RET_ALREADY_DISABLED, /**< Bound or constraint is already disabled. */ +RET_NO_HESSIAN_SPECIFIED, /**< No Hessian matrix has been specified. */ +RET_USING_REGULARISATION, /**< Using regularisation as Hessian matrix is not positive definite. (110) */ +RET_EPS_MUST_BE_POSITVE, /**< Eps for regularisation must be sufficiently positive. */ +RET_REGSTEPS_MUST_BE_POSITVE, /**< Maximum number of regularisation steps must be non-negative. */ +RET_HESSIAN_ALREADY_REGULARISED, /**< Hessian has been already regularised. */ +RET_CANNOT_REGULARISE_IDENTITY, /**< Identity Hessian matrix cannot be regularised. */ +RET_CANNOT_REGULARISE_SPARSE, /**< Sparse matrix cannot be regularised as diagonal entry is missing. */ +RET_NO_REGSTEP_NWSR, /**< No additional regularisation step could be performed due to limits. */ +RET_FEWER_REGSTEPS_NWSR, /**< Fewer additional regularisation steps have been performed due to limits. */ +RET_CHOLESKY_OF_ZERO_HESSIAN, /**< Cholesky decomposition of (unregularised) zero Hessian matrix. */ +RET_ZERO_HESSIAN_ASSUMED, /**< Zero Hessian matrix assumed as null pointer passed without specifying hessianType. */ +RET_CONSTRAINTS_ARE_NOT_SCALED, /**< (no longer in use) (120) */ +RET_INITIAL_BOUNDS_STATUS_NYI, /**< (no longer in use) */ +RET_ERROR_IN_CONSTRAINTPRODUCT, /**< Error in user-defined constraint product function. */ +RET_FIX_BOUNDS_FOR_LP, /**< All initial bounds must be fixed when solving an (unregularised) LP. */ +RET_USE_REGULARISATION_FOR_LP, /**< Set options.enableRegularisation=BT_TRUE for solving LPs. */ +/* SQProblem */ +RET_UPDATEMATRICES_FAILED, /**< Unable to update QP matrices. */ +RET_UPDATEMATRICES_FAILED_AS_QP_NOT_SOLVED, /**< Unable to update matrices as previous QP is not solved. */ +/* 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, /**< Unable to read from file. */ +RET_FILEDATA_INCONSISTENT, /**< File contains inconsistent data. (130) */ +/* Options */ +RET_OPTIONS_ADJUSTED, /**< Options needed to be adjusted for consistency reasons. */ +/* SolutionAnalysis */ +RET_UNABLE_TO_ANALYSE_QPROBLEM, /**< Unable to analyse (S)QProblem(B) object. */ +/* Benchmark */ +RET_NWSR_SET_TO_ONE, /**< Maximum number of working set changes was set to 1. */ +RET_UNABLE_TO_READ_BENCHMARK, /**< Unable to read benchmark data. */ +RET_BENCHMARK_ABORTED, /**< Benchmark aborted. */ +RET_INITIAL_QP_SOLVED, /**< Initial QP solved. */ +RET_QP_SOLUTION_STARTED, /**< Solving QP... */ +RET_BENCHMARK_SUCCESSFUL, /**< Benchmark terminated successfully. */ +/* Sparse matrices */ +RET_NO_DIAGONAL_AVAILABLE, /**< Sparse matrix does not have entries on full diagonal. */ +RET_DIAGONAL_NOT_INITIALISED, /**< Diagonal data of sparse matrix has not been initialised. (140) */ +/* Dropping of infeasible constraints */ +RET_ENSURELI_DROPPED, /**< Linear independence resolved by dropping blocking constraint. */ +/* Simple exitflags */ +RET_SIMPLE_STATUS_P1, /**< QP problem could not be solved within given number of iterations. */ +RET_SIMPLE_STATUS_P0, /**< QP problem solved. */ +RET_SIMPLE_STATUS_M1, /**< QP problem could not be solved due to an internal error. */ +RET_SIMPLE_STATUS_M2, /**< QP problem is infeasible (and thus could not be solved). */ +RET_SIMPLE_STATUS_M3 /**< QP problem is unbounded (and thus could not be solved). (146) */ +} returnValue; + + +/** + * \brief Data structure for entries in global message list. + * + * Data structure for entries in global message list. + * + * \author Hans Joachim Ferreau + * \version 3.1embedded + * \date 2007-2015 + */ +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; + + + +/** + * \brief Handles all kind of error messages, warnings and other information. + * + * This class handles all kinds of messages (errors, warnings, infos) initiated + * by qpOASES modules and stores the corresponding global preferences. + * + * \author Hans Joachim Ferreau (thanks to Leonard Wirsching) + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + VisibilityStatus errorVisibility; /**< Error messages visible? */ + VisibilityStatus warningVisibility; /**< Warning messages visible? */ + VisibilityStatus infoVisibility; /**< Info messages visible? */ + + FILE* outputFile; /**< Output file for messages. */ + + int errorCount; /**< Counts number of errors (for nicer output only). */ +} MessageHandling; + + + +/** Constructor which takes the desired output file and desired visibility states. */ +void MessageHandlingCON( MessageHandling* _THIS, + FILE* _outputFile, /**< Output file. */ + VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ + VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ + VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ + ); + +void MessageHandlingCPY( MessageHandling* FROM, + MessageHandling* TO + ); + + +/** 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 MessageHandling_throwError( MessageHandling* _THIS, + 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 stderr. + * 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 MessageHandling_throwWarning( MessageHandling* _THIS, + 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 stderr. + * 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 MessageHandling_throwInfo( MessageHandling* _THIS, + 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 stderr. + * 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 MessageHandling_reset( MessageHandling* _THIS ); + + +/** Prints a complete list of all messages to output file. + * \return SUCCESSFUL_RETURN */ +returnValue MessageHandling_listAllMessages( MessageHandling* _THIS ); + + +/** Returns visibility status for error messages. + * \return Visibility status for error messages. */ +static inline VisibilityStatus MessageHandling_getErrorVisibilityStatus( MessageHandling* _THIS ); + +/** Returns visibility status for warning messages. + * \return Visibility status for warning messages. */ +static inline VisibilityStatus MessageHandling_getWarningVisibilityStatus( MessageHandling* _THIS ); + +/** Returns visibility status for info messages. + * \return Visibility status for info messages. */ +static inline VisibilityStatus MessageHandling_getInfoVisibilityStatus( MessageHandling* _THIS ); + +/** Returns pointer to output file. + * \return Pointer to output file. */ +static inline FILE* MessageHandling_getOutputFile( MessageHandling* _THIS ); + +/** Returns error count value. + * \return Error count value. */ +static inline int MessageHandling_getErrorCount( MessageHandling* _THIS ); + + +/** Changes visibility status for error messages. */ +static inline void MessageHandling_setErrorVisibilityStatus( MessageHandling* _THIS, + VisibilityStatus _errorVisibility /**< New visibility status for error messages. */ + ); + +/** Changes visibility status for warning messages. */ +static inline void MessageHandling_setWarningVisibilityStatus( MessageHandling* _THIS, + VisibilityStatus _warningVisibility /**< New visibility status for warning messages. */ + ); + +/** Changes visibility status for info messages. */ +static inline void MessageHandling_setInfoVisibilityStatus( MessageHandling* _THIS, + VisibilityStatus _infoVisibility /**< New visibility status for info messages. */ + ); + +/** Changes output file for messages. */ +static inline void MessageHandling_setOutputFile( MessageHandling* _THIS, + FILE* _outputFile /**< New output file for messages. */ + ); + +/** Changes error count. + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENT */ +static inline returnValue MessageHandling_setErrorCount( MessageHandling* _THIS, + int _errorCount /**< New error count value. */ + ); + +/** Provides message text corresponding to given \a returnValue. + * \return String containing message text. */ +const char* MessageHandling_getErrorCodeMessage( MessageHandling* _THIS, + const returnValue _returnValue + ); + + +returnValue MessageHandling_throwMessage( MessageHandling* _THIS, + 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 stderr. + * 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. */ + ); + + +#ifndef __FILE__ + /** Ensures that __FILE__ macro is defined. */ + #define __FILE__ 0 +#endif + +#ifndef __LINE__ + /** Ensures that __LINE__ macro is defined. */ + #define __LINE__ 0 +#endif + +/** Define __FUNC__ macro providing current function for debugging. */ +/*#define __FUNC__ 0*/ +#define __FUNC__ ("(no function name provided)") +/*#define __FUNC__ __func__*/ +/*#define __FUNC__ __FUNCTION__*/ + + +/** Short version of throwError with default values, only returnValue is needed */ +#define THROWERROR(retval) ( MessageHandling_throwError( qpOASES_getGlobalMessageHandler(),(retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) + +/** Short version of throwWarning with default values, only returnValue is needed */ +#define THROWWARNING(retval) ( MessageHandling_throwWarning( qpOASES_getGlobalMessageHandler(),(retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) + +/** Short version of throwInfo with default values, only returnValue is needed */ +#define THROWINFO(retval) ( MessageHandling_throwInfo( qpOASES_getGlobalMessageHandler(),(retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) + + +/** Returns a pointer to global message handler. + * \return Pointer to global message handler. + */ +MessageHandling* qpOASES_getGlobalMessageHandler( ); + + +/* + * g e t E r r o r V i s i b i l i t y S t a t u s + */ +static inline VisibilityStatus MessageHandling_getErrorVisibilityStatus( MessageHandling* _THIS ) +{ + return _THIS->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 + */ +static inline VisibilityStatus MessageHandling_getWarningVisibilityStatus( MessageHandling* _THIS ) +{ + return _THIS->warningVisibility; +} + + +/* + * g e t I n f o V i s i b i l i t y S t a t u s + */ +static inline VisibilityStatus MessageHandling_getInfoVisibilityStatus( MessageHandling* _THIS ) +{ + return _THIS->infoVisibility; +} + + +/* + * g e t O u t p u t F i l e + */ +static inline FILE* MessageHandling_getOutputFile( MessageHandling* _THIS ) +{ + return _THIS->outputFile; +} + + +/* + * g e t E r r o r C o u n t + */ +static inline int MessageHandling_getErrorCount( MessageHandling* _THIS ) +{ + return _THIS->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 + */ +static inline void MessageHandling_setErrorVisibilityStatus( MessageHandling* _THIS, VisibilityStatus _errorVisibility ) +{ + _THIS->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 + */ +static inline void MessageHandling_setWarningVisibilityStatus( MessageHandling* _THIS, VisibilityStatus _warningVisibility ) +{ + _THIS->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 + */ +static inline void MessageHandling_setInfoVisibilityStatus( MessageHandling* _THIS, VisibilityStatus _infoVisibility ) +{ + _THIS->infoVisibility = _infoVisibility; +} + + +/* + * s e t O u t p u t F i l e + */ +static inline void MessageHandling_setOutputFile( MessageHandling* _THIS, FILE* _outputFile ) +{ + _THIS->outputFile = _outputFile; +} + + +/* + * s e t E r r o r C o u n t + */ +static inline returnValue MessageHandling_setErrorCount( MessageHandling* _THIS, int _errorCount ) +{ + if ( _errorCount >= 0 ) + { + _THIS->errorCount = _errorCount; + return SUCCESSFUL_RETURN; + } + else + return RET_INVALID_ARGUMENTS; +} + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_MESSAGEHANDLING_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/Options.h b/third_party/acados/include/qpOASES_e/Options.h new file mode 100644 index 00000000000000..b471ee0668fd76 --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Options.h @@ -0,0 +1,153 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Options.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of the Options class designed to manage user-specified + * options for solving a QProblem. + */ + + +#ifndef QPOASES_OPTIONS_H +#define QPOASES_OPTIONS_H + + +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** + * \brief Manages all user-specified options for solving QPs. + * + * This class manages all user-specified options used for solving + * quadratic programs. + * + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + PrintLevel printLevel; /**< Print level. */ + + BooleanType enableRamping; /**< Specifies whether ramping shall be enabled or not. */ + BooleanType enableFarBounds; /**< Specifies whether far bounds shall be used or not. */ + BooleanType enableFlippingBounds; /**< Specifies whether flipping bounds shall be used or not. */ + BooleanType enableRegularisation; /**< Specifies whether Hessian matrix shall be regularised in case semi-definiteness is detected. */ + BooleanType enableFullLITests; /**< Specifies whether condition-hardened LI test shall be used or not. */ + BooleanType enableNZCTests; /**< Specifies whether nonzero curvature tests shall be used. */ + int enableDriftCorrection; /**< Specifies the frequency of drift corrections (0 = off). */ + int enableCholeskyRefactorisation; /**< Specifies the frequency of full refactorisation of proj. Hessian (otherwise updates). */ + BooleanType enableEqualities; /**< Specifies whether equalities shall be always treated as active constraints. */ + + real_t terminationTolerance; /**< Termination tolerance. */ + real_t boundTolerance; /**< Lower/upper (constraints') bound tolerance (an inequality constraint whose lower and upper bounds differ by less is regarded to be an equality constraint). */ + real_t boundRelaxation; /**< Offset for relaxing (constraints') bounds at beginning of an initial homotopy. It is also as initial value for far bounds. */ + real_t epsNum; /**< Numerator tolerance for ratio tests. */ + real_t epsDen; /**< Denominator tolerance for ratio tests. */ + real_t maxPrimalJump; /**< Maximum allowed jump in primal variables in nonzero curvature tests. */ + real_t maxDualJump; /**< Maximum allowed jump in dual variables in linear independence tests. */ + + real_t initialRamping; /**< Start value for Ramping Strategy. */ + real_t finalRamping; /**< Final value for Ramping Strategy. */ + real_t initialFarBounds; /**< Initial size of Far Bounds. */ + real_t growFarBounds; /**< Factor to grow Far Bounds. */ + SubjectToStatus initialStatusBounds; /**< Initial status of bounds at first iteration. */ + real_t epsFlipping; /**< Tolerance of squared Cholesky diagonal factor which triggers flipping bound. */ + int numRegularisationSteps; /**< Maximum number of successive regularisation steps. */ + real_t epsRegularisation; /**< Scaling factor of identity matrix used for Hessian regularisation. */ + int numRefinementSteps; /**< Maximum number of iterative refinement steps. */ + real_t epsIterRef; /**< Early termination tolerance for iterative refinement. */ + real_t epsLITests; /**< Tolerance for linear independence tests. */ + real_t epsNZCTests; /**< Tolerance for nonzero curvature tests. */ + + BooleanType enableDropInfeasibles; /**< ... */ + int dropBoundPriority; /**< ... */ + int dropEqConPriority; /**< ... */ + int dropIneqConPriority; /**< ... */ +} Options; + + +void OptionsCON( Options* _THIS + ); + +/** Copies all members from given rhs object. + * \return SUCCESSFUL_RETURN */ +void OptionsCPY( Options* FROM, + Options* TO + ); + + +/** Sets all options to default values. + * \return SUCCESSFUL_RETURN */ +returnValue Options_setToDefault( Options* _THIS + ); + +/** Sets all options to values resulting in maximum reliabilty. + * \return SUCCESSFUL_RETURN */ +returnValue Options_setToReliable( Options* _THIS + ); + +/** Sets all options to values resulting in minimum solution time. + * \return SUCCESSFUL_RETURN */ +returnValue Options_setToMPC( Options* _THIS + ); + +/** Same as setToMPC( ), for ensuring backwards compatibility. + * \return SUCCESSFUL_RETURN */ +returnValue Options_setToFast( Options* _THIS + ); + + +/** Ensures that all options have consistent values by automatically + * adjusting inconsistent ones. + * Note: This routine cannot (and does not try to) ensure that values + * are set to reasonable values that make the QP solution work! + * \return SUCCESSFUL_RETURN \n + * RET_OPTIONS_ADJUSTED */ +returnValue Options_ensureConsistency( Options* _THIS + ); + + +/** Prints values of all options. + * \return SUCCESSFUL_RETURN */ +returnValue Options_print( Options* _THIS + ); + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_OPTIONS_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/QProblem.h b/third_party/acados/include/qpOASES_e/QProblem.h new file mode 100644 index 00000000000000..3c61a4d59681d6 --- /dev/null +++ b/third_party/acados/include/qpOASES_e/QProblem.h @@ -0,0 +1,2369 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/QProblem.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of the QProblem class which is able to use the newly + * developed online active set strategy for parametric quadratic programming. + */ + + + +#ifndef QPOASES_QPROBLEM_H +#define QPOASES_QPROBLEM_H + + +#include +#include +#include +#include +#include +#include + + +BEGIN_NAMESPACE_QPOASES + +typedef struct { + Bounds *auxiliaryBounds; + Constraints *auxiliaryConstraints; + + real_t *ub_new_far; + real_t *lb_new_far; + real_t *ubA_new_far; + real_t *lbA_new_far; + + real_t *g_new; + real_t *lb_new; + real_t *ub_new; + real_t *lbA_new; + real_t *ubA_new; + + real_t *g_new2; + real_t *lb_new2; + real_t *ub_new2; + real_t *lbA_new2; + real_t *ubA_new2; + + real_t *delta_xFX5; + real_t *delta_xFR5; + real_t *delta_yAC5; + real_t *delta_yFX5; + + real_t *Hx; + + real_t *_H; + + real_t *g_original; + real_t *lb_original; + real_t *ub_original; + real_t *lbA_original; + real_t *ubA_original; + + real_t *delta_xFR; + real_t *delta_xFX; + real_t *delta_yAC; + real_t *delta_yFX; + real_t *delta_g; + real_t *delta_lb; + real_t *delta_ub; + real_t *delta_lbA; + real_t *delta_ubA; + + real_t *gMod; + + real_t *aFR; + real_t *wZ; + + real_t *delta_g2; + real_t *delta_xFX2; + real_t *delta_xFR2; + real_t *delta_yAC2; + real_t *delta_yFX2; + real_t *nul; + real_t *Arow; + + real_t *xiC; + real_t *xiC_TMP; + real_t *xiB; + real_t *Arow2; + real_t *num; + + real_t *w; + real_t *tmp; + + real_t *delta_g3; + real_t *delta_xFX3; + real_t *delta_xFR3; + real_t *delta_yAC3; + real_t *delta_yFX3; + real_t *nul2; + + real_t *xiC2; + real_t *xiC_TMP2; + real_t *xiB2; + real_t *num2; + + real_t *Hz; + real_t *z; + real_t *ZHz; + real_t *r; + + real_t *tmp2; + real_t *Hz2; + real_t *z2; + real_t *r2; + real_t *rhs; + + real_t *delta_xFX4; + real_t *delta_xFR4; + real_t *delta_yAC4; + real_t *delta_yFX4; + real_t *nul3; + real_t *ek; + real_t *x_W; + real_t *As; + real_t *Ax_W; + + real_t *num3; + real_t *den; + real_t *delta_Ax_l; + real_t *delta_Ax_u; + real_t *delta_Ax; + real_t *delta_x; + + real_t *_A; + + real_t *grad; + real_t *AX; +} QProblem_ws; + +int QProblem_ws_calculateMemorySize( unsigned int nV, unsigned int nC ); + +char *QProblem_ws_assignMemory( unsigned int nV, unsigned int nC, QProblem_ws **mem, void *raw_memory ); + +QProblem_ws *QProblem_ws_createMemory( unsigned int nV, unsigned int nC ); + +/** + * \brief Implements the online active set strategy for QPs with general constraints. + * + * 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, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + QProblem_ws *ws; /**< Workspace */ + Bounds *bounds; /**< Data structure for problem's bounds. */ + Constraints *constraints; /**< Data structure for problem's constraints. */ + Flipper *flipper; /**< Struct for making a temporary copy of the matrix factorisations. */ + + DenseMatrix* H; /**< Hessian matrix pointer. */ + DenseMatrix* A; /**< Constraint matrix pointer. */ + + Options options; /**< Struct containing all user-defined options for solving QPs. */ + TabularOutput tabularOutput; /**< Struct storing information for tabular output (printLevel == PL_TABULAR). */ + + real_t *g; /**< Gradient. */ + + real_t *lb; /**< Lower bound vector (on variables). */ + real_t *ub; /**< Upper bound vector (on variables). */ + real_t *lbA; /**< Lower constraints' bound vector. */ + real_t *ubA; /**< Upper constraints' bound vector. */ + + real_t *R; /**< Cholesky factor of H (i.e. H = R^T*R). */ + + real_t *T; /**< Reverse triangular matrix, A = [0 T]*Q'. */ + real_t *Q; /**< Orthonormal quadratic matrix, A = [0 T]*Q'. */ + + real_t *Ax; /**< Stores the current A*x \n + * (for increased efficiency only). */ + real_t *Ax_l; /**< Stores the current distance to lower constraints' bounds A*x-lbA \n + * (for increased efficiency only). */ + real_t *Ax_u; /**< Stores the current distance to lower constraints' bounds ubA-A*x \n + * (for increased efficiency only). */ + + real_t *x; /**< Primal solution vector. */ + real_t *y; /**< Dual solution vector. */ + + real_t *delta_xFR_TMP; /**< Temporary for determineStepDirection */ + real_t *tempA; /**< Temporary for determineStepDirection. */ + real_t *tempB; /**< Temporary for determineStepDirection. */ + real_t *ZFR_delta_xFRz; /**< Temporary for determineStepDirection. */ + real_t *delta_xFRy; /**< Temporary for determineStepDirection. */ + real_t *delta_xFRz; /**< Temporary for determineStepDirection. */ + real_t *delta_yAC_TMP; /**< Temporary for determineStepDirection. */ + + ConstraintProduct constraintProduct; /**< Pointer to user-defined constraint product function. */ + + real_t tau; /**< Last homotopy step length. */ + real_t regVal; /**< Holds the offset used to regularise Hessian matrix (zero by default). */ + + real_t ramp0; /**< Start value for Ramping Strategy. */ + real_t ramp1; /**< Final value for Ramping Strategy. */ + + QProblemStatus status; /**< Current status of the solution process. */ + HessianType hessianType; /**< Type of Hessian matrix. */ + + BooleanType haveCholesky; /**< Flag indicating whether Cholesky decomposition has already been setup. */ + BooleanType infeasible; /**< QP infeasible? */ + BooleanType unbounded; /**< QP unbounded? */ + + int rampOffset; /**< Offset index for Ramping. */ + unsigned int count; /**< Counts the number of hotstart function calls (internal usage only!). */ + + int sizeT; /**< Matrix T is stored in a (sizeT x sizeT) array. */ +} QProblem; + +int QProblem_calculateMemorySize( unsigned int nV, unsigned int nC ); + +char *QProblem_assignMemory( unsigned int nV, unsigned int nC, QProblem **mem, void *raw_memory ); + +QProblem *QProblem_createMemory( unsigned int nV, unsigned int nC ); + + +/** Constructor which takes the QP dimension and Hessian type + * information. If the Hessian is the zero (i.e. HST_ZERO) or the + * identity matrix (i.e. HST_IDENTITY), respectively, no memory + * is allocated for it and a NULL pointer can be passed for it + * to the init() functions. */ +void QProblemCON( QProblem* _THIS, + int _nV, /**< Number of variables. */ + int _nC, /**< Number of constraints. */ + HessianType _hessianType /**< Type of Hessian matrix. */ + ); + +/** Copies all members from given rhs object. + * \return SUCCESSFUL_RETURN */ +void QProblemCPY( QProblem* FROM, + QProblem* TO + ); + + +/** Clears all data structures of QProblem except for QP data. + * \return SUCCESSFUL_RETURN \n + RET_RESET_FAILED */ +returnValue QProblem_reset( QProblem* _THIS ); + + +/** Initialises a QP problem with given QP data and tries to solve it + * using at most nWSR iterations. + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblem_initM( QProblem* _THIS, + DenseMatrix *_H, /**< Hessian matrix. */ + const real_t* const _g, /**< Gradient vector. */ + DenseMatrix *_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. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation (if pointer passed). */ + ); + + +/** Initialises a QP problem with given QP data and tries to solve it + * using at most nWSR iterations. + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblem_init( QProblem* _THIS, + real_t* const _H, /**< Hessian matrix. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + const real_t* const _g, /**< Gradient vector. */ + 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. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation (if pointer passed). */ + ); + +/** Initialises a QP problem with given QP data to be read from files and tries to solve it + * using at most nWSR iterations. + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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_UNABLE_TO_READ_FILE */ +returnValue QProblem_initF( QProblem* _THIS, + const char* const H_file, /**< Name of file where Hessian matrix is stored. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + const char* const g_file, /**< Name of file where gradient vector is stored. */ + const char* const A_file, /**< Name of file where constraint matrix is stored. */ + const char* const lb_file, /**< Name of file where lower bound vector. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bound vector. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const char* const lbA_file, /**< Name of file where lower constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const char* const ubA_file, /**< Name of file where upper constraints' bound vector. \n + If no upper 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. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation (if pointer passed). */ + ); + +/** Initialises a QP problem with given QP data and tries to solve it + * using at most nWSR iterations. Depending on the parameter constellation it: \n + * 1. 0, 0, 0 : starts with xOpt = 0, yOpt = 0 and gB/gC empty (or all implicit equality bounds), \n + * 2. xOpt, 0, 0 : starts with xOpt, yOpt = 0 and obtain gB/gC by "clipping", \n + * 3. 0, yOpt, 0 : starts with xOpt = 0, yOpt and obtain gB/gC from yOpt != 0, \n + * 4. 0, 0, gB/gC: starts with xOpt = 0, yOpt = 0 and gB/gC, \n + * 5. xOpt, yOpt, 0 : starts with xOpt, yOpt and obtain gB/gC from yOpt != 0, \n + * 6. xOpt, 0, gB/gC: starts with xOpt, yOpt = 0 and gB/gC, \n + * 7. xOpt, yOpt, gB/gC: starts with xOpt, yOpt and gB/gC (assume them to be consistent!) + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblem_initMW( QProblem* _THIS, + DenseMatrix *_H, /**< Hessian matrix. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + const real_t* const _g, /**< Gradient vector. */ + DenseMatrix *_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. */ + real_t* const cputime, /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation. */ + const real_t* const xOpt, /**< Optimal primal solution vector. \n + (If a null pointer is passed, the old primal solution is kept!) */ + const real_t* const yOpt, /**< Optimal dual solution vector. \n + (If a null pointer is passed, the old dual solution is kept!) */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). */ + Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). */ + const real_t* const _R /**< Pre-computed (upper triangular) Cholesky factor of Hessian matrix. + The Cholesky factor must be stored in a real_t array of size nV*nV + in row-major format. Note: Only used if xOpt/yOpt and gB are NULL! \n + (If a null pointer is passed, Cholesky decomposition is computed internally!) */ + ); + +/** Initialises a QP problem with given QP data and tries to solve it + * using at most nWSR iterations. Depending on the parameter constellation it: \n + * 1. 0, 0, 0 : starts with xOpt = 0, yOpt = 0 and gB/gC empty (or all implicit equality bounds), \n + * 2. xOpt, 0, 0 : starts with xOpt, yOpt = 0 and obtain gB/gC by "clipping", \n + * 3. 0, yOpt, 0 : starts with xOpt = 0, yOpt and obtain gB/gC from yOpt != 0, \n + * 4. 0, 0, gB/gC: starts with xOpt = 0, yOpt = 0 and gB/gC, \n + * 5. xOpt, yOpt, 0 : starts with xOpt, yOpt and obtain gB/gC from yOpt != 0, \n + * 6. xOpt, 0, gB/gC: starts with xOpt, yOpt = 0 and gB/gC, \n + * 7. xOpt, yOpt, gB/gC: starts with xOpt, yOpt and gB/gC (assume them to be consistent!) + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblem_initW( QProblem* _THIS, + real_t* const _H, /**< Hessian matrix. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + const real_t* const _g, /**< Gradient vector. */ + 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. */ + real_t* const cputime, /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation. */ + const real_t* const xOpt, /**< Optimal primal solution vector. \n + (If a null pointer is passed, the old primal solution is kept!) */ + const real_t* const yOpt, /**< Optimal dual solution vector. \n + (If a null pointer is passed, the old dual solution is kept!) */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). */ + Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). */ + const real_t* const _R /**< Pre-computed (upper triangular) Cholesky factor of Hessian matrix. + The Cholesky factor must be stored in a real_t array of size nV*nV + in row-major format. Note: Only used if xOpt/yOpt and gB are NULL! \n + (If a null pointer is passed, Cholesky decomposition is computed internally!) */ + ); + +/** Initialises a QP problem with given QP data to be ream from files and tries to solve it + * using at most nWSR iterations. Depending on the parameter constellation it: \n + * 1. 0, 0, 0 : starts with xOpt = 0, yOpt = 0 and gB/gC empty (or all implicit equality bounds), \n + * 2. xOpt, 0, 0 : starts with xOpt, yOpt = 0 and obtain gB/gC by "clipping", \n + * 3. 0, yOpt, 0 : starts with xOpt = 0, yOpt and obtain gB/gC from yOpt != 0, \n + * 4. 0, 0, gB/gC: starts with xOpt = 0, yOpt = 0 and gB/gC, \n + * 5. xOpt, yOpt, 0 : starts with xOpt, yOpt and obtain gB/gC from yOpt != 0, \n + * 6. xOpt, 0, gB/gC: starts with xOpt, yOpt = 0 and gB/gC, \n + * 7. xOpt, yOpt, gB/gC: starts with xOpt, yOpt and gB/gC (assume them to be consistent!) + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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_UNABLE_TO_READ_FILE */ +returnValue QProblem_initFW( QProblem* _THIS, + const char* const H_file, /**< Name of file where Hessian matrix is stored. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + const char* const g_file, /**< Name of file where gradient vector is stored. */ + const char* const A_file, /**< Name of file where constraint matrix is stored. */ + const char* const lb_file, /**< Name of file where lower bound vector. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bound vector. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const char* const lbA_file, /**< Name of file where lower constraints' bound vector. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const char* const ubA_file, /**< Name of file where upper constraints' bound vector. \n + If no upper 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. */ + real_t* const cputime, /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation. */ + const real_t* const xOpt, /**< Optimal primal solution vector. \n + (If a null pointer is passed, the old primal solution is kept!) */ + const real_t* const yOpt, /**< Optimal dual solution vector. \n + (If a null pointer is passed, the old dual solution is kept!) */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). */ + Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). */ + const char* const R_file /**< Pre-computed (upper triangular) Cholesky factor of Hessian matrix. + The Cholesky factor must be stored in a real_t array of size nV*nV + in row-major format. Note: Only used if xOpt/yOpt and gB are NULL! \n + (If a null pointer is passed, Cholesky decomposition is computed internally!) */ + ); + +/** Solves an initialised QP sequence using the online active set strategy. + * QP solution is started from previous solution. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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 */ +returnValue QProblem_hotstart( QProblem* _THIS, + 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 /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + ); + +/** Solves an initialised QP sequence using the online active set strategy, + * where QP data is read from files. QP solution is started from previous solution. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS */ +returnValue QProblem_hotstartF( QProblem* _THIS, + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const char* const lbA_file, /**< Name of file where lower constraints' bounds, of neighbouring QP to be solved, is stored. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const char* const ubA_file, /**< Name of file where upper constraints' bounds, of neighbouring QP to be solved, is stored. \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 /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + ); + +/** Solves an initialised QP sequence using the online active set strategy. + * By default, QP solution is started from previous solution. If a guess + * for the working set is provided, an initialised homotopy is performed. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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_SETUP_AUXILIARYQP_FAILED */ +returnValue QProblem_hotstartW( QProblem* _THIS, + 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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). \n + (If a null pointer is passed, the previous working set of bounds is kept!) */ + Constraints* const guessedConstraints /**< Optimal working set of constraints for solution (xOpt,yOpt). \n + (If a null pointer is passed, the previous working set of constraints is kept!) */ + ); + +/** Solves an initialised QP sequence using the online active set strategy, + * where QP data is read from files. + * By default, QP solution is started from previous solution. If a guess + * for the working set is provided, an initialised homotopy is performed. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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_SETUP_AUXILIARYQP_FAILED \n + RET_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS */ +returnValue QProblem_hotstartFW( QProblem* _THIS, + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const char* const lbA_file, /**< Name of file where lower constraints' bounds, of neighbouring QP to be solved, is stored. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const char* const ubA_file, /**< Name of file where upper constraints' bounds, of neighbouring QP to be solved, is stored. \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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). \n + (If a null pointer is passed, the previous working set of bounds is kept!) */ + Constraints* const guessedConstraints /**< Optimal working set of constraints for solution (xOpt,yOpt). \n + (If a null pointer is passed, the previous working set of constraints is kept!) */ + ); + + +/** Solves using the current working set + * \return SUCCESSFUL_RETURN \n + * RET_STEPDIRECTION_FAILED_TQ \n + * RET_STEPDIRECTION_FAILED_CHOLESKY \n + * RET_INVALID_ARGUMENTS */ +returnValue QProblem_solveCurrentEQP ( QProblem* _THIS, + const int n_rhs, /**< Number of consecutive right hand sides */ + const real_t* g_in, /**< Gradient of neighbouring QP to be solved. */ + const real_t* lb_in, /**< Lower bounds of neighbouring QP to be solved. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const real_t* ub_in, /**< Upper bounds of neighbouring QP to be solved. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const real_t* lbA_in, /**< 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* ubA_in, /**< Upper constraints' bounds of neighbouring QP to be solved. \n */ + real_t* x_out, /**< Output: Primal solution */ + real_t* y_out /**< Output: Dual solution */ + ); + + + +/** Returns current constraints object of the QP (deep copy). + * \return SUCCESSFUL_RETURN \n + RET_QPOBJECT_NOT_SETUP */ +static inline returnValue QProblem_getConstraints( QProblem* _THIS, + Constraints* _constraints /** Output: Constraints object. */ + ); + + +/** Returns the number of constraints. + * \return Number of constraints. */ +static inline int QProblem_getNC( QProblem* _THIS ); + +/** Returns the number of (implicitly defined) equality constraints. + * \return Number of (implicitly defined) equality constraints. */ +static inline int QProblem_getNEC( QProblem* _THIS ); + +/** Returns the number of active constraints. + * \return Number of active constraints. */ +static inline int QProblem_getNAC( QProblem* _THIS ); + +/** Returns the number of inactive constraints. + * \return Number of inactive constraints. */ +static inline int QProblem_getNIAC( QProblem* _THIS ); + +/** Returns the dimension of null space. + * \return Dimension of null space. */ +int QProblem_getNZ( QProblem* _THIS ); + + +/** Returns the dual solution vector (deep copy). + * \return SUCCESSFUL_RETURN \n + RET_QP_NOT_SOLVED */ +returnValue QProblem_getDualSolution( QProblem* _THIS, + real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ + ); + + +/** Defines user-defined routine for calculating the constraint product A*x + * \return SUCCESSFUL_RETURN \n */ +returnValue QProblem_setConstraintProduct( QProblem* _THIS, + ConstraintProduct _constraintProduct + ); + + +/** Prints concise list of properties of the current QP. + * \return SUCCESSFUL_RETURN \n */ +returnValue QProblem_printProperties( QProblem* _THIS ); + + + +/** Writes a vector with the state of the working set +* \return SUCCESSFUL_RETURN */ +returnValue QProblem_getWorkingSet( QProblem* _THIS, + real_t* workingSet /** Output: array containing state of the working set. */ + ); + +/** Writes a vector with the state of the working set of bounds + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +returnValue QProblem_getWorkingSetBounds( QProblem* _THIS, + real_t* workingSetB /** Output: array containing state of the working set of bounds. */ + ); + +/** Writes a vector with the state of the working set of constraints + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +returnValue QProblem_getWorkingSetConstraints( QProblem* _THIS, + real_t* workingSetC /** Output: array containing state of the working set of constraints. */ + ); + + +/** Returns current bounds object of the QP (deep copy). + * \return SUCCESSFUL_RETURN \n + RET_QPOBJECT_NOT_SETUP */ +static inline returnValue QProblem_getBounds( QProblem* _THIS, + Bounds* _bounds /** Output: Bounds object. */ + ); + + +/** Returns the number of variables. + * \return Number of variables. */ +static inline int QProblem_getNV( QProblem* _THIS ); + +/** Returns the number of free variables. + * \return Number of free variables. */ +static inline int QProblem_getNFR( QProblem* _THIS ); + +/** Returns the number of fixed variables. + * \return Number of fixed variables. */ +static inline int QProblem_getNFX( QProblem* _THIS ); + +/** Returns the number of implicitly fixed variables. + * \return Number of implicitly fixed variables. */ +static inline int QProblem_getNFV( QProblem* _THIS ); + + +/** 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 QProblem_getObjVal( QProblem* _THIS ); + +/** Returns the objective function value at an arbitrary point x. + * \return Objective function value at point x */ +real_t QProblem_getObjValX( QProblem* _THIS, + const real_t* const _x /**< Point at which the objective function shall be evaluated. */ + ); + +/** Returns the primal solution vector. + * \return SUCCESSFUL_RETURN \n + RET_QP_NOT_SOLVED */ +returnValue QProblem_getPrimalSolution( QProblem* _THIS, + real_t* const xOpt /**< Output: Primal solution vector (if QP has been solved). */ + ); + + +/** Returns status of the solution process. + * \return Status of solution process. */ +static inline QProblemStatus QProblem_getStatus( QProblem* _THIS ); + + +/** Returns if the QProblem object is initialised. + * \return BT_TRUE: QProblem initialised \n + BT_FALSE: QProblem not initialised */ +static inline BooleanType QProblem_isInitialised( QProblem* _THIS ); + +/** Returns if the QP has been solved. + * \return BT_TRUE: QProblem solved \n + BT_FALSE: QProblem not solved */ +static inline BooleanType QProblem_isSolved( QProblem* _THIS ); + +/** Returns if the QP is infeasible. + * \return BT_TRUE: QP infeasible \n + BT_FALSE: QP feasible (or not known to be infeasible!) */ +static inline BooleanType QProblem_isInfeasible( QProblem* _THIS ); + +/** Returns if the QP is unbounded. + * \return BT_TRUE: QP unbounded \n + BT_FALSE: QP unbounded (or not known to be unbounded!) */ +static inline BooleanType QProblem_isUnbounded( QProblem* _THIS ); + + +/** Returns Hessian type flag (type is not determined due to _THIS call!). + * \return Hessian type. */ +static inline HessianType QProblem_getHessianType( QProblem* _THIS ); + +/** Changes the print level. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblem_setHessianType( QProblem* _THIS, + HessianType _hessianType /**< New Hessian type. */ + ); + +/** Returns if the QP has been internally regularised. + * \return BT_TRUE: Hessian is internally regularised for QP solution \n + BT_FALSE: No internal Hessian regularisation is used for QP solution */ +static inline BooleanType QProblem_usingRegularisation( QProblem* _THIS ); + +/** Returns current options struct. + * \return Current options struct. */ +static inline Options QProblem_getOptions( QProblem* _THIS ); + +/** Overrides current options with given ones. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblem_setOptions( QProblem* _THIS, + Options _options /**< New options. */ + ); + +/** Returns the print level. + * \return Print level. */ +static inline PrintLevel QProblem_getPrintLevel( QProblem* _THIS ); + +/** Changes the print level. + * \return SUCCESSFUL_RETURN */ +returnValue QProblem_setPrintLevel( QProblem* _THIS, + PrintLevel _printlevel /**< New print level. */ + ); + + +/** Returns the current number of QP problems solved. + * \return Number of QP problems solved. */ +static inline unsigned int QProblem_getCount( QProblem* _THIS ); + +/** Resets QP problem counter (to zero). + * \return SUCCESSFUL_RETURN. */ +static inline returnValue QProblem_resetCounter( QProblem* _THIS ); + + +/** Prints a list of all options and their current values. + * \return SUCCESSFUL_RETURN \n */ +returnValue QProblem_printOptions( QProblem* _THIS ); + + +/** 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. + * Note: This function is internally called by all init functions! + * \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 QProblem_solveInitialQP( QProblem* _THIS, + const real_t* const xOpt, /**< Optimal primal solution vector.*/ + const real_t* const yOpt, /**< Optimal dual solution vector. */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). */ + Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). */ + const real_t* const _R, /**< Pre-computed (upper triangular) Cholesky factor of Hessian matrix. */ + int* nWSR, /**< Input: Maximum number of working set recalculations; \n + * Output: Number of performed working set recalculations. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP solution. \n + * Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + ); + +/** Solves QProblem using online active set strategy. + * Note: This function is internally called by all hotstart functions! + * \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 */ +returnValue QProblem_solveQP( QProblem* _THIS, + 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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + int nWSRperformed, /**< Number of working set recalculations already performed to solve + this QP within previous solveQP() calls. This number is + always zero, except for successive calls from solveRegularisedQP() + or when using the far bound strategy. */ + BooleanType isFirstCall /**< Indicating whether this is the first call for current QP. */ + ); + + +/** Solves QProblem using online active set strategy. + * Note: This function is internally called by all hotstart functions! + * \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 */ +returnValue QProblem_solveRegularisedQP( QProblem* _THIS, + 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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + int nWSRperformed, /**< Number of working set recalculations already performed to solve + this QP within previous solveRegularisedQP() calls. This number is + always zero, except for successive calls when using the far bound strategy. */ + BooleanType isFirstCall /**< Indicating whether this is the first call for current QP. */ + ); + + +/** Determines type of existing constraints and bounds (i.e. implicitly fixed, unbounded etc.). + * \return SUCCESSFUL_RETURN \n + RET_SETUPSUBJECTTOTYPE_FAILED */ +returnValue QProblem_setupSubjectToType( QProblem* _THIS ); + +/** Determines type of new constraints and bounds (i.e. implicitly fixed, unbounded etc.). + * \return SUCCESSFUL_RETURN \n + RET_SETUPSUBJECTTOTYPE_FAILED */ +returnValue QProblem_setupSubjectToTypeNew( QProblem* _THIS, + const real_t* const lb_new, /**< New lower bounds. */ + const real_t* const ub_new, /**< New upper bounds. */ + const real_t* const lbA_new, /**< New lower constraints' bounds. */ + const real_t* const ubA_new /**< New upper constraints' bounds. */ + ); + +/** Computes the Cholesky decomposition of the projected Hessian (i.e. R^T*R = Z^T*H*Z). + * Note: If Hessian turns out not to be positive definite, the Hessian type + * is set to HST_SEMIDEF accordingly. + * \return SUCCESSFUL_RETURN \n + * RET_HESSIAN_NOT_SPD \n + * RET_INDEXLIST_CORRUPTED */ +returnValue QProblem_computeProjectedCholesky( QProblem* _THIS ); + +/** Computes initial Cholesky decomposition of the projected Hessian making + * use of the function setupCholeskyDecomposition() or setupCholeskyDecompositionProjected(). + * \return SUCCESSFUL_RETURN \n + * RET_HESSIAN_NOT_SPD \n + * RET_INDEXLIST_CORRUPTED */ +returnValue QProblem_setupInitialCholesky( QProblem* _THIS ); + +/** Initialises TQ factorisation of A (i.e. A*Q = [0 T]) if NO constraint is active. + * \return SUCCESSFUL_RETURN \n + RET_INDEXLIST_CORRUPTED */ +returnValue QProblem_setupTQfactorisation( QProblem* _THIS ); + + +/** 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 QProblem_obtainAuxiliaryWorkingSet( QProblem* _THIS, + 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. */ + Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). */ + 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. */ + ); + +/** Sets up 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 QProblem_setupAuxiliaryWorkingSet( QProblem* _THIS, + Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ + 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. */ + ); + +/** Sets up the optimal primal/dual solution of the auxiliary initial QP. + * \return SUCCESSFUL_RETURN */ +returnValue QProblem_setupAuxiliaryQPsolution( QProblem* _THIS, + 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. */ + ); + +/** Sets up 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 QProblem_setupAuxiliaryQPgradient( QProblem* _THIS ); + +/** Sets up (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 QProblem_setupAuxiliaryQPbounds( QProblem* _THIS, + Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ + 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 QProblem_addConstraint( QProblem* _THIS, + 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. */ + BooleanType ensureLI /**< Ensure linear independence by exchange rules by default. */ + ); + +/** 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 QProblem_addConstraint_checkLI( QProblem* _THIS, + 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 QProblem_addConstraint_ensureLI( QProblem* _THIS, + 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 QProblem_addBound( QProblem* _THIS, + 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. */ + BooleanType ensureLI /**< Ensure linear independence by exchange rules by default. */ + ); + +/** 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 QProblem_addBound_checkLI( QProblem* _THIS, + 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 QProblem_addBound_ensureLI( QProblem* _THIS, + 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 QProblem_removeConstraint( QProblem* _THIS, + int number, /**< Number of constraint to be removed from active set. */ + BooleanType updateCholesky, /**< Flag indicating if Cholesky decomposition shall be updated. */ + BooleanType allowFlipping, /**< Flag indicating if flipping bounds are allowed. */ + BooleanType ensureNZC /**< Flag indicating if non-zero curvature is ensured by exchange rules. */ + ); + +/** Removes a bounds from active set. + * \return SUCCESSFUL_RETURN \n + RET_BOUND_NOT_ACTIVE \n + RET_HESSIAN_NOT_SPD \n + RET_REMOVEBOUND_FAILED */ +returnValue QProblem_removeBound( QProblem* _THIS, + int number, /**< Number of bound to be removed from active set. */ + BooleanType updateCholesky, /**< Flag indicating if Cholesky decomposition shall be updated. */ + BooleanType allowFlipping, /**< Flag indicating if flipping bounds are allowed. */ + BooleanType ensureNZC /**< Flag indicating if non-zero curvature is ensured by exchange rules. */ + ); + + +/** Performs robustified ratio test yield the maximum possible step length + * along the homotopy path. + * \return SUCCESSFUL_RETURN */ +returnValue QProblem_performPlainRatioTest( QProblem* _THIS, + int nIdx, /**< Number of ratios to be checked. */ + const int* const idxList, /**< Array containing the indices of all ratios to be checked. */ + const real_t* const num, /**< Array containing all numerators for performing the ratio test. */ + const real_t* const den, /**< Array containing all denominators for performing the ratio test. */ + real_t epsNum, /**< Numerator tolerance. */ + real_t epsDen, /**< Denominator tolerance. */ + real_t* t, /**< Output: Maximum possible step length along the homotopy path. */ + int* BC_idx /**< Output: Index of blocking constraint. */ + ); + + +/** Ensure non-zero curvature by primal jump. + * \return SUCCESSFUL_RETURN \n + * RET_HOTSTART_STOPPED_UNBOUNDEDNESS */ +returnValue QProblem_ensureNonzeroCurvature( QProblem* _THIS, + BooleanType removeBoundNotConstraint, /**< SubjectTo to be removed is a bound. */ + int remIdx, /**< Index of bound/constraint to be removed. */ + BooleanType* exchangeHappened, /**< Output: Exchange was necessary to ensure. */ + BooleanType* addBoundNotConstraint, /**< SubjectTo to be added is a bound. */ + int* addIdx, /**< Index of bound/constraint to be added. */ + SubjectToStatus* addStatus /**< Status of bound/constraint to be added. */ + ); + + +/** 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 QProblem_backsolveT( QProblem* _THIS, + 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 QProblem_determineDataShift( QProblem* _THIS, + 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 QProblem_determineStepDirection( QProblem* _THIS, + 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 + * and performs _THIS step (without changing working set). + * \return SUCCESSFUL_RETURN \n + * RET_ERROR_IN_CONSTRAINTPRODUCT \n + * RET_QP_INFEASIBLE */ +returnValue QProblem_performStep( QProblem* _THIS, + const real_t* const delta_g, /**< Step direction of gradient. */ + 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. */ + 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. */ + ); + +/** Updates the active set. + * \return SUCCESSFUL_RETURN \n + RET_REMOVE_FROM_ACTIVESET_FAILED \n + RET_ADD_TO_ACTIVESET_FAILED */ +returnValue QProblem_changeActiveSet( QProblem* _THIS, + int BC_idx, /**< Index of blocking constraint. */ + SubjectToStatus BC_status, /**< Status of blocking constraint. */ + BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ + ); + + +/** Compute relative length of homotopy in data space for termination + * criterion. + * \return Relative length in data space. */ +real_t QProblem_getRelativeHomotopyLength( QProblem* _THIS, + const real_t* const g_new, /**< Final gradient. */ + const real_t* const lb_new, /**< Final lower variable bounds. */ + const real_t* const ub_new, /**< Final upper variable bounds. */ + const real_t* const lbA_new, /**< Final lower constraint bounds. */ + const real_t* const ubA_new /**< Final upper constraint bounds. */ + ); + + +/** Ramping Strategy to avoid ties. Modifies homotopy start without + * changing current active set. + * \return SUCCESSFUL_RETURN */ +returnValue QProblem_performRamping( QProblem* _THIS ); + + +/** ... */ +returnValue QProblem_updateFarBounds( QProblem* _THIS, + real_t curFarBound, /**< ... */ + int nRamp, /**< ... */ + const real_t* const lb_new, /**< ... */ + real_t* const lb_new_far, /**< ... */ + const real_t* const ub_new, /**< ... */ + real_t* const ub_new_far, /**< ... */ + const real_t* const lbA_new, /**< ... */ + real_t* const lbA_new_far, /**< ... */ + const real_t* const ubA_new, /**< ... */ + real_t* const ubA_new_far /**< ... */ + ); + +/** ... */ +returnValue QProblemBCPY_updateFarBounds( QProblem* _THIS, + real_t curFarBound, /**< ... */ + int nRamp, /**< ... */ + const real_t* const lb_new, /**< ... */ + real_t* const lb_new_far, /**< ... */ + const real_t* const ub_new, /**< ... */ + real_t* const ub_new_far /**< ... */ + ); + + + +/** Performs robustified ratio test yield the maximum possible step length + * along the homotopy path. + * \return SUCCESSFUL_RETURN */ +returnValue QProblem_performRatioTestC( QProblem* _THIS, + int nIdx, /**< Number of ratios to be checked. */ + const int* const idxList, /**< Array containing the indices of all ratios to be checked. */ + Constraints* const subjectTo, /**< Constraint object corresponding to ratios to be checked. */ + const real_t* const num, /**< Array containing all numerators for performing the ratio test. */ + const real_t* const den, /**< Array containing all denominators for performing the ratio test. */ + real_t epsNum, /**< Numerator tolerance. */ + real_t epsDen, /**< Denominator tolerance. */ + real_t* t, /**< Output: Maximum possible step length along the homotopy path. */ + int* BC_idx /**< Output: Index of blocking constraint. */ + ); + + +/** Drift correction at end of each active set iteration + * \return SUCCESSFUL_RETURN */ +returnValue QProblem_performDriftCorrection( QProblem* _THIS ); + + +/** Updates QP vectors, working sets and internal data structures in order to + start from an optimal solution corresponding to initial guesses of the working + set for bounds and constraints. + * \return SUCCESSFUL_RETURN \n + * RET_SETUP_AUXILIARYQP_FAILED \n + RET_INVALID_ARGUMENTS */ +returnValue QProblem_setupAuxiliaryQP( QProblem* _THIS, + Bounds* const guessedBounds, /**< Initial guess for working set of bounds. */ + Constraints* const guessedConstraints /**< Initial guess for working set of constraints. */ + ); + +/** Determines if it is more efficient to refactorise the matrices when + * hotstarting or not (i.e. better to update the existing factorisations). + * \return BT_TRUE iff matrices shall be refactorised afresh + */ +BooleanType QProblem_shallRefactorise( QProblem* _THIS, + Bounds* const guessedBounds, /**< Guessed new working set of bounds. */ + Constraints* const guessedConstraints /**< Guessed new working set of constraints. */ + ); + +/** Setups internal QP data. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS \n + RET_UNKNONW_BUG */ +returnValue QProblem_setupQPdataM( QProblem* _THIS, + DenseMatrix *_H, /**< Hessian matrix. \n + If Hessian matrix is trivial,a NULL pointer can be passed. */ + const real_t* const _g, /**< Gradient vector. */ + DenseMatrix *_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. */ + ); + + +/** Sets up dense internal QP data. If the current Hessian is trivial + * (i.e. HST_ZERO or HST_IDENTITY) but a non-trivial one is given, + * memory for Hessian is allocated and it is set to the given one. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS \n + RET_UNKNONW_BUG */ +returnValue QProblem_setupQPdata( QProblem* _THIS, + real_t* const _H, /**< Hessian matrix. \n + If Hessian matrix is trivial,a NULL pointer can be passed. */ + const real_t* const _g, /**< Gradient vector. */ + 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. */ + ); + +/** Sets up internal QP data by loading it from files. If the current Hessian + * is trivial (i.e. HST_ZERO or HST_IDENTITY) but a non-trivial one is given, + * memory for Hessian is allocated and it is set to the given one. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS \n + RET_UNKNONW_BUG */ +returnValue QProblem_setupQPdataFromFile( QProblem* _THIS, + const char* const H_file, /**< Name of file where Hessian matrix, of neighbouring QP to be solved, is stored. \n + If Hessian matrix is trivial,a NULL pointer can be passed. */ + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const A_file, /**< Name of file where constraint matrix, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const char* const lbA_file, /**< Name of file where lower constraints' bounds, of neighbouring QP to be solved, is stored. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const char* const ubA_file /**< Name of file where upper constraints' bounds, of neighbouring QP to be solved, is stored. \n + If no upper constraints' bounds exist, a NULL pointer can be passed. */ + ); + +/** Loads new QP vectors from files (internal members are not affected!). + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS */ +returnValue QProblem_loadQPvectorsFromFile( QProblem* _THIS, + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + const char* const lbA_file, /**< Name of file where lower constraints' bounds, of neighbouring QP to be solved, is stored. \n + If no lower constraints' bounds exist, a NULL pointer can be passed. */ + const char* const ubA_file, /**< Name of file where upper constraints' bounds, of neighbouring QP to be solved, is stored. \n + If no upper constraints' bounds exist, a NULL pointer can be passed. */ + real_t* const g_new, /**< Output: Gradient of neighbouring QP to be solved. */ + real_t* const lb_new, /**< Output: Lower bounds of neighbouring QP to be solved */ + real_t* const ub_new, /**< Output: Upper bounds of neighbouring QP to be solved */ + real_t* const lbA_new, /**< Output: Lower constraints' bounds of neighbouring QP to be solved */ + real_t* const ubA_new /**< Output: Upper constraints' bounds of neighbouring QP to be solved */ + ); + + +/** Prints concise information on the current iteration. + * \return SUCCESSFUL_RETURN \n */ +returnValue QProblem_printIteration( QProblem* _THIS, + int iter, /**< 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. */ + real_t homotopyLength, /**< Current homotopy distance. */ + BooleanType isFirstCall /**< Indicating whether this is the first call for current QP. */ + ); + + +/** Sets constraint matrix of the QP. \n + Note: Also internal vector Ax is recomputed! + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +static inline returnValue QProblem_setAM( QProblem* _THIS, + DenseMatrix *A_new /**< New constraint matrix. */ + ); + +/** Sets dense constraint matrix of the QP. \n + Note: Also internal vector Ax is recomputed! + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +static inline returnValue QProblem_setA( QProblem* _THIS, + real_t* const A_new /**< New dense constraint matrix (with correct dimension!). */ + ); + + +/** Sets constraints' lower bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + * RET_QPOBJECT_NOT_SETUP */ +static inline returnValue QProblem_setLBA( QProblem* _THIS, + 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_QPOBJECT_NOT_SETUP \n + * RET_INDEX_OUT_OF_BOUNDS */ +static inline returnValue QProblem_setLBAn( QProblem* _THIS, + 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 \n + * RET_QPOBJECT_NOT_SETUP */ +static inline returnValue QProblem_setUBA( QProblem* _THIS, + 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_QPOBJECT_NOT_SETUP \n + * RET_INDEX_OUT_OF_BOUNDS */ +static inline returnValue QProblem_setUBAn( QProblem* _THIS, + int number, /**< Number of entry to be changed. */ + real_t value /**< New value for entry of upper constraints' bound vector (with correct dimension!). */ + ); + + +/** Decides if lower bounds are smaller than upper bounds + * + * \return SUCCESSFUL_RETURN \n + * RET_QP_INFEASIBLE */ +returnValue QProblem_areBoundsConsistent( QProblem* _THIS, + const real_t* const lb, /**< Vector of lower bounds*/ + const real_t* const ub, /**< Vector of upper bounds*/ + const real_t* const lbA, /**< Vector of lower constraints*/ + const real_t* const ubA /**< Vector of upper constraints*/ + ); + + +/** Drops the blocking bound/constraint that led to infeasibility, or finds another + * bound/constraint to drop according to drop priorities. + * \return SUCCESSFUL_RETURN \n + */ +returnValue QProblem_dropInfeasibles ( QProblem* _THIS, + int BC_number, /**< Number of the bound or constraint to be added */ + SubjectToStatus BC_status, /**< New status of the bound or constraint to be added */ + BooleanType BC_isBound, /**< Whether a bound or a constraint is to be added */ + real_t *xiB, + real_t *xiC + ); + + +/** If Hessian type has been set by the user, nothing is done. + * Otherwise the Hessian type is set to HST_IDENTITY, HST_ZERO, or + * HST_POSDEF (default), respectively. + * \return SUCCESSFUL_RETURN \n + RET_HESSIAN_INDEFINITE */ +returnValue QProblem_determineHessianType( QProblem* _THIS ); + +/** Computes the Cholesky decomposition 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! + * Note: If Hessian turns out not to be positive definite, the Hessian type + * is set to HST_SEMIDEF accordingly. + * \return SUCCESSFUL_RETURN \n + * RET_HESSIAN_NOT_SPD \n + * RET_INDEXLIST_CORRUPTED */ +returnValue QProblemBCPY_computeCholesky( QProblem* _THIS ); + +/** 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 QProblemBCPY_obtainAuxiliaryWorkingSet( QProblem* _THIS, + 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. */ + Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). */ + Bounds* auxiliaryBounds /**< Input: Allocated bound object. \n + * Output: Working set for auxiliary QP. */ + ); + + +/** 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 QProblem_backsolveR( QProblem* _THIS, + 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 QProblem_backsolveRrem( QProblem* _THIS, + 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 QProblemBCPY_determineDataShift( QProblem* _THIS, + 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. */ + ); + + +/** Sets up internal QP data. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ +returnValue QProblemBCPY_setupQPdataM( QProblem* _THIS, + DenseMatrix *_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. */ + ); + +/** Sets up internal QP data. If the current Hessian is trivial + * (i.e. HST_ZERO or HST_IDENTITY) but a non-trivial one is given, + * memory for Hessian is allocated and it is set to the given one. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS \n + RET_NO_HESSIAN_SPECIFIED */ +returnValue QProblemBCPY_setupQPdata( QProblem* _THIS, + real_t* const _H, /**< Hessian matrix. \n + If Hessian matrix is trivial,a NULL pointer can be passed. */ + 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 up internal QP data by loading it from files. If the current Hessian + * is trivial (i.e. HST_ZERO or HST_IDENTITY) but a non-trivial one is given, + * memory for Hessian is allocated and it is set to the given one. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS \n + RET_NO_HESSIAN_SPECIFIED */ +returnValue QProblemBCPY_setupQPdataFromFile( QProblem* _THIS, + const char* const H_file, /**< Name of file where Hessian matrix, of neighbouring QP to be solved, is stored. \n + If Hessian matrix is trivial,a NULL pointer can be passed. */ + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + ); + +/** Loads new QP vectors from files (internal members are not affected!). + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS */ +returnValue QProblemBCPY_loadQPvectorsFromFile( QProblem* _THIS, + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + real_t* const g_new, /**< Output: Gradient of neighbouring QP to be solved. */ + real_t* const lb_new, /**< Output: Lower bounds of neighbouring QP to be solved */ + real_t* const ub_new /**< Output: Upper bounds of neighbouring QP to be solved */ + ); + + +/** Sets internal infeasibility flag and throws given error in case the far bound + * strategy is not enabled (as QP might actually not be infeasible in _THIS case). + * \return RET_HOTSTART_STOPPED_INFEASIBILITY \n + RET_ENSURELI_FAILED_CYCLING \n + RET_ENSURELI_FAILED_NOINDEX */ +returnValue QProblem_setInfeasibilityFlag( QProblem* _THIS, + returnValue returnvalue, /**< Returnvalue to be tunneled. */ + BooleanType doThrowError /**< Flag forcing to throw an error. */ + ); + + +/** Determines if next QP iteration can be performed within given CPU time limit. + * \return BT_TRUE: CPU time limit is exceeded, stop QP solution. \n + BT_FALSE: Sufficient CPU time for next QP iteration. */ +BooleanType QProblem_isCPUtimeLimitExceeded( QProblem* _THIS, + const real_t* const cputime, /**< Maximum CPU time allowed for QP solution. */ + real_t starttime, /**< Start time of current QP solution. */ + int nWSR /**< Number of working set recalculations performed so far. */ + ); + + +/** Regularise Hessian matrix by adding a scaled identity matrix to it. + * \return SUCCESSFUL_RETURN \n + RET_HESSIAN_ALREADY_REGULARISED */ +returnValue QProblem_regulariseHessian( QProblem* _THIS ); + + +/** Sets Hessian matrix of the QP. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblem_setHM( QProblem* _THIS, + DenseMatrix* H_new /**< New Hessian matrix. */ + ); + +/** Sets dense Hessian matrix of the QP. + * If a null pointer is passed and + * a) hessianType is HST_IDENTITY, nothing is done, + * b) hessianType is not HST_IDENTITY, Hessian matrix is set to zero. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblem_setH( QProblem* _THIS, + real_t* const H_new /**< New dense Hessian matrix (with correct dimension!). */ + ); + +/** Changes gradient vector of the QP. + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +static inline returnValue QProblem_setG( QProblem* _THIS, + const real_t* const g_new /**< New gradient vector (with correct dimension!). */ + ); + +/** Changes lower bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +static inline returnValue QProblem_setLB( QProblem* _THIS, + 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 */ +static inline returnValue QProblem_setLBn( QProblem* _THIS, + 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 \n + * RET_INVALID_ARGUMENTS */ +static inline returnValue QProblem_setUB( QProblem* _THIS, + 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 */ +static inline returnValue QProblem_setUBn( QProblem* _THIS, + int number, /**< Number of entry to be changed. */ + real_t value /**< New value for entry of upper bound vector. */ + ); + + + +/** Compute relative length of homotopy in data space for termination + * criterion. + * \return Relative length in data space. */ +real_t QProblemBCPY_getRelativeHomotopyLength( QProblem* _THIS, + const real_t* const g_new, /**< Final gradient. */ + const real_t* const lb_new, /**< Final lower variable bounds. */ + const real_t* const ub_new /**< Final upper variable bounds. */ + ); + + + +/** Performs robustified ratio test yield the maximum possible step length + * along the homotopy path. + * \return SUCCESSFUL_RETURN */ +returnValue QProblem_performRatioTestB( QProblem* _THIS, + int nIdx, /**< Number of ratios to be checked. */ + const int* const idxList, /**< Array containing the indices of all ratios to be checked. */ + Bounds* const subjectTo, /**< Bound object corresponding to ratios to be checked. */ + const real_t* const num, /**< Array containing all numerators for performing the ratio test. */ + const real_t* const den, /**< Array containing all denominators for performing the ratio test. */ + real_t epsNum, /**< Numerator tolerance. */ + real_t epsDen, /**< Denominator tolerance. */ + real_t* t, /**< Output: Maximum possible step length along the homotopy path. */ + int* BC_idx /**< Output: Index of blocking constraint. */ + ); + +/** Checks whether given ratio is blocking, i.e. limits the maximum step length + * along the homotopy path to a value lower than given one. + * \return SUCCESSFUL_RETURN */ +static inline BooleanType QProblem_isBlocking( QProblem* _THIS, + real_t num, /**< Numerator for performing the ratio test. */ + real_t den, /**< Denominator for performing the ratio test. */ + real_t epsNum, /**< Numerator tolerance. */ + real_t epsDen, /**< Denominator tolerance. */ + real_t* t /**< Input: Current maximum step length along the homotopy path, + * Output: Updated maximum possible step length along the homotopy path. */ + ); + + +/** ... + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE */ +returnValue QProblem_writeQpDataIntoMatFile( QProblem* _THIS, + const char* const filename /**< Mat file name. */ + ); + +/** ... +* \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE */ +returnValue QProblem_writeQpWorkspaceIntoMatFile( QProblem* _THIS, + const char* const filename /**< Mat file name. */ + ); + + +/* + * g e t B o u n d s + */ +static inline returnValue QProblem_getBounds( QProblem* _THIS, Bounds* _bounds ) +{ + int nV = QProblem_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + _bounds = _THIS->bounds; + + return SUCCESSFUL_RETURN; +} + + +/* + * g e t N V + */ +static inline int QProblem_getNV( QProblem* _THIS ) +{ + return Bounds_getNV( _THIS->bounds ); +} + + +/* + * g e t N F R + */ +static inline int QProblem_getNFR( QProblem* _THIS ) +{ + return Bounds_getNFR( _THIS->bounds ); +} + + +/* + * g e t N F X + */ +static inline int QProblem_getNFX( QProblem* _THIS ) +{ + return Bounds_getNFX( _THIS->bounds ); +} + + +/* + * g e t N F V + */ +static inline int QProblem_getNFV( QProblem* _THIS ) +{ + return Bounds_getNFV( _THIS->bounds ); +} + + +/* + * g e t S t a t u s + */ +static inline QProblemStatus QProblem_getStatus( QProblem* _THIS ) +{ + return _THIS->status; +} + + +/* + * i s I n i t i a l i s e d + */ +static inline BooleanType QProblem_isInitialised( QProblem* _THIS ) +{ + if ( _THIS->status == QPS_NOTINITIALISED ) + return BT_FALSE; + else + return BT_TRUE; +} + + +/* + * i s S o l v e d + */ +static inline BooleanType QProblem_isSolved( QProblem* _THIS ) +{ + if ( _THIS->status == QPS_SOLVED ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * i s I n f e a s i b l e + */ +static inline BooleanType QProblem_isInfeasible( QProblem* _THIS ) +{ + return _THIS->infeasible; +} + + +/* + * i s U n b o u n d e d + */ +static inline BooleanType QProblem_isUnbounded( QProblem* _THIS ) +{ + return _THIS->unbounded; +} + + +/* + * g e t H e s s i a n T y p e + */ +static inline HessianType QProblem_getHessianType( QProblem* _THIS ) +{ + return _THIS->hessianType; +} + + +/* + * s e t H e s s i a n T y p e + */ +static inline returnValue QProblem_setHessianType( QProblem* _THIS, HessianType _hessianType ) +{ + _THIS->hessianType = _hessianType; + return SUCCESSFUL_RETURN; +} + + +/* + * u s i n g R e g u l a r i s a t i o n + */ +static inline BooleanType QProblem_usingRegularisation( QProblem* _THIS ) +{ + if ( _THIS->regVal > QPOASES_ZERO ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * g e t O p t i o n s + */ +static inline Options QProblem_getOptions( QProblem* _THIS ) +{ + return _THIS->options; +} + + +/* + * s e t O p t i o n s + */ +static inline returnValue QProblem_setOptions( QProblem* _THIS, + Options _options + ) +{ + OptionsCPY( &_options,&(_THIS->options) ); + Options_ensureConsistency( &(_THIS->options) ); + + QProblem_setPrintLevel( _THIS,_THIS->options.printLevel ); + + return SUCCESSFUL_RETURN; +} + + +/* + * g e t P r i n t L e v e l + */ +static inline PrintLevel QProblem_getPrintLevel( QProblem* _THIS ) +{ + return _THIS->options.printLevel; +} + + +/* + * g e t C o u n t + */ +static inline unsigned int QProblem_getCount( QProblem* _THIS ) +{ + return _THIS->count; +} + + +/* + * r e s e t C o u n t e r + */ +static inline returnValue QProblem_resetCounter( QProblem* _THIS ) +{ + _THIS->count = 0; + return SUCCESSFUL_RETURN; +} + + + +/***************************************************************************** + * P R O T E C T E D * + *****************************************************************************/ + + +/* + * s e t H + */ +static inline returnValue QProblem_setHM( QProblem* _THIS, DenseMatrix* H_new ) +{ + if ( H_new == 0 ) + return QProblem_setH( _THIS,(real_t*)0 ); + else + return QProblem_setH( _THIS,DenseMatrix_getVal(H_new) ); +} + + +/* + * s e t H + */ +static inline returnValue QProblem_setH( QProblem* _THIS, real_t* const H_new ) +{ + /* if null pointer is passed, Hessian is set to zero matrix + * (or stays identity matrix) */ + if ( H_new == 0 ) + { + if ( _THIS->hessianType == HST_IDENTITY ) + return SUCCESSFUL_RETURN; + + _THIS->hessianType = HST_ZERO; + + _THIS->H = 0; + } + else + { + DenseMatrixCON( _THIS->H,QProblem_getNV( _THIS ),QProblem_getNV( _THIS ),QProblem_getNV( _THIS ),H_new ); + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t G + */ +static inline returnValue QProblem_setG( QProblem* _THIS, const real_t* const g_new ) +{ + unsigned int nV = (unsigned int)QProblem_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( g_new == 0 ) + return THROWERROR( RET_INVALID_ARGUMENTS ); + + memcpy( _THIS->g,g_new,nV*sizeof(real_t) ); + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t L B + */ +static inline returnValue QProblem_setLB( QProblem* _THIS, const real_t* const lb_new ) +{ + unsigned int i; + unsigned int nV = (unsigned int)QProblem_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( lb_new != 0 ) + { + memcpy( _THIS->lb,lb_new,nV*sizeof(real_t) ); + } + else + { + /* if no lower bounds are specified, set them to -infinity */ + for( i=0; ilb[i] = -QPOASES_INFTY; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t L B + */ +static inline returnValue QProblem_setLBn( QProblem* _THIS, int number, real_t value ) +{ + int nV = QProblem_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ( number >= 0 ) && ( number < nV ) ) + { + _THIS->lb[number] = value; + return SUCCESSFUL_RETURN; + } + else + { + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + +/* + * s e t U B + */ +static inline returnValue QProblem_setUB( QProblem* _THIS, const real_t* const ub_new ) +{ + unsigned int i; + unsigned int nV = (unsigned int)QProblem_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ub_new != 0 ) + { + memcpy( _THIS->ub,ub_new,nV*sizeof(real_t) ); + } + else + { + /* if no upper bounds are specified, set them to infinity */ + for( i=0; iub[i] = QPOASES_INFTY; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t U B + */ +static inline returnValue QProblem_setUBn( QProblem* _THIS, int number, real_t value ) +{ + int nV = QProblem_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ( number >= 0 ) && ( number < nV ) ) + { + _THIS->ub[number] = value; + + return SUCCESSFUL_RETURN; + } + else + { + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + + +/* + * i s B l o c k i n g + */ +static inline BooleanType QProblem_isBlocking( QProblem* _THIS, + real_t num, + real_t den, + real_t epsNum, + real_t epsDen, + real_t* t + ) +{ + if ( ( den >= epsDen ) && ( num >= epsNum ) ) + { + if ( num < (*t)*den ) + return BT_TRUE; + } + + return BT_FALSE; +} + + + +/* + * g e t C o n s t r a i n t s + */ +static inline returnValue QProblem_getConstraints( QProblem* _THIS, Constraints* _constraints ) +{ + int nV = QProblem_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + ConstraintsCPY( _THIS->constraints,_constraints ); + + return SUCCESSFUL_RETURN; +} + + + +/* + * g e t N C + */ +static inline int QProblem_getNC( QProblem* _THIS ) +{ + return Constraints_getNC( _THIS->constraints ); +} + + +/* + * g e t N E C + */ +static inline int QProblem_getNEC( QProblem* _THIS ) +{ + return Constraints_getNEC( _THIS->constraints ); +} + + +/* + * g e t N A C + */ +static inline int QProblem_getNAC( QProblem* _THIS ) +{ + return Constraints_getNAC( _THIS->constraints ); +} + + +/* + * g e t N I A C + */ +static inline int QProblem_getNIAC( QProblem* _THIS ) +{ + return Constraints_getNIAC( _THIS->constraints ); +} + + + +/***************************************************************************** + * P R O T E C T E D * + *****************************************************************************/ + + +/* + * s e t A + */ +static inline returnValue QProblem_setAM( QProblem* _THIS, DenseMatrix *A_new ) +{ + if ( A_new == 0 ) + return QProblem_setA( _THIS,(real_t*)0 ); + else + return QProblem_setA( _THIS,DenseMatrix_getVal(A_new) ); +} + + +/* + * s e t A + */ +static inline returnValue QProblem_setA( QProblem* _THIS, real_t* const A_new ) +{ + int j; + int nV = QProblem_getNV( _THIS ); + int nC = QProblem_getNC( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( A_new == 0 ) + return THROWERROR( RET_INVALID_ARGUMENTS ); + + DenseMatrixCON( _THIS->A,QProblem_getNC( _THIS ),QProblem_getNV( _THIS ),QProblem_getNV( _THIS ),A_new ); + + DenseMatrix_times( _THIS->A,1, 1.0, _THIS->x, nV, 0.0, _THIS->Ax, nC); + + for( j=0; jAx_u[j] = _THIS->ubA[j] - _THIS->Ax[j]; + _THIS->Ax_l[j] = _THIS->Ax[j] - _THIS->lbA[j]; + + /* (ckirches) disable constraints with empty rows */ + if ( qpOASES_isZero( DenseMatrix_getRowNorm( _THIS->A,j,2 ),QPOASES_ZERO ) == BT_TRUE ) + Constraints_setType( _THIS->constraints,j,ST_DISABLED ); + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t L B A + */ +static inline returnValue QProblem_setLBA( QProblem* _THIS, const real_t* const lbA_new ) +{ + unsigned int i; + unsigned int nV = (unsigned int)QProblem_getNV( _THIS ); + unsigned int nC = (unsigned int)QProblem_getNC( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( lbA_new != 0 ) + { + memcpy( _THIS->lbA,lbA_new,nC*sizeof(real_t) ); + } + else + { + /* if no lower constraints' bounds are specified, set them to -infinity */ + for( i=0; ilbA[i] = -QPOASES_INFTY; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t L B A + */ +static inline returnValue QProblem_setLBAn( QProblem* _THIS, int number, real_t value ) +{ + int nV = QProblem_getNV( _THIS ); + int nC = QProblem_getNC( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ( number >= 0 ) && ( number < nC ) ) + { + _THIS->lbA[number] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +/* + * s e t U B A + */ +static inline returnValue QProblem_setUBA( QProblem* _THIS, const real_t* const ubA_new ) +{ + unsigned int i; + unsigned int nV = (unsigned int)QProblem_getNV( _THIS ); + unsigned int nC = (unsigned int)QProblem_getNC( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ubA_new != 0 ) + { + memcpy( _THIS->ubA,ubA_new,nC*sizeof(real_t) ); + } + else + { + /* if no upper constraints' bounds are specified, set them to infinity */ + for( i=0; iubA[i] = QPOASES_INFTY; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t U B A + */ +static inline returnValue QProblem_setUBAn( QProblem* _THIS, int number, real_t value ) +{ + int nV = QProblem_getNV( _THIS ); + int nC = QProblem_getNC( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ( number >= 0 ) && ( number < nC ) ) + { + _THIS->ubA[number] = value; + return SUCCESSFUL_RETURN; + } + else + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); +} + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_QPROBLEM_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/QProblemB.h b/third_party/acados/include/qpOASES_e/QProblemB.h new file mode 100644 index 00000000000000..ee5157dda77e8b --- /dev/null +++ b/third_party/acados/include/qpOASES_e/QProblemB.h @@ -0,0 +1,1641 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/QProblemB.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * 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_H +#define QPOASES_QPROBLEMB_H + + +#include +#include +#include +#include + + +BEGIN_NAMESPACE_QPOASES + +typedef struct { + Bounds *emptyBounds; + Bounds *auxiliaryBounds; + + real_t *ub_new_far; + real_t *lb_new_far; + + real_t *g_new; + real_t *lb_new; + real_t *ub_new; + + real_t *g_new2; + real_t *lb_new2; + real_t *ub_new2; + + real_t *Hx; + + real_t *_H; + + real_t *g_original; + real_t *lb_original; + real_t *ub_original; + + real_t *delta_xFR; + real_t *delta_xFX; + real_t *delta_yFX; + real_t *delta_g; + real_t *delta_lb; + real_t *delta_ub; + + real_t *gMod; + + real_t *num; + real_t *den; + + real_t *rhs; + real_t *r; +} QProblemB_ws; + +int QProblemB_ws_calculateMemorySize( unsigned int nV ); + +char *QProblemB_ws_assignMemory( unsigned int nV, QProblemB_ws **mem, void *raw_memory ); + +QProblemB_ws *QProblemB_ws_createMemory( unsigned int nV ); + + +/** + * \brief Implements the online active set strategy for box-constrained QPs. + * + * Class for setting up and solving quadratic programs with bounds (= box constraints) only. + * The main feature is the possibility to use the newly developed online active set strategy + * for parametric quadratic programming. + * + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + */ +typedef struct +{ + QProblemB_ws *ws; + Bounds *bounds; /**< Data structure for problem's bounds. */ + Flipper *flipper; /**< Struct for making a temporary copy of the matrix factorisations. */ + + DenseMatrix* H; /**< Hessian matrix pointer. */ + + Options options; /**< Struct containing all user-defined options for solving QPs. */ + TabularOutput tabularOutput; /**< Struct storing information for tabular output (printLevel == PL_TABULAR). */ + + real_t *g; /**< Gradient. */ + real_t *lb; /**< Lower bound vector (on variables). */ + real_t *ub; /**< Upper bound vector (on variables). */ + + real_t *R; /**< Cholesky factor of H (i.e. H = R^T*R). */ + + real_t *x; /**< Primal solution vector. */ + real_t *y; /**< Dual solution vector. */ + + real_t *delta_xFR_TMP; /**< Temporary for determineStepDirection */ + + real_t tau; /**< Last homotopy step length. */ + real_t regVal; /**< Holds the offset used to regularise Hessian matrix (zero by default). */ + + real_t ramp0; /**< Start value for Ramping Strategy. */ + real_t ramp1; /**< Final value for Ramping Strategy. */ + + QProblemStatus status; /**< Current status of the solution process. */ + HessianType hessianType; /**< Type of Hessian matrix. */ + + BooleanType haveCholesky; /**< Flag indicating whether Cholesky decomposition has already been setup. */ + BooleanType infeasible; /**< QP infeasible? */ + BooleanType unbounded; /**< QP unbounded? */ + + int rampOffset; /**< Offset index for Ramping. */ + unsigned int count; /**< Counts the number of hotstart function calls (internal usage only!). */ +} QProblemB; + +int QProblemB_calculateMemorySize( unsigned int nV ); + +char *QProblemB_assignMemory( unsigned int nV, QProblemB **mem, void *raw_memory ); + +QProblemB *QProblemB_createMemory( unsigned int nV ); + + +/** Constructor which takes the QP dimension and Hessian type + * information. If the Hessian is the zero (i.e. HST_ZERO) or the + * identity matrix (i.e. HST_IDENTITY), respectively, no memory + * is allocated for it and a NULL pointer can be passed for it + * to the init() functions. */ +void QProblemBCON( QProblemB* _THIS, + int _nV, /**< Number of variables. */ + HessianType _hessianType /**< Type of Hessian matrix. */ + ); + +void QProblemBCPY( QProblemB* FROM, + QProblemB* TO + ); + + +/** Clears all data structures of QProblemB except for QP data. + * \return SUCCESSFUL_RETURN \n + RET_RESET_FAILED */ +returnValue QProblemB_reset( QProblemB* _THIS ); + + +/** Initialises a simply bounded QP problem with given QP data and tries to solve it + * using at most nWSR iterations. + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblemB_initM( QProblemB* _THIS, + DenseMatrix *_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. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation (if pointer passed). */ + ); + +/** Initialises a simply bounded QP problem with given QP data and tries to solve it + * using at most nWSR iterations. + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblemB_init( QProblemB* _THIS, + real_t* const _H, /**< Hessian matrix. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + 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. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation (if pointer passed). */ + ); + +/** Initialises a simply bounded QP problem with given QP data to be read from files and solves it + * using at most nWSR iterations. + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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_UNABLE_TO_READ_FILE */ +returnValue QProblemB_initF( QProblemB* _THIS, + const char* const H_file, /**< Name of file where Hessian matrix is stored. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + const char* const g_file, /**< Name of file where gradient vector is stored. */ + const char* const lb_file, /**< Name of file where lower bound vector. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bound vector. \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. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation (if pointer passed). */ + ); + +/** Initialises a simply bounded QP problem with given QP data and tries to solve it + * using at most nWSR iterations. Depending on the parameter constellation it: \n + * 1. 0, 0, 0 : starts with xOpt = 0, yOpt = 0 and gB empty (or all implicit equality bounds), \n + * 2. xOpt, 0, 0 : starts with xOpt, yOpt = 0 and obtain gB by "clipping", \n + * 3. 0, yOpt, 0 : starts with xOpt = 0, yOpt and obtain gB from yOpt != 0, \n + * 4. 0, 0, gB: starts with xOpt = 0, yOpt = 0 and gB, \n + * 5. xOpt, yOpt, 0 : starts with xOpt, yOpt and obtain gB from yOpt != 0, \n + * 6. xOpt, 0, gB: starts with xOpt, yOpt = 0 and gB, \n + * 7. xOpt, yOpt, gB: starts with xOpt, yOpt and gB (assume them to be consistent!) + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblemB_initMW( QProblemB* _THIS, + DenseMatrix *_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. */ + real_t* const cputime, /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation. */ + const real_t* const xOpt, /**< Optimal primal solution vector. A NULL pointer can be passed. \n + (If a null pointer is passed, the old primal solution is kept!) */ + const real_t* const yOpt, /**< Optimal dual solution vector. A NULL pointer can be passed. \n + (If a null pointer is passed, the old dual solution is kept!) */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). \n + (If a null pointer is passed, all bounds are assumed inactive!) */ + const real_t* const _R /**< Pre-computed (upper triangular) Cholesky factor of Hessian matrix. + The Cholesky factor must be stored in a real_t array of size nV*nV + in row-major format. Note: Only used if xOpt/yOpt and gB are NULL! \n + (If a null pointer is passed, Cholesky decomposition is computed internally!) */ + ); + +/** Initialises a simply bounded QP problem with given QP data and tries to solve it + * using at most nWSR iterations. Depending on the parameter constellation it: \n + * 1. 0, 0, 0 : starts with xOpt = 0, yOpt = 0 and gB empty (or all implicit equality bounds), \n + * 2. xOpt, 0, 0 : starts with xOpt, yOpt = 0 and obtain gB by "clipping", \n + * 3. 0, yOpt, 0 : starts with xOpt = 0, yOpt and obtain gB from yOpt != 0, \n + * 4. 0, 0, gB: starts with xOpt = 0, yOpt = 0 and gB, \n + * 5. xOpt, yOpt, 0 : starts with xOpt, yOpt and obtain gB from yOpt != 0, \n + * 6. xOpt, 0, gB: starts with xOpt, yOpt = 0 and gB, \n + * 7. xOpt, yOpt, gB: starts with xOpt, yOpt and gB (assume them to be consistent!) + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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 */ +returnValue QProblemB_initW( QProblemB* _THIS, + real_t* const _H, /**< Hessian matrix. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + 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. */ + real_t* const cputime, /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation. */ + const real_t* const xOpt, /**< Optimal primal solution vector. A NULL pointer can be passed. \n + (If a null pointer is passed, the old primal solution is kept!) */ + const real_t* const yOpt, /**< Optimal dual solution vector. A NULL pointer can be passed. \n + (If a null pointer is passed, the old dual solution is kept!) */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). \n + (If a null pointer is passed, all bounds are assumed inactive!) */ + const real_t* const _R /**< Pre-computed (upper triangular) Cholesky factor of Hessian matrix. + The Cholesky factor must be stored in a real_t array of size nV*nV + in row-major format. Note: Only used if xOpt/yOpt and gB are NULL! \n + (If a null pointer is passed, Cholesky decomposition is computed internally!) */ + ); + +/** Initialises a simply bounded QP problem with given QP data to be read from files and solves it + * using at most nWSR iterations. Depending on the parameter constellation it: \n + * 1. 0, 0, 0 : starts with xOpt = 0, yOpt = 0 and gB empty (or all implicit equality bounds), \n + * 2. xOpt, 0, 0 : starts with xOpt, yOpt = 0 and obtain gB by "clipping", \n + * 3. 0, yOpt, 0 : starts with xOpt = 0, yOpt and obtain gB from yOpt != 0, \n + * 4. 0, 0, gB: starts with xOpt = 0, yOpt = 0 and gB, \n + * 5. xOpt, yOpt, 0 : starts with xOpt, yOpt and obtain gB from yOpt != 0, \n + * 6. xOpt, 0, gB: starts with xOpt, yOpt = 0 and gB, \n + * 7. xOpt, yOpt, gB: starts with xOpt, yOpt and gB (assume them to be consistent!) + * + * Note: This function internally calls solveInitialQP for initialisation! + * + * \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_UNABLE_TO_READ_FILE */ +returnValue QProblemB_initFW( QProblemB* _THIS, + const char* const H_file, /**< Name of file where Hessian matrix is stored. \n + If Hessian matrix is trivial, a NULL pointer can be passed. */ + const char* const g_file, /**< Name of file where gradient vector is stored. */ + const char* const lb_file, /**< Name of file where lower bound vector. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bound vector. \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. */ + real_t* const cputime, /**< Input: Maximum CPU time allowed for QP initialisation. \n + Output: CPU time spent for QP initialisation. */ + const real_t* const xOpt, /**< Optimal primal solution vector. A NULL pointer can be passed. \n + (If a null pointer is passed, the old primal solution is kept!) */ + const real_t* const yOpt, /**< Optimal dual solution vector. A NULL pointer can be passed. \n + (If a null pointer is passed, the old dual solution is kept!) */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). \n + (If a null pointer is passed, all bounds are assumed inactive!) */ + const char* const R_file /**< Name of the file where a pre-computed (upper triangular) Cholesky factor + of the Hessian matrix is stored. \n + (If a null pointer is passed, Cholesky decomposition is computed internally!) */ + ); + + +/** Solves an initialised QP sequence using the online active set strategy. + * By default, QP solution is started from previous solution. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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 */ +returnValue QProblemB_hotstart( QProblemB* _THIS, + 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 /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + ); + +/** Solves an initialised QP sequence using the online active set strategy, + * where QP data is read from files. QP solution is started from previous solution. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS */ +returnValue QProblemB_hotstartF( QProblemB* _THIS, + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \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 /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + ); + +/** Solves an initialised QP sequence using the online active set strategy. + * By default, QP solution is started from previous solution. If a guess + * for the working set is provided, an initialised homotopy is performed. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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_SETUP_AUXILIARYQP_FAILED */ +returnValue QProblemB_hotstartW( QProblemB* _THIS, + 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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + Bounds* const guessedBounds /**< Optimal working set of bounds for solution (xOpt,yOpt). \n + (If a null pointer is passed, the previous working set is kept!) */ + ); + +/** Solves an initialised QP sequence using the online active set strategy, + * where QP data is read from files. + * By default, QP solution is started from previous solution. If a guess + * for the working set is provided, an initialised homotopy is performed. + * + * Note: This function internally calls solveQP/solveRegularisedQP + * for solving an initialised QP! + * + * \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_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS \n + RET_SETUP_AUXILIARYQP_FAILED */ +returnValue QProblemB_hotstartFW( QProblemB* _THIS, + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + Bounds* const guessedBounds /**< Optimal working set of bounds for solution (xOpt,yOpt). \n + (If a null pointer is passed, the previous working set is kept!) */ + ); + + +/** Writes a vector with the state of the working set + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +returnValue QProblemB_getWorkingSet( QProblemB* _THIS, + real_t* workingSet /** Output: array containing state of the working set. */ + ); + +/** Writes a vector with the state of the working set of bounds + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +returnValue QProblemB_getWorkingSetBounds( QProblemB* _THIS, + real_t* workingSetB /** Output: array containing state of the working set of bounds. */ + ); + +/** Writes a vector with the state of the working set of constraints + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +returnValue QProblemB_getWorkingSetConstraints( QProblemB* _THIS, + real_t* workingSetC /** Output: array containing state of the working set of constraints. */ + ); + + +/** Returns current bounds object of the QP (deep copy). + * \return SUCCESSFUL_RETURN \n + RET_QPOBJECT_NOT_SETUP */ +static inline returnValue QProblemB_getBounds( QProblemB* _THIS, + Bounds* _bounds /** Output: Bounds object. */ + ); + + +/** Returns the number of variables. + * \return Number of variables. */ +static inline int QProblemB_getNV( QProblemB* _THIS ); + +/** Returns the number of free variables. + * \return Number of free variables. */ +static inline int QProblemB_getNFR( QProblemB* _THIS ); + +/** Returns the number of fixed variables. + * \return Number of fixed variables. */ +static inline int QProblemB_getNFX( QProblemB* _THIS ); + +/** Returns the number of implicitly fixed variables. + * \return Number of implicitly fixed variables. */ +static inline int QProblemB_getNFV( QProblemB* _THIS ); + +/** Returns the dimension of null space. + * \return Dimension of null space. */ +int QProblemB_getNZ( QProblemB* _THIS ); + + +/** 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 QProblemB_getObjVal( QProblemB* _THIS ); + +/** Returns the objective function value at an arbitrary point x. + * \return Objective function value at point x */ +real_t QProblemB_getObjValX( QProblemB* _THIS, + const real_t* const _x /**< Point at which the objective function shall be evaluated. */ + ); + +/** Returns the primal solution vector. + * \return SUCCESSFUL_RETURN \n + RET_QP_NOT_SOLVED */ +returnValue QProblemB_getPrimalSolution( QProblemB* _THIS, + real_t* const xOpt /**< Output: Primal solution vector (if QP has been solved). */ + ); + +/** Returns the dual solution vector. + * \return SUCCESSFUL_RETURN \n + RET_QP_NOT_SOLVED */ +returnValue QProblemB_getDualSolution( QProblemB* _THIS, + real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ + ); + + +/** Returns status of the solution process. + * \return Status of solution process. */ +static inline QProblemStatus QProblemB_getStatus( QProblemB* _THIS ); + + +/** Returns if the QProblem object is initialised. + * \return BT_TRUE: QProblemB initialised \n + BT_FALSE: QProblemB not initialised */ +static inline BooleanType QProblemB_isInitialised( QProblemB* _THIS ); + +/** Returns if the QP has been solved. + * \return BT_TRUE: QProblemB solved \n + BT_FALSE: QProblemB not solved */ +static inline BooleanType QProblemB_isSolved( QProblemB* _THIS ); + +/** Returns if the QP is infeasible. + * \return BT_TRUE: QP infeasible \n + BT_FALSE: QP feasible (or not known to be infeasible!) */ +static inline BooleanType QProblemB_isInfeasible( QProblemB* _THIS ); + +/** Returns if the QP is unbounded. + * \return BT_TRUE: QP unbounded \n + BT_FALSE: QP unbounded (or not known to be unbounded!) */ +static inline BooleanType QProblemB_isUnbounded( QProblemB* _THIS ); + + +/** Returns Hessian type flag (type is not determined due to _THIS call!). + * \return Hessian type. */ +static inline HessianType QProblemB_getHessianType( QProblemB* _THIS ); + +/** Changes the print level. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblemB_setHessianType( QProblemB* _THIS, + HessianType _hessianType /**< New Hessian type. */ + ); + +/** Returns if the QP has been internally regularised. + * \return BT_TRUE: Hessian is internally regularised for QP solution \n + BT_FALSE: No internal Hessian regularisation is used for QP solution */ +static inline BooleanType QProblemB_usingRegularisation( QProblemB* _THIS ); + +/** Returns current options struct. + * \return Current options struct. */ +static inline Options QProblemB_getOptions( QProblemB* _THIS ); + +/** Overrides current options with given ones. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblemB_setOptions( QProblemB* _THIS, + Options _options /**< New options. */ + ); + +/** Returns the print level. + * \return Print level. */ +static inline PrintLevel QProblemB_getPrintLevel( QProblemB* _THIS ); + +/** Changes the print level. + * \return SUCCESSFUL_RETURN */ +returnValue QProblemB_setPrintLevel( QProblemB* _THIS, + PrintLevel _printlevel /**< New print level. */ + ); + +/** Returns the current number of QP problems solved. + * \return Number of QP problems solved. */ +static inline unsigned int QProblemB_getCount( QProblemB* _THIS ); + +/** Resets QP problem counter (to zero). + * \return SUCCESSFUL_RETURN. */ +static inline returnValue QProblemB_resetCounter( QProblemB* _THIS ); + + +/** Prints concise list of properties of the current QP. + * \return SUCCESSFUL_RETURN \n */ +returnValue QProblemB_printProperties( QProblemB* _THIS ); + +/** Prints a list of all options and their current values. + * \return SUCCESSFUL_RETURN \n */ +returnValue QProblemB_printOptions( QProblemB* _THIS ); + + +/** If Hessian type has been set by the user, nothing is done. + * Otherwise the Hessian type is set to HST_IDENTITY, HST_ZERO, or + * HST_POSDEF (default), respectively. + * \return SUCCESSFUL_RETURN \n + RET_HESSIAN_INDEFINITE */ +returnValue QProblemB_determineHessianType( QProblemB* _THIS ); + +/** Determines type of existing constraints and bounds (i.e. implicitly fixed, unbounded etc.). + * \return SUCCESSFUL_RETURN \n + RET_SETUPSUBJECTTOTYPE_FAILED */ +returnValue QProblemB_setupSubjectToType( QProblemB* _THIS ); + +/** Determines type of new constraints and bounds (i.e. implicitly fixed, unbounded etc.). + * \return SUCCESSFUL_RETURN \n + RET_SETUPSUBJECTTOTYPE_FAILED */ +returnValue QProblemB_setupSubjectToTypeNew( QProblemB* _THIS, + const real_t* const lb_new, /**< New lower bounds. */ + const real_t* const ub_new /**< New upper bounds. */ + ); + +/** Computes the Cholesky decomposition 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! + * Note: If Hessian turns out not to be positive definite, the Hessian type + * is set to HST_SEMIDEF accordingly. + * \return SUCCESSFUL_RETURN \n + * RET_HESSIAN_NOT_SPD \n + * RET_INDEXLIST_CORRUPTED */ +returnValue QProblemB_computeCholesky( QProblemB* _THIS ); + +/** Computes initial Cholesky decomposition of the projected Hessian making + * use of the function setupCholeskyDecomposition() or setupCholeskyDecompositionProjected(). + * \return SUCCESSFUL_RETURN \n + * RET_HESSIAN_NOT_SPD \n + * RET_INDEXLIST_CORRUPTED */ +returnValue QProblemB_setupInitialCholesky( QProblemB* _THIS ); + + +/** 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 QProblemB_obtainAuxiliaryWorkingSet( QProblemB* _THIS, + 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. */ + Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). */ + Bounds* auxiliaryBounds /**< Input: Allocated bound object. \n + * Ouput: Working set for auxiliary QP. */ + ); + +/** Decides if lower bounds are smaller than upper bounds + * + * \return SUCCESSFUL_RETURN \n + * RET_QP_INFEASIBLE */ +returnValue QProblemB_areBoundsConsistent( QProblemB* _THIS, + const real_t* const lb, /**< Vector of lower bounds*/ + const real_t* const ub /**< Vector of upper bounds*/ + ); + +/** 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 QProblemB_backsolveR( QProblemB* _THIS, + 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 QProblemB_backsolveRrem( QProblemB* _THIS, + 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 QProblemB_determineDataShift( QProblemB* _THIS, + 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. */ + ); + + +/** Sets up internal QP data. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS */ +returnValue QProblemB_setupQPdataM( QProblemB* _THIS, + DenseMatrix *_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. */ + ); + +/** Sets up internal QP data. If the current Hessian is trivial + * (i.e. HST_ZERO or HST_IDENTITY) but a non-trivial one is given, + * memory for Hessian is allocated and it is set to the given one. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS \n + RET_NO_HESSIAN_SPECIFIED */ +returnValue QProblemB_setupQPdata( QProblemB* _THIS, + real_t* const _H, /**< Hessian matrix. \n + If Hessian matrix is trivial,a NULL pointer can be passed. */ + 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 up internal QP data by loading it from files. If the current Hessian + * is trivial (i.e. HST_ZERO or HST_IDENTITY) but a non-trivial one is given, + * memory for Hessian is allocated and it is set to the given one. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS \n + RET_NO_HESSIAN_SPECIFIED */ +returnValue QProblemB_setupQPdataFromFile( QProblemB* _THIS, + const char* const H_file, /**< Name of file where Hessian matrix, of neighbouring QP to be solved, is stored. \n + If Hessian matrix is trivial,a NULL pointer can be passed. */ + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + ); + +/** Loads new QP vectors from files (internal members are not affected!). + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE \n + RET_INVALID_ARGUMENTS */ +returnValue QProblemB_loadQPvectorsFromFile( QProblemB* _THIS, + const char* const g_file, /**< Name of file where gradient, of neighbouring QP to be solved, is stored. */ + const char* const lb_file, /**< Name of file where lower bounds, of neighbouring QP to be solved, is stored. \n + If no lower bounds exist, a NULL pointer can be passed. */ + const char* const ub_file, /**< Name of file where upper bounds, of neighbouring QP to be solved, is stored. \n + If no upper bounds exist, a NULL pointer can be passed. */ + real_t* const g_new, /**< Output: Gradient of neighbouring QP to be solved. */ + real_t* const lb_new, /**< Output: Lower bounds of neighbouring QP to be solved */ + real_t* const ub_new /**< Output: Upper bounds of neighbouring QP to be solved */ + ); + + +/** Sets internal infeasibility flag and throws given error in case the far bound + * strategy is not enabled (as QP might actually not be infeasible in _THIS case). + * \return RET_HOTSTART_STOPPED_INFEASIBILITY \n + RET_ENSURELI_FAILED_CYCLING \n + RET_ENSURELI_FAILED_NOINDEX */ +returnValue QProblemB_setInfeasibilityFlag( QProblemB* _THIS, + returnValue returnvalue, /**< Returnvalue to be tunneled. */ + BooleanType doThrowError /**< Flag forcing to throw an error. */ + ); + + +/** Determines if next QP iteration can be performed within given CPU time limit. + * \return BT_TRUE: CPU time limit is exceeded, stop QP solution. \n + BT_FALSE: Sufficient CPU time for next QP iteration. */ +BooleanType QProblemB_isCPUtimeLimitExceeded( QProblemB* _THIS, + const real_t* const cputime, /**< Maximum CPU time allowed for QP solution. */ + real_t starttime, /**< Start time of current QP solution. */ + int nWSR /**< Number of working set recalculations performed so far. */ + ); + + +/** Regularise Hessian matrix by adding a scaled identity matrix to it. + * \return SUCCESSFUL_RETURN \n + RET_HESSIAN_ALREADY_REGULARISED */ +returnValue QProblemB_regulariseHessian( QProblemB* _THIS ); + + +/** Sets Hessian matrix of the QP. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblemB_setHM( QProblemB* _THIS, + DenseMatrix* H_new /**< New Hessian matrix. */ + ); + +/** Sets dense Hessian matrix of the QP. + * If a null pointer is passed and + * a) hessianType is HST_IDENTITY, nothing is done, + * b) hessianType is not HST_IDENTITY, Hessian matrix is set to zero. + * \return SUCCESSFUL_RETURN */ +static inline returnValue QProblemB_setH( QProblemB* _THIS, + real_t* const H_new /**< New dense Hessian matrix (with correct dimension!). */ + ); + +/** Changes gradient vector of the QP. + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +static inline returnValue QProblemB_setG( QProblemB* _THIS, + const real_t* const g_new /**< New gradient vector (with correct dimension!). */ + ); + +/** Changes lower bound vector of the QP. + * \return SUCCESSFUL_RETURN \n + * RET_QPOBJECT_NOT_SETUP */ +static inline returnValue QProblemB_setLB( QProblemB* _THIS, + 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_QPOBJECT_NOT_SETUP \n + * RET_INDEX_OUT_OF_BOUNDS */ +static inline returnValue QProblemB_setLBn( QProblemB* _THIS, + 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 \n + * RET_QPOBJECT_NOT_SETUP */ +static inline returnValue QProblemB_setUB( QProblemB* _THIS, + 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_QPOBJECT_NOT_SETUP \n + * RET_INDEX_OUT_OF_BOUNDS */ +static inline returnValue QProblemB_setUBn( QProblemB* _THIS, + 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 */ +static inline void QProblemB_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. */ + ); + +/** Applies Givens matrix determined by c and s (cf. computeGivens). + * \return SUCCESSFUL_RETURN */ +static inline void QProblemB_applyGivens( real_t c, /**< Cosine entry of Givens matrix. */ + real_t s, /**< Sine entry of Givens matrix. */ + real_t nu, /**< Further factor: s/(1+c). */ + 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. */ + ); + + + +/** Compute relative length of homotopy in data space for termination + * criterion. + * \return Relative length in data space. */ +real_t QProblemB_getRelativeHomotopyLength( QProblemB* _THIS, + const real_t* const g_new, /**< Final gradient. */ + const real_t* const lb_new, /**< Final lower variable bounds. */ + const real_t* const ub_new /**< Final upper variable bounds. */ + ); + +/** Ramping Strategy to avoid ties. Modifies homotopy start without + * changing current active set. + * \return SUCCESSFUL_RETURN */ +returnValue QProblemB_performRamping( QProblemB* _THIS ); + + +/** ... */ +returnValue QProblemB_updateFarBounds( QProblemB* _THIS, + real_t curFarBound, /**< ... */ + int nRamp, /**< ... */ + const real_t* const lb_new, /**< ... */ + real_t* const lb_new_far, /**< ... */ + const real_t* const ub_new, /**< ... */ + real_t* const ub_new_far /**< ... */ + ); + + + +/** Performs robustified ratio test yield the maximum possible step length + * along the homotopy path. + * \return SUCCESSFUL_RETURN */ +returnValue QProblemB_performRatioTestB( QProblemB* _THIS, + int nIdx, /**< Number of ratios to be checked. */ + const int* const idxList, /**< Array containing the indices of all ratios to be checked. */ + Bounds* const subjectTo, /**< Bound object corresponding to ratios to be checked. */ + const real_t* const num, /**< Array containing all numerators for performing the ratio test. */ + const real_t* const den, /**< Array containing all denominators for performing the ratio test. */ + real_t epsNum, /**< Numerator tolerance. */ + real_t epsDen, /**< Denominator tolerance. */ + real_t* t, /**< Output: Maximum possible step length along the homotopy path. */ + int* BC_idx /**< Output: Index of blocking constraint. */ + ); + +/** Checks whether given ratio is blocking, i.e. limits the maximum step length + * along the homotopy path to a value lower than given one. + * \return SUCCESSFUL_RETURN */ +static inline BooleanType QProblemB_isBlocking( QProblemB* _THIS, + real_t num, /**< Numerator for performing the ratio test. */ + real_t den, /**< Denominator for performing the ratio test. */ + real_t epsNum, /**< Numerator tolerance. */ + real_t epsDen, /**< Denominator tolerance. */ + real_t* t /**< Input: Current maximum step length along the homotopy path, + * Output: Updated maximum possible step length along the homotopy path. */ + ); + + +/** 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. + * Note: This function is internally called by all init functions! + * \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 QProblemB_solveInitialQP( QProblemB* _THIS, + const real_t* const xOpt, /**< Optimal primal solution vector.*/ + const real_t* const yOpt, /**< Optimal dual solution vector. */ + Bounds* const guessedBounds, /**< Optimal working set of bounds for solution (xOpt,yOpt). */ + const real_t* const _R, /**< Pre-computed (upper triangular) Cholesky factor of Hessian matrix. */ + int* nWSR, /**< Input: Maximum number of working set recalculations; \n + * Output: Number of performed working set recalculations. */ + real_t* const cputime /**< Input: Maximum CPU time allowed for QP solution. \n + * Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + ); + +/** Solves an initialised QProblemB using online active set strategy. + * Note: This function is internally called by all hotstart functions! + * \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 */ +returnValue QProblemB_solveQP( QProblemB* _THIS, + 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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + int nWSRperformed, /**< Number of working set recalculations already performed to solve + this QP within previous solveQP() calls. This number is + always zero, except for successive calls from solveRegularisedQP() + or when using the far bound strategy. */ + BooleanType isFirstCall /**< Indicating whether this is the first call for current QP. */ + ); + + +/** Solves an initialised QProblemB using online active set strategy. + * Note: This function is internally called by all hotstart functions! + * \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 */ +returnValue QProblemB_solveRegularisedQP( QProblemB* _THIS, + 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, /**< Input: Maximum CPU time allowed for QP solution. \n + Output: CPU time spent for QP solution (or to perform nWSR iterations). */ + int nWSRperformed, /**< Number of working set recalculations already performed to solve + this QP within previous solveRegularisedQP() calls. This number is + always zero, except for successive calls when using the far bound strategy. */ + BooleanType isFirstCall /**< Indicating whether this is the first call for current QP. */ + ); + + +/** Sets up 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 QProblemB_setupAuxiliaryWorkingSet( QProblemB* _THIS, + 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. */ + ); + +/** Sets up the optimal primal/dual solution of the auxiliary initial QP. + * \return SUCCESSFUL_RETURN */ +returnValue QProblemB_setupAuxiliaryQPsolution( QProblemB* _THIS, + 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. */ + ); + +/** Sets up 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 (ialised!). + * \return SUCCESSFUL_RETURN */ +returnValue QProblemB_setupAuxiliaryQPgradient( QProblemB* _THIS ); + +/** Sets up 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 QProblemB_setupAuxiliaryQPbounds( QProblemB* _THIS, + BooleanType useRelaxation /**< Flag indicating if inactive bounds shall be relaxed. */ + ); + + +/** Updates QP vectors, working sets and internal data structures in order to + start from an optimal solution corresponding to initial guesses of the working + set for bounds + * \return SUCCESSFUL_RETURN \n + * RET_SETUP_AUXILIARYQP_FAILED */ +returnValue QProblemB_setupAuxiliaryQP( QProblemB* _THIS, + Bounds* const guessedBounds /**< Initial guess for working set of bounds. */ + ); + +/** Determines step direction of the homotopy path. + * \return SUCCESSFUL_RETURN \n + RET_STEPDIRECTION_FAILED_CHOLESKY */ +returnValue QProblemB_determineStepDirection( QProblemB* _THIS, + 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 + * and performs _THIS step (without changing working set). + * \return SUCCESSFUL_RETURN \n + * RET_QP_INFEASIBLE \n + */ +returnValue QProblemB_performStep( QProblemB* _THIS, + const real_t* const delta_g, /**< Step direction of gradient. */ + 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, /**< Output: Index of blocking constraint. */ + SubjectToStatus* BC_status /**< Output: Status of blocking constraint. */ + ); + +/** Updates active set. + * \return SUCCESSFUL_RETURN \n + RET_REMOVE_FROM_ACTIVESET_FAILED \n + RET_ADD_TO_ACTIVESET_FAILED */ +returnValue QProblemB_changeActiveSet( QProblemB* _THIS, + int BC_idx, /**< Index of blocking constraint. */ + SubjectToStatus BC_status /**< Status of blocking constraint. */ + ); + +/** Drift correction at end of each active set iteration + * \return SUCCESSFUL_RETURN */ +returnValue QProblemB_performDriftCorrection( QProblemB* _THIS ); + +/** Determines if it is more efficient to refactorise the matrices when + * hotstarting or not (i.e. better to update the existing factorisations). + * \return BT_TRUE iff matrices shall be refactorised afresh + */ +BooleanType QProblemB_shallRefactorise( QProblemB* _THIS, + Bounds* const guessedBounds /**< Guessed new working set. */ + ); + + +/** Adds a bound to active set (specialised version for the case where no constraints exist). + * \return SUCCESSFUL_RETURN \n + RET_ADDBOUND_FAILED */ +returnValue QProblemB_addBound( QProblemB* _THIS, + 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 QProblemB_removeBound( QProblemB* _THIS, + int number, /**< Number of bound to be removed from active set. */ + BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ + ); + + +/** Prints concise information on the current iteration. + * \return SUCCESSFUL_RETURN \n */ +returnValue QProblemB_printIteration( QProblemB* _THIS, + int iter, /**< Number of current iteration. */ + int BC_idx, /**< Index of blocking bound. */ + SubjectToStatus BC_status, /**< Status of blocking bound. */ + real_t homotopyLength, /**< Current homotopy distance. */ + BooleanType isFirstCall /**< Indicating whether this is the first call for current QP. */ + ); + + + +/* + * g e t B o u n d s + */ +static inline returnValue QProblemB_getBounds( QProblemB* _THIS, Bounds* _bounds ) +{ + int nV = QProblemB_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + _bounds = _THIS->bounds; + + return SUCCESSFUL_RETURN; +} + + +/* + * g e t N V + */ +static inline int QProblemB_getNV( QProblemB* _THIS ) +{ + return Bounds_getNV( _THIS->bounds ); +} + + +/* + * g e t N F R + */ +static inline int QProblemB_getNFR( QProblemB* _THIS ) +{ + return Bounds_getNFR( _THIS->bounds ); +} + + +/* + * g e t N F X + */ +static inline int QProblemB_getNFX( QProblemB* _THIS ) +{ + return Bounds_getNFX( _THIS->bounds ); +} + + +/* + * g e t N F V + */ +static inline int QProblemB_getNFV( QProblemB* _THIS ) +{ + return Bounds_getNFV( _THIS->bounds ); +} + + +/* + * g e t S t a t u s + */ +static inline QProblemStatus QProblemB_getStatus( QProblemB* _THIS ) +{ + return _THIS->status; +} + + +/* + * i s I n i t i a l i s e d + */ +static inline BooleanType QProblemB_isInitialised( QProblemB* _THIS ) +{ + if ( _THIS->status == QPS_NOTINITIALISED ) + return BT_FALSE; + else + return BT_TRUE; +} + + +/* + * i s S o l v e d + */ +static inline BooleanType QProblemB_isSolved( QProblemB* _THIS ) +{ + if ( _THIS->status == QPS_SOLVED ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * i s I n f e a s i b l e + */ +static inline BooleanType QProblemB_isInfeasible( QProblemB* _THIS ) +{ + return _THIS->infeasible; +} + + +/* + * i s U n b o u n d e d + */ +static inline BooleanType QProblemB_isUnbounded( QProblemB* _THIS ) +{ + return _THIS->unbounded; +} + + +/* + * g e t H e s s i a n T y p e + */ +static inline HessianType QProblemB_getHessianType( QProblemB* _THIS ) +{ + return _THIS->hessianType; +} + + +/* + * s e t H e s s i a n T y p e + */ +static inline returnValue QProblemB_setHessianType( QProblemB* _THIS, HessianType _hessianType ) +{ + _THIS->hessianType = _hessianType; + return SUCCESSFUL_RETURN; +} + + +/* + * u s i n g R e g u l a r i s a t i o n + */ +static inline BooleanType QProblemB_usingRegularisation( QProblemB* _THIS ) +{ + if ( _THIS->regVal > QPOASES_ZERO ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * g e t O p t i o n s + */ +static inline Options QProblemB_getOptions( QProblemB* _THIS ) +{ + return _THIS->options; +} + + +/* + * s e t O p t i o n s + */ +static inline returnValue QProblemB_setOptions( QProblemB* _THIS, + Options _options + ) +{ + OptionsCPY( &_options,&(_THIS->options) ); + Options_ensureConsistency( &(_THIS->options) ); + + QProblemB_setPrintLevel( _THIS,_THIS->options.printLevel ); + + return SUCCESSFUL_RETURN; +} + + +/* + * g e t P r i n t L e v e l + */ +static inline PrintLevel QProblemB_getPrintLevel( QProblemB* _THIS ) +{ + return _THIS->options.printLevel; +} + + + +/* + * g e t C o u n t + */ +static inline unsigned int QProblemB_getCount( QProblemB* _THIS ) +{ + return _THIS->count; +} + + +/* + * r e s e t C o u n t e r + */ +static inline returnValue QProblemB_resetCounter( QProblemB* _THIS ) +{ + _THIS->count = 0; + return SUCCESSFUL_RETURN; +} + + + +/***************************************************************************** + * P R O T E C T E D * + *****************************************************************************/ + + +/* + * s e t H + */ +static inline returnValue QProblemB_setHM( QProblemB* _THIS, DenseMatrix* H_new ) +{ + if ( H_new == 0 ) + return QProblemB_setH( _THIS,(real_t*)0 ); + else + return QProblemB_setH( _THIS,DenseMatrix_getVal(H_new) ); +} + + +/* + * s e t H + */ +static inline returnValue QProblemB_setH( QProblemB* _THIS, real_t* const H_new ) +{ + /* if null pointer is passed, Hessian is set to zero matrix + * (or stays identity matrix) */ + if ( H_new == 0 ) + { + if ( _THIS->hessianType == HST_IDENTITY ) + return SUCCESSFUL_RETURN; + + _THIS->hessianType = HST_ZERO; + + _THIS->H = 0; + } + else + { + DenseMatrixCON( _THIS->H,QProblemB_getNV( _THIS ),QProblemB_getNV( _THIS ),QProblemB_getNV( _THIS ),H_new ); + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t G + */ +static inline returnValue QProblemB_setG( QProblemB* _THIS, const real_t* const g_new ) +{ + unsigned int nV = (unsigned int)QProblemB_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( g_new == 0 ) + return THROWERROR( RET_INVALID_ARGUMENTS ); + + memcpy( _THIS->g,g_new,nV*sizeof(real_t) ); + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t L B + */ +static inline returnValue QProblemB_setLB( QProblemB* _THIS, const real_t* const lb_new ) +{ + unsigned int i; + unsigned int nV = (unsigned int)QProblemB_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( lb_new != 0 ) + { + memcpy( _THIS->lb,lb_new,nV*sizeof(real_t) ); + } + else + { + /* if no lower bounds are specified, set them to -infinity */ + for( i=0; ilb[i] = -QPOASES_INFTY; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t L B + */ +static inline returnValue QProblemB_setLBn( QProblemB* _THIS, int number, real_t value ) +{ + int nV = QProblemB_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ( number >= 0 ) && ( number < nV ) ) + { + _THIS->lb[number] = value; + return SUCCESSFUL_RETURN; + } + else + { + return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); + } +} + + +/* + * s e t U B + */ +static inline returnValue QProblemB_setUB( QProblemB* _THIS, const real_t* const ub_new ) +{ + unsigned int i; + unsigned int nV = (unsigned int)QProblemB_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ub_new != 0 ) + { + memcpy( _THIS->ub,ub_new,nV*sizeof(real_t) ); + } + else + { + /* if no upper bounds are specified, set them to infinity */ + for( i=0; iub[i] = QPOASES_INFTY; + } + + return SUCCESSFUL_RETURN; +} + + +/* + * s e t U B + */ +static inline returnValue QProblemB_setUBn( QProblemB* _THIS, int number, real_t value ) +{ + int nV = QProblemB_getNV( _THIS ); + + if ( nV == 0 ) + return THROWERROR( RET_QPOBJECT_NOT_SETUP ); + + if ( ( number >= 0 ) && ( number < nV ) ) + { + _THIS->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 + */ +static inline void QProblemB_computeGivens( real_t xold, real_t yold, + real_t* xnew, real_t* ynew, real_t* c, real_t* s + ) +{ + real_t t, mu; + + if ( fabs( yold ) <= QPOASES_ZERO ) + { + *c = 1.0; + *s = 0.0; + + *xnew = xold; + *ynew = yold; + } + else + { + mu = fabs( xold ); + if ( fabs( yold ) > mu ) + mu = fabs( 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 + */ +static inline void QProblemB_applyGivens( real_t c, real_t s, real_t nu, real_t xold, real_t yold, + real_t* xnew, real_t* ynew + ) +{ + #ifdef __USE_THREE_MULTS_GIVENS__ + + /* Givens plane rotation requiring only three multiplications, + * cf. Hammarling, S.: A note on modifications to the givens plane rotation. + * J. Inst. Maths Applics, 13:215-218, 1974. */ + *xnew = xold*c + yold*s; + *ynew = (*xnew+xold)*nu - yold; + + #else + + /* Usual Givens plane rotation requiring four multiplications. */ + *xnew = c*xold + s*yold; + *ynew = -s*xold + c*yold; + + #endif + + return; +} + + +/* + * i s B l o c k i n g + */ +static inline BooleanType QProblemB_isBlocking( QProblemB* _THIS, + real_t num, + real_t den, + real_t epsNum, + real_t epsDen, + real_t* t + ) +{ + if ( ( den >= epsDen ) && ( num >= epsNum ) ) + { + if ( num < (*t)*den ) + return BT_TRUE; + } + + return BT_FALSE; +} + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_QPROBLEMB_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/Types.h b/third_party/acados/include/qpOASES_e/Types.h new file mode 100644 index 00000000000000..1e452097f8536d --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Types.h @@ -0,0 +1,310 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Types.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of all non-built-in types (except for classes). + */ + + +#ifndef QPOASES_TYPES_H +#define QPOASES_TYPES_H + +#ifdef USE_ACADOS_TYPES +#include "acados/utils/types.h" +#endif + +/* If your compiler does not support the snprintf() function, + * uncomment the following line and try to compile again. */ +/* #define __NO_SNPRINTF__ */ + + +/* Uncomment the following line for setting the __DSPACE__ flag. */ +/* #define __DSPACE__ */ + +/* Uncomment the following line for setting the __XPCTARGET__ flag. */ +/* #define __XPCTARGET__ */ + + +/* Uncomment the following line for setting the __NO_FMATH__ flag. */ +/* #define __NO_FMATH__ */ + +/* Uncomment the following line to enable debug information. */ +/* #define __DEBUG__ */ + +/* Uncomment the following line to enable suppress any kind of console output. */ +/* #define __SUPPRESSANYOUTPUT__ */ + + +/** Forces to always include all implicitly fixed bounds and all equality constraints + * into the initial working set when setting up an auxiliary QP. */ +#define __ALWAYS_INITIALISE_WITH_ALL_EQUALITIES__ + +/* Uncomment the following line to activate the use of an alternative Givens + * plane rotation requiring only three multiplications. */ +/* #define __USE_THREE_MULTS_GIVENS__ */ + +/* Uncomment the following line to activate the use of single precision arithmetic. */ +/* #define __USE_SINGLE_PRECISION__ */ + +/* The inline keyword is skipped by default as it is not part of the C90 standard. + * However, by uncommenting the following line, use of the inline keyword can be enforced. */ +/* #define __USE_INLINE__ */ + + +/* Work-around for Borland BCC 5.5 compiler. */ +#ifdef __BORLANDC__ +#if __BORLANDC__ < 0x0561 + #define __STDC__ 1 +#endif +#endif + + +/* Work-around for Microsoft compilers. */ +#ifdef _MSC_VER + #define __NO_SNPRINTF__ + #pragma warning( disable : 4061 4100 4250 4514 4996 ) +#endif + + +/* Apply pre-processor settings when using qpOASES within auto-generated code. */ +#ifdef __CODE_GENERATION__ + #define __NO_COPYRIGHT__ + #define __EXTERNAL_DIMENSIONS__ +#endif /* __CODE_GENERATION__ */ + + +/* Avoid using static variables declaration within functions. */ +#ifdef __NO_STATIC__ + #define myStatic +#else + #define myStatic static +#endif /* __NO_STATIC__ */ + + +/* Skip inline keyword if not specified otherwise. */ +#ifndef __USE_INLINE__ + #define inline +#endif + + +/* Avoid any printing on embedded platforms. */ +#if defined(__DSPACE__) || defined(__XPCTARGET__) + #define __SUPPRESSANYOUTPUT__ + #define __NO_SNPRINTF__ +#endif + + +#ifdef __NO_SNPRINTF__ + #if (!defined(_MSC_VER)) || defined(__DSPACE__) || defined(__XPCTARGET__) + /* If snprintf is not available, provide an empty implementation... */ + int snprintf( char* s, size_t n, const char* format, ... ); + #else + /* ... or substitute snprintf by _snprintf for Microsoft compilers. */ + #define snprintf _snprintf + #endif +#endif /* __NO_SNPRINTF__ */ + + +/** Macro for switching on/off the beginning of the qpOASES namespace definition. */ +#define BEGIN_NAMESPACE_QPOASES + +/** Macro for switching on/off the end of the qpOASES namespace definition. */ +#define END_NAMESPACE_QPOASES + +/** Macro for switching on/off the use of the qpOASES namespace. */ +#define USING_NAMESPACE_QPOASES + +/** Macro for switching on/off references to the qpOASES namespace. */ +#define REFER_NAMESPACE_QPOASES /*::*/ + + +/** Macro for accessing the Cholesky factor R. */ +#define RR( I,J ) _THIS->R[(I)+nV*(J)] + +/** Macro for accessing the orthonormal matrix Q of the QT factorisation. */ +#define QQ( I,J ) _THIS->Q[(I)+nV*(J)] + +/** Macro for accessing the triangular matrix T of the QT factorisation. */ +#define TT( I,J ) _THIS->T[(I)*nVC_min+(J)] + + + +BEGIN_NAMESPACE_QPOASES + + +/** Defines real_t for facilitating switching between double and float. */ + +#ifndef USE_ACADOS_TYPES +#ifndef __CODE_GENERATION__ + + #ifdef __USE_SINGLE_PRECISION__ + typedef float real_t; + #else + typedef double real_t; + #endif /* __USE_SINGLE_PRECISION__ */ + +#endif /* __CODE_GENERATION__ */ +#endif /* USE_ACADOS_TYPES */ + +/** Summarises all possible logical values. */ +typedef enum +{ + BT_FALSE = 0, /**< Logical value for "false". */ + BT_TRUE /**< Logical value for "true". */ +} BooleanType; + + +/** Summarises all possible print levels. Print levels are used to describe + * the desired amount of output during runtime of qpOASES. */ +typedef enum +{ + PL_DEBUG_ITER = -2, /**< Full tabular debugging output. */ + PL_TABULAR, /**< Tabular output. */ + 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. */ +} PrintLevel; + + +/** Defines visibility status of a message. */ +typedef enum +{ + VS_HIDDEN, /**< Message not visible. */ + VS_VISIBLE /**< Message visible. */ +} VisibilityStatus; + + +/** Summarises all possible states of the (S)QProblem(B) object during the +solution process of a QP sequence. */ +typedef enum +{ + 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. */ +} QProblemStatus; + + +/** Summarises all possible types of the QP's Hessian matrix. */ +typedef enum +{ + HST_ZERO, /**< Hessian is zero matrix (i.e. LP formulation). */ + HST_IDENTITY, /**< Hessian is identity matrix. */ + HST_POSDEF, /**< Hessian is (strictly) positive definite. */ + HST_POSDEF_NULLSPACE, /**< Hessian is positive definite on null space of active bounds/constraints. */ + HST_SEMIDEF, /**< Hessian is positive semi-definite. */ + HST_INDEF, /**< Hessian is indefinite. */ + HST_UNKNOWN /**< Hessian type is unknown. */ +} HessianType; + + +/** Summarises all possible types of bounds and constraints. */ +typedef enum +{ + 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_DISABLED, /**< Bound/constraint is disabled (i.e. ignored when solving QP). */ + ST_UNKNOWN /**< Type of bound/constraint unknown. */ +} SubjectToType; + + +/** Summarises all possible states of bounds and constraints. */ +typedef enum +{ + ST_LOWER = -1, /**< Bound/constraint is at its lower bound. */ + ST_INACTIVE, /**< Bound/constraint is inactive. */ + ST_UPPER, /**< Bound/constraint is at its upper bound. */ + ST_INFEASIBLE_LOWER, /**< (to be documented) */ + ST_INFEASIBLE_UPPER, /**< (to be documented) */ + ST_UNDEFINED /**< Status of bound/constraint undefined. */ +} SubjectToStatus; + + +/** + * \brief Stores internal information for tabular (debugging) output. + * + * Struct storing internal information for tabular (debugging) output + * when using the (S)QProblem(B) objects. + * + * \author Hans Joachim Ferreau + * \version 3.1embedded + * \date 2013-2015 + */ +typedef struct +{ + int idxAddB; /**< Index of bound that has been added to working set. */ + int idxRemB; /**< Index of bound that has been removed from working set. */ + int idxAddC; /**< Index of constraint that has been added to working set. */ + int idxRemC; /**< Index of constraint that has been removed from working set. */ + int excAddB; /**< Flag indicating whether a bound has been added to working set to keep a regular projected Hessian. */ + int excRemB; /**< Flag indicating whether a bound has been removed from working set to keep a regular projected Hessian. */ + int excAddC; /**< Flag indicating whether a constraint has been added to working set to keep a regular projected Hessian. */ + int excRemC; /**< Flag indicating whether a constraint has been removed from working set to keep a regular projected Hessian. */ +} TabularOutput; + +/** + * \brief Struct containing the variable header for mat file. + * + * Struct storing the header of a variable to be stored in + * Matlab's binary format (using the outdated Level 4 variant + * for simplictiy). + * + * Note, this code snippet has been inspired from the document + * "Matlab(R) MAT-file Format, R2013b" by MathWorks + * + * \author Hans Joachim Ferreau + * \version 3.1embedded + * \date 2013-2015 + */ +typedef struct +{ + long numericFormat; /**< Flag indicating numerical format. */ + long nRows; /**< Number of rows. */ + long nCols; /**< Number of rows. */ + long imaginaryPart; /**< (to be documented) */ + long nCharName; /**< Number of character in name. */ +} MatMatrixHeader; + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_TYPES_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/UnitTesting.h b/third_party/acados/include/qpOASES_e/UnitTesting.h new file mode 100644 index 00000000000000..3fb31129a5752d --- /dev/null +++ b/third_party/acados/include/qpOASES_e/UnitTesting.h @@ -0,0 +1,79 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/UnitTesting.h + * \author Hans Joachim Ferreau + * \version 3.1embedded + * \date 2014-2015 + * + * Definition of auxiliary functions/macros for unit testing. + */ + + +#ifndef QPOASES_UNIT_TESTING_H +#define QPOASES_UNIT_TESTING_H + + +#ifndef TEST_TOL_FACTOR +#define TEST_TOL_FACTOR 1 +#endif + + +/** Return value for tests that passed. */ +#define TEST_PASSED 0 + +/** Return value for tests that failed. */ +#define TEST_FAILED 1 + +/** Return value for tests that could not run due to missing external data. */ +#define TEST_DATA_NOT_FOUND 99 + + +/** Macro verifying that two numerical values are equal in order to pass unit test. */ +#define QPOASES_TEST_FOR_EQUAL( x,y ) if ( REFER_NAMESPACE_QPOASES isEqual( (x),(y) ) == BT_FALSE ) { return TEST_FAILED; } + +/** Macro verifying that two numerical values are close to each other in order to pass unit test. */ +#define QPOASES_TEST_FOR_NEAR( x,y ) if ( REFER_NAMESPACE_QPOASES getAbs((x)-(y)) / REFER_NAMESPACE_QPOASES getMax( 1.0,REFER_NAMESPACE_QPOASES getAbs(x) ) >= 1e-10 ) { return TEST_FAILED; } + +/** Macro verifying that first quantity is lower or equal than second one in order to pass unit test. */ +#define QPOASES_TEST_FOR_TOL( x,tol ) if ( (x) > (tol)*(TEST_TOL_FACTOR) ) { return TEST_FAILED; } + +/** Macro verifying that a logical expression holds in order to pass unit test. */ +#define QPOASES_TEST_FOR_TRUE( x ) if ( (x) == 0 ) { return TEST_FAILED; } + + + +BEGIN_NAMESPACE_QPOASES + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_UNIT_TESTING_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/Utils.h b/third_party/acados/include/qpOASES_e/Utils.h new file mode 100644 index 00000000000000..75e45a56a08c55 --- /dev/null +++ b/third_party/acados/include/qpOASES_e/Utils.h @@ -0,0 +1,500 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/Utils.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of some utilities for working with the different QProblem classes. + */ + + +#ifndef QPOASES_UTILS_H +#define QPOASES_UTILS_H + +#include + + +BEGIN_NAMESPACE_QPOASES + + +/** Prints a vector. + * \return SUCCESSFUL_RETURN */ +returnValue qpOASES_printV( const real_t* const v, /**< Vector to be printed. */ + int n /**< Length of vector. */ + ); + +/** Prints a permuted vector. + * \return SUCCESSFUL_RETURN */ +returnValue qpOASES_printPV( 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 qpOASES_printNV( 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 qpOASES_printM( 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 qpOASES_printPM( 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 qpOASES_printNM( 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 qpOASES_printI( const int* const _index, /**< Index array to be printed. */ + int n /**< Length of index array. */ + ); + +/** Prints a named index array. + * \return SUCCESSFUL_RETURN */ +returnValue qpOASES_printNI( 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 qpOASES_myPrintf( const char* s /**< String to be written. */ + ); + + +/** Prints qpOASES copyright notice. + * \return SUCCESSFUL_RETURN */ +returnValue qpOASES_printCopyrightNotice( ); + + +/** Reads a real_t matrix from file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_OPEN_FILE \n + RET_UNABLE_TO_READ_FILE */ +returnValue qpOASES_readFromFileM( 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 qpOASES_readFromFileV( 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 qpOASES_readFromFileI( 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 qpOASES_writeIntoFileM( 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 qpOASES_writeIntoFileV( 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 qpOASES_writeIntoFileI( 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). */ + ); + +/** Writes a real_t matrix/vector into a Matlab binary file. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS + RET_UNABLE_TO_WRITE_FILE */ +returnValue qpOASES_writeIntoMatFile( FILE* const matFile, /**< Pointer to Matlab binary file. */ + const real_t* const data, /**< Data to be written into file. */ + int nRows, /**< Row number of matrix. */ + int nCols, /**< Column number of matrix. */ + const char* name /**< Matlab name of matrix/vector to be stored. */ + ); + +/** Writes in integer matrix/vector into a Matlab binary file. + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS + RET_UNABLE_TO_WRITE_FILE */ +returnValue qpOASES_writeIntoMatFileI( FILE* const matFile, /**< Pointer to Matlab binary file. */ + const int* const data, /**< Data to be written into file. */ + int nRows, /**< Row number of matrix. */ + int nCols, /**< Column number of matrix. */ + const char* name /**< Matlab name of matrix/vector to be stored. */ + ); + + +/** Returns the current system time. + * \return current system time */ +real_t qpOASES_getCPUtime( ); + + +/** Returns the N-norm of a vector. + * \return >= 0.0: successful */ +real_t qpOASES_getNorm( const real_t* const v, /**< Vector. */ + int n, /**< Vector's dimension. */ + int type /**< Norm type, 1: one-norm, 2: Euclidean norm. */ + ); + +/** Tests whether two real-valued arguments are (numerically) equal. + * \return BT_TRUE: arguments differ not more than TOL \n + BT_FALSE: arguments differ more than TOL */ +static inline BooleanType qpOASES_isEqual( real_t x, /**< First real number. */ + real_t y, /**< Second real number. */ + real_t TOL /**< Tolerance for comparison. */ + ); + + +/** Tests whether a real-valued argument is (numerically) zero. + * \return BT_TRUE: argument differs from 0.0 not more than TOL \n + BT_FALSE: argument differs from 0.0 more than TOL */ +static inline BooleanType qpOASES_isZero( real_t x, /**< Real number. */ + real_t TOL /**< Tolerance for comparison. */ + ); + + +/** Returns sign of a real-valued argument. + * \return 1.0: argument is non-negative \n + -1.0: argument is negative */ +static inline real_t qpOASES_getSign( real_t arg /**< real-valued argument whose sign is to be determined. */ + ); + + +/** Returns maximum of two integers. + * \return Maximum of two integers */ +static inline int qpOASES_getMaxI( int x, /**< First integer. */ + int y /**< Second integer. */ + ); + + +/** Returns minimum of two integers. + * \return Minimum of two integers */ +static inline int qpOASES_getMinI( int x, /**< First integer. */ + int y /**< Second integer. */ + ); + + +/** Returns maximum of two reals. + * \return Maximum of two reals */ +static inline real_t qpOASES_getMax( real_t x, /**< First real number. */ + real_t y /**< Second real number. */ + ); + + +/** Returns minimum of two reals. + * \return Minimum of two reals */ +static inline real_t qpOASES_getMin( real_t x, /**< First real number. */ + real_t y /**< Second real number. */ + ); + + +/** Returns the absolute value of a real_t-valued argument. + * \return Absolute value of a real_t-valued argument */ +static inline real_t qpOASES_getAbs( real_t x /**< real_t-valued argument. */ + ); + +/** Returns the square-root of a real number. + * \return Square-root of a real number */ +static inline real_t qpOASES_getSqrt( real_t x /**< Non-negative real number. */ + ); + + +/** Computes the maximum violation of the KKT optimality conditions + * of given iterate for given QP data. */ +returnValue qpOASES_getKktViolation( int nV, /**< Number of variables. */ + int nC, /**< Number of constraints. */ + const real_t* const H, /**< Hessian matrix (may be NULL if Hessian is zero or identity 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). */ + const real_t* const ub, /**< Upper bound vector (on variables). */ + const real_t* const lbA, /**< Lower constraints' bound vector. */ + const real_t* const ubA, /**< Upper constraints' bound vector. */ + const real_t* const x, /**< Primal trial vector. */ + const real_t* const y, /**< Dual trial vector. */ + real_t* const _stat, /**< Output: maximum value of stationarity condition residual. */ + real_t* const feas, /**< Output: maximum value of primal feasibility violation. */ + real_t* const cmpl /**< Output: maximum value of complementarity residual. */ + ); + +/** Computes the maximum violation of the KKT optimality conditions + * of given iterate for given QP data. */ +returnValue qpOASES_getKktViolationSB( int nV, /**< Number of variables. */ + const real_t* const H, /**< Hessian matrix (may be NULL if Hessian is zero or identity matrix). */ + const real_t* const g, /**< Gradient vector. */ + const real_t* const lb, /**< Lower bound vector (on variables). */ + const real_t* const ub, /**< Upper bound vector (on variables). */ + const real_t* const x, /**< Primal trial vector. */ + const real_t* const y, /**< Dual trial vector. */ + real_t* const _stat, /**< Output: maximum value of stationarity condition residual. */ + real_t* const feas, /**< Output: maximum value of primal feasibility violation. */ + real_t* const cmpl /**< Output: maximum value of complementarity residual. */ + ); + + +/** Writes a value of BooleanType into a string. + * \return SUCCESSFUL_RETURN */ +returnValue qpOASES_convertBooleanTypeToString( BooleanType value, /**< Value to be written. */ + char* const string /**< Input: String of sufficient size, \n + Output: String containing value. */ + ); + +/** Writes a value of SubjectToStatus into a string. + * \return SUCCESSFUL_RETURN */ +returnValue qpOASES_convertSubjectToStatusToString( SubjectToStatus value, /**< Value to be written. */ + char* const string /**< Input: String of sufficient size, \n + Output: String containing value. */ + ); + +/** Writes a value of PrintLevel into a string. + * \return SUCCESSFUL_RETURN */ +returnValue qpOASES_convertPrintLevelToString( PrintLevel value, /**< Value to be written. */ + char* const string /**< Input: String of sufficient size, \n + Output: String containing value. */ + ); + + +/** Converts a returnValue from an QProblem(B) object into a more + * simple status flag. + * + * \return 0: QP problem solved + * 1: QP could not be solved within given number of iterations + * -1: QP could not be solved due to an internal error + * -2: QP is infeasible (and thus could not be solved) + * -3: QP is unbounded (and thus could not be solved) + */ +int qpOASES_getSimpleStatus( returnValue returnvalue, /**< ReturnValue to be analysed. */ + BooleanType doPrintStatus /**< Flag indicating whether simple status shall be printed to screen. */ + ); + +/** Normalises QP constraints. + * \return SUCCESSFUL_RETURN \n + * RET_INVALID_ARGUMENTS */ +returnValue qpOASES_normaliseConstraints( int nV, /**< Number of variables. */ + int nC, /**< Number of constraints. */ + real_t* A, /**< Input: Constraint matrix, \n + Output: Normalised constraint matrix. */ + real_t* lbA, /**< Input: Constraints' lower bound vector, \n + Output: Normalised constraints' lower bound vector. */ + real_t* ubA, /**< Input: Constraints' upper bound vector, \n + Output: Normalised constraints' upper bound vector. */ + int type /**< Norm type, 1: one-norm, 2: Euclidean norm. */ + ); + + +#ifdef __DEBUG__ +/** Writes matrix with given dimension into specified file. */ +void gdb_printmat( const char *fname, /**< File name. */ + real_t *M, /**< Matrix to be written. */ + int n, /**< Number of rows. */ + int m, /**< Number of columns. */ + int ldim /**< Leading dimension. */ + ); +#endif /* __DEBUG__ */ + + +#if defined(__DSPACE__) || defined(__XPCTARGET__) +void __cxa_pure_virtual( void ); +#endif /* __DSPACE__ || __XPCTARGET__*/ + + + +/* + * i s E q u a l + */ +static inline BooleanType qpOASES_isEqual( real_t x, + real_t y, + real_t TOL + ) +{ + if ( qpOASES_getAbs(x-y) <= TOL ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * i s Z e r o + */ +static inline BooleanType qpOASES_isZero( real_t x, + real_t TOL + ) +{ + if ( qpOASES_getAbs(x) <= TOL ) + return BT_TRUE; + else + return BT_FALSE; +} + + +/* + * g e t S i g n + */ +static inline real_t qpOASES_getSign( real_t arg + ) +{ + if ( arg >= 0.0 ) + return 1.0; + else + return -1.0; +} + + + +/* + * g e t M a x + */ +static inline int qpOASES_getMaxI( int x, + int y + ) +{ + return (yx) ? x : y; +} + + +/* + * g e t M a x + */ +static inline real_t qpOASES_getMax( real_t x, + real_t y + ) +{ + #ifdef __NO_FMATH__ + return (yx) ? x : y; + #else + return (y>x) ? x : y; + /*return fmin(x,y); seems to be slower */ + #endif +} + + +/* + * g e t A b s + */ +static inline real_t qpOASES_getAbs( real_t x + ) +{ + #ifdef __NO_FMATH__ + return (x>=0.0) ? x : -x; + #else + return fabs(x); + #endif +} + +/* + * g e t S q r t + */ +static inline real_t qpOASES_getSqrt( real_t x + ) +{ + #ifdef __NO_FMATH__ + return sqrt(x); /* put your custom sqrt-replacement here */ + #else + return sqrt(x); + #endif +} + + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_UTILS_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/include/qpOASES_e/extras/OQPinterface.h b/third_party/acados/include/qpOASES_e/extras/OQPinterface.h new file mode 100644 index 00000000000000..da59ea9db6483f --- /dev/null +++ b/third_party/acados/include/qpOASES_e/extras/OQPinterface.h @@ -0,0 +1,227 @@ +/* + * This file is part of qpOASES. + * + * qpOASES -- An Implementation of the Online Active Set Strategy. + * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, + * Christian Kirches 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/qpOASES_e/extras/OQPinterface.h + * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches + * \version 3.1embedded + * \date 2007-2015 + * + * Declaration of an interface comprising several utility functions + * for solving test problems from the Online QP Benchmark Collection + * (This collection is no longer maintained, see + * http://www.qpOASES.org/onlineQP for a backup). + */ + + +#ifndef QPOASES_OQPINTERFACE_H +#define QPOASES_OQPINTERFACE_H + + +#include +#include + +#include +#include + + +BEGIN_NAMESPACE_QPOASES + +typedef struct { + QProblem *qp; + + DenseMatrix *H; + DenseMatrix *A; + + real_t *x; + real_t *y; +} OQPbenchmark_ws; + +int OQPbenchmark_ws_calculateMemorySize( unsigned int nV, unsigned int nC ); + +char *OQPbenchmark_ws_assignMemory( unsigned int nV, unsigned int nC, OQPbenchmark_ws **mem, void *raw_memory ); + +OQPbenchmark_ws *OQPbenchmark_ws_createMemory( unsigned int nV, unsigned int nC ); + +typedef struct { + QProblemB *qp; + + DenseMatrix *H; + + real_t *x; + real_t *y; +} OQPbenchmarkB_ws; + +int OQPbenchmarkB_ws_calculateMemorySize( unsigned int nV ); + +char *OQPbenchmarkB_ws_assignMemory( unsigned int nV, OQPbenchmarkB_ws **mem, void *raw_memory ); + +OQPbenchmarkB_ws *OQPbenchmarkB_ws_createMemory( unsigned int nV ); + +typedef struct { + OQPbenchmark_ws *qp_ws; + OQPbenchmarkB_ws *qpB_ws; + + real_t *H; + real_t *g; + real_t *A; + real_t *lb; + real_t *ub; + real_t *lbA; + real_t *ubA; +} OQPinterface_ws; + +int OQPinterface_ws_calculateMemorySize( unsigned int nV, unsigned int nC, unsigned int nQP ); + +char *OQPinterface_ws_assignMemory( unsigned int nV, unsigned int nC, unsigned int nQP, OQPinterface_ws **mem, void *raw_memory ); + +OQPinterface_ws *OQPinterface_ws_createMemory( unsigned int nV, unsigned int nC, unsigned int nQP ); + +/** Reads dimensions of an Online QP Benchmark problem from file. + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_READ_FILE \n + RET_FILEDATA_INCONSISTENT */ +returnValue readOQPdimensions( const char* path, /**< Full path of the data files (without trailing slash!). */ + int* nQP, /**< Output: Number of QPs. */ + int* nV, /**< Output: Number of variables. */ + int* nC, /**< Output: Number of constraints. */ + int* nEC /**< Output: Number of equality constraints. */ + ); + +/** Reads data of an Online QP Benchmark problem from file. + * This function allocates the required memory for all data; after successfully calling it, + * you have to free this memory yourself! + * \return SUCCESSFUL_RETURN \n + RET_INVALID_ARGUMENTS \n + RET_UNABLE_TO_READ_FILE \n + RET_FILEDATA_INCONSISTENT */ +returnValue readOQPdata( const char* path, /**< Full path of the data files (without trailing slash!). */ + int* nQP, /**< Output: Number of QPs. */ + int* nV, /**< Output: Number of variables. */ + int* nC, /**< Output: Number of constraints. */ + int* nEC, /**< Output: Number of equality constraints. */ + real_t* H, /**< Output: Hessian matrix. */ + real_t* g, /**< Output: Sequence of gradient vectors. */ + real_t* A, /**< Output: Constraint matrix. */ + real_t* lb, /**< Output: Sequence of lower bound vectors (on variables). */ + real_t* ub, /**< Output: Sequence of upper bound vectors (on variables). */ + real_t* lbA, /**< Output: Sequence of lower constraints' bound vectors. */ + real_t* ubA, /**< Output: Sequence of upper constraints' bound vectors. */ + real_t* xOpt, /**< Output: Sequence of primal solution vectors + * (not read if a null pointer is passed). */ + real_t* yOpt, /**< Output: Sequence of dual solution vectors + * (not read if a null pointer is passed). */ + real_t* objOpt /**< Output: Sequence of optimal objective function values + * (not read if a null pointer is passed). */ + ); + + +/** Solves an Online QP Benchmark problem as specified by the arguments. + * The maximum deviations from the given optimal solution as well as the + * maximum CPU time to solve each QP are determined. + * \return SUCCESSFUL_RETURN \n + RET_BENCHMARK_ABORTED */ +returnValue solveOQPbenchmark( int nQP, /**< Number of QPs. */ + int nV, /**< Number of variables. */ + int nC, /**< Number of constraints. */ + int nEC, /**< Number of equality constraints. */ + real_t* _H, /**< Hessian matrix. */ + const real_t* const g, /**< Sequence of gradient vectors. */ + real_t* _A, /**< Constraint matrix. */ + const real_t* const lb, /**< Sequence of lower bound vectors (on variables). */ + const real_t* const ub, /**< Sequence of upper bound vectors (on variables). */ + const real_t* const lbA, /**< Sequence of lower constraints' bound vectors. */ + const real_t* const ubA, /**< Sequence of upper constraints' bound vectors. */ + BooleanType isSparse, /**< Shall convert matrices to sparse format before solution? */ + BooleanType useHotstarts, /**< Shall QP solution be hotstarted? */ + const Options* options, /**< QP solver options to be used while solving benchmark problems. */ + int maxAllowedNWSR, /**< Maximum number of working set recalculations to be performed. */ + real_t* maxNWSR, /**< Output: Maximum number of performed working set recalculations. */ + real_t* avgNWSR, /**< Output: Average number of performed working set recalculations. */ + real_t* maxCPUtime, /**< Output: Maximum CPU time required for solving each QP. */ + real_t* avgCPUtime, /**< Output: Average CPU time required for solving each QP. */ + real_t* maxStationarity, /**< Output: Maximum residual of stationarity condition. */ + real_t* maxFeasibility, /**< Output: Maximum residual of primal feasibility condition. */ + real_t* maxComplementarity, /**< Output: Maximum residual of complementarity condition. */ + OQPbenchmark_ws *work /**< Workspace. */ + ); + +/** Solves an Online QP Benchmark problem (without constraints) as specified + * by the arguments. The maximum deviations from the given optimal solution + * as well as the maximum CPU time to solve each QP are determined. + * \return SUCCESSFUL_RETURN \n + RET_BENCHMARK_ABORTED */ +returnValue solveOQPbenchmarkB( int nQP, /**< Number of QPs. */ + int nV, /**< Number of variables. */ + real_t* _H, /**< Hessian matrix. */ + const real_t* const g, /**< Sequence of gradient vectors. */ + const real_t* const lb, /**< Sequence of lower bound vectors (on variables). */ + const real_t* const ub, /**< Sequence of upper bound vectors (on variables). */ + BooleanType isSparse, /**< Shall convert matrices to sparse format before solution? */ + BooleanType useHotstarts, /**< Shall QP solution be hotstarted? */ + const Options* options, /**< QP solver options to be used while solving benchmark problems. */ + int maxAllowedNWSR, /**< Maximum number of working set recalculations to be performed. */ + real_t* maxNWSR, /**< Output: Maximum number of performed working set recalculations. */ + real_t* avgNWSR, /**< Output: Average number of performed working set recalculations. */ + real_t* maxCPUtime, /**< Output: Maximum CPU time required for solving each QP. */ + real_t* avgCPUtime, /**< Output: Average CPU time required for solving each QP. */ + real_t* maxStationarity, /**< Output: Maximum residual of stationarity condition. */ + real_t* maxFeasibility, /**< Output: Maximum residual of primal feasibility condition. */ + real_t* maxComplementarity, /**< Output: Maximum residual of complementarity condition. */ + OQPbenchmarkB_ws *work /**< Workspace. */ + ); + + +/** Runs an Online QP Benchmark problem and determines the maximum + * violation of the KKT optimality conditions as well as the + * maximum and average number of iterations and CPU time to solve + * each QP. + * + * \return SUCCESSFUL_RETURN \n + RET_UNABLE_TO_READ_BENCHMARK \n + RET_BENCHMARK_ABORTED */ +returnValue runOQPbenchmark( const char* path, /**< Full path of the benchmark files (without trailing slash!). */ + BooleanType isSparse, /**< Shall convert matrices to sparse format before solution? */ + BooleanType useHotstarts, /**< Shall QP solution be hotstarted? */ + const Options* options, /**< QP solver options to be used while solving benchmark problems. */ + int maxAllowedNWSR, /**< Maximum number of working set recalculations to be performed. */ + real_t* maxNWSR, /**< Output: Maximum number of performed working set recalculations. */ + real_t* avgNWSR, /**< Output: Average number of performed working set recalculations. */ + real_t* maxCPUtime, /**< Output: Maximum CPU time required for solving each QP. */ + real_t* avgCPUtime, /**< Output: Average CPU time required for solving each QP. */ + real_t* maxStationarity, /**< Output: Maximum residual of stationarity condition. */ + real_t* maxFeasibility, /**< Output: Maximum residual of primal feasibility condition. */ + real_t* maxComplementarity, /**< Output: Maximum residual of complementarity condition. */ + OQPinterface_ws* work /**< Workspace. */ + ); + +END_NAMESPACE_QPOASES + + +#endif /* QPOASES_OQPINTERFACE_H */ + + +/* + * end of file + */ diff --git a/third_party/acados/larch64/lib/libacados.so b/third_party/acados/larch64/lib/libacados.so new file mode 100644 index 00000000000000..1f2b1f5c0b976e Binary files /dev/null and b/third_party/acados/larch64/lib/libacados.so differ diff --git a/third_party/acados/larch64/lib/libblasfeo.so b/third_party/acados/larch64/lib/libblasfeo.so new file mode 100644 index 00000000000000..790282fa194245 Binary files /dev/null and b/third_party/acados/larch64/lib/libblasfeo.so differ diff --git a/third_party/acados/larch64/lib/libhpipm.so b/third_party/acados/larch64/lib/libhpipm.so new file mode 100644 index 00000000000000..bebd5e891145e2 Binary files /dev/null and b/third_party/acados/larch64/lib/libhpipm.so differ diff --git a/third_party/acados/larch64/lib/libqpOASES_e.so b/third_party/acados/larch64/lib/libqpOASES_e.so new file mode 120000 index 00000000000000..14048625a1c2d3 --- /dev/null +++ b/third_party/acados/larch64/lib/libqpOASES_e.so @@ -0,0 +1 @@ +libqpOASES_e.so.3.1 \ No newline at end of file diff --git a/third_party/acados/larch64/lib/libqpOASES_e.so.3.1 b/third_party/acados/larch64/lib/libqpOASES_e.so.3.1 new file mode 100644 index 00000000000000..0611c8a9390013 Binary files /dev/null and b/third_party/acados/larch64/lib/libqpOASES_e.so.3.1 differ diff --git a/third_party/acados/larch64/t_renderer b/third_party/acados/larch64/t_renderer new file mode 100755 index 00000000000000..b4ff8bc319ba99 Binary files /dev/null and b/third_party/acados/larch64/t_renderer differ diff --git a/third_party/acados/x86_64/lib/libacados.so b/third_party/acados/x86_64/lib/libacados.so new file mode 100644 index 00000000000000..00a5e2371a8e9a Binary files /dev/null and b/third_party/acados/x86_64/lib/libacados.so differ diff --git a/third_party/acados/x86_64/lib/libblasfeo.so b/third_party/acados/x86_64/lib/libblasfeo.so new file mode 100644 index 00000000000000..5a8399287a7da6 Binary files /dev/null and b/third_party/acados/x86_64/lib/libblasfeo.so differ diff --git a/third_party/acados/x86_64/lib/libhpipm.so b/third_party/acados/x86_64/lib/libhpipm.so new file mode 100644 index 00000000000000..f52091d931ad8f Binary files /dev/null and b/third_party/acados/x86_64/lib/libhpipm.so differ diff --git a/third_party/acados/x86_64/lib/libqpOASES_e.so b/third_party/acados/x86_64/lib/libqpOASES_e.so new file mode 120000 index 00000000000000..14048625a1c2d3 --- /dev/null +++ b/third_party/acados/x86_64/lib/libqpOASES_e.so @@ -0,0 +1 @@ +libqpOASES_e.so.3.1 \ No newline at end of file diff --git a/third_party/acados/x86_64/lib/libqpOASES_e.so.3.1 b/third_party/acados/x86_64/lib/libqpOASES_e.so.3.1 new file mode 100644 index 00000000000000..6b553554fd52ed Binary files /dev/null and b/third_party/acados/x86_64/lib/libqpOASES_e.so.3.1 differ diff --git a/third_party/acados/x86_64/t_renderer b/third_party/acados/x86_64/t_renderer new file mode 100755 index 00000000000000..181ef9c3d281fc Binary files /dev/null and b/third_party/acados/x86_64/t_renderer differ diff --git a/third_party/android_frameworks_native/get.txt b/third_party/android_frameworks_native/get.txt new file mode 100644 index 00000000000000..277bdcb6a8efe7 --- /dev/null +++ b/third_party/android_frameworks_native/get.txt @@ -0,0 +1,3 @@ +git clone https://github.com/CyanogenMod/android_frameworks_native.git && cd android_frameworks_native +git reset --hard b22bca465e55618a949d9cbdea665a1a3a831241 +cp -r include ~/one/third_party/android_frameworks_native/ diff --git a/phonelibs/android_frameworks_native/include/android/asset_manager.h b/third_party/android_frameworks_native/include/android/asset_manager.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/asset_manager.h rename to third_party/android_frameworks_native/include/android/asset_manager.h diff --git a/phonelibs/android_frameworks_native/include/android/asset_manager_jni.h b/third_party/android_frameworks_native/include/android/asset_manager_jni.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/asset_manager_jni.h rename to third_party/android_frameworks_native/include/android/asset_manager_jni.h diff --git a/phonelibs/android_frameworks_native/include/android/bitmap.h b/third_party/android_frameworks_native/include/android/bitmap.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/bitmap.h rename to third_party/android_frameworks_native/include/android/bitmap.h diff --git a/phonelibs/android_frameworks_native/include/android/configuration.h b/third_party/android_frameworks_native/include/android/configuration.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/configuration.h rename to third_party/android_frameworks_native/include/android/configuration.h diff --git a/phonelibs/android_frameworks_native/include/android/input.h b/third_party/android_frameworks_native/include/android/input.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/input.h rename to third_party/android_frameworks_native/include/android/input.h diff --git a/phonelibs/android_frameworks_native/include/android/keycodes.h b/third_party/android_frameworks_native/include/android/keycodes.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/keycodes.h rename to third_party/android_frameworks_native/include/android/keycodes.h diff --git a/phonelibs/android_frameworks_native/include/android/looper.h b/third_party/android_frameworks_native/include/android/looper.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/looper.h rename to third_party/android_frameworks_native/include/android/looper.h diff --git a/phonelibs/android_frameworks_native/include/android/multinetwork.h b/third_party/android_frameworks_native/include/android/multinetwork.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/multinetwork.h rename to third_party/android_frameworks_native/include/android/multinetwork.h diff --git a/phonelibs/android_frameworks_native/include/android/native_activity.h b/third_party/android_frameworks_native/include/android/native_activity.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/native_activity.h rename to third_party/android_frameworks_native/include/android/native_activity.h diff --git a/phonelibs/android_frameworks_native/include/android/native_window.h b/third_party/android_frameworks_native/include/android/native_window.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/native_window.h rename to third_party/android_frameworks_native/include/android/native_window.h diff --git a/phonelibs/android_frameworks_native/include/android/native_window_jni.h b/third_party/android_frameworks_native/include/android/native_window_jni.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/native_window_jni.h rename to third_party/android_frameworks_native/include/android/native_window_jni.h diff --git a/phonelibs/android_frameworks_native/include/android/obb.h b/third_party/android_frameworks_native/include/android/obb.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/obb.h rename to third_party/android_frameworks_native/include/android/obb.h diff --git a/phonelibs/android_frameworks_native/include/android/rect.h b/third_party/android_frameworks_native/include/android/rect.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/rect.h rename to third_party/android_frameworks_native/include/android/rect.h diff --git a/phonelibs/android_frameworks_native/include/android/sensor.h b/third_party/android_frameworks_native/include/android/sensor.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/sensor.h rename to third_party/android_frameworks_native/include/android/sensor.h diff --git a/phonelibs/android_frameworks_native/include/android/storage_manager.h b/third_party/android_frameworks_native/include/android/storage_manager.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/storage_manager.h rename to third_party/android_frameworks_native/include/android/storage_manager.h diff --git a/phonelibs/android_frameworks_native/include/android/trace.h b/third_party/android_frameworks_native/include/android/trace.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/trace.h rename to third_party/android_frameworks_native/include/android/trace.h diff --git a/phonelibs/android_frameworks_native/include/android/window.h b/third_party/android_frameworks_native/include/android/window.h similarity index 100% rename from phonelibs/android_frameworks_native/include/android/window.h rename to third_party/android_frameworks_native/include/android/window.h diff --git a/phonelibs/android_frameworks_native/include/binder/AppOpsManager.h b/third_party/android_frameworks_native/include/binder/AppOpsManager.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/AppOpsManager.h rename to third_party/android_frameworks_native/include/binder/AppOpsManager.h diff --git a/phonelibs/android_frameworks_native/include/binder/Binder.h b/third_party/android_frameworks_native/include/binder/Binder.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/Binder.h rename to third_party/android_frameworks_native/include/binder/Binder.h diff --git a/phonelibs/android_frameworks_native/include/binder/BinderService.h b/third_party/android_frameworks_native/include/binder/BinderService.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/BinderService.h rename to third_party/android_frameworks_native/include/binder/BinderService.h diff --git a/phonelibs/android_frameworks_native/include/binder/BpBinder.h b/third_party/android_frameworks_native/include/binder/BpBinder.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/BpBinder.h rename to third_party/android_frameworks_native/include/binder/BpBinder.h diff --git a/phonelibs/android_frameworks_native/include/binder/BufferedTextOutput.h b/third_party/android_frameworks_native/include/binder/BufferedTextOutput.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/BufferedTextOutput.h rename to third_party/android_frameworks_native/include/binder/BufferedTextOutput.h diff --git a/phonelibs/android_frameworks_native/include/binder/Debug.h b/third_party/android_frameworks_native/include/binder/Debug.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/Debug.h rename to third_party/android_frameworks_native/include/binder/Debug.h diff --git a/phonelibs/android_frameworks_native/include/binder/IAppOpsCallback.h b/third_party/android_frameworks_native/include/binder/IAppOpsCallback.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IAppOpsCallback.h rename to third_party/android_frameworks_native/include/binder/IAppOpsCallback.h diff --git a/phonelibs/android_frameworks_native/include/binder/IAppOpsService.h b/third_party/android_frameworks_native/include/binder/IAppOpsService.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IAppOpsService.h rename to third_party/android_frameworks_native/include/binder/IAppOpsService.h diff --git a/phonelibs/android_frameworks_native/include/binder/IBatteryStats.h b/third_party/android_frameworks_native/include/binder/IBatteryStats.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IBatteryStats.h rename to third_party/android_frameworks_native/include/binder/IBatteryStats.h diff --git a/phonelibs/android_frameworks_native/include/binder/IBinder.h b/third_party/android_frameworks_native/include/binder/IBinder.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IBinder.h rename to third_party/android_frameworks_native/include/binder/IBinder.h diff --git a/phonelibs/android_frameworks_native/include/binder/IInterface.h b/third_party/android_frameworks_native/include/binder/IInterface.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IInterface.h rename to third_party/android_frameworks_native/include/binder/IInterface.h diff --git a/phonelibs/android_frameworks_native/include/binder/IMemory.h b/third_party/android_frameworks_native/include/binder/IMemory.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IMemory.h rename to third_party/android_frameworks_native/include/binder/IMemory.h diff --git a/phonelibs/android_frameworks_native/include/binder/IPCThreadState.h b/third_party/android_frameworks_native/include/binder/IPCThreadState.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IPCThreadState.h rename to third_party/android_frameworks_native/include/binder/IPCThreadState.h diff --git a/phonelibs/android_frameworks_native/include/binder/IPermissionController.h b/third_party/android_frameworks_native/include/binder/IPermissionController.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IPermissionController.h rename to third_party/android_frameworks_native/include/binder/IPermissionController.h diff --git a/phonelibs/android_frameworks_native/include/binder/IProcessInfoService.h b/third_party/android_frameworks_native/include/binder/IProcessInfoService.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IProcessInfoService.h rename to third_party/android_frameworks_native/include/binder/IProcessInfoService.h diff --git a/phonelibs/android_frameworks_native/include/binder/IServiceManager.h b/third_party/android_frameworks_native/include/binder/IServiceManager.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/IServiceManager.h rename to third_party/android_frameworks_native/include/binder/IServiceManager.h diff --git a/phonelibs/android_frameworks_native/include/binder/MemoryBase.h b/third_party/android_frameworks_native/include/binder/MemoryBase.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/MemoryBase.h rename to third_party/android_frameworks_native/include/binder/MemoryBase.h diff --git a/phonelibs/android_frameworks_native/include/binder/MemoryDealer.h b/third_party/android_frameworks_native/include/binder/MemoryDealer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/MemoryDealer.h rename to third_party/android_frameworks_native/include/binder/MemoryDealer.h diff --git a/phonelibs/android_frameworks_native/include/binder/MemoryHeapBase.h b/third_party/android_frameworks_native/include/binder/MemoryHeapBase.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/MemoryHeapBase.h rename to third_party/android_frameworks_native/include/binder/MemoryHeapBase.h diff --git a/phonelibs/android_frameworks_native/include/binder/MemoryHeapIon.h b/third_party/android_frameworks_native/include/binder/MemoryHeapIon.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/MemoryHeapIon.h rename to third_party/android_frameworks_native/include/binder/MemoryHeapIon.h diff --git a/phonelibs/android_frameworks_native/include/binder/Parcel.h b/third_party/android_frameworks_native/include/binder/Parcel.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/Parcel.h rename to third_party/android_frameworks_native/include/binder/Parcel.h diff --git a/phonelibs/android_frameworks_native/include/binder/PermissionCache.h b/third_party/android_frameworks_native/include/binder/PermissionCache.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/PermissionCache.h rename to third_party/android_frameworks_native/include/binder/PermissionCache.h diff --git a/phonelibs/android_frameworks_native/include/binder/ProcessInfoService.h b/third_party/android_frameworks_native/include/binder/ProcessInfoService.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/ProcessInfoService.h rename to third_party/android_frameworks_native/include/binder/ProcessInfoService.h diff --git a/phonelibs/android_frameworks_native/include/binder/ProcessState.h b/third_party/android_frameworks_native/include/binder/ProcessState.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/ProcessState.h rename to third_party/android_frameworks_native/include/binder/ProcessState.h diff --git a/phonelibs/android_frameworks_native/include/binder/TextOutput.h b/third_party/android_frameworks_native/include/binder/TextOutput.h similarity index 100% rename from phonelibs/android_frameworks_native/include/binder/TextOutput.h rename to third_party/android_frameworks_native/include/binder/TextOutput.h diff --git a/phonelibs/android_frameworks_native/include/gui/BitTube.h b/third_party/android_frameworks_native/include/gui/BitTube.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BitTube.h rename to third_party/android_frameworks_native/include/gui/BitTube.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferItem.h b/third_party/android_frameworks_native/include/gui/BufferItem.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferItem.h rename to third_party/android_frameworks_native/include/gui/BufferItem.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferItemConsumer.h b/third_party/android_frameworks_native/include/gui/BufferItemConsumer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferItemConsumer.h rename to third_party/android_frameworks_native/include/gui/BufferItemConsumer.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferQueue.h b/third_party/android_frameworks_native/include/gui/BufferQueue.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferQueue.h rename to third_party/android_frameworks_native/include/gui/BufferQueue.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferQueueConsumer.h b/third_party/android_frameworks_native/include/gui/BufferQueueConsumer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferQueueConsumer.h rename to third_party/android_frameworks_native/include/gui/BufferQueueConsumer.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferQueueCore.h b/third_party/android_frameworks_native/include/gui/BufferQueueCore.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferQueueCore.h rename to third_party/android_frameworks_native/include/gui/BufferQueueCore.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferQueueDefs.h b/third_party/android_frameworks_native/include/gui/BufferQueueDefs.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferQueueDefs.h rename to third_party/android_frameworks_native/include/gui/BufferQueueDefs.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferQueueProducer.h b/third_party/android_frameworks_native/include/gui/BufferQueueProducer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferQueueProducer.h rename to third_party/android_frameworks_native/include/gui/BufferQueueProducer.h diff --git a/phonelibs/android_frameworks_native/include/gui/BufferSlot.h b/third_party/android_frameworks_native/include/gui/BufferSlot.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/BufferSlot.h rename to third_party/android_frameworks_native/include/gui/BufferSlot.h diff --git a/phonelibs/android_frameworks_native/include/gui/ConsumerBase.h b/third_party/android_frameworks_native/include/gui/ConsumerBase.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/ConsumerBase.h rename to third_party/android_frameworks_native/include/gui/ConsumerBase.h diff --git a/phonelibs/android_frameworks_native/include/gui/CpuConsumer.h b/third_party/android_frameworks_native/include/gui/CpuConsumer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/CpuConsumer.h rename to third_party/android_frameworks_native/include/gui/CpuConsumer.h diff --git a/phonelibs/android_frameworks_native/include/gui/DisplayEventReceiver.h b/third_party/android_frameworks_native/include/gui/DisplayEventReceiver.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/DisplayEventReceiver.h rename to third_party/android_frameworks_native/include/gui/DisplayEventReceiver.h diff --git a/phonelibs/android_frameworks_native/include/gui/GLConsumer.h b/third_party/android_frameworks_native/include/gui/GLConsumer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/GLConsumer.h rename to third_party/android_frameworks_native/include/gui/GLConsumer.h diff --git a/phonelibs/android_frameworks_native/include/gui/GraphicBufferAlloc.h b/third_party/android_frameworks_native/include/gui/GraphicBufferAlloc.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/GraphicBufferAlloc.h rename to third_party/android_frameworks_native/include/gui/GraphicBufferAlloc.h diff --git a/phonelibs/android_frameworks_native/include/gui/GuiConfig.h b/third_party/android_frameworks_native/include/gui/GuiConfig.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/GuiConfig.h rename to third_party/android_frameworks_native/include/gui/GuiConfig.h diff --git a/phonelibs/android_frameworks_native/include/gui/IConsumerListener.h b/third_party/android_frameworks_native/include/gui/IConsumerListener.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/IConsumerListener.h rename to third_party/android_frameworks_native/include/gui/IConsumerListener.h diff --git a/phonelibs/android_frameworks_native/include/gui/IDisplayEventConnection.h b/third_party/android_frameworks_native/include/gui/IDisplayEventConnection.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/IDisplayEventConnection.h rename to third_party/android_frameworks_native/include/gui/IDisplayEventConnection.h diff --git a/phonelibs/android_frameworks_native/include/gui/IGraphicBufferAlloc.h b/third_party/android_frameworks_native/include/gui/IGraphicBufferAlloc.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/IGraphicBufferAlloc.h rename to third_party/android_frameworks_native/include/gui/IGraphicBufferAlloc.h diff --git a/phonelibs/android_frameworks_native/include/gui/IGraphicBufferConsumer.h b/third_party/android_frameworks_native/include/gui/IGraphicBufferConsumer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/IGraphicBufferConsumer.h rename to third_party/android_frameworks_native/include/gui/IGraphicBufferConsumer.h diff --git a/phonelibs/android_frameworks_native/include/gui/IGraphicBufferProducer.h b/third_party/android_frameworks_native/include/gui/IGraphicBufferProducer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/IGraphicBufferProducer.h rename to third_party/android_frameworks_native/include/gui/IGraphicBufferProducer.h diff --git a/phonelibs/android_frameworks_native/include/gui/IProducerListener.h b/third_party/android_frameworks_native/include/gui/IProducerListener.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/IProducerListener.h rename to third_party/android_frameworks_native/include/gui/IProducerListener.h diff --git a/phonelibs/android_frameworks_native/include/gui/ISensorEventConnection.h b/third_party/android_frameworks_native/include/gui/ISensorEventConnection.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/ISensorEventConnection.h rename to third_party/android_frameworks_native/include/gui/ISensorEventConnection.h diff --git a/phonelibs/android_frameworks_native/include/gui/ISensorServer.h b/third_party/android_frameworks_native/include/gui/ISensorServer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/ISensorServer.h rename to third_party/android_frameworks_native/include/gui/ISensorServer.h diff --git a/phonelibs/android_frameworks_native/include/gui/ISurfaceComposer.h b/third_party/android_frameworks_native/include/gui/ISurfaceComposer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/ISurfaceComposer.h rename to third_party/android_frameworks_native/include/gui/ISurfaceComposer.h diff --git a/phonelibs/android_frameworks_native/include/gui/ISurfaceComposerClient.h b/third_party/android_frameworks_native/include/gui/ISurfaceComposerClient.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/ISurfaceComposerClient.h rename to third_party/android_frameworks_native/include/gui/ISurfaceComposerClient.h diff --git a/phonelibs/android_frameworks_native/include/gui/Sensor.h b/third_party/android_frameworks_native/include/gui/Sensor.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/Sensor.h rename to third_party/android_frameworks_native/include/gui/Sensor.h diff --git a/phonelibs/android_frameworks_native/include/gui/SensorEventQueue.h b/third_party/android_frameworks_native/include/gui/SensorEventQueue.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/SensorEventQueue.h rename to third_party/android_frameworks_native/include/gui/SensorEventQueue.h diff --git a/phonelibs/android_frameworks_native/include/gui/SensorManager.h b/third_party/android_frameworks_native/include/gui/SensorManager.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/SensorManager.h rename to third_party/android_frameworks_native/include/gui/SensorManager.h diff --git a/phonelibs/android_frameworks_native/include/gui/StreamSplitter.h b/third_party/android_frameworks_native/include/gui/StreamSplitter.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/StreamSplitter.h rename to third_party/android_frameworks_native/include/gui/StreamSplitter.h diff --git a/phonelibs/android_frameworks_native/include/gui/Surface.h b/third_party/android_frameworks_native/include/gui/Surface.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/Surface.h rename to third_party/android_frameworks_native/include/gui/Surface.h diff --git a/phonelibs/android_frameworks_native/include/gui/SurfaceComposerClient.h b/third_party/android_frameworks_native/include/gui/SurfaceComposerClient.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/SurfaceComposerClient.h rename to third_party/android_frameworks_native/include/gui/SurfaceComposerClient.h diff --git a/phonelibs/android_frameworks_native/include/gui/SurfaceControl.h b/third_party/android_frameworks_native/include/gui/SurfaceControl.h similarity index 100% rename from phonelibs/android_frameworks_native/include/gui/SurfaceControl.h rename to third_party/android_frameworks_native/include/gui/SurfaceControl.h diff --git a/phonelibs/android_frameworks_native/include/ui/ANativeObjectBase.h b/third_party/android_frameworks_native/include/ui/ANativeObjectBase.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/ANativeObjectBase.h rename to third_party/android_frameworks_native/include/ui/ANativeObjectBase.h diff --git a/phonelibs/android_frameworks_native/include/ui/DisplayInfo.h b/third_party/android_frameworks_native/include/ui/DisplayInfo.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/DisplayInfo.h rename to third_party/android_frameworks_native/include/ui/DisplayInfo.h diff --git a/phonelibs/android_frameworks_native/include/ui/DisplayStatInfo.h b/third_party/android_frameworks_native/include/ui/DisplayStatInfo.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/DisplayStatInfo.h rename to third_party/android_frameworks_native/include/ui/DisplayStatInfo.h diff --git a/phonelibs/android_frameworks_native/include/ui/Fence.h b/third_party/android_frameworks_native/include/ui/Fence.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/Fence.h rename to third_party/android_frameworks_native/include/ui/Fence.h diff --git a/phonelibs/android_frameworks_native/include/ui/FrameStats.h b/third_party/android_frameworks_native/include/ui/FrameStats.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/FrameStats.h rename to third_party/android_frameworks_native/include/ui/FrameStats.h diff --git a/phonelibs/android_frameworks_native/include/ui/FramebufferNativeWindow.h b/third_party/android_frameworks_native/include/ui/FramebufferNativeWindow.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/FramebufferNativeWindow.h rename to third_party/android_frameworks_native/include/ui/FramebufferNativeWindow.h diff --git a/phonelibs/android_frameworks_native/include/ui/GraphicBuffer.h b/third_party/android_frameworks_native/include/ui/GraphicBuffer.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/GraphicBuffer.h rename to third_party/android_frameworks_native/include/ui/GraphicBuffer.h diff --git a/phonelibs/android_frameworks_native/include/ui/GraphicBufferAllocator.h b/third_party/android_frameworks_native/include/ui/GraphicBufferAllocator.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/GraphicBufferAllocator.h rename to third_party/android_frameworks_native/include/ui/GraphicBufferAllocator.h diff --git a/phonelibs/android_frameworks_native/include/ui/GraphicBufferMapper.h b/third_party/android_frameworks_native/include/ui/GraphicBufferMapper.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/GraphicBufferMapper.h rename to third_party/android_frameworks_native/include/ui/GraphicBufferMapper.h diff --git a/phonelibs/android_frameworks_native/include/ui/PixelFormat.h b/third_party/android_frameworks_native/include/ui/PixelFormat.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/PixelFormat.h rename to third_party/android_frameworks_native/include/ui/PixelFormat.h diff --git a/phonelibs/android_frameworks_native/include/ui/Point.h b/third_party/android_frameworks_native/include/ui/Point.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/Point.h rename to third_party/android_frameworks_native/include/ui/Point.h diff --git a/phonelibs/android_frameworks_native/include/ui/Rect.h b/third_party/android_frameworks_native/include/ui/Rect.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/Rect.h rename to third_party/android_frameworks_native/include/ui/Rect.h diff --git a/phonelibs/android_frameworks_native/include/ui/Region.h b/third_party/android_frameworks_native/include/ui/Region.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/Region.h rename to third_party/android_frameworks_native/include/ui/Region.h diff --git a/phonelibs/android_frameworks_native/include/ui/TMatHelpers.h b/third_party/android_frameworks_native/include/ui/TMatHelpers.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/TMatHelpers.h rename to third_party/android_frameworks_native/include/ui/TMatHelpers.h diff --git a/phonelibs/android_frameworks_native/include/ui/TVecHelpers.h b/third_party/android_frameworks_native/include/ui/TVecHelpers.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/TVecHelpers.h rename to third_party/android_frameworks_native/include/ui/TVecHelpers.h diff --git a/phonelibs/android_frameworks_native/include/ui/UiConfig.h b/third_party/android_frameworks_native/include/ui/UiConfig.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/UiConfig.h rename to third_party/android_frameworks_native/include/ui/UiConfig.h diff --git a/phonelibs/android_frameworks_native/include/ui/mat4.h b/third_party/android_frameworks_native/include/ui/mat4.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/mat4.h rename to third_party/android_frameworks_native/include/ui/mat4.h diff --git a/phonelibs/android_frameworks_native/include/ui/vec2.h b/third_party/android_frameworks_native/include/ui/vec2.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/vec2.h rename to third_party/android_frameworks_native/include/ui/vec2.h diff --git a/phonelibs/android_frameworks_native/include/ui/vec3.h b/third_party/android_frameworks_native/include/ui/vec3.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/vec3.h rename to third_party/android_frameworks_native/include/ui/vec3.h diff --git a/phonelibs/android_frameworks_native/include/ui/vec4.h b/third_party/android_frameworks_native/include/ui/vec4.h similarity index 100% rename from phonelibs/android_frameworks_native/include/ui/vec4.h rename to third_party/android_frameworks_native/include/ui/vec4.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/activity_recognition.h b/third_party/android_hardware_libhardware/include/hardware/activity_recognition.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/activity_recognition.h rename to third_party/android_hardware_libhardware/include/hardware/activity_recognition.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/audio.h b/third_party/android_hardware_libhardware/include/hardware/audio.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/audio.h rename to third_party/android_hardware_libhardware/include/hardware/audio.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/audio_alsaops.h b/third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/audio_alsaops.h rename to third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/audio_amplifier.h b/third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/audio_amplifier.h rename to third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/audio_effect.h b/third_party/android_hardware_libhardware/include/hardware/audio_effect.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/audio_effect.h rename to third_party/android_hardware_libhardware/include/hardware/audio_effect.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/audio_policy.h b/third_party/android_hardware_libhardware/include/hardware/audio_policy.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/audio_policy.h rename to third_party/android_hardware_libhardware/include/hardware/audio_policy.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bluetooth.h b/third_party/android_hardware_libhardware/include/hardware/bluetooth.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bluetooth.h rename to third_party/android_hardware_libhardware/include/hardware/bluetooth.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_av.h b/third_party/android_hardware_libhardware/include/hardware/bt_av.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_av.h rename to third_party/android_hardware_libhardware/include/hardware/bt_av.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_common_types.h b/third_party/android_hardware_libhardware/include/hardware/bt_common_types.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_common_types.h rename to third_party/android_hardware_libhardware/include/hardware/bt_common_types.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_gatt.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_gatt.h rename to third_party/android_hardware_libhardware/include/hardware/bt_gatt.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_client.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_client.h rename to third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_server.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_server.h rename to third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_types.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_types.h rename to third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_hd.h b/third_party/android_hardware_libhardware/include/hardware/bt_hd.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_hd.h rename to third_party/android_hardware_libhardware/include/hardware/bt_hd.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_hf.h b/third_party/android_hardware_libhardware/include/hardware/bt_hf.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_hf.h rename to third_party/android_hardware_libhardware/include/hardware/bt_hf.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_hf_client.h b/third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_hf_client.h rename to third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_hh.h b/third_party/android_hardware_libhardware/include/hardware/bt_hh.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_hh.h rename to third_party/android_hardware_libhardware/include/hardware/bt_hh.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_hl.h b/third_party/android_hardware_libhardware/include/hardware/bt_hl.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_hl.h rename to third_party/android_hardware_libhardware/include/hardware/bt_hl.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_mce.h b/third_party/android_hardware_libhardware/include/hardware/bt_mce.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_mce.h rename to third_party/android_hardware_libhardware/include/hardware/bt_mce.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_pan.h b/third_party/android_hardware_libhardware/include/hardware/bt_pan.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_pan.h rename to third_party/android_hardware_libhardware/include/hardware/bt_pan.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_rc.h b/third_party/android_hardware_libhardware/include/hardware/bt_rc.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_rc.h rename to third_party/android_hardware_libhardware/include/hardware/bt_rc.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_sdp.h b/third_party/android_hardware_libhardware/include/hardware/bt_sdp.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_sdp.h rename to third_party/android_hardware_libhardware/include/hardware/bt_sdp.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/bt_sock.h b/third_party/android_hardware_libhardware/include/hardware/bt_sock.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/bt_sock.h rename to third_party/android_hardware_libhardware/include/hardware/bt_sock.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/camera.h b/third_party/android_hardware_libhardware/include/hardware/camera.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/camera.h rename to third_party/android_hardware_libhardware/include/hardware/camera.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/camera2.h b/third_party/android_hardware_libhardware/include/hardware/camera2.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/camera2.h rename to third_party/android_hardware_libhardware/include/hardware/camera2.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/camera3.h b/third_party/android_hardware_libhardware/include/hardware/camera3.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/camera3.h rename to third_party/android_hardware_libhardware/include/hardware/camera3.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/camera_common.h b/third_party/android_hardware_libhardware/include/hardware/camera_common.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/camera_common.h rename to third_party/android_hardware_libhardware/include/hardware/camera_common.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/consumerir.h b/third_party/android_hardware_libhardware/include/hardware/consumerir.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/consumerir.h rename to third_party/android_hardware_libhardware/include/hardware/consumerir.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/display_defs.h b/third_party/android_hardware_libhardware/include/hardware/display_defs.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/display_defs.h rename to third_party/android_hardware_libhardware/include/hardware/display_defs.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/fb.h b/third_party/android_hardware_libhardware/include/hardware/fb.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/fb.h rename to third_party/android_hardware_libhardware/include/hardware/fb.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/fingerprint.h b/third_party/android_hardware_libhardware/include/hardware/fingerprint.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/fingerprint.h rename to third_party/android_hardware_libhardware/include/hardware/fingerprint.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/fused_location.h b/third_party/android_hardware_libhardware/include/hardware/fused_location.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/fused_location.h rename to third_party/android_hardware_libhardware/include/hardware/fused_location.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/gatekeeper.h b/third_party/android_hardware_libhardware/include/hardware/gatekeeper.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/gatekeeper.h rename to third_party/android_hardware_libhardware/include/hardware/gatekeeper.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/gps.h b/third_party/android_hardware_libhardware/include/hardware/gps.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/gps.h rename to third_party/android_hardware_libhardware/include/hardware/gps.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/gralloc.h b/third_party/android_hardware_libhardware/include/hardware/gralloc.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/gralloc.h rename to third_party/android_hardware_libhardware/include/hardware/gralloc.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/hardware.h b/third_party/android_hardware_libhardware/include/hardware/hardware.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/hardware.h rename to third_party/android_hardware_libhardware/include/hardware/hardware.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/hdmi_cec.h b/third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/hdmi_cec.h rename to third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/hw_auth_token.h b/third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/hw_auth_token.h rename to third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/hwcomposer.h b/third_party/android_hardware_libhardware/include/hardware/hwcomposer.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/hwcomposer.h rename to third_party/android_hardware_libhardware/include/hardware/hwcomposer.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/hwcomposer_defs.h b/third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/hwcomposer_defs.h rename to third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/input.h b/third_party/android_hardware_libhardware/include/hardware/input.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/input.h rename to third_party/android_hardware_libhardware/include/hardware/input.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/keymaster0.h b/third_party/android_hardware_libhardware/include/hardware/keymaster0.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/keymaster0.h rename to third_party/android_hardware_libhardware/include/hardware/keymaster0.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/keymaster1.h b/third_party/android_hardware_libhardware/include/hardware/keymaster1.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/keymaster1.h rename to third_party/android_hardware_libhardware/include/hardware/keymaster1.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/keymaster_common.h b/third_party/android_hardware_libhardware/include/hardware/keymaster_common.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/keymaster_common.h rename to third_party/android_hardware_libhardware/include/hardware/keymaster_common.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/keymaster_defs.h b/third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/keymaster_defs.h rename to third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/lights.h b/third_party/android_hardware_libhardware/include/hardware/lights.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/lights.h rename to third_party/android_hardware_libhardware/include/hardware/lights.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/local_time_hal.h b/third_party/android_hardware_libhardware/include/hardware/local_time_hal.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/local_time_hal.h rename to third_party/android_hardware_libhardware/include/hardware/local_time_hal.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/memtrack.h b/third_party/android_hardware_libhardware/include/hardware/memtrack.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/memtrack.h rename to third_party/android_hardware_libhardware/include/hardware/memtrack.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/nfc.h b/third_party/android_hardware_libhardware/include/hardware/nfc.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/nfc.h rename to third_party/android_hardware_libhardware/include/hardware/nfc.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/nfc_tag.h b/third_party/android_hardware_libhardware/include/hardware/nfc_tag.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/nfc_tag.h rename to third_party/android_hardware_libhardware/include/hardware/nfc_tag.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/power.h b/third_party/android_hardware_libhardware/include/hardware/power.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/power.h rename to third_party/android_hardware_libhardware/include/hardware/power.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/qemu_pipe.h b/third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/qemu_pipe.h rename to third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/qemud.h b/third_party/android_hardware_libhardware/include/hardware/qemud.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/qemud.h rename to third_party/android_hardware_libhardware/include/hardware/qemud.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/radio.h b/third_party/android_hardware_libhardware/include/hardware/radio.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/radio.h rename to third_party/android_hardware_libhardware/include/hardware/radio.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/sensors.h b/third_party/android_hardware_libhardware/include/hardware/sensors.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/sensors.h rename to third_party/android_hardware_libhardware/include/hardware/sensors.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/sound_trigger.h b/third_party/android_hardware_libhardware/include/hardware/sound_trigger.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/sound_trigger.h rename to third_party/android_hardware_libhardware/include/hardware/sound_trigger.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/tv_input.h b/third_party/android_hardware_libhardware/include/hardware/tv_input.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/tv_input.h rename to third_party/android_hardware_libhardware/include/hardware/tv_input.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/vibrator.h b/third_party/android_hardware_libhardware/include/hardware/vibrator.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/vibrator.h rename to third_party/android_hardware_libhardware/include/hardware/vibrator.h diff --git a/phonelibs/android_hardware_libhardware/include/hardware/wipower.h b/third_party/android_hardware_libhardware/include/hardware/wipower.h similarity index 100% rename from phonelibs/android_hardware_libhardware/include/hardware/wipower.h rename to third_party/android_hardware_libhardware/include/hardware/wipower.h diff --git a/phonelibs/android_system_core/include/cutils/android_reboot.h b/third_party/android_system_core/include/cutils/android_reboot.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/android_reboot.h rename to third_party/android_system_core/include/cutils/android_reboot.h diff --git a/phonelibs/android_system_core/include/cutils/aref.h b/third_party/android_system_core/include/cutils/aref.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/aref.h rename to third_party/android_system_core/include/cutils/aref.h diff --git a/phonelibs/android_system_core/include/cutils/ashmem.h b/third_party/android_system_core/include/cutils/ashmem.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/ashmem.h rename to third_party/android_system_core/include/cutils/ashmem.h diff --git a/phonelibs/android_system_core/include/cutils/atomic.h b/third_party/android_system_core/include/cutils/atomic.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/atomic.h rename to third_party/android_system_core/include/cutils/atomic.h diff --git a/phonelibs/android_system_core/include/cutils/bitops.h b/third_party/android_system_core/include/cutils/bitops.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/bitops.h rename to third_party/android_system_core/include/cutils/bitops.h diff --git a/phonelibs/android_system_core/include/cutils/compiler.h b/third_party/android_system_core/include/cutils/compiler.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/compiler.h rename to third_party/android_system_core/include/cutils/compiler.h diff --git a/phonelibs/android_system_core/include/cutils/config_utils.h b/third_party/android_system_core/include/cutils/config_utils.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/config_utils.h rename to third_party/android_system_core/include/cutils/config_utils.h diff --git a/phonelibs/android_system_core/include/cutils/debugger.h b/third_party/android_system_core/include/cutils/debugger.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/debugger.h rename to third_party/android_system_core/include/cutils/debugger.h diff --git a/phonelibs/android_system_core/include/cutils/fs.h b/third_party/android_system_core/include/cutils/fs.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/fs.h rename to third_party/android_system_core/include/cutils/fs.h diff --git a/phonelibs/android_system_core/include/cutils/hashmap.h b/third_party/android_system_core/include/cutils/hashmap.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/hashmap.h rename to third_party/android_system_core/include/cutils/hashmap.h diff --git a/phonelibs/android_system_core/include/cutils/iosched_policy.h b/third_party/android_system_core/include/cutils/iosched_policy.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/iosched_policy.h rename to third_party/android_system_core/include/cutils/iosched_policy.h diff --git a/phonelibs/android_system_core/include/cutils/jstring.h b/third_party/android_system_core/include/cutils/jstring.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/jstring.h rename to third_party/android_system_core/include/cutils/jstring.h diff --git a/phonelibs/android_system_core/include/cutils/klog.h b/third_party/android_system_core/include/cutils/klog.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/klog.h rename to third_party/android_system_core/include/cutils/klog.h diff --git a/phonelibs/android_system_core/include/cutils/list.h b/third_party/android_system_core/include/cutils/list.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/list.h rename to third_party/android_system_core/include/cutils/list.h diff --git a/phonelibs/android_system_core/include/cutils/log.h b/third_party/android_system_core/include/cutils/log.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/log.h rename to third_party/android_system_core/include/cutils/log.h diff --git a/phonelibs/android_system_core/include/cutils/memory.h b/third_party/android_system_core/include/cutils/memory.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/memory.h rename to third_party/android_system_core/include/cutils/memory.h diff --git a/phonelibs/android_system_core/include/cutils/misc.h b/third_party/android_system_core/include/cutils/misc.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/misc.h rename to third_party/android_system_core/include/cutils/misc.h diff --git a/phonelibs/android_system_core/include/cutils/multiuser.h b/third_party/android_system_core/include/cutils/multiuser.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/multiuser.h rename to third_party/android_system_core/include/cutils/multiuser.h diff --git a/phonelibs/android_system_core/include/cutils/native_handle.h b/third_party/android_system_core/include/cutils/native_handle.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/native_handle.h rename to third_party/android_system_core/include/cutils/native_handle.h diff --git a/phonelibs/android_system_core/include/cutils/open_memstream.h b/third_party/android_system_core/include/cutils/open_memstream.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/open_memstream.h rename to third_party/android_system_core/include/cutils/open_memstream.h diff --git a/phonelibs/android_system_core/include/cutils/partition_utils.h b/third_party/android_system_core/include/cutils/partition_utils.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/partition_utils.h rename to third_party/android_system_core/include/cutils/partition_utils.h diff --git a/phonelibs/android_system_core/include/cutils/process_name.h b/third_party/android_system_core/include/cutils/process_name.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/process_name.h rename to third_party/android_system_core/include/cutils/process_name.h diff --git a/phonelibs/android_system_core/include/cutils/properties.h b/third_party/android_system_core/include/cutils/properties.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/properties.h rename to third_party/android_system_core/include/cutils/properties.h diff --git a/phonelibs/android_system_core/include/cutils/qtaguid.h b/third_party/android_system_core/include/cutils/qtaguid.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/qtaguid.h rename to third_party/android_system_core/include/cutils/qtaguid.h diff --git a/phonelibs/android_system_core/include/cutils/record_stream.h b/third_party/android_system_core/include/cutils/record_stream.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/record_stream.h rename to third_party/android_system_core/include/cutils/record_stream.h diff --git a/phonelibs/android_system_core/include/cutils/sched_policy.h b/third_party/android_system_core/include/cutils/sched_policy.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/sched_policy.h rename to third_party/android_system_core/include/cutils/sched_policy.h diff --git a/phonelibs/android_system_core/include/cutils/sockets.h b/third_party/android_system_core/include/cutils/sockets.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/sockets.h rename to third_party/android_system_core/include/cutils/sockets.h diff --git a/phonelibs/android_system_core/include/cutils/str_parms.h b/third_party/android_system_core/include/cutils/str_parms.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/str_parms.h rename to third_party/android_system_core/include/cutils/str_parms.h diff --git a/phonelibs/android_system_core/include/cutils/threads.h b/third_party/android_system_core/include/cutils/threads.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/threads.h rename to third_party/android_system_core/include/cutils/threads.h diff --git a/phonelibs/android_system_core/include/cutils/trace.h b/third_party/android_system_core/include/cutils/trace.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/trace.h rename to third_party/android_system_core/include/cutils/trace.h diff --git a/phonelibs/android_system_core/include/cutils/uevent.h b/third_party/android_system_core/include/cutils/uevent.h similarity index 100% rename from phonelibs/android_system_core/include/cutils/uevent.h rename to third_party/android_system_core/include/cutils/uevent.h diff --git a/phonelibs/android_system_core/include/log/event_tag_map.h b/third_party/android_system_core/include/log/event_tag_map.h similarity index 100% rename from phonelibs/android_system_core/include/log/event_tag_map.h rename to third_party/android_system_core/include/log/event_tag_map.h diff --git a/phonelibs/android_system_core/include/log/log.h b/third_party/android_system_core/include/log/log.h similarity index 100% rename from phonelibs/android_system_core/include/log/log.h rename to third_party/android_system_core/include/log/log.h diff --git a/phonelibs/android_system_core/include/log/log_read.h b/third_party/android_system_core/include/log/log_read.h similarity index 100% rename from phonelibs/android_system_core/include/log/log_read.h rename to third_party/android_system_core/include/log/log_read.h diff --git a/phonelibs/android_system_core/include/log/logd.h b/third_party/android_system_core/include/log/logd.h similarity index 100% rename from phonelibs/android_system_core/include/log/logd.h rename to third_party/android_system_core/include/log/logd.h diff --git a/phonelibs/android_system_core/include/log/logger.h b/third_party/android_system_core/include/log/logger.h similarity index 100% rename from phonelibs/android_system_core/include/log/logger.h rename to third_party/android_system_core/include/log/logger.h diff --git a/phonelibs/android_system_core/include/log/logprint.h b/third_party/android_system_core/include/log/logprint.h similarity index 100% rename from phonelibs/android_system_core/include/log/logprint.h rename to third_party/android_system_core/include/log/logprint.h diff --git a/phonelibs/android_system_core/include/log/uio.h b/third_party/android_system_core/include/log/uio.h similarity index 100% rename from phonelibs/android_system_core/include/log/uio.h rename to third_party/android_system_core/include/log/uio.h diff --git a/phonelibs/android_system_core/include/system/camera.h b/third_party/android_system_core/include/system/camera.h similarity index 100% rename from phonelibs/android_system_core/include/system/camera.h rename to third_party/android_system_core/include/system/camera.h diff --git a/phonelibs/android_system_core/include/system/graphics.h b/third_party/android_system_core/include/system/graphics.h similarity index 100% rename from phonelibs/android_system_core/include/system/graphics.h rename to third_party/android_system_core/include/system/graphics.h diff --git a/phonelibs/android_system_core/include/system/radio.h b/third_party/android_system_core/include/system/radio.h similarity index 100% rename from phonelibs/android_system_core/include/system/radio.h rename to third_party/android_system_core/include/system/radio.h diff --git a/phonelibs/android_system_core/include/system/thread_defs.h b/third_party/android_system_core/include/system/thread_defs.h similarity index 100% rename from phonelibs/android_system_core/include/system/thread_defs.h rename to third_party/android_system_core/include/system/thread_defs.h diff --git a/phonelibs/android_system_core/include/system/window.h b/third_party/android_system_core/include/system/window.h similarity index 100% rename from phonelibs/android_system_core/include/system/window.h rename to third_party/android_system_core/include/system/window.h diff --git a/phonelibs/android_system_core/include/utils/AndroidThreads.h b/third_party/android_system_core/include/utils/AndroidThreads.h similarity index 100% rename from phonelibs/android_system_core/include/utils/AndroidThreads.h rename to third_party/android_system_core/include/utils/AndroidThreads.h diff --git a/phonelibs/android_system_core/include/utils/Atomic.h b/third_party/android_system_core/include/utils/Atomic.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Atomic.h rename to third_party/android_system_core/include/utils/Atomic.h diff --git a/phonelibs/android_system_core/include/utils/BasicHashtable.h b/third_party/android_system_core/include/utils/BasicHashtable.h similarity index 100% rename from phonelibs/android_system_core/include/utils/BasicHashtable.h rename to third_party/android_system_core/include/utils/BasicHashtable.h diff --git a/phonelibs/android_system_core/include/utils/BitSet.h b/third_party/android_system_core/include/utils/BitSet.h similarity index 100% rename from phonelibs/android_system_core/include/utils/BitSet.h rename to third_party/android_system_core/include/utils/BitSet.h diff --git a/phonelibs/android_system_core/include/utils/BlobCache.h b/third_party/android_system_core/include/utils/BlobCache.h similarity index 100% rename from phonelibs/android_system_core/include/utils/BlobCache.h rename to third_party/android_system_core/include/utils/BlobCache.h diff --git a/phonelibs/android_system_core/include/utils/ByteOrder.h b/third_party/android_system_core/include/utils/ByteOrder.h similarity index 100% rename from phonelibs/android_system_core/include/utils/ByteOrder.h rename to third_party/android_system_core/include/utils/ByteOrder.h diff --git a/phonelibs/android_system_core/include/utils/CallStack.h b/third_party/android_system_core/include/utils/CallStack.h similarity index 100% rename from phonelibs/android_system_core/include/utils/CallStack.h rename to third_party/android_system_core/include/utils/CallStack.h diff --git a/phonelibs/android_system_core/include/utils/Compat.h b/third_party/android_system_core/include/utils/Compat.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Compat.h rename to third_party/android_system_core/include/utils/Compat.h diff --git a/phonelibs/android_system_core/include/utils/Condition.h b/third_party/android_system_core/include/utils/Condition.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Condition.h rename to third_party/android_system_core/include/utils/Condition.h diff --git a/phonelibs/android_system_core/include/utils/Debug.h b/third_party/android_system_core/include/utils/Debug.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Debug.h rename to third_party/android_system_core/include/utils/Debug.h diff --git a/phonelibs/android_system_core/include/utils/Endian.h b/third_party/android_system_core/include/utils/Endian.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Endian.h rename to third_party/android_system_core/include/utils/Endian.h diff --git a/phonelibs/android_system_core/include/utils/Errors.h b/third_party/android_system_core/include/utils/Errors.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Errors.h rename to third_party/android_system_core/include/utils/Errors.h diff --git a/phonelibs/android_system_core/include/utils/FileMap.h b/third_party/android_system_core/include/utils/FileMap.h similarity index 100% rename from phonelibs/android_system_core/include/utils/FileMap.h rename to third_party/android_system_core/include/utils/FileMap.h diff --git a/phonelibs/android_system_core/include/utils/Flattenable.h b/third_party/android_system_core/include/utils/Flattenable.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Flattenable.h rename to third_party/android_system_core/include/utils/Flattenable.h diff --git a/phonelibs/android_system_core/include/utils/Functor.h b/third_party/android_system_core/include/utils/Functor.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Functor.h rename to third_party/android_system_core/include/utils/Functor.h diff --git a/phonelibs/android_system_core/include/utils/JenkinsHash.h b/third_party/android_system_core/include/utils/JenkinsHash.h similarity index 100% rename from phonelibs/android_system_core/include/utils/JenkinsHash.h rename to third_party/android_system_core/include/utils/JenkinsHash.h diff --git a/phonelibs/android_system_core/include/utils/KeyedVector.h b/third_party/android_system_core/include/utils/KeyedVector.h similarity index 100% rename from phonelibs/android_system_core/include/utils/KeyedVector.h rename to third_party/android_system_core/include/utils/KeyedVector.h diff --git a/phonelibs/android_system_core/include/utils/LinearTransform.h b/third_party/android_system_core/include/utils/LinearTransform.h similarity index 100% rename from phonelibs/android_system_core/include/utils/LinearTransform.h rename to third_party/android_system_core/include/utils/LinearTransform.h diff --git a/phonelibs/android_system_core/include/utils/List.h b/third_party/android_system_core/include/utils/List.h similarity index 100% rename from phonelibs/android_system_core/include/utils/List.h rename to third_party/android_system_core/include/utils/List.h diff --git a/phonelibs/android_system_core/include/utils/Log.h b/third_party/android_system_core/include/utils/Log.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Log.h rename to third_party/android_system_core/include/utils/Log.h diff --git a/phonelibs/android_system_core/include/utils/Looper.h b/third_party/android_system_core/include/utils/Looper.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Looper.h rename to third_party/android_system_core/include/utils/Looper.h diff --git a/phonelibs/android_system_core/include/utils/LruCache.h b/third_party/android_system_core/include/utils/LruCache.h similarity index 100% rename from phonelibs/android_system_core/include/utils/LruCache.h rename to third_party/android_system_core/include/utils/LruCache.h diff --git a/phonelibs/android_system_core/include/utils/Mutex.h b/third_party/android_system_core/include/utils/Mutex.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Mutex.h rename to third_party/android_system_core/include/utils/Mutex.h diff --git a/phonelibs/android_system_core/include/utils/NativeHandle.h b/third_party/android_system_core/include/utils/NativeHandle.h similarity index 100% rename from phonelibs/android_system_core/include/utils/NativeHandle.h rename to third_party/android_system_core/include/utils/NativeHandle.h diff --git a/phonelibs/android_system_core/include/utils/Printer.h b/third_party/android_system_core/include/utils/Printer.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Printer.h rename to third_party/android_system_core/include/utils/Printer.h diff --git a/phonelibs/android_system_core/include/utils/ProcessCallStack.h b/third_party/android_system_core/include/utils/ProcessCallStack.h similarity index 100% rename from phonelibs/android_system_core/include/utils/ProcessCallStack.h rename to third_party/android_system_core/include/utils/ProcessCallStack.h diff --git a/phonelibs/android_system_core/include/utils/PropertyMap.h b/third_party/android_system_core/include/utils/PropertyMap.h similarity index 100% rename from phonelibs/android_system_core/include/utils/PropertyMap.h rename to third_party/android_system_core/include/utils/PropertyMap.h diff --git a/phonelibs/android_system_core/include/utils/RWLock.h b/third_party/android_system_core/include/utils/RWLock.h similarity index 100% rename from phonelibs/android_system_core/include/utils/RWLock.h rename to third_party/android_system_core/include/utils/RWLock.h diff --git a/phonelibs/android_system_core/include/utils/RefBase.h b/third_party/android_system_core/include/utils/RefBase.h similarity index 100% rename from phonelibs/android_system_core/include/utils/RefBase.h rename to third_party/android_system_core/include/utils/RefBase.h diff --git a/phonelibs/android_system_core/include/utils/SharedBuffer.h b/third_party/android_system_core/include/utils/SharedBuffer.h similarity index 100% rename from phonelibs/android_system_core/include/utils/SharedBuffer.h rename to third_party/android_system_core/include/utils/SharedBuffer.h diff --git a/phonelibs/android_system_core/include/utils/Singleton.h b/third_party/android_system_core/include/utils/Singleton.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Singleton.h rename to third_party/android_system_core/include/utils/Singleton.h diff --git a/phonelibs/android_system_core/include/utils/SortedVector.h b/third_party/android_system_core/include/utils/SortedVector.h similarity index 100% rename from phonelibs/android_system_core/include/utils/SortedVector.h rename to third_party/android_system_core/include/utils/SortedVector.h diff --git a/phonelibs/android_system_core/include/utils/StopWatch.h b/third_party/android_system_core/include/utils/StopWatch.h similarity index 100% rename from phonelibs/android_system_core/include/utils/StopWatch.h rename to third_party/android_system_core/include/utils/StopWatch.h diff --git a/phonelibs/android_system_core/include/utils/String16.h b/third_party/android_system_core/include/utils/String16.h similarity index 100% rename from phonelibs/android_system_core/include/utils/String16.h rename to third_party/android_system_core/include/utils/String16.h diff --git a/phonelibs/android_system_core/include/utils/String8.h b/third_party/android_system_core/include/utils/String8.h similarity index 100% rename from phonelibs/android_system_core/include/utils/String8.h rename to third_party/android_system_core/include/utils/String8.h diff --git a/phonelibs/android_system_core/include/utils/StrongPointer.h b/third_party/android_system_core/include/utils/StrongPointer.h similarity index 100% rename from phonelibs/android_system_core/include/utils/StrongPointer.h rename to third_party/android_system_core/include/utils/StrongPointer.h diff --git a/phonelibs/android_system_core/include/utils/SystemClock.h b/third_party/android_system_core/include/utils/SystemClock.h similarity index 100% rename from phonelibs/android_system_core/include/utils/SystemClock.h rename to third_party/android_system_core/include/utils/SystemClock.h diff --git a/phonelibs/android_system_core/include/utils/Thread.h b/third_party/android_system_core/include/utils/Thread.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Thread.h rename to third_party/android_system_core/include/utils/Thread.h diff --git a/phonelibs/android_system_core/include/utils/ThreadDefs.h b/third_party/android_system_core/include/utils/ThreadDefs.h similarity index 100% rename from phonelibs/android_system_core/include/utils/ThreadDefs.h rename to third_party/android_system_core/include/utils/ThreadDefs.h diff --git a/phonelibs/android_system_core/include/utils/Timers.h b/third_party/android_system_core/include/utils/Timers.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Timers.h rename to third_party/android_system_core/include/utils/Timers.h diff --git a/phonelibs/android_system_core/include/utils/Tokenizer.h b/third_party/android_system_core/include/utils/Tokenizer.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Tokenizer.h rename to third_party/android_system_core/include/utils/Tokenizer.h diff --git a/phonelibs/android_system_core/include/utils/Trace.h b/third_party/android_system_core/include/utils/Trace.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Trace.h rename to third_party/android_system_core/include/utils/Trace.h diff --git a/phonelibs/android_system_core/include/utils/TypeHelpers.h b/third_party/android_system_core/include/utils/TypeHelpers.h similarity index 100% rename from phonelibs/android_system_core/include/utils/TypeHelpers.h rename to third_party/android_system_core/include/utils/TypeHelpers.h diff --git a/phonelibs/android_system_core/include/utils/Unicode.h b/third_party/android_system_core/include/utils/Unicode.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Unicode.h rename to third_party/android_system_core/include/utils/Unicode.h diff --git a/phonelibs/android_system_core/include/utils/Vector.h b/third_party/android_system_core/include/utils/Vector.h similarity index 100% rename from phonelibs/android_system_core/include/utils/Vector.h rename to third_party/android_system_core/include/utils/Vector.h diff --git a/phonelibs/android_system_core/include/utils/VectorImpl.h b/third_party/android_system_core/include/utils/VectorImpl.h similarity index 100% rename from phonelibs/android_system_core/include/utils/VectorImpl.h rename to third_party/android_system_core/include/utils/VectorImpl.h diff --git a/phonelibs/android_system_core/include/utils/ashmem.h b/third_party/android_system_core/include/utils/ashmem.h similarity index 100% rename from phonelibs/android_system_core/include/utils/ashmem.h rename to third_party/android_system_core/include/utils/ashmem.h diff --git a/phonelibs/android_system_core/include/utils/misc.h b/third_party/android_system_core/include/utils/misc.h similarity index 100% rename from phonelibs/android_system_core/include/utils/misc.h rename to third_party/android_system_core/include/utils/misc.h diff --git a/phonelibs/android_system_core/include/utils/threads.h b/third_party/android_system_core/include/utils/threads.h similarity index 100% rename from phonelibs/android_system_core/include/utils/threads.h rename to third_party/android_system_core/include/utils/threads.h diff --git a/third_party/bzip2/LICENSE b/third_party/bzip2/LICENSE new file mode 100644 index 00000000000000..cc614178cf7958 --- /dev/null +++ b/third_party/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/bzip2/build.txt b/third_party/bzip2/build.txt similarity index 100% rename from phonelibs/bzip2/build.txt rename to third_party/bzip2/build.txt diff --git a/phonelibs/bzip2/bzlib.h b/third_party/bzip2/bzlib.h similarity index 100% rename from phonelibs/bzip2/bzlib.h rename to third_party/bzip2/bzlib.h diff --git a/phonelibs/bzip2/libbz2.a b/third_party/bzip2/libbz2.a similarity index 100% rename from phonelibs/bzip2/libbz2.a rename to third_party/bzip2/libbz2.a diff --git a/phonelibs/json11/json11.cpp b/third_party/json11/json11.cpp similarity index 100% rename from phonelibs/json11/json11.cpp rename to third_party/json11/json11.cpp diff --git a/phonelibs/json11/json11.hpp b/third_party/json11/json11.hpp similarity index 100% rename from phonelibs/json11/json11.hpp rename to third_party/json11/json11.hpp diff --git a/third_party/kaitai/custom_decoder.h b/third_party/kaitai/custom_decoder.h new file mode 100644 index 00000000000000..6da7f5fd23cd63 --- /dev/null +++ b/third_party/kaitai/custom_decoder.h @@ -0,0 +1,16 @@ +#ifndef KAITAI_CUSTOM_DECODER_H +#define KAITAI_CUSTOM_DECODER_H + +#include + +namespace kaitai { + +class custom_decoder { +public: + virtual ~custom_decoder() {}; + virtual std::string decode(std::string src) = 0; +}; + +} + +#endif diff --git a/third_party/kaitai/exceptions.h b/third_party/kaitai/exceptions.h new file mode 100644 index 00000000000000..5c09c4672b8c25 --- /dev/null +++ b/third_party/kaitai/exceptions.h @@ -0,0 +1,189 @@ +#ifndef KAITAI_EXCEPTIONS_H +#define KAITAI_EXCEPTIONS_H + +#include + +#include +#include + +// We need to use "noexcept" in virtual destructor of our exceptions +// subclasses. Different compilers have different ideas on how to +// achieve that: C++98 compilers prefer `throw()`, C++11 and later +// use `noexcept`. We define KS_NOEXCEPT macro for that. + +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) +#define KS_NOEXCEPT noexcept +#else +#define KS_NOEXCEPT throw() +#endif + +namespace kaitai { + +/** + * Common ancestor for all error originating from Kaitai Struct usage. + * Stores KSY source path, pointing to an element supposedly guilty of + * an error. + */ +class kstruct_error: public std::runtime_error { +public: + kstruct_error(const std::string what, const std::string src_path): + std::runtime_error(src_path + ": " + what), + m_src_path(src_path) + { + } + + virtual ~kstruct_error() KS_NOEXCEPT {}; + +protected: + const std::string m_src_path; +}; + +/** + * Error that occurs when default endianness should be decided with + * a switch, but nothing matches (although using endianness expression + * implies that there should be some positive result). + */ +class undecided_endianness_error: public kstruct_error { +public: + undecided_endianness_error(const std::string src_path): + kstruct_error("unable to decide on endianness for a type", src_path) + { + } + + virtual ~undecided_endianness_error() KS_NOEXCEPT {}; +}; + +/** + * Common ancestor for all validation failures. Stores pointer to + * KaitaiStream IO object which was involved in an error. + */ +class validation_failed_error: public kstruct_error { +public: + validation_failed_error(const std::string what, kstream* io, const std::string src_path): + kstruct_error("at pos " + kstream::to_string(static_cast(io->pos())) + ": validation failed: " + what, src_path), + m_io(io) + { + } + +// "at pos #{io.pos}: validation failed: #{msg}" + + virtual ~validation_failed_error() KS_NOEXCEPT {}; + +protected: + kstream* m_io; +}; + +/** + * Signals validation failure: we required "actual" value to be equal to + * "expected", but it turned out that it's not. + */ +template +class validation_not_equal_error: public validation_failed_error { +public: + validation_not_equal_error(const T& expected, const T& actual, kstream* io, const std::string src_path): + validation_failed_error("not equal", io, src_path), + m_expected(expected), + m_actual(actual) + { + } + + // "not equal, expected #{expected.inspect}, but got #{actual.inspect}" + + virtual ~validation_not_equal_error() KS_NOEXCEPT {}; + +protected: + const T& m_expected; + const T& m_actual; +}; + +/** + * Signals validation failure: we required "actual" value to be greater + * than or equal to "min", but it turned out that it's not. + */ +template +class validation_less_than_error: public validation_failed_error { +public: + validation_less_than_error(const T& min, const T& actual, kstream* io, const std::string src_path): + validation_failed_error("not in range", io, src_path), + m_min(min), + m_actual(actual) + { + } + + // "not in range, min #{min.inspect}, but got #{actual.inspect}" + + virtual ~validation_less_than_error() KS_NOEXCEPT {}; + +protected: + const T& m_min; + const T& m_actual; +}; + +/** + * Signals validation failure: we required "actual" value to be less + * than or equal to "max", but it turned out that it's not. + */ +template +class validation_greater_than_error: public validation_failed_error { +public: + validation_greater_than_error(const T& max, const T& actual, kstream* io, const std::string src_path): + validation_failed_error("not in range", io, src_path), + m_max(max), + m_actual(actual) + { + } + + // "not in range, max #{max.inspect}, but got #{actual.inspect}" + + virtual ~validation_greater_than_error() KS_NOEXCEPT {}; + +protected: + const T& m_max; + const T& m_actual; +}; + +/** + * Signals validation failure: we required "actual" value to be from + * the list, but it turned out that it's not. + */ +template +class validation_not_any_of_error: public validation_failed_error { +public: + validation_not_any_of_error(const T& actual, kstream* io, const std::string src_path): + validation_failed_error("not any of the list", io, src_path), + m_actual(actual) + { + } + + // "not any of the list, got #{actual.inspect}" + + virtual ~validation_not_any_of_error() KS_NOEXCEPT {}; + +protected: + const T& m_actual; +}; + +/** + * Signals validation failure: we required "actual" value to match + * the expression, but it turned out that it doesn't. + */ +template +class validation_expr_error: public validation_failed_error { +public: + validation_expr_error(const T& actual, kstream* io, const std::string src_path): + validation_failed_error("not matching the expression", io, src_path), + m_actual(actual) + { + } + + // "not matching the expression, got #{actual.inspect}" + + virtual ~validation_expr_error() KS_NOEXCEPT {}; + +protected: + const T& m_actual; +}; + +} + +#endif diff --git a/third_party/kaitai/kaitaistream.cpp b/third_party/kaitai/kaitaistream.cpp new file mode 100644 index 00000000000000..d82ddb7e8279ec --- /dev/null +++ b/third_party/kaitai/kaitaistream.cpp @@ -0,0 +1,689 @@ +#include + +#if defined(__APPLE__) +#include +#include +#define bswap_16(x) OSSwapInt16(x) +#define bswap_32(x) OSSwapInt32(x) +#define bswap_64(x) OSSwapInt64(x) +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +#define __LITTLE_ENDIAN LITTLE_ENDIAN +#elif defined(_MSC_VER) // !__APPLE__ +#include +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __BYTE_ORDER __LITTLE_ENDIAN +#define bswap_16(x) _byteswap_ushort(x) +#define bswap_32(x) _byteswap_ulong(x) +#define bswap_64(x) _byteswap_uint64(x) +#else // !__APPLE__ or !_MSC_VER +#include +#include +#endif + +#include +#include +#include + +kaitai::kstream::kstream(std::istream* io) { + m_io = io; + init(); +} + +kaitai::kstream::kstream(std::string& data): m_io_str(data) { + m_io = &m_io_str; + init(); +} + +void kaitai::kstream::init() { + exceptions_enable(); + align_to_byte(); +} + +void kaitai::kstream::close() { + // m_io->close(); +} + +void kaitai::kstream::exceptions_enable() const { + m_io->exceptions( + std::istream::eofbit | + std::istream::failbit | + std::istream::badbit + ); +} + +// ======================================================================== +// Stream positioning +// ======================================================================== + +bool kaitai::kstream::is_eof() const { + if (m_bits_left > 0) { + return false; + } + char t; + m_io->exceptions( + std::istream::badbit + ); + m_io->get(t); + if (m_io->eof()) { + m_io->clear(); + exceptions_enable(); + return true; + } else { + m_io->unget(); + exceptions_enable(); + return false; + } +} + +void kaitai::kstream::seek(uint64_t pos) { + m_io->seekg(pos); +} + +uint64_t kaitai::kstream::pos() { + return m_io->tellg(); +} + +uint64_t kaitai::kstream::size() { + std::iostream::pos_type cur_pos = m_io->tellg(); + m_io->seekg(0, std::ios::end); + std::iostream::pos_type len = m_io->tellg(); + m_io->seekg(cur_pos); + return len; +} + +// ======================================================================== +// Integer numbers +// ======================================================================== + +// ------------------------------------------------------------------------ +// Signed +// ------------------------------------------------------------------------ + +int8_t kaitai::kstream::read_s1() { + char t; + m_io->get(t); + return t; +} + +// ........................................................................ +// Big-endian +// ........................................................................ + +int16_t kaitai::kstream::read_s2be() { + int16_t t; + m_io->read(reinterpret_cast(&t), 2); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_16(t); +#endif + return t; +} + +int32_t kaitai::kstream::read_s4be() { + int32_t t; + m_io->read(reinterpret_cast(&t), 4); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_32(t); +#endif + return t; +} + +int64_t kaitai::kstream::read_s8be() { + int64_t t; + m_io->read(reinterpret_cast(&t), 8); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_64(t); +#endif + return t; +} + +// ........................................................................ +// Little-endian +// ........................................................................ + +int16_t kaitai::kstream::read_s2le() { + int16_t t; + m_io->read(reinterpret_cast(&t), 2); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_16(t); +#endif + return t; +} + +int32_t kaitai::kstream::read_s4le() { + int32_t t; + m_io->read(reinterpret_cast(&t), 4); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_32(t); +#endif + return t; +} + +int64_t kaitai::kstream::read_s8le() { + int64_t t; + m_io->read(reinterpret_cast(&t), 8); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_64(t); +#endif + return t; +} + +// ------------------------------------------------------------------------ +// Unsigned +// ------------------------------------------------------------------------ + +uint8_t kaitai::kstream::read_u1() { + char t; + m_io->get(t); + return t; +} + +// ........................................................................ +// Big-endian +// ........................................................................ + +uint16_t kaitai::kstream::read_u2be() { + uint16_t t; + m_io->read(reinterpret_cast(&t), 2); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_16(t); +#endif + return t; +} + +uint32_t kaitai::kstream::read_u4be() { + uint32_t t; + m_io->read(reinterpret_cast(&t), 4); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_32(t); +#endif + return t; +} + +uint64_t kaitai::kstream::read_u8be() { + uint64_t t; + m_io->read(reinterpret_cast(&t), 8); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_64(t); +#endif + return t; +} + +// ........................................................................ +// Little-endian +// ........................................................................ + +uint16_t kaitai::kstream::read_u2le() { + uint16_t t; + m_io->read(reinterpret_cast(&t), 2); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_16(t); +#endif + return t; +} + +uint32_t kaitai::kstream::read_u4le() { + uint32_t t; + m_io->read(reinterpret_cast(&t), 4); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_32(t); +#endif + return t; +} + +uint64_t kaitai::kstream::read_u8le() { + uint64_t t; + m_io->read(reinterpret_cast(&t), 8); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_64(t); +#endif + return t; +} + +// ======================================================================== +// Floating point numbers +// ======================================================================== + +// ........................................................................ +// Big-endian +// ........................................................................ + +float kaitai::kstream::read_f4be() { + uint32_t t; + m_io->read(reinterpret_cast(&t), 4); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_32(t); +#endif + return reinterpret_cast(t); +} + +double kaitai::kstream::read_f8be() { + uint64_t t; + m_io->read(reinterpret_cast(&t), 8); +#if __BYTE_ORDER == __LITTLE_ENDIAN + t = bswap_64(t); +#endif + return reinterpret_cast(t); +} + +// ........................................................................ +// Little-endian +// ........................................................................ + +float kaitai::kstream::read_f4le() { + uint32_t t; + m_io->read(reinterpret_cast(&t), 4); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_32(t); +#endif + return reinterpret_cast(t); +} + +double kaitai::kstream::read_f8le() { + uint64_t t; + m_io->read(reinterpret_cast(&t), 8); +#if __BYTE_ORDER == __BIG_ENDIAN + t = bswap_64(t); +#endif + return reinterpret_cast(t); +} + +// ======================================================================== +// Unaligned bit values +// ======================================================================== + +void kaitai::kstream::align_to_byte() { + m_bits_left = 0; + m_bits = 0; +} + +uint64_t kaitai::kstream::read_bits_int_be(int n) { + int bits_needed = n - m_bits_left; + if (bits_needed > 0) { + // 1 bit => 1 byte + // 8 bits => 1 byte + // 9 bits => 2 bytes + int bytes_needed = ((bits_needed - 1) / 8) + 1; + if (bytes_needed > 8) + throw std::runtime_error("read_bits_int: more than 8 bytes requested"); + char buf[8]; + m_io->read(buf, bytes_needed); + for (int i = 0; i < bytes_needed; i++) { + uint8_t b = buf[i]; + m_bits <<= 8; + m_bits |= b; + m_bits_left += 8; + } + } + + // raw mask with required number of 1s, starting from lowest bit + uint64_t mask = get_mask_ones(n); + // shift mask to align with highest bits available in @bits + int shift_bits = m_bits_left - n; + mask <<= shift_bits; + // derive reading result + uint64_t res = (m_bits & mask) >> shift_bits; + // clear top bits that we've just read => AND with 1s + m_bits_left -= n; + mask = get_mask_ones(m_bits_left); + m_bits &= mask; + + return res; +} + +// Deprecated, use read_bits_int_be() instead. +uint64_t kaitai::kstream::read_bits_int(int n) { + return read_bits_int_be(n); +} + +uint64_t kaitai::kstream::read_bits_int_le(int n) { + int bits_needed = n - m_bits_left; + if (bits_needed > 0) { + // 1 bit => 1 byte + // 8 bits => 1 byte + // 9 bits => 2 bytes + int bytes_needed = ((bits_needed - 1) / 8) + 1; + if (bytes_needed > 8) + throw std::runtime_error("read_bits_int_le: more than 8 bytes requested"); + char buf[8]; + m_io->read(buf, bytes_needed); + for (int i = 0; i < bytes_needed; i++) { + uint8_t b = buf[i]; + m_bits |= (static_cast(b) << m_bits_left); + m_bits_left += 8; + } + } + + // raw mask with required number of 1s, starting from lowest bit + uint64_t mask = get_mask_ones(n); + // derive reading result + uint64_t res = m_bits & mask; + // remove bottom bits that we've just read by shifting + m_bits >>= n; + m_bits_left -= n; + + return res; +} + +uint64_t kaitai::kstream::get_mask_ones(int n) { + if (n == 64) { + return 0xFFFFFFFFFFFFFFFF; + } else { + return ((uint64_t) 1 << n) - 1; + } +} + +// ======================================================================== +// Byte arrays +// ======================================================================== + +std::string kaitai::kstream::read_bytes(std::streamsize len) { + std::vector result(len); + + // NOTE: streamsize type is signed, negative values are only *supposed* to not be used. + // http://en.cppreference.com/w/cpp/io/streamsize + if (len < 0) { + throw std::runtime_error("read_bytes: requested a negative amount"); + } + + if (len > 0) { + m_io->read(&result[0], len); + } + + return std::string(result.begin(), result.end()); +} + +std::string kaitai::kstream::read_bytes_full() { + std::iostream::pos_type p1 = m_io->tellg(); + m_io->seekg(0, std::ios::end); + std::iostream::pos_type p2 = m_io->tellg(); + size_t len = p2 - p1; + + // Note: this requires a std::string to be backed with a + // contiguous buffer. Officially, it's a only requirement since + // C++11 (C++98 and C++03 didn't have this requirement), but all + // major implementations had contiguous buffers anyway. + std::string result(len, ' '); + m_io->seekg(p1); + m_io->read(&result[0], len); + + return result; +} + +std::string kaitai::kstream::read_bytes_term(char term, bool include, bool consume, bool eos_error) { + std::string result; + std::getline(*m_io, result, term); + if (m_io->eof()) { + // encountered EOF + if (eos_error) { + throw std::runtime_error("read_bytes_term: encountered EOF"); + } + } else { + // encountered terminator + if (include) + result.push_back(term); + if (!consume) + m_io->unget(); + } + return result; +} + +std::string kaitai::kstream::ensure_fixed_contents(std::string expected) { + std::string actual = read_bytes(expected.length()); + + if (actual != expected) { + // NOTE: I think printing it outright is not best idea, it could contain non-ascii charactes like backspace and beeps and whatnot. It would be better to print hexlified version, and also to redirect it to stderr. + throw std::runtime_error("ensure_fixed_contents: actual data does not match expected data"); + } + + return actual; +} + +std::string kaitai::kstream::bytes_strip_right(std::string src, char pad_byte) { + std::size_t new_len = src.length(); + + while (new_len > 0 && src[new_len - 1] == pad_byte) + new_len--; + + return src.substr(0, new_len); +} + +std::string kaitai::kstream::bytes_terminate(std::string src, char term, bool include) { + std::size_t new_len = 0; + std::size_t max_len = src.length(); + + while (new_len < max_len && src[new_len] != term) + new_len++; + + if (include && new_len < max_len) + new_len++; + + return src.substr(0, new_len); +} + +// ======================================================================== +// Byte array processing +// ======================================================================== + +std::string kaitai::kstream::process_xor_one(std::string data, uint8_t key) { + size_t len = data.length(); + std::string result(len, ' '); + + for (size_t i = 0; i < len; i++) + result[i] = data[i] ^ key; + + return result; +} + +std::string kaitai::kstream::process_xor_many(std::string data, std::string key) { + size_t len = data.length(); + size_t kl = key.length(); + std::string result(len, ' '); + + size_t ki = 0; + for (size_t i = 0; i < len; i++) { + result[i] = data[i] ^ key[ki]; + ki++; + if (ki >= kl) + ki = 0; + } + + return result; +} + +std::string kaitai::kstream::process_rotate_left(std::string data, int amount) { + size_t len = data.length(); + std::string result(len, ' '); + + for (size_t i = 0; i < len; i++) { + uint8_t bits = data[i]; + result[i] = (bits << amount) | (bits >> (8 - amount)); + } + + return result; +} + +#ifdef KS_ZLIB +#include + +std::string kaitai::kstream::process_zlib(std::string data) { + int ret; + + unsigned char *src_ptr = reinterpret_cast(&data[0]); + std::stringstream dst_strm; + + z_stream strm; + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + + ret = inflateInit(&strm); + if (ret != Z_OK) + throw std::runtime_error("process_zlib: inflateInit error"); + + strm.next_in = src_ptr; + strm.avail_in = data.length(); + + unsigned char outbuffer[ZLIB_BUF_SIZE]; + std::string outstring; + + // get the decompressed bytes blockwise using repeated calls to inflate + do { + strm.next_out = reinterpret_cast(outbuffer); + strm.avail_out = sizeof(outbuffer); + + ret = inflate(&strm, 0); + + if (outstring.size() < strm.total_out) + outstring.append(reinterpret_cast(outbuffer), strm.total_out - outstring.size()); + } while (ret == Z_OK); + + if (ret != Z_STREAM_END) { // an error occurred that was not EOF + std::ostringstream exc_msg; + exc_msg << "process_zlib: error #" << ret << "): " << strm.msg; + throw std::runtime_error(exc_msg.str()); + } + + if (inflateEnd(&strm) != Z_OK) + throw std::runtime_error("process_zlib: inflateEnd error"); + + return outstring; +} +#endif + +// ======================================================================== +// Misc utility methods +// ======================================================================== + +int kaitai::kstream::mod(int a, int b) { + if (b <= 0) + throw std::invalid_argument("mod: divisor b <= 0"); + int r = a % b; + if (r < 0) + r += b; + return r; +} + +#include +std::string kaitai::kstream::to_string(int val) { + // if int is 32 bits, "-2147483648" is the longest string representation + // => 11 chars + zero => 12 chars + // if int is 64 bits, "-9223372036854775808" is the longest + // => 20 chars + zero => 21 chars + char buf[25]; + int got_len = snprintf(buf, sizeof(buf), "%d", val); + + // should never happen, but check nonetheless + if (got_len > sizeof(buf)) + throw std::invalid_argument("to_string: integer is longer than string buffer"); + + return std::string(buf); +} + +#include +std::string kaitai::kstream::reverse(std::string val) { + std::reverse(val.begin(), val.end()); + + return val; +} + +uint8_t kaitai::kstream::byte_array_min(const std::string val) { + uint8_t min = 0xff; // UINT8_MAX + std::string::const_iterator end = val.end(); + for (std::string::const_iterator it = val.begin(); it != end; ++it) { + uint8_t cur = static_cast(*it); + if (cur < min) { + min = cur; + } + } + return min; +} + +uint8_t kaitai::kstream::byte_array_max(const std::string val) { + uint8_t max = 0; // UINT8_MIN + std::string::const_iterator end = val.end(); + for (std::string::const_iterator it = val.begin(); it != end; ++it) { + uint8_t cur = static_cast(*it); + if (cur > max) { + max = cur; + } + } + return max; +} + +// ======================================================================== +// Other internal methods +// ======================================================================== + +#ifndef KS_STR_DEFAULT_ENCODING +#define KS_STR_DEFAULT_ENCODING "UTF-8" +#endif + +#ifdef KS_STR_ENCODING_ICONV + +#include +#include +#include + +std::string kaitai::kstream::bytes_to_str(std::string src, std::string src_enc) { + iconv_t cd = iconv_open(KS_STR_DEFAULT_ENCODING, src_enc.c_str()); + + if (cd == (iconv_t) -1) { + if (errno == EINVAL) { + throw std::runtime_error("bytes_to_str: invalid encoding pair conversion requested"); + } else { + throw std::runtime_error("bytes_to_str: error opening iconv"); + } + } + + size_t src_len = src.length(); + size_t src_left = src_len; + + // Start with a buffer length of double the source length. + size_t dst_len = src_len * 2; + std::string dst(dst_len, ' '); + size_t dst_left = dst_len; + + char *src_ptr = &src[0]; + char *dst_ptr = &dst[0]; + + while (true) { + size_t res = iconv(cd, &src_ptr, &src_left, &dst_ptr, &dst_left); + + if (res == (size_t) -1) { + if (errno == E2BIG) { + // dst buffer is not enough to accomodate whole string + // enlarge the buffer and try again + size_t dst_used = dst_len - dst_left; + dst_left += dst_len; + dst_len += dst_len; + dst.resize(dst_len); + + // dst.resize might have allocated destination buffer in another area + // of memory, thus our previous pointer "dst" will be invalid; re-point + // it using "dst_used". + dst_ptr = &dst[dst_used]; + } else { + throw std::runtime_error("bytes_to_str: iconv error"); + } + } else { + // conversion successful + dst.resize(dst_len - dst_left); + break; + } + } + + if (iconv_close(cd) != 0) { + throw std::runtime_error("bytes_to_str: iconv close error"); + } + + return dst; +} +#elif defined(KS_STR_ENCODING_NONE) +std::string kaitai::kstream::bytes_to_str(std::string src, std::string src_enc) { + return src; +} +#else +#error Need to decide how to handle strings: please define one of: KS_STR_ENCODING_ICONV, KS_STR_ENCODING_NONE +#endif diff --git a/third_party/kaitai/kaitaistream.h b/third_party/kaitai/kaitaistream.h new file mode 100644 index 00000000000000..e7f4c6ce347d5b --- /dev/null +++ b/third_party/kaitai/kaitaistream.h @@ -0,0 +1,268 @@ +#ifndef KAITAI_STREAM_H +#define KAITAI_STREAM_H + +// Kaitai Struct runtime API version: x.y.z = 'xxxyyyzzz' decimal +#define KAITAI_STRUCT_VERSION 9000L + +#include +#include +#include +#include + +namespace kaitai { + +/** + * Kaitai Stream class (kaitai::kstream) is an implementation of + * Kaitai Struct stream API + * for C++/STL. It's implemented as a wrapper over generic STL std::istream. + * + * It provides a wide variety of simple methods to read (parse) binary + * representations of primitive types, such as integer and floating + * point numbers, byte arrays and strings, and also provides stream + * positioning / navigation methods with unified cross-language and + * cross-toolkit semantics. + * + * Typically, end users won't access Kaitai Stream class manually, but would + * describe a binary structure format using .ksy language and then would use + * Kaitai Struct compiler to generate source code in desired target language. + * That code, in turn, would use this class and API to do the actual parsing + * job. + */ +class kstream { +public: + /** + * Constructs new Kaitai Stream object, wrapping a given std::istream. + * \param io istream object to use for this Kaitai Stream + */ + kstream(std::istream* io); + + /** + * Constructs new Kaitai Stream object, wrapping a given in-memory data + * buffer. + * \param data data buffer to use for this Kaitai Stream + */ + kstream(std::string& data); + + void close(); + + /** @name Stream positioning */ + //@{ + /** + * Check if stream pointer is at the end of stream. Note that the semantics + * are different from traditional STL semantics: one does *not* need to do a + * read (which will fail) after the actual end of the stream to trigger EOF + * flag, which can be accessed after that read. It is sufficient to just be + * at the end of the stream for this method to return true. + * \return "true" if we are located at the end of the stream. + */ + bool is_eof() const; + + /** + * Set stream pointer to designated position. + * \param pos new position (offset in bytes from the beginning of the stream) + */ + void seek(uint64_t pos); + + /** + * Get current position of a stream pointer. + * \return pointer position, number of bytes from the beginning of the stream + */ + uint64_t pos(); + + /** + * Get total size of the stream in bytes. + * \return size of the stream in bytes + */ + uint64_t size(); + //@} + + /** @name Integer numbers */ + //@{ + + // ------------------------------------------------------------------------ + // Signed + // ------------------------------------------------------------------------ + + int8_t read_s1(); + + // ........................................................................ + // Big-endian + // ........................................................................ + + int16_t read_s2be(); + int32_t read_s4be(); + int64_t read_s8be(); + + // ........................................................................ + // Little-endian + // ........................................................................ + + int16_t read_s2le(); + int32_t read_s4le(); + int64_t read_s8le(); + + // ------------------------------------------------------------------------ + // Unsigned + // ------------------------------------------------------------------------ + + uint8_t read_u1(); + + // ........................................................................ + // Big-endian + // ........................................................................ + + uint16_t read_u2be(); + uint32_t read_u4be(); + uint64_t read_u8be(); + + // ........................................................................ + // Little-endian + // ........................................................................ + + uint16_t read_u2le(); + uint32_t read_u4le(); + uint64_t read_u8le(); + + //@} + + /** @name Floating point numbers */ + //@{ + + // ........................................................................ + // Big-endian + // ........................................................................ + + float read_f4be(); + double read_f8be(); + + // ........................................................................ + // Little-endian + // ........................................................................ + + float read_f4le(); + double read_f8le(); + + //@} + + /** @name Unaligned bit values */ + //@{ + + void align_to_byte(); + uint64_t read_bits_int_be(int n); + uint64_t read_bits_int(int n); + uint64_t read_bits_int_le(int n); + + //@} + + /** @name Byte arrays */ + //@{ + + std::string read_bytes(std::streamsize len); + std::string read_bytes_full(); + std::string read_bytes_term(char term, bool include, bool consume, bool eos_error); + std::string ensure_fixed_contents(std::string expected); + + static std::string bytes_strip_right(std::string src, char pad_byte); + static std::string bytes_terminate(std::string src, char term, bool include); + static std::string bytes_to_str(std::string src, std::string src_enc); + + //@} + + /** @name Byte array processing */ + //@{ + + /** + * Performs a XOR processing with given data, XORing every byte of input with a single + * given value. + * @param data data to process + * @param key value to XOR with + * @return processed data + */ + static std::string process_xor_one(std::string data, uint8_t key); + + /** + * Performs a XOR processing with given data, XORing every byte of input with a key + * array, repeating key array many times, if necessary (i.e. if data array is longer + * than key array). + * @param data data to process + * @param key array of bytes to XOR with + * @return processed data + */ + static std::string process_xor_many(std::string data, std::string key); + + /** + * Performs a circular left rotation shift for a given buffer by a given amount of bits, + * using groups of 1 bytes each time. Right circular rotation should be performed + * using this procedure with corrected amount. + * @param data source data to process + * @param amount number of bits to shift by + * @return copy of source array with requested shift applied + */ + static std::string process_rotate_left(std::string data, int amount); + +#ifdef KS_ZLIB + /** + * Performs an unpacking ("inflation") of zlib-compressed data with usual zlib headers. + * @param data data to unpack + * @return unpacked data + * @throws IOException + */ + static std::string process_zlib(std::string data); +#endif + + //@} + + /** + * Performs modulo operation between two integers: dividend `a` + * and divisor `b`. Divisor `b` is expected to be positive. The + * result is always 0 <= x <= b - 1. + */ + static int mod(int a, int b); + + /** + * Converts given integer `val` to a decimal string representation. + * Should be used in place of std::to_string() (which is available only + * since C++11) in older C++ implementations. + */ + static std::string to_string(int val); + + /** + * Reverses given string `val`, so that the first character becomes the + * last and the last one becomes the first. This should be used to avoid + * the need of local variables at the caller. + */ + static std::string reverse(std::string val); + + /** + * Finds the minimal byte in a byte array, treating bytes as + * unsigned values. + * @param val byte array to scan + * @return minimal byte in byte array as integer + */ + static uint8_t byte_array_min(const std::string val); + + /** + * Finds the maximal byte in a byte array, treating bytes as + * unsigned values. + * @param val byte array to scan + * @return maximal byte in byte array as integer + */ + static uint8_t byte_array_max(const std::string val); + +private: + std::istream* m_io; + std::istringstream m_io_str; + int m_bits_left; + uint64_t m_bits; + + void init(); + void exceptions_enable() const; + + static uint64_t get_mask_ones(int n); + + static const int ZLIB_BUF_SIZE = 128 * 1024; +}; + +} + +#endif diff --git a/third_party/kaitai/kaitaistruct.h b/third_party/kaitai/kaitaistruct.h new file mode 100644 index 00000000000000..8172ede6c98195 --- /dev/null +++ b/third_party/kaitai/kaitaistruct.h @@ -0,0 +1,20 @@ +#ifndef KAITAI_STRUCT_H +#define KAITAI_STRUCT_H + +#include + +namespace kaitai { + +class kstruct { +public: + kstruct(kstream *_io) { m__io = _io; } + virtual ~kstruct() {} +protected: + kstream *m__io; +public: + kstream *_io() { return m__io; } +}; + +} + +#endif diff --git a/phonelibs/libgralloc/include/gralloc_priv.h b/third_party/libgralloc/include/gralloc_priv.h similarity index 100% rename from phonelibs/libgralloc/include/gralloc_priv.h rename to third_party/libgralloc/include/gralloc_priv.h diff --git a/phonelibs/libyuv/include/libyuv.h b/third_party/libyuv/include/libyuv.h similarity index 100% rename from phonelibs/libyuv/include/libyuv.h rename to third_party/libyuv/include/libyuv.h diff --git a/phonelibs/libyuv/include/libyuv/basic_types.h b/third_party/libyuv/include/libyuv/basic_types.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/basic_types.h rename to third_party/libyuv/include/libyuv/basic_types.h diff --git a/phonelibs/libyuv/include/libyuv/compare.h b/third_party/libyuv/include/libyuv/compare.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/compare.h rename to third_party/libyuv/include/libyuv/compare.h diff --git a/phonelibs/libyuv/include/libyuv/compare_row.h b/third_party/libyuv/include/libyuv/compare_row.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/compare_row.h rename to third_party/libyuv/include/libyuv/compare_row.h diff --git a/phonelibs/libyuv/include/libyuv/convert.h b/third_party/libyuv/include/libyuv/convert.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/convert.h rename to third_party/libyuv/include/libyuv/convert.h diff --git a/phonelibs/libyuv/include/libyuv/convert_argb.h b/third_party/libyuv/include/libyuv/convert_argb.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/convert_argb.h rename to third_party/libyuv/include/libyuv/convert_argb.h diff --git a/phonelibs/libyuv/include/libyuv/convert_from.h b/third_party/libyuv/include/libyuv/convert_from.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/convert_from.h rename to third_party/libyuv/include/libyuv/convert_from.h diff --git a/phonelibs/libyuv/include/libyuv/convert_from_argb.h b/third_party/libyuv/include/libyuv/convert_from_argb.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/convert_from_argb.h rename to third_party/libyuv/include/libyuv/convert_from_argb.h diff --git a/phonelibs/libyuv/include/libyuv/cpu_id.h b/third_party/libyuv/include/libyuv/cpu_id.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/cpu_id.h rename to third_party/libyuv/include/libyuv/cpu_id.h diff --git a/phonelibs/libyuv/include/libyuv/macros_msa.h b/third_party/libyuv/include/libyuv/macros_msa.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/macros_msa.h rename to third_party/libyuv/include/libyuv/macros_msa.h diff --git a/phonelibs/libyuv/include/libyuv/mjpeg_decoder.h b/third_party/libyuv/include/libyuv/mjpeg_decoder.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/mjpeg_decoder.h rename to third_party/libyuv/include/libyuv/mjpeg_decoder.h diff --git a/phonelibs/libyuv/include/libyuv/planar_functions.h b/third_party/libyuv/include/libyuv/planar_functions.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/planar_functions.h rename to third_party/libyuv/include/libyuv/planar_functions.h diff --git a/phonelibs/libyuv/include/libyuv/rotate.h b/third_party/libyuv/include/libyuv/rotate.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/rotate.h rename to third_party/libyuv/include/libyuv/rotate.h diff --git a/phonelibs/libyuv/include/libyuv/rotate_argb.h b/third_party/libyuv/include/libyuv/rotate_argb.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/rotate_argb.h rename to third_party/libyuv/include/libyuv/rotate_argb.h diff --git a/phonelibs/libyuv/include/libyuv/rotate_row.h b/third_party/libyuv/include/libyuv/rotate_row.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/rotate_row.h rename to third_party/libyuv/include/libyuv/rotate_row.h diff --git a/phonelibs/libyuv/include/libyuv/row.h b/third_party/libyuv/include/libyuv/row.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/row.h rename to third_party/libyuv/include/libyuv/row.h diff --git a/phonelibs/libyuv/include/libyuv/scale.h b/third_party/libyuv/include/libyuv/scale.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/scale.h rename to third_party/libyuv/include/libyuv/scale.h diff --git a/phonelibs/libyuv/include/libyuv/scale_argb.h b/third_party/libyuv/include/libyuv/scale_argb.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/scale_argb.h rename to third_party/libyuv/include/libyuv/scale_argb.h diff --git a/phonelibs/libyuv/include/libyuv/scale_row.h b/third_party/libyuv/include/libyuv/scale_row.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/scale_row.h rename to third_party/libyuv/include/libyuv/scale_row.h diff --git a/phonelibs/libyuv/include/libyuv/version.h b/third_party/libyuv/include/libyuv/version.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/version.h rename to third_party/libyuv/include/libyuv/version.h diff --git a/phonelibs/libyuv/include/libyuv/video_common.h b/third_party/libyuv/include/libyuv/video_common.h similarity index 100% rename from phonelibs/libyuv/include/libyuv/video_common.h rename to third_party/libyuv/include/libyuv/video_common.h diff --git a/third_party/libyuv/larch64/lib/libyuv.a b/third_party/libyuv/larch64/lib/libyuv.a new file mode 100644 index 00000000000000..fdbcda2517a96c Binary files /dev/null and b/third_party/libyuv/larch64/lib/libyuv.a differ diff --git a/phonelibs/libyuv/lib/libyuv.a b/third_party/libyuv/lib/libyuv.a similarity index 100% rename from phonelibs/libyuv/lib/libyuv.a rename to third_party/libyuv/lib/libyuv.a diff --git a/phonelibs/linux/include/linux/ion.h b/third_party/linux/include/linux/ion.h similarity index 100% rename from phonelibs/linux/include/linux/ion.h rename to third_party/linux/include/linux/ion.h diff --git a/phonelibs/linux/include/msm_ion.h b/third_party/linux/include/msm_ion.h similarity index 98% rename from phonelibs/linux/include/msm_ion.h rename to third_party/linux/include/msm_ion.h index e41b3170fd438e..d5caed5eb36e1b 100644 --- a/phonelibs/linux/include/msm_ion.h +++ b/third_party/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/third_party/mapbox-gl-native-qt/include/QMapbox b/third_party/mapbox-gl-native-qt/include/QMapbox new file mode 100644 index 00000000000000..a8479c09aa7fb7 --- /dev/null +++ b/third_party/mapbox-gl-native-qt/include/QMapbox @@ -0,0 +1 @@ +#include "qmapbox.hpp" diff --git a/third_party/mapbox-gl-native-qt/include/QMapboxGL b/third_party/mapbox-gl-native-qt/include/QMapboxGL new file mode 100644 index 00000000000000..15b55a9abe98f8 --- /dev/null +++ b/third_party/mapbox-gl-native-qt/include/QMapboxGL @@ -0,0 +1 @@ +#include "qmapboxgl.hpp" diff --git a/third_party/mapbox-gl-native-qt/include/qmapbox.hpp b/third_party/mapbox-gl-native-qt/include/qmapbox.hpp new file mode 100644 index 00000000000000..3acc9d55e0118d --- /dev/null +++ b/third_party/mapbox-gl-native-qt/include/qmapbox.hpp @@ -0,0 +1,147 @@ +#ifndef QMAPBOX_H +#define QMAPBOX_H + +#include +#include +#include +#include +#include + +// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style + +#if !defined(QT_MAPBOXGL_STATIC) +# if defined(QT_BUILD_MAPBOXGL_LIB) +# define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT +# else +# define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_MAPBOXGL_EXPORT +#endif + +namespace QMapbox { + +typedef QPair Coordinate; +typedef QPair CoordinateZoom; +typedef QPair ProjectedMeters; + +typedef QVector Coordinates; +typedef QVector CoordinatesCollection; + +typedef QVector CoordinatesCollections; + +struct Q_MAPBOXGL_EXPORT Feature { + enum Type { + PointType = 1, + LineStringType, + PolygonType + }; + + /*! Class constructor. */ + Feature(Type type_ = PointType, const CoordinatesCollections& geometry_ = CoordinatesCollections(), + const QVariantMap& properties_ = QVariantMap(), const QVariant& id_ = QVariant()) + : type(type_), geometry(geometry_), properties(properties_), id(id_) {} + + Type type; + CoordinatesCollections geometry; + QVariantMap properties; + QVariant id; +}; + +struct Q_MAPBOXGL_EXPORT ShapeAnnotationGeometry { + enum Type { + LineStringType = 1, + PolygonType, + MultiLineStringType, + MultiPolygonType + }; + + /*! Class constructor. */ + ShapeAnnotationGeometry(Type type_ = LineStringType, const CoordinatesCollections& geometry_ = CoordinatesCollections()) + : type(type_), geometry(geometry_) {} + + Type type; + CoordinatesCollections geometry; +}; + +struct Q_MAPBOXGL_EXPORT SymbolAnnotation { + Coordinate geometry; + QString icon; +}; + +struct Q_MAPBOXGL_EXPORT LineAnnotation { + /*! Class constructor. */ + LineAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, + float width_ = 1.0f, const QColor& color_ = Qt::black) + : geometry(geometry_), opacity(opacity_), width(width_), color(color_) {} + + ShapeAnnotationGeometry geometry; + float opacity; + float width; + QColor color; +}; + +struct Q_MAPBOXGL_EXPORT FillAnnotation { + /*! Class constructor. */ + FillAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, + const QColor& color_ = Qt::black, const QVariant& outlineColor_ = QVariant()) + : geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {} + + ShapeAnnotationGeometry geometry; + float opacity; + QColor color; + QVariant outlineColor; +}; + +typedef QVariant Annotation; +typedef quint32 AnnotationID; +typedef QVector AnnotationIDs; + +enum NetworkMode { + Online, // Default + Offline, +}; + +Q_MAPBOXGL_EXPORT QVector >& defaultStyles(); + +Q_MAPBOXGL_EXPORT NetworkMode networkMode(); +Q_MAPBOXGL_EXPORT void setNetworkMode(NetworkMode); + +// This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters. +struct Q_MAPBOXGL_EXPORT CustomLayerRenderParameters { + double width; + double height; + double latitude; + double longitude; + double zoom; + double bearing; + double pitch; + double fieldOfView; +}; + +class Q_MAPBOXGL_EXPORT CustomLayerHostInterface { +public: + virtual ~CustomLayerHostInterface() = default; + virtual void initialize() = 0; + virtual void render(const CustomLayerRenderParameters&) = 0; + virtual void deinitialize() = 0; +}; + +Q_MAPBOXGL_EXPORT double metersPerPixelAtLatitude(double latitude, double zoom); +Q_MAPBOXGL_EXPORT ProjectedMeters projectedMetersForCoordinate(const Coordinate &); +Q_MAPBOXGL_EXPORT Coordinate coordinateForProjectedMeters(const ProjectedMeters &); + +} // namespace QMapbox + +Q_DECLARE_METATYPE(QMapbox::Coordinate); +Q_DECLARE_METATYPE(QMapbox::Coordinates); +Q_DECLARE_METATYPE(QMapbox::CoordinatesCollection); +Q_DECLARE_METATYPE(QMapbox::CoordinatesCollections); +Q_DECLARE_METATYPE(QMapbox::Feature); + +Q_DECLARE_METATYPE(QMapbox::SymbolAnnotation); +Q_DECLARE_METATYPE(QMapbox::ShapeAnnotationGeometry); +Q_DECLARE_METATYPE(QMapbox::LineAnnotation); +Q_DECLARE_METATYPE(QMapbox::FillAnnotation); + +#endif // QMAPBOX_H diff --git a/third_party/mapbox-gl-native-qt/include/qmapboxgl.hpp b/third_party/mapbox-gl-native-qt/include/qmapboxgl.hpp new file mode 100644 index 00000000000000..337991aa1c1360 --- /dev/null +++ b/third_party/mapbox-gl-native-qt/include/qmapboxgl.hpp @@ -0,0 +1,277 @@ +#ifndef QMAPBOXGL_H +#define QMAPBOXGL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class QMapboxGLPrivate; + +// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style + +class Q_MAPBOXGL_EXPORT QMapboxGLSettings +{ +public: + QMapboxGLSettings(); + + enum GLContextMode { + UniqueGLContext = 0, + SharedGLContext + }; + + enum MapMode { + Continuous = 0, + Static + }; + + enum ConstrainMode { + NoConstrain = 0, + ConstrainHeightOnly, + ConstrainWidthAndHeight + }; + + enum ViewportMode { + DefaultViewport = 0, + FlippedYViewport + }; + + GLContextMode contextMode() const; + void setContextMode(GLContextMode); + + MapMode mapMode() const; + void setMapMode(MapMode); + + ConstrainMode constrainMode() const; + void setConstrainMode(ConstrainMode); + + ViewportMode viewportMode() const; + void setViewportMode(ViewportMode); + + unsigned cacheDatabaseMaximumSize() const; + void setCacheDatabaseMaximumSize(unsigned); + + QString cacheDatabasePath() const; + void setCacheDatabasePath(const QString &); + + QString assetPath() const; + void setAssetPath(const QString &); + + QString accessToken() const; + void setAccessToken(const QString &); + + QString apiBaseUrl() const; + void setApiBaseUrl(const QString &); + + QString localFontFamily() const; + void setLocalFontFamily(const QString &); + + std::function resourceTransform() const; + void setResourceTransform(const std::function &); + +private: + GLContextMode m_contextMode; + MapMode m_mapMode; + ConstrainMode m_constrainMode; + ViewportMode m_viewportMode; + + unsigned m_cacheMaximumSize; + QString m_cacheDatabasePath; + QString m_assetPath; + QString m_accessToken; + QString m_apiBaseUrl; + QString m_localFontFamily; + std::function m_resourceTransform; +}; + +struct Q_MAPBOXGL_EXPORT QMapboxGLCameraOptions { + QVariant center; // Coordinate + QVariant anchor; // QPointF + QVariant zoom; // double + QVariant bearing; // double + QVariant pitch; // double +}; + +class Q_MAPBOXGL_EXPORT QMapboxGL : public QObject +{ + Q_OBJECT + Q_PROPERTY(double latitude READ latitude WRITE setLatitude) + Q_PROPERTY(double longitude READ longitude WRITE setLongitude) + Q_PROPERTY(double zoom READ zoom WRITE setZoom) + Q_PROPERTY(double bearing READ bearing WRITE setBearing) + Q_PROPERTY(double pitch READ pitch WRITE setPitch) + Q_PROPERTY(QString styleJson READ styleJson WRITE setStyleJson) + Q_PROPERTY(QString styleUrl READ styleUrl WRITE setStyleUrl) + Q_PROPERTY(double scale READ scale WRITE setScale) + Q_PROPERTY(QMapbox::Coordinate coordinate READ coordinate WRITE setCoordinate) + Q_PROPERTY(QMargins margins READ margins WRITE setMargins) + +public: + enum MapChange { + MapChangeRegionWillChange = 0, + MapChangeRegionWillChangeAnimated, + MapChangeRegionIsChanging, + MapChangeRegionDidChange, + MapChangeRegionDidChangeAnimated, + MapChangeWillStartLoadingMap, + MapChangeDidFinishLoadingMap, + MapChangeDidFailLoadingMap, + MapChangeWillStartRenderingFrame, + MapChangeDidFinishRenderingFrame, + MapChangeDidFinishRenderingFrameFullyRendered, + MapChangeWillStartRenderingMap, + MapChangeDidFinishRenderingMap, + MapChangeDidFinishRenderingMapFullyRendered, + MapChangeDidFinishLoadingStyle, + MapChangeSourceDidChange + }; + + enum MapLoadingFailure { + StyleParseFailure, + StyleLoadFailure, + NotFoundFailure, + UnknownFailure + }; + + // Determines the orientation of the map. + enum NorthOrientation { + NorthUpwards, // Default + NorthRightwards, + NorthDownwards, + NorthLeftwards, + }; + + QMapboxGL(QObject* parent = 0, + const QMapboxGLSettings& = QMapboxGLSettings(), + const QSize& size = QSize(), + qreal pixelRatio = 1); + virtual ~QMapboxGL(); + + QString styleJson() const; + QString styleUrl() const; + + void setStyleJson(const QString &); + void setStyleUrl(const QString &); + + double latitude() const; + void setLatitude(double latitude); + + double longitude() const; + void setLongitude(double longitude); + + double scale() const; + void setScale(double scale, const QPointF ¢er = QPointF()); + + double zoom() const; + void setZoom(double zoom); + + double minimumZoom() const; + double maximumZoom() const; + + double bearing() const; + void setBearing(double degrees); + void setBearing(double degrees, const QPointF ¢er); + + double pitch() const; + void setPitch(double pitch); + void pitchBy(double pitch); + + NorthOrientation northOrientation() const; + void setNorthOrientation(NorthOrientation); + + QMapbox::Coordinate coordinate() const; + void setCoordinate(const QMapbox::Coordinate &); + void setCoordinateZoom(const QMapbox::Coordinate &, double zoom); + + void jumpTo(const QMapboxGLCameraOptions&); + + void setGestureInProgress(bool inProgress); + + void setTransitionOptions(qint64 duration, qint64 delay = 0); + + void addAnnotationIcon(const QString &name, const QImage &sprite); + + QMapbox::AnnotationID addAnnotation(const QMapbox::Annotation &); + void updateAnnotation(QMapbox::AnnotationID, const QMapbox::Annotation &); + void removeAnnotation(QMapbox::AnnotationID); + + bool setLayoutProperty(const QString &layer, const QString &property, const QVariant &value); + bool setPaintProperty(const QString &layer, const QString &property, const QVariant &value); + + bool isFullyLoaded() const; + + void moveBy(const QPointF &offset); + void scaleBy(double scale, const QPointF ¢er = QPointF()); + void rotateBy(const QPointF &first, const QPointF &second); + + void resize(const QSize &size); + + double metersPerPixelAtLatitude(double latitude, double zoom) const; + QMapbox::ProjectedMeters projectedMetersForCoordinate(const QMapbox::Coordinate &) const; + QMapbox::Coordinate coordinateForProjectedMeters(const QMapbox::ProjectedMeters &) const; + QPointF pixelForCoordinate(const QMapbox::Coordinate &) const; + QMapbox::Coordinate coordinateForPixel(const QPointF &) const; + + QMapbox::CoordinateZoom coordinateZoomForBounds(const QMapbox::Coordinate &sw, QMapbox::Coordinate &ne) const; + QMapbox::CoordinateZoom coordinateZoomForBounds(const QMapbox::Coordinate &sw, QMapbox::Coordinate &ne, double bearing, double pitch); + + void setMargins(const QMargins &margins); + QMargins margins() const; + + void addSource(const QString &sourceID, const QVariantMap& params); + bool sourceExists(const QString &sourceID); + void updateSource(const QString &sourceID, const QVariantMap& params); + void removeSource(const QString &sourceID); + + void addImage(const QString &name, const QImage &sprite); + void removeImage(const QString &name); + + void addCustomLayer(const QString &id, + QScopedPointer& host, + const QString& before = QString()); + void addLayer(const QVariantMap ¶ms, const QString& before = QString()); + bool layerExists(const QString &id); + void removeLayer(const QString &id); + + QVector layerIds() const; + + void setFilter(const QString &layer, const QVariant &filter); + QVariant getFilter(const QString &layer) const; + // When rendering on a different thread, + // should be called on the render thread. + void createRenderer(); + void destroyRenderer(); + void setFramebufferObject(quint32 fbo, const QSize &size); + +public slots: + void render(); + void connectionEstablished(); + + // Commit changes, load all the resources + // and renders the map when completed. + void startStaticRender(); + +signals: + void needsRendering(); + void mapChanged(QMapboxGL::MapChange); + void mapLoadingFailed(QMapboxGL::MapLoadingFailure, const QString &reason); + void copyrightsChanged(const QString ©rightsHtml); + + void staticRenderFinished(const QString &error); + +private: + Q_DISABLE_COPY(QMapboxGL) + + QMapboxGLPrivate *d_ptr; +}; + +Q_DECLARE_METATYPE(QMapboxGL::MapChange); +Q_DECLARE_METATYPE(QMapboxGL::MapLoadingFailure); + +#endif // QMAPBOXGL_H diff --git a/phonelibs/opencl/include/CL/cl.h b/third_party/opencl/include/CL/cl.h similarity index 100% rename from phonelibs/opencl/include/CL/cl.h rename to third_party/opencl/include/CL/cl.h diff --git a/phonelibs/opencl/include/CL/cl_d3d10.h b/third_party/opencl/include/CL/cl_d3d10.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_d3d10.h rename to third_party/opencl/include/CL/cl_d3d10.h diff --git a/phonelibs/opencl/include/CL/cl_d3d11.h b/third_party/opencl/include/CL/cl_d3d11.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_d3d11.h rename to third_party/opencl/include/CL/cl_d3d11.h diff --git a/phonelibs/opencl/include/CL/cl_dx9_media_sharing.h b/third_party/opencl/include/CL/cl_dx9_media_sharing.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_dx9_media_sharing.h rename to third_party/opencl/include/CL/cl_dx9_media_sharing.h diff --git a/phonelibs/opencl/include/CL/cl_egl.h b/third_party/opencl/include/CL/cl_egl.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_egl.h rename to third_party/opencl/include/CL/cl_egl.h diff --git a/phonelibs/opencl/include/CL/cl_ext.h b/third_party/opencl/include/CL/cl_ext.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_ext.h rename to third_party/opencl/include/CL/cl_ext.h diff --git a/third_party/opencl/include/CL/cl_ext_qcom.h b/third_party/opencl/include/CL/cl_ext_qcom.h new file mode 100644 index 00000000000000..6328a1cd93a10e --- /dev/null +++ b/third_party/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/opencl/include/CL/cl_gl.h b/third_party/opencl/include/CL/cl_gl.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_gl.h rename to third_party/opencl/include/CL/cl_gl.h diff --git a/phonelibs/opencl/include/CL/cl_gl_ext.h b/third_party/opencl/include/CL/cl_gl_ext.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_gl_ext.h rename to third_party/opencl/include/CL/cl_gl_ext.h diff --git a/phonelibs/opencl/include/CL/cl_platform.h b/third_party/opencl/include/CL/cl_platform.h similarity index 100% rename from phonelibs/opencl/include/CL/cl_platform.h rename to third_party/opencl/include/CL/cl_platform.h diff --git a/phonelibs/opencl/include/CL/opencl.h b/third_party/opencl/include/CL/opencl.h similarity index 100% rename from phonelibs/opencl/include/CL/opencl.h rename to third_party/opencl/include/CL/opencl.h diff --git a/phonelibs/openmax/include/OMX_Audio.h b/third_party/openmax/include/OMX_Audio.h similarity index 100% rename from phonelibs/openmax/include/OMX_Audio.h rename to third_party/openmax/include/OMX_Audio.h diff --git a/phonelibs/openmax/include/OMX_Component.h b/third_party/openmax/include/OMX_Component.h similarity index 100% rename from phonelibs/openmax/include/OMX_Component.h rename to third_party/openmax/include/OMX_Component.h diff --git a/phonelibs/openmax/include/OMX_ContentPipe.h b/third_party/openmax/include/OMX_ContentPipe.h similarity index 100% rename from phonelibs/openmax/include/OMX_ContentPipe.h rename to third_party/openmax/include/OMX_ContentPipe.h diff --git a/phonelibs/openmax/include/OMX_Core.h b/third_party/openmax/include/OMX_Core.h similarity index 100% rename from phonelibs/openmax/include/OMX_Core.h rename to third_party/openmax/include/OMX_Core.h diff --git a/phonelibs/openmax/include/OMX_CoreExt.h b/third_party/openmax/include/OMX_CoreExt.h similarity index 100% rename from phonelibs/openmax/include/OMX_CoreExt.h rename to third_party/openmax/include/OMX_CoreExt.h diff --git a/phonelibs/openmax/include/OMX_IVCommon.h b/third_party/openmax/include/OMX_IVCommon.h similarity index 100% rename from phonelibs/openmax/include/OMX_IVCommon.h rename to third_party/openmax/include/OMX_IVCommon.h diff --git a/phonelibs/openmax/include/OMX_Image.h b/third_party/openmax/include/OMX_Image.h similarity index 100% rename from phonelibs/openmax/include/OMX_Image.h rename to third_party/openmax/include/OMX_Image.h diff --git a/phonelibs/openmax/include/OMX_Index.h b/third_party/openmax/include/OMX_Index.h similarity index 100% rename from phonelibs/openmax/include/OMX_Index.h rename to third_party/openmax/include/OMX_Index.h diff --git a/phonelibs/openmax/include/OMX_IndexExt.h b/third_party/openmax/include/OMX_IndexExt.h similarity index 100% rename from phonelibs/openmax/include/OMX_IndexExt.h rename to third_party/openmax/include/OMX_IndexExt.h diff --git a/phonelibs/openmax/include/OMX_Other.h b/third_party/openmax/include/OMX_Other.h similarity index 100% rename from phonelibs/openmax/include/OMX_Other.h rename to third_party/openmax/include/OMX_Other.h diff --git a/phonelibs/openmax/include/OMX_QCOMExtns.h b/third_party/openmax/include/OMX_QCOMExtns.h similarity index 100% rename from phonelibs/openmax/include/OMX_QCOMExtns.h rename to third_party/openmax/include/OMX_QCOMExtns.h diff --git a/phonelibs/openmax/include/OMX_Skype_VideoExtensions.h b/third_party/openmax/include/OMX_Skype_VideoExtensions.h similarity index 100% rename from phonelibs/openmax/include/OMX_Skype_VideoExtensions.h rename to third_party/openmax/include/OMX_Skype_VideoExtensions.h diff --git a/phonelibs/openmax/include/OMX_Types.h b/third_party/openmax/include/OMX_Types.h similarity index 100% rename from phonelibs/openmax/include/OMX_Types.h rename to third_party/openmax/include/OMX_Types.h diff --git a/phonelibs/openmax/include/OMX_Video.h b/third_party/openmax/include/OMX_Video.h similarity index 100% rename from phonelibs/openmax/include/OMX_Video.h rename to third_party/openmax/include/OMX_Video.h diff --git a/phonelibs/openmax/include/OMX_VideoExt.h b/third_party/openmax/include/OMX_VideoExt.h similarity index 100% rename from phonelibs/openmax/include/OMX_VideoExt.h rename to third_party/openmax/include/OMX_VideoExt.h diff --git a/third_party/qrcode/QrCode.cc b/third_party/qrcode/QrCode.cc new file mode 100644 index 00000000000000..b9de86215e204a --- /dev/null +++ b/third_party/qrcode/QrCode.cc @@ -0,0 +1,862 @@ +/* + * QR Code generator library (C++) + * + * Copyright (c) Project Nayuki. (MIT License) + * https://www.nayuki.io/page/qr-code-generator-library + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include "QrCode.hpp" + +using std::int8_t; +using std::uint8_t; +using std::size_t; +using std::vector; + + +namespace qrcodegen { + +QrSegment::Mode::Mode(int mode, int cc0, int cc1, int cc2) : + modeBits(mode) { + numBitsCharCount[0] = cc0; + numBitsCharCount[1] = cc1; + numBitsCharCount[2] = cc2; +} + + +int QrSegment::Mode::getModeBits() const { + return modeBits; +} + + +int QrSegment::Mode::numCharCountBits(int ver) const { + return numBitsCharCount[(ver + 7) / 17]; +} + + +const QrSegment::Mode QrSegment::Mode::NUMERIC (0x1, 10, 12, 14); +const QrSegment::Mode QrSegment::Mode::ALPHANUMERIC(0x2, 9, 11, 13); +const QrSegment::Mode QrSegment::Mode::BYTE (0x4, 8, 16, 16); +const QrSegment::Mode QrSegment::Mode::KANJI (0x8, 8, 10, 12); +const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0); + + +QrSegment QrSegment::makeBytes(const vector &data) { + if (data.size() > static_cast(INT_MAX)) + throw std::length_error("Data too long"); + BitBuffer bb; + for (uint8_t b : data) + bb.appendBits(b, 8); + return QrSegment(Mode::BYTE, static_cast(data.size()), std::move(bb)); +} + + +QrSegment QrSegment::makeNumeric(const char *digits) { + BitBuffer bb; + int accumData = 0; + int accumCount = 0; + int charCount = 0; + for (; *digits != '\0'; digits++, charCount++) { + char c = *digits; + if (c < '0' || c > '9') + throw std::domain_error("String contains non-numeric characters"); + accumData = accumData * 10 + (c - '0'); + accumCount++; + if (accumCount == 3) { + bb.appendBits(static_cast(accumData), 10); + accumData = 0; + accumCount = 0; + } + } + if (accumCount > 0) // 1 or 2 digits remaining + bb.appendBits(static_cast(accumData), accumCount * 3 + 1); + return QrSegment(Mode::NUMERIC, charCount, std::move(bb)); +} + + +QrSegment QrSegment::makeAlphanumeric(const char *text) { + BitBuffer bb; + int accumData = 0; + int accumCount = 0; + int charCount = 0; + for (; *text != '\0'; text++, charCount++) { + const char *temp = std::strchr(ALPHANUMERIC_CHARSET, *text); + if (temp == nullptr) + throw std::domain_error("String contains unencodable characters in alphanumeric mode"); + accumData = accumData * 45 + static_cast(temp - ALPHANUMERIC_CHARSET); + accumCount++; + if (accumCount == 2) { + bb.appendBits(static_cast(accumData), 11); + accumData = 0; + accumCount = 0; + } + } + if (accumCount > 0) // 1 character remaining + bb.appendBits(static_cast(accumData), 6); + return QrSegment(Mode::ALPHANUMERIC, charCount, std::move(bb)); +} + + +vector QrSegment::makeSegments(const char *text) { + // Select the most efficient segment encoding automatically + vector result; + if (*text == '\0'); // Leave result empty + else if (isNumeric(text)) + result.push_back(makeNumeric(text)); + else if (isAlphanumeric(text)) + result.push_back(makeAlphanumeric(text)); + else { + vector bytes; + for (; *text != '\0'; text++) + bytes.push_back(static_cast(*text)); + result.push_back(makeBytes(bytes)); + } + return result; +} + + +QrSegment QrSegment::makeEci(long assignVal) { + BitBuffer bb; + if (assignVal < 0) + throw std::domain_error("ECI assignment value out of range"); + else if (assignVal < (1 << 7)) + bb.appendBits(static_cast(assignVal), 8); + else if (assignVal < (1 << 14)) { + bb.appendBits(2, 2); + bb.appendBits(static_cast(assignVal), 14); + } else if (assignVal < 1000000L) { + bb.appendBits(6, 3); + bb.appendBits(static_cast(assignVal), 21); + } else + throw std::domain_error("ECI assignment value out of range"); + return QrSegment(Mode::ECI, 0, std::move(bb)); +} + + +QrSegment::QrSegment(Mode md, int numCh, const std::vector &dt) : + mode(md), + numChars(numCh), + data(dt) { + if (numCh < 0) + throw std::domain_error("Invalid value"); +} + + +QrSegment::QrSegment(Mode md, int numCh, std::vector &&dt) : + mode(md), + numChars(numCh), + data(std::move(dt)) { + if (numCh < 0) + throw std::domain_error("Invalid value"); +} + + +int QrSegment::getTotalBits(const vector &segs, int version) { + int result = 0; + for (const QrSegment &seg : segs) { + int ccbits = seg.mode.numCharCountBits(version); + if (seg.numChars >= (1L << ccbits)) + return -1; // The segment's length doesn't fit the field's bit width + if (4 + ccbits > INT_MAX - result) + return -1; // The sum will overflow an int type + result += 4 + ccbits; + if (seg.data.size() > static_cast(INT_MAX - result)) + return -1; // The sum will overflow an int type + result += static_cast(seg.data.size()); + } + return result; +} + + +bool QrSegment::isAlphanumeric(const char *text) { + for (; *text != '\0'; text++) { + if (std::strchr(ALPHANUMERIC_CHARSET, *text) == nullptr) + return false; + } + return true; +} + + +bool QrSegment::isNumeric(const char *text) { + for (; *text != '\0'; text++) { + char c = *text; + if (c < '0' || c > '9') + return false; + } + return true; +} + + +QrSegment::Mode QrSegment::getMode() const { + return mode; +} + + +int QrSegment::getNumChars() const { + return numChars; +} + + +const std::vector &QrSegment::getData() const { + return data; +} + + +const char *QrSegment::ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; + + + +int QrCode::getFormatBits(Ecc ecl) { + switch (ecl) { + case Ecc::LOW : return 1; + case Ecc::MEDIUM : return 0; + case Ecc::QUARTILE: return 3; + case Ecc::HIGH : return 2; + default: throw std::logic_error("Assertion error"); + } +} + + +QrCode QrCode::encodeText(const char *text, Ecc ecl) { + vector segs = QrSegment::makeSegments(text); + return encodeSegments(segs, ecl); +} + + +QrCode QrCode::encodeBinary(const vector &data, Ecc ecl) { + vector segs{QrSegment::makeBytes(data)}; + return encodeSegments(segs, ecl); +} + + +QrCode QrCode::encodeSegments(const vector &segs, Ecc ecl, + int minVersion, int maxVersion, int mask, bool boostEcl) { + if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) + throw std::invalid_argument("Invalid value"); + + // Find the minimal version number to use + int version, dataUsedBits; + for (version = minVersion; ; version++) { + int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; // Number of data bits available + dataUsedBits = QrSegment::getTotalBits(segs, version); + if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits) + break; // This version number is found to be suitable + if (version >= maxVersion) { // All versions in the range could not fit the given data + std::ostringstream sb; + if (dataUsedBits == -1) + sb << "Segment too long"; + else { + sb << "Data length = " << dataUsedBits << " bits, "; + sb << "Max capacity = " << dataCapacityBits << " bits"; + } + throw data_too_long(sb.str()); + } + } + if (dataUsedBits == -1) + throw std::logic_error("Assertion error"); + + // Increase the error correction level while the data still fits in the current version number + for (Ecc newEcl : vector{Ecc::MEDIUM, Ecc::QUARTILE, Ecc::HIGH}) { // From low to high + if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8) + ecl = newEcl; + } + + // Concatenate all segments to create the data bit string + BitBuffer bb; + for (const QrSegment &seg : segs) { + bb.appendBits(static_cast(seg.getMode().getModeBits()), 4); + bb.appendBits(static_cast(seg.getNumChars()), seg.getMode().numCharCountBits(version)); + bb.insert(bb.end(), seg.getData().begin(), seg.getData().end()); + } + if (bb.size() != static_cast(dataUsedBits)) + throw std::logic_error("Assertion error"); + + // Add terminator and pad up to a byte if applicable + size_t dataCapacityBits = static_cast(getNumDataCodewords(version, ecl)) * 8; + if (bb.size() > dataCapacityBits) + throw std::logic_error("Assertion error"); + bb.appendBits(0, std::min(4, static_cast(dataCapacityBits - bb.size()))); + bb.appendBits(0, (8 - static_cast(bb.size() % 8)) % 8); + if (bb.size() % 8 != 0) + throw std::logic_error("Assertion error"); + + // Pad with alternating bytes until data capacity is reached + for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11) + bb.appendBits(padByte, 8); + + // Pack bits into bytes in big endian + vector dataCodewords(bb.size() / 8); + for (size_t i = 0; i < bb.size(); i++) + dataCodewords[i >> 3] |= (bb.at(i) ? 1 : 0) << (7 - (i & 7)); + + // Create the QR Code object + return QrCode(version, ecl, dataCodewords, mask); +} + + +QrCode::QrCode(int ver, Ecc ecl, const vector &dataCodewords, int msk) : + // Initialize fields and check arguments + version(ver), + errorCorrectionLevel(ecl) { + if (ver < MIN_VERSION || ver > MAX_VERSION) + throw std::domain_error("Version value out of range"); + if (msk < -1 || msk > 7) + throw std::domain_error("Mask value out of range"); + size = ver * 4 + 17; + size_t sz = static_cast(size); + modules = vector >(sz, vector(sz)); // Initially all white + isFunction = vector >(sz, vector(sz)); + + // Compute ECC, draw modules + drawFunctionPatterns(); + const vector allCodewords = addEccAndInterleave(dataCodewords); + drawCodewords(allCodewords); + + // Do masking + if (msk == -1) { // Automatically choose best mask + long minPenalty = LONG_MAX; + for (int i = 0; i < 8; i++) { + applyMask(i); + drawFormatBits(i); + long penalty = getPenaltyScore(); + if (penalty < minPenalty) { + msk = i; + minPenalty = penalty; + } + applyMask(i); // Undoes the mask due to XOR + } + } + if (msk < 0 || msk > 7) + throw std::logic_error("Assertion error"); + this->mask = msk; + applyMask(msk); // Apply the final choice of mask + drawFormatBits(msk); // Overwrite old format bits + + isFunction.clear(); + isFunction.shrink_to_fit(); +} + + +int QrCode::getVersion() const { + return version; +} + + +int QrCode::getSize() const { + return size; +} + + +QrCode::Ecc QrCode::getErrorCorrectionLevel() const { + return errorCorrectionLevel; +} + + +int QrCode::getMask() const { + return mask; +} + + +bool QrCode::getModule(int x, int y) const { + return 0 <= x && x < size && 0 <= y && y < size && module(x, y); +} + + +std::string QrCode::toSvgString(int border) const { + if (border < 0) + throw std::domain_error("Border must be non-negative"); + if (border > INT_MAX / 2 || border * 2 > INT_MAX - size) + throw std::overflow_error("Border too large"); + + std::ostringstream sb; + sb << "\n"; + sb << "\n"; + sb << "\n"; + sb << "\t\n"; + sb << "\t\n"; + sb << "\n"; + return sb.str(); +} + + +void QrCode::drawFunctionPatterns() { + // Draw horizontal and vertical timing patterns + for (int i = 0; i < size; i++) { + setFunctionModule(6, i, i % 2 == 0); + setFunctionModule(i, 6, i % 2 == 0); + } + + // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) + drawFinderPattern(3, 3); + drawFinderPattern(size - 4, 3); + drawFinderPattern(3, size - 4); + + // Draw numerous alignment patterns + const vector alignPatPos = getAlignmentPatternPositions(); + size_t numAlign = alignPatPos.size(); + for (size_t i = 0; i < numAlign; i++) { + for (size_t j = 0; j < numAlign; j++) { + // Don't draw on the three finder corners + if (!((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0))) + drawAlignmentPattern(alignPatPos.at(i), alignPatPos.at(j)); + } + } + + // Draw configuration data + drawFormatBits(0); // Dummy mask value; overwritten later in the constructor + drawVersion(); +} + + +void QrCode::drawFormatBits(int msk) { + // Calculate error correction code and pack bits + int data = getFormatBits(errorCorrectionLevel) << 3 | msk; // errCorrLvl is uint2, msk is uint3 + int rem = data; + for (int i = 0; i < 10; i++) + rem = (rem << 1) ^ ((rem >> 9) * 0x537); + int bits = (data << 10 | rem) ^ 0x5412; // uint15 + if (bits >> 15 != 0) + throw std::logic_error("Assertion error"); + + // Draw first copy + for (int i = 0; i <= 5; i++) + setFunctionModule(8, i, getBit(bits, i)); + setFunctionModule(8, 7, getBit(bits, 6)); + setFunctionModule(8, 8, getBit(bits, 7)); + setFunctionModule(7, 8, getBit(bits, 8)); + for (int i = 9; i < 15; i++) + setFunctionModule(14 - i, 8, getBit(bits, i)); + + // Draw second copy + for (int i = 0; i < 8; i++) + setFunctionModule(size - 1 - i, 8, getBit(bits, i)); + for (int i = 8; i < 15; i++) + setFunctionModule(8, size - 15 + i, getBit(bits, i)); + setFunctionModule(8, size - 8, true); // Always black +} + + +void QrCode::drawVersion() { + if (version < 7) + return; + + // Calculate error correction code and pack bits + int rem = version; // version is uint6, in the range [7, 40] + for (int i = 0; i < 12; i++) + rem = (rem << 1) ^ ((rem >> 11) * 0x1F25); + long bits = static_cast(version) << 12 | rem; // uint18 + if (bits >> 18 != 0) + throw std::logic_error("Assertion error"); + + // Draw two copies + for (int i = 0; i < 18; i++) { + bool bit = getBit(bits, i); + int a = size - 11 + i % 3; + int b = i / 3; + setFunctionModule(a, b, bit); + setFunctionModule(b, a, bit); + } +} + + +void QrCode::drawFinderPattern(int x, int y) { + for (int dy = -4; dy <= 4; dy++) { + for (int dx = -4; dx <= 4; dx++) { + int dist = std::max(std::abs(dx), std::abs(dy)); // Chebyshev/infinity norm + int xx = x + dx, yy = y + dy; + if (0 <= xx && xx < size && 0 <= yy && yy < size) + setFunctionModule(xx, yy, dist != 2 && dist != 4); + } + } +} + + +void QrCode::drawAlignmentPattern(int x, int y) { + for (int dy = -2; dy <= 2; dy++) { + for (int dx = -2; dx <= 2; dx++) + setFunctionModule(x + dx, y + dy, std::max(std::abs(dx), std::abs(dy)) != 1); + } +} + + +void QrCode::setFunctionModule(int x, int y, bool isBlack) { + size_t ux = static_cast(x); + size_t uy = static_cast(y); + modules .at(uy).at(ux) = isBlack; + isFunction.at(uy).at(ux) = true; +} + + +bool QrCode::module(int x, int y) const { + return modules.at(static_cast(y)).at(static_cast(x)); +} + + +vector QrCode::addEccAndInterleave(const vector &data) const { + if (data.size() != static_cast(getNumDataCodewords(version, errorCorrectionLevel))) + throw std::invalid_argument("Invalid argument"); + + // Calculate parameter numbers + int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[static_cast(errorCorrectionLevel)][version]; + int blockEccLen = ECC_CODEWORDS_PER_BLOCK [static_cast(errorCorrectionLevel)][version]; + int rawCodewords = getNumRawDataModules(version) / 8; + int numShortBlocks = numBlocks - rawCodewords % numBlocks; + int shortBlockLen = rawCodewords / numBlocks; + + // Split data into blocks and append ECC to each block + vector > blocks; + const vector rsDiv = reedSolomonComputeDivisor(blockEccLen); + for (int i = 0, k = 0; i < numBlocks; i++) { + vector dat(data.cbegin() + k, data.cbegin() + (k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1))); + k += static_cast(dat.size()); + const vector ecc = reedSolomonComputeRemainder(dat, rsDiv); + if (i < numShortBlocks) + dat.push_back(0); + dat.insert(dat.end(), ecc.cbegin(), ecc.cend()); + blocks.push_back(std::move(dat)); + } + + // Interleave (not concatenate) the bytes from every block into a single sequence + vector result; + for (size_t i = 0; i < blocks.at(0).size(); i++) { + for (size_t j = 0; j < blocks.size(); j++) { + // Skip the padding byte in short blocks + if (i != static_cast(shortBlockLen - blockEccLen) || j >= static_cast(numShortBlocks)) + result.push_back(blocks.at(j).at(i)); + } + } + if (result.size() != static_cast(rawCodewords)) + throw std::logic_error("Assertion error"); + return result; +} + + +void QrCode::drawCodewords(const vector &data) { + if (data.size() != static_cast(getNumRawDataModules(version) / 8)) + throw std::invalid_argument("Invalid argument"); + + size_t i = 0; // Bit index into the data + // Do the funny zigzag scan + for (int right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair + if (right == 6) + right = 5; + for (int vert = 0; vert < size; vert++) { // Vertical counter + for (int j = 0; j < 2; j++) { + size_t x = static_cast(right - j); // Actual x coordinate + bool upward = ((right + 1) & 2) == 0; + size_t y = static_cast(upward ? size - 1 - vert : vert); // Actual y coordinate + if (!isFunction.at(y).at(x) && i < data.size() * 8) { + modules.at(y).at(x) = getBit(data.at(i >> 3), 7 - static_cast(i & 7)); + i++; + } + // If this QR Code has any remainder bits (0 to 7), they were assigned as + // 0/false/white by the constructor and are left unchanged by this method + } + } + } + if (i != data.size() * 8) + throw std::logic_error("Assertion error"); +} + + +void QrCode::applyMask(int msk) { + if (msk < 0 || msk > 7) + throw std::domain_error("Mask value out of range"); + size_t sz = static_cast(size); + for (size_t y = 0; y < sz; y++) { + for (size_t x = 0; x < sz; x++) { + bool invert; + switch (msk) { + case 0: invert = (x + y) % 2 == 0; break; + case 1: invert = y % 2 == 0; break; + case 2: invert = x % 3 == 0; break; + case 3: invert = (x + y) % 3 == 0; break; + case 4: invert = (x / 3 + y / 2) % 2 == 0; break; + case 5: invert = x * y % 2 + x * y % 3 == 0; break; + case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; + case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; + default: throw std::logic_error("Assertion error"); + } + modules.at(y).at(x) = modules.at(y).at(x) ^ (invert & !isFunction.at(y).at(x)); + } + } +} + + +long QrCode::getPenaltyScore() const { + long result = 0; + + // Adjacent modules in row having same color, and finder-like patterns + for (int y = 0; y < size; y++) { + bool runColor = false; + int runX = 0; + std::array runHistory = {}; + for (int x = 0; x < size; x++) { + if (module(x, y) == runColor) { + runX++; + if (runX == 5) + result += PENALTY_N1; + else if (runX > 5) + result++; + } else { + finderPenaltyAddHistory(runX, runHistory); + if (!runColor) + result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3; + runColor = module(x, y); + runX = 1; + } + } + result += finderPenaltyTerminateAndCount(runColor, runX, runHistory) * PENALTY_N3; + } + // Adjacent modules in column having same color, and finder-like patterns + for (int x = 0; x < size; x++) { + bool runColor = false; + int runY = 0; + std::array runHistory = {}; + for (int y = 0; y < size; y++) { + if (module(x, y) == runColor) { + runY++; + if (runY == 5) + result += PENALTY_N1; + else if (runY > 5) + result++; + } else { + finderPenaltyAddHistory(runY, runHistory); + if (!runColor) + result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3; + runColor = module(x, y); + runY = 1; + } + } + result += finderPenaltyTerminateAndCount(runColor, runY, runHistory) * PENALTY_N3; + } + + // 2*2 blocks of modules having same color + for (int y = 0; y < size - 1; y++) { + for (int x = 0; x < size - 1; x++) { + bool color = module(x, y); + if ( color == module(x + 1, y) && + color == module(x, y + 1) && + color == module(x + 1, y + 1)) + result += PENALTY_N2; + } + } + + // Balance of black and white modules + int black = 0; + for (const vector &row : modules) { + for (bool color : row) { + if (color) + black++; + } + } + int total = size * size; // Note that size is odd, so black/total != 1/2 + // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)% + int k = static_cast((std::abs(black * 20L - total * 10L) + total - 1) / total) - 1; + result += k * PENALTY_N4; + return result; +} + + +vector QrCode::getAlignmentPatternPositions() const { + if (version == 1) + return vector(); + else { + int numAlign = version / 7 + 2; + int step = (version == 32) ? 26 : + (version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2; + vector result; + for (int i = 0, pos = size - 7; i < numAlign - 1; i++, pos -= step) + result.insert(result.begin(), pos); + result.insert(result.begin(), 6); + return result; + } +} + + +int QrCode::getNumRawDataModules(int ver) { + if (ver < MIN_VERSION || ver > MAX_VERSION) + throw std::domain_error("Version number out of range"); + int result = (16 * ver + 128) * ver + 64; + if (ver >= 2) { + int numAlign = ver / 7 + 2; + result -= (25 * numAlign - 10) * numAlign - 55; + if (ver >= 7) + result -= 36; + } + if (!(208 <= result && result <= 29648)) + throw std::logic_error("Assertion error"); + return result; +} + + +int QrCode::getNumDataCodewords(int ver, Ecc ecl) { + return getNumRawDataModules(ver) / 8 + - ECC_CODEWORDS_PER_BLOCK [static_cast(ecl)][ver] + * NUM_ERROR_CORRECTION_BLOCKS[static_cast(ecl)][ver]; +} + + +vector QrCode::reedSolomonComputeDivisor(int degree) { + if (degree < 1 || degree > 255) + throw std::domain_error("Degree out of range"); + // Polynomial coefficients are stored from highest to lowest power, excluding the leading term which is always 1. + // For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. + vector result(static_cast(degree)); + result.at(result.size() - 1) = 1; // Start off with the monomial x^0 + + // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), + // and drop the highest monomial term which is always 1x^degree. + // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). + uint8_t root = 1; + for (int i = 0; i < degree; i++) { + // Multiply the current product by (x - r^i) + for (size_t j = 0; j < result.size(); j++) { + result.at(j) = reedSolomonMultiply(result.at(j), root); + if (j + 1 < result.size()) + result.at(j) ^= result.at(j + 1); + } + root = reedSolomonMultiply(root, 0x02); + } + return result; +} + + +vector QrCode::reedSolomonComputeRemainder(const vector &data, const vector &divisor) { + vector result(divisor.size()); + for (uint8_t b : data) { // Polynomial division + uint8_t factor = b ^ result.at(0); + result.erase(result.begin()); + result.push_back(0); + for (size_t i = 0; i < result.size(); i++) + result.at(i) ^= reedSolomonMultiply(divisor.at(i), factor); + } + return result; +} + + +uint8_t QrCode::reedSolomonMultiply(uint8_t x, uint8_t y) { + // Russian peasant multiplication + int z = 0; + for (int i = 7; i >= 0; i--) { + z = (z << 1) ^ ((z >> 7) * 0x11D); + z ^= ((y >> i) & 1) * x; + } + if (z >> 8 != 0) + throw std::logic_error("Assertion error"); + return static_cast(z); +} + + +int QrCode::finderPenaltyCountPatterns(const std::array &runHistory) const { + int n = runHistory.at(1); + if (n > size * 3) + throw std::logic_error("Assertion error"); + bool core = n > 0 && runHistory.at(2) == n && runHistory.at(3) == n * 3 && runHistory.at(4) == n && runHistory.at(5) == n; + return (core && runHistory.at(0) >= n * 4 && runHistory.at(6) >= n ? 1 : 0) + + (core && runHistory.at(6) >= n * 4 && runHistory.at(0) >= n ? 1 : 0); +} + + +int QrCode::finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLength, std::array &runHistory) const { + if (currentRunColor) { // Terminate black run + finderPenaltyAddHistory(currentRunLength, runHistory); + currentRunLength = 0; + } + currentRunLength += size; // Add white border to final run + finderPenaltyAddHistory(currentRunLength, runHistory); + return finderPenaltyCountPatterns(runHistory); +} + + +void QrCode::finderPenaltyAddHistory(int currentRunLength, std::array &runHistory) const { + if (runHistory.at(0) == 0) + currentRunLength += size; // Add white border to initial run + std::copy_backward(runHistory.cbegin(), runHistory.cend() - 1, runHistory.end()); + runHistory.at(0) = currentRunLength; +} + + +bool QrCode::getBit(long x, int i) { + return ((x >> i) & 1) != 0; +} + + +/*---- Tables of constants ----*/ + +const int QrCode::PENALTY_N1 = 3; +const int QrCode::PENALTY_N2 = 3; +const int QrCode::PENALTY_N3 = 40; +const int QrCode::PENALTY_N4 = 10; + + +const int8_t QrCode::ECC_CODEWORDS_PER_BLOCK[4][41] = { + // Version: (note that index 0 is for padding, and is set to an illegal value) + //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level + {-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low + {-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28}, // Medium + {-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Quartile + {-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // High +}; + +const int8_t QrCode::NUM_ERROR_CORRECTION_BLOCKS[4][41] = { + // Version: (note that index 0 is for padding, and is set to an illegal value) + //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level + {-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low + {-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49}, // Medium + {-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68}, // Quartile + {-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81}, // High +}; + + +data_too_long::data_too_long(const std::string &msg) : + std::length_error(msg) {} + + + +BitBuffer::BitBuffer() + : std::vector() {} + + +void BitBuffer::appendBits(std::uint32_t val, int len) { + if (len < 0 || len > 31 || val >> len != 0) + throw std::domain_error("Value out of range"); + for (int i = len - 1; i >= 0; i--) // Append bit by bit + this->push_back(((val >> i) & 1) != 0); +} + +} diff --git a/third_party/qrcode/QrCode.hpp b/third_party/qrcode/QrCode.hpp new file mode 100644 index 00000000000000..7341e410292001 --- /dev/null +++ b/third_party/qrcode/QrCode.hpp @@ -0,0 +1,556 @@ +/* + * QR Code generator library (C++) + * + * Copyright (c) Project Nayuki. (MIT License) + * https://www.nayuki.io/page/qr-code-generator-library + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + + +namespace qrcodegen { + +/* + * A segment of character/binary/control data in a QR Code symbol. + * Instances of this class are immutable. + * The mid-level way to create a segment is to take the payload data + * and call a static factory function such as QrSegment::makeNumeric(). + * The low-level way to create a segment is to custom-make the bit buffer + * and call the QrSegment() constructor with appropriate values. + * This segment class imposes no length restrictions, but QR Codes have restrictions. + * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. + * Any segment longer than this is meaningless for the purpose of generating QR Codes. + */ +class QrSegment final { + + /*---- Public helper enumeration ----*/ + + /* + * Describes how a segment's data bits are interpreted. Immutable. + */ + public: class Mode final { + + /*-- Constants --*/ + + public: static const Mode NUMERIC; + public: static const Mode ALPHANUMERIC; + public: static const Mode BYTE; + public: static const Mode KANJI; + public: static const Mode ECI; + + + /*-- Fields --*/ + + // The mode indicator bits, which is a uint4 value (range 0 to 15). + private: int modeBits; + + // Number of character count bits for three different version ranges. + private: int numBitsCharCount[3]; + + + /*-- Constructor --*/ + + private: Mode(int mode, int cc0, int cc1, int cc2); + + + /*-- Methods --*/ + + /* + * (Package-private) Returns the mode indicator bits, which is an unsigned 4-bit value (range 0 to 15). + */ + public: int getModeBits() const; + + /* + * (Package-private) Returns the bit width of the character count field for a segment in + * this mode in a QR Code at the given version number. The result is in the range [0, 16]. + */ + public: int numCharCountBits(int ver) const; + + }; + + + + /*---- Static factory functions (mid level) ----*/ + + /* + * Returns a segment representing the given binary data encoded in + * byte mode. All input byte vectors are acceptable. Any text string + * can be converted to UTF-8 bytes and encoded as a byte mode segment. + */ + public: static QrSegment makeBytes(const std::vector &data); + + + /* + * Returns a segment representing the given string of decimal digits encoded in numeric mode. + */ + public: static QrSegment makeNumeric(const char *digits); + + + /* + * Returns a segment representing the given text string encoded in alphanumeric mode. + * The characters allowed are: 0 to 9, A to Z (uppercase only), space, + * dollar, percent, asterisk, plus, hyphen, period, slash, colon. + */ + public: static QrSegment makeAlphanumeric(const char *text); + + + /* + * Returns a list of zero or more segments to represent the given text string. The result + * may use various segment modes and switch modes to optimize the length of the bit stream. + */ + public: static std::vector makeSegments(const char *text); + + + /* + * Returns a segment representing an Extended Channel Interpretation + * (ECI) designator with the given assignment value. + */ + public: static QrSegment makeEci(long assignVal); + + + /*---- Public static helper functions ----*/ + + /* + * Tests whether the given string can be encoded as a segment in alphanumeric mode. + * A string is encodable iff each character is in the following set: 0 to 9, A to Z + * (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon. + */ + public: static bool isAlphanumeric(const char *text); + + + /* + * Tests whether the given string can be encoded as a segment in numeric mode. + * A string is encodable iff each character is in the range 0 to 9. + */ + public: static bool isNumeric(const char *text); + + + + /*---- Instance fields ----*/ + + /* The mode indicator of this segment. Accessed through getMode(). */ + private: Mode mode; + + /* The length of this segment's unencoded data. Measured in characters for + * numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode. + * Always zero or positive. Not the same as the data's bit length. + * Accessed through getNumChars(). */ + private: int numChars; + + /* The data bits of this segment. Accessed through getData(). */ + private: std::vector data; + + + /*---- Constructors (low level) ----*/ + + /* + * Creates a new QR Code segment with the given attributes and data. + * The character count (numCh) must agree with the mode and the bit buffer length, + * but the constraint isn't checked. The given bit buffer is copied and stored. + */ + public: QrSegment(Mode md, int numCh, const std::vector &dt); + + + /* + * Creates a new QR Code segment with the given parameters and data. + * The character count (numCh) must agree with the mode and the bit buffer length, + * but the constraint isn't checked. The given bit buffer is moved and stored. + */ + public: QrSegment(Mode md, int numCh, std::vector &&dt); + + + /*---- Methods ----*/ + + /* + * Returns the mode field of this segment. + */ + public: Mode getMode() const; + + + /* + * Returns the character count field of this segment. + */ + public: int getNumChars() const; + + + /* + * Returns the data bits of this segment. + */ + public: const std::vector &getData() const; + + + // (Package-private) Calculates the number of bits needed to encode the given segments at + // the given version. Returns a non-negative number if successful. Otherwise returns -1 if a + // segment has too many characters to fit its length field, or the total bits exceeds INT_MAX. + public: static int getTotalBits(const std::vector &segs, int version); + + + /*---- Private constant ----*/ + + /* The set of all legal characters in alphanumeric mode, where + * each character value maps to the index in the string. */ + private: static const char *ALPHANUMERIC_CHARSET; + +}; + + + +/* + * A QR Code symbol, which is a type of two-dimension barcode. + * Invented by Denso Wave and described in the ISO/IEC 18004 standard. + * Instances of this class represent an immutable square grid of black and white cells. + * The class provides static factory functions to create a QR Code from text or binary data. + * The class covers the QR Code Model 2 specification, supporting all versions (sizes) + * from 1 to 40, all 4 error correction levels, and 4 character encoding modes. + * + * Ways to create a QR Code object: + * - High level: Take the payload data and call QrCode::encodeText() or QrCode::encodeBinary(). + * - Mid level: Custom-make the list of segments and call QrCode::encodeSegments(). + * - Low level: Custom-make the array of data codeword bytes (including + * segment headers and final padding, excluding error correction codewords), + * supply the appropriate version number, and call the QrCode() constructor. + * (Note that all ways require supplying the desired error correction level.) + */ +class QrCode final { + + /*---- Public helper enumeration ----*/ + + /* + * The error correction level in a QR Code symbol. + */ + public: enum class Ecc { + LOW = 0 , // The QR Code can tolerate about 7% erroneous codewords + MEDIUM , // The QR Code can tolerate about 15% erroneous codewords + QUARTILE, // The QR Code can tolerate about 25% erroneous codewords + HIGH , // The QR Code can tolerate about 30% erroneous codewords + }; + + + // Returns a value in the range 0 to 3 (unsigned 2-bit integer). + private: static int getFormatBits(Ecc ecl); + + + + /*---- Static factory functions (high level) ----*/ + + /* + * Returns a QR Code representing the given Unicode text string at the given error correction level. + * As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer + * UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible + * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than + * the ecl argument if it can be done without increasing the version. + */ + public: static QrCode encodeText(const char *text, Ecc ecl); + + + /* + * Returns a QR Code representing the given binary data at the given error correction level. + * This function always encodes using the binary segment mode, not any text mode. The maximum number of + * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. + * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. + */ + public: static QrCode encodeBinary(const std::vector &data, Ecc ecl); + + + /*---- Static factory functions (mid level) ----*/ + + /* + * Returns a QR Code representing the given segments with the given encoding parameters. + * The smallest possible QR Code version within the given range is automatically + * chosen for the output. Iff boostEcl is true, then the ECC level of the result + * may be higher than the ecl argument if it can be done without increasing the + * version. The mask number is either between 0 to 7 (inclusive) to force that + * mask, or -1 to automatically choose an appropriate mask (which may be slow). + * This function allows the user to create a custom sequence of segments that switches + * between modes (such as alphanumeric and byte) to encode text in less space. + * This is a mid-level API; the high-level API is encodeText() and encodeBinary(). + */ + public: static QrCode encodeSegments(const std::vector &segs, Ecc ecl, + int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true); // All optional parameters + + + + /*---- Instance fields ----*/ + + // Immutable scalar parameters: + + /* The version number of this QR Code, which is between 1 and 40 (inclusive). + * This determines the size of this barcode. */ + private: int version; + + /* The width and height of this QR Code, measured in modules, between + * 21 and 177 (inclusive). This is equal to version * 4 + 17. */ + private: int size; + + /* The error correction level used in this QR Code. */ + private: Ecc errorCorrectionLevel; + + /* The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). + * Even if a QR Code is created with automatic masking requested (mask = -1), + * the resulting object still has a mask value between 0 and 7. */ + private: int mask; + + // Private grids of modules/pixels, with dimensions of size*size: + + // The modules of this QR Code (false = white, true = black). + // Immutable after constructor finishes. Accessed through getModule(). + private: std::vector > modules; + + // Indicates function modules that are not subjected to masking. Discarded when constructor finishes. + private: std::vector > isFunction; + + + + /*---- Constructor (low level) ----*/ + + /* + * Creates a new QR Code with the given version number, + * error correction level, data codeword bytes, and mask number. + * This is a low-level API that most users should not use directly. + * A mid-level API is the encodeSegments() function. + */ + public: QrCode(int ver, Ecc ecl, const std::vector &dataCodewords, int msk); + + + + /*---- Public instance methods ----*/ + + /* + * Returns this QR Code's version, in the range [1, 40]. + */ + public: int getVersion() const; + + + /* + * Returns this QR Code's size, in the range [21, 177]. + */ + public: int getSize() const; + + + /* + * Returns this QR Code's error correction level. + */ + public: Ecc getErrorCorrectionLevel() const; + + + /* + * Returns this QR Code's mask, in the range [0, 7]. + */ + public: int getMask() const; + + + /* + * Returns the color of the module (pixel) at the given coordinates, which is false + * for white or true for black. The top left corner has the coordinates (x=0, y=0). + * If the given coordinates are out of bounds, then false (white) is returned. + */ + public: bool getModule(int x, int y) const; + + + /* + * Returns a string of SVG code for an image depicting this QR Code, with the given number + * of border modules. The string always uses Unix newlines (\n), regardless of the platform. + */ + public: std::string toSvgString(int border) const; + + + + /*---- Private helper methods for constructor: Drawing function modules ----*/ + + // Reads this object's version field, and draws and marks all function modules. + private: void drawFunctionPatterns(); + + + // Draws two copies of the format bits (with its own error correction code) + // based on the given mask and this object's error correction level field. + private: void drawFormatBits(int msk); + + + // Draws two copies of the version bits (with its own error correction code), + // based on this object's version field, iff 7 <= version <= 40. + private: void drawVersion(); + + + // Draws a 9*9 finder pattern including the border separator, + // with the center module at (x, y). Modules can be out of bounds. + private: void drawFinderPattern(int x, int y); + + + // Draws a 5*5 alignment pattern, with the center module + // at (x, y). All modules must be in bounds. + private: void drawAlignmentPattern(int x, int y); + + + // Sets the color of a module and marks it as a function module. + // Only used by the constructor. Coordinates must be in bounds. + private: void setFunctionModule(int x, int y, bool isBlack); + + + // Returns the color of the module at the given coordinates, which must be in range. + private: bool module(int x, int y) const; + + + /*---- Private helper methods for constructor: Codewords and masking ----*/ + + // Returns a new byte string representing the given data with the appropriate error correction + // codewords appended to it, based on this object's version and error correction level. + private: std::vector addEccAndInterleave(const std::vector &data) const; + + + // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire + // data area of this QR Code. Function modules need to be marked off before this is called. + private: void drawCodewords(const std::vector &data); + + + // XORs the codeword modules in this QR Code with the given mask pattern. + // The function modules must be marked and the codeword bits must be drawn + // before masking. Due to the arithmetic of XOR, calling applyMask() with + // the same mask value a second time will undo the mask. A final well-formed + // QR Code needs exactly one (not zero, two, etc.) mask applied. + private: void applyMask(int msk); + + + // Calculates and returns the penalty score based on state of this QR Code's current modules. + // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. + private: long getPenaltyScore() const; + + + + /*---- Private helper functions ----*/ + + // Returns an ascending list of positions of alignment patterns for this version number. + // Each position is in the range [0,177), and are used on both the x and y axes. + // This could be implemented as lookup table of 40 variable-length lists of unsigned bytes. + private: std::vector getAlignmentPatternPositions() const; + + + // Returns the number of data bits that can be stored in a QR Code of the given version number, after + // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. + // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. + private: static int getNumRawDataModules(int ver); + + + // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any + // QR Code of the given version number and error correction level, with remainder bits discarded. + // This stateless pure function could be implemented as a (40*4)-cell lookup table. + private: static int getNumDataCodewords(int ver, Ecc ecl); + + + // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be + // implemented as a lookup table over all possible parameter values, instead of as an algorithm. + private: static std::vector reedSolomonComputeDivisor(int degree); + + + // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials. + private: static std::vector reedSolomonComputeRemainder(const std::vector &data, const std::vector &divisor); + + + // Returns the product of the two given field elements modulo GF(2^8/0x11D). + // All inputs are valid. This could be implemented as a 256*256 lookup table. + private: static std::uint8_t reedSolomonMultiply(std::uint8_t x, std::uint8_t y); + + + // Can only be called immediately after a white run is added, and + // returns either 0, 1, or 2. A helper function for getPenaltyScore(). + private: int finderPenaltyCountPatterns(const std::array &runHistory) const; + + + // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore(). + private: int finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLength, std::array &runHistory) const; + + + // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore(). + private: void finderPenaltyAddHistory(int currentRunLength, std::array &runHistory) const; + + + // Returns true iff the i'th bit of x is set to 1. + private: static bool getBit(long x, int i); + + + /*---- Constants and tables ----*/ + + // The minimum version number supported in the QR Code Model 2 standard. + public: static constexpr int MIN_VERSION = 1; + + // The maximum version number supported in the QR Code Model 2 standard. + public: static constexpr int MAX_VERSION = 40; + + + // For use in getPenaltyScore(), when evaluating which mask is best. + private: static const int PENALTY_N1; + private: static const int PENALTY_N2; + private: static const int PENALTY_N3; + private: static const int PENALTY_N4; + + + private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41]; + private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41]; + +}; + + + +/*---- Public exception class ----*/ + +/* + * Thrown when the supplied data does not fit any QR Code version. Ways to handle this exception include: + * - Decrease the error correction level if it was greater than Ecc::LOW. + * - If the encodeSegments() function was called with a maxVersion argument, then increase + * it if it was less than QrCode::MAX_VERSION. (This advice does not apply to the other + * factory functions because they search all versions up to QrCode::MAX_VERSION.) + * - Split the text data into better or optimal segments in order to reduce the number of bits required. + * - Change the text or binary data to be shorter. + * - Change the text to fit the character set of a particular segment mode (e.g. alphanumeric). + * - Propagate the error upward to the caller/user. + */ +class data_too_long : public std::length_error { + + public: explicit data_too_long(const std::string &msg); + +}; + + + +/* + * An appendable sequence of bits (0s and 1s). Mainly used by QrSegment. + */ +class BitBuffer final : public std::vector { + + /*---- Constructor ----*/ + + // Creates an empty bit buffer (length 0). + public: BitBuffer(); + + + + /*---- Method ----*/ + + // Appends the given number of low-order bits of the given value + // to this buffer. Requires 0 <= len <= 31 and val < 2^len. + public: void appendBits(std::uint32_t val, int len); + +}; + +} diff --git a/third_party/snpe/aarch64 b/third_party/snpe/aarch64 new file mode 120000 index 00000000000000..baf4e9cb6ed759 --- /dev/null +++ b/third_party/snpe/aarch64 @@ -0,0 +1 @@ +aarch64-android-clang6.0 \ No newline at end of file diff --git a/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so b/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so new file mode 100644 index 00000000000000..5df5b07b18bb15 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libSNPE.so b/third_party/snpe/aarch64-android-clang6.0/libSNPE.so new file mode 100644 index 00000000000000..6ef777e15b77d1 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libSNPE.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so b/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so new file mode 100644 index 00000000000000..565c80bb68c5ce Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so b/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so new file mode 100644 index 00000000000000..5b9a9cff612be4 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libcalculator.so b/third_party/snpe/aarch64-android-clang6.0/libcalculator.so new file mode 100644 index 00000000000000..3aa1ec3ac27cc6 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libcalculator.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so b/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so new file mode 100644 index 00000000000000..bef3fc20192cf6 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libhta.so b/third_party/snpe/aarch64-android-clang6.0/libhta.so new file mode 100644 index 00000000000000..bfd3554cf78b14 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libhta.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so new file mode 100644 index 00000000000000..8a6b4e3fc5a085 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so new file mode 100644 index 00000000000000..0663d25e3378ad Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so new file mode 100644 index 00000000000000..33d354ff7d4764 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so new file mode 100644 index 00000000000000..5a63344590a106 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so new file mode 100644 index 00000000000000..2d74ae0f055f9c Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so b/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so new file mode 100644 index 00000000000000..8dd26fb26664d7 Binary files /dev/null and b/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libPlatformValidatorShared.so b/third_party/snpe/aarch64-linux-gcc4.9/libPlatformValidatorShared.so new file mode 100644 index 00000000000000..32f8e2f60e224a Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libPlatformValidatorShared.so differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libSNPE.so b/third_party/snpe/aarch64-linux-gcc4.9/libSNPE.so new file mode 100644 index 00000000000000..6f497cfa08321d Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libSNPE.so differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libatomic.so.1 b/third_party/snpe/aarch64-linux-gcc4.9/libatomic.so.1 new file mode 100644 index 00000000000000..809fd4ef6ffe79 Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libatomic.so.1 differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libcalculator.so b/third_party/snpe/aarch64-linux-gcc4.9/libcalculator.so new file mode 100644 index 00000000000000..dd3bfe5afd2644 Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libcalculator.so differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libcalculator_domains.so b/third_party/snpe/aarch64-linux-gcc4.9/libcalculator_domains.so new file mode 100644 index 00000000000000..05cf724b7b09d6 Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libcalculator_domains.so differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_adsp.so b/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_adsp.so new file mode 100644 index 00000000000000..11db2cdf6d83de Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_adsp.so differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_dsp_domains_v2.so b/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_dsp_domains_v2.so new file mode 100644 index 00000000000000..cc8a8dc2aefe54 Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_dsp_domains_v2.so differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libsymphony-cpu.so b/third_party/snpe/aarch64-linux-gcc4.9/libsymphony-cpu.so new file mode 100644 index 00000000000000..202d7e9710da17 Binary files /dev/null and b/third_party/snpe/aarch64-linux-gcc4.9/libsymphony-cpu.so differ diff --git a/third_party/snpe/dsp/libcalculator_domains_skel.so b/third_party/snpe/dsp/libcalculator_domains_skel.so new file mode 100644 index 00000000000000..cb8897f23943f0 Binary files /dev/null and b/third_party/snpe/dsp/libcalculator_domains_skel.so differ diff --git a/third_party/snpe/dsp/libcalculator_skel.so b/third_party/snpe/dsp/libcalculator_skel.so new file mode 100644 index 00000000000000..45515ea4f44fca Binary files /dev/null and b/third_party/snpe/dsp/libcalculator_skel.so differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_domains_skel.so b/third_party/snpe/dsp/libsnpe_dsp_domains_skel.so new file mode 100644 index 00000000000000..d4e341262a5180 Binary files /dev/null and b/third_party/snpe/dsp/libsnpe_dsp_domains_skel.so differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_skel.so b/third_party/snpe/dsp/libsnpe_dsp_skel.so new file mode 100644 index 00000000000000..cb37356a98ceef Binary files /dev/null and b/third_party/snpe/dsp/libsnpe_dsp_skel.so differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_v65_domains_v2_skel.so b/third_party/snpe/dsp/libsnpe_dsp_v65_domains_v2_skel.so new file mode 100644 index 00000000000000..97a1499a042321 Binary files /dev/null and b/third_party/snpe/dsp/libsnpe_dsp_v65_domains_v2_skel.so differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_v66_domains_v2_skel.so b/third_party/snpe/dsp/libsnpe_dsp_v66_domains_v2_skel.so new file mode 100644 index 00000000000000..008e9e97805918 Binary files /dev/null and b/third_party/snpe/dsp/libsnpe_dsp_v66_domains_v2_skel.so differ diff --git a/phonelibs/snpe/include/DiagLog/IDiagLog.hpp b/third_party/snpe/include/DiagLog/IDiagLog.hpp similarity index 91% rename from phonelibs/snpe/include/DiagLog/IDiagLog.hpp rename to third_party/snpe/include/DiagLog/IDiagLog.hpp index af1ef8917e8627..018b5672561c0b 100644 --- a/phonelibs/snpe/include/DiagLog/IDiagLog.hpp +++ b/third_party/snpe/include/DiagLog/IDiagLog.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,14 +8,11 @@ #ifndef __IDIAGLOG_HPP_ #define __IDIAGLOG_HPP_ -#ifndef ZDL_LOGGING_EXPORT -#define ZDL_LOGGING_EXPORT __attribute__((visibility("default"))) -#endif - #include #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/third_party/snpe/include/DiagLog/Options.hpp similarity index 80% rename from phonelibs/snpe/include/DiagLog/Options.hpp rename to third_party/snpe/include/DiagLog/Options.hpp index ba0c82119bfebb..798fa3f1240a62 100644 --- a/phonelibs/snpe/include/DiagLog/Options.hpp +++ b/third_party/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/third_party/snpe/include/DlContainer/IDlContainer.hpp b/third_party/snpe/include/DlContainer/IDlContainer.hpp new file mode 100644 index 00000000000000..4e29b39bb41eb8 --- /dev/null +++ b/third_party/snpe/include/DlContainer/IDlContainer.hpp @@ -0,0 +1,191 @@ +//============================================================================= +// +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================= + +#ifndef ZEROTH_IDNC_CONTAINER_HPP +#define ZEROTH_IDNC_CONTAINER_HPP + +#include +#include +#include +#include +#include + +#include "DlSystem/ZdlExportDefine.hpp" +#include "DlSystem/String.hpp" + +namespace zdl { +namespace DlContainer { + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +class IDlContainer; +class dlc_error; + +/** + * The structure of a record in a DL container. + */ +struct ZDL_EXPORT DlcRecord +{ + /// Name of the record. + std::string name; + /// Byte blob holding the data for the record. + std::vector data; + + DlcRecord(); + DlcRecord( DlcRecord&& other ) + : 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; +}; + +// The maximum length of any record name. +extern const uint32_t RECORD_NAME_MAX_SIZE; +// The maximum size of the record payload (bytes). +extern const uint32_t RECORD_DATA_MAX_SIZE; +// The maximum number of records in an archive at one time. +extern const uint32_t ARCHIVE_MAX_RECORDS; + +/** + * Represents a container for a neural network model which can + * be used to load the model into the SNPE runtime. + */ +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 + */ + static std::unique_ptr + open(const std::string &filename) noexcept; + + /** + * Initializes a container from a container archive file. + * + * @param[in] filename Container archive file path. + * + * @return A pointer to the initialized container + */ + 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 + * file. + * + * @return A pointer to the initialized container + */ + 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 + * file. + * + * @param[in] size Size of the byte buffer. + * + * @return A pointer to the initialized container + */ + static std::unique_ptr + open(const uint8_t* buffer, const size_t size) noexcept; + + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + + /** + * Get the record catalog for a container. + * + * @param[out] catalog Buffer that will hold the record names on + * return. + */ + virtual void getCatalog(std::set &catalog) const = 0; + + /** + * Get the record catalog for a container. + * + * @param[out] catalog Buffer that will hold the record names on + * return. + */ + virtual void getCatalog(std::set &catalog) const = 0; + + /** + * 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 + * will own the data in the record and is + * responsible for freeing it if needed. + */ + virtual void getRecord(const std::string &name, DlcRecord &record) const = 0; + + /** + * 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 + * will own the data in the record and is + * responsible for freeing it if needed. + */ + 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() {} +}; + +} // ns DlContainer +} // ns zdl + + +#endif diff --git a/third_party/snpe/include/DlSystem/DlEnums.hpp b/third_party/snpe/include/DlSystem/DlEnums.hpp new file mode 100644 index 00000000000000..14470635538767 --- /dev/null +++ b/third_party/snpe/include/DlSystem/DlEnums.hpp @@ -0,0 +1,202 @@ +//============================================================================== +// +// Copyright (c) 2014-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef _DL_ENUMS_HPP_ +#define _DL_ENUMS_HPP_ + +#include "DlSystem/ZdlExportDefine.hpp" + + +namespace zdl { +namespace DlSystem +{ +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * Enumeration of supported target runtimes. + */ +enum class Runtime_t +{ + /// Run the processing on Snapdragon CPU. + /// Data: float 32bit + /// Math: float 32bit + CPU_FLOAT32 = 0, + + /// Run the processing on the Adreno GPU. + /// Data: float 16bit + /// Math: float 32bit + GPU_FLOAT32_16_HYBRID = 1, + + /// Run the processing on the Hexagon DSP. + /// Data: 8bit fixed point Tensorflow style format + /// Math: 8bit fixed point Tensorflow style format + DSP_FIXED8_TF = 2, + + /// Run the processing on the Adreno GPU. + /// Data: float 16bit + /// 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, + + /// Default legacy enum to retain backward compatibility. + /// GPU = GPU_FLOAT32_16_HYBRID + GPU = GPU_FLOAT32_16_HYBRID, + + /// Default legacy enum to retain backward compatibility. + /// 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, +}; + +/** + * Enumeration of various performance profiles that can be requested. + */ +enum class PerformanceProfile_t +{ + /// Run in a standard mode. + /// This mode will be deprecated in the future and replaced with BALANCED. + DEFAULT = 0, + /// Run in a balanced mode. + BALANCED = 0, + + /// Run in high performance mode + HIGH_PERFORMANCE = 1, + + /// Run in a power sensitive mode, at the expense of performance. + POWER_SAVER = 2, + + /// Use system settings. SNPE makes no calls to any performance related APIs. + SYSTEM_SETTINGS = 3, + + /// Run in sustained high performance mode + 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 +}; + +/** + * Enumeration of various execution priority hints. + */ +enum class ExecutionPriorityHint_t +{ + /// Normal priority + NORMAL = 0, + + /// Higher than normal priority + HIGH = 1, + + /// Lower priority + LOW = 2 + +}; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++*/ + +/** + * Enumeration that lists the supported image encoding formats. + */ +enum class ImageEncoding_t +{ + /// For unknown image type. Also used as a default value for ImageEncoding_t. + UNKNOWN = 0, + + /// 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 = 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 = 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 = 3, + + /// The GRAYSCALE format is for 8-bit 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 = 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 = 6 +}; + +}} // namespaces end + + +#endif diff --git a/phonelibs/snpe/include/DlSystem/DlError.hpp b/third_party/snpe/include/DlSystem/DlError.hpp similarity index 79% rename from phonelibs/snpe/include/DlSystem/DlError.hpp rename to third_party/snpe/include/DlSystem/DlError.hpp index 383403b5418a26..f0a66e8e458ad1 100644 --- a/phonelibs/snpe/include/DlSystem/DlError.hpp +++ b/third_party/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/third_party/snpe/include/DlSystem/DlOptional.hpp similarity index 94% rename from phonelibs/snpe/include/DlSystem/DlOptional.hpp rename to third_party/snpe/include/DlSystem/DlOptional.hpp index 2c41b6b6894ee4..4f83e6b4e417fc 100644 --- a/phonelibs/snpe/include/DlSystem/DlOptional.hpp +++ b/third_party/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/DlVersion.hpp b/third_party/snpe/include/DlSystem/DlVersion.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/DlVersion.hpp rename to third_party/snpe/include/DlSystem/DlVersion.hpp diff --git a/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp b/third_party/snpe/include/DlSystem/IBufferAttributes.hpp similarity index 81% rename from phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp rename to third_party/snpe/include/DlSystem/IBufferAttributes.hpp index e80f6c134c9ab4..f893e0a2370880 100644 --- a/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp +++ b/third_party/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/third_party/snpe/include/DlSystem/ITensor.hpp similarity index 98% rename from phonelibs/snpe/include/DlSystem/ITensor.hpp rename to third_party/snpe/include/DlSystem/ITensor.hpp index ed6d5f1072e888..2f006c857fc442 100644 --- a/phonelibs/snpe/include/DlSystem/ITensor.hpp +++ b/third_party/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/ITensorFactory.hpp b/third_party/snpe/include/DlSystem/ITensorFactory.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/ITensorFactory.hpp rename to third_party/snpe/include/DlSystem/ITensorFactory.hpp diff --git a/phonelibs/snpe/include/DlSystem/ITensorItr.hpp b/third_party/snpe/include/DlSystem/ITensorItr.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/ITensorItr.hpp rename to third_party/snpe/include/DlSystem/ITensorItr.hpp diff --git a/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp b/third_party/snpe/include/DlSystem/ITensorItrImpl.hpp similarity index 93% rename from phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp rename to third_party/snpe/include/DlSystem/ITensorItrImpl.hpp index 7923c160b95b0d..069e7a1d69031f 100644 --- a/phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp +++ b/third_party/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/IUDL.hpp b/third_party/snpe/include/DlSystem/IUDL.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/IUDL.hpp rename to third_party/snpe/include/DlSystem/IUDL.hpp diff --git a/third_party/snpe/include/DlSystem/IUserBuffer.hpp b/third_party/snpe/include/DlSystem/IUserBuffer.hpp new file mode 100644 index 00000000000000..5e5731dd83a41d --- /dev/null +++ b/third_party/snpe/include/DlSystem/IUserBuffer.hpp @@ -0,0 +1,421 @@ +//============================================================================== +// +// Copyright (c) 2017-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef _IUSER_BUFFER_HPP +#define _IUSER_BUFFER_HPP + +#include "TensorShape.hpp" +#include "ZdlExportDefine.hpp" +#include + +namespace zdl { +namespace DlSystem { + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + + +/** + * @brief . + * + * A base class buffer encoding type + */ +class ZDL_EXPORT UserBufferEncoding { +public: + + /** + * @brief . + * + * An enum class of all supported element types in a IUserBuffer + */ + enum class ElementType_t + { + /// Unknown element type. + UNKNOWN = 0, + + /// Each element is presented by float. + FLOAT = 1, + + /// Each element is presented by an unsigned int. + UNSIGNED8BIT = 2, + + /// Each element is presented by an 8-bit quantized value. + TF8 = 10, + + /// Each element is presented by an 16-bit quantized value. + TF16 = 11 + }; + + /** + * @brief Retrieves the size of the element, in bytes. + * + * @return Size of the element, in bytes. + */ + virtual size_t getElementSize() const noexcept = 0; + + /** + * @brief Retrieves the element type + * + * @return Element type + */ + ElementType_t getElementType() const noexcept {return m_ElementType;}; + + virtual ~UserBufferEncoding() {} + +protected: + UserBufferEncoding(ElementType_t elementType) : m_ElementType(elementType) {}; +private: + const ElementType_t m_ElementType; +}; + +/** + * @brief . + * + * A base class buffer source type + * + * @note User buffer from CPU support all kinds of runtimes; + * User buffer from GLBUFFER support only GPU runtime. + */ +class ZDL_EXPORT UserBufferSource { +public: + enum class SourceType_t + { + /// Unknown buffer source type. + UNKNOWN = 0, + + /// The network inputs are from CPU buffer. + CPU = 1, + + /// The network inputs are from OpenGL buffer. + GLBUFFER = 2 + }; + + /** + * @brief Retrieves the source type + * + * @return Source type + */ + SourceType_t getSourceType() const noexcept {return m_SourceType;}; + +protected: + UserBufferSource(SourceType_t sourceType): m_SourceType(sourceType) {}; +private: + const SourceType_t m_SourceType; +}; + +/** + * @brief . + * + * An source type where input data is delivered from OpenGL buffer + */ +class ZDL_EXPORT UserBufferSourceGLBuffer : public UserBufferSource{ +public: + UserBufferSourceGLBuffer() : UserBufferSource(SourceType_t::GLBUFFER) {}; +}; + +/** + * @brief . + * + * An encoding type where each element is represented by an unsigned int + */ +class ZDL_EXPORT UserBufferEncodingUnsigned8Bit : public UserBufferEncoding { +public: + UserBufferEncodingUnsigned8Bit() : UserBufferEncoding(ElementType_t::UNSIGNED8BIT) {}; + size_t getElementSize() const noexcept override; + +protected: + UserBufferEncodingUnsigned8Bit(ElementType_t elementType) : UserBufferEncoding(elementType) {}; + +}; + +/** + * @brief . + * + * An encoding type where each element is represented by a float + */ +class ZDL_EXPORT UserBufferEncodingFloat : public UserBufferEncoding { +public: + UserBufferEncodingFloat() : UserBufferEncoding(ElementType_t::FLOAT) {}; + size_t getElementSize() const noexcept override; + +}; + +/** + * @brief . + * + * 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; + UserBufferEncodingTf8(unsigned char stepFor0, float stepSize) : + UserBufferEncodingUnsigned8Bit(ElementType_t::TF8), + 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; + } + +private: + unsigned char m_StepExactly0; + + 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. + */ +class ZDL_EXPORT IUserBuffer { +public: + virtual ~IUserBuffer() = default; + + /** + * @brief Retrieves the total number of bytes between elements in each dimension if + * the buffer were to be interpreted as a multi-dimensional array. + * + * @return Number of bytes between elements in each dimension. + * e.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would + * return strides of [24, 8, 4]. + */ + virtual const TensorShape& getStrides() const = 0; + + /** + * @brief Retrieves the size of the buffer, in bytes. + * + * @return Size of the underlying buffer, in bytes. + */ + 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. + * + * This can be used to avoid creating multiple UserBuffer objects + * when the only thing that differs is the memory location. + * + * @param[in] buffer Pointer to the memory location + * + * @return Whether the set succeeds. + */ + virtual bool setBufferAddress(void *buffer) noexcept = 0; + + /** + * @brief Gets a const reference to the data encoding object of + * the underlying buffer + * + * This is necessary when the UserBuffer is filled by SNPE with + * data types such as TF8, where the caller needs to know the quantization + * parameters in order to interpret the data properly + * + * @return A read-only encoding object + */ + virtual const UserBufferEncoding& getEncoding() const noexcept = 0; + + /** + * @brief Gets a reference to the data encoding object of + * the underlying buffer + * + * This is necessary when the UserBuffer is re-used, and the encoding + * parameters can change. For example, each input can be quantized with + * different step sizes. + * + * @return Data encoding meta-data + */ + virtual UserBufferEncoding& getEncoding() noexcept = 0; + +}; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +} +} + +#endif diff --git a/phonelibs/snpe/include/DlSystem/IUserBufferFactory.hpp b/third_party/snpe/include/DlSystem/IUserBufferFactory.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/IUserBufferFactory.hpp rename to third_party/snpe/include/DlSystem/IUserBufferFactory.hpp diff --git a/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp b/third_party/snpe/include/DlSystem/PlatformConfig.hpp similarity index 78% rename from phonelibs/snpe/include/DlSystem/PlatformConfig.hpp rename to third_party/snpe/include/DlSystem/PlatformConfig.hpp index df452dc46970bf..3f15f177e3eeba 100644 --- a/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp +++ b/third_party/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/third_party/snpe/include/DlSystem/RuntimeList.hpp b/third_party/snpe/include/DlSystem/RuntimeList.hpp new file mode 100644 index 00000000000000..1088a5b31f4538 --- /dev/null +++ b/third_party/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/third_party/snpe/include/DlSystem/String.hpp similarity index 94% rename from phonelibs/snpe/include/DlSystem/String.hpp rename to third_party/snpe/include/DlSystem/String.hpp index 97b07726c72bc7..c1eba3bad96b02 100644 --- a/phonelibs/snpe/include/DlSystem/String.hpp +++ b/third_party/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/StringList.hpp b/third_party/snpe/include/DlSystem/StringList.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/StringList.hpp rename to third_party/snpe/include/DlSystem/StringList.hpp diff --git a/phonelibs/snpe/include/DlSystem/TensorMap.hpp b/third_party/snpe/include/DlSystem/TensorMap.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/TensorMap.hpp rename to third_party/snpe/include/DlSystem/TensorMap.hpp diff --git a/phonelibs/snpe/include/DlSystem/TensorShape.hpp b/third_party/snpe/include/DlSystem/TensorShape.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/TensorShape.hpp rename to third_party/snpe/include/DlSystem/TensorShape.hpp diff --git a/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp b/third_party/snpe/include/DlSystem/TensorShapeMap.hpp similarity index 97% rename from phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp rename to third_party/snpe/include/DlSystem/TensorShapeMap.hpp index 00dc41a113160d..cef946e2e6dbc9 100644 --- a/phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp +++ b/third_party/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/UDLContext.hpp b/third_party/snpe/include/DlSystem/UDLContext.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/UDLContext.hpp rename to third_party/snpe/include/DlSystem/UDLContext.hpp diff --git a/phonelibs/snpe/include/DlSystem/UDLFunc.hpp b/third_party/snpe/include/DlSystem/UDLFunc.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/UDLFunc.hpp rename to third_party/snpe/include/DlSystem/UDLFunc.hpp diff --git a/phonelibs/snpe/include/DlSystem/UserBufferMap.hpp b/third_party/snpe/include/DlSystem/UserBufferMap.hpp similarity index 100% rename from phonelibs/snpe/include/DlSystem/UserBufferMap.hpp rename to third_party/snpe/include/DlSystem/UserBufferMap.hpp diff --git a/third_party/snpe/include/DlSystem/ZdlExportDefine.hpp b/third_party/snpe/include/DlSystem/ZdlExportDefine.hpp new file mode 100644 index 00000000000000..92eb786d312f6d --- /dev/null +++ b/third_party/snpe/include/DlSystem/ZdlExportDefine.hpp @@ -0,0 +1,13 @@ +//============================================================================= +// +// Copyright (c) 2015, 2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================= + +#pragma once + +#ifndef ZDL_EXPORT +#define ZDL_EXPORT +#endif diff --git a/third_party/snpe/include/PlatformValidator/PlatformValidator.hpp b/third_party/snpe/include/PlatformValidator/PlatformValidator.hpp new file mode 100644 index 00000000000000..e74278ead7bff5 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SNPE/ApplicationBufferMap.hpp b/third_party/snpe/include/SNPE/ApplicationBufferMap.hpp new file mode 100644 index 00000000000000..380a3e0e6e77ee --- /dev/null +++ b/third_party/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/third_party/snpe/include/SNPE/PSNPE.hpp b/third_party/snpe/include/SNPE/PSNPE.hpp new file mode 100644 index 00000000000000..c0a6fb55d67a45 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SNPE/RuntimeConfigList.hpp b/third_party/snpe/include/SNPE/RuntimeConfigList.hpp new file mode 100644 index 00000000000000..837dba092a1d21 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SNPE/SNPE.hpp similarity index 96% rename from phonelibs/snpe/include/SNPE/SNPE.hpp rename to third_party/snpe/include/SNPE/SNPE.hpp index ba84265b9663f8..239690ab2c7f1c 100644 --- a/phonelibs/snpe/include/SNPE/SNPE.hpp +++ b/third_party/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/third_party/snpe/include/SNPE/SNPEBuilder.hpp b/third_party/snpe/include/SNPE/SNPEBuilder.hpp new file mode 100644 index 00000000000000..f314d88bcff949 --- /dev/null +++ b/third_party/snpe/include/SNPE/SNPEBuilder.hpp @@ -0,0 +1,283 @@ +//============================================================================== +// +// Copyright (c) 2017-2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef _SNPE_BUILDER_HPP_ +#define _SNPE_BUILDER_HPP_ + +#include "SNPE/SNPE.hpp" +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/UDLFunc.hpp" +#include "DlSystem/DlOptional.hpp" +#include "DlSystem/TensorShapeMap.hpp" +#include "DlSystem/PlatformConfig.hpp" +#include "DlSystem/RuntimeList.hpp" + +namespace zdl { + namespace DlContainer + { + class IDlContainer; + } +} + +struct SNPEBuilderImpl; + + +namespace zdl { namespace SNPE { +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * The builder class for creating SNPE objects. + * Not meant to be extended. + */ +class ZDL_EXPORT SNPEBuilder final +{ +private: + std::unique_ptr<::SNPEBuilderImpl> m_Impl; +public: + + /** + * @brief Constructor of NeuralNetwork Builder with a supplied model. + * + * @param[in] container A container holding the model. + * + * @return A new instance of a SNPEBuilder object + * that can be used to configure and build + * an instance of SNPE. + * + */ + explicit SNPEBuilder( + zdl::DlContainer::IDlContainer* container); + ~SNPEBuilder(); + + /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use + * setRuntimeProcessorOrder() + * + * @brief Sets the runtime processor. + * + * @param[in] targetRuntimeProcessor The target runtime. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setRuntimeProcessor( + zdl::DlSystem::Runtime_t targetRuntimeProcessor); + + /** + * @brief Requests a performance profile. + * + * @param[in] targetRuntimeProfile The target performance profile. + * + * @return The current instance of SNPEBuilder. + */ + 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. + * + * This allows the caller to give coarse hint to SNPE runtime + * about the priority of the network. SNPE runtime is free to use + * this information to co-ordinate between different workloads + * that may or may not extend beyond SNPE. + * + * @param[in] ExecutionPriorityHint_t The target performance profile. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setExecutionPriorityHint( + zdl::DlSystem::ExecutionPriorityHint_t priority); + + /** + * @brief Sets the layers that will generate output. + * + * @param[in] outputLayerNames List of layer names to + * output. An empty list will + * result in only the final + * layer of the model being + * the output layer. The list + * will be copied. + * + * @return The current instance of SNPEBuilder. + */ + 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. + * + * @param udlBundle Bundle of udl factory function and a cookie + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setUdlBundle( + zdl::DlSystem::UDLBundle udlBundle); + + /** + * @brief Sets whether this neural network will perform inference with + * input from user-supplied buffers, and write output to user-supplied + * buffers. Default behaviour is to use tensors created by + * ITensorFactory. + * + * @param[in] bufferMode Whether to use user-supplied buffer or not. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setUseUserSuppliedBuffers( + bool bufferMode); + + /** + * @brief Sets the debug mode of the runtime. + * + * @param[in] debugMode This enables debug mode for the runtime. It + * does two things. For an empty + * outputLayerNames list, all layers will be + * output. It might also disable some internal + * runtime optimizations (e.g., some networks + * might be optimized by combining layers, + * etc.). + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setDebugMode( + 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 + * of CPU fallback. When the CPU fallback + * functionality is enabled, layers in model that + * violates runtime constraints will run on CPU + * while the rest of non-violating layers will + * run on the chosen runtime processor. In + * disabled mode, models with layers violating + * runtime constraints will NOT run on the chosen + * runtime processor and will result in runtime + * exception. By default, the functionality is + * enabled. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setCPUFallbackMode( + bool mode); + + + /** + * @brief Sets network's input dimensions to enable resizing of + * the spatial dimensions of each layer for fully convolutional networks, + * and the batch dimension for all networks. + * + * @param[in] tensorShapeMap The map of input names and their new dimensions. + * The new dimensions overwrite the input dimensions + * embedded in the model and then resize each layer + * of the model. If the model contains + * layers whose dimensions cannot be resized e.g FullyConnected, + * exception will be thrown when SNPE instance is actually built. + * In general the batch dimension is always resizable. + * After resizing of layers' dimensions in model based + * on new input dimensions, the new model is revalidated + * against all runtime constraints, whose failures may + * result in cpu fallback situation. + * + * @return The current instance of SNPEBuilder. + */ + 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. + * + * @return A new instance of a SNPE object that can be used + * to execute models or null if any errors occur. + */ + std::unique_ptr build() noexcept; + + /** + * @brief Sets the platform configuration. + * + * @param[in] platformConfig The platform configuration. + * + * @return The current instance of SNPEBuilder. + */ + 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++ */ + +}} + +#endif diff --git a/third_party/snpe/include/SNPE/SNPEFactory.hpp b/third_party/snpe/include/SNPE/SNPEFactory.hpp new file mode 100644 index 00000000000000..7bef45d877c4c1 --- /dev/null +++ b/third_party/snpe/include/SNPE/SNPEFactory.hpp @@ -0,0 +1,131 @@ +//============================================================================== +// +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef _SNPE_FACTORY_HPP_ +#define _SNPE_FACTORY_HPP_ + +#include "SNPE/SNPE.hpp" +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/UDLFunc.hpp" +#include "DlSystem/ZdlExportDefine.hpp" +#include "DlSystem/DlOptional.hpp" + +namespace zdl { + namespace DlSystem + { + class ITensorFactory; + class IUserBufferFactory; + } + namespace DlContainer + { + class IDlContainer; + } +} + + + +namespace zdl { namespace SNPE { +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * The factory class for creating SNPE objects. + * + */ +class ZDL_EXPORT SNPEFactory +{ +public: + + /** + * 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); + + /** + * 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(); + + /** + * Gets a reference to the UserBuffer factory. + * + * @return A reference to the UserBuffer factory. + */ + static zdl::DlSystem::IUserBufferFactory& getUserBufferFactory(); + + /** + * Gets the version of the SNPE library. + * + * @return Version of the SNPE library. + * + */ + static zdl::DlSystem::Version_t getLibraryVersion(); + + /** + * Set the SNPE storage location for all SNPE instances in this + * process. Note that this may only be called once, and if so + * must be called before creating any SNPE instances. + * + * @param[in] storagePath Absolute path to a directory which SNPE may + * use for caching and other storage purposes. + * + * @return True if the supplied path was succesfully set as + * the SNPE storage location, false otherwise. + */ + 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. + * + * @return True if the OpenGL and OpenCl interop is supported; false, + * otherwise. + */ + static bool isGLCLInteropSupported(); +}; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ +}} + + +#endif diff --git a/third_party/snpe/include/SNPE/UserBufferList.hpp b/third_party/snpe/include/SNPE/UserBufferList.hpp new file mode 100644 index 00000000000000..a660bca0f6a525 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SnpeUdo/UdoBase.h b/third_party/snpe/include/SnpeUdo/UdoBase.h new file mode 100644 index 00000000000000..be370e1ac5b975 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SnpeUdo/UdoImpl.h b/third_party/snpe/include/SnpeUdo/UdoImpl.h new file mode 100644 index 00000000000000..bd29bc251dd688 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SnpeUdo/UdoImplCpu.h b/third_party/snpe/include/SnpeUdo/UdoImplCpu.h new file mode 100644 index 00000000000000..3bbe0638e60fc8 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SnpeUdo/UdoImplDsp.h b/third_party/snpe/include/SnpeUdo/UdoImplDsp.h new file mode 100644 index 00000000000000..7e85bf15d87871 --- /dev/null +++ b/third_party/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/third_party/snpe/include/SnpeUdo/UdoImplGpu.h b/third_party/snpe/include/SnpeUdo/UdoImplGpu.h new file mode 100644 index 00000000000000..1af654d110c26b --- /dev/null +++ b/third_party/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/third_party/snpe/include/SnpeUdo/UdoReg.h b/third_party/snpe/include/SnpeUdo/UdoReg.h new file mode 100644 index 00000000000000..a5d239883355ab --- /dev/null +++ b/third_party/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/third_party/snpe/include/SnpeUdo/UdoShared.h b/third_party/snpe/include/SnpeUdo/UdoShared.h new file mode 100644 index 00000000000000..6fd50c318acc28 --- /dev/null +++ b/third_party/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/third_party/snpe/larch64 b/third_party/snpe/larch64 new file mode 120000 index 00000000000000..e5c222b1c9be49 --- /dev/null +++ b/third_party/snpe/larch64 @@ -0,0 +1 @@ +aarch64-linux-gcc4.9 \ No newline at end of file diff --git a/phonelibs/zlib/build.txt b/third_party/zlib/build.txt similarity index 100% rename from phonelibs/zlib/build.txt rename to third_party/zlib/build.txt diff --git a/phonelibs/zlib/lib/libz.a b/third_party/zlib/lib/libz.a similarity index 100% rename from phonelibs/zlib/lib/libz.a rename to third_party/zlib/lib/libz.a diff --git a/tools/lib/README.md b/tools/lib/README.md new file mode 100644 index 00000000000000..c681809eaecfb7 --- /dev/null +++ b/tools/lib/README.md @@ -0,0 +1,33 @@ +## LogReader + +Route is a class for conviently accessing all the [logs](/selfdrive/loggerd/) from your routes. The LogReader class reads the non-video logs, i.e. rlog.bz2 and qlog.bz2. There's also a matching FrameReader class for reading the videos. + +```python +from tools.lib.route import Route +from tools.lib.logreader import LogReader + +r = Route("4cf7a6ad03080c90|2021-09-29--13-46-36") + +# get a list of paths for the route's rlog files +print(r.log_paths()) + +# and road camera (fcamera.hevc) files +print(r.camera_paths()) + +# setup a LogReader to read the route's first rlog +lr = LogReader(r.log_paths()[0]) + +# print out all the messages in the log +import codecs +codecs.register_error("strict", codecs.backslashreplace_errors) +for msg in lr: + print(msg) + +# setup a LogReader for the route's second qlog +lr = LogReader(r.log_paths()[1]) + +# print all the steering angles values from the log +for msg in lr: + if msg.which() == "carState": + print(msg.carState.steeringAngleDeg) +``` diff --git a/selfdrive/visiond/__init__.py b/tools/lib/__init__.py similarity index 100% rename from selfdrive/visiond/__init__.py rename to tools/lib/__init__.py diff --git a/tools/lib/api.py b/tools/lib/api.py new file mode 100644 index 00000000000000..6ff9242f29810c --- /dev/null +++ b/tools/lib/api.py @@ -0,0 +1,34 @@ +import os +import requests +API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com') + +class CommaApi(): + def __init__(self, token=None): + self.session = requests.Session() + self.session.headers['User-agent'] = 'OpenpilotTools' + if token: + self.session.headers['Authorization'] = 'JWT ' + token + + def request(self, method, endpoint, **kwargs): + resp = self.session.request(method, API_HOST + '/' + endpoint, **kwargs) + resp_json = resp.json() + if isinstance(resp_json, dict) and resp_json.get('error'): + if resp.status_code in [401, 403]: + raise UnauthorizedError('Unauthorized. Authenticate with tools/lib/auth.py') + + e = APIError(str(resp.status_code) + ":" + resp_json.get('description', str(resp_json['error']))) + e.status_code = resp.status_code + raise e + return resp_json + + def get(self, endpoint, **kwargs): + return self.request('GET', endpoint, **kwargs) + + def post(self, endpoint, **kwargs): + return self.request('POST', endpoint, **kwargs) + +class APIError(Exception): + pass + +class UnauthorizedError(Exception): + pass diff --git a/tools/lib/auth.py b/tools/lib/auth.py new file mode 100755 index 00000000000000..d5d2a60bb0dcf9 --- /dev/null +++ b/tools/lib/auth.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python3 +""" +Usage:: + + usage: auth.py [-h] [{google,apple,github,jwt}] [jwt] + + Login to your comma account + + positional arguments: + {google,apple,github,jwt} + jwt + + optional arguments: + -h, --help show this help message and exit + + +Examples:: + + ./auth.py # Log in with google account + ./auth.py github # Log in with GitHub Account + ./auth.py jwt ey......hw # Log in with a JWT from https://jwt.comma.ai, for use in CI +""" + +import argparse +import sys +import pprint +import webbrowser +from http.server import BaseHTTPRequestHandler, HTTPServer +from typing import Any, Dict +from urllib.parse import parse_qs, urlencode + +from tools.lib.api import APIError, CommaApi, UnauthorizedError +from tools.lib.auth_config import set_token, get_token + +PORT = 3000 + + +class ClientRedirectServer(HTTPServer): + query_params: Dict[str, Any] = {} + + +class ClientRedirectHandler(BaseHTTPRequestHandler): + def do_GET(self): + if not self.path.startswith('/auth'): + self.send_response(204) + return + + query = self.path.split('?', 1)[-1] + query = parse_qs(query, keep_blank_values=True) + self.server.query_params = query + + self.send_response(200) + self.send_header('Content-type', 'text/plain') + self.end_headers() + self.wfile.write(b'Return to the CLI to continue') + + def log_message(self, format, *args): # pylint: disable=redefined-builtin + pass # this prevent http server from dumping messages to stdout + + +def auth_redirect_link(method): + provider_id = { + 'google': 'g', + 'apple': 'a', + 'github': 'h', + }[method] + + params = { + 'redirect_uri': f"https://api.comma.ai/v2/auth/{provider_id}/redirect/", + 'state': f'service,localhost:{PORT}', + } + + if method == 'google': + params.update({ + 'type': 'web_server', + 'client_id': '45471411055-ornt4svd2miog6dnopve7qtmh5mnu6id.apps.googleusercontent.com', + 'response_type': 'code', + 'scope': 'https://www.googleapis.com/auth/userinfo.email', + 'prompt': 'select_account', + }) + return 'https://accounts.google.com/o/oauth2/auth?' + urlencode(params) + elif method == 'github': + params.update({ + 'client_id': '28c4ecb54bb7272cb5a4', + 'scope': 'read:user', + }) + return 'https://github.com/login/oauth/authorize?' + urlencode(params) + elif method == 'apple': + params.update({ + 'client_id': 'ai.comma.login', + 'response_type': 'code', + 'response_mode': 'form_post', + 'scope': 'name email', + }) + return 'https://appleid.apple.com/auth/authorize?' + urlencode(params) + else: + raise NotImplementedError(f"no redirect implemented for method {method}") + + +def login(method): + oauth_uri = auth_redirect_link(method) + + web_server = ClientRedirectServer(('localhost', PORT), ClientRedirectHandler) + print(f'To sign in, use your browser and navigate to {oauth_uri}') + webbrowser.open(oauth_uri, new=2) + + while True: + web_server.handle_request() + if 'code' in web_server.query_params: + break + elif 'error' in web_server.query_params: + print('Authentication Error: "%s". Description: "%s" ' % ( + web_server.query_params['error'], + web_server.query_params.get('error_description')), file=sys.stderr) + break + + try: + auth_resp = CommaApi().post('v2/auth/', data={'code': web_server.query_params['code'], 'provider': web_server.query_params['provider']}) + set_token(auth_resp['access_token']) + except APIError as e: + print(f'Authentication Error: {e}', file=sys.stderr) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Login to your comma account') + parser.add_argument('method', default='google', const='google', nargs='?', choices=['google', 'apple', 'github', 'jwt']) + parser.add_argument('jwt', nargs='?') + + args = parser.parse_args() + if args.method == 'jwt': + if args.jwt is None: + print("method JWT selected, but no JWT was provided") + exit(1) + + set_token(args.jwt) + else: + login(args.method) + + try: + me = CommaApi(token=get_token()).get('/v1/me') + print("Authenticated!") + pprint.pprint(me) + except UnauthorizedError: + print("Got invalid JWT") + exit(1) diff --git a/tools/lib/auth_config.py b/tools/lib/auth_config.py new file mode 100644 index 00000000000000..1699d94e53c871 --- /dev/null +++ b/tools/lib/auth_config.py @@ -0,0 +1,34 @@ +import json +import os +from common.file_helpers import mkdirs_exists_ok +from selfdrive.hardware import PC + + +class MissingAuthConfigError(Exception): + pass + + +if PC: + CONFIG_DIR = os.path.expanduser('~/.comma') +else: + CONFIG_DIR = "/tmp/.comma" + +mkdirs_exists_ok(CONFIG_DIR) + + +def get_token(): + try: + with open(os.path.join(CONFIG_DIR, 'auth.json')) as f: + auth = json.load(f) + return auth['access_token'] + except Exception: + return None + + +def set_token(token): + with open(os.path.join(CONFIG_DIR, 'auth.json'), 'w') as f: + json.dump({'access_token': token}, f) + + +def clear_token(): + os.unlink(os.path.join(CONFIG_DIR, 'auth.json')) diff --git a/tools/lib/cache.py b/tools/lib/cache.py new file mode 100644 index 00000000000000..82b22987300c18 --- /dev/null +++ b/tools/lib/cache.py @@ -0,0 +1,15 @@ +import os +import urllib.parse +from common.file_helpers import mkdirs_exists_ok + +DEFAULT_CACHE_DIR = os.path.expanduser("~/.commacache") + +def cache_path_for_file_path(fn, cache_prefix=None): + dir_ = os.path.join(DEFAULT_CACHE_DIR, "local") + mkdirs_exists_ok(dir_) + fn_parsed = urllib.parse.urlparse(fn) + if fn_parsed.scheme == '': + cache_fn = os.path.abspath(fn).replace("/", "_") + else: + cache_fn = f'{fn_parsed.hostname}_{fn_parsed.path.replace("/", "_")}' + return os.path.join(dir_, cache_fn) diff --git a/tools/lib/exceptions.py b/tools/lib/exceptions.py new file mode 100644 index 00000000000000..41de2e86422dea --- /dev/null +++ b/tools/lib/exceptions.py @@ -0,0 +1,2 @@ +class DataUnreadableError(Exception): + pass diff --git a/tools/lib/filereader.py b/tools/lib/filereader.py new file mode 100644 index 00000000000000..3d4c46b2200a51 --- /dev/null +++ b/tools/lib/filereader.py @@ -0,0 +1,6 @@ +from tools.lib.url_file import URLFile + +def FileReader(fn, debug=False): + if fn.startswith("http://") or fn.startswith("https://"): + return URLFile(fn, debug=debug) + return open(fn, "rb") diff --git a/tools/lib/framereader.py b/tools/lib/framereader.py new file mode 100644 index 00000000000000..db07c20177f63b --- /dev/null +++ b/tools/lib/framereader.py @@ -0,0 +1,586 @@ +# pylint: skip-file +import json +import os +import pickle +import struct +import subprocess +import tempfile +import threading +from enum import IntEnum +from functools import wraps + +import numpy as np +from lru import LRU + +import _io +from tools.lib.cache import cache_path_for_file_path +from tools.lib.exceptions import DataUnreadableError +from common.file_helpers import atomic_write_in_dir + +try: + from xx.chffr.lib.filereader import FileReader +except ImportError: + from tools.lib.filereader import FileReader + +HEVC_SLICE_B = 0 +HEVC_SLICE_P = 1 +HEVC_SLICE_I = 2 + + +class GOPReader: + def get_gop(self, num): + # returns (start_frame_num, num_frames, frames_to_skip, gop_data) + raise NotImplementedError + + +class DoNothingContextManager: + def __enter__(self): + return self + + def __exit__(self, *x): + pass + + +class FrameType(IntEnum): + raw = 1 + h265_stream = 2 + + +def fingerprint_video(fn): + with FileReader(fn) as f: + header = f.read(4) + if len(header) == 0: + raise DataUnreadableError("%s is empty" % fn) + elif header == b"\x00\xc0\x12\x00": + return FrameType.raw + elif header == b"\x00\x00\x00\x01": + if 'hevc' in fn: + return FrameType.h265_stream + else: + raise NotImplementedError(fn) + else: + raise NotImplementedError(fn) + + +def ffprobe(fn, fmt=None): + cmd = ["ffprobe", + "-v", "quiet", + "-print_format", "json", + "-show_format", "-show_streams"] + if fmt: + cmd += ["-f", fmt] + cmd += [fn] + + try: + ffprobe_output = subprocess.check_output(cmd) + except subprocess.CalledProcessError: + raise DataUnreadableError(fn) + + return json.loads(ffprobe_output) + + +def vidindex(fn, typ): + vidindex_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "vidindex") + vidindex = os.path.join(vidindex_dir, "vidindex") + + subprocess.check_call(["make"], cwd=vidindex_dir, stdout=open("/dev/null", "w")) + + with tempfile.NamedTemporaryFile() as prefix_f, \ + tempfile.NamedTemporaryFile() as index_f: + try: + subprocess.check_call([vidindex, typ, fn, prefix_f.name, index_f.name]) + except subprocess.CalledProcessError: + raise DataUnreadableError("vidindex failed on file %s" % fn) + with open(index_f.name, "rb") as f: + index = f.read() + with open(prefix_f.name, "rb") as f: + prefix = f.read() + + index = np.frombuffer(index, np.uint32).reshape(-1, 2) + + assert index[-1, 0] == 0xFFFFFFFF + assert index[-1, 1] == os.path.getsize(fn) + + return index, prefix + + +def cache_fn(func): + @wraps(func) + def cache_inner(fn, *args, **kwargs): + if kwargs.pop('no_cache', None): + cache_path = None + else: + cache_prefix = kwargs.pop('cache_prefix', None) + cache_path = cache_path_for_file_path(fn, cache_prefix) + + if cache_path and os.path.exists(cache_path): + with open(cache_path, "rb") as cache_file: + cache_value = pickle.load(cache_file) + else: + cache_value = func(fn, *args, **kwargs) + + if cache_path: + with atomic_write_in_dir(cache_path, mode="wb", overwrite=True) as cache_file: + pickle.dump(cache_value, cache_file, -1) + + return cache_value + + return cache_inner + + +@cache_fn +def index_stream(fn, typ): + assert typ in ("hevc", ) + + with FileReader(fn) as f: + assert os.path.exists(f.name), fn + index, prefix = vidindex(f.name, typ) + probe = ffprobe(f.name, typ) + + return { + 'index': index, + 'global_prefix': prefix, + 'probe': probe + } + + +def index_videos(camera_paths, cache_prefix=None): + """Requires that paths in camera_paths are contiguous and of the same type.""" + if len(camera_paths) < 1: + raise ValueError("must provide at least one video to index") + + frame_type = fingerprint_video(camera_paths[0]) + for fn in camera_paths: + index_video(fn, frame_type, cache_prefix) + + +def index_video(fn, frame_type=None, cache_prefix=None): + cache_path = cache_path_for_file_path(fn, cache_prefix) + + if os.path.exists(cache_path): + return + + if frame_type is None: + frame_type = fingerprint_video(fn[0]) + + if frame_type == FrameType.h265_stream: + index_stream(fn, "hevc", cache_prefix=cache_prefix) + else: + raise NotImplementedError("Only h265 supported") + + +def get_video_index(fn, frame_type, cache_prefix=None): + cache_path = cache_path_for_file_path(fn, cache_prefix) + + if not os.path.exists(cache_path): + index_video(fn, frame_type, cache_prefix) + + if not os.path.exists(cache_path): + return None + with open(cache_path, "rb") as cache_file: + return pickle.load(cache_file) + + +def read_file_check_size(f, sz, cookie): + buff = bytearray(sz) + bytes_read = f.readinto(buff) + assert bytes_read == sz, (bytes_read, sz) + return buff + + +def rgb24toyuv420(rgb): + yuv_from_rgb = np.array([[ 0.299 , 0.587 , 0.114 ], + [-0.14714119, -0.28886916, 0.43601035 ], + [ 0.61497538, -0.51496512, -0.10001026 ]]) + img = np.dot(rgb.reshape(-1, 3), yuv_from_rgb.T).reshape(rgb.shape) + + y_len = img.shape[0] * img.shape[1] + uv_len = y_len // 4 + + ys = img[:, :, 0] + us = (img[::2, ::2, 1] + img[1::2, ::2, 1] + img[::2, 1::2, 1] + img[1::2, 1::2, 1]) / 4 + 128 + vs = (img[::2, ::2, 2] + img[1::2, ::2, 2] + img[::2, 1::2, 2] + img[1::2, 1::2, 2]) / 4 + 128 + + yuv420 = np.empty(y_len + 2 * uv_len, dtype=img.dtype) + yuv420[:y_len] = ys.reshape(-1) + yuv420[y_len:y_len + uv_len] = us.reshape(-1) + yuv420[y_len + uv_len:y_len + 2 * uv_len] = vs.reshape(-1) + + return yuv420.clip(0, 255).astype('uint8') + + +def decompress_video_data(rawdat, vid_fmt, w, h, pix_fmt): + # using a tempfile is much faster than proc.communicate for some reason + + with tempfile.TemporaryFile() as tmpf: + tmpf.write(rawdat) + tmpf.seek(0) + + threads = os.getenv("FFMPEG_THREADS", "0") + cuda = os.getenv("FFMPEG_CUDA", "0") == "1" + proc = subprocess.Popen( + ["ffmpeg", + "-threads", threads, + "-hwaccel", "none" if not cuda else "cuda", + "-c:v", "hevc", + "-vsync", "0", + "-f", vid_fmt, + "-flags2", "showall", + "-i", "pipe:0", + "-threads", threads, + "-f", "rawvideo", + "-pix_fmt", pix_fmt, + "pipe:1"], + stdin=tmpf, stdout=subprocess.PIPE, stderr=open("/dev/null")) + + # dat = proc.communicate()[0] + dat = proc.stdout.read() + if proc.wait() != 0: + raise DataUnreadableError("ffmpeg failed") + + if pix_fmt == "rgb24": + ret = np.frombuffer(dat, dtype=np.uint8).reshape(-1, h, w, 3) + elif pix_fmt == "yuv420p": + ret = np.frombuffer(dat, dtype=np.uint8).reshape(-1, (h*w*3//2)) + elif pix_fmt == "yuv444p": + ret = np.frombuffer(dat, dtype=np.uint8).reshape(-1, 3, h, w) + else: + raise NotImplementedError + + return ret + + +class BaseFrameReader: + # properties: frame_type, frame_count, w, h + + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + + def close(self): + pass + + def get(self, num, count=1, pix_fmt="yuv420p"): + raise NotImplementedError + + +def FrameReader(fn, cache_prefix=None, readahead=False, readbehind=False, index_data=None): + frame_type = fingerprint_video(fn) + if frame_type == FrameType.raw: + return RawFrameReader(fn) + elif frame_type in (FrameType.h265_stream,): + if not index_data: + index_data = get_video_index(fn, frame_type, cache_prefix) + return StreamFrameReader(fn, frame_type, index_data, readahead=readahead, readbehind=readbehind) + else: + raise NotImplementedError(frame_type) + + +class RawData: + def __init__(self, f): + self.f = _io.FileIO(f, 'rb') + self.lenn = struct.unpack("I", self.f.read(4))[0] + self.count = os.path.getsize(f) / (self.lenn+4) + + def read(self, i): + self.f.seek((self.lenn+4)*i + 4) + return self.f.read(self.lenn) + + +class RawFrameReader(BaseFrameReader): + def __init__(self, fn): + # raw camera + self.fn = fn + self.frame_type = FrameType.raw + self.rawfile = RawData(self.fn) + self.frame_count = self.rawfile.count + self.w, self.h = 640, 480 + + def load_and_debayer(self, img): + img = np.frombuffer(img, dtype='uint8').reshape(960, 1280) + cimg = np.dstack([img[0::2, 1::2], ((img[0::2, 0::2].astype("uint16") + img[1::2, 1::2].astype("uint16")) >> 1).astype("uint8"), img[1::2, 0::2]]) + return cimg + + def get(self, num, count=1, pix_fmt="yuv420p"): + assert self.frame_count is not None + assert num+count <= self.frame_count + + if pix_fmt not in ("yuv420p", "rgb24"): + raise ValueError("Unsupported pixel format %r" % pix_fmt) + + app = [] + for i in range(num, num+count): + dat = self.rawfile.read(i) + rgb_dat = self.load_and_debayer(dat) + if pix_fmt == "rgb24": + app.append(rgb_dat) + elif pix_fmt == "yuv420p": + app.append(rgb24toyuv420(rgb_dat)) + else: + raise NotImplementedError + + return app + + +class VideoStreamDecompressor: + def __init__(self, fn, vid_fmt, w, h, pix_fmt): + self.fn = fn + self.vid_fmt = vid_fmt + self.w = w + self.h = h + self.pix_fmt = pix_fmt + + if pix_fmt == "yuv420p": + self.out_size = w*h*3//2 # yuv420p + elif pix_fmt in ("rgb24", "yuv444p"): + self.out_size = w*h*3 + else: + raise NotImplementedError + + self.proc = None + self.t = threading.Thread(target=self.write_thread) + self.t.daemon = True + + def write_thread(self): + try: + with FileReader(self.fn) as f: + while True: + r = f.read(1024*1024) + if len(r) == 0: + break + self.proc.stdin.write(r) + finally: + self.proc.stdin.close() + + def read(self): + threads = os.getenv("FFMPEG_THREADS", "0") + cuda = os.getenv("FFMPEG_CUDA", "0") == "1" + cmd = [ + "ffmpeg", + "-threads", threads, + "-hwaccel", "none" if not cuda else "cuda", + "-c:v", "hevc", + # "-avioflags", "direct", + "-analyzeduration", "0", + "-probesize", "32", + "-flush_packets", "0", + # "-fflags", "nobuffer", + "-vsync", "0", + "-f", self.vid_fmt, + "-i", "pipe:0", + "-threads", threads, + "-f", "rawvideo", + "-pix_fmt", self.pix_fmt, + "pipe:1" + ] + self.proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + try: + self.t.start() + + while True: + dat = self.proc.stdout.read(self.out_size) + if len(dat) == 0: + break + assert len(dat) == self.out_size + if self.pix_fmt == "rgb24": + ret = np.frombuffer(dat, dtype=np.uint8).reshape((self.h, self.w, 3)) + elif self.pix_fmt == "yuv420p": + ret = np.frombuffer(dat, dtype=np.uint8) + elif self.pix_fmt == "yuv444p": + ret = np.frombuffer(dat, dtype=np.uint8).reshape((3, self.h, self.w)) + else: + assert False + yield ret + + result_code = self.proc.wait() + assert result_code == 0, result_code + finally: + self.proc.kill() + self.t.join() + +class StreamGOPReader(GOPReader): + def __init__(self, fn, frame_type, index_data): + assert frame_type == FrameType.h265_stream + + self.fn = fn + + self.frame_type = frame_type + self.frame_count = None + self.w, self.h = None, None + + self.prefix = None + self.index = None + + self.index = index_data['index'] + self.prefix = index_data['global_prefix'] + probe = index_data['probe'] + + self.prefix_frame_data = None + self.num_prefix_frames = 0 + self.vid_fmt = "hevc" + + i = 0 + while i < self.index.shape[0] and self.index[i, 0] != HEVC_SLICE_I: + i += 1 + self.first_iframe = i + + assert self.first_iframe == 0 + + self.frame_count = len(self.index) - 1 + + self.w = probe['streams'][0]['width'] + self.h = probe['streams'][0]['height'] + + def _lookup_gop(self, num): + frame_b = num + while frame_b > 0 and self.index[frame_b, 0] != HEVC_SLICE_I: + frame_b -= 1 + + frame_e = num + 1 + while frame_e < (len(self.index) - 1) and self.index[frame_e, 0] != HEVC_SLICE_I: + frame_e += 1 + + offset_b = self.index[frame_b, 1] + offset_e = self.index[frame_e, 1] + + return (frame_b, frame_e, offset_b, offset_e) + + def get_gop(self, num): + frame_b, frame_e, offset_b, offset_e = self._lookup_gop(num) + assert frame_b <= num < frame_e + + num_frames = frame_e - frame_b + + with FileReader(self.fn) as f: + f.seek(offset_b) + rawdat = f.read(offset_e - offset_b) + + if num < self.first_iframe: + assert self.prefix_frame_data + rawdat = self.prefix_frame_data + rawdat + + rawdat = self.prefix + rawdat + + skip_frames = 0 + if num < self.first_iframe: + skip_frames = self.num_prefix_frames + + return frame_b, num_frames, skip_frames, rawdat + + +class GOPFrameReader(BaseFrameReader): + #FrameReader with caching and readahead for formats that are group-of-picture based + + def __init__(self, readahead=False, readbehind=False): + self.open_ = True + + self.readahead = readahead + self.readbehind = readbehind + self.frame_cache = LRU(64) + + if self.readahead: + self.cache_lock = threading.RLock() + self.readahead_last = None + self.readahead_len = 30 + self.readahead_c = threading.Condition() + self.readahead_thread = threading.Thread(target=self._readahead_thread) + self.readahead_thread.daemon = True + self.readahead_thread.start() + else: + self.cache_lock = DoNothingContextManager() + + def close(self): + if not self.open_: + return + self.open_ = False + + if self.readahead: + self.readahead_c.acquire() + self.readahead_c.notify() + self.readahead_c.release() + self.readahead_thread.join() + + def _readahead_thread(self): + while True: + self.readahead_c.acquire() + try: + if not self.open_: + break + self.readahead_c.wait() + finally: + self.readahead_c.release() + if not self.open_: + break + assert self.readahead_last + num, pix_fmt = self.readahead_last + + if self.readbehind: + for k in range(num - 1, max(0, num - self.readahead_len), -1): + self._get_one(k, pix_fmt) + else: + for k in range(num, min(self.frame_count, num + self.readahead_len)): + self._get_one(k, pix_fmt) + + def _get_one(self, num, pix_fmt): + assert num < self.frame_count + + if (num, pix_fmt) in self.frame_cache: + return self.frame_cache[(num, pix_fmt)] + + with self.cache_lock: + if (num, pix_fmt) in self.frame_cache: + return self.frame_cache[(num, pix_fmt)] + + frame_b, num_frames, skip_frames, rawdat = self.get_gop(num) + + ret = decompress_video_data(rawdat, self.vid_fmt, self.w, self.h, pix_fmt) + ret = ret[skip_frames:] + assert ret.shape[0] == num_frames + + for i in range(ret.shape[0]): + self.frame_cache[(frame_b+i, pix_fmt)] = ret[i] + + return self.frame_cache[(num, pix_fmt)] + + def get(self, num, count=1, pix_fmt="yuv420p"): + assert self.frame_count is not None + + if num + count > self.frame_count: + raise ValueError("{} > {}".format(num + count, self.frame_count)) + + if pix_fmt not in ("yuv420p", "rgb24", "yuv444p"): + raise ValueError("Unsupported pixel format %r" % pix_fmt) + + ret = [self._get_one(num + i, pix_fmt) for i in range(count)] + + if self.readahead: + self.readahead_last = (num+count, pix_fmt) + self.readahead_c.acquire() + self.readahead_c.notify() + self.readahead_c.release() + + return ret + + +class StreamFrameReader(StreamGOPReader, GOPFrameReader): + def __init__(self, fn, frame_type, index_data, readahead=False, readbehind=False): + StreamGOPReader.__init__(self, fn, frame_type, index_data) + GOPFrameReader.__init__(self, readahead, readbehind) + + +def GOPFrameIterator(gop_reader, pix_fmt): + dec = VideoStreamDecompressor(gop_reader.fn, gop_reader.vid_fmt, gop_reader.w, gop_reader.h, pix_fmt) + for frame in dec.read(): + yield frame + + +def FrameIterator(fn, pix_fmt, **kwargs): + fr = FrameReader(fn, **kwargs) + if isinstance(fr, GOPReader): + for v in GOPFrameIterator(fr, pix_fmt): + yield v + else: + for i in range(fr.frame_count): + yield fr.get(i, pix_fmt=pix_fmt)[0] diff --git a/tools/lib/kbhit.py b/tools/lib/kbhit.py new file mode 100644 index 00000000000000..ac048fda9464b4 --- /dev/null +++ b/tools/lib/kbhit.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +import sys +import termios +import atexit +from select import select + +STDIN_FD = sys.stdin.fileno() + +class KBHit: + def __init__(self) -> None: + ''' Creates a KBHit object that you can call to do various keyboard things. + ''' + + self.set_kbhit_terminal() + + def set_kbhit_terminal(self) -> None: + ''' Save old terminal settings for closure, remove ICANON & ECHO flags. + ''' + + # Save the terminal settings + self.old_term = termios.tcgetattr(STDIN_FD) + self.new_term = self.old_term.copy() + + # New terminal setting unbuffered + self.new_term[3] &= ~(termios.ICANON | termios.ECHO) # type: ignore + termios.tcsetattr(STDIN_FD, termios.TCSAFLUSH, self.new_term) + + # Support normal-terminal reset at exit + atexit.register(self.set_normal_term) + + def set_normal_term(self) -> None: + ''' Resets to normal terminal. On Windows this is a no-op. + ''' + + termios.tcsetattr(STDIN_FD, termios.TCSAFLUSH, self.old_term) + + @staticmethod + def getch() -> str: + ''' Returns a keyboard character after kbhit() has been called. + Should not be called in the same program as getarrow(). + ''' + return sys.stdin.read(1) + + @staticmethod + def getarrow() -> int: + ''' Returns an arrow-key code after kbhit() has been called. Codes are + 0 : up + 1 : right + 2 : down + 3 : left + Should not be called in the same program as getch(). + ''' + + c = sys.stdin.read(3)[2] + vals = [65, 67, 66, 68] + + return vals.index(ord(c)) + + @staticmethod + def kbhit(): + ''' Returns True if keyboard character was hit, False otherwise. + ''' + return select([sys.stdin], [], [], 0)[0] != [] + + +# Test +if __name__ == "__main__": + + kb = KBHit() + + print('Hit any key, or ESC to exit') + + while True: + + if kb.kbhit(): + c = kb.getch() + if c == '\x1b': # ESC + break + print(c) + + kb.set_normal_term() diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py new file mode 100755 index 00000000000000..1c9cc81e32c7af --- /dev/null +++ b/tools/lib/logreader.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +import os +import sys +import bz2 +import urllib.parse +import capnp + +try: + from xx.chffr.lib.filereader import FileReader +except ImportError: + from tools.lib.filereader import FileReader +from cereal import log as capnp_log + +# this is an iterator itself, and uses private variables from LogReader +class MultiLogIterator(object): + def __init__(self, log_paths, wraparound=False): + self._log_paths = log_paths + self._wraparound = wraparound + + self._first_log_idx = next(i for i in range(len(log_paths)) if log_paths[i] is not None) + self._current_log = self._first_log_idx + self._idx = 0 + self._log_readers = [None]*len(log_paths) + self.start_time = self._log_reader(self._first_log_idx)._ts[0] + + def _log_reader(self, i): + if self._log_readers[i] is None and self._log_paths[i] is not None: + log_path = self._log_paths[i] + self._log_readers[i] = LogReader(log_path) + + return self._log_readers[i] + + def __iter__(self): + return self + + def _inc(self): + lr = self._log_reader(self._current_log) + if self._idx < len(lr._ents)-1: + self._idx += 1 + else: + self._idx = 0 + self._current_log = next(i for i in range(self._current_log + 1, len(self._log_readers) + 1) + if i == len(self._log_readers) or self._log_paths[i] is not None) + # wraparound + if self._current_log == len(self._log_readers): + if self._wraparound: + self._current_log = self._first_log_idx + else: + raise StopIteration + + def __next__(self): + while 1: + lr = self._log_reader(self._current_log) + ret = lr._ents[self._idx] + self._inc() + return ret + + def tell(self): + # returns seconds from start of log + return (self._log_reader(self._current_log)._ts[self._idx] - self.start_time) * 1e-9 + + def seek(self, ts): + # seek to nearest minute + minute = int(ts/60) + if minute >= len(self._log_paths) or self._log_paths[minute] is None: + return False + + self._current_log = minute + + # HACK: O(n) seek afterward + self._idx = 0 + while self.tell() < ts: + self._inc() + return True + + +class LogReader(object): + def __init__(self, fn, canonicalize=True, only_union_types=False): + data_version = None + _, ext = os.path.splitext(urllib.parse.urlparse(fn).path) + with FileReader(fn) as f: + dat = f.read() + + if ext == "": + # old rlogs weren't bz2 compressed + ents = capnp_log.Event.read_multiple_bytes(dat) + elif ext == ".bz2": + dat = bz2.decompress(dat) + ents = capnp_log.Event.read_multiple_bytes(dat) + else: + raise Exception(f"unknown extension {ext}") + + self._ents = list(ents) + self._ts = [x.logMonoTime for x in self._ents] + self.data_version = data_version + self._only_union_types = only_union_types + + def __iter__(self): + for ent in self._ents: + if self._only_union_types: + try: + ent.which() + yield ent + except capnp.lib.capnp.KjException: + pass + else: + yield ent + +if __name__ == "__main__": + import codecs + # capnproto <= 0.8.0 throws errors converting byte data to string + # below line catches those errors and replaces the bytes with \x__ + codecs.register_error("strict", codecs.backslashreplace_errors) + log_path = sys.argv[1] + lr = LogReader(log_path) + for msg in lr: + print(msg) diff --git a/tools/lib/robust_logreader.py b/tools/lib/robust_logreader.py new file mode 100755 index 00000000000000..e534a7c8f06d9c --- /dev/null +++ b/tools/lib/robust_logreader.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +import os +import bz2 +import urllib.parse +import subprocess +import tqdm +import glob +from tempfile import TemporaryDirectory +import capnp + +from tools.lib.logreader import FileReader, LogReader +from cereal import log as capnp_log + + +class RobustLogReader(LogReader): + def __init__(self, fn, canonicalize=True, only_union_types=False): # pylint: disable=super-init-not-called + data_version = None + _, ext = os.path.splitext(urllib.parse.urlparse(fn).path) + with FileReader(fn) as f: + dat = f.read() + + if ext == "": + pass + elif ext == ".bz2": + try: + dat = bz2.decompress(dat) + except ValueError: + print("Failed to decompress, falling back to bzip2recover") + with TemporaryDirectory() as directory: + # Run bzip2recovery on log + with open(os.path.join(directory, 'out.bz2'), 'wb') as f: + f.write(dat) + subprocess.check_call(["bzip2recover", "out.bz2"], cwd=directory) + + # Decompress and concatenate parts + dat = b"" + for n in sorted(glob.glob(f"{directory}/rec*.bz2")): + print(f"Decompressing {n}") + with open(n, 'rb') as f: + dat += bz2.decompress(f.read()) + else: + raise Exception(f"unknown extension {ext}") + + progress = None + while True: + try: + ents = capnp_log.Event.read_multiple_bytes(dat) + self._ents = list(ents) + break + except capnp.lib.capnp.KjException: + if progress is None: + progress = tqdm.tqdm(total=len(dat)) + + # Cut off bytes at the end until capnp is able to read + dat = dat[:-1] + progress.update(1) + + self._ts = [x.logMonoTime for x in self._ents] + self.data_version = data_version + self._only_union_types = only_union_types diff --git a/tools/lib/route.py b/tools/lib/route.py new file mode 100644 index 00000000000000..8c03cd9ccaf2bf --- /dev/null +++ b/tools/lib/route.py @@ -0,0 +1,187 @@ +import os +import re +from urllib.parse import urlparse +from collections import defaultdict +from itertools import chain + +from tools.lib.auth_config import get_token +from tools.lib.api import CommaApi + +SEGMENT_NAME_RE = r'[a-z0-9]{16}[|_][0-9]{4}-[0-9]{2}-[0-9]{2}--[0-9]{2}-[0-9]{2}-[0-9]{2}--[0-9]+' +EXPLORER_FILE_RE = r'^({})--([a-z]+\.[a-z0-9]+)$'.format(SEGMENT_NAME_RE) +OP_SEGMENT_DIR_RE = r'^({})$'.format(SEGMENT_NAME_RE) + +QLOG_FILENAMES = ['qlog.bz2'] +QCAMERA_FILENAMES = ['qcamera.ts'] +LOG_FILENAMES = ['rlog.bz2', 'raw_log.bz2'] +CAMERA_FILENAMES = ['fcamera.hevc', 'video.hevc'] +DCAMERA_FILENAMES = ['dcamera.hevc'] +ECAMERA_FILENAMES = ['ecamera.hevc'] + +class Route(object): + def __init__(self, route_name, data_dir=None): + self.files = None + self.route_name = route_name.replace('_', '|') + if data_dir is not None: + self._segments = self._get_segments_local(data_dir) + else: + self._segments = self._get_segments_remote() + self.max_seg_number = self._segments[-1].canonical_name.segment_num + + @property + def segments(self): + return self._segments + + def log_paths(self): + log_path_by_seg_num = {s.canonical_name.segment_num: s.log_path for s in self._segments} + return [log_path_by_seg_num.get(i, None) for i in range(self.max_seg_number+1)] + + def qlog_paths(self): + qlog_path_by_seg_num = {s.canonical_name.segment_num: s.qlog_path for s in self._segments} + return [qlog_path_by_seg_num.get(i, None) for i in range(self.max_seg_number+1)] + + def camera_paths(self): + camera_path_by_seg_num = {s.canonical_name.segment_num: s.camera_path for s in self._segments} + return [camera_path_by_seg_num.get(i, None) for i in range(self.max_seg_number+1)] + + def dcamera_paths(self): + dcamera_path_by_seg_num = {s.canonical_name.segment_num: s.dcamera_path for s in self._segments} + return [dcamera_path_by_seg_num.get(i, None) for i in range(self.max_seg_number+1)] + + def ecamera_paths(self): + ecamera_path_by_seg_num = {s.canonical_name.segment_num: s.ecamera_path for s in self._segments} + return [ecamera_path_by_seg_num.get(i, None) for i in range(self.max_seg_number+1)] + + def qcamera_paths(self): + qcamera_path_by_seg_num = {s.canonical_name.segment_num: s.qcamera_path for s in self._segments} + return [qcamera_path_by_seg_num.get(i, None) for i in range(self.max_seg_number+1)] + + # TODO: refactor this, it's super repetitive + def _get_segments_remote(self): + api = CommaApi(get_token()) + route_files = api.get('v1/route/' + self.route_name + '/files') + self.files = list(chain.from_iterable(route_files.values())) + + segments = {} + for url in self.files: + _, dongle_id, time_str, segment_num, fn = urlparse(url).path.rsplit('/', maxsplit=4) + segment_name = f'{dongle_id}|{time_str}--{segment_num}' + if segments.get(segment_name): + segments[segment_name] = RouteSegment( + segment_name, + url if fn in LOG_FILENAMES else segments[segment_name].log_path, + url if fn in QLOG_FILENAMES else segments[segment_name].qlog_path, + url if fn in CAMERA_FILENAMES else segments[segment_name].camera_path, + url if fn in DCAMERA_FILENAMES else segments[segment_name].dcamera_path, + url if fn in ECAMERA_FILENAMES else segments[segment_name].ecamera_path, + url if fn in QCAMERA_FILENAMES else segments[segment_name].qcamera_path, + ) + else: + segments[segment_name] = RouteSegment( + segment_name, + url if fn in LOG_FILENAMES else None, + url if fn in QLOG_FILENAMES else None, + url if fn in CAMERA_FILENAMES else None, + url if fn in DCAMERA_FILENAMES else None, + url if fn in ECAMERA_FILENAMES else None, + url if fn in QCAMERA_FILENAMES else None, + ) + + return sorted(segments.values(), key=lambda seg: seg.canonical_name.segment_num) + + def _get_segments_local(self, data_dir): + files = os.listdir(data_dir) + segment_files = defaultdict(list) + + for f in files: + fullpath = os.path.join(data_dir, f) + explorer_match = re.match(EXPLORER_FILE_RE, f) + op_match = re.match(OP_SEGMENT_DIR_RE, f) + + if explorer_match: + segment_name, fn = explorer_match.groups() + if segment_name.replace('_', '|').startswith(self.route_name): + segment_files[segment_name].append((fullpath, fn)) + elif op_match and os.path.isdir(fullpath): + segment_name, = op_match.groups() + if segment_name.startswith(self.route_name): + for seg_f in os.listdir(fullpath): + segment_files[segment_name].append((os.path.join(fullpath, seg_f), seg_f)) + elif f == self.route_name: + for seg_num in os.listdir(fullpath): + if not seg_num.isdigit(): + continue + + segment_name = '{}--{}'.format(self.route_name, seg_num) + for seg_f in os.listdir(os.path.join(fullpath, seg_num)): + segment_files[segment_name].append((os.path.join(fullpath, seg_num, seg_f), seg_f)) + + segments = [] + for segment, files in segment_files.items(): + + try: + log_path = next(path for path, filename in files if filename in LOG_FILENAMES) + except StopIteration: + log_path = None + + try: + qlog_path = next(path for path, filename in files if filename in QLOG_FILENAMES) + except StopIteration: + qlog_path = None + + try: + camera_path = next(path for path, filename in files if filename in CAMERA_FILENAMES) + except StopIteration: + camera_path = None + + try: + dcamera_path = next(path for path, filename in files if filename in DCAMERA_FILENAMES) + except StopIteration: + dcamera_path = None + + try: + ecamera_path = next(path for path, filename in files if filename in ECAMERA_FILENAMES) + except StopIteration: + ecamera_path = None + + try: + qcamera_path = next(path for path, filename in files if filename in QCAMERA_FILENAMES) + except StopIteration: + qcamera_path = None + + segments.append(RouteSegment(segment, log_path, qlog_path, camera_path, dcamera_path, ecamera_path, qcamera_path)) + + if len(segments) == 0: + raise ValueError('Could not find segments for route {} in data directory {}'.format(self.route_name, data_dir)) + return sorted(segments, key=lambda seg: seg.canonical_name.segment_num) + +class RouteSegment(object): + def __init__(self, name, log_path, qlog_path, camera_path, dcamera_path, ecamera_path, qcamera_path): + self._name = RouteSegmentName(name) + self.log_path = log_path + self.qlog_path = qlog_path + self.camera_path = camera_path + self.dcamera_path = dcamera_path + self.ecamera_path = ecamera_path + self.qcamera_path = qcamera_path + + @property + def name(self): + return str(self._name) + + @property + def canonical_name(self): + return self._name + +class RouteSegmentName(object): + def __init__(self, name_str): + self._segment_name_str = name_str + self._route_name_str, num_str = self._segment_name_str.rsplit("--", 1) + self._num = int(num_str) + + @property + def segment_num(self): + return self._num + + def __str__(self): + return self._segment_name_str diff --git a/panda/boardesp/obj/.placeholder b/tools/lib/tests/__init__.py similarity index 100% rename from panda/boardesp/obj/.placeholder rename to tools/lib/tests/__init__.py diff --git a/tools/lib/tests/test_caching.py b/tools/lib/tests/test_caching.py new file mode 100644 index 00000000000000..953b47e95ae5c3 --- /dev/null +++ b/tools/lib/tests/test_caching.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +import os +import shutil +import unittest + +os.environ["COMMA_CACHE"] = "/tmp/__test_cache__" +from tools.lib.url_file import URLFile, CACHE_DIR + + +class TestFileDownload(unittest.TestCase): + + def compare_loads(self, url, start=0, length=None): + """Compares range between cached and non cached version""" + shutil.rmtree(CACHE_DIR) + + file_cached = URLFile(url, cache=True) + file_downloaded = URLFile(url, cache=False) + + file_cached.seek(start) + file_downloaded.seek(start) + + self.assertEqual(file_cached.get_length(), file_downloaded.get_length()) + self.assertLessEqual(length + start if length is not None else 0, file_downloaded.get_length()) + + response_cached = file_cached.read(ll=length) + response_downloaded = file_downloaded.read(ll=length) + + self.assertEqual(response_cached, response_downloaded) + + # Now test with cache in place + file_cached = URLFile(url, cache=True) + file_cached.seek(start) + response_cached = file_cached.read(ll=length) + + self.assertEqual(file_cached.get_length(), file_downloaded.get_length()) + self.assertEqual(response_cached, response_downloaded) + + def test_small_file(self): + # Make sure we don't force cache + os.environ["FILEREADER_CACHE"] = "0" + small_file_url = "https://raw.githubusercontent.com/commaai/openpilot/master/docs/SAFETY.md" + # If you want large file to be larger than a chunk + # large_file_url = "https://commadataci.blob.core.windows.net/openpilotci/0375fdf7b1ce594d/2019-06-13--08-32-25/3/fcamera.hevc" + + # Load full small file + self.compare_loads(small_file_url) + + file_small = URLFile(small_file_url) + length = file_small.get_length() + + self.compare_loads(small_file_url, length - 100, 100) + self.compare_loads(small_file_url, 50, 100) + + # Load small file 100 bytes at a time + for i in range(length // 100): + self.compare_loads(small_file_url, 100 * i, 100) + + def test_large_file(self): + large_file_url = "https://commadataci.blob.core.windows.net/openpilotci/0375fdf7b1ce594d/2019-06-13--08-32-25/3/qlog.bz2" + # Load the end 100 bytes of both files + file_large = URLFile(large_file_url) + length = file_large.get_length() + + self.compare_loads(large_file_url, length - 100, 100) + self.compare_loads(large_file_url) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/lib/tests/test_readers.py b/tools/lib/tests/test_readers.py new file mode 100755 index 00000000000000..1d8918ba54880f --- /dev/null +++ b/tools/lib/tests/test_readers.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +import unittest +import requests +import tempfile + +from collections import defaultdict +import numpy as np +from tools.lib.framereader import FrameReader +from tools.lib.logreader import LogReader + + +class TestReaders(unittest.TestCase): + @unittest.skip("skip for bandwith reasons") + def test_logreader(self): + def _check_data(lr): + hist = defaultdict(int) + for l in lr: + hist[l.which()] += 1 + + self.assertEqual(hist['carControl'], 6000) + self.assertEqual(hist['logMessage'], 6857) + + with tempfile.NamedTemporaryFile(suffix=".bz2") as fp: + r = requests.get("https://github.com/commaai/comma2k19/blob/master/Example_1/b0c9d2329ad1606b%7C2018-08-02--08-34-47/40/raw_log.bz2?raw=true") + fp.write(r.content) + fp.flush() + + lr_file = LogReader(fp.name) + _check_data(lr_file) + + lr_url = LogReader("https://github.com/commaai/comma2k19/blob/master/Example_1/b0c9d2329ad1606b%7C2018-08-02--08-34-47/40/raw_log.bz2?raw=true") + _check_data(lr_url) + + @unittest.skip("skip for bandwith reasons") + def test_framereader(self): + def _check_data(f): + self.assertEqual(f.frame_count, 1200) + self.assertEqual(f.w, 1164) + self.assertEqual(f.h, 874) + + frame_first_30 = f.get(0, 30) + self.assertEqual(len(frame_first_30), 30) + + print(frame_first_30[15]) + + print("frame_0") + frame_0 = f.get(0, 1) + frame_15 = f.get(15, 1) + + print(frame_15[0]) + + assert np.all(frame_first_30[0] == frame_0[0]) + assert np.all(frame_first_30[15] == frame_15[0]) + + with tempfile.NamedTemporaryFile(suffix=".hevc") as fp: + r = requests.get("https://github.com/commaai/comma2k19/blob/master/Example_1/b0c9d2329ad1606b%7C2018-08-02--08-34-47/40/video.hevc?raw=true") + fp.write(r.content) + fp.flush() + + fr_file = FrameReader(fp.name) + _check_data(fr_file) + + fr_url = FrameReader("https://github.com/commaai/comma2k19/blob/master/Example_1/b0c9d2329ad1606b%7C2018-08-02--08-34-47/40/video.hevc?raw=true") + _check_data(fr_url) + +if __name__ == "__main__": + unittest.main() diff --git a/tools/lib/url_file.py b/tools/lib/url_file.py new file mode 100644 index 00000000000000..2161770d030409 --- /dev/null +++ b/tools/lib/url_file.py @@ -0,0 +1,198 @@ +# pylint: skip-file + +import os +import time +import tempfile +import threading +import urllib.parse +import pycurl +from hashlib import sha256 +from io import BytesIO +from tenacity import retry, wait_random_exponential, stop_after_attempt +from common.file_helpers import mkdirs_exists_ok, atomic_write_in_dir +# Cache chunk size +K = 1000 +CHUNK_SIZE = 1000 * K + +CACHE_DIR = os.environ.get("COMMA_CACHE", "/tmp/comma_download_cache/") + + +def hash_256(link): + hsh = str(sha256((link.split("?")[0]).encode('utf-8')).hexdigest()) + return hsh + + +class URLFile(object): + _tlocal = threading.local() + + def __init__(self, url, debug=False, cache=None): + self._url = url + self._pos = 0 + self._length = None + self._local_file = None + self._debug = debug + # True by default, false if FILEREADER_CACHE is defined, but can be overwritten by the cache input + self._force_download = not int(os.environ.get("FILEREADER_CACHE", "0")) + if cache is not None: + self._force_download = not cache + + try: + self._curl = self._tlocal.curl + except AttributeError: + self._curl = self._tlocal.curl = pycurl.Curl() + mkdirs_exists_ok(CACHE_DIR) + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + if self._local_file is not None: + os.remove(self._local_file.name) + self._local_file.close() + self._local_file = None + + @retry(wait=wait_random_exponential(multiplier=1, max=5), stop=stop_after_attempt(3), reraise=True) + def get_length_online(self): + c = self._curl + c.reset() + c.setopt(pycurl.NOSIGNAL, 1) + c.setopt(pycurl.TIMEOUT_MS, 500000) + c.setopt(pycurl.FOLLOWLOCATION, True) + c.setopt(pycurl.URL, self._url) + c.setopt(c.NOBODY, 1) + c.perform() + length = int(c.getinfo(c.CONTENT_LENGTH_DOWNLOAD)) + c.reset() + return length + + def get_length(self): + if self._length is not None: + return self._length + file_length_path = os.path.join(CACHE_DIR, hash_256(self._url) + "_length") + if os.path.exists(file_length_path) and not self._force_download: + with open(file_length_path, "r") as file_length: + content = file_length.read() + self._length = int(content) + return self._length + + self._length = self.get_length_online() + if not self._force_download: + with atomic_write_in_dir(file_length_path, mode="w") as file_length: + file_length.write(str(self._length)) + return self._length + + def read(self, ll=None): + if self._force_download: + return self.read_aux(ll=ll) + + file_begin = self._pos + file_end = self._pos + ll if ll is not None else self.get_length() + # We have to align with chunks we store. Position is the begginiing of the latest chunk that starts before or at our file + position = (file_begin // CHUNK_SIZE) * CHUNK_SIZE + response = b"" + while True: + self._pos = position + chunk_number = self._pos / CHUNK_SIZE + file_name = hash_256(self._url) + "_" + str(chunk_number) + full_path = os.path.join(CACHE_DIR, str(file_name)) + data = None + # If we don't have a file, download it + if not os.path.exists(full_path): + data = self.read_aux(ll=CHUNK_SIZE) + with atomic_write_in_dir(full_path, mode="wb") as new_cached_file: + new_cached_file.write(data) + else: + with open(full_path, "rb") as cached_file: + data = cached_file.read() + + response += data[max(0, file_begin - position): min(CHUNK_SIZE, file_end - position)] + + position += CHUNK_SIZE + if position >= file_end: + self._pos = file_end + return response + + @retry(wait=wait_random_exponential(multiplier=1, max=5), stop=stop_after_attempt(3), reraise=True) + def read_aux(self, ll=None): + download_range = False + headers = ["Connection: keep-alive"] + if self._pos != 0 or ll is not None: + if ll is None: + end = self.get_length() - 1 + else: + end = min(self._pos + ll, self.get_length()) - 1 + if self._pos >= end: + return b"" + headers.append(f"Range: bytes={self._pos}-{end}") + download_range = True + + dats = BytesIO() + c = self._curl + c.setopt(pycurl.URL, self._url) + c.setopt(pycurl.WRITEDATA, dats) + c.setopt(pycurl.NOSIGNAL, 1) + c.setopt(pycurl.TIMEOUT_MS, 500000) + c.setopt(pycurl.HTTPHEADER, headers) + c.setopt(pycurl.FOLLOWLOCATION, True) + + if self._debug: + print("downloading", self._url) + + def header(x): + if b'MISS' in x: + print(x.strip()) + + c.setopt(pycurl.HEADERFUNCTION, header) + + def test(debug_type, debug_msg): + print(" debug(%d): %s" % (debug_type, debug_msg.strip())) + + c.setopt(pycurl.VERBOSE, 1) + c.setopt(pycurl.DEBUGFUNCTION, test) + t1 = time.time() + + c.perform() + + if self._debug: + t2 = time.time() + if t2 - t1 > 0.1: + print("get %s %r %.f slow" % (self._url, headers, t2 - t1)) + + response_code = c.getinfo(pycurl.RESPONSE_CODE) + if response_code == 416: # Requested Range Not Satisfiable + raise Exception(f"Error, range out of bounds {response_code} {headers} ({self._url}): {repr(dats.getvalue())[:500]}") + if download_range and response_code != 206: # Partial Content + raise Exception(f"Error, requested range but got unexpected response {response_code} {headers} ({self._url}): {repr(dats.getvalue())[:500]}") + if (not download_range) and response_code != 200: # OK + raise Exception(f"Error {response_code} {headers} ({self._url}): {repr(dats.getvalue())[:500]}") + + ret = dats.getvalue() + self._pos += len(ret) + return ret + + def seek(self, pos): + self._pos = pos + + @property + def name(self): + """Returns a local path to file with the URLFile's contents. + + This can be used to interface with modules that require local files. + """ + if self._local_file is None: + _, ext = os.path.splitext(urllib.parse.urlparse(self._url).path) + local_fd, local_path = tempfile.mkstemp(suffix=ext) + try: + os.write(local_fd, self.read()) + local_file = open(local_path, "rb") + except Exception: + os.remove(local_path) + raise + finally: + os.close(local_fd) + + self._local_file = local_file + self.read = self._local_file.read + self.seek = self._local_file.seek + + return self._local_file.name diff --git a/tools/lib/vidindex/.gitignore b/tools/lib/vidindex/.gitignore new file mode 100644 index 00000000000000..a77a06e97d7d3c --- /dev/null +++ b/tools/lib/vidindex/.gitignore @@ -0,0 +1 @@ +vidindex diff --git a/tools/lib/vidindex/Makefile b/tools/lib/vidindex/Makefile new file mode 100644 index 00000000000000..f6526db212d23a --- /dev/null +++ b/tools/lib/vidindex/Makefile @@ -0,0 +1,6 @@ +CC := gcc + +vidindex: bitstream.c bitstream.h vidindex.c + $(eval $@_TMP := $(shell mktemp)) + $(CC) -std=c99 bitstream.c vidindex.c -o $($@_TMP) + mv $($@_TMP) $@ diff --git a/tools/lib/vidindex/bitstream.c b/tools/lib/vidindex/bitstream.c new file mode 100644 index 00000000000000..d174ffa8a7dfa6 --- /dev/null +++ b/tools/lib/vidindex/bitstream.c @@ -0,0 +1,118 @@ +#include +#include + +#include "bitstream.h" + +static const uint32_t BS_MASKS[33] = { + 0, 0x1L, 0x3L, 0x7L, 0xFL, 0x1FL, + 0x3FL, 0x7FL, 0xFFL, 0x1FFL, 0x3FFL, 0x7FFL, + 0xFFFL, 0x1FFFL, 0x3FFFL, 0x7FFFL, 0xFFFFL, 0x1FFFFL, + 0x3FFFFL, 0x7FFFFL, 0xFFFFFL, 0x1FFFFFL, 0x3FFFFFL, 0x7FFFFFL, + 0xFFFFFFL, 0x1FFFFFFL, 0x3FFFFFFL, 0x7FFFFFFL, 0xFFFFFFFL, 0x1FFFFFFFL, + 0x3FFFFFFFL, 0x7FFFFFFFL, 0xFFFFFFFFL}; + +void bs_init(struct bitstream* bs, const uint8_t* buffer, size_t input_size) { + bs->buffer_ptr = buffer; + bs->buffer_end = buffer + input_size; + bs->value = 0; + bs->pos = 0; + bs->shift = 8; + bs->size = input_size * 8; +} + +uint32_t bs_get(struct bitstream* bs, int n) { + if (n > 32) + return 0; + + bs->pos += n; + bs->shift += n; + while (bs->shift > 8) { + if (bs->buffer_ptr < bs->buffer_end) { + bs->value <<= 8; + bs->value |= *bs->buffer_ptr++; + bs->shift -= 8; + } else { + bs_seek(bs, bs->pos - n); + return 0; + // bs->value <<= 8; + // bs->shift -= 8; + } + } + return (bs->value >> (8 - bs->shift)) & BS_MASKS[n]; +} + +void bs_seek(struct bitstream* bs, size_t new_pos) { + bs->pos = (new_pos / 32) * 32; + bs->shift = 8; + bs->value = 0; + bs_get(bs, new_pos % 32); +} + +uint32_t bs_peek(struct bitstream* bs, int n) { + struct bitstream bak = *bs; + return bs_get(&bak, n); +} + +size_t bs_remain(struct bitstream* bs) { + return bs->size - bs->pos; +} + +int bs_eof(struct bitstream* bs) { + return bs_remain(bs) == 0; +} + +uint32_t bs_ue(struct bitstream* bs) { + static const uint8_t exp_golomb_bits[256] = { + 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }; + uint32_t bits, read = 0; + int bits_left; + uint8_t coded; + int done = 0; + bits = 0; + // we want to read 8 bits at a time - if we don't have 8 bits, + // read what's left, and shift. The exp_golomb_bits calc remains the + // same. + while (!done) { + bits_left = bs_remain(bs); + if (bits_left < 8) { + read = bs_peek(bs, bits_left) << (8 - bits_left); + done = 1; + } else { + read = bs_peek(bs, 8); + if (read == 0) { + bs_get(bs, 8); + bits += 8; + } else { + done = 1; + } + } + } + coded = exp_golomb_bits[read]; + bs_get(bs, coded); + bits += coded; + + // printf("ue - bits %d\n", bits); + return bs_get(bs, bits + 1) - 1; +} + +int32_t bs_se(struct bitstream* bs) { + uint32_t ret; + ret = bs_ue(bs); + if ((ret & 0x1) == 0) { + ret >>= 1; + int32_t temp = 0 - ret; + return temp; + } + return (ret + 1) >> 1; +} diff --git a/tools/lib/vidindex/bitstream.h b/tools/lib/vidindex/bitstream.h new file mode 100644 index 00000000000000..0f538a59ab7d00 --- /dev/null +++ b/tools/lib/vidindex/bitstream.h @@ -0,0 +1,26 @@ +#ifndef bitstream_H +#define bitstream_H + + +#include +#include + +struct bitstream { + const uint8_t *buffer_ptr; + const uint8_t *buffer_end; + uint64_t value; + uint32_t pos; + uint32_t shift; + size_t size; +}; + +void bs_init(struct bitstream *bs, const uint8_t *buffer, size_t input_size); +void bs_seek(struct bitstream *bs, size_t new_pos); +uint32_t bs_get(struct bitstream *bs, int n); +uint32_t bs_peek(struct bitstream *bs, int n); +size_t bs_remain(struct bitstream *bs); +int bs_eof(struct bitstream *bs); +uint32_t bs_ue(struct bitstream *bs); +int32_t bs_se(struct bitstream *bs); + +#endif diff --git a/tools/lib/vidindex/vidindex.c b/tools/lib/vidindex/vidindex.c new file mode 100644 index 00000000000000..4857c60dd2fc03 --- /dev/null +++ b/tools/lib/vidindex/vidindex.c @@ -0,0 +1,307 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "bitstream.h" + +#define START_CODE 0x000001 + +static uint32_t read24be(const uint8_t* ptr) { + return (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; +} +static void write32le(FILE *of, uint32_t v) { + uint8_t va[4] = { + v & 0xff, (v >> 8) & 0xff, (v >> 16) & 0xff, (v >> 24) & 0xff + }; + fwrite(va, 1, sizeof(va), of); +} + +// Table 7-1 +enum hevc_nal_type { + HEVC_NAL_TYPE_TRAIL_N = 0, + HEVC_NAL_TYPE_TRAIL_R = 1, + HEVC_NAL_TYPE_TSA_N = 2, + HEVC_NAL_TYPE_TSA_R = 3, + HEVC_NAL_TYPE_STSA_N = 4, + HEVC_NAL_TYPE_STSA_R = 5, + HEVC_NAL_TYPE_RADL_N = 6, + HEVC_NAL_TYPE_RADL_R = 7, + HEVC_NAL_TYPE_RASL_N = 8, + HEVC_NAL_TYPE_RASL_R = 9, + HEVC_NAL_TYPE_BLA_W_LP = 16, + HEVC_NAL_TYPE_BLA_W_RADL = 17, + HEVC_NAL_TYPE_BLA_N_LP = 18, + HEVC_NAL_TYPE_IDR_W_RADL = 19, + HEVC_NAL_TYPE_IDR_N_LP = 20, + HEVC_NAL_TYPE_CRA_NUT = 21, + HEVC_NAL_TYPE_RSV_IRAP_VCL23 = 23, + HEVC_NAL_TYPE_VPS_NUT = 32, + HEVC_NAL_TYPE_SPS_NUT = 33, + HEVC_NAL_TYPE_PPS_NUT = 34, + HEVC_NAL_TYPE_AUD_NUT = 35, + HEVC_NAL_TYPE_EOS_NUT = 36, + HEVC_NAL_TYPE_EOB_NUT = 37, + HEVC_NAL_TYPE_FD_NUT = 38, + HEVC_NAL_TYPE_PREFIX_SEI_NUT = 39, + HEVC_NAL_TYPE_SUFFIX_SEI_NUT = 40, +}; + +// Table 7-7 +enum hevc_slice_type { + HEVC_SLICE_B = 0, + HEVC_SLICE_P = 1, + HEVC_SLICE_I = 2, +}; + +static void hevc_index(const uint8_t *data, size_t file_size, FILE *of_prefix, FILE *of_index) { + const uint8_t* ptr = data; + const uint8_t* ptr_end = data + file_size; + + assert(ptr[0] == 0); + ptr++; + assert(read24be(ptr) == START_CODE); + + // pps. ignore for now + uint32_t num_extra_slice_header_bits = 0; + uint32_t dependent_slice_segments_enabled_flag = 0; + + while (ptr < ptr_end) { + const uint8_t* next = ptr+1; + for (; next < ptr_end-4; next++) { + if (read24be(next) == START_CODE) break; + } + size_t nal_size = next - ptr; + if (nal_size < 6) { + break; + } + + { + struct bitstream bs = {0}; + bs_init(&bs, ptr, nal_size); + + uint32_t start_code = bs_get(&bs, 24); + assert(start_code == 0x000001); + + // nal_unit_header + uint32_t forbidden_zero_bit = bs_get(&bs, 1); + uint32_t nal_unit_type = bs_get(&bs, 6); + uint32_t nuh_layer_id = bs_get(&bs, 6); + uint32_t nuh_temporal_id_plus1 = bs_get(&bs, 3); + + // if (nal_unit_type != 1) printf("%3d -- %3d %10d %lu\n", nal_unit_type, frame_num, (uint32_t)(ptr-data), nal_size); + + switch (nal_unit_type) { + case HEVC_NAL_TYPE_VPS_NUT: + case HEVC_NAL_TYPE_SPS_NUT: + case HEVC_NAL_TYPE_PPS_NUT: + fwrite(ptr, 1, nal_size, of_prefix); + break; + case HEVC_NAL_TYPE_TRAIL_N: + case HEVC_NAL_TYPE_TRAIL_R: + case HEVC_NAL_TYPE_TSA_N: + case HEVC_NAL_TYPE_TSA_R: + case HEVC_NAL_TYPE_STSA_N: + case HEVC_NAL_TYPE_STSA_R: + case HEVC_NAL_TYPE_RADL_N: + case HEVC_NAL_TYPE_RADL_R: + case HEVC_NAL_TYPE_RASL_N: + case HEVC_NAL_TYPE_RASL_R: + case HEVC_NAL_TYPE_BLA_W_LP: + case HEVC_NAL_TYPE_BLA_W_RADL: + case HEVC_NAL_TYPE_BLA_N_LP: + case HEVC_NAL_TYPE_IDR_W_RADL: + case HEVC_NAL_TYPE_IDR_N_LP: + case HEVC_NAL_TYPE_CRA_NUT: { + // slice_segment_header + uint32_t first_slice_segment_in_pic_flag = bs_get(&bs, 1); + if (nal_unit_type >= HEVC_NAL_TYPE_BLA_W_LP && nal_unit_type <= HEVC_NAL_TYPE_RSV_IRAP_VCL23) { + uint32_t no_output_of_prior_pics_flag = bs_get(&bs, 1); + } + uint32_t slice_pic_parameter_set_id = bs_get(&bs, 1); + if (!first_slice_segment_in_pic_flag) { + // ... + break; + } + + if (!dependent_slice_segments_enabled_flag) { + for (int i=0; i 4); + + const uint8_t* data = (const uint8_t*)mmap(NULL, file_size, PROT_READ, MAP_PRIVATE, fd, 0); + assert(data != MAP_FAILED); + + if (strcmp(file_type, "hevc") == 0) { + hevc_index(data, file_size, of_prefix, of_index); + } else if (strcmp(file_type, "h264") == 0) { + h264_index(data, file_size, of_prefix, of_index); + } else { + assert(false); + } + + munmap((void*)data, file_size); + close(fd); + + return 0; +}
    %s