Skip to content

Commit ad6103f

Browse files
committed
[architecture] can: validate message buffer length and fix module dependencies
1 parent 853d5c7 commit ad6103f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/modm/architecture/module.lb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,18 @@ class Can(Module):
121121
module.description = FileReader("interface/can.md")
122122

123123
def prepare(self, module, options):
124+
def validate_dlc(s: int):
125+
valid_dlcs = [8, 12, 16, 20, 24, 32, 48, 64]
126+
if s not in valid_dlcs:
127+
raise ValueError(f"Input must be a valid CAN data length: {', '.join(valid_dlcs)}!")
124128
module.add_option(
125129
NumericOption(
126130
name="message.buffer",
127131
description="",
128132
minimum=8, maximum=64,
133+
validate=validate_dlc,
129134
default=8))
135+
module.depends(":debug")
130136
return True
131137

132138
def build(self, env):

0 commit comments

Comments
 (0)