Advertisement
Guest User

Untitled

a guest
Mar 18th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
  2. index 2e71123..e7c9776 100644
  3. --- a/library/Osmocom_Types.ttcn
  4. +++ b/library/Osmocom_Types.ttcn
  5. @@ -178,5 +178,31 @@ function f_pad_bcd_number(hexstring number) return hexstring {
  6.         }
  7.  }
  8.  
  9. +/* Presence bits are heavily used in CSN.1: { 0 | 1 < field > } */
  10. +function f_pres_bit(template (omit) anytype field) return BIT1
  11. +{
  12. +       if (not istemplatekind(field, "omit")) {
  13. +               return '1'B;
  14. +       } else {
  15. +               return '0'B;
  16. +       }
  17. +}
  18. +
  19. +/* Unfortunately, this trick does not work:
  20. + * TITAN error: Reference to non-existent field `OCT1' in union template for type `@Osmocom_Types.anytype'
  21. + * TITAN note: @Osmocom_Types.anytype has no fields */
  22. +testcase TC_f_pres_bit() runs on CT_TUWAT {
  23. +       var template (omit) OCT1 field;
  24. +       var BIT1 field_ind;
  25. +
  26. +       field := '2B'O;
  27. +       field_ind := f_pres_bit({ OCT1 := field });
  28. +       log("Test #1: field=", field, " field_ind=", field_ind);
  29. +
  30. +       field := omit;
  31. +       field_ind := f_pres_bit({ OCT1 := field });
  32. +       log("Test #2: field=", field, " field_ind=", field_ind);
  33. +}
  34. +
  35.  
  36.  } with { encode "RAW"; variant "FIELDORDER(msb)" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement