Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 11 months ago.
add_rpc_class member function not found
I am receiving the following error: class "mbed::Base" has no member "add_rpc_class" type name is not allowed expected an expression
on all of the lines of code within the SerialRPCInterface class function:
void SerialRPCInterface::_RegClasses(void){ //Register classes with base Base::add_rpc_class<AnalogIn>(); Base::add_rpc_class<DigitalIn>(); Base::add_rpc_class<DigitalOut>(); Base::add_rpc_class<DigitalInOut>(); Base::add_rpc_class<PwmOut>(); Base::add_rpc_class<Timer>(); Base::add_rpc_class<BusOut>(); Base::add_rpc_class<BusIn>(); Base::add_rpc_class<BusInOut>(); Base::add_rpc_class<Serial>(); //AnalogOut not avaliable on mbed LPC11U24 so only compile for other devices #if !defined(TARGET_LPC11U24) Base::add_rpc_class<AnalogOut>(); #endif }
Question relating to:
2 Answers
10 years, 8 months ago.
Hi Jez Cawley,
i was getting the same problem with analog. after exploring the code i found the following problem. AnalogIn also returns unsigned integer. in arguments.cpp file there is a reply class which is responsible for returning outputs through the putData template which doesnt have a definition to handle unsigned integer data type. solution is to add a putData template to handle it. its a plain copy paste as follows: (copy the following in arguments.cpp after the last putData template)
putData template for unsigned integer data type
// put by me to accomodate read_u16() of AnalogIn template<> void Reply::putData<unsigned short>(unsigned short uint16) { separator(); reply += sprintf(reply, "%u", uint16); }
11 years, 11 months ago.
Hi Jeremy,
I think this all changed when the RPC was moved out to be a separate class (November last year?)
I've got some of the newer code to compile ok (Emilio sent me a link to some of the RPC test code) but it's not running yet & it didn't seem to like analogue in/out objects...
Anyway, in case this might help you a bit, the following compiled OK & allowed me to manipulate some RPC objects created within the code - but so far I've not managed to be able to create new RPC objects & use them via the serial interface (via TeraTerm for example)
HTH
JezC
#include "mbed.h" #include "mbed_rpc.h" int main() { // RPC::add_rpc_class<RpcAnalogIn>(); // RPC::add_rpc_class<RpcAnalogOut>(); RPC::add_rpc_class<RpcDigitalOut>(); RPC::add_rpc_class<RpcDigitalIn>(); RPC::add_rpc_class<RpcDigitalInOut>(); RPC::add_rpc_class<RpcPwmOut>(); RPC::add_rpc_class<RpcTimer>(); RPC::add_rpc_class<RpcSPI>(); RPC::add_rpc_class<RpcSerial>(); // Instance RpcDigitalOut rpc_led(LED1, "led1"); test("/led1/write 1", ""); test("/led1/read", "1"); wait (1.0); test("/led1/write 0", ""); test("/led1/read", "0"); wait(0.5); while(1) { wait(0.1); } }
Oh... i'll try it and see if it works. But what I really want is to be able to create new rpc objects and use them. (via the python Library). Has anybody been able to get in working with the new arrangement with the RPC being a separate class...? Also I think they should update the cookbook information since those RPC instructions no longer work
posted by 19 Mar 2013