Testing

Windows USB Device Driver

If you want to send and receive vehicle data in Windows via USB, you must install the VI Windows Driver.

Python Library

The OpenXC Python library, in particular the openxc-dashboard tool, is useful for testing a VI. A quick “smoke test” using the Python tools is described in the Getting Started Guide for Python developers at the OpenXC website.

Keep in mind when bench testing that the VI will suspend if no CAN bus activity is detected. Compiled with DEFAULT_POWER_MANAGEMENT=ALWAYS_ON to stop this behavior, but don’t leave it plugged into your car with power management off.

Debugging

To view debugging information, first compile the firmware with the debugging flag:

$ make clean
$ DEBUG=1 make
$ make flash

When compiled with DEBUG=1, two things happen:

  • Debug symbols are available in the .elf file generated in the build directory.
  • Log messages will be output over a separate USB endpoint required) - see I/O, Data Format and Commands for details. You can optionally enable logging via UART with the DEFAULT_LOGGING_OUTPUT config option, but there may be a performance hit - see the Makefile Options.

To view the logs via USB, you can use the --log-mode flag with the Python CLI tools. See the --help text for any of those tools for more information.

To view UART logs, you can use an FTDI cable and any of the many available serial terminal monitoring programs, e.g. screen, minicom, etc. The pins for this UART output are different for each board, so see the platform specific docs.

Test Suite

The non-embedded platform specific code in this repository includes a unit test suite. It’s a good idea to run the test suite before committing any changes to the git repository.

The test suite uses the check library. It should already be installed if you used bootstrap.sh to set up your development environment.

Running the Suite

vi-firmware/src $ make clean && make test

Functional Test Suite

For a complete functional test of the firmware code on the support hardware platforms, the repository includes an automated script to program a VI and run a self-test. The VIs are configured to self-receive every CAN message they send, allowing the complete firmware stack to be tested without any physical CAN configuration. The test script is written in Python and uses the OpenXC Python library send commands to the VI, read responses and receive the test vehicle data.

The functional test suite is currently supported on the:

  • Ford Reference VI
  • chipKIT VI

Running the Suite

MAke sure you have the following connected to your development machine:

  • Reference VI via USB
  • USB JTAG programming connected to the refernece VI
  • chipKIT micro-USB (for OpenXC interface)
  • chipKIT mini-USB (for programming)

Then run the automated functional test suite:

vi-firmware/ $ fab auto_functional_test

which will program each of the VIs and run the tests on them independently. The process takes a couple of minutes.