Skip to content

Commit 2054c3d

Browse files
authored
Merge pull request #136 from openxc/next
Next
2 parents 9a033e5 + 509ac36 commit 2054c3d

22 files changed

+411
-87
lines changed

CHANGELOG.rst

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

4+
v2.0.0
5+
----------
6+
* Known Issue: OpenXC python must be used with firmware 8.0.0 or greater.
7+
* Feature: openxc-generate-firmware-code generator now generates signals.cpp in a more memory efficent way.
8+
* Feature: Add dashboard on message change highlighting.
9+
* Feature: Add column sorting and filtering on dashboard.
10+
* Feature: Add more verbosity to libusb errors.
11+
* Fix: Fix more python 3 migration byte bugs.
12+
413
v1.1.1
514
----------
615
* Fix: Fixed Pip included files

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ include LICENSE
44
include openxc/generator/signals.cpp.footer
55
include openxc/generator/signals.cpp.header
66
include openxc/tools/templates/dashboard.html
7+
include openxc/tools/static/css/dashboard.css
8+
include openxc/tools/static/js/jquery-3.4.1.min.js
9+
include openxc/tools/static/js/dashboard.js
10+
include openxc/tools/static/js/socket.io.slim.js
11+
include openxc/tools/static/js/jquery.color-2.1.2.min.js

README.rst

Lines changed: 3 additions & 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: 1.1.1
7+
:Version: 2.0.0
88
:Web: http://openxcplatform.com
99
:Download: http://pypi.python.org/pypi/openxc/
1010
:Documentation: http://python.openxcplatform.com
@@ -30,6 +30,8 @@ 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+
Due to changes in signals.cpp openxc-python Version 2.0.0 must be used with vi-firmware 8.0.0 or greater.
34+
3335
To package run "setup.py sdist bdist_wheel"
3436
to push to pypi run "python -m twine upload dist/\*"
3537
Version files:

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: 1.1.1
7+
:Version: 2.0.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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ResponseReceiver(object):
2828
of ResponseReceivers as they arrive.
2929
"""
3030

31-
COMMAND_RESPONSE_TIMEOUT_S = .5
31+
COMMAND_RESPONSE_TIMEOUT_S = 0.5
3232

3333
def __init__(self, queue, request, quit_after_first=True):
3434
"""Construct a new ResponseReceiver.

openxc/generator/coder.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def build_source(self):
3232
lines.extend(self._build_messages())
3333
lines.extend(self._build_signal_states())
3434
lines.extend(self._build_signals())
35+
lines.extend(self._build_signal_managers())
3536
lines.extend(self._build_initializers())
3637
lines.extend(self._build_loop())
3738
lines.extend(self._build_commands())
@@ -231,20 +232,45 @@ def _build_signals(self):
231232
lines = []
232233
lines.append("const int MAX_SIGNAL_COUNT = %d;" %
233234
self._max_signal_count())
234-
lines.append("CanSignal SIGNALS[][MAX_SIGNAL_COUNT] = {")
235+
lines.append("const CanSignal SIGNALS[][MAX_SIGNAL_COUNT] __attribute__ ((section(\".rodata._ZL7SIGNALS\"))) = {")
235236

236237
def block(message_set):
237238
lines = []
238-
i = 1
239-
for signal in message_set.all_signals():
239+
for i, signal in enumerate(message_set.all_signals()):
240240
if not signal.enabled:
241241
LOG.warning("Skipping disabled signal '%s' (in 0x%x)" % (
242242
signal.generic_name, signal.message.id))
243243
continue
244-
signal.array_index = i - 1
244+
if not hasattr(signal, "array_index") or signal.array_index is None:
245+
signal.array_index = i
245246
lines.append(" " * 8 + "%s" % signal)
246247
LOG.info("Added signal '%s'" % signal.generic_name)
247-
i += 1
248+
return lines
249+
250+
lines.extend(self._message_set_lister(block))
251+
lines.append("};")
252+
lines.append("")
253+
254+
return lines
255+
256+
def _build_signal_managers(self):
257+
lines = []
258+
lines.append("SignalManager SIGNAL_MANAGERS[][MAX_SIGNAL_COUNT] = {")
259+
260+
def block(message_set):
261+
lines = []
262+
for i, signal in enumerate(message_set.all_signals()):
263+
if not signal.enabled:
264+
LOG.warning("Skipping manager for disabled signal '%s' (in 0x%x)" % (
265+
signal.generic_name, signal.message.id))
266+
continue
267+
if not hasattr(signal, "array_index") or signal.array_index is None:
268+
signal.array_index = i
269+
270+
signal_arr_str = "SIGNALS[%d][%d]" % (signal.message_set.index, signal.array_index)
271+
lines.append(" " * 8 + "{signal: &%s, frequencyClock: {%s.frequency}}," % (signal_arr_str, signal_arr_str))
272+
LOG.info("Added signal manager '%s'" % signal.generic_name)
273+
248274
return lines
249275

250276
lines.extend(self._message_set_lister(block))
@@ -314,16 +340,18 @@ def block(message_set):
314340
lines.append(" " * 12 + "case 0x%x: // %s" % (message.id,
315341
message.name))
316342
for handler in message.handlers:
317-
lines.append(" " * 16 + "%s(message, SIGNALS[%d], " % (
318-
handler, message_set.index) +
319-
"getSignalCount(), pipeline);")
343+
lines.append(" " * 16 + "%s(SIGNALS[%d], SIGNALS[%d], " % (
344+
handler, message_set.index, message_set.index) +
345+
"SIGNAL_MANAGERS[%d], SIGNAL_MANAGERS[%d], " % (
346+
message_set.index, message_set.index) +
347+
"getSignalCount(), message, pipeline);")
320348
for signal in message.active_signals():
321349
line = " " * 16
322350
line += ("can::read::translateSignal("
323351
"&SIGNALS[%d][%d], message, " %
324352
(message_set.index, signal.array_index))
325-
line += ("SIGNALS[%d], getSignalCount(), pipeline); // %s" % (
326-
message_set.index, signal.name))
353+
line += ("SIGNALS[%d], SIGNAL_MANAGERS[%d], getSignalCount(), pipeline); // %s" % (
354+
message_set.index, message_set.index, signal.name))
327355
lines.append(line)
328356
lines.append(" " * 16 + "break;")
329357
lines.append(" " * 12 + "}")

openxc/generator/signals.cpp.footer

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ int openxc::signals::getCommandCount() {
66
return getActiveMessageSet()->commandCount;
77
}
88

9-
CanMessageDefinition* openxc::signals::getMessages() {
9+
const CanMessageDefinition* openxc::signals::getMessages() {
1010
return CAN_MESSAGES[getActiveMessageSet()->index];
1111
}
1212

1313
int openxc::signals::getMessageCount() {
1414
return getActiveMessageSet()->messageCount;
1515
}
1616

17-
CanSignal* openxc::signals::getSignals() {
17+
const CanSignal* openxc::signals::getSignals() {
1818
return SIGNALS[getActiveMessageSet()->index];
1919
}
2020

21+
SignalManager* openxc::signals::getSignalManagers() {
22+
return SIGNAL_MANAGERS[getActiveMessageSet()->index];
23+
}
24+
2125
int openxc::signals::getSignalCount() {
2226
return getActiveMessageSet()->signalCount;
2327
}
@@ -30,11 +34,11 @@ int openxc::signals::getCanBusCount() {
3034
return getActiveMessageSet()->busCount;
3135
}
3236

33-
CanMessageSet* openxc::signals::getActiveMessageSet() {
37+
const CanMessageSet* openxc::signals::getActiveMessageSet() {
3438
return &MESSAGE_SETS[getConfiguration()->messageSetIndex];
3539
}
3640

37-
CanMessageSet* openxc::signals::getMessageSets() {
41+
const CanMessageSet* openxc::signals::getMessageSets() {
3842
return MESSAGE_SETS;
3943
}
4044

openxc/generator/signals.cpp.header

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
namespace can = openxc::can;
1717

1818
using openxc::util::log::debug;
19+
using openxc::util::time::FrequencyClock;
1920
using openxc::pipeline::Pipeline;
2021
using openxc::config::getConfiguration;
2122
using openxc::can::read::booleanDecoder;

openxc/generator/structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def _invert_bit_index(cls, bit_index, length):
487487
return inverted_index
488488

489489
def __str__(self):
490-
result = ("{message: &CAN_MESSAGES[%d][%d], genericName: \"%s\", bitPosition: %s, bitSize: %d, factor: %f, offset: %f, minValue: %f, maxValue: %f, frequencyClock: {%f}, sendSame: %s, forceSendChanged: %s, " % (
490+
result = ("{message: &CAN_MESSAGES[%d][%d], genericName: \"%s\", bitPosition: %s, bitSize: %d, factor: %f, offset: %f, minValue: %f, maxValue: %f, frequency: %f, sendSame: %s, forceSendChanged: %s, " % (
491491
self.message_set.index,
492492
self.message_set.lookup_message_index(self.message),
493493
self.generic_name, self.bit_position, self.bit_size,

openxc/sources/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def run(self):
143143
message from the buffer of bytes. When a message is parsed, passes it
144144
off to the callback if one is set.
145145
"""
146-
message_buffer = b""
146+
message_buffer = ""
147147
while self.running:
148148
try:
149149
message_buffer += self.source.read_logs()
@@ -158,7 +158,7 @@ def run(self):
158158
while True:
159159
if "\x00" not in message_buffer:
160160
break
161-
record, _, remainder = message_buffer.partition(b"\x00")
161+
record, _, remainder = message_buffer.partition("\x00")
162162
self.record(record)
163163
message_buffer = remainder
164164

@@ -191,6 +191,7 @@ def run(self):
191191
off to the callback if one is set.
192192
"""
193193
while self.running:
194+
payload = ""
194195
try:
195196
payload = self.read()
196197
except DataSourceError as e:
@@ -223,7 +224,7 @@ def run(self):
223224
self._receive_command_response(message)
224225

225226
def _receive_command_response(self, message):
226-
# TODO the controller/source are getting a litlte mixed up since the
227+
# TODO the controller/source are getting a little mixed up since the
227228
# controller now needs to receive responses from the soruce side, maybe
228229
# just mix them again. the only exception to being both is a trace
229230
# source, and we can just leave the controller methods on that

0 commit comments

Comments
 (0)