Hi all,
I'm trying to pass a string from the M7 to M4 processor.
In M4 I have a Webclient that call a webservice passing data supplyed from M7.
I try this sketch:
#include "Arduino.h"
#include "RPC.h"
int c = 0;
#ifdef CORE_CM4
//this is just for CM4
String receiveStringFromM7(arduino::String str);
int i = 0;
// *****************************************
int32_t add(int32_t a, int32_t b) {
int val = a + b;
String st = " M4: calling add" + (String)val;
RPC.println(st);
return a + b;
}
// Implementation of function on M4
String receiveStringFromM7(arduino::String str) {
char charArray[str.length() + 1];
str.toCharArray(charArray, sizeof(charArray));
Serial.print("M4 received string: ");
Serial.println(charArray);
// reply to M7
String response = "M4: received string - ";
response += str;
return response;
}
#endif
// *****************************************
void setup() {
//for both cores using RPC
RPC.begin();
#ifdef CORE_CM7
Serial.begin(115200);
while (!Serial) {}
Serial.println("CM7: release and boot CM4");
//boot CM4
//-->it has to be done in order to release CM4 !!
LL_RCC_ForceCM4Boot();
#endif
#ifdef CORE_CM4
RPC.bind("add", add);
RPC.bind("receiveStringFromM7", receiveStringFromM7);
#endif
}
void loop() {
// put your main code here, to run repeatedly:
#ifdef CORE_CM7
//this is the CM7 main thread
char strArg[] = "Hello, World!";
arduino::String strToSend = strArg;
String responseFromM4 = RPC.call("receiveStringFromM7", strToSend).as<String>();
Serial.print("M7: Received reply from M4: ");
Serial.println(responseFromM4);
//Serial.print(" M7: Calling add | ");
//auto res = RPC.call("add", (int32_t)c, (int32_t)100).as<int32_t>();
//Serial.println(res);
//while (RPC.available()) {
// Serial.write(RPC.read());
//}
//c++;
#else
//The CM4 does nothing
#endif
}
The demo function "add" works fine but if I try to change the type of data
from int to String I receive an error in compile:
In file included from C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/object.hpp:15:0,
from C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack.hpp:23,
from C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.h:12,
from C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\RPC\src/RPC.h:13,
from C:\Users\infor\AppData\Local\Temp\.arduinoIDE-unsaved202396-3076-5hjbjx.vu0ue\sketch_oct6f\sketch_oct6f.ino:2:
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/object.hpp: In instantiation of 'void clmdep_msgpack::v1::adaptor::object_with_zone<T, Enabler>::operator()(clmdep_msgpack::v1::object::with_zone&, const T&) const [with T = arduino::String; Enabler = void]':
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/adaptor/adaptor_base.hpp:101:51: required from 'typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value)>::type clmdep_msgpack::v1::operator<<(clmdep_msgpack::v1::object::with_zone&, const T&) [with T = arduino::String; typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value)>::type = void]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/object.hpp:632:31: required from 'clmdep_msgpack::v1::object::object(const T&, clmdep_msgpack::v1::zone&) [with T = arduino::String]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v2/object_fwd.hpp:49:64: required from 'clmdep_msgpack::v2::object::object(const T&, clmdep_msgpack::v1::zone&) [with T = arduino::String]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:74:39: required from 'rpc::detail::dispatcher::bind(const string&, F, const rpc::detail::tags::nonvoid_result&, const rpc::detail::tags::nonzero_arg&)::<lambda(const clmdep_msgpack::v2::object&)> [with F = arduino::String (*)(arduino::String)]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:68:41: required from 'struct rpc::detail::dispatcher::bind(const string&, F, const rpc::detail::tags::nonvoid_result&, const rpc::detail::tags::nonzero_arg&) [with F = arduino::String (*)(arduino::String); std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const struct clmdep_msgpack::v2::object&)>'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:67:33: required from 'void rpc::detail::dispatcher::bind(const string&, F, const rpc::detail::tags::nonvoid_result&, const rpc::detail::tags::nonzero_arg&) [with F = arduino::String (*)(arduino::String); std::__cxx11::string = std::__cxx11::basic_string<char>]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:7:5: required from 'void rpc::detail::dispatcher::bind(const string&, F) [with F = arduino::String (*)(arduino::String); std::__cxx11::string = std::__cxx11::basic_string<char>]'
C:\Users\infor\AppData\Local\Temp\.arduinoIDE-unsaved202396-3076-5hjbjx.vu0ue\sketch_oct6f\sketch_oct6f.ino:69:54: required from here
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/object.hpp:229:7: error: 'const class arduino::String' has no member named 'msgpack_object'
v.msgpack_object(static_cast<clmdep_msgpack::object*>(&o), o.zone);
~~^~~~~~~~~~~~~~
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/object.hpp: In instantiation of 'const clmdep_msgpack::v2::object& clmdep_msgpack::v1::adaptor::convert<T, Enabler>::operator()(const clmdep_msgpack::v2::object&, T&) const [with T = arduino::String; Enabler = void]':
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/adaptor/adaptor_base.hpp:58:49: required from 'typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value), const clmdep_msgpack::v2::object&>::type clmdep_msgpack::v1::operator>>(const clmdep_msgpack::v2::object&, T&) [with T = arduino::String; typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value), const clmdep_msgpack::v2::object&>::type = const clmdep_msgpack::v2::object&]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/object.hpp:549:31: required from 'typename std::enable_if<((! std::is_array< <template-parameter-1-1> >::value) && (! std::is_pointer<_Tp>::value)), T&>::type clmdep_msgpack::v1::object::convert(T&) const [with T = arduino::String; typename std::enable_if<((! std::is_array< <template-parameter-1-1> >::value) && (! std::is_pointer<_Tp>::value)), T&>::type = arduino::String&]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v2/object_fwd.hpp:60:56: required from 'T& clmdep_msgpack::v2::object::convert(T&) const [with T = arduino::String]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/adaptor/cpp11/tuple.hpp:97:13: required from 'static void clmdep_msgpack::v1::StdTupleConverter<Tuple, N>::convert(const clmdep_msgpack::v2::object&, Tuple&) [with Tuple = std::tuple<arduino::String>&; unsigned int N = 1]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/adaptor/cpp11/tuple.hpp:126:65: required from 'const clmdep_msgpack::v2::object& clmdep_msgpack::v1::adaptor::convert<std::tuple<_Tps ...> >::operator()(const clmdep_msgpack::v2::object&, std::tuple<_Tps ...>&) const [with Args = {arduino::String}]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/adaptor/adaptor_base.hpp:58:49: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v2/object_fwd.hpp:60:56: required from 'T& clmdep_msgpack::v2::object::convert(T&) const [with T = std::tuple<arduino::String>]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:72:9: required from 'rpc::detail::dispatcher::bind(const string&, F, const rpc::detail::tags::nonvoid_result&, const rpc::detail::tags::nonzero_arg&)::<lambda(const clmdep_msgpack::v2::object&)> [with F = arduino::String (*)(arduino::String)]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:68:41: required from 'struct rpc::detail::dispatcher::bind(const string&, F, const rpc::detail::tags::nonvoid_result&, const rpc::detail::tags::nonzero_arg&) [with F = arduino::String (*)(arduino::String); std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const struct clmdep_msgpack::v2::object&)>'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:67:33: required from 'void rpc::detail::dispatcher::bind(const string&, F, const rpc::detail::tags::nonvoid_result&, const rpc::detail::tags::nonzero_arg&) [with F = arduino::String (*)(arduino::String); std::__cxx11::string = std::__cxx11::basic_string<char>]'
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/dispatcher.inl:7:5: required from 'void rpc::detail::dispatcher::bind(const string&, F) [with F = arduino::String (*)(arduino::String); std::__cxx11::string = std::__cxx11::basic_string<char>]'
C:\Users\infor\AppData\Local\Temp\.arduinoIDE-unsaved202396-3076-5hjbjx.vu0ue\sketch_oct6f\sketch_oct6f.ino:69:54: required from here
C:\Users\infor\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\4.0.8\libraries\rpclib\src/rpc/msgpack/v1/object.hpp:213:7: error: 'class arduino::String' has no member named 'msgpack_unpack'
v.msgpack_unpack(o.convert());
~~^~~~~~~~~~~~~~
*******************************
I tried to change String to char[] array without success.
Whats the 'msgpack_unpack'?
how can i implement it in the String class?
There are some other workaround or suggestions to achieve my goal?
Many thanks in advance
Paolo