Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metatransport data types #69

Merged
merged 2 commits into from
Oct 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def compute_max_num_frames_canfd(bit_length):
print('%d data types in %.1f seconds' % (len(output), elapsed_time),
file=sys.stderr)

largest = None
for t in output:
text = open(t.source_file_path).read()
for index, line in enumerate(text.split('\n')):
Expand Down Expand Up @@ -93,18 +92,19 @@ def compute_max_num_frames_canfd(bit_length):
if not text.endswith('\n') or text.endswith('\n' * 2):
abort('A file must contain exactly one blank line at the end')

if isinstance(t, pydsdl.ServiceType):
tt = t.request_type, t.response_type

def get_max_bit_length(ty) -> int:
if isinstance(ty, pydsdl.ServiceType):
return max(map(max, (ty.request_type.bit_length_set,
ty.response_type.bit_length_set)))
else:
tt = t,
return max(ty.bit_length_set)

for t in tt:
largest = largest if largest and (max(largest.bit_length_set) >= max(t.bit_length_set)) else t

if max(largest.bit_length_set) > MAX_SERIALIZED_BIT_LENGTH:
print('The largest data type', largest, 'exceeds the bit length limit of', MAX_SERIALIZED_BIT_LENGTH,
file=sys.stderr)
sys.exit(1)
else:
print('Largest data type is', largest, 'up to', (max(largest.bit_length_set) + 7) // 8, 'bytes',
file=sys.stderr)
for t in output:
max_bit_length = get_max_bit_length(t)
if max_bit_length > MAX_SERIALIZED_BIT_LENGTH:
text = open(t.source_file_path).read()
if '#pragma:no-bit-length-limit' not in text.replace(' ', ''):
print('The data type', t, 'exceeds the bit length limit of', MAX_SERIALIZED_BIT_LENGTH, file=sys.stderr)
sys.exit(1)
10 changes: 10 additions & 0 deletions uavcan/metatransport/can/ArbitrationID.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# CAN frame arbitration field.
#

@union

BaseArbitrationID.0.1 base
ExtendedArbitrationID.0.1 extended

@assert _offset_ == {30}
6 changes: 6 additions & 0 deletions uavcan/metatransport/can/BaseArbitrationID.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# 11-bit identifier.
#

truncated uint11 value
void18
7 changes: 7 additions & 0 deletions uavcan/metatransport/can/DataClassic.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Classic data frame payload.
#

ArbitrationID.0.1 arbitration_id
void4
uint8[<=8] data
7 changes: 7 additions & 0 deletions uavcan/metatransport/can/DataFD.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# CAN FD data frame payload.
#

ArbitrationID.0.1 arbitration_id
void1
uint8[<=64] data
5 changes: 5 additions & 0 deletions uavcan/metatransport/can/Error.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# CAN bus error report: either an intentionally generated error frame or a disturbance.
#

void30
5 changes: 5 additions & 0 deletions uavcan/metatransport/can/ExtendedArbitrationID.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# 29-bit identifier.
#

truncated uint29 value
11 changes: 11 additions & 0 deletions uavcan/metatransport/can/Frame.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# CAN 2.0 or CAN FD frame representation. This is the top-level data type in its namespace.
#

uavcan.time.SynchronizedTimestamp.1.0 timestamp

Manifestation.0.1 manifestation

@assert _offset_ % 8 == {0}
@assert _offset_.min == (7 + 4) * 8
@assert _offset_.max == (7 + 4 + 1 + 64) * 8
14 changes: 14 additions & 0 deletions uavcan/metatransport/can/Manifestation.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# CAN frame properties that can be manifested on the bus.
#

@union

Error.0.1 error # CAN error (intentional or disturbance)
DataFD.0.1 data_fd # Bit rate switch flag active
DataClassic.0.1 data_classic # Bit rate switch flag not active
RTR.0.1 remote_transmission_request # Bit rate switch flag not active

@assert _offset_.min == 32
@assert _offset_.max == 32 + 8 + 64 * 8
@assert _offset_ % 8 == {0}
5 changes: 5 additions & 0 deletions uavcan/metatransport/can/RTR.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Classic remote transmission request (not defined for CAN FD).
#

ArbitrationID.0.1 arbitration_id
13 changes: 13 additions & 0 deletions uavcan/metatransport/serial/Fragment.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# A chunk of raw bytes exchanged over a serial transport. Serial links do not support framing natively.
# The chunk may be of arbitrary size.
#

uavcan.time.SynchronizedTimestamp.1.0 timestamp

uint9 CAPACITY_BYTES = 256
void7
uint8[<=CAPACITY_BYTES] data

@assert _offset_ % 8 == {0}
@assert _offset_.max / 8 <= 313
18 changes: 18 additions & 0 deletions uavcan/metatransport/udp/Endpoint.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# A UDP/IP endpoint address specification.
#

# The IP address of the host in the network byte order (big endian).
# IPv6 addresses are represented as-is.
# IPv4 addresses are represented using IPv4-mapped IPv6 addresses.
uint8[16] ip_address

# MAC address of the host in the network byte order (big endian).
uint8[6] mac_address

# The UDP port number.
uint16 port

void64

@assert _offset_ == {32} * 8
23 changes: 23 additions & 0 deletions uavcan/metatransport/udp/Frame.0.1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# A generic UDP/IP frame.
# Jumboframes are supported in the interest of greater application compatibility.
#
# pragma: no-bit-length-limit
#

uavcan.time.SynchronizedTimestamp.1.0 timestamp

void8
@assert _offset_ % 64 == {0}

Endpoint.0.1 source
Endpoint.0.1 destination

@assert _offset_ % 64 == {0}

# Max jumbo frame 9 KiB, IP header min 20 B, UDP header 8 B.
uint14 MTU = 1024 * 9 - 20 - 8
void2
uint8[<=MTU] data

@assert _offset_ % 8 == {0}