diff --git a/.travis.yml b/.travis.yml index aca4864bb..6df180023 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ +#keep Ubuntu 12.04 on Travis to match Vagrant +dist: precise language: c +dist: precise compiler: - clang script: PLATFORM=TESTING make test @@ -6,7 +9,7 @@ install: - gem install coveralls-lcov before_install: - sudo apt-get update -qq -- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq -y libgd2-xpm ia32-libs +- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq -y libgd2-xpm ia32-libs libsubunit-dev ia32-libs-multiarch; fi - travis_wait script/bootstrap.sh - cd src diff --git a/CHANGELOG.mkd b/CHANGELOG.mkd index 5f5568015..05ceedd7f 100644 --- a/CHANGELOG.mkd +++ b/CHANGELOG.mkd @@ -1,6 +1,6 @@ # OpenXC Vehicle Interface Firmware Changelog -## v7.2.1-dev +## v7.3.0 * BREAKING: Removed fine_odometer_since_restart from emulator. * Feature: Added sending evented messages from emulator. @@ -13,6 +13,15 @@ and the command line. The response will mimic the request's bus, message ID, mode, and PID (if sent). The response will also include a randomly generated value between 0 and 100. Recurring diagnostic messages when running emulator firmware are currently not supported. +* Update: Moved Vagrant VM to xenial64. Several updated packages. +* Fix: Fixed a few bugs with C5 support from initial release: + - BLE Broadcast name and MAC + - CAN2 access + - UART debug access + - Updated flash instructions +* Feature: Add PLATFORM command + + ## v7.2.0 diff --git a/CONTRIBUTING.mkd b/CONTRIBUTING.mkd index 04ff715cd..859c72ff8 100644 --- a/CONTRIBUTING.mkd +++ b/CONTRIBUTING.mkd @@ -8,14 +8,14 @@ top of things. ## Reporting an Issue * Make sure you have a [GitHub account](https://github.com/signup/free) -* Check if a ticket already exists for your issue on [GitHub](gh-issues). -* If one does not already exist, [create a new ticket](gh-issues) +* Check if a ticket already exists for your issue on [GitHub](https://github.com/openxc/vi-firmware/issues). +* If one does not already exist, [create a new ticket](https://github.com/openxc/vi-firmware/issues/new) * Clearly describe the issue including steps to reproduce when it is a bug. * Make sure you include in the earliest version that you know has the issue. ## Making Changes -* If you haven't already, create a new issue on [GitHub](gh-issues) for your bug +* If you haven't already, create a new issue on [GitHub](https://github.com/openxc/vi-firmware/issues/new) for your bug fix or new feature. * Fork the repository on GitHub * Create a topic branch from where you want to base your work. @@ -30,7 +30,7 @@ top of things. * Make sure your commit messages are in the [proper format](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). * Make sure you have added the necessary tests for your changes in the `openxc-it` sub-project -* Run the [full test suite](https://github.com/openxc/vi-firmware/blob/master/README_developers.mkd) to assure nothing else was accidentally broken. +* Run the [full test suite](http://vi-firmware.openxcplatform.com/en/master/testing.html#test-suite) to assure nothing else was accidentally broken. ## Submitting Changes @@ -42,6 +42,6 @@ top of things. # Additional Resources * [General GitHub documentation](http://help.github.com/) -* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) +* [GitHub pull request documentation](https://help.github.com/articles/about-pull-requests/) [gh-issues]: https://github.com/openxc/vi-firmware/issues diff --git a/README.rst b/README.rst index 651c089d6..abd00dee6 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ OpenXC Vehicle Interface Firmware .. image:: /docs/_static/logo.png -:Version: 7.2.1-dev +:Version: 7.3.0 :Web: http://openxcplatform.com :Documentation: http://vi-firmware.openxcplatform.com :Source: http://github.com/openxc/vi-firmware @@ -82,7 +82,7 @@ Releasing License ======= -Copyright (c) 2012-2014 Ford Motor Company +Copyright (c) 2012-2018 Ford Motor Company Licensed under the BSD license. diff --git a/Vagrantfile b/Vagrantfile index bbd82c96e..cb34727fd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # -*- mode: ruby -*- # vi: set ft=ruby : @@ -9,10 +10,31 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # vagrantup.com. # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = "ubuntu/precise64" + config.vm.box = "ubuntu/xenial64" + + # Check for proxy enviroment variable and set it + if ENV['HTTP_PROXY'] || ENV['HTTPS_PROXY'] + if Vagrant.has_plugin?("vagrant-proxyconf") + if ENV['HTTP_PROXY'] + config.proxy.http = ENV['HTTP_PROXY'] + config.apt_proxy.http = ENV['HTTP_PROXY'] + end + if ENV['HTTPS_PROXY'] + config.proxy.https = ENV['HTTPS_PROXY'] + config.apt_proxy.https = ENV['HTTP_PROXY'] + end + if ENV['NO_PROXY'] + config.proxy.no_proxy = ENV['NO_PROXY'] + end + else + abort("ERROR, vagrant-proxyconf not installed run ‘vagrant plugin install vagrant-proxyconf’ to install it") + end + end + config.vm.provision "shell", privileged: false, keep_color: true do |s| s.inline = "ln -fs /vagrant vi-firmware;" s.inline += "VAGRANT=1 vi-firmware/script/bootstrap.sh" + end end diff --git a/docs/advanced/rtc.rst b/docs/advanced/rtc.rst index 7763756b1..06d23eb12 100644 --- a/docs/advanced/rtc.rst +++ b/docs/advanced/rtc.rst @@ -5,11 +5,13 @@ Real Time Clock Real time Clock Configuration ------------------------------ -For correct time stamping it is necessary that the RTC is configured with the correct time. +For correct time stamping it is necessary that the RTC is configured with the correct time. A new rtc configuration command is added to the `OpenXC message format `_. Example JSON command { "command": "rtc_configuration", "unix_time": "1448551563"} +To set the RTC to the correct unix time on Windows Git Bash, Mac, or Linux shell, use the following command: +``% TIME=$(date +%s); openxc-control set --time $TIME`` diff --git a/docs/compile/example-builds.rst b/docs/compile/example-builds.rst index 5acb2b1c8..1819fd830 100644 --- a/docs/compile/example-builds.rst +++ b/docs/compile/example-builds.rst @@ -48,8 +48,8 @@ want to send diagnostic requests through a VI: The Makefile will always print the configuration used so you can double check. -* This default configuration will run on a _`Ford reference VI - ` (``PLATFORM`` is ``FORDBOARD``) running the +* This default configuration will run on a `Ford reference VI `_ + (``PLATFORM`` is ``FORDBOARD``) running the pre-loaded bootloader (``BOOTLOADER`` is ``1``). * Debug mode is off (``DEBUG`` is ``0``) so no log messages will be output via USB for maximum performance. @@ -57,18 +57,18 @@ The Makefile will always print the configuration used so you can double check. will only be permitted if set via USB (``DEFAULT_ALLOW_RAW_WRITE_USB`` is ``1`` but the ``*_UART`` and ``*_NETWORK`` versions are ``0``. * The data sent from the VI will be serialized to JSON in the format defined by - the _`OpenXC message format `. + the `OpenXC message format `_. * The VI will go into sleep mode only when no CAN bus activity is detected for a few seconds (the ``DEFAULT_POWER_MANAGEMENT`` mode is ``SILENT_CAN``). * The CAN controllers will be initialized as listen only unless the VI configuration explicitly states they are writable (``DEFAULT_CAN_ACK_STATUS`` is ``1``). This means that the VI may not work in a bench testing setup where nothing else on the bus is ACKing. -* :ref:`Mass storage device ` (``MSD_ENABLE`` is ``0``) is disabled - by default and is available on certain C5 devices which have a provision to connect - a SD card. The time intervals at which the data is logged is +* :ref:`Mass storage device ` (``MSD_ENABLE`` is ``0``) is disabled + by default and is available on certain C5 devices which have a provision to connect + a SD card. The time intervals at which the data is logged is (``DEFAULT_FILE_GENERATE_SECS`` is ``180``) set to 180 seconds by default. - + .. NOTE:: There's a shortcut for this default build, using the Fabric tool and an included script. This will build the default build for the reference VI @@ -117,7 +117,7 @@ options: - 0 = TEST_MODE_ONLY - 0 = DEBUG - 0 = MSD_ENABLE - - 180 = DEFAULT_FILE_GENERATE_SECS + - 180 = DEFAULT_FILE_GENERATE_SECS - 0 = DEFAULT_METRICS_STATUS - 1 = DEFAULT_ALLOW_RAW_WRITE_USB - 0 = DEFAULT_ALLOW_RAW_WRITE_UART @@ -162,9 +162,9 @@ to a vehicle, but you don't care about the actual vehicle data being generated, you can compile a build that generates random vehicle data and sends it via the normal I/O interfaces. -If you are building an app, you'll want to use a _`trace file -` or the _`vehicle simulator -`. +If you are building an app, you'll want to use a `trace file +`_ or the `vehicle simulator +`_. The config a VI to emulate a vehicle: @@ -202,7 +202,7 @@ There are 2 changes from the default build: * ``DEFAULT_POWER_MANAGEMENT`` is ``ALWAYS_ON``, so the VI will not go to sleep while plugged in. Make sure to clear this configuration option before making a build to run in a vehicle, or you could drain the battery! - + .. NOTE:: This build also has a shortcut using the Fabric script. Just add the keyword ``emulator`` before ``build`` in your call to ``fab`` at the command line. @@ -256,7 +256,7 @@ while this builds the default firmware, ready for OBD2 requests for the chipKIT: .. code-block:: sh fab chipkit obd2 build - + You can specify the message format with ``json``, ``protobuf``, or ``messagepack``: .. code-block:: sh diff --git a/docs/compile/native-development.rst b/docs/compile/native-development.rst index af7230118..f43f1d23d 100644 --- a/docs/compile/native-development.rst +++ b/docs/compile/native-development.rst @@ -49,7 +49,7 @@ installer - during the installation process, select these packages: .. code-block:: sh - make, gcc-core, patchutils, unzip, python, check, curl, libsasl2, python-setuptools + make, git, gcc-core, patchutils, unzip, python, check, curl, libsasl2, python-setuptools After it's installed, open a new Cygwin terminal and configure it to ignore Windows-style line endings in scripts by running this command: diff --git a/docs/conf.py b/docs/conf.py index 8f6ccf5c5..025b0f1cb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,16 +42,16 @@ # General information about the project. project = 'OpenXC Vehicle Interface Firmware' -copyright = '2016, Ford Motor Company' +copyright = '2018, Ford Motor Company' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '7.2.1-dev' +version = '7.3.0' # The full version, including alpha/beta/rc tags. -release = '7.2.1-dev' +release = '7.3.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/config/bit-numbering.rst b/docs/config/bit-numbering.rst index 69438e4a5..fed4bff61 100644 --- a/docs/config/bit-numbering.rst +++ b/docs/config/bit-numbering.rst @@ -7,7 +7,7 @@ Bit Numbering and Byte Order When dealing with binary data like CAN messages, there are two important details - byte order and bit numbering. -Byte order, or _`endianness `, determines +Byte order, or `endianness `_, determines the convention used to interpret a sequence of bytes as a number. Given 4 bytes of data, e.g. ``0x01 02 03 04``, the endianness determines which byte is the "zero-th" byte and which is the last. There are only two options: big endian diff --git a/docs/getting-started/compiling-emulator.rst b/docs/getting-started/compiling-emulator.rst index 556ace649..532c8b9f2 100644 --- a/docs/getting-started/compiling-emulator.rst +++ b/docs/getting-started/compiling-emulator.rst @@ -38,8 +38,7 @@ e.g. for the ``CHIPKIT`` platform it will be at Finally, test that you can receive the emulated data output stream using the OpenXC Python library: -#. You should already have the OpenXC Python library installed after running the - ``bootstrap.sh`` script, but if not, `install the library +#. If you don't already have the OpenXC Python library installed, `install the library `_ with ``pip``. Don't forget a `USB backend `_. #. Attach the programmed VI to your computer with a USB cable. In Windows, diff --git a/docs/index.rst b/docs/index.rst index fa43cb447..3e7c359b4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -4,7 +4,7 @@ OpenXC Vehicle Interface Firmware .. image:: /_static/logo.png -:Version: 7.2.1-dev +:Version: 7.3.0 :Web: http://openxcplatform.com :Documentation: http://vi-firmware.openxcplatform.com :Source: http://github.com/openxc/vi-firmware diff --git a/docs/output.rst b/docs/output.rst index 9c146d808..a540843f9 100644 --- a/docs/output.rst +++ b/docs/output.rst @@ -74,6 +74,15 @@ Device ID Query openxc-control id +.. _platform-query: + +Platform Query +--------------- + +.. code-block:: sh + + openxc-control platform + Set CAN Message Passthrough Status ---------------------------------- @@ -105,7 +114,7 @@ wireless I/O with the VI. The VI will send all messages it is configured to received out over the UART interface using the OpenXC message format. The data may be serialized as either JSON or protocol buffers, depending on the selected output format. Each message -is followed by a ``\r\n`` delimiter. +is followed by a ``\0`` delimiter. The UART interface also accepts all valid OpenXC commands. JSON is the only support format for commands in this version. Commands must be delimited with a @@ -125,7 +134,7 @@ go about 100KB/s. The VI will publish all messages it is configured to received to USB bulk ``IN`` endpoint 2 using the OpenXC message format. The data may be serialized as either JSON or protocol buffers, depending on the selected output format. Each message -is followed by a ``\r\n`` delimiter. A larger read request from the host request +is followed by a ``\0`` delimiter. A larger read request from the host request will allow more messages to be batched together into one USB request and give high overall throughput (with the downside of introducing delay depending on the size of the request). @@ -136,11 +145,11 @@ Commands must be delimited with a ``\0`` (NULL) character. Commands must be no more than 256 bytes (4 USB packets). Finally, the VI publishes log messages to bulk ``IN`` endpoint 11 when compiled -with the ``DEBUG`` flag. The log messages are delimited with ``\r\n``. +with the ``DEBUG`` flag. The log messages are delimited with ``\0``. If you are using one of the support libraries (e.g. `openxc-python -`_ or `openxc-android -`_, you don't need to worry about the +`_ or `openxc-android +`_, you don't need to worry about the details of the USB device driver, but for creating new libraries the endpoints are documented here. diff --git a/script/bootstrap/common.sh b/script/bootstrap/common.sh index 8d896a63b..7013fd028 100644 --- a/script/bootstrap/common.sh +++ b/script/bootstrap/common.sh @@ -150,25 +150,13 @@ supported - see the docs for the recommended approach" if [ $OS == "cygwin" ]; then # TODO need a warning colored promp - echo "It looks like you're developing in Cygwin. Cygwin is no \ -longer the recommended build environment for \ -Windows developers. It is unofficially supported by the bootstrap \ -scripts, but the recommended method is to use Vagrant - see the docs for \ -more information." - echo -n "Press Enter to continue anyway, or Control-C to cancel" - read - echo "Continuing with bootstrap..." + die "Compiling the VI firmware from a Cigwin prompt is not \ +supported - see the docs for the recommended approach" fi if [ $OS == "mac" ]; then - echo "It looks like you're developing in Mac OS X. We recommend \ -using Vagrant to compile the VI firmware. OS X is unofficially supported by \ -the bootstrap scripts and you should be able to compile just fine, but you \ -can save yourself some trouble by using the pre-configured Vagrant \ -environment. See the docs for more information." - echo -n "Press Enter to continue anyway, or Control-C to cancel" - read - echo "Continuing with bootstrap..." + die "Compiling the VI firmware from a MacOS prompt is not \ +supported - see the docs for the recommended approach" fi if [ $OS == "linux" ] && [ -z $VAGRANT ] && [ -z $CI ]; then @@ -182,22 +170,13 @@ pre-configured Vagrant environment. See the docs for more information." echo "Continuing with bootstrap..." fi - if [ $OS == "mac" ] && ! command -v brew >/dev/null 2>&1; then - echo "Installing Homebrew..." - ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)" - fi + if ! command -v make >/dev/null 2>&1; then - if [ $OS == "cygwin" ]; then - _cygwin_error "make" - elif [ $OS == "mac" ]; then - die "Missing 'make' - install the Xcode CLI tools" - else - if [ $DISTRO == "arch" ]; then - _install "base-devel" - elif [ $DISTRO == "Ubuntu" ]; then - _install "build-essential" - fi + if [ $DISTRO == "arch" ]; then + _install "base-devel" + elif [ $DISTRO == "Ubuntu" ]; then + _install "build-essential" fi fi @@ -213,11 +192,7 @@ pre-configured Vagrant environment. See the docs for more information." if ! command -v git >/dev/null 2>&1; then - if [ $OS == "cygwin" ]; then - die "You need to install Git for Windows from http://git-scm.com/ and select the option to \"Run Git from the Windows Command Prompt\" during the installation." - elif [ $OS == "mac" ] || [ $OS == "linux" ]; then - _install git - fi + _install git fi echo "Updating Git submodules..." @@ -228,35 +203,26 @@ pre-configured Vagrant environment. See the docs for more information." if ! git submodule update --init --recursive --quiet; then echo "Unable to update git submodules - try running \"git submodule update --init --recursive\" to see the full error" echo "If git complains that it \"Needed a single revision\", run \"rm -rf src/libs\" and then try the bootstrap script again" - if [ $OS == "cygwin" ]; then - echo "In Cygwin this may be true (ignore if you know ca-certifications is installed:" - _cygwin_error "ca-certificates" - fi die fi set -e + #https://cryptography.io/en/latest/installation/#building-cryptography-on-linux + #cryptography is dependency of pyparsing - need to ensure other packages first + #otherwise cffi error + if [ $OS == "linux" ]; then + echo "Installing libffi-dev" + _install "libffi-dev" + fi + if ! command -v python >/dev/null 2>&1; then echo "Installing Python..." _install "python" fi - if [ $OS != "cygwin" ]; then - echo "Installing Python development headers..." - _install "python-dev" - fi - if ! command -v pip >/dev/null 2>&1; then - echo "Installing Pip..." - if ! command -v easy_install >/dev/null 2>&1; then - _install "python-setuptools" - fi - - if ! command -v easy_install >/dev/null 2>&1; then - die "easy_install not available, can't install pip" - fi - - $SUDO_CMD easy_install pip + curl -Ss https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py + $SUDO_CMD python /tmp/get-pip.py fi PIP_SUDO_CMD= @@ -269,6 +235,10 @@ pre-configured Vagrant environment. See the docs for more information." if [ -z $CI ]; then $PIP_SUDO_CMD pip install --src dependencies --pre -r $BOOTSTRAP_DIR/pip-requirements.txt fi + + if ! command -v clang >/dev/null 2>&1; then + $SUDO_CMD sudo apt-get install clang -y + fi COMMON_SOURCED=1 fi diff --git a/script/bootstrap/pip-requirements.txt b/script/bootstrap/pip-requirements.txt index 4117697e4..bb0697889 100644 --- a/script/bootstrap/pip-requirements.txt +++ b/script/bootstrap/pip-requirements.txt @@ -1,3 +1,4 @@ -Fabric==1.9.0 -ecdsa==0.11 -prettyprint==0.1.5 +Fabric==1.13.1 +ecdsa==0.13 +prettyprint==0.1.5 +pyparsing==2.2.0 diff --git a/src/config.cpp b/src/config.cpp index e7a9e5e04..7c12770fa 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -118,7 +118,7 @@ openxc::telitHE910::TelitDevice telitDevice = { openxc::config::Configuration* openxc::config::getConfiguration() { static openxc::config::Configuration CONFIG = { messageSetIndex: 0, - version: "7.2.1-dev", + version: "7.3.0", platform: PLATFORM, environmentMode: ENVIRONMENT_MODE, payloadFormat: PayloadFormat::DEFAULT_OUTPUT_FORMAT, diff --git a/src/libs/openxc-message-format b/src/libs/openxc-message-format index d9f54f975..5d7b86f4d 160000 --- a/src/libs/openxc-message-format +++ b/src/libs/openxc-message-format @@ -1 +1 @@ -Subproject commit d9f54f97578429773421abce98d5f6579717afcc +Subproject commit 5d7b86f4d00c0bb66094aee231caa01c08368b66 diff --git a/src/libs/uds-c b/src/libs/uds-c index e506334e2..7ab5e7d69 160000 --- a/src/libs/uds-c +++ b/src/libs/uds-c @@ -1 +1 @@ -Subproject commit e506334e270d77b20c0bc259ac6c7d8c9b702b7a +Subproject commit 7ab5e7d6997d8b70058d2927670ec55f1f1609d9 diff --git a/src/pipeline.cpp b/src/pipeline.cpp index 5a29aaf6c..7394530d2 100644 --- a/src/pipeline.cpp +++ b/src/pipeline.cpp @@ -241,11 +241,9 @@ void openxc::pipeline::process(Pipeline* pipeline) { fs::processSendQueue(pipeline->fs); } #endif - #ifndef UART_LOGGING_DISABLE if(uart::connected(pipeline->uart)) { uart::processSendQueue(pipeline->uart); } - #endif if(pipeline->network != NULL) { network::processSendQueue(pipeline->network); } diff --git a/src/platform/pic32/ble.cpp b/src/platform/pic32/ble.cpp index 26145be81..3871c363d 100644 --- a/src/platform/pic32/ble.cpp +++ b/src/platform/pic32/ble.cpp @@ -594,7 +594,7 @@ bool openxc::interface::ble::initialize(BleDevice* device) //debug("Mac address %x:%x:%x:%x:%x:%x", device->blesettings.bdaddr[0], device->blesettings.bdaddr[1], device->blesettings.bdaddr[2], // device->blesettings.bdaddr[3], device->blesettings.bdaddr[4], device->blesettings.bdaddr[5]); - sprintf(device_adv_name,"OPENXC-VI-%02X%02X",device->blesettings.bdaddr[1],device->blesettings.bdaddr[0]); + sprintf(device_adv_name,"OpenXC-VI-%02X%02X",device->blesettings.bdaddr[1],device->blesettings.bdaddr[0]); device->blesettings.advname = (const char*)device_adv_name; diff --git a/src/platform/pic32/c5_common_platforms.h b/src/platform/pic32/c5_common_platforms.h index 16f6c3644..258ee560a 100644 --- a/src/platform/pic32/c5_common_platforms.h +++ b/src/platform/pic32/c5_common_platforms.h @@ -129,8 +129,4 @@ #endif -#ifdef CROSSCHASM_C5_BLE - #define UART_LOGGING_DISABLE #endif - -#endif \ No newline at end of file diff --git a/src/platform/pic32/canutil.cpp b/src/platform/pic32/canutil.cpp index 987195cbb..2579f54c4 100644 --- a/src/platform/pic32/canutil.cpp +++ b/src/platform/pic32/canutil.cpp @@ -4,23 +4,38 @@ #include "util/log.h" #include "gpio.h" +//pin numbers and names in comments below from actual schematic +//Since we use ardunio libs, actual number comes from +//../dependencies/mpide/hardware/pic32/variants/Max32/Board_Data.c + + #if defined(CROSSCHASM_C5_BT) #define CAN1_TRANSCEIVER_SWITCHED #define CAN1_TRANSCEIVER_ENABLE_POLARITY 0 - #define CAN1_TRANSCEIVER_ENABLE_PIN 38 // PORTD BIT10 (RD10) + #define CAN1_TRANSCEIVER_ENABLE_PIN 38 // pin #44 PORTD BIT10 (RD10) + + #define CAN2_TRANSCEIVER_SWITCHED + #define CAN2_TRANSCEIVER_ENABLE_POLARITY 0 + #define CAN2_TRANSCEIVER_ENABLE_PIN 49 // pin #45 RD11 + #elif defined(CROSSCHASM_C5_CELLULAR) #define CAN1_TRANSCEIVER_SWITCHED #define CAN1_TRANSCEIVER_ENABLE_POLARITY 0 - #define CAN1_TRANSCEIVER_ENABLE_PIN 38 // PORTD BIT10 (RD10) + #define CAN1_TRANSCEIVER_ENABLE_PIN 38 // pin #44 PORTD BIT10 (RD10) + + #define CAN2_TRANSCEIVER_SWITCHED + #define CAN2_TRANSCEIVER_ENABLE_POLARITY 0 + #define CAN2_TRANSCEIVER_ENABLE_PIN 49 // pin #45 RD11 + #elif defined(CROSSCHASM_C5_BLE) #define CAN1_TRANSCEIVER_SWITCHED #define CAN1_TRANSCEIVER_ENABLE_POLARITY 0 - #define CAN1_TRANSCEIVER_ENABLE_PIN 5 // PORTD BIT1 (RD1) -#endif - - - + #define CAN1_TRANSCEIVER_ENABLE_PIN 5 // pin #49 PORTD BIT1 (RD1) + #define CAN2_TRANSCEIVER_SWITCHED + #define CAN2_TRANSCEIVER_ENABLE_POLARITY 0 + #define CAN2_TRANSCEIVER_ENABLE_PIN 37 // pin #60 PMD0/RE0 +#endif #define CAN_RX_CHANNEL 1 #define BUS_MEMORY_BUFFER_SIZE 2 * 8 * 16 @@ -163,11 +178,24 @@ void openxc::can::deinitialize(CanBus* bus) { switchControllerMode(bus, CAN::DISABLE); // disable off-chip line driver - #if defined(CAN1_TRANSCEIVER_SWITCHED) - GpioValue value = CAN1_TRANSCEIVER_ENABLE_POLARITY ? GPIO_VALUE_LOW : GPIO_VALUE_HIGH; - gpio::setDirection(0, CAN1_TRANSCEIVER_ENABLE_PIN, GPIO_DIRECTION_OUTPUT); - gpio::setValue(0, CAN1_TRANSCEIVER_ENABLE_PIN, value); - #endif + if(bus->address == 1) { + debug("disable bus 1"); + #if defined(CAN1_TRANSCEIVER_SWITCHED) + GpioValue value = CAN1_TRANSCEIVER_ENABLE_POLARITY ? GPIO_VALUE_LOW : GPIO_VALUE_HIGH; + gpio::setDirection(0, CAN1_TRANSCEIVER_ENABLE_PIN, GPIO_DIRECTION_OUTPUT); + gpio::setValue(0, CAN1_TRANSCEIVER_ENABLE_PIN, value); + #endif + } else if(bus->address == 2) { + debug("disable bus 2"); + #if defined(CAN2_TRANSCEIVER_SWITCHED) + GpioValue value = CAN2_TRANSCEIVER_ENABLE_POLARITY ? GPIO_VALUE_LOW : GPIO_VALUE_HIGH; + gpio::setDirection(0, CAN2_TRANSCEIVER_ENABLE_PIN, GPIO_DIRECTION_OUTPUT); + gpio::setValue(0, CAN2_TRANSCEIVER_ENABLE_PIN, value); + #endif + } else { + // TODO an error if the address isn't valid + debug("disable invalid bus - should be error"); + } } /* Called by the Interrupt Service Routine whenever an event we registered for @@ -237,11 +265,24 @@ void openxc::can::initialize(CanBus* bus, bool writable, CanBus* buses, CAN_CONTROLLER(bus)->enableFeature(CAN::WAKEUP_BUS_FILTER, true); // switch ON off-chip CAN line drivers (if necessary) - #if defined(CAN1_TRANSCEIVER_SWITCHED) - GpioValue value = CAN1_TRANSCEIVER_ENABLE_POLARITY ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW; - gpio::setDirection(0, CAN1_TRANSCEIVER_ENABLE_PIN, GPIO_DIRECTION_OUTPUT); - gpio::setValue(0, CAN1_TRANSCEIVER_ENABLE_PIN, value); - #endif + if(bus->address == 1) { + debug("enable bus 1"); + #if defined(CAN1_TRANSCEIVER_SWITCHED) + GpioValue value = CAN1_TRANSCEIVER_ENABLE_POLARITY ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW; + gpio::setDirection(0, CAN1_TRANSCEIVER_ENABLE_PIN, GPIO_DIRECTION_OUTPUT); + gpio::setValue(0, CAN1_TRANSCEIVER_ENABLE_PIN, value); + #endif + } else if(bus->address == 2) { + debug("enable bus 2"); + #if defined(CAN2_TRANSCEIVER_SWITCHED) + GpioValue value = CAN2_TRANSCEIVER_ENABLE_POLARITY ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW; + gpio::setDirection(0, CAN2_TRANSCEIVER_ENABLE_PIN, GPIO_DIRECTION_OUTPUT); + gpio::setValue(0, CAN2_TRANSCEIVER_ENABLE_PIN, value); + #endif + } else { + // TODO an error if the address isn't valid + debug("enable invalid bus - should be error"); + } // move CAN module to OPERATIONAL state (go on bus) CAN::OP_MODE mode; @@ -261,5 +302,5 @@ void openxc::can::initialize(CanBus* bus, bool writable, CanBus* buses, // TODO an error if the address isn't valid CAN_CONTROLLER(bus)->attachInterrupt(bus->address == 1 ? handleCan1Interrupt : handleCan2Interrupt); - debug("Done."); + debug("CAN setup done."); } diff --git a/src/platform/pic32/uart.cpp b/src/platform/pic32/uart.cpp index d439c9397..70d4827e3 100644 --- a/src/platform/pic32/uart.cpp +++ b/src/platform/pic32/uart.cpp @@ -39,11 +39,11 @@ #define UART_STATUS_PORT 0 #define UART_STATUS_PIN 58 // PORTB BIT4 (RB4) #define UART_STATUS_PIN_POLARITY 1 // high == connected -#elif defined(CROSSCHASM_C5_CELLULAR) +#elif defined(CROSSCHASM_C5_BLE) - #define UART_STATUS_PORT - #define UART_STATUS_PIN // PORTB BIT4 (RB4) - #define UART_STATUS_PIN_POLARITY // high == connected + #define UART_STATUS_PORT 0 + #define UART_STATUS_PIN 58 + #define UART_STATUS_PIN_POLARITY 1 // high == connected #elif defined(CHIPKIT) @@ -122,8 +122,6 @@ int openxc::interface::uart::readByte(UartDevice* device) { } void openxc::interface::uart::initialize(UartDevice* device) { -#ifndef UART_LOGGING_DISABLE - if(device == NULL) { debug("Can't initialize a NULL UartDevice"); return; @@ -137,14 +135,12 @@ void openxc::interface::uart::initialize(UartDevice* device) { gpio::setDirection(UART_STATUS_PORT, UART_STATUS_PIN, gpio::GPIO_DIRECTION_INPUT); - debug("Done."); -#endif + debug("UART init Done."); } // The chipKIT version of this function is blocking. It will entirely flush the // send queue before returning. void openxc::interface::uart::processSendQueue(UartDevice* device) { -#ifndef UART_LOGGING_DISABLE int byteCount = 0; char sendBuffer[MAX_MESSAGE_SIZE]; while(!QUEUE_EMPTY(uint8_t, &device->sendQueue) && @@ -156,7 +152,6 @@ void openxc::interface::uart::processSendQueue(UartDevice* device) { ((HardwareSerial*)device->controller)->write((const uint8_t*)sendBuffer, byteCount); } -#endif } bool openxc::interface::uart::connected(UartDevice* device) { @@ -165,7 +160,6 @@ bool openxc::interface::uart::connected(UartDevice* device) { static unsigned int timer; bool status = false; static bool last_status = false; -#ifndef UART_LOGGING_DISABLE #ifdef CHIPKIT // Use analogRead instead of digitalRead so we don't have to require @@ -208,8 +202,6 @@ bool openxc::interface::uart::connected(UartDevice* device) { } last_status = status; -#endif return status; - } diff --git a/src/tests/canread_tests.cpp b/src/tests/canread_tests.cpp index 1f49e399d..cb64dde0f 100644 --- a/src/tests/canread_tests.cpp +++ b/src/tests/canread_tests.cpp @@ -365,15 +365,15 @@ START_TEST (test_translate_many_signals) { getConfiguration()->pipeline.uart = NULL; ck_assert_int_eq(0, SENT_BYTES); - for(int i = 7; i < 23; i++) { + for(int i = 7; i < 19; i++) { can::read::translateSignal(&getSignals()[i], &TEST_MESSAGE, getSignals(), getSignalCount(), &getConfiguration()->pipeline); fail_unless(getSignals()[i].received); } fail_unless(USB_PROCESSED); - // 8 signals sent - ck_assert_int_eq(15 * 34 + 2, SENT_BYTES); - // 6 in the output queue + // 8 signals sent - depends on queue size + ck_assert_int_eq(11 * 34 + 2, SENT_BYTES); + // 1 in the output queue fail_if(queueEmpty()); ck_assert_int_eq(1 * 34, QUEUE_LENGTH(uint8_t, OUTPUT_QUEUE)); } diff --git a/src/tests/runtests.sh b/src/tests/runtests.sh index 4781636b8..7534b340b 100644 --- a/src/tests/runtests.sh +++ b/src/tests/runtests.sh @@ -2,6 +2,7 @@ echo "Running unit tests:" for i in $1/*.bin do + find . -name "*.gcda" -type f -delete if test -f $i then if ./$i diff --git a/src/tests/tests.mk b/src/tests/tests.mk index 2acf61cb4..929e6c851 100644 --- a/src/tests/tests.mk +++ b/src/tests/tests.mk @@ -8,7 +8,7 @@ TEST_OBJDIR = build/$(TEST_DIR) TEST_SRC=$(wildcard $(TEST_DIR)/*_tests.cpp) TESTS=$(patsubst %.cpp,$(TEST_OBJDIR)/%.bin,$(TEST_SRC)) -TEST_LIBS = -lcheck -lrt -lpthread +TEST_LIBS = -lcheck -lrt -lpthread -lsubunit NON_TESTABLE_SRCS = signals.cpp main.cpp hardware_tests_main.cpp diff --git a/src/util/bytebuffer.h b/src/util/bytebuffer.h index 7f4e42e5e..ce6166323 100644 --- a/src/util/bytebuffer.h +++ b/src/util/bytebuffer.h @@ -4,7 +4,7 @@ #include "emqueue.h" #include "commands/commands.h" -QUEUE_DECLARE(uint8_t, 512) +QUEUE_DECLARE(uint8_t, 384) namespace openxc { namespace util { diff --git a/src/vi_firmware.cpp b/src/vi_firmware.cpp index 6ef8f8fe7..53263db32 100644 --- a/src/vi_firmware.cpp +++ b/src/vi_firmware.cpp @@ -198,11 +198,9 @@ void initializeIO() { #ifdef FS_SUPPORT fs::initialize(getConfiguration()->fs); #endif - usb::initialize(&getConfiguration()->usb); - - #ifndef UART_LOGGING_DISABLE + + usb::initialize(&getConfiguration()->usb); uart::initialize(&getConfiguration()->uart); - #endif #ifdef BLE_SUPPORT ble::initialize(getConfiguration()->ble); @@ -212,7 +210,7 @@ void initializeIO() { #endif network::initialize(&getConfiguration()->network); getConfiguration()->runLevel = RunLevel::ALL_IO; - + } void initializeVehicleInterface() {