This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/25802 )
Change subject: ts_51_011: Add encoder for EF.SST
......................................................................
ts_51_011: Add encoder for EF.SST
We already have those for EF.UST, let's add them for EF.SST, too
Change-Id: Ib51bfffaf8444ec30415aad42e3a0f4f3f7598cb
---
M pySim/ts_51_011.py
1 file changed, 26 insertions(+), 1 deletion(-)
Approvals:
dexter: Looks good to me, approved; Verified
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index 5d1197c..3492a8d 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -505,6 +505,12 @@
def __init__(self, fid, sfid, name, desc, size, table):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self.table = table
+ @staticmethod
+ def _bit_byte_offset_for_service(service:int) -> (int, int):
+ i = service - 1
+ byte_offset = i//4
+ bit_offset = (i % 4) * 2
+ return (byte_offset, bit_offset)
def _decode_bin(self, raw_bin):
ret = {}
for i in range(0, len(raw_bin)*4):
@@ -518,7 +524,26 @@
'activated': True if bits & 2 else False,
}
return ret
- # TODO: encoder
+ def _encode_bin(self, in_json):
+ # compute the required binary size
+ bin_len = 0
+ for srv in in_json.keys():
+ service_nr = int(srv)
+ (byte_offset, bit_offset) = EF_ServiceTable._bit_byte_offset_for_service(service_nr)
+ if byte_offset >= bin_len:
+ bin_len = byte_offset+1
+ # encode the actual data
+ out = bytearray(b'\x00' * bin_len)
+ for srv in in_json.keys():
+ service_nr = int(srv)
+ (byte_offset, bit_offset) = EF_ServiceTable._bit_byte_offset_for_service(service_nr)
+ bits = 0
+ if in_json[srv]['allocated'] == True:
+ bits |= 1
+ if in_json[srv]['activated'] == True:
+ bits |= 2
+ out[byte_offset] |= ((bits & 3) << bit_offset)
+ return out
# TS 51.011 Section 10.3.11
class EF_SPN(TransparentEF):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/25802
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib51bfffaf8444ec30415aad42e3a0f4f3f7598cb
Gerrit-Change-Number: 25802
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211015/fb493aeb/attachment.htm>