Skip to content

Commit 127f753

Browse files
committed
Merge remote-tracking branch 'origin/next' into get-vin-heartbeat
2 parents 88f307a + 1339794 commit 127f753

16 files changed

Lines changed: 663 additions & 461 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
twine upload dist/*

.github/workflows/python-test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Test Open XC Pyton
5+
6+
on: [ pull_request ]
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.6.7]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install dependencies
23+
run: |
24+
sudo apt-get install python-bluetooth -qq -y
25+
python -m pip install --upgrade pip
26+
python -m pip install pytest pyserial==3.1.1 coveralls
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
29+
- name: Test
30+
run: |
31+
python setup.py test
32+

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
OpenXC Python Library Changelog
22
===============================
33

4+
v2.1.0
5+
----------
6+
* SonarQube integration
7+
* Fix: Modem configuration for c5 cellar build now properly sets baud rate
8+
* Fix: Protobuf general improvements
9+
* Keyboard interupt via <ctrl>c added to openxc-dump and Obd2 Scanner
10+
* Stitching Feature, large messages are now packaged and sent in smaller chunks from the vi
11+
412
v2.0.0
513
----------
614
* Known Issue: OpenXC python must be used with firmware 8.0.0 or greater.

README.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ OpenXC for Python
44

55
.. image:: https://github.com/openxc/openxc-python/raw/master/docs/_static/logo.png
66

7-
:Version: 2.0.0
7+
:Version: 2.1.0
88
:Web: http://openxcplatform.com
99
:Download: http://pypi.python.org/pypi/openxc/
1010
:Documentation: http://python.openxcplatform.com
1111
:Source: http://github.com/openxc/openxc-python/
1212
:Keywords: vehicle, openxc, python
1313

14-
.. image:: https://travis-ci.org/openxc/openxc-python.svg?branch=master
15-
:target: https://travis-ci.org/openxc/openxc-python
14+
.. image:: https://github.com/openxc/openxc-python/workflows/Test%20Open%20XC%20Pyton/badge.svg
15+
:target: https://github.com/openxc/openxc-python/actions?query=workflow%3A%22Test+Open+XC+Pyton%22
1616

1717
.. image:: https://coveralls.io/repos/openxc/openxc-python/badge.png?branch=master
1818
:target: https://coveralls.io/r/openxc/openxc-python?branch=master
@@ -30,7 +30,10 @@ In addition to a port of the Android library API, the package also contains a
3030
number of command-line tools for connecting to the CAN translator and
3131
manipulating previously recorded vehicle data.
3232

33+
If you are getting the error "ValueError: No backend available" on windows please reinstall your libusb0 driver using https://github.com/openxc/vi-windows-driver if you are in a envirment where you can not use an unsigned driver please use https://zadig.akeo.ie/
34+
3335
Due to changes in signals.cpp openxc-python Version 2.0.0 must be used with vi-firmware 8.0.0 or greater.
36+
Due to changes with large diagnostic responses Version 2.1.0 must be used with vi-firmware 8.1.0 or greater.
3437

3538
To package run "setup.py sdist bdist_wheel"
3639
to push to pypi run "python -m twine upload dist/\*"
@@ -44,6 +47,6 @@ Version files:
4447
License
4548
========
4649

47-
Copyright (c) 2012-2017 Ford Motor Company
50+
Copyright (c) 2012-2020 Ford Motor Company
4851

4952
Licensed under the BSD license.

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OpenXC for Python
44

55
.. image:: https://github.com/openxc/openxc-python/raw/master/docs/_static/logo.png
66

7-
:Version: 2.0.0
7+
:Version: 2.1.0
88
:Web: http://openxcplatform.com
99
:Download: http://pypi.python.org/pypi/openxc/
1010
:Documentation: http://python.openxcplatform.com

openxc/controllers/base.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,17 @@ def handle_responses(self):
8383
response = self.queue.get(
8484
timeout=self.COMMAND_RESPONSE_TIMEOUT_S)
8585
if self._response_matches_request(response):
86-
if type(self) == DiagnosticResponseReceiver:
87-
if self._response_is_multiframe(response):
88-
if response['message_id'] in self.diag_dict:
89-
self.diag_dict[response['message_id']].addFrame(response)
86+
if type(self) == DiagnosticResponseReceiver and self._response_is_multiframe(response):
87+
if response['id'] in self.diag_dict:
88+
self.diag_dict[response['id']].addFrame(response)
9089
else:
91-
self.diag_dict[response['message_id']] = MultiframeDiagnosticMessage(response)
90+
self.diag_dict[response['id']] = MultiframeDiagnosticMessage(response)
9291
if self._return_final(response):
93-
self.responses.append(self.diag_dict[response['message_id']].getResponse())
94-
self.diag_dict.pop(response['message_id'])
92+
save = self.responses.pop()
93+
dentry = self.diag_dict[response['id']].getResponse() # DO NOT REMOVE This MUST be saved to a local variable to prevent deallocation
94+
self.responses.append(dentry) # DO NOT REMOVE This MUST be saved to a local variable to prevent deallocation
95+
self.responses.append(save)
96+
self.diag_dict.pop(response['id'])
9597
self.responses.append(response)
9698
if self.quit_after_first:
9799
self.running = False
@@ -101,20 +103,20 @@ def handle_responses(self):
101103

102104
class MultiframeDiagnosticMessage:
103105
def __init__(self, response):
104-
self.message_id = response['message_id'] - 16
106+
self.id = response['id']
105107
self.mode = response['mode']
106108
self.bus = response['bus']
107109
self.pid = response['pid']
108110
self.payload = '0x' + response['payload'][8:]
109111

110112
def addFrame(self, response):
111-
self.payload += response['payload'][8:]
113+
self.payload += response['payload'][2:]
112114

113115
def getResponse(self):
114116
request = {
115117
'timestamp': 0,
116118
'bus': self.bus,
117-
'id': self.message_id,
119+
'id': self.id,
118120
'mode': self.mode,
119121
'success': True,
120122
'pid': self.pid,
@@ -170,8 +172,9 @@ def _response_matches_request(self, response):
170172
return response.get('mode', None) == self.diagnostic_request['mode']
171173

172174
def _response_is_multiframe(self, response):
173-
if 'frame' in response:
174-
return True
175+
print(response)
176+
if 'total_size' in response.keys() and response["total_size"] > 0:
177+
return True
175178
return False
176179

177180
def _return_final(self, response):
@@ -222,12 +225,12 @@ def _send_complex_request(self, request):
222225
self.write_bytes(self.streamer.serialize_for_stream(request))
223226

224227
@classmethod
225-
def _build_diagnostic_request(cls, message_id, mode, bus=None, pid=None,
228+
def _build_diagnostic_request(cls, id, mode, bus=None, pid=None,
226229
frequency=None, payload=None, decoded_type=None):
227230
request = {
228231
'command': "diagnostic_request",
229232
'request': {
230-
'id': message_id,
233+
'id': id,
231234
'mode': mode
232235
}
233236
}
@@ -247,19 +250,19 @@ def _build_diagnostic_request(cls, message_id, mode, bus=None, pid=None,
247250

248251
return request
249252

250-
def delete_diagnostic_request(self, message_id, mode, bus=None, pid=None):
251-
request = self._build_diagnostic_request(message_id, mode, bus, pid)
253+
def delete_diagnostic_request(self, id, mode, bus=None, pid=None):
254+
request = self._build_diagnostic_request(id, mode, bus, pid)
252255
request['action'] = 'cancel'
253256
return self._check_command_response_status(request)
254257

255-
def create_diagnostic_request(self, message_id, mode, bus=None, pid=None,
258+
def create_diagnostic_request(self, id, mode, bus=None, pid=None,
256259
frequency=None, payload=None, wait_for_ack=True,
257260
wait_for_first_response=False, decoded_type=None):
258261
"""Send a new diagnostic message request to the VI
259262
260263
Required:
261264
262-
message_id - The message ID (arbitration ID) for the request.
265+
id - The message ID (arbitration ID) for the request.
263266
mode - the diagnostic mode (or service).
264267
265268
Optional:
@@ -287,7 +290,7 @@ def create_diagnostic_request(self, message_id, mode, bus=None, pid=None,
287290
288291
"""
289292

290-
request = self._build_diagnostic_request(message_id, mode, bus, pid,
293+
request = self._build_diagnostic_request(id, mode, bus, pid,
291294
frequency, payload, decoded_type)
292295

293296
diag_response_receiver = None
@@ -461,15 +464,15 @@ def write_translated(self, name, value, event=None):
461464
assert bytes_written == len(message)
462465
return bytes_written
463466

464-
def write_raw(self, message_id, data, bus=None, frame_format=None):
467+
def write_raw(self, id, data, bus=None, frame_format=None):
465468
"""Send a raw write request to the VI.
466469
"""
467-
if not isinstance(message_id, numbers.Number):
470+
if not isinstance(id, numbers.Number):
468471
try:
469-
message_id = int(message_id, 0)
472+
id = int(id, 0)
470473
except ValueError:
471474
raise ValueError("ID must be numerical")
472-
data = {'id': message_id, 'data': data}
475+
data = {'id': id, 'data': data}
473476
if bus is not None:
474477
data['bus'] = bus
475478
if frame_format is not None:

openxc/formats/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ class VehicleMessageStreamer(object):
33
bytes_received = 0
44

55
def receive(self, payload):
6-
if not isinstance(payload, bytes):
7-
payload = payload.encode("utf-8")
86
if len(payload) > 0:
97
self.message_buffer += payload
108
self.bytes_received += len(payload)

0 commit comments

Comments
 (0)