File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -81,15 +81,32 @@ static inline uint32_t @(msg_underscored_name)_encode(@(msg_c_type)* msg, uint8_
8181 , bool tao
8282# endif
8383) {
84+ @ [if msg_max_bitlen == 0 ]
85+ (void )msg;
86+ (void )buffer;
87+ # if CANARD_ENABLE_TAO_OPTION
88+ (void )tao;
89+ # endif
90+
91+ return 0 ; // 0 - length message encodes to 0 bytes
92+ @ [else ]
8493 return _@ (msg_underscored_name)_encode (msg, buffer
8594# if CANARD_ENABLE_TAO_OPTION
8695 , tao
8796# endif
8897 );
98+ @ [end if ]
8999}
90100
91101static inline bool @ (msg_underscored_name)_decode (const CanardRxTransfer* transfer, @ (msg_c_type)* msg) {
102+ @ [if msg_max_bitlen == 0 ]
103+ (void )msg;
104+
105+ // all transports accurately convey a payload length of 0 bytes so any payload is an error
106+ return transfer-> payload_len != 0 ;
107+ @ [else ]
92108 return _@ (msg_underscored_name)_decode (transfer, msg);
109+ @ [end if ]
93110}
94111
95112# if defined(CANARD_DSDLC_INTERNAL)
You can’t perform that action at this time.
0 commit comments