Begin rewrite

This commit is contained in:
2025-03-05 11:20:01 +01:00
parent d26e91db31
commit ffd75d94dc
9 changed files with 155 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import struct
class Decoder:
def decode_ascii(self, value: bytes) -> str:
try:
return value.decode()
except:
return 'Error'
def decode_float(self, value: bytes) -> float:
return struct.unpack('>f', bytes.fromhex(str(value, 'ascii') + '00'))[0]
def decode_float_long(self, value: bytes) -> float:
return struct.unpack('>f', bytes.fromhex(str(value, 'ascii') + '0000'))[0]
def decode_int(self, value: bytes) -> int:
return int(value, base=16)