Restructure for better usability

This commit is contained in:
2025-06-10 17:15:39 +02:00
parent af4b697e01
commit e423add6a0
23 changed files with 0 additions and 0 deletions

18
lib/decoder.py Normal file
View File

@@ -0,0 +1,18 @@
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.from_bytes(value, 'big')
return int(value, base=16)