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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged.
Change subject: Osmocom_Types: Add bool2bit() and bool2bit_templ()
......................................................................
Osmocom_Types: Add bool2bit() and bool2bit_templ()
Those can be very handy to convert boolean values and templates
to the BIT1 type that is used a lot in Ericsson code.
Change-Id: I137595edabd2bbf5e6cf8bf9bdb73b3589c94c64
---
M library/Osmocom_Types.ttcn
1 file changed, 29 insertions(+), 0 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index a748bbc..a736e95 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -1,4 +1,7 @@
module Osmocom_Types {
+
+ import from General_Types all;
+
type integer uint8_t (0..255) with { variant "unsigned 8 bit" };
type integer uint16_t (0..65535) with { variant "unsigned 16 bit" };
type integer uint24_t (0..16777215) with { variant "unsigned 24 bit" };
@@ -66,4 +69,30 @@
T.timeout;
}
+function bool2bit(boolean inp) return BIT1 {
+ if (inp) {
+ return '1'B;
+ } else {
+ return '0'B;
+ }
+}
+
+function bool2bit_tmpl(template boolean inp) return template BIT1 {
+ if (istemplatekind(inp, "omit")) {
+ return omit;
+ } else if (istemplatekind(inp, "*")) {
+ return *;
+ } else if (istemplatekind(inp, "?")) {
+ } else {
+ if (valueof(inp)) {
+ return '1'B;
+ } else {
+ return '0'B;
+ }
+ }
+ setverdict(fail, "Unsupported template");
+ self.stop;
+}
+
+
} with { encode "RAW"; variant "FIELDORDER(msb)" }
--
To view, visit https://gerrit.osmocom.org/6527
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I137595edabd2bbf5e6cf8bf9bdb73b3589c94c64
Gerrit-PatchSet: 4
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder