mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-07 15:07:33 -06:00
ctr: Encode integers in hex
Replace the custom encoding with a hex encoding. This makes it a little easier to inspect the CTR conversions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
69fc1e63b4
commit
e59d875256
2 changed files with 11 additions and 8 deletions
|
@ -125,9 +125,9 @@ Handlers.append(HandlerEnumerations)
|
|||
|
||||
def decode_integer(value):
|
||||
value = value.strip()
|
||||
if len(value) != 7 or value[0] not in '-+':
|
||||
if len(value) != 11 or value[0] not in '-+' or value[1:3] != '0x':
|
||||
error("Invalid encoded integer '%s'" % (value,))
|
||||
out = sum([(ord(c) - 48) << (i*6) for i, c in enumerate(value[1:])])
|
||||
out = int(value[1:], 0)
|
||||
if value[0] == '-':
|
||||
out -= 1<<32
|
||||
return out
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue