Attention is currently required from: dexter.
neels has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/28218 )
Change subject: commands: add ".." notation to expand hexstrings
......................................................................
Patch Set 1: Code-Review+1
(1 comment)
Patchset:
PS1:
i don't know this code, but the patch looks ok to me
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28218
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iedd7887bf7d706878f4a3beca8dbea456404610b
Gerrit-Change-Number: 28218
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 02 Jun 2022 18:37:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/28203 )
Change subject: drop log from ts_is_usable()
......................................................................
drop log from ts_is_usable()
ts_is_usable() returns the current state; logging is the job of calling
functions. An upcoming patch adds some calls to ts_is_usable(), this
avoids the log flaring up with useless messages.
Related: SYS#5976
Change-Id: I0635c47609fd7c7d0195b6658b7da231d6527b4b
---
M src/osmo-bsc/gsm_data.c
1 file changed, 1 insertion(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
fixeria: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c
index 1d6df12..ad28058 100644
--- a/src/osmo-bsc/gsm_data.c
+++ b/src/osmo-bsc/gsm_data.c
@@ -960,10 +960,8 @@
bool ts_is_usable(const struct gsm_bts_trx_ts *ts)
{
- if (!trx_is_usable(ts->trx)) {
- LOGP(DRLL, LOGL_DEBUG, "%s not usable\n", gsm_trx_name(ts->trx));
+ if (!trx_is_usable(ts->trx))
return false;
- }
if (!ts->fi)
return false;
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/28203
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I0635c47609fd7c7d0195b6658b7da231d6527b4b
Gerrit-Change-Number: 28203
Gerrit-PatchSet: 3
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/28218 )
Change subject: commands: add ".." notation to expand hexstrings
......................................................................
commands: add ".." notation to expand hexstrings
When updating files and records there are sometimes huge portions that
are just 0xff. Mostly this is at the end of a file or record that is not
completely used. Lets add a notation to tell PySim-shell how to fill
those sections.
Change-Id: Iedd7887bf7d706878f4a3beca8dbea456404610b
---
M pySim/commands.py
M pySim/utils.py
2 files changed, 64 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/18/28218/1
diff --git a/pySim/commands.py b/pySim/commands.py
index a959851..7b50677 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -23,7 +23,7 @@
from construct import *
from pySim.construct import LV
-from pySim.utils import rpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, str_sanitize
+from pySim.utils import rpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, str_sanitize, expand_hex
from pySim.exceptions import SwMatchError
@@ -190,6 +190,10 @@
offset : byte offset in file from which to start writing
verify : Whether or not to verify data after write
"""
+
+ file_len = self.binary_size(ef)
+ data = expand_hex(data, file_len)
+
data_length = len(data) // 2
# Save write cycles by reading+comparing before write
@@ -255,16 +259,17 @@
verify : verify data by re-reading the record
conserve : read record and compare it with data, skip write on match
"""
+
res = self.select_path(ef)
+ rec_length = self.__record_len(res)
+ data = expand_hex(data, rec_length)
if force_len:
# enforce the record length by the actual length of the given data input
rec_length = len(data) // 2
else:
- # determine the record length from the select response of the file and pad
- # the input data with 0xFF if necessary. In cases where the input data
- # exceed we throw an exception.
- rec_length = self.__record_len(res)
+ # make sure the input data is padded to the record length using 0xFF.
+ # In cases where the input data exceed we throw an exception.
if (len(data) // 2 > rec_length):
raise ValueError('Data length exceeds record length (expected max %d, got %d)' % (
rec_length, len(data) // 2))
diff --git a/pySim/utils.py b/pySim/utils.py
index ef770f9..6b8ee37 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1225,6 +1225,60 @@
return int(x, 0)
+def expand_hex(hexstring, length):
+ """Expand a given hexstring to a specified length by replacing "." or ".."
+ with a filler that is derived from the neighboring nibbles respective
+ bytes. Usually this will be the nibble respective byte before "." or
+ "..", execpt when the string begins with "." or "..", then the nibble
+ respective byte after "." or ".." is used.". In case the string cannot
+ be expanded for some reason, the input string is returned unmodified.
+
+ Args:
+ hexstring : hexstring to expand
+ length : desired length of the resulting hexstring.
+ Returns:
+ expanded hexstring
+ """
+
+ # expand digit aligned
+ if hexstring.count(".") == 1:
+ pos = hexstring.index(".")
+ if pos > 0:
+ filler = hexstring[pos - 1]
+ else:
+ filler = hexstring[pos + 1]
+
+ missing = length * 2 - (len(hexstring) - 1)
+ if missing <= 0:
+ return hexstring
+
+ return hexstring.replace(".", filler * missing)
+
+ # expand byte aligned
+ elif hexstring.count("..") == 1:
+ if len(hexstring) % 2:
+ return hexstring
+
+ pos = hexstring.index("..")
+
+ if pos % 2:
+ return hexstring
+
+ if pos > 1:
+ filler = hexstring[pos - 2:pos]
+ else:
+ filler = hexstring[pos + 2:pos+4]
+
+ missing = length * 2 - (len(hexstring) - 2)
+ if missing <= 0:
+ return hexstring
+
+ return hexstring.replace("..", filler * (missing // 2))
+
+ # no change
+ return hexstring
+
+
class JsonEncoder(json.JSONEncoder):
"""Extend the standard library JSONEncoder with support for more types."""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28218
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iedd7887bf7d706878f4a3beca8dbea456404610b
Gerrit-Change-Number: 28218
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange