Closed unijay2671 closed 1 year ago
Please provide the dbc description of the signal you were trying to use with phys.setter function (signal type, byte order, mode, bit position, length, factor, offset, minimum, and maximum).
This happens when we try to store as an int in python and then pack it into 10-bits before sending on the bus.
<signal_name> : 24|10@0- (0.125,0) [-64|63.875] "m" DAQ
Length is 10 bits, factor is 0.125, minimum is -64, max is 63.875, offset is 0, bit position is 24, mode is big endian, signed.
We were unable to reproduce this.
Here is the test used:
BO_ 1 msg: 8 Vector__XXX
SG_ testsig : 24|10@0- (0.125,0) [-64|63.875] "" Vector__XXX
__________________ test_reproduce_phys_setter_issue ___________________
def test_reproduce_phys_setter_issue():
db = kvadblib.Dbc(filename=os.path.join(DATADIR, "phys.dbc"))
framebox = kvadblib.FrameBox(db, messages=("msg",))
bsig = framebox.signal('testsig')
bsig.phys = -1
frames = list(framebox.frames())
data = list(frames[0].data)
> assert not any(data) # expect all zeros if reproducible
E assert not True
E + where True = any([0, 0, 0, 1, 252, 0, ...])
test_phys_setter.py:16: AssertionError
======================= short test summary info =======================
We have an issue where the @phys.setter function (line 18 in
canlib/kvadblib/bound_signal.py
) sets the frame data as 0 when we pass in a negative non-binary number as the value.A temporary fix for us was adding 2^(bitsize) of the signal we wanted to send, but we were hoping for a more permanent fix baked into the library.