<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/17896">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">utils.py: Add helper method to parse and print Service Table<br><br>This method helps in printing Service Tables in EF.SST, EF.UST, EF.IST.<br>Takes hex string of Service table, parses it and prints available service along with its description.<br><br>Change-Id: Ie1e82e07ead2e28314a5794661e6b2ced0acd72a<br>---<br>M pySim/utils.py<br>1 file changed, 31 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/utils.py b/pySim/utils.py</span><br><span>index 51f2954..be670e9 100644</span><br><span>--- a/pySim/utils.py</span><br><span>+++ b/pySim/utils.py</span><br><span>@@ -347,3 +347,34 @@</span><br><span>                                 avail_srvc.append((8*i) + j)</span><br><span>                         byte = byte >> 1</span><br><span>       return avail_srvc</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def dec_st(st, table="sim"):</span><br><span style="color: hsl(120, 100%, 40%);">+   """</span><br><span style="color: hsl(120, 100%, 40%);">+    Parses the EF S/U/IST and prints the list of available services in EF S/U/IST</span><br><span style="color: hsl(120, 100%, 40%);">+ """</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if table == "usim":</span><br><span style="color: hsl(120, 100%, 40%);">+         from pySim.ts_31_102 import EF_UST_map</span><br><span style="color: hsl(120, 100%, 40%);">+                lookup_map = EF_UST_map</span><br><span style="color: hsl(120, 100%, 40%);">+       else:</span><br><span style="color: hsl(120, 100%, 40%);">+         from pySim.ts_51_011 import EF_SST_map</span><br><span style="color: hsl(120, 100%, 40%);">+                lookup_map = EF_SST_map</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     st_bytes = [st[i:i+2] for i in range(0, len(st), 2) ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       avail_st = ""</span><br><span style="color: hsl(120, 100%, 40%);">+       # Get each byte and check for available services</span><br><span style="color: hsl(120, 100%, 40%);">+      for i in range(0, len(st_bytes)):</span><br><span style="color: hsl(120, 100%, 40%);">+             # Byte i contains info about Services num (8i+1) to num (8i+8)</span><br><span style="color: hsl(120, 100%, 40%);">+                byte = int(st_bytes[i], 16)</span><br><span style="color: hsl(120, 100%, 40%);">+           # Services in each byte are in order MSB to LSB</span><br><span style="color: hsl(120, 100%, 40%);">+               # MSB - Service (8i+8)</span><br><span style="color: hsl(120, 100%, 40%);">+                # LSB - Service (8i+1)</span><br><span style="color: hsl(120, 100%, 40%);">+                for j in range(1, 9):</span><br><span style="color: hsl(120, 100%, 40%);">+                 if byte&0x01 == 0x01 and ((8*i) + j in lookup_map):</span><br><span style="color: hsl(120, 100%, 40%);">+                               # Byte X contains info about Services num (8X-7) to num (8X)</span><br><span style="color: hsl(120, 100%, 40%);">+                          # bit = 1: service available</span><br><span style="color: hsl(120, 100%, 40%);">+                          # bit = 0: service not available</span><br><span style="color: hsl(120, 100%, 40%);">+                              avail_st += '\tService %d - %s\n' % ((8*i) + j, lookup_map[(8*i) + j])</span><br><span style="color: hsl(120, 100%, 40%);">+                        byte = byte >> 1</span><br><span style="color: hsl(120, 100%, 40%);">+        return avail_st</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/17896">change 17896</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/17896"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie1e82e07ead2e28314a5794661e6b2ced0acd72a </div>
<div style="display:none"> Gerrit-Change-Number: 17896 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: herlesupreeth <herlesupreeth@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>