10 years, 4 months ago.

AnalogIn not working in rpc???

hi, i am trying to interface python and mbed LPC11U24 using serial rpc. i have been successful in controlling digital pins so far. but the analog controll gives me the following error:

Error: Undefined symbol mbed::Reply::putData<unsigned short>(T1) (referred from main.cpp.LPC11U24.o).

my code is as follows:

controlling analog pins

#include "mbed.h"
#include "mbed_rpc.h"
Serial pc(USBTX, USBRX);
int main() {
    // setup the classes that can be created dynamically
    RPC::add_rpc_class<RpcAnalogIn>();
    RPC::add_rpc_class<RpcDigitalIn>();
    RPC::add_rpc_class<RpcDigitalOut>();
    RpcAnalogIn rpc_ain(p19, "ain");
    RpcDigitalOut rpc_led(LED1, "led");
    // receive commands, and send back the responses
    char buf[256], outbuf[256];    
    while(1) {
        pc.gets(buf, 256);
        RPC::call(buf, outbuf);
        pc.printf("%s\n", outbuf);
    }
}

how to solve the error and why is it happening???

getting the above error because 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);
}
posted by bhavik gala 29 Jun 2014
Be the first to answer this question.