ts_51_011.EF_SMSP: Use integer division during encode

Otherwise we might compute float values and fail encoding like this:

> construct.core.FormatFieldError: Error in path (building) -> tp_vp_minutes
> struct '>B' error during building, given value 169.0

Change-Id: I989669434c7ddee9595ee81a0822f9966907a844
This commit is contained in:
Harald Welte
2025-12-16 02:14:03 +01:00
parent 11dfad88e6
commit cc15b2b4c3

View File

@@ -267,11 +267,11 @@ class EF_SMSP(LinFixedEF):
raise ValueError raise ValueError
def _encode(self, obj, context, path): def _encode(self, obj, context, path):
if obj <= 12*60: if obj <= 12*60:
return obj/5 - 1 return obj // 5 - 1
elif obj <= 24*60: elif obj <= 24*60:
return 143 + ((obj - (12 * 60)) // 30) return 143 + ((obj - (12 * 60)) // 30)
elif obj <= 30 * 24 * 60: elif obj <= 30 * 24 * 60:
return 166 + (obj / (24 * 60)) return 166 + (obj // (24 * 60))
elif obj <= 63 * 7 * 24 * 60: elif obj <= 63 * 7 * 24 * 60:
return 192 + (obj // (7 * 24 * 60)) return 192 + (obj // (7 * 24 * 60))
else: else: