Printer FriendlyEmail Article Link

TTworkbench: How to modify my template so that such a response would fail?

Environment/Versions
TTworkbench 32/64 Bit Linux/Windows
Answer
The type definition:
type record RAPDU {
BYTE_ARRAY data optional,
WORD SW optional
}

The example template:
template RAPDU SW_OK_ONLY := {
data := ' 'O,
SW := '9000'O
}

The template doesn't catch such a bug if there are extra bytes following '9000'O.
For example, a response like '900001020304'O.

How to modify my template so that such a response would fail?

If there is only one expected template with field data and SW and you decode in your decoder just the
2 Bytes 90 00, the template matches because the rest of the message will be ignored.

There are two options to solve the problem:
  • Change the decoder by returning null if the message length does not equal the decoded number of bytes.
  • Add a template field and set it to omit and decode here the last 4 Bytes '01020304'O.
In both cases the template will not match and catch the buggy response '900001020304'O.

Product : TTCN-3 Language