Skip to content

Commit 564a62c

Browse files
authored
Merge pull request #151 from openxc/multiframe_message_patch
Update base.py
2 parents e1a2cc8 + 9dc7565 commit 564a62c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

openxc/controllers/base.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ def handle_responses(self):
8585
if self._response_matches_request(response):
8686
if type(self) == DiagnosticResponseReceiver:
8787
if self._response_is_multiframe(response):
88-
if response['message_id'] in self.diag_dict:
89-
self.diag_dict[response['message_id']].addFrame(response)
88+
if response['id'] in self.diag_dict:
89+
self.diag_dict[response['id']].addFrame(response)
9090
else:
91-
self.diag_dict[response['message_id']] = MultiframeDiagnosticMessage(response)
91+
self.diag_dict[response['id']] = MultiframeDiagnosticMessage(response)
9292
if self._return_final(response):
93-
self.responses.append(self.diag_dict[response['message_id']].getResponse())
94-
self.diag_dict.pop(response['message_id'])
93+
self.responses.append(self.diag_dict[response['id']].getResponse())
94+
self.diag_dict.pop(response['id'])
9595
self.responses.append(response)
9696
if self.quit_after_first:
9797
self.running = False
@@ -101,7 +101,7 @@ def handle_responses(self):
101101

102102
class MultiframeDiagnosticMessage:
103103
def __init__(self, response):
104-
self.message_id = response['message_id'] - 16
104+
self.id = response['id'] - 16
105105
self.mode = response['mode']
106106
self.bus = response['bus']
107107
self.pid = response['pid']
@@ -114,7 +114,7 @@ def getResponse(self):
114114
request = {
115115
'timestamp': 0,
116116
'bus': self.bus,
117-
'id': self.message_id,
117+
'id': self.id,
118118
'mode': self.mode,
119119
'success': True,
120120
'pid': self.pid,
@@ -222,12 +222,12 @@ def _send_complex_request(self, request):
222222
self.write_bytes(self.streamer.serialize_for_stream(request))
223223

224224
@classmethod
225-
def _build_diagnostic_request(cls, message_id, mode, bus=None, pid=None,
225+
def _build_diagnostic_request(cls, id, mode, bus=None, pid=None,
226226
frequency=None, payload=None, decoded_type=None):
227227
request = {
228228
'command': "diagnostic_request",
229229
'request': {
230-
'id': message_id,
230+
'id': id,
231231
'mode': mode
232232
}
233233
}
@@ -247,19 +247,19 @@ def _build_diagnostic_request(cls, message_id, mode, bus=None, pid=None,
247247

248248
return request
249249

250-
def delete_diagnostic_request(self, message_id, mode, bus=None, pid=None):
251-
request = self._build_diagnostic_request(message_id, mode, bus, pid)
250+
def delete_diagnostic_request(self, id, mode, bus=None, pid=None):
251+
request = self._build_diagnostic_request(id, mode, bus, pid)
252252
request['action'] = 'cancel'
253253
return self._check_command_response_status(request)
254254

255-
def create_diagnostic_request(self, message_id, mode, bus=None, pid=None,
255+
def create_diagnostic_request(self, id, mode, bus=None, pid=None,
256256
frequency=None, payload=None, wait_for_ack=True,
257257
wait_for_first_response=False, decoded_type=None):
258258
"""Send a new diagnostic message request to the VI
259259
260260
Required:
261261
262-
message_id - The message ID (arbitration ID) for the request.
262+
id - The message ID (arbitration ID) for the request.
263263
mode - the diagnostic mode (or service).
264264
265265
Optional:
@@ -287,7 +287,7 @@ def create_diagnostic_request(self, message_id, mode, bus=None, pid=None,
287287
288288
"""
289289

290-
request = self._build_diagnostic_request(message_id, mode, bus, pid,
290+
request = self._build_diagnostic_request(id, mode, bus, pid,
291291
frequency, payload, decoded_type)
292292

293293
diag_response_receiver = None
@@ -453,15 +453,15 @@ def write_translated(self, name, value, event=None):
453453
assert bytes_written == len(message)
454454
return bytes_written
455455

456-
def write_raw(self, message_id, data, bus=None, frame_format=None):
456+
def write_raw(self, id, data, bus=None, frame_format=None):
457457
"""Send a raw write request to the VI.
458458
"""
459-
if not isinstance(message_id, numbers.Number):
459+
if not isinstance(id, numbers.Number):
460460
try:
461-
message_id = int(message_id, 0)
461+
id = int(id, 0)
462462
except ValueError:
463463
raise ValueError("ID must be numerical")
464-
data = {'id': message_id, 'data': data}
464+
data = {'id': id, 'data': data}
465465
if bus is not None:
466466
data['bus'] = bus
467467
if frame_format is not None:

0 commit comments

Comments
 (0)