Skip to content

Commit c765552

Browse files
committed
unify the bitmask output code
the standard does not seem to allow an odd number of nibbles (i.e., the examples featuring an odd number of nibbles do not pass XML validation using the XSD), so we use the same code for printing bit masks for `POS-RESPONSE-SUPPRESSABLE` as for diag services. this patch was inspired by one of [at]kayoub5's comments; thanks! Signed-off-by: Andreas Lauser <[email protected]>
1 parent 866b543 commit c765552

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

odxtools/templates/macros/printService.xml.jinja2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
{%- macro printPosResponseSuppressible(prs) -%}
1010
<POS-RESPONSE-SUPPRESSABLE>
11-
<BIT-MASK>{{ hex(prs.bit_mask).lower() }}</BIT-MASK>
11+
{%- set num_nibbles = (prs.bit_mask.bit_length() + 7) // 8 * 2 %}
12+
<BIT-MASK>{{ ("%%0%dX" | format(num_nibbles | int)) | format(prs.bit_mask | int) }}</BIT-MASK>
1213
{%- if prs.coded_const_snref is not none %}
1314
<CODED-CONST-SNREF SHORT-NAME="{{ prs.coded_const_snref }}" />
1415
{%- endif %}

0 commit comments

Comments
 (0)