From e0304c3209ac8eb3e75cf0ad5f7afdd6612d28e3 Mon Sep 17 00:00:00 2001 From: Ion Mironov <97184530+ion-mironov@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:47:27 -0500 Subject: [PATCH 1/8] Several spelling and grammatical fixes. --- docs/Command Lookup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 0c9abbc4ca9c2aa685e324b383400f47bcf11b34 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Wed, 5 Feb 2025 22:07:37 -0500 Subject: [PATCH 2/8] Fix escaped serial port label string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this fix, Python 3.13.1 yields this warning during "import odb": …/obd/utils.py:177: SyntaxWarning: invalid escape sequence '\C' I'm not a Windows expert, but the correct naming convention seems to be described here: https://support.microsoft.com/en-us/topic/howto-specify-serial-ports-larger-than-com9-db9078a5-b7b6-bf00-240f-f749ebfd913e --- obd/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = [ From a47d791de1884da167a4bb51f6c576dc07019a9a Mon Sep 17 00:00:00 2001 From: Ion Mironov <97184530+ion-mironov@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:02:27 -0500 Subject: [PATCH 3/8] Included note mentioning which OBD it will work with. --- docs/index.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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.
From 0c019019fddfae2435209fbf8b3d2c53483647a6 Mon Sep 17 00:00:00 2001 From: Brendan Whitfield Date: Sun, 6 Apr 2025 20:24:33 -0700 Subject: [PATCH 4/8] Uprev pint to 0.24.* for python 3.13+ support --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a5e30300..ac3274c0 100644 --- a/setup.py +++ b/setup.py @@ -30,5 +30,5 @@ packages=find_packages(), include_package_data=True, zip_safe=False, - install_requires=["pyserial==3.*", "pint==0.20.*"], + install_requires=["pyserial==3.*", "pint==0.24.*"], ) From c30cfc3511122f7519582559805d2e87c677dba5 Mon Sep 17 00:00:00 2001 From: Brendan Whitfield Date: Sun, 6 Apr 2025 21:00:20 -0700 Subject: [PATCH 5/8] Uprev tox.ini to test python 3.13 Also corrected some of the package classifiers to indicate that this python library no longer supports python 2. It didn't even with the older 0.20.* Pint, though Pint itself now only supports python 3.9+ --- setup.py | 6 +++++- tox.ini | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index ac3274c0..f16a0232 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,12 @@ "Operating System :: POSIX :: Linux", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Topic :: System :: Monitoring", - "Programming Language :: Python :: 2", "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", 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 From 630f0be2709d6ddba6c2a215d05f9b4024db4a21 Mon Sep 17 00:00:00 2001 From: Brendan Whitfield Date: Sun, 6 Apr 2025 21:20:42 -0700 Subject: [PATCH 6/8] setup.py -> pyproject.toml --- pyproject.toml | 36 ++++++++++++++++++++++++++++++++++++ setup.py | 38 -------------------------------------- 2 files changed, 36 insertions(+), 38 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..2a89a0a7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[project] +name = "obd" +version = "0.7.2" +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 f16a0232..00000000 --- a/setup.py +++ /dev/null @@ -1,38 +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 :: 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", - 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.24.*"], -) From 3d1beba44f7202f1bd3c6dd7a2deaf3dcd21cee6 Mon Sep 17 00:00:00 2001 From: Brendan Whitfield Date: Sun, 6 Apr 2025 21:44:37 -0700 Subject: [PATCH 7/8] Updated the testing docs with modern build commands --- tests/README.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) 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 From b53cbcbf9e6252461e276d73a7ff75adb714dc53 Mon Sep 17 00:00:00 2001 From: Brendan Whitfield Date: Sun, 6 Apr 2025 22:12:25 -0700 Subject: [PATCH 8/8] bumped to 0.7.3 --- obd/__version__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/pyproject.toml b/pyproject.toml index 2a89a0a7..f91d6e3f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "obd" -version = "0.7.2" +version = "0.7.3" authors = [ { name="Brendan Whitfield", email="me@brendan-w.com" }, { name="Alistair Francis", email="alistair@alistair23.me" },