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

Bug fix in bus load calculations and removal of compiler defines from command line #123

Merged
merged 2 commits into from
Mar 1, 2025
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
2 changes: 0 additions & 2 deletions embedded/platforms/stm32/f1/stm32f103xb.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
name: stm32f103
defines:
NUM_CAN_BUSES: 1U
extraSources:
- "f103/startup_stm32f103xb.S"
- "system_stm32f1xx.c"
Expand Down
2 changes: 0 additions & 2 deletions embedded/platforms/stm32/f1/stm32f105.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
name: stm32f105
defines:
NUM_CAN_BUSES: 2U
extraSources:
- "f105/startup_stm32f105vc.S"
- "system_stm32f1xx.c"
Expand Down
7 changes: 6 additions & 1 deletion network/NetworkGen/NetworkGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,16 @@ def calculate_bus_load(bus, output_dir):
total_messages_per_s = 0
total_unscheduled_bits = 0
total_unscheduled_messages = 0
total_messages = 0

output = [ open(str(output_dir) + f"/{bus.name}-stats.txt", 'w'), sys.stdout ]

for _, message in bus.messages.items():
# SOF(1), RTR(1), IDE(1), DLC(4), CRC(15)
# DEL(1), ACK(1), DEL(1), EOF(7), ITM(11)
if bus.name not in message.source_buses:
continue

bit_length = 43
bit_length += message.length_bytes * 8
bit_length += 11 if message.id <= 0x7ff else 29
Expand All @@ -770,6 +774,7 @@ def calculate_bus_load(bus, output_dir):
total_unscheduled_bits += bit_length
total_unscheduled_messages += 1
continue
total_messages += 1
messages_per_s = 1000 / message.cycle_time_ms

total_bits_per_s += bit_length * messages_per_s
Expand All @@ -781,7 +786,7 @@ def calculate_bus_load(bus, output_dir):
print(f"Total Bits Transmitted/s: {int(total_bits_per_s)}; Total Messages Transmitted/s: {int(total_messages_per_s)}", file=out)
if total_unscheduled_messages > 0:
print(f"Total Bits Unscheduled: {int(total_unscheduled_bits)}; Total Messages Unscheduled: {int(total_unscheduled_messages)}", file=out)
print(f"Total Nodes: {len(bus.nodes)}; Count Messages: {len(bus.messages)}", file=out)
print(f"Total Nodes: {len(bus.nodes)}; Count Messages: {total_messages}", file=out)

if usage > 0.8:
print(f"Warning: CANBus '{bus.name.upper()}' has high bus load")
Expand Down