arduino / ArduinoCore-mbed

348 stars 202 forks source link

Parameter type enhancements for strings #961

Open razvanphp opened 1 month ago

razvanphp commented 1 month ago

I have a rather basic need to pass strings in between the cores via RPC, which actually represent a JSON.

I know those changes are probably meant in other repositories, but the use-case is in the context of RPC.

/Users/razvan/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.1.5/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());
     ~~^~~~~~~~~~~~~~

and

/Users/razvan/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.1.5/libraries/rpclib/src/rpc/msgpack/v1/object.hpp:213:7:
error: request for member 'msgpack_unpack' in 'v', which is of non-class type 'const char'
     v.msgpack_unpack(o.convert());
     ~~^~~~~~~~~~~~~~

It compiles with std::string tho.

iabdalkader commented 1 month ago

This repo is for Arduino Python libraries, it has nothing to do with this issue, so I'm transferring here. If strings can't be packed/unpacked try using std::vector<byte>. You can also read/write to raw channel, see the pinpong example RPC.write(&buf[0], sizeof(buf)); where buf is uint8_t array.