Repository navigation
Conversation
this allows to extract overlapping values. (occasionally happens in CAN network descriptions.) This was created with AI assistance. I went over all hunks and ensured to understand each of them. Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com> Approved-by: Michael Hahn <michael.a.hahn@mercedes-benz.com>
`bitstruct.c` is CPython-only. Hopefully plain `bitstruct` is fast enough on pypy. Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>
|
negative padding is a bit odd, hmmm... maybe a new character "seeking" in the bit stream? |
|
IMO negative padding is not too difficult to grasp as a concept, but I also don't mind using a separate format character for this. how about |
|
okay, I added a patch using a new format letter |
thanks to [at]eerimoq for the suggestion. Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>
f266fbc to
c12f620
Compare
|
Claude and I think these will give wrong result. buf = bytearray(2)
pack_into('u8q8p4', buf, 0, 0xff, fill_padding=False)
# expected: b'\xff\x00' (padding leaves bits untouched)
# I think this gives: b'\x0f\x00'
buf = bytearray(b'\xff\xff\xff')
pack_into('u8q4u8u4', buf, 0, 0, 0, 0)
# expected: b'\x00\x00\xff'
# I think this gives: b'\x00\x0f\xff' |
|
I think this is a matter of definition: the |
my python seems to disagree: |
|
okay, this was a |
d0b798a to
53066c2
Compare
…ffects one byte if first==last byte, the restore code for the last byte overwrote the restored bits for the first byte. thanks to [at]eerimoq for the catch. Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>
53066c2 to
a4cff9c
Compare
|
I'm not sure about this. it adds complexity and makes performance a little worse. how important is this feature? |
|
it is a long-standing missing feature in cantools which regularly comes up. Recently, a pull request has been opened to implement support for overlapping signals, but this is quite involved (multiple layers of codecs per PDU), and it would an order of magnitude in complexity if there was a way to seek backwards using bitstruct. If you don't like the feature, just close this PR and we'll get cantools#825 merged, if you're not opposed in principle, I'll invest the time to beat |
|
have you implemented changes in cantools to use bitstruct that can seek backwards? I just want to make sure we don't make changes to bitstruct that in the end did not fit your use case. |
I've asked my LLM to do it: cantools/cantools@17182d0 . while it is not too many fewer lines of code changed than cantools/cantools#825, IMO the result is conceptionally simpler and I suppose it is more performant if overlapping signals are present. Anyway, no bad blood from my side if you prefer not to have this feature... |
|
I suggest not making this change to bitstruct right now, and possibly continue on it later on after evaluation of other solution. |
|
ok, let's close this PR then. thanks for your feedback! |
|
thanks |
this allows to pack and unpack overlapping values. (occasionally happens in CAN network descriptions.)
This was created with AI assistance. I went over all hunks and ensured to understand each of them. (I also found and fixed a few minor issues. As usual, all the good stuff is from the AI, while all bugs are mine ;))