diff --git a/docs/Command Lookup.md b/docs/Command Lookup.md index 1610657d..f87ea39a 100644 --- a/docs/Command Lookup.md +++ b/docs/Command Lookup.md @@ -1,6 +1,6 @@ # Command Lookup -`OBDCommand`s are objects used to query information from the vehicle. They contain all of the information neccessary to perform the query, and decode the cars response. Python-OBD has [built in tables](Command Tables.md) for the most common commands. They can be looked up by name, or by mode & PID. +`OBDCommand`s are objects used to query information from the vehicle. They contain all of the information necessary to perform the query and decode the car's response. Python-OBD has [built in tables](Command Tables.md) for the most common commands. They can be looked up by name or by mode & PID. ```python import obd diff --git a/docs/index.md b/docs/index.md index 3d2c1e69..890ffd1a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,8 @@ # Welcome -Python-OBD is a library for handling data from a car's [**O**n-**B**oard **D**iagnostics port](https://en.wikipedia.org/wiki/On-board_diagnostics) (OBD-II). It can stream real time sensor data, perform diagnostics (such as reading check-engine codes), and is fit for the Raspberry Pi. This library is designed to work with standard [ELM327 OBD-II adapters](http://www.amazon.com/s/ref=nb_sb_noss?field-keywords=elm327). +Python-OBD is a library for handling data from a car's [**O**n-**B**oard **D**iagnostics](https://en.wikipedia.org/wiki/On-board_diagnostics) port. Please keep in mind that the car **must** have OBD-II (any car made in 1996 and up); this will _**not**_ work with OBD-I. + +Python-OBD can stream real time sensor data, perform diagnostics (such as reading check-engine codes), and is fit for the Raspberry Pi. This library is designed to work with standard [ELM327 OBD-II adapters](http://www.amazon.com/s/ref=nb_sb_noss?field-keywords=elm327). *NOTE: Python-OBD is below 1.0.0, meaning the API may change between minor versions. Consult the [GitHub release page](https://github.com/brendan-w/python-OBD/releases) for changelogs before updating.* @@ -31,13 +33,13 @@ connection = obd.OBD() # auto-connects to USB or RF port cmd = obd.commands.SPEED # select an OBD command (sensor) -response = connection.query(cmd) # send the command, and parse the response +response = connection.query(cmd) # send the command and parse the response print(response.value) # returns unit-bearing values thanks to Pint print(response.value.to("mph")) # user-friendly unit conversions ``` -OBD connections operate in a request-reply fashion. To retrieve data from the car, you must send commands that query for the data you want (e.g. RPM, Vehicle speed, etc). In python-OBD, this is done with the `query()` function. The commands themselves are represented as objects, and can be looked up by name or value in `obd.commands`. The `query()` function will return a response object with parsed data in its `value` property. +OBD connections operate in a request-reply fashion. To retrieve data from the car, you must send commands that query for the data you want (e.g. RPM, Vehicle speed, etc). In python-OBD this is done with the `query()` function. The commands themselves are represented as objects and can be looked up by name or value in `obd.commands`. The `query()` function will return a response object with parsed data in its `value` property.
diff --git a/obd/__version__.py b/obd/__version__.py index fb9b668f..1ef13195 100644 --- a/obd/__version__.py +++ b/obd/__version__.py @@ -1 +1 @@ -__version__ = '0.7.2' +__version__ = '0.7.3' diff --git a/obd/utils.py b/obd/utils.py index 77cb36e2..221d3e9c 100644 --- a/obd/utils.py +++ b/obd/utils.py @@ -174,7 +174,7 @@ def scan_serial(): possible_ports += glob.glob("/dev/ttyUSB[0-9]*") elif sys.platform.startswith('win'): - possible_ports += ["\\.\COM%d" % i for i in range(256)] + possible_ports += [r"\\.\COM%d" % i for i in range(256)] elif sys.platform.startswith('darwin'): exclude = [ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..f91d6e3f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[project] +name = "obd" +version = "0.7.3" +authors = [ + { name="Brendan Whitfield", email="me@brendan-w.com" }, + { name="Alistair Francis", email="alistair@alistair23.me" }, + { name="Paul Bartek" }, + { name="Peter Harris" }, +] +description = "Serial module for handling live sensor data from a vehicle's OBD-II port" +readme = "README.md" +requires-python = ">=3.9" +classifiers = [ + "Operating System :: POSIX :: Linux", + "Topic :: System :: Monitoring", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Development Status :: 3 - Alpha", + "Topic :: System :: Logging", + "Intended Audience :: Developers", +] +keywords = ["obd", "obdii", "obd-ii", "obd2", "car", "serial", "vehicle", "diagnostic"] +dependencies = [ + "pyserial==3.*", + "pint==0.24.*", +] +license = "GPL-2.0-only" +license-files = ["LICENSE"] + +[project.urls] +Homepage = "https://github.com/brendan-w/python-OBD" +Issues = "https://github.com/brendan-w/python-OBD/issues" diff --git a/setup.py b/setup.py deleted file mode 100644 index a5e30300..00000000 --- a/setup.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/env python -# -*- coding: utf-8 -*- - -from setuptools import setup, find_packages - -with open("README.md", "r") as readme: - long_description = readme.read() - -setup( - name="obd", - version="0.7.2", - description=("Serial module for handling live sensor data from a vehicle's OBD-II port"), - long_description=long_description, - long_description_content_type="text/markdown", - classifiers=[ - "Operating System :: POSIX :: Linux", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Topic :: System :: Monitoring", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - "Development Status :: 3 - Alpha", - "Topic :: System :: Logging", - "Intended Audience :: Developers", - ], - keywords="obd obdii obd-ii obd2 car serial vehicle diagnostic", - author="Brendan Whitfield", - author_email="brendanw@windworksdesign.com", - url="http://github.com/brendan-w/python-OBD", - license="GNU GPLv2", - packages=find_packages(), - include_package_data=True, - zip_safe=False, - install_requires=["pyserial==3.*", "pint==0.20.*"], -) diff --git a/tests/README.md b/tests/README.md index 2ecfa72e..5f9c4573 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,10 +1,34 @@ Testing ======= -To test python-OBD, you will need to `pip install pytest` and install the module (preferably in a virtualenv) by running `python setup.py install`. The end-to-end tests will also require [obdsim](http://icculus.org/obdgpslogger/obdsim.html) to be running in the background. When starting obdsim, note the "SimPort name" that it creates, and pass it as an argument to py.test. +To test python-OBD, you will need to install `pytest` and the `obd` module from your local tree (preferably in a virtualenv) by running: -To run all tests, run the following command: +```bash +pip install pytest +pip install build +python -m build +pip install ./dist/obd-0.7.2.tar.gz +``` - $ py.test --port=/dev/pts/ +To run all basic python-only unit tests, run: + +```bash +py.test +``` + +This directory also contains a set of end-to-end tests that require [obdsim](http://icculus.org/obdgpslogger/obdsim.html) to be running in the background. These tests are skipped by default, but can be activated by passing the `--port` flag. + +- Download `obdgpslogger`: https://icculus.org/obdgpslogger/downloads/obdgpslogger-0.16.tar.gz +- Run the following build commands: + ```bash + mkdir build + cd build + cmake .. + make obdsim + ``` +- Start `./bin/obdsim`, note the `SimPort name: /dev/pts/` that it creates. Pass this pseudoterminal path as an argument to py.test: + ```bash + py.test --port=/dev/pts/ + ``` For more information on pytest with virtualenvs, [read more here](https://pytest.org/dev/goodpractises.html) \ No newline at end of file diff --git a/tox.ini b/tox.ini index 20476082..6fe55f43 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,15 @@ [tox] envlist = - py{38,39,310,311}, + py{39,310,311,312,313}, coverage [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 + 3.13: py313 [testenv] usedevelop = true