Skip to content

Commit 9b517cc

Browse files
fix decoding for parse=false (#72)
1 parent a09dbf9 commit 9b517cc

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

code-gen/templates/decoders.c.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ void receive_{{ macros.function_name(msg) }}(const can_msg_t *message, {{macros.
3838
{%- for point in msg.points %}
3939
{%- if point.name is defined %}
4040
{%- set shift = total_bits - bit_pos.value - point.size %}
41+
{%- if point.parse is not defined or point.parse is not false %}
4142
{%- if point.signed is defined and point.signed %}
4243
{%- if point.size >= 64 %}
4344
int64_t {{ point.name }}_raw = (int64_t)(data >> {{ shift }});
@@ -74,6 +75,7 @@ void receive_{{ macros.function_name(msg) }}(const can_msg_t *message, {{macros.
7475
{{macros.function_name(msg) -}}->{{ point.name }} = ({{ point.c_type }}){{ point.name }}_raw;
7576
{%- endif %}
7677
{%- endif %}
78+
{%- endif %}
7779
{%- set bit_pos.value = bit_pos.value + point.size %}
7880
{%- endif %}
7981
{%- endfor %}
@@ -87,6 +89,7 @@ void receive_{{ macros.function_name(msg) }}(const can_msg_t *message, {{macros.
8789
memcpy(&bitstream_data, message->data, sizeof(bitstream_data));
8890

8991
{% for point in msg.points -%}
92+
{% if point.parse is not defined or point.parse is not false %}
9093
{% if point.endianness is defined and point.endianness == "big" %}
9194
endian_swap(&bitstream_data.{{ point.name }}, sizeof(bitstream_data.{{ point.name }}));
9295
{% endif %}
@@ -99,6 +102,7 @@ void receive_{{ macros.function_name(msg) }}(const can_msg_t *message, {{macros.
99102
{% else %}
100103
{{macros.function_name(msg) -}}->{{ point.name }} = ({{ point.c_type }})bitstream_data.{{ point.name }};
101104
{% endif %}
105+
{% endif %}
102106
{% endfor %}
103107
{%- endif %}
104108
}

code-gen/templates/decoders.h.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% for msg in can_msgs %}
88
typedef struct {
99
{% for point in msg.points -%}
10-
{% if point.name is defined %} {{ point.c_type }} {{ point.name }};
10+
{% if point.name is defined and (point.parse is not defined or point.parse is not false) %} {{ point.c_type }} {{ point.name }};
1111
{% endif -%}
1212
{% endfor -%}
1313
} {{ macros.function_name(msg) -}}_t;

0 commit comments

Comments
 (0)