Skip to content

Commit

Permalink
Another attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermedemouraa committed Jun 17, 2024
1 parent 1738155 commit a87f205
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions py/farm_ng/canbus/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ def encode(self):
R1 C1 R2 C2 R3 C3
"""

if any(rate > 255 or rate < 0 for rate in [self.rate1, self.rate2, self.rate3]):
raise ValueError("Rates must be between 0 and 255")
if any(rate > 25.5 or rate < 0.0 for rate in [self.rate1, self.rate2, self.rate3]):
raise ValueError("Rates must be between 0 and 25.5 m/drop")

if any(counter > 255 or counter < 0 for counter in [self.counter1, self.counter2, self.counter3]):
raise ValueError("Counters must be between 0 and 255")
Expand Down
12 changes: 6 additions & 6 deletions py/tests/test_packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def test_bug_dispenser_rpdo3_encode_decode(bug_dispenser_rpdo3_instance):
decoded_instance = BugDispenserRpdo3()
decoded_instance.decode(encoded)

assert bug_dispenser_rpdo3_instance.rate1 == pytest.approx(decoded_instance.rate1, rel=1e-2)
assert bug_dispenser_rpdo3_instance.rate2 == pytest.approx(decoded_instance.rate2, rel=1e-2)
assert bug_dispenser_rpdo3_instance.rate3 == pytest.approx(decoded_instance.rate3, rel=1e-2)
assert bug_dispenser_rpdo3_instance.rate1 == pytest.approx(decoded_instance.rate1, rel=1e-1)
assert bug_dispenser_rpdo3_instance.rate2 == pytest.approx(decoded_instance.rate2, rel=1e-1)
assert bug_dispenser_rpdo3_instance.rate3 == pytest.approx(decoded_instance.rate3, rel=1e-1)


def test_bug_dispenser_rpdo3_invalid_rate():
Expand All @@ -143,11 +143,11 @@ def test_bug_dispenser_tpdo3_encode_decode(bug_dispenser_tpdo3_instance):
decoded_instance = BugDispenserTpdo3()
decoded_instance.decode(encoded)

assert bug_dispenser_tpdo3_instance.rate1 == pytest.approx(decoded_instance.rate1, rel=1e-2)
assert bug_dispenser_tpdo3_instance.rate1 == pytest.approx(decoded_instance.rate1, rel=1e-1)
assert bug_dispenser_tpdo3_instance.counter1 == decoded_instance.counter1
assert bug_dispenser_tpdo3_instance.rate2 == pytest.approx(decoded_instance.rate2, rel=1e-2)
assert bug_dispenser_tpdo3_instance.rate2 == pytest.approx(decoded_instance.rate2, rel=1e-1)
assert bug_dispenser_tpdo3_instance.counter2 == decoded_instance.counter2
assert bug_dispenser_tpdo3_instance.rate3 == pytest.approx(decoded_instance.rate3, rel=1e-2)
assert bug_dispenser_tpdo3_instance.rate3 == pytest.approx(decoded_instance.rate3, rel=1e-1)
assert bug_dispenser_tpdo3_instance.counter3 == decoded_instance.counter3


Expand Down

0 comments on commit a87f205

Please sign in to comment.