From ebb1e79d46cbea5def1bcb7c54346e6e44e4c830 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 3 Apr 2019 11:06:52 +0200 Subject: NanoPB benchmark generator: add encode/decode of float values --- lib/protocol_benchmarks.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/protocol_benchmarks.py b/lib/protocol_benchmarks.py index 2761699..c509e83 100755 --- a/lib/protocol_benchmarks.py +++ b/lib/protocol_benchmarks.py @@ -881,6 +881,12 @@ class NanoPB(DummyProtocol): self.enc_buf += 'msg.{}{} = {};\n'.format(self.cc_prefix, key, value) self.dec_buf += 'kout << msg.{}{};\n'.format(self.cc_prefix, key) self.assign_and_kout(self.int_type, 'msg.{}{}'.format(self.cc_prefix, key)) + elif fieldtype == float: + if cardinality == 'optional': + self.enc_buf += 'msg.{}has_{} = true;\n'.format(self.cc_prefix, key) + self.enc_buf += 'msg.{}{} = {};\n'.format(self.cc_prefix, key, value) + self.dec_buf += 'kout << msg.{}{};\n'.format(self.cc_prefix, key) + self.assign_and_kout(self.float_type, 'msg.{}{}'.format(self.cc_prefix, key)) elif fieldtype == dict: if cardinality == 'optional': self.enc_buf += 'msg.{}has_{} = true;\n'.format(self.cc_prefix, key) -- cgit v1.2.3