Here is an example which should demonstrate how the lenght field is computed: The string "TESTSTRING123" precedes the string "PREFIX...SUFFIX".
P R E F I X L1 L2 D S U F L1 D
----------------------------------------------------------------------------------------
PREFIXTESTSTRING123SUFFIX 05 50 52 45 46 49 58 E0 04 16 02 53 55 46 20 12 40 42 00
PREFIXTESTSTRING12SUFFIX 05 50 52 45 46 49 58 E0 03 16 02 53 55 46 20 11 40 41 00
PREFIXTESTSTRING1SUFFIX 05 50 52 45 46 49 58 E0 02 16 02 53 55 46 20 10 40 40 00 33 40
PREFIXTESTSTRINGSUFFIX 05 50 52 45 46 49 58 E0 01 16 02 53 55 46 20 0F 40 3F 00 33 40
PREFIXTESTSTRINSUFFIX 05 50 52 45 46 49 58 E0 00 16 02 53 55 46 20 0E 40 3E 00 33 40
PREFIXTESTSTRISUFFIX 05 50 52 45 46 49 58 C0 16 02 53 55 46 20 0D 40 3D 00 33 40
PREFIXTESTSTRSUFFIX 05 50 52 45 46 49 58 A0 16 02 53 55 46 20 0C 40 3C 00 33 40
PREFIXTESTSTSUFFIX 05 50 52 45 46 49 58 80 16 02 53 55 46 20 0B 40 3B 00 33 40
PREFIXTESTSSUFFIX 05 50 52 45 46 49 58 60 16 02 53 55 46 20 0A 40 3A 00 33 40
PREFIXTESTSUFFIX 05 50 52 45 46 49 58 60 16 01 55 46 20 09 40 39 00 33 40
PREFIXTESSUFFIX 05 50 52 45 46 49 58 20 16 02 53 55 46 20 08 40 38 00 33 40
PREFIXTESUFFIX 05 50 52 45 46 49 58 20 16 01 55 46 20 07 40 37 00 33 40
PREFIXTSUFFIX 09 50 52 45 46 49 58 54 53 55 46 20 06 40 36 00 33 40