From 36b13a3d27d70105eab9897fc6b9b025500a1da7 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 14 May 2018 13:55:33 -0700 Subject: [PATCH] fix protocol functions with arguments It invoking functions that take arguments via the protocol was temporarily broken. Such functions were invoked with undefined arguments (usually 0). --- Firmware/communication/protocol.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Firmware/communication/protocol.hpp b/Firmware/communication/protocol.hpp index 87ef82cc..f51fc2de 100644 --- a/Firmware/communication/protocol.hpp +++ b/Firmware/communication/protocol.hpp @@ -812,6 +812,18 @@ public: LOG_PROTO("my tuple is at %x and of size %u\r\n", (uintptr_t)&in_args_, sizeof(in_args_)); } + // The custom copy constructor is needed because otherwise the + // input_properties_ and output_properties_ would point to memory + // locations of the old object. + ProtocolFunction(const ProtocolFunction& other) : + name_(other.name_), obj_(other.obj_), func_ptr_(other.func_ptr_), + input_names_{other.input_names_}, output_names_{other.output_names_}, + input_properties_(PropertyListFactory::template make_property_list<0>(input_names_, in_args_)), + output_properties_(PropertyListFactory::template make_property_list<0>(output_names_, out_args_)) + { + LOG_PROTO("COPIED! my tuple is at %x and of size %u\r\n", (uintptr_t)&in_args_, sizeof(in_args_)); + } + void write_json(size_t id, StreamSink* output) { // write name write_string("{\"name\":\"", output);