Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def name_bit(signal):
offset = start_bit(signal) + signal.length - 1
if signal.byte_order == 'big_endian':
return (8 * (offset // 8) + (7 - (offset % 8)))
else:
return offset
senders.append(_get_node_name_by_id(nodes,
sender.attrib['id']))
# Find all signals in this message.
signals = []
for mux in message.iterfind('ns:Multiplex', NAMESPACES):
signals += _load_multiplex_element(mux, nodes)
for signal in message.iterfind('ns:Signal', NAMESPACES):
signals.append(_load_signal_element(signal, nodes))
if length == 'auto':
if signals:
last_signal = sorted(signals, key=start_bit)[-1]
length = (start_bit(last_signal) + last_signal.length + 7) // 8
else:
length = 0
else:
length = int(length)
return Message(frame_id=frame_id,
is_extended_frame=is_extended_frame,
name=name,
length=length,
senders=senders,
send_type=None,
cycle_time=interval,
signals=signals,
comment=notes,
bus_name=bus_name,
strict=strict)
def _check_signal(self, message_bits, signal):
signal_bits = signal.length * [signal.name]
if signal.byte_order == 'big_endian':
padding = start_bit(signal) * [None]
signal_bits = padding + signal_bits
else:
signal_bits += signal.start * [None]
if len(signal_bits) < len(message_bits):
padding = (len(message_bits) - len(signal_bits)) * [None]
reversed_signal_bits = padding + signal_bits
else:
reversed_signal_bits = signal_bits
signal_bits = []
for i in range(0, len(reversed_signal_bits), 8):
signal_bits = reversed_signal_bits[i:i + 8] + signal_bits
# Check that the signal fits in the message.
def format_big():
signals = []
for signal in self._signals:
if signal.byte_order != 'big_endian':
continue
formatted = start_bit(signal) * ' '
formatted += '<{}x'.format((3 * signal.length - 2) * '-')
signals.append(formatted)
return signals
signals,
comment=None,
senders=None,
send_type=None,
cycle_time=None,
dbc_specifics=None,
is_extended_frame=False,
bus_name=None,
strict=True,
protocol=None):
self._frame_id = frame_id
self._is_extended_frame = is_extended_frame
self._name = name
self._length = length
self._signals = signals
self._signals.sort(key=start_bit)
self._comment = comment
self._senders = senders if senders else []
self._send_type = send_type
self._cycle_time = cycle_time
self._dbc = dbc_specifics
self._bus_name = bus_name
self._codecs = None
self._signal_tree = None
self._strict = strict
self._protocol = protocol
self.refresh()