Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diag response, doc updates, platform command, -py2.6 #96

Merged
merged 15 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
language: python
python:
- "2.6"
- "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get install python-bluetooth -qq -y
- if [[ $TRAVIS_PYTHON_VERSION = '2.6' ]]; then pip install importlib; fi
- pip install pyserial
- pip install pyserial==3.1.1
- pip install coveralls
install: pip install -q -e .
script: python setup.py test
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
OpenXC Python Library Changelog
===============================

v0.14.0-dev
----------

* Fix: Remove support for Python 2.6
* Fix: Diagnostic response cleanup
* Feature: Add "platform" command support
* Fix: Documentation improvements
* Fix: openxc-dump command file access

v0.13.0
----------

Expand Down
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OpenXC for Python

.. image:: /docs/_static/logo.png

:Version: 0.13.0
:Version: 0.14.0-dev
:Web: http://openxcplatform.com
:Download: http://pypi.python.org/pypi/openxc/
:Documentation: http://python.openxcplatform.com
Expand All @@ -21,7 +21,7 @@ OpenXC for Python
:target: http://python.openxcplatform.com
:alt: Documentation Status

The OpenXC Python library (for Python 2.6 or 2.7) provides an interface to
The OpenXC Python library (for Python 2.7) provides an interface to
vehicle data from the OpenXC Platform. The primary platform for OpenXC
applications is Android, but for prototyping and testing, often it is
preferrable to use a low-overhead environment like Python when developing.
Expand All @@ -30,9 +30,10 @@ In addition to a port of the Android library API, the package also contains a
number of command-line tools for connecting to the CAN translator and
manipulating previously recorded vehicle data.


License
=======

Copyright (c) 2012-2014 Ford Motor Company
Copyright (c) 2012-2017 Ford Motor Company

Licensed under the BSD license.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# General information about the project.
project = u'OpenXC for Python'
copyright = u'2014, Ford Motor Company'
copyright = u'2017, 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
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OpenXC for Python
:Documentation: http://python.openxcplatform.com
:Source: http://github.com/openxc/openxc-python/

The OpenXC Python library (for Python 2.6 or 2.7) provides an interface to
The OpenXC Python library (for Python 2.7) provides an interface to
vehicle data from the OpenXC Platform. The primary platform for OpenXC
applications is Android, but for prototyping and testing, often it is
preferrable to use a low-overhead environment like Python when developing.
Expand All @@ -19,7 +19,7 @@ In addition to a port of the Android library API, the package also contains a
number of command-line tools for connecting to the vehicle interface and
manipulating previously recorded vehicle data.

This Python package works with Python 2.6 and 2.7. Unfortunately we had to drop
This Python package works with Python 2.7. Unfortunately we had to drop
support for Python 3 when we added the protobuf library as a dependency.

For general documentation on the OpenXC platform, visit the main `OpenXC site`_.
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Install Python and Pip
----------------------

This library (obviously) requires a Python language runtime - the OpenXC library
currently works with Python 2.6 and 2.7, but not Python 3.x.
currently works with Python 2.7, but not Python 3.x.

- **Mac OS X and Linux**

Expand Down
2 changes: 1 addition & 1 deletion docs/tools/codegen.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=============================================
Vehicle Interface Firmware Configuration Tool
``openxc-generate-firmware-code`` - configure CAN messages, signals and buses
=============================================

The `OpenXC vehicle interface
Expand Down
27 changes: 22 additions & 5 deletions docs/tools/control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ Basic use
version
--------

Print the current firmware version and vehicle platform of the attached CAN
Print the current firmware version and firmware description of the attached CAN
translator:

.. code-block:: bash

$ openxc-control version

An example response is ``v7.2.1 (default)``, where the ``default`` firmware
description can be modified in the JSON file via the ``"name"`` entry.
The first example in `Low-level CAN Features <http://vi-firmware.openxcplatform.com/en/master/advanced/lowlevel.html>`_
would return a value of ``passthrough``.

---
id
---
Expand All @@ -30,6 +35,18 @@ the Bluetooth module.

$ openxc-control id

---------
platform
---------

Print the hardware platform of the vehicle interface.

.. code-block:: bash

$ openxc-control platform

Supported platforms include ``CHIPKIT``, ``BLUEBOARD``, ``FORDBOARD``, ``CROSSCHASM_C5``, ``CROSSCHASM_C5_BT``, ``CROSSCHASM_C5_BLE``, and ``CROSSCHASM_C5_CELLULAR``

---
set
---
Expand Down Expand Up @@ -70,9 +87,9 @@ Set the host and port for the C5 Cellular device

.. code-block:: bash

$ openxc-control set --host www.server.com --port 80
$ openxc-control set --network-host www.server.com --port 80

This will return true when successful. If host is supplied, but not port,
This will return true when successful. If network-host is supplied, but not port,
port will default to 80.

------
Expand Down Expand Up @@ -116,11 +133,11 @@ a message with a lower ID using the extended frame format, you can use the
sd_mount_status
---------------

This queries the device to see if the SD card is mounted correctly.
This queries the device to see if the SD card is mounted correctly.

.. code-block:: bash

$ openxc-control sd_mount_status
$ openxc-control sd_mount_status

This will return 'True' if the SD card is available for writing. Otherwise, it will return 'False'.

Expand Down
8 changes: 4 additions & 4 deletions docs/tools/diag.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Perform a single diagnostic request

This example will add a new one-time diagnostic request - it will be sent
once, and any respones will be printed to the terminal via stdout. The
``--message-id`` and ``--mode`` options are required. This particular request
``--message`` and ``--mode`` options are required. This particular request
sends a functional broadcast request (ID ``0x7df``) for the mode 3 service, to
store a "freeze frame". See the Unified Diagnostics Service and On-Board
Diagnostics standards for more information on valid modes.
Expand All @@ -20,7 +20,7 @@ bus if one is not specified.

.. code-block:: bash

$ openxc-diag add --message-id 0x7df --mode 0x3
$ openxc-diag add --message 0x7df --mode 0x3

.. note::

Expand All @@ -37,7 +37,7 @@ responses.

.. code-block:: bash

$ openxc-diag add --message-id 0x7df --mode 0x1 --pid 0xc --frequency 1
$ openxc-diag add --message 0x7df --mode 0x1 --pid 0xc --frequency 1

Cancel an existing recurring diagnostic request
===============================================
Expand All @@ -48,7 +48,7 @@ and PID to identify a request.

.. code-block:: bash

$ openxc-diag cancel --message-id 0x7df --mode 0x1 --pid 0xc
$ openxc-diag cancel --message 0x7df --mode 0x1 --pid 0xc

Cancelling a non-recurring diagnostic request
=========================================================
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/scanner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you wish to scan only a single message ID, you can skip right to it:

.. code-block:: bash

$ openxc-scanner --message-id 0x7e0
$ openxc-scanner --message 0x7e0

Command-line options
====================
Expand Down
1 change: 1 addition & 0 deletions docs/tools/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ explicitly set the protocol buffers:

$ openxc-control set --bus 1 --passthrough --format protobuf

The following links describe the available openxc-python commands.

.. toctree::
:maxdepth: 1
Expand Down
8 changes: 8 additions & 0 deletions openxc/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ def version(self):
"command": "version"
}
return self._check_command_response_message(request)

def platform(self):
"""Request the VI platform.
"""
request = {
"command": "platform"
}
return self._check_command_response_message(request)

def sd_mount_status(self):
"""Request for SD Mount status if available.
Expand Down
2 changes: 1 addition & 1 deletion openxc/sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __init__(self, source, mode="off"):
if self.mode == "file":
filename = "openxc-logs-%s.txt" % datetime.datetime.now().strftime(
self.FILENAME_TEMPLATE)
self.file = open(filename, 'wa')
self.file = open(filename, 'w')

def stop(self):
self.running = False
Expand Down
7 changes: 6 additions & 1 deletion openxc/tools/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

def version(interface):
print("Device is running version %s" % interface.version())

def platform(interface):
print("Device is a %s" % interface.platform())

def sd_mount_status(interface):
result = interface.sd_mount_status()
Expand Down Expand Up @@ -90,7 +93,7 @@ def parse_options():
parser = argparse.ArgumentParser(description="Send control messages to an "
"attached OpenXC vehicle interface", parents=[device_options()])
parser.add_argument("command", type=str,
choices=['version', 'write', 'id', 'set', 'sd_mount_status'])
choices=['version', 'platform', 'write', 'id', 'set', 'sd_mount_status'])
write_group = parser.add_mutually_exclusive_group()
write_group.add_argument("--name", action="store", dest="write_name",
help="name for message write request")
Expand Down Expand Up @@ -141,6 +144,8 @@ def main():

if arguments.command == "version":
version(interface)
elif arguments.command == "platform":
platform(interface)
elif arguments.command == "sd_mount_status":
sd_mount_status(interface)
elif arguments.command == "id":
Expand Down
18 changes: 16 additions & 2 deletions openxc/tools/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,22 @@ def diagnostic_request(arguments, controller):
wait_for_first_response=True)
if len(responses) == 0:
print("No response received before timeout")
for response in responses:
print("Response: %s" % response)
else:
for response in responses:
# After sending a diagnostic request, it will return with a signal message saying if the
# request was recieved. After that it used to show about 30 vehicle messages (rpm, speed, etc)
# with the actual diagnostic response mixed in. So, if the response length is more than
# 1, it's the response, if its less (only 1) it's the recieved message.
if len(response) > 1:
# Stripping all of the unnesseary data we get after sending a diag request in python
# Just like in enabler, it's a diag response if it contains the keys "mode", "bus",
# "id", and "success".
diagMsgReqKeys = ['mode', 'bus', 'id', 'success']
indices = [i for i, s in enumerate(response) if all(x in s for x in diagMsgReqKeys)]
if indices:
print("Response: %s" % response[indices[0]])
else:
print("Response: %s" % response)
elif arguments.command == "cancel":
if controller.delete_diagnostic_request(message, mode, bus=bus,
pid=pid):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
tests_require=['nose'],
install_requires=install_reqs,
extras_require = {
'serial': ["pyserial"],
'serial': ["pyserial==3.1.1"],
'bluetooth': ["pybluez"],
'lxml': ["lxml"],
},
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py26, py27
envlist = py27

[testenv]
commands = {envpython} setup.py test