einride / can-go

Controller Area Network (CAN) SDK for Go.
MIT License
189 stars 38 forks source link

fix(cantool): CopyFrom preserves signal values that are out-of-range #276

Closed Jassob closed 3 months ago

Jassob commented 4 months ago

Previously we used the setters and getters in the CopyFrom method. The getters and setters both caps a signal to be within [min, max] range.

This meant that if we used CopyFrom from a message which contained an out-of-bounds signal the new value would not keep the same signal value.

This commit updates the CopyFrom implementation to instead unmarshal the generated CAN frame from the original message.

BREAKING CHANGE: This changes CopyFrom to accept a message instead of a message reader to copy from, however mostly test code should be affected.