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 uploaded this change for review. ( 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(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/02/25802/1 diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index 70629f7..bb76574 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: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211014/e045278e/attachment.htm>